public List <AllObjs> getAllobjs() { List <AllObjs> objs = new List <AllObjs>(); using (SqlConnection conn = DBHelp.getConn()) { conn.Open(); SqlCommand objCommand = new SqlCommand("select * from Tb_Objs", conn); using (SqlDataReader objReader = objCommand.ExecuteReader()) { while (objReader.Read()) { AllObjs o = new AllObjs(); o.Chinese = objReader["ChineseName"].ToString(); o.English = objReader["EnglishName"].ToString(); o.FormId = Convert.ToInt32(objReader["FormID"]); objs.Add(o); } objReader.Close(); } } return(objs); }
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); } }