Beispiel #1
0
        /// <summary>
        /// 获取部门所有成员,并以membertree的形式返回
        /// </summary>
        /// <param name="ds"></param>
        /// <returns></returns>
        private MemberTree GetAllMembers(DataSet ds)
        {
            MemberTree Department = new MemberTree();

            Department.Name = "电学部";

            foreach (DataRow dr in ds.Tables[0].Rows)
            {
                if (dr["部门"].ToString() == "电子部" && dr["在职状态"].ToString() != "False")
                {
                    //新建一个与datarow对应的子树
                    MemberTree Company = new MemberTree();
                    Company.Name     = dr["分公司"].ToString();
                    Company.Children = new List <MemberTree>();
                    MemberTree Group = new MemberTree();
                    Group.Name     = dr["组别"].ToString();
                    Group.Children = new List <MemberTree>();
                    MemberTree Member = new MemberTree();
                    Member.Name = dr["姓名"].ToString();

                    Group.Children.Add(Member);
                    Company.Children.Add(Group);

                    //将子树合并到部门树中去
                    Department.Add(Company);
                }
            }
            return(Department);
        }
Beispiel #2
0
        /// <summary>
        /// 获取部门所有成员,并以membertree的形式返回
        /// </summary>
        /// <param name="ds"></param>
        /// <returns></returns>
        private MemberTree GetAllMembers(string department)
        {
            MemberTree Department = new MemberTree();

            Department.Name = department;

            using (mainEntities db = new mainEntities())
            {
                List <staff> staffs = new List <staff>();
                staffs = db.staffs.Where(x => x.部门 == department).ToList <staff>();;
                foreach (var item in staffs)
                {
                    //新建一个与datarow对应的子树
                    MemberTree Company = new MemberTree();
                    Company.Name     = item.分公司;
                    Company.Children = new List <MemberTree>();
                    MemberTree Group = new MemberTree();
                    Group.Name     = item.组别;
                    Group.Children = new List <MemberTree>();
                    MemberTree Member = new MemberTree();
                    //Member.Name = dr["姓名"].ToString()+"("+dr["系统账号"].ToString()+")";
                    Member.Name = item.Name;

                    Member.Account = item.Account;

                    Group.Children.Add(Member);
                    Company.Children.Add(Group);

                    //将子树合并到部门树中去
                    Department.Add(Company);
                }
            }

            return(Department);
        }