using System;
|
using System.Collections.Generic;
|
using System.Linq;
|
using System.Web;
|
using System.Web.UI;
|
using System.Web.UI.WebControls;
|
using CY.BLL;
|
using CY.Model;
|
using CY.Infrastructure.Common;
|
using System.Data;
|
|
namespace CY.WebForm.Pages.membermanage
|
{
|
//吴辉
|
//角色管理
|
public partial class PermissionsRoleList : BasePage
|
{
|
Sys_Permissions_UserCaseBLL bll_Sys_Permissions_UserCaseBLL = null;
|
Sys_Permissions_MenuBLL bll_Sys_Permissions_MenuBLL = null;
|
Sys_Permissions_RoleBLL bll_Sys_Permissions_RoleBLL = null;
|
public static string treeHtml = ""; //树形参数
|
public static string selHtml = ""; //下拉框内容
|
//实例化
|
public PermissionsRoleList()
|
{
|
bll_Sys_Permissions_UserCaseBLL = new Sys_Permissions_UserCaseBLL();
|
bll_Sys_Permissions_MenuBLL = new Sys_Permissions_MenuBLL();
|
bll_Sys_Permissions_RoleBLL = new Sys_Permissions_RoleBLL();
|
}
|
|
//页面加载
|
protected void Page_Load(object sender, EventArgs e)
|
{
|
if (!IsPostBack)
|
{
|
InitialData();
|
}
|
if (Request["delete"] != null && Request["delete"].ToInt32() > 0)
|
{
|
Sys_Permissions_Role model = bll_Sys_Permissions_RoleBLL.SelectModel(Request["delete"].ToInt32());
|
if (model != null && model.Keyid > 0)
|
{
|
if(bll_Sys_Permissions_RoleBLL.DeleteModel(model))
|
JavaScript.MessageBox("删除成功", this);
|
else
|
JavaScript.MessageBox("删除失败", this);
|
InitialData();
|
}
|
}
|
}
|
|
//提交修改 hideKeyId
|
protected void btn_Submit_Config(object sender, EventArgs e)
|
{
|
|
}
|
|
//获取遍历结果
|
public void InitialData()
|
{
|
DataTable ds = bll_Sys_Permissions_MenuBLL.SelectAllUsedList();
|
treeHtml = "";
|
selHtml = "";
|
int? MenuOneId = 0;
|
if (ds != null && ds.Rows.Count > 0)
|
{
|
GetDataByLevel(ref treeHtml, ref selHtml, ref MenuOneId, ds, 0, 1);
|
}
|
treeHtml = treeHtml.Trim(',');
|
this.RepClientList.DataSource = bll_Sys_Permissions_RoleBLL.SelectList();
|
this.RepClientList.DataBind();
|
}
|
|
//遍历菜单以及用例数据
|
public void GetDataByLevel(ref string treeHtmlo, ref string selHtmlo, ref int? MenuOneId, DataTable data, int parentId, int level)
|
{
|
|
DataRow[] result = data.Select(string.Format("ParentId={0}", parentId));
|
int i = -1;
|
int j = -1;
|
while (++i < result.Length)
|
{
|
if (level == 2)
|
{
|
MenuOneId = result[i]["Keyid"].ToInt32();
|
}
|
|
treeHtmlo = treeHtmlo + "{GetMenuRoleId:'0', id: " + result[i]["Keyid"].ToString2() + ", parentId: " + result[i]["ParentId"].ToString2() + ", name: '" + result[i]["MenuName"].ToString2() + "[" + result[i]["Keyid"].ToString2() + "]" + "'" + (level < 4 ? ", open: true" : "") + " },";
|
if (level == 4)
|
{
|
treeHtmlo = treeHtmlo + "{GetMenuRoleId:'" + MenuOneId + "-" + result[i]["ParentId"].ToString2() + "-" + result[i]["Keyid"].ToString2() + "+0', id: " + (result[i]["ParentId"].ToString2() + "00" + result[i]["Keyid"].ToString2()).ToInt32() + ", parentId: " + result[i]["Keyid"].ToString2() + ", name: '查看页面' },";
|
|
|
DataTable ds = bll_Sys_Permissions_UserCaseBLL.SelectList(result[i]["Keyid"].ToInt32());
|
DataRow[] resultUserCase = ds.Select(string.Format("MenuId={0}", result[i]["Keyid"].ToInt32()));
|
while (++j < resultUserCase.Length)
|
{
|
treeHtmlo = treeHtmlo + "{GetMenuRoleId:'" + MenuOneId + "-" + result[i]["ParentId"].ToString2() + "-" + result[i]["Keyid"].ToString2() + "+" + resultUserCase[j]["Keyid"].ToString2() + "', id: 333" + resultUserCase[j]["Keyid"].ToString2() + ", parentId: " + resultUserCase[j]["MenuId"].ToString2() + ", name: '" + resultUserCase[j]["UserCaseName"].ToString2() + "'},";
|
}
|
j = -1;
|
}
|
GetDataByLevel(ref treeHtmlo, ref selHtmlo, ref MenuOneId, data, result[i]["Keyid"].ToInt32().Value, level + 1);
|
}
|
}
|
|
//获取隔位符
|
public static string GetSplitChar(int startnum, int level, string sige)
|
{
|
string res = ""; //level.ToString2();
|
for (int i = startnum; i < level; i++)
|
{
|
res += sige;
|
}
|
return res;
|
}
|
|
//保存角色权限
|
protected void btn_SaveRole_Click(object sender, EventArgs e)
|
{
|
try
|
{
|
int? Keyid = Request["hideKeyid"].ToInt32();
|
string Roles = Request["hideRoles"].ToString2();
|
string[] RolesArry = Roles.Split(',');
|
Dictionary<string, string> MenusJionRole = new Dictionary<string, string>();
|
foreach (var itemRole in RolesArry)
|
{
|
string MenuAll = itemRole;
|
string[] MenuAllArry = MenuAll.Split('+');
|
if (MenuAllArry.Length > 1)
|
{
|
string value_Role = MenuAllArry[1] == "0" ? "" : MenuAllArry[1];
|
if (MenusJionRole.Keys.Contains(MenuAllArry[0]))
|
MenusJionRole[MenuAllArry[0]] = MenusJionRole[MenuAllArry[0]] + "," + value_Role;
|
else
|
MenusJionRole.Add(MenuAllArry[0], value_Role);
|
}
|
}
|
bool result = bll_Sys_Permissions_RoleBLL.EditMenusRole(Keyid, MenusJionRole);
|
if (result)
|
{
|
InitialData();
|
JavaScript.MessageBox("保存成功", this);
|
}
|
else
|
JavaScript.MessageBox("操作失败", this);
|
}
|
catch (Exception ex)
|
{
|
PAGEHandleException(ex);
|
JavaScript.MessageBox("操作失败",this);
|
}
|
}
|
}
|
}
|