Exemple #1
0
        /// <summary>
        /// 把员工的考勤情况,如外出,加班,请假,迟到早退等信息赋值给员工,用于在日历控件中显示员工的考勤情况
        /// </summary>
        public Employee GetCalendarByEmployee(int EmployeeID, DateTime From, DateTime To)
        {
            Employee employee = _dalEmployee.GetEmployeeByAccountID(EmployeeID);

            employee.EmployeeAttendance = new EmployeeAttendance(From, To);

            //迟到早退旷工详情
            employee.EmployeeAttendance.DayAttendanceList.AddRange(
                _GetBadAttendance.GetCalendarByEmployee(EmployeeID, From, To, AttendanceTypeEmnu.All));
            //请假详情
            employee.EmployeeAttendance.DayAttendanceList.AddRange(
                _GetLeaveRequest.GetAllCalendarByEmployee(EmployeeID, From, To));
            //加班外出申请
            employee.EmployeeAttendance.DayAttendanceList.AddRange(
                _GetOutApplication.GetAllCalendarByEmployee(EmployeeID, From, To));
            employee.EmployeeAttendance.DayAttendanceList.AddRange(
                _GetOverWork.GetAllCalendarByEmployee(EmployeeID, From, To));

            return(employee);
        }
        ///<summary>
        /// 通过员工姓名部门,得到考勤情况,获得正在进行审批或者审批结束的所有考勤
        ///</summary>
        ///<returns></returns>
        public List <Employee> GetAllEmployeeAttendanceByCondition(string EmployeeName, int DepartmentID, int?gradesId,
                                                                   DateTime FromDate, DateTime ToDate, Account _Account, int powers)
        {
            _GetBadAttendance = new GetBadAttendance(_Account);

            List <Employee> retEmployeeList = new List <Employee>();
            //List<EmployeeAttendance> EmployeeAttendanceList=new List<EmployeeAttendance>();
            //获取符合条件的员工

            List <Account> AccountList =
                _IAccountBll.GetAccountByBaseCondition(EmployeeName, DepartmentID, -1, gradesId, true, null);

            if (DepartmentID == -1)
            {
                AccountList = Tools.RemoteUnAuthAccount(AccountList, AuthType.HRMIS, _Account, powers);
            }
            List <Employee> EmployeeList = new List <Employee>();

            foreach (Account account in AccountList)
            {
                Employee employee = _GetEmployee.GetEmployeeByAccountID(account.Id);
                if (employee == null)
                {
                    continue;
                }
                employee.Account = account;
                EmployeeList.Add(employee);
            }

            for (int i = 0; i < EmployeeList.Count; i++)
            {
                if (EmployeeList[i].EmployeeType == EmployeeTypeEnum.BorrowedEmployee)
                {
                    continue;
                }
                //根据入职离职时间确定考勤的有效时间
                DateTime employeeFromDate = DateTime.Compare(EmployeeList[i].EmployeeDetails.Work.ComeDate, FromDate) > 0
                                                ? EmployeeList[i].EmployeeDetails.Work.ComeDate
                                                : FromDate;
                DateTime employeeToDate;
                if (EmployeeList[i].EmployeeType == EmployeeTypeEnum.DimissionEmployee && EmployeeList[i].EmployeeDetails.Work.DimissionInfo != null)
                {
                    employeeToDate =
                        DateTime.Compare(EmployeeList[i].EmployeeDetails.Work.DimissionInfo.DimissionDate, ToDate) < 0
                            ? EmployeeList[i].EmployeeDetails.Work.DimissionInfo.DimissionDate
                            : ToDate;
                }
                else
                {
                    employeeToDate = ToDate;
                }
                employeeToDate = employeeToDate.AddDays(1).AddSeconds(-1);
                if (DateTime.Compare(employeeFromDate, employeeToDate) > 0)
                {
                    continue;
                }
                EmployeeList[i].EmployeeAttendance = new EmployeeAttendance(employeeFromDate, employeeToDate);
                //打卡信息
                EmployeeList[i].EmployeeAttendance.AttendanceInAndOutRecordList =
                    _dalAttendanceInAndOutRecord.GetAttendanceInAndOutRecordByCondition(EmployeeList[i].Account.Id, "",
                                                                                        employeeFromDate,
                                                                                        employeeToDate,
                                                                                        InOutStatusEnum.All,
                                                                                        OutInRecordOperateStatusEnum.All,
                                                                                        Convert.ToDateTime("1900-1-1"),
                                                                                        Convert.ToDateTime("2900-12-31"));
                //考勤规则
                EmployeeList[i].EmployeeAttendance.PlanDutyDetailList =
                    _IPlanDutyDal.GetPlanDutyDetailByAccount(EmployeeList[i].Account.Id, employeeFromDate, employeeToDate);
                //迟到早退旷工详情
                EmployeeList[i].EmployeeAttendance.DayAttendanceList.AddRange(
                    _GetBadAttendance.GetCalendarByEmployee(EmployeeList[i].Account.Id,
                                                            EmployeeList[i].EmployeeAttendance.FromDate,
                                                            EmployeeList[i].EmployeeAttendance.ToDate, AttendanceTypeEmnu.All));
                //请假详情
                EmployeeList[i].EmployeeAttendance.DayAttendanceList.AddRange(
                    _GetLeaveRequest.GetAllCalendarByEmployee(EmployeeList[i].Account.Id,
                                                              EmployeeList[i].EmployeeAttendance.FromDate,
                                                              EmployeeList[i].EmployeeAttendance.ToDate));
                //加班外出申请
                EmployeeList[i].EmployeeAttendance.DayAttendanceList.AddRange(
                    _GetOutApplication.GetAllCalendarByEmployee(EmployeeList[i].Account.Id,
                                                                EmployeeList[i].EmployeeAttendance.FromDate,
                                                                EmployeeList[i].EmployeeAttendance.ToDate));
                EmployeeList[i].EmployeeAttendance.DayAttendanceList.AddRange(
                    _GetOverWork.GetAllCalendarByEmployee(EmployeeList[i].Account.Id,
                                                          EmployeeList[i].EmployeeAttendance.FromDate,
                                                          EmployeeList[i].EmployeeAttendance.ToDate));

                retEmployeeList.Add(EmployeeList[i]);
            }
            return(retEmployeeList);
        }