public List <SelectListItem> GetDepartItems() { DBTreeDataProfile treeProfile = new DBTreeDataProfile(); var DepartItems = treeProfile.getDepartmentList(); List <SelectListItem> items = (from a in DepartItems orderby a.DepartSN select new SelectListItem() { Text = a.DepartName, Value = a.DepartID.ToString() }).Distinct().ToList(); return(items); }
public List <SelectListItem> GetMasterItems() { DBTreeDataProfile treeProfile = new DBTreeDataProfile(); var MasterItems = treeProfile.getMasterList(); List <SelectListItem> items = (from a in MasterItems orderby a.OrgSN select new SelectListItem() { Text = a.OrgSN, Value = a.MasterID.ToString() }).Distinct().ToList(); //System.Threading.Thread.Sleep(3000); return(items); }
public DBTreeDataProfile GetTreeViewItems() { List <DBTreeDataProfile> items = new List <DBTreeDataProfile>(); DBTreeDataProfile treeprofile = new DBTreeDataProfile(); DBTreeDataProfile PONode = new DBTreeDataProfile(); var AccDepItems = treeprofile.getAccDepView(); var level1 = AccDepItems.Select(x => new { x.OrgSN, x.MasterID }).Distinct(); DBTreeDataProfile rootNode = new DBTreeDataProfile(); PONode.Name = "POProfile"; PONode.ID = 0; PONode.HasChildren = false; PONode.ParentName = "POProfile"; PONode.Items = new List <DBTreeDataProfile>(); rootNode.Name = "Root"; rootNode.ID = 0; rootNode.HasChildren = true; rootNode.expanded = true; rootNode.icon = "root"; rootNode.Items = new List <DBTreeDataProfile>(); foreach (var p in level1) { var level2 = AccDepItems.Where(x => x.MasterID == p.MasterID).Select(x => new { x.DepartID, x.DepartName }).Distinct(); DBTreeDataProfile branchNode = new DBTreeDataProfile(); branchNode.Name = p.OrgSN; branchNode.ID = p.MasterID; branchNode.ParentName = "Company"; branchNode.icon = "root"; branchNode.HasChildren = true; branchNode.Items = new List <DBTreeDataProfile>(); foreach (var q in level2) { var level3 = AccDepItems.Where(x => x.MasterID == p.MasterID && x.DepartID == q.DepartID).Select(x => new { x.UserID, x.Username }).Distinct(); DBTreeDataProfile leafNode = new DBTreeDataProfile(); leafNode.Name = q.DepartName; leafNode.ID = q.DepartID; leafNode.ParentName = "Department"; leafNode.icon = "depart"; leafNode.expanded = false; leafNode.HasChildren = true; leafNode.Items = new List <DBTreeDataProfile>(); foreach (var w in level3) { DBTreeDataProfile endNode = new DBTreeDataProfile(); endNode.Name = w.Username; endNode.ID = w.UserID; endNode.ParentName = "User"; endNode.icon = "user"; endNode.HasChildren = false; endNode.Items = new List <DBTreeDataProfile>(); leafNode.Items.Add(endNode); } branchNode.Items.Add(leafNode); } rootNode.Items.Add(branchNode); } DBTreeDataProfile FinalRootNode = new DBTreeDataProfile(); FinalRootNode.Name = "RootRoot"; FinalRootNode.ID = 0; FinalRootNode.HasChildren = true; FinalRootNode.expanded = true; FinalRootNode.icon = "root"; FinalRootNode.Items = new List <DBTreeDataProfile>(); FinalRootNode.Items.Add(rootNode); return(rootNode); }
public DBTreeDataProfile(string name, int id, DBTreeDataProfile parent) { Name = name; ID = id; Parent = parent; }