/// <summary> /// 绑定tree列表 /// add by fzz /// 16-03-02 /// </summary> /// <param name="context"></param> public void getZTree(HttpContext context) { string id = context.Request["id"] ?? ""; if (string.IsNullOrEmpty(id)) { return; } Sys_Operating_BLL bll = new Sys_Operating_BLL(); List <Sys_RoleOperating> roleList = new Sys_Role_BLL().GetListOperate(id); string[] allIDs = roleList.Select(p => p.OperatingId.ToString()).ToArray();//该角色授权过的所有权限 List <Sys_Operating> oList = bll.GetList(""); StringBuilder sstr = new StringBuilder(); if (oList != null && oList.Count > 0) { foreach (var item in oList) { sstr.Append("{ \"id\": \"" + item.ID + "\", \"pId\": \"" + item.ParentId + "\", \"name\": \"" + item.Name + "\"" + (item.ParentId == null ? ",\"open\":true" : "") + (allIDs.Contains(item.ID + "") ? ",\"checked\": true}," : "},")); } } //context.Response.Write(JsonConvert.SerializeObject(oList)); context.Response.Write("[" + sstr.ToString().TrimEnd(',') + "]"); }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { string id = Context.Request["id"] ?? ""; //string name=Context.Request["name"]??""; if (string.IsNullOrEmpty(id)) { return; } this.id.Value = id; // this.name.Value = name; int totalCount = 0; Sys_Operating_BLL bll = new Sys_Operating_BLL(); List <Sys_RoleOperating> roleList = new Sys_Role_BLL().GetListOperate(id); string[] allIDs = roleList.Select(p => p.OperatingId.ToString()).ToArray(); //该角色授权过的所有权限 List <Sys_Operating> operList = bll.GetList("", false); //父级 totalCount += operList.Count; foreach (var key in operList) { //查询子级 List <Sys_Operating> childList = bll.GetList(key.ID.ToString(), true); totalCount += childList.Count; } StringBuilder html = new StringBuilder(); foreach (var key in operList) { //查询子级 List <Sys_Operating> childList = bll.GetList(key.ID.ToString(), true); html.Append("<div class='user_jur_h1'><span><input type='checkbox' newname='MySelect' count='" + childList.Count + "' value='" + key.ID + "' id='" + key.ID + "' onclick='CheckBoxP(this," + totalCount + ")' " + (allIDs.Contains(key.ID.ToString()) ? "checked=checked" : "") + "/><em>" + key.Name + "</em></span></div>"); if (childList.Count > 0) { html.Append("<div class='user_jur_h2'>"); foreach (var item in childList) { html.Append(" <span><input type='checkbox' name='" + item.ParentId + "' count='" + childList.Count + "' id='" + item.ID + "' value='" + item.ID + "' onclick='CheckBoxC(this," + totalCount + ")' newname='MySelect' " + (allIDs.Contains(item.ID.ToString()) ? "checked=checked" : "") + " /><em>" + item.Name + "</em></span>"); } html.Append("</div>"); } } html.Append(" <div class='user_jur_h3'><span><input type='checkbox' id='selectAll' " + (Regex.Matches(html.ToString(), @"checked").Count / 2 == totalCount ? "checked=checked" : "") + " onclick='selectAlls()'/><em>全选</em></span></div>"); this.operates.InnerHtml = html.ToString(); } }
/// <summary> /// 绑定操作模块 /// 创建人:wsy /// 时间:2015-06-02 /// </summary> /// <param name="context"></param> private void SelectOperate(HttpContext context) { Sys_Operating_BLL opbll = new Sys_Operating_BLL(); List <Sys_Operating> operating = opbll.GetList(" OptionLevel=2 and Name!='用户日志'");//只查询二级页面 operating = operating.OrderBy(p => p.Name).ToList(); StringBuilder oper = new StringBuilder(); oper.Append("<option value=\"\">全部</option>"); if (operating.Count > 0) { for (int i = 0; i < operating.Count; i++) { if (Convert.ToBoolean(operating[i].IsPublicOperating)) { oper.Append("<option value=\"" + operating[i].ID + "\">" + operating[i].Name + "</option>"); } } } context.Response.Write(oper); }