Пример #1
0
    protected void btnRemove_Click(object sender, EventArgs e)
    {
        try
        {
            if (Page.IsValid)
            {
                int    userId      = CurrentEnvironment.LoggedUser.Id;
                string machineName = Request.ServerVariables["REMOTE_HOST"].ToString();
                int    i           = 0;
                if (lbUserRoles.Items.Count > 0)
                {
                    int ddluserId = int.Parse(ddlUser.SelectedValue);
                    for (int j = 0; j <= lbUserRoles.Items.Count - 1; j++)
                    {
                        if (lbUserRoles.Items[j].Selected)
                        {
                            int roleId = int.Parse(lbUserRoles.Items[j].Value.ToString());
                            i = UserRole.DeleteByUserAndRole(ddluserId, roleId);
                        }
                    }

                    _roles = Role.GetLeftRolesOfUser(ddluserId);
                    BindLeftRolesOfUser(_roles);

                    _userRoles = Role.GetRolesOfUser(ddluserId);
                    BindRolesOfUser(_userRoles);

                    lblSuccess.Visible = true;
                    lblWarning.Visible = false;
                    lblError.Visible   = false;
                }
            }
        }
        catch (Exception ex)
        {
            lblSuccess.Visible = false;
            lblWarning.Visible = false;
            lblError.Visible   = true;
        }
    }