/// <summary> /// init company menus /// </summary> void InitComMenus() { EyouSoft.BLL.SysStructure.BSysMenu bll = new EyouSoft.BLL.SysStructure.BSysMenu(); var items = bll.GetComMenus(SysId); bll = null; if (items != null && items.Count > 0) { this.phSetDefaultMenus.Visible = false; this.rptMenus.DataSource = items; this.rptMenus.DataBind(); } else { this.phSetDefaultMenus.Visible = true; } }
/// <summary> /// init company menus /// </summary> void InitComMenus() { var bll = new EyouSoft.BLL.SysStructure.BSysMenu(); var items = bll.GetComMenus(SysId); bll = null; string script = "var comMenus={0};"; if (items != null && items.Count > 0) { script = string.Format(script, Newtonsoft.Json.JsonConvert.SerializeObject(items)); } else { script = string.Format(script, "[]"); } RegisterScript(script); }
/// <summary> /// 页面初始化 /// </summary> /// <param name="id">操作ID</param> protected void PageInit() { System.Text.StringBuilder RolePower = new System.Text.StringBuilder(); IList <EyouSoft.Model.ComStructure.MComRole> RoleList = new EyouSoft.BLL.ComStructure.BComRole().GetList(SiteUserInfo.CompanyId); if (RoleList != null && RoleList.Count > 0) { RolePower.Append("["); foreach (var item in RoleList) { RolePower.Append("{"); RolePower.AppendFormat("RoleId: '{0}',PowerIds: '{1}'", item.Id, item.RoleChilds); RolePower.Append("},"); } RolePower.Append("]"); } hidPower.Value = RolePower.ToString(); this.ddlRole.DataTextField = "RoleName"; this.ddlRole.DataValueField = "Id"; this.ddlRole.DataSource = RoleList; this.ddlRole.DataBind(); this.ddlRole.Items.Insert(0, new ListItem("请选择", "0")); if (ddlRole.Items.FindByValue(RoleID) != null) { ddlRole.Items.FindByValue(RoleID).Selected = true; } string[] PowerIds = new EyouSoft.BLL.ComStructure.BComUser().GetPrivs(UserID, SiteUserInfo.CompanyId).Split(','); if (PowerIds == null || PowerIds[0] == "") { if (!string.IsNullOrEmpty(RoleID)) { EyouSoft.Model.ComStructure.MComRole model = new EyouSoft.BLL.ComStructure.BComRole().GetModel(Utils.GetInt(RoleID), SiteUserInfo.CompanyId); if (model != null) { PowerIds = model.RoleChilds.Split(','); } } } System.Text.StringBuilder str = new System.Text.StringBuilder(); System.Text.StringBuilder Privs = null; EyouSoft.BLL.SysStructure.BSysMenu BSysMenuBll = new EyouSoft.BLL.SysStructure.BSysMenu(); IList <EyouSoft.Model.SysStructure.MComMenu1Info> list = BSysMenuBll.GetComMenus(SiteUserInfo.SysId); if (list != null) { //一级栏目 for (int i = 0; i < list.Count; i++) { str.Append("<table width=\"99%\" cellspacing=\"0\" cellpadding=\"0\" border=\"0\" align=\"center\" class=\"quanxian_add_bottom\"> <tbody><tr>"); str.AppendFormat(" <td width=\"92\" height=\"25\" align=\"center\" class=\"quanxian_add\">{0}</td>", list[i].Name); str.AppendFormat("<td><span> <input type=\"checkbox\" name=\"chkAll\" value=\"{0}\"/></span>全选</td>", list[i].MenuId); str.Append(" </tr></tbody></table>"); str.Append("<div class=\"hr_5\"></div>"); str.Append(" <table width=\"99%\" cellspacing=\"1\" cellpadding=\"0\" border=\"0\" bgcolor=\"#85c1dd\" align=\"center\"><tbody>"); if (list[i].Menu2s != null) { //每行显示4列,共循环多少次 for (int k = 0; k <= list[i].Menu2s.Count / 4; k++) { Privs = new System.Text.StringBuilder(); str.Append("<tr>"); Privs.Append("<tr>"); for (int j = k * 4; j < list[i].Menu2s.Count; j++) { //当前权限是否选中 bool check = false; str.AppendFormat("<th width=\"25%\" height=\"26\" bgcolor=\"#BDDCF4\" align=\"left\"> <input type=\"checkbox\" MenuId =\"{0}\" Menu2Id=\"{1}\" name=\"chkMenu\" />{2}</th>", list[i].MenuId, list[i].Menu2s[j].MenuId, list[i].Menu2s[j].Name); Privs.Append("<td style=\" vertical-align:top;\"><table cellspacing=\"0\" cellpadding=\"0\" border=\"0\">"); for (int t = 0; t < list[i].Menu2s[j].Privs.Count; t++) { for (int p = 0; p < PowerIds.Length; p++) { check = false; if (Utils.GetInt(PowerIds[p]) == list[i].Menu2s[j].Privs[t].PrivsId) { check = true; break; } } Privs.AppendFormat("<tr><td width=\"25%\" height=\"26\" bgcolor=\"#FFFFFF\" align=\"left\"> <input type=\"checkbox\" name=\"chkPower\" Menu2Id=\"{0}\" value=\"{1}\" {2}/>{3}</td></tr>", list[i].Menu2s[j].MenuId, list[i].Menu2s[j].Privs[t].PrivsId, check ? "checked=\"checked\"" : "", list[i].Menu2s[j].Privs[t].Name); } Privs.Append("</table></td>"); if ((j != 0 && (j + 1) % 4 == 0) || j + 1 == list[i].Menu2s.Count) { str.Append("</tr>"); Privs.Append("<tr>"); str.Append(Privs.ToString()); break; } } } } str.Append("</tbody></table><div class=\"hr_5\"></div>"); PowerStr = str.ToString(); } } }
/// <summary> /// 页面初始化 /// </summary> /// <param name="id">操作ID</param> protected void PageInit() { int RoleId = Utils.GetInt(EyouSoft.Common.Utils.GetQueryStringValue("id")); //当前角色的所有权限ID string[] PowerIds = { }; System.Text.StringBuilder str = new System.Text.StringBuilder(); System.Text.StringBuilder Privs = null; EyouSoft.BLL.SysStructure.BSysMenu BSysMenuBll = new EyouSoft.BLL.SysStructure.BSysMenu(); EyouSoft.BLL.ComStructure.BComRole BComRoleBll = new EyouSoft.BLL.ComStructure.BComRole(); IList <EyouSoft.Model.SysStructure.MComMenu1Info> list = BSysMenuBll.GetComMenus(SiteUserInfo.SysId); if (RoleId != 0) { EyouSoft.Model.ComStructure.MComRole model = BComRoleBll.GetModel(RoleId, SiteUserInfo.CompanyId); if (model != null) { txtRoleName.Value = model.RoleName; PowerIds = model.RoleChilds.Split(','); } } else { txtRoleName.Value = ""; } if (list != null) { //一级栏目 for (int i = 0; i < list.Count; i++) { str.Append("<table width=\"100%\" cellspacing=\"0\" cellpadding=\"0\" border=\"0\" align=\"center\" class=\"quanxian_add_bottom\"> <tbody><tr>"); str.AppendFormat(" <td width=\"92\" height=\"25\" align=\"center\" class=\"quanxian_add\">{0}</td>", list[i].Name); str.AppendFormat("<td><label><input type=\"checkbox\" name=\"chkAll\" value=\"{0}\"/> 全选</label></td>", list[i].MenuId); str.Append(" </tr></tbody></table>"); str.Append("<div class=\"hr_5\"></div>"); str.Append(" <table width=\"100%\" cellspacing=\"1\" cellpadding=\"0\" border=\"0\" align=\"center\" bgcolor=\"#85c1dd\"><tbody>"); if (list[i].Menu2s != null) { //每行显示4列,共循环多少次 for (int k = 0; k <= list[i].Menu2s.Count / 4; k++) { Privs = new System.Text.StringBuilder(); str.Append("<tr>"); Privs.Append("<tr>"); for (int j = k * 4; j < list[i].Menu2s.Count; j++) { //当前权限是否选中 bool check = false; str.AppendFormat("<th width=\"25%\" height=\"26\" bgcolor=\"#BDDCF4\" align=\"left\"><label> <input type=\"checkbox\" MenuId =\"{0}\" Menu2Id=\"{1}\" name=\"chkMenu\" /> {2}</label></th>", list[i].MenuId, list[i].Menu2s[j].MenuId, list[i].Menu2s[j].Name); Privs.Append("<td align='left' style=\" vertical-align:top;\" bgcolor=\"#FFFFFF\"><table cellspacing=\"0\" cellpadding=\"0\" border=\"0\">"); for (int t = 0; t < list[i].Menu2s[j].Privs.Count; t++) { for (int p = 0; p < PowerIds.Length; p++) { check = false; if (Utils.GetInt(PowerIds[p]) == list[i].Menu2s[j].Privs[t].PrivsId) { check = true; break; } } Privs.AppendFormat("<tr><td width=\"25%\" height=\"26\" bgcolor=\"#FFFFFF\" align=\"left\"><label> <input type=\"checkbox\" name=\"chkPower\" Menu2Id=\"{0}\" value=\"{1}\" {2}/> {3}</label></td></tr>", list[i].Menu2s[j].MenuId, list[i].Menu2s[j].Privs[t].PrivsId, check ? "checked=\"checked\"" : "", list[i].Menu2s[j].Privs[t].Name); } Privs.Append("</table></td>"); if ((j != 0 && (j + 1) % 4 == 0) || j + 1 == list[i].Menu2s.Count) { int AddThTd = 4 - list[i].Menu2s.Count % 4; if (AddThTd > 0 && list[i].Menu2s.Count > 4) { for (int s = 0; s < AddThTd; s++) { str.Append("<th width=\"25%\" height=\"26\" bgcolor=\"#BDDCF4\" align=\"left\"></th>"); Privs.Append("<td width=\"25%\" height=\"26\" bgcolor=\"#FFFFFF\" align=\"left\"></td>"); } } str.Append("</tr>"); Privs.Append("<tr>"); str.Append(Privs.ToString()); break; } } } } str.Append("</tbody></table><div class=\"hr_5\"></div>"); PowerStr = str.ToString(); } } }
/// <summary> /// init privs /// </summary> void InitPrivs() { EyouSoft.BLL.SysStructure.BSysMenu bll = new EyouSoft.BLL.SysStructure.BSysMenu(); var items = bll.GetComMenus(SysId); bll = null; string script = "var comMenus={0};"; if (items == null || items.Count < 1) { this.phUnsetMenuMsg.Visible = true; this.phPrivs.Visible = false; script = string.Format(script, "[]"); RegisterScript(script); return; } else { this.phUnsetMenuMsg.Visible = false; this.phPrivs.Visible = true; } System.Text.StringBuilder html = new System.Text.StringBuilder(); EyouSoft.BLL.SysStructure.BSys sysbll = new EyouSoft.BLL.SysStructure.BSys(); foreach (var menu1 in items) { html.AppendFormat("<div class=\"p1\"><input type=\"checkbox\" id=\"chk_p_1_{1}\" value=\"{1}\" name=\"chk_p_1\" /><label for=\"chk_p_1_{1}\">{0}</label><!--<span class=\"pcode\">[{1}]</span>--></div>", menu1.Name, menu1.MenuId); if (menu1.Menu2s == null || menu1.Menu2s.Count < 1) { continue; } html.Append("<div>"); int i = 0; foreach (var menu2 in menu1.Menu2s) { html.Append("<ul class=\"p2\">"); html.AppendFormat("<li class=\"p2title\"><input type=\"checkbox\" id=\"chk_p_2_{1}\" value=\"{1}\" name=\"chk_p_2_p1v_{2}\" /><label for=\"chk_p_2_{1}\">{0}</label><!--<span class=\"pcode\">[{1}]</span>--></li>", menu2.Name, menu2.MenuId, menu1.MenuId); var privs = sysbll.GetPrivs(menu2.DefaultMenu2Id); if (privs != null && privs.Count > 0) { foreach (var priv in privs) { html.AppendFormat("<li class=\"p3\"><input type=\"checkbox\" id=\"chk_p_3_{1}\" value=\"{1}\" name=\"chk_p_3_p2v_{2}\" /><label for=\"chk_p_3_{1}\">{0}</label><span class=\"pcode\">[{1}]</span></li>", priv.Name, priv.PrivsId, menu2.MenuId); } } html.Append("</ul>"); if (i % 4 == 3) { html.Append("<ul class=\"p2space\"><li></li></ul>"); } i++; } html.Append("<ul class=\"p2space\"><li></li></ul>"); html.Append("</div>"); } this.ltrPrivs.Text = html.ToString(); script = string.Format(script, Newtonsoft.Json.JsonConvert.SerializeObject(items)); RegisterScript(script); }