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 PermissionsUserCaseList : BasePage { Sys_Permissions_UserCaseBLL bll_Sys_Permissions_UserCaseBLL = null; Sys_Permissions_RoleBLL bll_Sys_Permissions_RoleBLL = null; Sys_Permissions_MenuBLL bll_Sys_Permissions_MenuBLL = null; public static string treeHtml = ""; //树形参数 public static string selHtml = ""; //下拉框内容 //实例化 public PermissionsUserCaseList() { bll_Sys_Permissions_UserCaseBLL = new Sys_Permissions_UserCaseBLL(); bll_Sys_Permissions_RoleBLL = new Sys_Permissions_RoleBLL(); bll_Sys_Permissions_MenuBLL = new Sys_Permissions_MenuBLL(); } //页面加载 protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { InitialData(); } } //提交修改 hideKeyId protected void btn_Submit_Config(object sender, EventArgs e) { Sys_Permissions_UserCase m_Sys_Permissions_UserCase = new Sys_Permissions_UserCase(); if (this.hideKeyId.Value.ToInt32() > 0) m_Sys_Permissions_UserCase = bll_Sys_Permissions_UserCaseBLL.SelectModelByKeyId(this.hideKeyId.Value.ToInt32()); m_Sys_Permissions_UserCase.MenuId = Request["selParentId"].ToInt32(); m_Sys_Permissions_UserCase.UserCaseName = this.txtUserCaseName.Value.ToString2(); m_Sys_Permissions_UserCase.ListId = ""; m_Sys_Permissions_UserCase.ControId = this.txtControId.Value.ToString2(); m_Sys_Permissions_UserCase.IsUsed = this.selIsUsed.Value.ToBoolean2(); m_Sys_Permissions_UserCase.Operator = CurrentUser.ShortName; m_Sys_Permissions_UserCase.LastUpdateTime = DateTime.Now; m_Sys_Permissions_UserCase.Remark = ""; if (this.hideKeyId.Value.ToInt32() > 0) bll_Sys_Permissions_UserCaseBLL.UpdateModel(m_Sys_Permissions_UserCase); else bll_Sys_Permissions_UserCaseBLL.InsertModel(m_Sys_Permissions_UserCase); if (Request["selMoneyType"] == "0") { bll_Sys_Permissions_RoleBLL.UpdateCaseToMember(m_Sys_Permissions_UserCase.MenuId, m_Sys_Permissions_UserCase.Keyid); } } //获取遍历结果 public void InitialData() { DataTable ds = bll_Sys_Permissions_MenuBLL.SelectList(); treeHtml = ""; selHtml = ""; if (ds != null && ds.Rows.Count > 0) { GetDataByLevel(ref treeHtml,ref selHtml, ds, 0, 1); } treeHtml = treeHtml.Trim(','); } //遍历数据 public void GetDataByLevel(ref string treeHtmlo, ref string selHtmlo, 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 (result[i]["Keyid"].ToString2() == "11") { string s = ""; } if (result[i]["IsUsed"].ToString2().ToLowerInvariant() == "true") { treeHtmlo = treeHtmlo + "{isMenu:true, id: 333" + result[i]["Keyid"].ToString2() + ", parentId: 333" + result[i]["ParentId"].ToString2() + ", name: '" + result[i]["MenuName"].ToString2() + "'" + (level < 3 ? ", open: true" : "") + " },"; if (level >= 3) { 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 + "{isMenu:false, id: " + resultUserCase[j]["Keyid"].ToString2() + ", parentId: 333" + resultUserCase[j]["MenuId"].ToString2() + ", name: '" + resultUserCase[j]["UserCaseName"].ToString2() + "'},"; } j = -1; } if (level < 3) { selHtmlo += ""; GetDataByLevel(ref treeHtmlo, ref selHtmlo, data, result[i]["Keyid"].ToInt32().Value, level + 1); selHtmlo += ""; } else { selHtmlo += ""; GetDataByLevel(ref treeHtmlo, ref selHtmlo, 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; } } }