Esempio n. 1
0
        public double GetDefaultLunch(DatabaseConnection dbConn, DateTime date)
        {
            if (WorkHourPatternWorkDayDetermineMethod.Equals(WORKDAYDETERMINDMETHOD_ROSTERTABLE))
            {
                ERosterCode rosterCode = new ERosterCode();
                rosterCode.RosterCodeID = GetDefaultRosterCodeID(dbConn, date, false, false);
                if (ERosterCode.db.select(dbConn, rosterCode))
                {
                    if (rosterCode.RosterCodeType.Equals(ERosterCode.ROSTERTYPE_CODE_NORMAL) || rosterCode.RosterCodeType.Equals(ERosterCode.ROSTERTYPE_CODE_OVERNIGHT))
                    {
                        if (rosterCode.RosterCodeHasLunch)
                        {
                            double LunchTime = rosterCode.RosterCodeLunchEndTime.TimeOfDay.Subtract(rosterCode.RosterCodeLunchStartTime.TimeOfDay).TotalHours;
                            if (LunchTime < 0)
                            {
                                LunchTime += 24;
                            }
                            return(LunchTime);
                        }
                    }
                }
                return(0);
            }
            else
            {
                if (this.m_WorkHourPatternUseStatutoryHolidayTable)
                {
                    if (EStatutoryHoliday.IsHoliday(dbConn, date))
                    {
                        return(0);
                    }
                }
                if (this.m_WorkHourPatternUsePublicHolidayTable)
                {
                    if (EPublicHoliday.IsHoliday(dbConn, date))
                    {
                        return(0);
                    }
                }

                if (date.DayOfWeek.Equals(DayOfWeek.Sunday))
                {
                    return(m_WorkHourPatternSunLunchTimeHoursPerDay);
                }
                else if (date.DayOfWeek.Equals(DayOfWeek.Monday))
                {
                    return(m_WorkHourPatternMonLunchTimeHoursPerDay);
                }
                else if (date.DayOfWeek.Equals(DayOfWeek.Tuesday))
                {
                    return(m_WorkHourPatternTueLunchTimeHoursPerDay);
                }
                else if (date.DayOfWeek.Equals(DayOfWeek.Wednesday))
                {
                    return(m_WorkHourPatternWedLunchTimeHoursPerDay);
                }
                else if (date.DayOfWeek.Equals(DayOfWeek.Thursday))
                {
                    return(m_WorkHourPatternThuLunchTimeHoursPerDay);
                }
                else if (date.DayOfWeek.Equals(DayOfWeek.Friday))
                {
                    return(m_WorkHourPatternFriLunchTimeHoursPerDay);
                }
                else if (date.DayOfWeek.Equals(DayOfWeek.Saturday))
                {
                    return(m_WorkHourPatternSatLunchTimeHoursPerDay);
                }
                else
                {
                    return(0);
                }
            }
        }
Esempio n. 2
0
        public double GetDefaultWorkHour(DatabaseConnection dbConn, DateTime date)
        {
            if (WorkHourPatternWorkDayDetermineMethod.Equals(WORKDAYDETERMINDMETHOD_ROSTERTABLE))
            {
                ERosterCode rosterCode = new ERosterCode();
                rosterCode.RosterCodeID = GetDefaultRosterCodeID(dbConn, date, false, false);
                if (ERosterCode.db.select(dbConn, rosterCode))
                {
                    if (rosterCode.RosterCodeType.Equals(ERosterCode.ROSTERTYPE_CODE_NORMAL) || rosterCode.RosterCodeType.Equals(ERosterCode.ROSTERTYPE_CODE_OVERNIGHT))
                    {
                        return(rosterCode.RosterCodeDailyWorkingHour);
                    }
                }
                return(0);
            }
            else
            {
                if (this.m_WorkHourPatternUseStatutoryHolidayTable)
                {
                    if (EStatutoryHoliday.IsHoliday(dbConn, date))
                    {
                        return(0);
                    }
                }
                if (this.m_WorkHourPatternUsePublicHolidayTable)
                {
                    if (EPublicHoliday.IsHoliday(dbConn, date))
                    {
                        return(0);
                    }
                }

                if (date.DayOfWeek.Equals(DayOfWeek.Sunday))
                {
                    //if (m_WorkHourPatternSunWorkHoursPerDay > 0)
                    return(m_WorkHourPatternSunWorkHoursPerDay);
                }
                //else
                //    return m_WorkHourPatternSunDefaultDayUnit * m_WorkHourPatternContractWorkHoursPerDay;
                else if (date.DayOfWeek.Equals(DayOfWeek.Monday))
                {
                    //if (m_WorkHourPatternMonWorkHoursPerDay > 0)
                    return(m_WorkHourPatternMonWorkHoursPerDay);
                }
                //else
                //    return m_WorkHourPatternMonDefaultDayUnit * m_WorkHourPatternContractWorkHoursPerDay;
                else if (date.DayOfWeek.Equals(DayOfWeek.Tuesday))
                {
                    //if (m_WorkHourPatternTueWorkHoursPerDay > 0)
                    return(m_WorkHourPatternTueWorkHoursPerDay);
                }
                //else
                //    return m_WorkHourPatternTueDefaultDayUnit * m_WorkHourPatternContractWorkHoursPerDay;
                else if (date.DayOfWeek.Equals(DayOfWeek.Wednesday))
                {
                    //if (m_WorkHourPatternWedWorkHoursPerDay > 0)
                    return(m_WorkHourPatternWedWorkHoursPerDay);
                }
                //else
                //    return m_WorkHourPatternWedDefaultDayUnit * m_WorkHourPatternContractWorkHoursPerDay;
                else if (date.DayOfWeek.Equals(DayOfWeek.Thursday))
                {
                    //if (m_WorkHourPatternThuWorkHoursPerDay > 0)
                    return(m_WorkHourPatternThuWorkHoursPerDay);
                }
                //else
                //    return m_WorkHourPatternThuDefaultDayUnit * m_WorkHourPatternContractWorkHoursPerDay;
                else if (date.DayOfWeek.Equals(DayOfWeek.Friday))
                {
                    //if (m_WorkHourPatternFriWorkHoursPerDay > 0)
                    return(m_WorkHourPatternFriWorkHoursPerDay);
                }
                //else
                //    return m_WorkHourPatternFriDefaultDayUnit * m_WorkHourPatternContractWorkHoursPerDay;
                else if (date.DayOfWeek.Equals(DayOfWeek.Saturday))
                {
                    //if (m_WorkHourPatternSatWorkHoursPerDay > 0)
                    return(m_WorkHourPatternSatWorkHoursPerDay);
                }
                //else
                //    return m_WorkHourPatternSatDefaultDayUnit * m_WorkHourPatternContractWorkHoursPerDay;
                else
                {
                    return(0);
                }
            }
        }
Esempio n. 3
0
        public int GetDefaultRosterCodeID(DatabaseConnection dbConn, DateTime date, bool SkipStatutoryHolidayChecking, bool SkipPublicHolidayChecking)
        {
            if (!WorkHourPatternWorkDayDetermineMethod.Equals(WORKDAYDETERMINDMETHOD_ROSTERTABLE))
            {
                return(0);
            }
            else
            {
                if (this.m_WorkHourPatternUseStatutoryHolidayTable)
                {
                    if (EStatutoryHoliday.IsHoliday(dbConn, date))
                    {
                        if (!SkipStatutoryHolidayChecking)
                        {
                            return(this.m_WorkHourPatternStatutoryHolidayDefaultRosterCodeID);
                        }
                    }
                }
                if (this.m_WorkHourPatternUsePublicHolidayTable)
                {
                    if (EPublicHoliday.IsHoliday(dbConn, date))
                    {
                        if (!SkipPublicHolidayChecking)
                        {
                            return(this.m_WorkHourPatternPublicHolidayDefaultRosterCodeID);
                        }
                    }
                }

                if (date.DayOfWeek.Equals(DayOfWeek.Sunday))
                {
                    return(m_WorkHourPatternSunDefaultRosterCodeID);
                }
                else if (date.DayOfWeek.Equals(DayOfWeek.Monday))
                {
                    return(m_WorkHourPatternMonDefaultRosterCodeID);
                }
                else if (date.DayOfWeek.Equals(DayOfWeek.Tuesday))
                {
                    return(m_WorkHourPatternTueDefaultRosterCodeID);
                }
                else if (date.DayOfWeek.Equals(DayOfWeek.Wednesday))
                {
                    return(m_WorkHourPatternWedDefaultRosterCodeID);
                }
                else if (date.DayOfWeek.Equals(DayOfWeek.Thursday))
                {
                    return(m_WorkHourPatternThuDefaultRosterCodeID);
                }
                else if (date.DayOfWeek.Equals(DayOfWeek.Friday))
                {
                    return(m_WorkHourPatternFriDefaultRosterCodeID);
                }
                else if (date.DayOfWeek.Equals(DayOfWeek.Saturday))
                {
                    return(m_WorkHourPatternSatDefaultRosterCodeID);
                }
                else
                {
                    return(0);
                }
            }
        }
Esempio n. 4
0
        public double GetDefaultDayUnit(DatabaseConnection dbConn, DateTime date, bool SkipStatutoryHolidayChecking, bool SkipPublicHolidayChecking)
        {
            if (WorkHourPatternWorkDayDetermineMethod.Equals(WORKDAYDETERMINDMETHOD_ROSTERTABLE))
            {
                ERosterCode rosterCode = new ERosterCode();
                rosterCode.RosterCodeID = GetDefaultRosterCodeID(dbConn, date, SkipStatutoryHolidayChecking, SkipPublicHolidayChecking);
                if (ERosterCode.db.select(dbConn, rosterCode))
                {
                    if (rosterCode.RosterCodeType.Equals(ERosterCode.ROSTERTYPE_CODE_NORMAL) || rosterCode.RosterCodeType.Equals(ERosterCode.ROSTERTYPE_CODE_OVERNIGHT))
                    {
                        return(rosterCode.RosterCodeWorkingDayUnit);
                    }
                }
                return(0);
            }
            else
            {
                if (this.m_WorkHourPatternUseStatutoryHolidayTable)
                {
                    if (EStatutoryHoliday.IsHoliday(dbConn, date))
                    {
                        if (!SkipStatutoryHolidayChecking)
                        {
                            return(0);
                        }
                    }
                }
                if (this.m_WorkHourPatternUsePublicHolidayTable)
                {
                    if (EPublicHoliday.IsHoliday(dbConn, date))
                    {
                        if (!SkipPublicHolidayChecking)
                        {
                            return(0);
                        }
                    }
                }

                if (date.DayOfWeek.Equals(DayOfWeek.Sunday))
                {
                    return(m_WorkHourPatternSunDefaultDayUnit);
                }
                else if (date.DayOfWeek.Equals(DayOfWeek.Monday))
                {
                    return(m_WorkHourPatternMonDefaultDayUnit);
                }
                else if (date.DayOfWeek.Equals(DayOfWeek.Tuesday))
                {
                    return(m_WorkHourPatternTueDefaultDayUnit);
                }
                else if (date.DayOfWeek.Equals(DayOfWeek.Wednesday))
                {
                    return(m_WorkHourPatternWedDefaultDayUnit);
                }
                else if (date.DayOfWeek.Equals(DayOfWeek.Thursday))
                {
                    return(m_WorkHourPatternThuDefaultDayUnit);
                }
                else if (date.DayOfWeek.Equals(DayOfWeek.Friday))
                {
                    return(m_WorkHourPatternFriDefaultDayUnit);
                }
                else if (date.DayOfWeek.Equals(DayOfWeek.Saturday))
                {
                    return(m_WorkHourPatternSatDefaultDayUnit);
                }
                else
                {
                    return(0);
                }
            }
        }
Esempio n. 5
0
        public static double GetEstimatedNumOfLeaveDays(DatabaseConnection dbConn, int EmpID, DateTime DateFrom, DateTime DateTo, int LeaveCodeID, out DateTime[] DateSkipArray)
        {
            System.Collections.ArrayList dateSkipArrayList = new System.Collections.ArrayList();

            EEmpPositionInfo empPos    = null;
            double           totalDays = 0;

            ELeaveType leaveType = new ELeaveType();

            leaveType.LeaveTypeIsUseWorkHourPattern = true;

            ELeaveCode leaveCode = new ELeaveCode();

            leaveCode.LeaveCodeID = LeaveCodeID;
            if (ELeaveCode.db.select(dbConn, leaveCode))
            {
                leaveType.LeaveTypeID = leaveCode.LeaveTypeID;
                ELeaveType.db.select(dbConn, leaveType);
            }
            for (DateTime currentDate = DateFrom; currentDate <= DateTo; currentDate = currentDate.AddDays(1))
            {
                //  default every date count = 1
                double dateCount = 1;
                if (EStatutoryHoliday.IsHoliday(dbConn, currentDate))
                {
                    if (!leaveType.LeaveTypeIsSkipStatutoryHolidayChecking)
                    {
                        dateCount = 0;
                    }
                }
                else if (EPublicHoliday.IsHoliday(dbConn, currentDate))
                {
                    if (!leaveType.LeaveTypeIsSkipPublicHolidayChecking)
                    {
                        dateCount = 0;
                    }
                }

                if (empPos == null)
                {
                    empPos = AppUtils.GetLastPositionInfo(dbConn, currentDate, EmpID);
                }
                else
                if (!empPos.EmpPosEffTo.Ticks.Equals(0) && empPos.EmpPosEffTo <= currentDate)
                {
                    empPos = AppUtils.GetLastPositionInfo(dbConn, currentDate, EmpID);
                }

                if (empPos != null)
                {
                    EWorkHourPattern workPattern = new EWorkHourPattern();
                    workPattern.WorkHourPatternID = empPos.WorkHourPatternID;
                    if (EWorkHourPattern.db.select(dbConn, workPattern))
                    {
                        if (leaveType.LeaveTypeIsUseWorkHourPattern)
                        {
                            dateCount = workPattern.GetDefaultDayUnit(dbConn, currentDate, leaveType.LeaveTypeIsSkipStatutoryHolidayChecking, leaveType.LeaveTypeIsSkipPublicHolidayChecking);
                        }
                    }
                }


                totalDays += dateCount;

                if (dateCount <= 0)
                {
                    dateSkipArrayList.Add(currentDate);
                }
            }

            DateSkipArray = (DateTime[])dateSkipArrayList.ToArray(typeof(DateTime));
            return(totalDays);
        }