1: static List<Entity.OA.Department> entitiesList = null;
2:
3: internal static void Reload()
4: {
5: entitiesList = (from pc in iDepartmentsRepository.GetDepartments()
6: orderby pc.DeptName ascending
7: select pc).ToList();
8: }
9:
10: #region 树型部门列表
11: /// <summary>
12: /// 虚拟产品类别
13: /// </summary>
14: /// <returns>虚拟产品类别列表</returns>
15: public static Entity.OA.Department GetTree()
16: {
17: Reload();
18: Entity.OA.Department root = new Entity.OA.Department();
19: try
20: {
21: root = entitiesList.Single(
22: item => item.DeptID.Equals(Entity.OA.Department.ROOTID));//获取跟节点
23: GetSubs(root);
24:
25: }
26: catch (InvalidOperationException ex)
27: {
28: ex.ToString();
29: }
30: return root;
31: }
32:
33:
34: /// <summary>
35: /// 根据父对象,找到子孙树
36: /// </summary>
37: /// <param name="father">父对象</param>
38: static public void GetSubs(Entity.OA.Department father)
39: {
40: father.SubList = entitiesList.Where(item =>
41: item.ParentID.Equals(father.DeptID)).ToList();
42: father.SubList.ForEach(item =>
43: {
44: item.Father = father;
45: GetSubs(item);
46: });
47:
48: }
49: #endregion
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)