📄 sys_permission.aspx.cs
字号:
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
public partial class SysManage_Sys_Permission : System.Web.UI.Page
{
protected FileManager DropMenu = new FileManager();
protected SysManage SysRoleGrant = new SysManage();
public string GetPagePermission = "";
int selectid = 1;
string rolecode = "";
string UserCode = "";
string OperationID = "";
string AllMenu2ID = "";
int pageid;
protected void Page_Load(object sender, EventArgs e)
{
try
{
//获取左边页面传来的(ID+角色信息)
GetPagePermission = Request["PageID"].ToString();
}
catch
{
}
String[] getppid = GetPagePermission.Split(',');
rolecode = getppid[1].ToString();
pageid = Convert.ToInt32(getppid[0].ToString());
UserCode = Session["MX_Role_Code"].ToString();
//UserCode = "Test1,Test2,";
//pageid = 140;
//根据登陆用户角色以及页面ID获取工程项目管理中Meun1,Menu2的操作权限
OperationID = SysRoleGrant.GetProGrantByRole(UserCode, pageid);
//根据角色ID获取该角色对应的所有Menu2ID
AllMenu2ID = SysRoleGrant.GetMenu2IDByRole(UserCode);
ViewValue.Text = AllMenu2ID;
if (!Page.IsPostBack)
{
if (pageid == 140)
{
table2.Visible = true;
table1.Visible = false;
DropPageMenuBind();
}
}
}
//绑定工程项目管理的权限
public void DropPageMenuBind()
{
DropDownCheckList1.DataSource = DropMenu.GetProGrantName("OperationGrant", "2");
DropDownCheckList1.DataBind();
DropDownCheckList1.DataValueField = "ID";
DropDownCheckList1.DataTextField = "Name";
}
protected void submit_ServerClick(object sender, EventArgs e)
{
if (pageid != 140)
{
if (radio1.Checked == true)
{
selectid = Convert.ToInt32(radio1.Value);
}
else if (radio2.Checked == true)
{
selectid = Convert.ToInt32(radio2.Value);
}
else if (radio3.Checked == true)
{
selectid = Convert.ToInt32(radio3.Value);
}
else if (radio4.Checked == true)
{
selectid = Convert.ToInt32(radio4.Value);
}
else if (radio5.Checked == true)
{
selectid = Convert.ToInt32(radio5.Value);
}
//pageid != 140的添加授权
SysRoleGrant.UpdataRoleGrant(rolecode, pageid, selectid);
Response.Write("<script language='javascript'>alert('授权成功!!');window.close();</script>");
}
else
{
string OperationID = this.DropDownCheckList1.SelectedValuesToString(",").ToString().Trim() + ",";
string[] OperArr = OperationID.Split(',');
//是否选择授权信息
if (OperArr[0] == "")
{
Response.Write("<script language='javascript'>alert('请选择授权权限!!');window.close();</script>");
}
else
{
//查找该角色是否已经授权
int k = SysRoleGrant.GetProGrant(rolecode, pageid);
//已经授权则先删除后添加授权信息
if (k != 0)
SysRoleGrant.DeleteProGrantByRoleID(rolecode);
for (int i = 0; i < OperArr.Length - 1; i++)
{
//pageid == 140的添加授权
SysRoleGrant.AddProGrant(rolecode, pageid,Convert.ToInt32(OperArr[i]));
Response.Write("<script language='javascript'>alert('授权成功!!');window.close();</script>");
}
}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -