Exemplo n.º 1
0
 /// <summary>
 /// 初始界面查询所有的员工信息
 /// </summary>
 public void InitLetter()
 {
     if (!ValidateFrom() || !ValidateTo())
     {
     }
     else
     {
         try
         {
             _View.ErrorMessage = string.Empty;
             //20090112 修改默认查询条件中的员工类型为“正式” by yyb
             EmployeeTypeEnum employeetype =
                 EmployeeTypeUtility.GetEmployeeTypeByID(Convert.ToInt32(_View.EmployeeType));
             //_EmployeeList = _IEmployeeFacade.GetEmployeeByBasicCondition(string.Empty,
             //                                                             EmployeeTypeEnum.NormalEmployee,
             //                                                             -1, -1, _View.RecursionDepartment);
             //20090807  修改查询条件  by liudan
             _EmployeeList = _IEmployeeFacade.GetEmployeeBasicInfoByBasicConditionWithCompanyAge(_View.EmployeeName, employeetype, _View.PositionId, _View.GradesId, _View.DepartmentId, AgeFrom, AgeTo, _View.RecursionDepartment, Convert.ToInt32(_View.EmployeeStatusId));
             _EmployeeList =
                 HrmisUtility.RemoteUnAuthEmployee(_EmployeeList, AuthType.HRMIS, _Operator, HrmisPowers.A401);
             List <Employee> emplyees = new List <Employee>();
             foreach (Employee emplyee in _EmployeeList)
             {
                 //根据所属公司id,得到所属公司名称
                 Employee temp = emplyee;
                 if (temp.EmployeeDetails == null || temp.EmployeeDetails.Work == null ||
                     temp.EmployeeDetails.Work.Company == null)
                 {
                 }
                 else
                 {
                     //todo noted by wsl transfer waiting for modify
                     temp.EmployeeDetails.Work.Company =
                         _IDepartmentBll.GetDepartmentById(
                             temp.EmployeeDetails.Work.Company.Id, new Account());
                 }
                 temp.EmployeeDetails              = temp.EmployeeDetails ?? new EmployeeDetails();
                 temp.EmployeeDetails.Work         = temp.EmployeeDetails.Work ?? new Work();
                 temp.EmployeeDetails.Work.Company = temp.EmployeeDetails.Work.Company ??
                                                     new Department();
                 emplyees.Add(temp);
             }
             _CardView.Employees = _EmployeeList;
             _View.ErrorMessage  = "<span class='font14b'>共查到 </span>"
                                   + "<span class='fontred'>" + _EmployeeList.Count + "</span>"
                                   + "<span class='font14b'> 条信息</span>";
         }
         catch (Exception ex)
         {
             _View.ErrorMessage = "<span class='fontred'>" + ex.Message + "</span>";
         }
     }
 }
Exemplo n.º 2
0
        private void Search(NameValueCollection parameters)
        {
            List <ControlError>  errors            = new List <ControlError>();
            List <EmployeeModel> EmployeeModelList = new List <EmployeeModel>();
            string EmployeeName = parameters["EmployeeName"];
            int    employeeType = Convert.ToInt32(parameters["employeeType"]);
            int    positionID   = Convert.ToInt32(parameters["positionID"]);
            int    departmentID = Convert.ToInt32(parameters["departmentID"]);
            int?   gradesID     = Convert.ToInt32(parameters["gradesID"]);

            if (gradesID < 0)
            {
                gradesID = null;
            }
            int    EmployeeStatusId    = Convert.ToInt32(parameters["EmployeeStatusId"]);
            string recursionDepartment = parameters["recursionDepartment"];
            string ageFrom             = parameters["ageFrom"];
            string ageTo = parameters["ageTo"];

            try
            {
                ValidateAge(ageFrom, ageTo);
                EmployeeTypeEnum _employeeType =
                    EmployeeTypeUtility.GetEmployeeTypeByID(employeeType);
                List <Employee> _EmployeeList = _IEmployeeFacade.GetEmployeeBasicInfoByBasicConditionWithCompanyAge(
                    EmployeeName,
                    _employeeType, positionID, gradesID, departmentID, intAgeFrom, intAgeTo, recursionDepartment == "true",
                    EmployeeStatusId);
                _EmployeeList =
                    HrmisUtility.RemoteUnAuthEmployee(_EmployeeList, AuthType.HRMIS, _Operator, HrmisPowers.A401);
                List <Employee> employees = new List <Employee>();
                foreach (Employee emplyee in _EmployeeList)
                {
                    //根据所属公司id,得到所属公司名称
                    var temp = emplyee;
                    if (temp.EmployeeDetails == null || temp.EmployeeDetails.Work == null ||
                        temp.EmployeeDetails.Work.Company == null)
                    {
                    }
                    else
                    {
                        //todo noted by wsl transfer waiting for modify
                        temp.EmployeeDetails.Work.Company =
                            _IDepartmentBll.GetDepartmentById(
                                temp.EmployeeDetails.Work.Company.Id, new Account());
                    }
                    temp.EmployeeDetails              = temp.EmployeeDetails ?? new EmployeeDetails();
                    temp.EmployeeDetails.Work         = temp.EmployeeDetails.Work ?? new Work();
                    temp.EmployeeDetails.Work.Company = temp.EmployeeDetails.Work.Company ??
                                                        new Department();
                    employees.Add(temp);
                }
                //列表中没有查出当前员工的信息时,满足一下两个条件的任何一个,再次加载当前员工的信息
                //1.所选部门是当前员工的部门
                //2.所选部门包含当前员工的部门
                //如现实数据中王莎莉登录,无任何权限,只可看自己的信息
                if (_Operator.Name.Contains(EmployeeName) &&
                    !HrmisUtility.IsEmployeeListContainEmployee(employees, _Operator.Id))
                {
                    if (departmentID == -1)
                    {
                        GetCurrEmployee(employees, employeeType, positionID, gradesID, departmentID);
                    }
                    else if (departmentID != _Operator.Dept.Id)
                    {
                        Department selectedDept =
                            _IDepartmentBll.GetDepartmentById(departmentID, null);
                        if (selectedDept.IsExistDept(_Operator.Dept.Id))
                        {
                            GetCurrEmployee(employees, employeeType, positionID, gradesID, departmentID);
                        }
                    }
                    else
                    {
                        GetCurrEmployee(employees, employeeType, positionID, gradesID, departmentID);
                    }
                }
                EmployeeModelList = employees.Select(x => new EmployeeModel
                {
                    PKID         = x.Account.Id,
                    EmployeeName = "<div class='info' pkid='" + SecurityUtil.DECEncrypt(x.Account.Id.ToString()) + "'>" + x.Account.Name + "</div>",
                    EmployeeType = EmployeeTypeUtility.EmployeeTypeDisplay(x.EmployeeType),
                    Department   = x.Account.Dept.Name,
                    Company      = x.EmployeeDetails.Work.Company.Name,
                    Position     = x.Account.Position.Name,
                    WorkTime     =
                        x.EmployeeDetails.Work.ComeDate.ToString("yyyy-MM-dd")
                }).ToList();
            }
            catch (Exception ex)
            {
                errors.Add(new ControlError("lblMessage", ex.Message));
            }
            _ResponseString = PageUtility.FomartSearchString(EmployeeModelList, errors);
        }