Exemple #1
0
        /// <summary>
        /// 获取我管理的人员
        /// </summary>
        /// <param name="EmpLoyeeID"></param>
        /// <returns></returns>
        public List <Sys_Employee> GetMyManagerEmpLoyees(int?EmpLoyeeID, ref string keyList)
        {
            HHL_WeddingEntities ObjWeddingDataContext = new HHL_WeddingEntities();

            using (EntityConnection ObjEntityconn = new EntityConnection("name=HHL_WeddingEntities"))
            {
                List <int>            ObjKeyList        = new List <int>();
                ObjectContext         ObjDataContext    = new ObjectContext(ObjEntityconn);
                var                   MyDepartmentList  = ObjWeddingDataContext.Sys_Department.Where(C => C.DepartmentManager == EmpLoyeeID);
                List <Sys_Department> ObjDepartmentList = new List <Sys_Department>();
                foreach (var ObjDepartment in MyDepartmentList)
                {
                    ObjDepartmentList.AddRange(ObjDataContext.CreateQuery <Sys_Department>("Select VALUE c from HHL_WeddingEntities.Sys_Department as c where c.IsDelete =false and c.SortOrder  Like '%" + ObjDepartment.SortOrder + "%'").ToList <Sys_Department>());
                }

                foreach (var Objitem in ObjDepartmentList)
                {
                    ObjKeyList.Add(Objitem.DepartmentID);
                }
                var ObjEmpLoyeeList = this.GetByDepartmetnKeysList(ObjKeyList.ToArray());
                foreach (var item in ObjKeyList)
                {
                    keyList += item.ToString() + ",";
                }

                return(ObjEmpLoyeeList.Where(C => C.Status == 0).ToList());
            }
        }
Exemple #2
0
        /// <summary>
        /// 获取我管理的人员
        /// </summary>
        /// <param name="EmpLoyeeID"></param>
        /// <returns></returns>
        public static string GetMyManagerEmpLoyee(int?EmpLoyeeID, string KeyList, bool IsTrue = false)
        {
            HHL_WeddingEntities ObjWeddingDataContext = new HHL_WeddingEntities();

            using (EntityConnection ObjEntityconn = new EntityConnection("name=HHL_WeddingEntities"))
            {
                List <int>            ObjKeyList        = new List <int>();
                ObjectContext         ObjDataContext    = new ObjectContext(ObjEntityconn);
                var                   MyDepartmentList  = ObjWeddingDataContext.Sys_Department.Where(C => C.DepartmentManager == EmpLoyeeID && C.Status == 0);
                List <Sys_Department> ObjDepartmentList = new List <Sys_Department>();
                foreach (var ObjDepartment in MyDepartmentList)
                {
                    ObjDepartmentList.AddRange(ObjDataContext.CreateQuery <Sys_Department>("Select VALUE c from HHL_WeddingEntities.Sys_Department as c where c.SortOrder  Like '%" + ObjDepartment.SortOrder + "%'").ToList <Sys_Department>());
                }

                foreach (var Objitem in ObjDepartmentList)
                {
                    ObjKeyList.Add(Objitem.DepartmentID);
                }
                var ObjEmpLoyeeList = new Employee().GetByDepartmetnKeysList(ObjKeyList.ToArray(), IsTrue).Where(C => C.Status == 0).ToList();

                foreach (var ObjItem in ObjEmpLoyeeList)
                {
                    KeyList += ObjItem.EmployeeID.ToString() + ",";
                }
                return(" {" + (KeyList.Trim(',') + "," + EmpLoyeeID).Trim(',') + "} ");
            }

            //return EmpLoyeeID.ToString();
        }
Exemple #3
0
        /// <summary>
        /// 获取我管理的人员
        /// </summary>
        /// <param name="EmpLoyeeID"></param>
        /// <returns></returns>
        public List <Sys_Employee> GetMyManagerEmpLoyee(int?EmpLoyeeID)
        {
            HHL_WeddingEntities ObjWeddingDataContext = new HHL_WeddingEntities();

            using (EntityConnection ObjEntityconn = new EntityConnection("name=HHL_WeddingEntities"))
            {
                List <int>            ObjKeyList        = new List <int>();
                ObjectContext         ObjDataContext    = new ObjectContext(ObjEntityconn);
                var                   MyDepartmentList  = ObjWeddingDataContext.Sys_Department.Where(C => C.DepartmentManager == EmpLoyeeID);
                List <Sys_Department> ObjDepartmentList = new List <Sys_Department>();
                foreach (var ObjDepartment in MyDepartmentList)
                {
                    ObjDepartmentList.AddRange(ObjDataContext.CreateQuery <Sys_Department>("Select VALUE c from HHL_WeddingEntities.Sys_Department as c where c.SortOrder  Like '%" + ObjDepartment.SortOrder + "%'").ToList <Sys_Department>());
                }
                ////猜测是否为部门主管
                //if (ObjDepartment.DepartmentManager == ObjEmpLoyee.EmployeeID)
                //{
                //Department ObjDepartmentBLL=new Department();


                // var DepartmetnList = ObjDataContext.CreateQuery<Sys_Department>("Select VALUE c from HHL_WeddingEntities.Sys_Department as c where c.SortOrder  Like '%" + ObjDepartment.SortOrder + "%'").ToList<Sys_Department>();

                foreach (var Objitem in ObjDepartmentList)
                {
                    //ObjKeyList.Add(Convert.ToInt32(Objitem.Parent));
                    ObjKeyList.Add(Objitem.DepartmentID);
                }
                var ObjEmpLoyeeList = this.GetByDepartmetnKeysList(ObjKeyList.ToArray());

                return(ObjEmpLoyeeList.Where(C => C.Status == 0).ToList());
            }
        }
Exemple #4
0
        /// <summary>
        /// 获取下级信息(EmployeeInfo)
        /// </summary>
        /// <param name="EmpLoyeeID"></param>
        /// <returns></returns>
        public List <EmployeeInfo> GetMyMnanagerInfo(int?EmpLoyeeID)
        {
            HHL_WeddingEntities ObjWeddingDataContext = new HHL_WeddingEntities();

            using (EntityConnection ObjEntityconn = new EntityConnection("name=HHL_WeddingEntities"))
            {
                List <int>    ObjKeyList     = new List <int>();
                ObjectContext ObjDataContext = new ObjectContext(ObjEntityconn);

                //我的直属部门
                var MyDepartmentList = ObjWeddingDataContext.Sys_Department.Where(C => C.DepartmentManager == EmpLoyeeID);
                List <Sys_Department> ObjDepartmentList = new List <Sys_Department>();
                //获取间接管理的部门
                foreach (var ObjDepartment in MyDepartmentList)
                {
                    var query = (from c in ObjEntity.Sys_Department where c.SortOrder.Contains(ObjDepartment.SortOrder) select c);
                    ObjDepartmentList.AddRange(query.ToList());
                }

                //我管理的部门Id
                foreach (var Objitem in ObjDepartmentList)
                {
                    ObjKeyList.Add(Objitem.DepartmentID);
                }
                //获取部门的员工
                var ObjEmpLoyeeList = this.GetEmpInfoList(ObjKeyList.ToArray());

                return(ObjEmpLoyeeList.ToList());
            }
        }
Exemple #5
0
        /// <summary>
        /// 获取我管理的人员 返回list<Employee>
        /// </summary>
        /// <param name="EmpLoyeeID"></param>
        /// <returns></returns>
        public List <Sys_Employee> GetMyManagerEmpLoyee(int?EmpLoyeeID)
        {
            HHL_WeddingEntities ObjWeddingDataContext = new HHL_WeddingEntities();

            using (EntityConnection ObjEntityconn = new EntityConnection("name=HHL_WeddingEntities"))
            {
                List <int>            ObjKeyList        = new List <int>();
                ObjectContext         ObjDataContext    = new ObjectContext(ObjEntityconn);
                var                   MyDepartmentList  = ObjWeddingDataContext.Sys_Department.Where(C => C.DepartmentManager == EmpLoyeeID);
                List <Sys_Department> ObjDepartmentList = new List <Sys_Department>();
                foreach (var ObjDepartment in MyDepartmentList)
                {
                    var query = (from c in ObjEntity.Sys_Department where c.SortOrder.Contains(ObjDepartment.SortOrder) select c);
                    ObjDepartmentList.AddRange(query.ToList());
                    //ObjDepartmentList.AddRange(ObjDataContext.CreateQuery<Sys_Department>("Select VALUE c from HHL_WeddingEntities.Sys_Department as c where c.SortOrder  Like '%" + ObjDepartment.SortOrder + "%'").ToList<Sys_Department>());
                }

                foreach (var Objitem in ObjDepartmentList)
                {
                    ObjKeyList.Add(Objitem.DepartmentID);
                }
                var ObjEmpLoyeeList = this.GetByDepartmetnKeysList(ObjKeyList.ToArray());

                return(ObjEmpLoyeeList.ToList());
            }
        }
Exemple #6
0
        /// <summary>
        /// 判断该条数据是否存在
        /// </summary>
        /// <returns></returns>
        public static bool IsExists(List <PMSParameters> ObjParameterList)
        {
            string WhereStr = GetWhere(ObjParameterList);


            string sql = "Select count(*) from " + typeof(T).Name + " as c where 1=1 " + WhereStr;
            HHL_WeddingEntities ObjContex = new HHL_WeddingEntities();
            var SourctcountResualt        = ObjContex.Database.SqlQuery <int>(sql, new List <ObjectParameter>().ToArray()).First();
            int Count = SourctcountResualt;

            if (Count > 0)
            {
                return(true);            //该条数据已经存在
            }
            else
            {
                return(false);           //不存在 就可以新增
            }
        }
Exemple #7
0
        /// <summary>
        /// 获取我管理的所有人员Id(返回List<string>)
        /// </summary>
        /// <returns></returns>
        public List <string> GetMyEmployeeKey(int?EmpLoyeeID)
        {
            HHL_WeddingEntities ObjWeddingDataContext = new HHL_WeddingEntities();

            using (EntityConnection ObjEntityconn = new EntityConnection("name=HHL_WeddingEntities"))
            {
                List <string> ObjKey           = new List <string>();
                List <int>    ObjKeyList       = new List <int>();
                ObjectContext ObjDataContext   = new ObjectContext(ObjEntityconn);
                var           MyDepartmentList = ObjWeddingDataContext.Sys_Department.Where(C => C.DepartmentManager == EmpLoyeeID);
                if (MyDepartmentList.Count() > 0)        //有部门  是部门主管
                {
                    List <Sys_Department> ObjDepartmentList = new List <Sys_Department>();
                    //所有部门的主管都是当前登录客户
                    foreach (var ObjDepartment in MyDepartmentList)
                    {
                        var query = (from c in ObjEntity.Sys_Department where c.SortOrder.Contains(ObjDepartment.SortOrder) select c);
                        ObjDepartmentList.AddRange(query.ToList());
                    }
                    //获取的所有管理的下级部门
                    foreach (var objItem in ObjDepartmentList)
                    {
                        ObjKeyList.Add(objItem.DepartmentID);
                    }

                    //我的所有客户(启用)
                    var ObjEmpLoyeeList = this.GetByDepartmetnKeysList(ObjKeyList.ToArray());
                    //取出客户Id
                    foreach (var objEmp in ObjEmpLoyeeList)
                    {
                        ObjKey.Add(objEmp.EmployeeID.ToString());
                    }
                }
                else
                {
                    ObjKey.Add(EmpLoyeeID.ToString());
                }

                return(ObjKey);
            }
        }
Exemple #8
0
        /// <summary>
        /// 获取我管理的人员 (返回list<Employee>) 通过ref取值 字符串
        /// </summary>
        /// <param name="EmpLoyeeID"></param>
        /// <returns></returns>
        public List <Sys_Employee> GetMyManagerEmpLoyees(int?EmpLoyeeID, ref string keyList)
        {
            keyList = "";
            HHL_WeddingEntities ObjWeddingDataContext = new HHL_WeddingEntities();
            List <Sys_Employee> ObjEmpLoyeeList       = new List <Sys_Employee>();

            using (EntityConnection ObjEntityconn = new EntityConnection("name=HHL_WeddingEntities"))
            {
                List <int>            ObjKeyList        = new List <int>();
                ObjectContext         ObjDataContext    = new ObjectContext(ObjEntityconn);
                var                   MyDepartmentList  = ObjWeddingDataContext.Sys_Department.Where(C => C.DepartmentManager == EmpLoyeeID);
                List <Sys_Department> ObjDepartmentList = new List <Sys_Department>();
                if (MyDepartmentList.Count() > 0)
                {
                    foreach (var ObjDepartment in MyDepartmentList)
                    {
                        var query = (from c in ObjEntity.Sys_Department where c.SortOrder.Contains(ObjDepartment.SortOrder) select c);
                        ObjDepartmentList.AddRange(query.ToList());
                    }

                    foreach (var Objitem in ObjDepartmentList)
                    {
                        ObjKeyList.Add(Objitem.DepartmentID);
                    }
                    ObjEmpLoyeeList = this.GetByDepartmetnKeysList(ObjKeyList.ToArray());
                    foreach (var item in ObjEmpLoyeeList)
                    {
                        keyList += item.EmployeeID.ToString() + ",";
                    }
                }
                else        //不是部门主管  就查询自己本人 一个人
                {
                    keyList = EmpLoyeeID.ToString() + ",";
                }

                return(ObjEmpLoyeeList.Where(C => C.Status == 1).ToList());
            }
        }
Exemple #9
0
        //  GetDataByPower(T ObjEntity, int? EmployeeID, int? ChannelID, ObjectParameter[] ObjParameterList)
        /// <summary>
        /// 根据复杂条件获取数据
        /// </summary>
        /// <param name="ObjEntity">需要的实体</param>
        /// <param name="ObjParameterList">参数集合</param>
        ///OrderByCloumname排序字段
        /// <returns></returns>
        public static List <T> GetDataByWhereParameter(List <PMSParameters> ObjParameterList, string OrderByCloumname, int PageSize, int PageIndex, out int SourceCount, int Sort = 1)
        {
            string WhereStr = GetWhere(ObjParameterList);

            string CountSql = " Select count(*) from " + typeof(T).Name + " as c where 1=1 " + WhereStr.Replace("{", "(").Replace("}", ")").Replace("System.Boolean", "bit").Replace("False", "'0'").Replace("True", "'1'");

            //CountSql = CountSql.Replace("System.DateTime", "date");
            CountSql = CountSql.Replace("cast(", "").Replace("as System.DateTime)", "");
            HHL_WeddingEntities ObjContex = new HHL_WeddingEntities();
            var SourctcountResualt        = ObjContex.Database.SqlQuery <int>(CountSql, new List <ObjectParameter>().ToArray()).First();

            SourceCount = SourctcountResualt;

            using (
                EntityConnection ObjEntityconn = new EntityConnection("name=HHL_WeddingEntities"))
            {
                List <ObjectParameter> ObjListparmeter = new List <ObjectParameter>();
                ObjectContext          ObjDataContext  = new ObjectContext(ObjEntityconn);
                PageIndex = PageIndex - 1;
                ObjListparmeter.Add(new ObjectParameter("skip", PageIndex * PageSize));
                ObjListparmeter.Add(new ObjectParameter("limit", PageSize));
                List <T>  ObjList = new List <T>();
                OrderType GroupBy = OrderType.Desc;
                if (Sort == 2)
                {
                    GroupBy = OrderType.Asc;
                }
                string RunSql = "Select VALUE c from HHL_WeddingEntities." + typeof(T).Name + " as c where 1=1 " + WhereStr + " order by c." + OrderByCloumname + " " + GroupBy.ToString() + " SKIP @skip LIMIT @limit ";


                var ObjReturnList = ObjDataContext.CreateQuery <T>(RunSql, ObjListparmeter.ToArray());
                ObjList = ObjReturnList.ToList();
                ObjEntityconn.Close();

                return(ObjList);
            }
        }
Exemple #10
0
        /// <summary>
        /// 是否查询直接下属
        /// </summary>
        /// <param name="EmpLoyeeID"></param>
        /// <param name="IsFirst"></param>
        /// <returns></returns>
        public List <Sys_Employee> GetMyManagerEmpLoyee(int?EmpLoyeeID, bool IsFirst)
        {
            HHL_WeddingEntities ObjWeddingDataContext = new HHL_WeddingEntities();

            using (EntityConnection ObjEntityconn = new EntityConnection("name=HHL_WeddingEntities"))
            {
                List <int>    ObjKeyList     = new List <int>();
                ObjectContext ObjDataContext = new ObjectContext(ObjEntityconn);

                //我主管的部门
                var MyDepartmentList = ObjWeddingDataContext.Sys_Department.Where(C => C.DepartmentManager == EmpLoyeeID);

                //我所在的部门
                var MineEmployeeModel = this.GetByID(EmpLoyeeID);
                var MyDepartment      = ObjWeddingDataContext.Sys_Department.FirstOrDefault(C => C.DepartmentID == MineEmployeeModel.DepartmentID);
                List <Sys_Department> ObjDepartmentList = new List <Sys_Department>();

                if (IsFirst)
                {
                    //先取得我主管的部门
                    foreach (var ObjDepartment in MyDepartmentList)
                    {
                        ObjDepartmentList.AddRange(ObjDataContext.CreateQuery <Sys_Department>("Select VALUE c from HHL_WeddingEntities.Sys_Department as c where c.SortOrder  =   '" + ObjDepartment.SortOrder + "'").ToList <Sys_Department>());
                    }
                    //取得部门主管 和我直接领导的部门

                    //部门主管
                    List <int> ObjManagerList = new List <int>();
                    foreach (var Objitem in ObjDepartmentList)
                    {
                        ObjKeyList.Add(Objitem.DepartmentID);
                    }

                    //取得我直接领导的部门
                    var ObjEmpLoyeeList = this.GetByDepartmetnKeysList(ObjKeyList.ToArray());


                    //取得我间接领导的部门主管
                    ObjDepartmentList = new List <Sys_Department>();
                    ObjDepartmentList = ObjDataContext.CreateQuery <Sys_Department>("Select VALUE c from HHL_WeddingEntities.Sys_Department as c where c.Parent  = " + MyDepartment.DepartmentID).ToList <Sys_Department>();
                    if (ObjDepartmentList.Count > 0)
                    {
                        foreach (var ObjDepartmentManager in ObjDepartmentList)
                        {
                            if (ObjDepartmentManager.DepartmentManager != null && ObjDepartmentManager.DepartmentManager != 0)
                            {
                                ObjEmpLoyeeList.Add(this.GetByID(ObjDepartmentManager.DepartmentManager));
                            }
                        }
                    }
                    return(ObjEmpLoyeeList.Where(C => C.EmployeeID != EmpLoyeeID && C.Status == 0).ToList());
                    //然后计算我的直接领导部门 就是部门主管是我的
                }
                else
                {
                    var MineDepartment = new List <Sys_Department>();

                    //foreach (var ObjDepartment in MyDepartmentList)
                    //{
                    //    MineDepartment.AddRange(ObjDataContext.CreateQuery<Sys_Department>("Select VALUE c from HHL_WeddingEntities.Sys_Department as c where c.SortOrder  = '" + MyDepartment.SortOrder + "'").ToList<Sys_Department>());
                    //}


                    foreach (var ObjDepartment in MyDepartmentList)
                    {
                        ObjDepartmentList.AddRange(ObjDataContext.CreateQuery <Sys_Department>("Select VALUE c from HHL_WeddingEntities.Sys_Department as c where c.SortOrder  Like '%" + MyDepartment.SortOrder + "%'").ToList <Sys_Department>());
                    }


                    foreach (var RemoveItem in MineDepartment)
                    {
                        ObjDepartmentList.Remove(ObjDepartmentList.First(C => C.DepartmentID == RemoveItem.DepartmentID));
                    }


                    //取得部门主管 和我直接领导的部门

                    //部门主管
                    List <int> ObjManagerList = new List <int>();
                    foreach (var Objitem in ObjDepartmentList)
                    {
                        ObjKeyList.Add(Objitem.DepartmentID);
                    }


                    ObjDepartmentList = new List <Sys_Department>();
                    ObjDepartmentList = ObjDataContext.CreateQuery <Sys_Department>("Select VALUE c from HHL_WeddingEntities.Sys_Department as c where c.Parent  =" + MyDepartment.DepartmentID).ToList <Sys_Department>();
                    //取得我直接间接领导的部门
                    var ObjEmpLoyeeList = this.GetByDepartmetnKeysList(ObjKeyList.ToArray());
                    if (ObjDepartmentList.Count > 0)
                    {
                        foreach (var ObjDepartmentManager in ObjDepartmentList)
                        {
                            if (ObjDepartmentManager.DepartmentManager != null && ObjDepartmentManager.DepartmentManager != 0)
                            {
                                var ObjEmpLoyeeListFirst = ObjEmpLoyeeList.FirstOrDefault(C => C.EmployeeID == ObjDepartmentManager.DepartmentManager);
                                if (ObjEmpLoyeeListFirst != null)
                                {
                                    ObjEmpLoyeeList.Remove(ObjEmpLoyeeListFirst);
                                }
                            }
                        }
                    }

                    return(ObjEmpLoyeeList.Where(C => C.EmployeeID != EmpLoyeeID && C.Status == 0).ToList());
                }
                ////猜测是否为部门主管
                //if (ObjDepartment.DepartmentManager == ObjEmpLoyee.EmployeeID)
                //{
                //Department ObjDepartmentBLL=new Department();


                // var DepartmetnList = ObjDataContext.CreateQuery<Sys_Department>("Select VALUE c from HHL_WeddingEntities.Sys_Department as c where c.SortOrder  Like '%" + ObjDepartment.SortOrder + "%'").ToList<Sys_Department>();
            }

            //return new List<Sys_Employee>();
        }