コード例 #1
0
    protected void BindData()
    {
        try
        {
            //Initialize the values for the IN ROLE list box
            if (RoleDropDownList.Text == Resources.SecurityData.NoneRoleItem || string.IsNullOrEmpty(RoleDropDownList.Text))
            {
                InRoleListBox.DataSource = theUsersAndRolesBLL.UsersInNoneRole();
            }
            else
            {
                if (Roles.GetUsersInRole(RoleDropDownList.Text) == null)
                {
                    InRoleListBox.DataSource = "";
                }
                else
                {
                    InRoleListBox.DataSource = Roles.GetUsersInRole(RoleDropDownList.Text);
                }
            }
            InRoleListBox.DataBind();

            //Initialize the values for the NOT IN ROLE list box
            if (RoleDropDownList.Text == Resources.SecurityData.NoneRoleItem || string.IsNullOrEmpty(RoleDropDownList.Text))
            {
                OutRoleListBox.DataSource    = theUsersAndRolesBLL.UsersNotInRoleNone();
                AddOutImageButton.Enabled    = false;
                DeleteRolImageButton.Visible = false;
            }
            else
            {
                if (theUsersAndRolesBLL.GetUsersNotInRol(RoleDropDownList.Text) == null)
                {
                    OutRoleListBox.DataSource = "";
                }
                else
                {
                    OutRoleListBox.DataSource = theUsersAndRolesBLL.GetUsersNotInRol(RoleDropDownList.Text);
                }

                AddOutImageButton.Enabled    = true;
                DeleteRolImageButton.Visible = false;
            }
            OutRoleListBox.DataBind();
        }
        catch (Exception q)
        {
            log.Error("Error en BindData de la pagina AssignRoles.aspx.", q);
            SystemMessages.DisplaySystemErrorMessage(Resources.SecurityData.MessageErrorGetUsersByRole + RoleDropDownList.Text);
        }
        EmployeeRolePanel.Visible = false;
    }
コード例 #2
0
    protected void InRoleListBox_SelectedIndexChanged(object sender, EventArgs e)
    {
        try
        {
            OutRoleListBox.ClearSelection();
            if (VerifyIfIsOnlyOneUserSelected(InRoleListBox))
            {
                MembershipUser theUser;
                EmployeeRolePanel.Visible = true;
                gRolesForUser             = Roles.GetRolesForUser(InRoleListBox.SelectedValue);
                FillCheckBoxesForRoles(gRolesForUser);
                theUser             = Membership.GetUser(InRoleListBox.SelectedValue.ToString());
                UserLabel.Text      = theUser.UserName.ToString();
                UserEmailLabel.Text = theUser.Email.ToString();

                if (theUser.UserName.Equals(HttpContext.Current.User.Identity.Name))
                {
                    foreach (ListItem item in UserRoleCheckBoxList.Items)
                    {
                        item.Enabled = false;
                    }

                    SaveRolesButton.Visible   = false;
                    ResetRolesButton.Visible  = false;
                    AddInImageButton.Enabled  = false;
                    AddOutImageButton.Enabled = false;
                }
                else
                {
                    SaveRolesButton.Visible   = true;
                    ResetRolesButton.Visible  = (!LoginSecurity.IsUserAuthorizedPermission("RESET_USER_ACCOUNT"));
                    AddInImageButton.Enabled  = true;
                    AddOutImageButton.Enabled = (RoleDropDownList.Text != Resources.SecurityData.NoneRoleItem && !string.IsNullOrEmpty(RoleDropDownList.Text));
                }
            }
            else
            {
                EmployeeRolePanel.Visible = false;
            }
        }
        catch (Exception q)
        {
            log.Error("Function InRoleListBox_SelectedIndexChanged from AssignRoles page", q);
            SystemMessages.DisplaySystemMessage(Resources.SecurityData.MessageErrorGetRoles);
        }
    }