Exemplo n.º 1
0
        protected void Egv_RowCommand(object sender, CommandEventArgs e)
        {
            int adminId = DataConverter.CLng(e.CommandArgument);

            if (string.Compare("ModifyAdmin", e.CommandName, StringComparison.OrdinalIgnoreCase) == 0)
            {
                BasePage.ResponseRedirect("Administrator.aspx?Action=Modify&AdminId=" + adminId);
            }
            if (string.Compare("DeleteAdmin", e.CommandName, StringComparison.OrdinalIgnoreCase) == 0)
            {
                if (PEContext.Current.Admin.AdministratorInfo.AdminId == adminId)
                {
                    AdminPage.WriteErrMsg("不能删除自己!", "AdministratorManage.aspx");
                }
                else
                {
                    Administrators.Delete(adminId);
                    AdminPage.WriteSuccessMsg("删除管理员成功!", "AdministratorManage.aspx");
                }
            }
            if (string.Compare("LockAdmin", e.CommandName, StringComparison.OrdinalIgnoreCase) == 0)
            {
                AdministratorInfo administratorByAdminId = Administrators.GetAdministratorByAdminId(adminId);
                administratorByAdminId.IsLock = !administratorByAdminId.IsLock;
                Administrators.Update(administratorByAdminId);
                this.Egv.DataBind();
            }
        }
Exemplo n.º 2
0
        private void ModifyAdmin()
        {
            AdministratorInfo administratorByAdminId = Administrators.GetAdministratorByAdminId(BasePage.RequestInt32("AdminId"));

            if (string.IsNullOrEmpty(this.TxtPassword.Text.Trim()))
            {
                administratorByAdminId.AdminPassword = this.ViewState["Password"].ToString();
            }
            else
            {
                administratorByAdminId.AdminPassword = StringHelper.MD5(this.TxtPassword.Text);
            }
            if ((!administratorByAdminId.EnableModifyPassword && (administratorByAdminId.AdminPassword != this.ViewState["Password"].ToString())) && !PEContext.Current.Admin.IsSuperAdmin)
            {
                AdminPage.WriteErrMsg("没有修改密码的权限!");
            }
            if (administratorByAdminId.AdminPassword != this.ViewState["Password"].ToString())
            {
                administratorByAdminId.LastModifyPasswordTime = new DateTime?(DateTime.Now);
            }
            if (string.Compare(this.TxtUserName.Text.Trim(), this.ViewState["UserName"].ToString(), StringComparison.OrdinalIgnoreCase) != 0)
            {
                UserInfo usersByUserName = Users.GetUsersByUserName(this.TxtUserName.Text.Trim());
                if (usersByUserName.IsNull)
                {
                    AdminPage.WriteErrMsg("此前台用户名不存在!");
                }
                if (!Administrators.GetAdministratorByUserName(usersByUserName.UserName).IsNull)
                {
                    AdminPage.WriteErrMsg("此前台用户已经被添加为管理员了!");
                }
            }
            administratorByAdminId.UserName             = this.TxtUserName.Text.Trim();
            administratorByAdminId.IsLock               = this.ChkIsLock.Checked;
            administratorByAdminId.EnableModifyPassword = this.ChkEnableModifyPassword.Checked;
            administratorByAdminId.EnableMultiLogOn     = this.ChkEnableMultiLogin.Checked;
            if (Administrators.Update(administratorByAdminId))
            {
                if (this.RadPurview1.Checked)
                {
                    RoleMembers.AddMemberToRoles(administratorByAdminId.AdminId, "0");
                }
                else
                {
                    RoleMembers.AddMemberToRoles(administratorByAdminId.AdminId, this.HdnBelongToRole.Value);
                }
                AdminPage.WriteSuccessMsg("修改管理员成功!", "AdministratorManage.aspx");
            }
            else
            {
                AdminPage.WriteErrMsg("修改管理员失败!");
            }
        }
Exemplo n.º 3
0
        private void InitModify()
        {
            int adminId = BasePage.RequestInt32("AdminId");
            AdministratorInfo administratorByAdminId = Administrators.GetAdministratorByAdminId(adminId);

            if (administratorByAdminId.IsNull)
            {
                AdminPage.WriteErrMsg("不存在此管理员");
            }
            if (string.CompareOrdinal("," + RoleMembers.GetRoleIdListByAdminId(adminId) + ",", ",0,") == 0)
            {
                this.RadPurview1.Checked = true;
                this.RadPurview2.Checked = false;
                this.RolePurview.Style.Add("display", "none");
            }
            this.TxtAdminName.Text               = administratorByAdminId.AdminName;
            this.TxtUserName.Text                = administratorByAdminId.UserName;
            this.ChkEnableMultiLogin.Checked     = administratorByAdminId.EnableMultiLogOn;
            this.ViewState["AdminName"]          = administratorByAdminId.AdminName;
            this.ViewState["UserName"]           = administratorByAdminId.UserName;
            this.ChkEnableModifyPassword.Checked = administratorByAdminId.EnableModifyPassword;
            this.ChkIsLock.Checked               = administratorByAdminId.IsLock;
            if (PEContext.Current.Admin.AdministratorInfo.AdminId == adminId)
            {
                this.ChkIsLock.Enabled = false;
            }
            this.TxtAdminName.Enabled      = false;
            this.ViewState["Password"]     = administratorByAdminId.AdminPassword;
            this.ValrUserPassword.Enabled  = false;
            this.CompareValidator1.Enabled = false;
            this.TrPassword.Style.Add("display", "none");
            this.LabTip.Text = "<font color=red>不修改密码请保持为空!</font>";
            if (!administratorByAdminId.EnableModifyPassword && !PEContext.Current.Admin.IsSuperAdmin)
            {
                this.TxtPassword.Enabled             = false;
                this.TxtPassword2.Enabled            = false;
                this.LabTip.Visible                  = false;
                this.ChkEnableModifyPassword.Enabled = false;
            }
        }