📄 administratormanage.cs
字号:
namespace PowerEasy.WebSite.Admin.User
{
using PowerEasy.Common;
using PowerEasy.Components;
using PowerEasy.Controls;
using PowerEasy.Model.UserManage;
using PowerEasy.UserManage;
using PowerEasy.Web.UI;
using System;
using System.Web.UI.WebControls;
public class AdministratorManage : AdminPage
{
protected ExtendedGridView Egv;
protected HiddenField HdnRoleId;
protected ObjectDataSource ObjectDataSource1;
protected ExtendedSiteMapPath SmpNavigator;
protected void Egv_RowCommand(object sender, CommandEventArgs e)
{
int adminId = DataConverter.CLng(e.CommandArgument);
if (string.Compare("ModifyAdmin", e.CommandName, true) == 0)
{
BasePage.ResponseRedirect("Administrator.aspx?Action=Modify&AdminId=" + adminId);
}
if (string.Compare("DeleteAdmin", e.CommandName, true) == 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, true) == 0)
{
AdministratorInfo administratorByAdminId = Administrators.GetAdministratorByAdminId(adminId);
administratorByAdminId.IsLock = !administratorByAdminId.IsLock;
Administrators.Update(administratorByAdminId);
this.Egv.DataBind();
}
}
protected void Egv_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
AdministratorInfo dataItem = (AdministratorInfo) e.Row.DataItem;
Label label = (Label) e.Row.FindControl("LabEnableMultiLogin");
Label label2 = (Label) e.Row.FindControl("LabLastLoginTime");
Label label3 = (Label) e.Row.FindControl("LabIsLock");
LinkButton button = (LinkButton) e.Row.FindControl("LnkLock");
HyperLink link = (HyperLink) e.Row.FindControl("HypUserName");
Label label4 = (Label) e.Row.FindControl("LabRoleList");
Label label5 = (Label) e.Row.FindControl("LabManageName");
Label label6 = (Label) e.Row.FindControl("LabLastModifyPasswordTime");
Label label7 = (Label) e.Row.FindControl("LabLastLoginIp");
label7.Text = dataItem.LastLoginIP;
if (!dataItem.LastModifyPasswordTime.HasValue)
{
label6.Text = "未修改过";
}
else
{
label6.Text = dataItem.LastModifyPasswordTime.Value.ToString("yyyy-MM-dd HH:mm:ss");
}
if (RoleMembers.GetRoleIdListByAdminId(dataItem.AdminId).IndexOf("0", 0) > -1)
{
label5.Text = string.Concat(new object[] { "<strong><font color=blue><a href=\"Administrator.aspx?Action=Modify&AdminId=", dataItem.AdminId, "\">", dataItem.AdminName, "</a></font></strong>" });
}
else
{
label5.Text = string.Concat(new object[] { "<a href=\"Administrator.aspx?Action=Modify&AdminId=", dataItem.AdminId, "\">", dataItem.AdminName, "</a>" });
}
string[] strArray = dataItem.RoleList.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
if (strArray.Length > 1)
{
label4.Text = strArray[0] + ",<span style=\"cursor:pointer;\" Title='" + dataItem.RoleList.Replace(strArray[0] + ",", "") + "' >[更多]</span>";
}
else
{
label4.Text = dataItem.RoleList;
}
link.Text = dataItem.UserName;
link.NavigateUrl = "UserShow.aspx?UserName=" + base.Server.UrlEncode(dataItem.UserName);
if (dataItem.EnableMultiLogin)
{
label.Text = "允许";
}
else
{
label.Text = "<font color=\"red\">不允许</font>";
}
if (dataItem.IsLock)
{
label3.Text = "<font color=\"red\">已锁定</font>";
button.Text = "解锁";
}
else
{
label3.Text = "<font color=\"blue\">正常</font>";
button.Text = "锁定";
}
if (dataItem.LastLoginTime.HasValue)
{
label2.Text = dataItem.LastLoginTime.Value.ToString("yyyy-MM-dd hh:mm:ss");
}
if (PEContext.Current.Admin.AdministratorInfo.AdminId == dataItem.AdminId)
{
((LinkButton) e.Row.FindControl("LnkLock")).Enabled = false;
((LinkButton) e.Row.FindControl("LnkDelete")).Enabled = false;
}
}
}
protected void Page_Load(object sender, EventArgs e)
{
int roleId = BasePage.RequestInt32("RoleId", -1);
this.HdnRoleId.Value = roleId.ToString();
if (roleId > -1)
{
this.SmpNavigator.AdditionalNode = "所属<font color=red>" + UserRole.GetRoleInfoByRoleId(roleId).RoleName + "</font>角色下包含的管理员";
}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -