private void fillMenu() { List <RoleUser> role_user = new RoleUserService().getRoleIdByUserId(Convert.ToInt32(base.Session["currentUserId"])); string roleStr = ""; for (int i = 0; i < role_user.Count; i++) { roleStr = roleStr + "," + role_user[i].RoleId; } if (roleStr != "") { roleStr = roleStr.Substring(1, roleStr.Length - 1); } else { roleStr = "-1"; } List <roleSysform> rsf = new roleSysFormService().getRightsByRoleId(roleStr); this.sysForms = new List <SysForm>(); foreach (roleSysform r in rsf) { this.sysForms.Add(r.Sysform); } this.sysMenus = new sysMenuService().getAllSysMenus(); this.sysForms.Sort(delegate(SysForm form1, SysForm form2) { return(form1.FormIndex.CompareTo(form2.FormIndex)); }); List <ShowAccordion> accs = new List <ShowAccordion>(); foreach (SysMenu sm in this.sysMenus) { string DisplayName = sm.DisplayName; ShowAccordion showOne = new ShowAccordion(); showOne.HeardText = DisplayName; string body = ""; foreach (SysForm sf in this.sysForms) { if (sf.UpperID == sm.MenuID) { string url = base.ResolveUrl(sf.AssemblyPath); body = body + string.Format("<a href='{1}' target='right'>{0}</a><br><div style='border-top:1px dashed #cccccc;height: 1px;overflow:hidden;margin-top:7px;margin-bottom:7px'></div>", sf.DisplayName, url); } } if (body != "") { showOne.Body = body; accs.Add(showOne); } } this.sysMenus.Clear(); this.sysForms.Clear(); this.MyAccordion.DataSource = accs; this.MyAccordion.DataBind(); }
public void setTabPage(int selectedIndex) { this.formIndexs = new Dictionary <int, List <SysForm> >(); this.TreeView1.Nodes.Clear(); sysMenuService menuMan = new sysMenuService(); List <SysObject> sysobjects = new SysObjectService().getSomeObjects(selectedIndex); List <SysMenu> sysMenus = menuMan.getAllSysMenus(); sysFormService form1 = new sysFormService(); List <AllObjs> allobjs = new AllObjsService().getAllobjs(); List <SysForm> sysForms = form1.getAllForms_1(); foreach (SysMenu sysm in sysMenus) { int i; TreeNode fristNode = new TreeNode(sysm.DisplayName); SysForm form = new SysForm(); form.UpperID = sysm.MenuID; List <SysForm> currentForms = sysForms.FindAll(new Predicate <SysForm>(form.getForms)); this.formIndexs.Add(sysm.MenuIndex, currentForms); currentForms.Sort(delegate(SysForm from1, SysForm form2) { return(from1.FormIndex.CompareTo(form2.FormIndex)); }); foreach (SysForm currentForm in currentForms) { TreeNode secondNode = new TreeNode(currentForm.DisplayName); secondNode.Value = currentForm.FormID.ToString(); fristNode.ChildNodes.Add(secondNode); AllObjs all = new AllObjs(); all.FormId = currentForm.FormID; List <AllObjs> currentObjs = allobjs.FindAll(new Predicate <AllObjs>(all.getForms)); i = 0; while (i < currentObjs.Count) { TreeNode tiridNode = new TreeNode(currentObjs[i].Chinese); tiridNode.Value = currentObjs[i].English; SysObject oo = new SysObject(); oo.FromId = currentForm.FormID; List <SysObject> someObjs = sysobjects.FindAll(new Predicate <SysObject>(oo.getSomeObjct)); tiridNode.Checked = this.getEnable(someObjs, currentObjs[i].English); secondNode.ChildNodes.Add(tiridNode); i++; } } List <roleSysform> rsf = new roleSysFormService().getRightsByRoleId_1(selectedIndex); for (int j = 0; j < rsf.Count; j++) { for (i = 0; i < fristNode.ChildNodes.Count; i++) { int formId = Convert.ToInt32(fristNode.ChildNodes[i].Value); try { if (formId == rsf[j].Sysform.FormID) { fristNode.ChildNodes[i].Checked = true; fristNode.Checked = true; } } catch (Exception) { } } } this.TreeView1.Nodes.Add(fristNode); } }