/// <summary> /// 返回初始化界面希望显示的条件内容 /// </summary> /// <returns></returns> public static List <SearchField> InitialConditionList() { List <SearchField> returnList = new List <SearchField>(); returnList.Add(InitContractSearchField_EmployeeType()); returnList[0].ConditionField.ConditionExpression = EmployeeTypeUtility.EmployeeTypeDisplay(EmployeeTypeEnum.NormalEmployee) + ";" + EmployeeTypeUtility.EmployeeTypeDisplay(EmployeeTypeEnum.ProbationEmployee) + ";" + EmployeeTypeUtility.EmployeeTypeDisplay(EmployeeTypeEnum.PracticeEmployee) + ";" + EmployeeTypeUtility.EmployeeTypeDisplay(EmployeeTypeEnum.RetirementHire) + ";" + EmployeeTypeUtility.EmployeeTypeDisplay(EmployeeTypeEnum.WorkEmployee); returnList.Add(InitContractSearchField_Department()); returnList.Add(InitContractSearchField_Position()); returnList.Add(InitContractSearchField_Name()); returnList.Add(InitContractSearchField_ComeDate()); return(returnList); }
/// <summary> /// 执行导出功能 /// </summary> /// <returns></returns> public DataTable Excute() { List <EmployeeSalary> employeeSalarys = new GetEmployeeAccountSet().GetEmployeeAccountSetByCondition(_EmployeeName, _DepartmentID, _PositionID, _EmployeeTypeEnum, _IsRecursionDepartment, _AccountOperator, _EmployeeStatus); foreach (EmployeeSalary employeeSalary in employeeSalarys) { EmployeeSalary employeeSalaryInfo = new GetEmployeeAccountSet().GetEmployeeAccountSetByEmployeeID(employeeSalary.Employee.Account.Id); if (employeeSalaryInfo != null) { employeeSalary.AccountSet = employeeSalaryInfo.AccountSet; } } //表格组成 DataTable dt = new DataTable(); dt.Columns.Add("员工姓名"); dt.Columns.Add("所属部门"); dt.Columns.Add("职位"); dt.Columns.Add("员工类型"); dt.Columns.Add("帐套名称"); foreach (EmployeeSalary employeeSalary in employeeSalarys) { if (employeeSalary.AccountSet == null || employeeSalary.AccountSet.Items == null) { continue; } foreach (AccountSetItem accountSetItem in employeeSalary.AccountSet.Items) { if (accountSetItem.AccountSetPara.FieldAttribute.Id == FieldAttributeEnum.FixedField.Id && !dt.Columns.Contains(accountSetItem.AccountSetPara.AccountSetParaName)) { dt.Columns.Add(accountSetItem.AccountSetPara.AccountSetParaName); } } } //赋值table foreach (EmployeeSalary employeeSalary in employeeSalarys) { DataRow dr = dt.NewRow(); dr["员工姓名"] = employeeSalary.Employee.Account.Name; dr["所属部门"] = employeeSalary.Employee.Account.Dept.Name; dr["职位"] = employeeSalary.Employee.Account.Position.Name; dr["员工类型"] = EmployeeTypeUtility.EmployeeTypeDisplay(employeeSalary.Employee.EmployeeType); dr["帐套名称"] = employeeSalary.AccountSet.AccountSetName; if (employeeSalary.AccountSet != null && employeeSalary.AccountSet.Items != null) { foreach (AccountSetItem accountSetItem in employeeSalary.AccountSet.Items) { if (accountSetItem.AccountSetPara.FieldAttribute.Id == FieldAttributeEnum.FixedField.Id && dt.Columns.Contains(accountSetItem.AccountSetPara.AccountSetParaName)) { dr[accountSetItem.AccountSetPara.AccountSetParaName] = accountSetItem.CalculateResult; } } } dt.Rows.Add(dr); } return(dt); }
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); }