Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Imports System.Data
- Imports System.Data.SqlClient
- Imports Datex.Common.Corporate.Users
- Imports ClientLibrary.Web.UI
- Imports ClientLibrary.Properties
- Imports System.Collections.Generic
- Imports ClientLibrary
- Imports ClientLibrary.Properties.RM
- Imports Datex.Common.Corporate.Users.Roles
- Imports Telerik.Web.UI
- Partial Class e_UserRole
- Inherits ClientPageBS
- #Region " Web Form Designer Generated Code "
- 'This call is required by the Web Form Designer.
- <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
- End Sub
- Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init
- 'CODEGEN: This method call is required by the Web Form Designer
- 'Do not modify it using the code editor.
- InitializeComponent()
- End Sub
- #End Region
- #Region " Value Storing Properties "
- Protected Property UserRoleID() As Int16
- Get
- Return CInt(Me.ViewState("userroleid"))
- End Get
- Set(ByVal Value As Int16)
- Me.ViewState("userroleid") = Value
- End Set
- End Property
- Protected Property UserID() As Int16
- Get
- Return CInt(Me.ViewState("userid"))
- End Get
- Set(ByVal Value As Int16)
- Me.ViewState("userid") = Value
- End Set
- End Property
- Protected Property RoleID() As Integer
- Get
- Return Me.ViewState("roleid")
- End Get
- Set(ByVal value As Integer)
- Me.ViewState("roleid") = value
- End Set
- End Property
- Protected Const m_Action As String = "a"
- Protected Property Action() As String
- Get
- Dim state As String = CStr(Me.ViewState("action"))
- If state = "" Then
- Return m_Action
- Else
- Return state
- End If
- End Get
- Set(ByVal Value As String)
- Me.ViewState("action") = Value
- End Set
- End Property
- 'BASE-2869
- Protected Property DoesCommercialManagement As Boolean
- Get
- Return Me.ViewState("DoesCommercialManagement")
- End Get
- Set(ByVal value As Boolean)
- Me.ViewState("DoesCommercialManagement") = value
- End Set
- End Property
- Protected Property DoesResidentialManagement As Boolean
- Get
- Return Me.ViewState("DoesResidentialManagement")
- End Get
- Set(ByVal value As Boolean)
- Me.ViewState("DoesResidentialManagement") = value
- End Set
- End Property
- Dim dynamicDict As New Dictionary(Of String, String)
- #End Region
- Private Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs) Handles MyBase.Load
- If Not Page.IsPostBack Then
- 'BASE-2869
- DoesCommercialManagement = False
- Boolean.TryParse(ConfigurationManager.AppSettings("DoesCommercialManagement"), DoesCommercialManagement)
- DoesResidentialManagement = False
- Boolean.TryParse(ConfigurationManager.AppSettings("DoesResidentialManagement"), DoesResidentialManagement)
- If DoesCommercialManagement Then
- FillBuildings()
- End If
- If DoesResidentialManagement Then
- PopulateApartmentSelect()
- End If
- FillRoles()
- FillUsers()
- FillEntities()
- 'There should be a userid that is available to us
- UserID = Request.QueryString("userid")
- UserRoleID = Request.QueryString("userroleid")
- RoleID = Request.QueryString("roleid")
- 'Go by action
- If UserRoleID = 0 Then
- 'If UserRoleID = 0 AND UserID = 0, we have an 'ADD USER TO ROLE' case
- If UserID = 0 Then
- lstUsers.Enabled = True
- lstRole.Enabled = False
- lstRole.SelectedValue = RoleID
- Else 'If UserRoleID = 0 but a User exists, we have a 'ADD ROLE TO USER' case
- lstUsers.Items.FindByValue(UserID).Selected = True
- lstRole.Enabled = True
- lstUsers.Enabled = False
- End If
- 'Add a please select to the roles
- lstRole.Items.Insert(0, New ListItem("Please Select", "-1"))
- 'Hide the buildings by default
- pnlCommercialBuildings.Visible = False
- pnlCommercialDynamic.Visible = False
- pnlResidentialDynamic.Visible = False
- pnlResidentialSelect.Visible = False
- ViewState("header") = "Add Role"
- Else 'The UserRoleID exists
- 'Grab the user role id from the querystring
- UserRoleID = CInt(Request.QueryString("userroleid"))
- 'Grab the User Role
- Dim r As New UserRole(UserRoleID)
- 'Select their role
- 'Try
- lstRole.Items.FindByValue(r.RoleID).Selected = True
- lstUsers.Items.FindByValue(r.UserID).Selected = True
- lstRole.Enabled = False
- lstUsers.Enabled = False
- 'Catch
- 'We couldn't find it, so add a please select
- 'lstRole.Items.Insert(0, New ListItem("Please Select", "-1"))
- 'lstRole.Enabled = True
- 'End Try
- 'Check for the is main
- If r.IsMain Then
- chkIsMain.Checked = True
- Else
- chkIsMain.Checked = False
- End If
- If DoesCommercialManagement Then
- 'Check to see if the role uses buildings
- If r.Role.BldgAccess = 1 Then 'selected
- lblRole.Text = " Selected Buildings <br/> To change, go to User Settings/Manage Roles"
- pnlCommercialBuildings.Visible = True
- pnlCommercialDynamic.Visible = False
- 'Grab the buildings they've previously selected
- 'Dim mRBC As New RoleBuildingCollection(r.UserRoleID)
- 'For Each b As RoleBuilding In mRBC
- ' Try
- ' lstPropertySource.Transfer(lstPropertySource.FindItemByValue(Trim(b.BldgID)), lstPropertySource, lstPropertyDestination)
- ' Catch : End Try
- 'Next
- 'Base-3853 Load Select2 for buildings
- Page.ClientScript.RegisterStartupScript(
- Me.GetType(),
- "checkPostback",
- "loadBuildingsForUser('" & r.UserRoleID & "')", True)
- ElseIf r.Role.BldgAccess = 2 Then 'dynamic
- pnlCommercialDynamic.Visible = True
- pnlCommercialBuildings.Visible = False
- Dim mRole As New Role(lstRole.SelectedValue)
- Select Case r.Role.DynamicRole
- Case "LEASING AGENT"
- lblKeyValue.Text = "Please select a Leasing Agent"
- Case "MANAGER"
- lblKeyValue.Text = "Please select a Property Manager"
- Case "PROP ACCT."
- lblKeyValue.Text = "Please select a Property Accountant"
- Case "REGION"
- lblKeyValue.Text = "Please select a Region"
- Case "ASSET MANAGER"
- lblKeyValue.Text = "Please select an Asset Manager"
- End Select
- lblRole.Text = " Dynamic Buildings(" & mRole.DynamicRole & ") <br/> To change, go to User Settings/Manage Roles"
- ViewState("dynamicrole") = mRole.DynamicRole
- 'BASE-7253
- dynamicDict.Add("DynamicRole", mRole.DynamicRole)
- dynamicDict.Add("Dropdown", "ddlDynamic")
- BindKeyNames()
- ddlDynamic.Items.Insert(0, New ListItem("Select One", 0))
- Page.ClientScript.RegisterStartupScript(
- Me.GetType(),
- "checkPostback",
- "loadDynamicKeynameRoles('" & mRole.DynamicRole & "'" & ",'" & Me.UserID & "'" & ",'" & r.RoleID & "'" & ")", True)
- Try
- ddlDynamic.SelectedValue = r.KeyValue
- dynamicDict.Add("SelectedValue", r.KeyValue)
- Catch ex As Exception
- End Try
- ElseIf r.Role.BldgAccess = 4 Then '
- lblRole.Text = " Selected Entities <br/> To change, go to User Settings/Manage Roles"
- pnlEntities.Visible = True
- pnlCommercialBuildings.Visible = False
- pnlCommercialDynamic.Visible = False
- Page.ClientScript.RegisterStartupScript(
- Me.GetType(),
- "checkPostback",
- "loadEntitiesForUser('" & r.UserRoleID & "')", True)
- Else
- lblRole.Text = "This role has access to all buildings. <br /> To change, go to Administration > User Administration > Manage Roles"
- pnlCommercialDynamic.Visible = False
- pnlCommercialBuildings.Visible = False
- End If
- End If
- If DoesResidentialManagement Then
- 'Check to see if the role uses Apartments
- If r.Role.ApartmentAccess = 1 Then 'selected
- lblRole.Text = " Selected Apartments <br/> To change, go to User Settings/Manage Roles"
- pnlResidentialSelect.Visible = True
- pnlResidentialDynamic.Visible = False
- 'Base-3853 Load Select2 for apartments
- Page.ClientScript.RegisterStartupScript(
- Me.GetType(),
- "checkPostback",
- "loadApartmentsForUser('" & r.UserRoleID & "')", True)
- ElseIf r.Role.ApartmentAccess = 2 Then 'dynamic
- pnlResidentialDynamic.Visible = True
- pnlResidentialSelect.Visible = False
- Dim role As New Role(lstRole.SelectedValue)
- Select Case r.Role.DynamicRole
- Case "RM MANAGER"
- lblResidentialKeyValue.Text = "Please select a Residential Manager:"
- End Select
- lblRole.Text = " Dynamic Apartments(" & role.DynamicRole & ") <br/> To change, go to User Settings/Manage Roles"
- ViewState("dynamicrole") = role.DynamicRole
- 'BASE-7253
- dynamicDict.Add("DynamicRole", role.DynamicRole)
- dynamicDict.Add("Dropdown", "ddlResidentialDynamic")
- BindKeyNames()
- ddlResidentialDynamic.Items.Insert(0, New ListItem("Select One", 0))
- Try
- ddlResidentialDynamic.SelectedValue = r.KeyValue
- dynamicDict.Add("SelectedValue", r.KeyValue)
- Catch ex As Exception
- End Try
- Page.ClientScript.RegisterStartupScript(
- Me.GetType(),
- "checkPostback",
- "loadDynamicKeynameRoles('" & role.DynamicRole & "'" & ",'" & Me.UserID & "'" & ",'" & r.RoleID & "'" & ")", True)
- ElseIf r.Role.ApartmentAccess = 4 Then '
- lblRole.Text = " Selected Entities <br/> To change, go to User Settings/Manage Roles"
- pnlEntities.Visible = True
- pnlResidentialSelect.Visible = False
- pnlResidentialDynamic.Visible = False
- Page.ClientScript.RegisterStartupScript(
- Me.GetType(),
- "checkPostback",
- "loadEntitiesForUser('" & r.UserRoleID & "')", True)
- Else
- 'BASE-7252
- 'Since this is page is handling both cases of Commercial / Residential
- 'We need to check if there is a BldgAccess Role currently
- 'Otherwise, in this else case it will change the lblRole.Text when it shouldn't.
- If String.IsNullOrEmpty(r.Role.BldgAccess) Then
- lblRole.Text = "This role has access to all properties. <br /> To change, go to Administration > User Administration > Manage Roles"
- End If
- pnlResidentialDynamic.Visible = False
- pnlResidentialSelect.Visible = False
- End If
- End If
- ViewState("header") = "Edit Role"
- End If
- lblRole.Font.Bold = True
- lblRole.Font.Italic = True
- 'Set the action of the cancel button
- cmdCancel.Attributes.Add("OnClick", "Javascript: self.close();")
- End If
- 'Setup the base page
- MyBase.Title = ConfigurationManager.AppSettings("CompanyName") & " - " & ViewState("header")
- MyBase.PageHeaderText = ViewState("header")
- MyBase.IsDialog = True
- End Sub
- Private Sub FillEntities()
- Dim dt As New DataTable
- Using dv = Entity.GetEntities()
- dt = dv.ToTable
- dt.Columns.Add("ENTITYNAMEWITHID", GetType(System.String), "ENTITYID + ' - ' + ENTITYNAME")
- lstEntitiesSource.DataSource = dt
- lstEntitiesSource.DataTextField = "ENTITYNAMEWITHID"
- lstEntitiesSource.DataValueField = "EntityId"
- lstEntitiesSource.DataBind()
- End Using
- End Sub
- Private Sub FillRoles()
- Dim mRC As List(Of Role) = Role.GetRoles(True)
- Me.lstRole.DataSource = mRC
- Me.lstRole.DataTextField = "RoleName"
- Me.lstRole.DataValueField = "RoleID"
- Me.lstRole.DataBind()
- End Sub
- Private Sub FillBuildings()
- Dim buildings As List(Of Building) = Building.GetBuildingNames()
- Me.lstPropertySource.DataSource = buildings
- Me.lstPropertySource.DataTextField = "BuildingName"
- Me.lstPropertySource.DataValueField = "BuildingID"
- Me.lstPropertySource.DataBind()
- End Sub
- Private Sub PopulateApartmentSelect()
- Dim apartments As List(Of Apartment) = Apartment.GetApartments(True)
- rlbApartmentSource.DataSource = apartments
- rlbApartmentSource.DataTextField = "PropName"
- rlbApartmentSource.DataValueField = "RMPropID"
- rlbApartmentSource.DataBind()
- End Sub
- Private Sub BindKeyNames()
- If DoesCommercialManagement Then
- Dim rss As SqlDataReader = Datex.Common.Corporate.Users.Role.getKeyNameByRolenames(Me.ViewState("dynamicrole"))
- Me.ddlDynamic.DataSource = rss
- Me.ddlDynamic.DataTextField = "Description"
- Me.ddlDynamic.DataValueField = "Keyname"
- Me.ddlDynamic.DataBind()
- rss.Close()
- End If
- If DoesResidentialManagement Then
- Dim residentialDynamicRoles = Role.GetResidentialKeyNamesByRoleName(CType(ViewState("dynamicrole"), String))
- ddlResidentialDynamic.DataSource = residentialDynamicRoles
- ddlResidentialDynamic.DataTextField = "Description"
- ddlResidentialDynamic.DataValueField = "Keyname"
- ddlResidentialDynamic.DataBind()
- End If
- Dim jsonString As String = Newtonsoft.Json.JsonConvert.SerializeObject(dynamicDict)
- hdnDynamicRole.Value = jsonString
- End Sub
- Private Sub FillUsers()
- Dim users As List(Of DatexUser) = Datex.Common.Corporate.Users.DatexUser.GetUsers(1)
- Me.lstUsers.DataSource = users
- Me.lstUsers.DataTextField = "FullName"
- Me.lstUsers.DataValueField = "UserID"
- Me.lstUsers.DataBind()
- End Sub
- Private Sub lstRole_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles lstRole.SelectedIndexChanged
- 'Get the current selected value
- Dim m_SelectedValue As Int16 = CInt(Me.lstRole.SelectedItem.Value)
- If m_SelectedValue > 0 Then
- Dim r As New Role(m_SelectedValue)
- If DoesCommercialManagement Then
- If r.BldgAccess = 0 Then 'All
- pnlBuildings.Visible = False
- pnlDynamic.Visible = False
- pnlEntities.Visible = False
- pnlResidentialDynamic.Visible = False
- pnlResidentialSelect.Visible = False
- Me.lblRole.Text = "All Buildings <br/> To change, go to User Settings/Manage Roles"
- ElseIf r.BldgAccess = 1 Then 'Selected
- Me.pnlBuildings.Visible = True
- Me.pnlDynamic.Visible = False
- Me.pnlResidentialDynamic.Visible = False
- Me.pnlResidentialSelect.Visible = False
- pnlEntities.Visible = False
- Me.lblRole.Text = "Selected Buildings <br/> To change, go to User Settings/Manage Roles"
- 'Base-3853 Load all apartments into Select2
- 'For user to select from
- Page.ClientScript.RegisterStartupScript(
- Me.GetType(),
- "checkPostback",
- "loadAllBuildings()", True)
- ElseIf r.BldgAccess = 2 Then 'Dynamic
- <<<<<<< HEAD
- Me.pnlDynamic.Visible = True
- Me.pnlBuildings.Visible = False
- Me.pnlResidentialDynamic.Visible = False
- Me.pnlResidentialSelect.Visible = False
- Me.pnlEntities.Visible = False
- =======
- Me.pnlCommercialBuildings.Visible = False
- Me.pnlCommercialDynamic.Visible = True
- >>>>>>> origin/MRK2
- Me.ViewState("dynamicrole") = r.DynamicRole
- dynamicDict.Add("DynamicRole", r.DynamicRole)
- dynamicDict.Add("Dropdown", "ddlDynamic")
- BindKeyNames()
- Me.lblRole.Text = " Dynamic Buildings(" & r.DynamicRole & ") <br/> To change, go to User Settings/Manage Roles"
- Select Case r.DynamicRole
- Case "LEASING AGENT"
- lblKeyValue.Text = "Please select a Leasing Agent"
- Case "MANAGER"
- lblKeyValue.Text = "Please select a Property Manager"
- Case "PROP ACCT."
- lblKeyValue.Text = "Please select a Property Accountant"
- Case "REGION"
- lblKeyValue.Text = "Please select a Region"
- Case "ASSET MANAGER"
- lblKeyValue.Text = "Please select an Asset Manager"
- End Select
- 'Base-984 mtr support for multiple entities
- Page.ClientScript.RegisterStartupScript(
- Me.GetType(),
- "checkPostback",
- "loadDynamicKeynameRoles('" & r.DynamicRole & "'" & ",'" & 0 & "'" & ")", True)
- ElseIf r.BldgAccess = 4 Then
- pnlEntities.Visible = True
- <<<<<<< HEAD
- pnlBuildings.Visible = False
- pnlDynamic.Visible = False
- pnlResidentialDynamic.Visible = False
- pnlResidentialSelect.Visible = False
- =======
- pnlCommercialBuildings.Visible = False
- pnlCommercialDynamic.Visible = False
- >>>>>>> origin/MRK2
- lblRole.Text = "Selected Entities <br/> To change, go to User Settings/Manage Roles"
- Page.ClientScript.RegisterStartupScript(
- Me.GetType(),
- "checkPostback",
- "loadEntitiesForUser('" & UserRoleID & "')", True)
- End If
- End If
- 'Residential
- If DoesResidentialManagement Then
- If r.ApartmentAccess = 0 Then 'All
- pnlResidentialSelect.Visible = False
- pnlResidentialDynamic.Visible = False
- pnlBuildings.Visible = False
- pnlDynamic.Visible = False
- pnlEntities.Visible = False
- lblRole.Text = "All Apartments <br/> To change, go to User Settings/Manage Roles"
- ElseIf r.ApartmentAccess = 1 Then 'Selected
- pnlResidentialSelect.Visible = True
- pnlResidentialDynamic.Visible = False
- pnlBuildings.Visible = False
- pnlDynamic.Visible = False
- pnlEntities.Visible = False
- lblRole.Text = "Selected Apartments <br/> To change, go to User Settings/Manage Roles"
- 'Base-3853 Load all apartments into Select2
- 'For user to select from
- Page.ClientScript.RegisterStartupScript(
- Me.GetType(),
- "checkPostback",
- "loadAllApartments()", True)
- ElseIf r.ApartmentAccess = 2 Then 'Dynamic
- pnlResidentialDynamic.Visible = True
- pnlResidentialSelect.Visible = False
- pnlBuildings.Visible = False
- pnlDynamic.Visible = False
- pnlEntities.Visible = False
- ViewState("dynamicrole") = r.DynamicRole
- 'BASE-7253
- dynamicDict.Add("DynamicRole", r.DynamicRole)
- dynamicDict.Add("Dropdown", "ddlResidentialDynamic")
- BindKeyNames()
- lblRole.Text = " Dynamic Apartments(" & r.DynamicRole & ") <br/> To change, go to User Settings/Manage Roles"
- Select Case r.DynamicRole
- Case "RM MANAGER"
- lblKeyValue.Text = "Please select a Residential Manager"
- End Select
- Page.ClientScript.RegisterStartupScript(
- Me.GetType(),
- "checkPostback",
- "loadDynamicKeynameRoles('" & r.DynamicRole & "'" & ",'" & Me.UserID & "'" & ",'" & r.RoleID & "'" & ")", True)
- 'Base-984 mtr support for multiple entities
- ElseIf r.ApartmentAccess = 4 Then
- pnlEntities.Visible = True
- <<<<<<< HEAD
- pnlBuildings.Visible = False
- pnlDynamic.Visible = False
- pnlResidentialDynamic.Visible = False
- pnlResidentialSelect.Visible = False
- =======
- pnlResidentialSelect.Visible = False
- pnlResidentialDynamic.Visible = False
- >>>>>>> origin/MRK2
- lblRole.Text = "Selected Entities <br/> To change, go to User Settings/Manage Roles"
- Page.ClientScript.RegisterStartupScript(
- Me.GetType(),
- "checkPostback",
- "loadEntitiesForUser('" & UserRoleID & "')", True)
- End If
- End If
- Else
- pnlBuildings.Visible = False
- pnlDynamic.Visible = False
- pnlEntities.Visible = False
- pnlResidentialDynamic.Visible = False
- pnlResidentialSelect.Visible = False
- Me.lblRole.Text = ""
- End If
- End Sub
- Private Sub cmdSave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdSave.Click
- 'Setup an empty container
- Dim r As UserRole
- 'Check to see what we're doing
- If Me.UserRoleID = 0 Then 'SETTING ME.USERID <> 0 FIXES ADD USER AND ADD ROLE; SETTING ME.USERID = 0 FIXES EDIT ROLE
- Dim strList() As String = hdnDynamicRoleList.Value.Split(",")
- If strList.GetLength(0) > 0 Then
- 'Need to remove the current dynamic roles assigned to that user
- UserRoleCollection.DeleteDynamicRolesByUserId(Me.lstUsers.SelectedItem.Value, Me.lstRole.SelectedItem.Value)
- For Each s As String In strList
- r = New UserRole
- r.RoleID = Me.lstRole.SelectedItem.Value
- r.IsMain = Me.chkIsMain.Checked
- r.UserID = Me.lstUsers.SelectedItem.Value
- Dim mRole As New Role(r.RoleID)
- If mRole.BldgAccess = 2 Then
- r.KeyValue = s
- End If
- If mRole.ApartmentAccess = 2 Then
- r.KeyValue = s
- End If
- r.Save()
- Next
- Else
- r = New UserRole
- 'Fill in the basics of it
- r.RoleID = Me.lstRole.SelectedItem.Value
- r.IsMain = Me.chkIsMain.Checked
- r.UserID = Me.lstUsers.SelectedItem.Value
- Dim mRole As New Role(r.RoleID)
- If mRole.BldgAccess = 2 AndAlso Me.ddlDynamic.Items.Count > 0 Then
- r.KeyValue = Me.ddlDynamic.SelectedItem.Value
- End If
- If mRole.ApartmentAccess = 2 AndAlso Me.ddlResidentialDynamic.Items.Count > 0 Then
- r.KeyValue = Me.ddlResidentialDynamic.SelectedItem.Value
- End If
- r.Save()
- End If
- Else
- Dim strList() As String = hdnDynamicRoleList.Value.Split(",")
- If strList.GetLength(0) > 0 Then
- 'Need to remove the current dynamic roles assigned to that user
- UserRoleCollection.DeleteDynamicRolesByUserId(Me.lstUsers.SelectedItem.Value, Me.lstRole.SelectedItem.Value)
- For Each s As String In strList
- r = New UserRole
- r.RoleID = Me.lstRole.SelectedItem.Value
- r.IsMain = Me.chkIsMain.Checked
- r.UserID = Me.lstUsers.SelectedItem.Value
- Dim mRole As New Role(r.RoleID)
- If mRole.BldgAccess = 2 Then
- r.KeyValue = s
- End If
- If mRole.ApartmentAccess = 2 Then
- r.KeyValue = s
- End If
- r.Save()
- Next
- Else
- r = New UserRole
- 'Fill in the basics of it
- r.RoleID = Me.lstRole.SelectedItem.Value
- r.IsMain = Me.chkIsMain.Checked
- r.UserID = Me.lstUsers.SelectedItem.Value
- Dim mRole As New Role(r.RoleID)
- If mRole.BldgAccess = 2 AndAlso Me.ddlDynamic.Items.Count > 0 Then
- r.KeyValue = Me.ddlDynamic.SelectedItem.Value
- End If
- If mRole.ApartmentAccess = 2 AndAlso Me.ddlResidentialDynamic.Items.Count > 0 Then
- r.KeyValue = Me.ddlResidentialDynamic.SelectedItem.Value
- End If
- r.Save()
- End If
- End If
- 'Save it so we know we're up to date
- 'Check to see if we're working with buildings
- If Me.pnlCommercialBuildings.Visible Then
- 'First, just make sure we don't have any buildings in the db from this user
- RoleBuildingCollection.Delete(r.UserRoleID)
- 'Base-3853
- Dim list As String() = hdnBuildingList.Value.Split(",")
- If list.Length > 0 Then
- For Each Building In list
- Dim rb As New RoleBuilding
- rb.BldgID = Building
- rb.DateAdded = DateTime.Now()
- rb.UserRoleID = r.UserRoleID
- rb.Save()
- Next
- End If
- 'Now add in the new buildings that they've selected
- 'For Each l As RadListBoxItem In Me.lstPropertyDestination.Items
- ' Dim rb As New RoleBuilding
- ' rb.BldgID = l.Value
- ' rb.DateAdded = DateTime.Now()
- ' rb.UserRoleID = r.UserRoleID
- ' rb.Save()
- 'Next
- End If
- If Me.pnlResidentialSelect.Visible Then
- RoleApartment.DeleteByUserRole(r.UserRoleID)
- 'Base-3853
- Dim list As String() = hdnApartmentList.Value.Split(",")
- If list.Length > 0 Then
- For Each Apartment In list
- Dim ra As New RoleApartment
- ra.RMPROPID = Apartment
- ra.DateAdded = DateTime.Now()
- ra.UserRoleID = r.UserRoleID
- ra.Save()
- Next
- End If
- 'For Each rlbi As RadListBoxItem In rlbApartmentDestination.Items
- ' Dim ra As New RoleApartment
- ' ra.RMPROPID = rlbi.Value
- ' ra.DateAdded = DateTime.Now()
- ' ra.UserRoleID = r.UserRoleID
- ' ra.Save()
- 'Next
- End If
- If pnlEntities.Visible Then
- RoleEntityCollection.Delete(r.UserRoleID)
- 'BASE-5986
- Dim list As String() = hdnEntityList.Value.Split(",")
- If list.Length > 0 Then
- For Each entityId In list
- Dim re As New RoleEntity
- re.EntityId = Trim(entityId)
- re.DateAdded = DateTime.Now()
- re.UserRoleId = r.UserRoleID
- re.Save()
- Next
- End If
- 'For Each l As RadListBoxItem In lstEntitiesDestination.Items
- ' Dim re As New RoleEntity
- ' re.EntityId = Trim(l.Value)
- ' re.DateAdded = DateTime.Now()
- ' re.UserRoleId = r.UserRoleID
- ' re.Save()
- 'Next
- End If
- 'Before we leave, we need to clear the cache
- Me.Cache.Remove("TopLevelMenu" & Me.UserID)
- 'See if they want us to recalculate the assignments for this role
- If Me.chkRefactor.Checked Then
- 'Let's get started
- AssignmentRecalc.RecalculateForUserRole(r)
- End If
- 'Response.Redirect("../um/e_role.aspx?action=e&roleid=" & r.RoleID)
- 'I'm done with it, close and refresh
- ' Me.Page.Controls.Add(New LiteralControl("<script language=Javascript>RefreshParentPage();CloseOnReload();</script>"))
- 'Redirect the telerik modal back to the role page
- 'Me.Page.Controls.Add(New LiteralControl("<script language=Javascript>location.href='e_role.aspx?action=e&roleid=" & Me.UserRoleID & "';</script>"))
- Page.ClientScript.RegisterStartupScript(
- Me.GetType(),
- "ReloadPage",
- " RefreshParentPage();", True)
- 'Page.ClientScript.RegisterStartupScript(
- ' Me.GetType(),
- ' "ReloadPage",
- ' "location.href='e_role.aspx?action=e&userTab=1&roleid=" & Me.RoleID & "'", True)
- End Sub
- 'set titles for rad box controls
- Protected Sub lstPropertySource_ItemDataBound(sender As Object, e As RadListBoxItemEventArgs)
- Dim lblPropertySourceHeader As Label = lstPropertySource.Header.FindControl("lblPropertySourceHeader")
- lblPropertySourceHeader.Text = "Properties"
- Dim lblPropertyDestHeader As Label = lstPropertyDestination.Header.FindControl("lblPropertyDestHeader")
- lblPropertyDestHeader.Text = "Selected Properties"
- End Sub
- Protected Sub rlbApartmentSource_ItemDataBound(sender As Object, e As RadListBoxItemEventArgs)
- Dim lblApartmentSourceHeader = CType(rlbApartmentSource.Header.FindControl("lblApartmentSourceHeader"), Label)
- lblApartmentSourceHeader.Text = "Properties"
- Dim lblApartmentDestHeader = CType(rlbApartmentDestination.Header.FindControl("lblApartmentDestHeader"), Label)
- lblApartmentDestHeader.Text = "Selected Properties"
- End Sub
- End Class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement