Beispiel #1
0
        public static List <ERosterTable> GetRosterTableList(DatabaseConnection dbConn, int EmpID, DateTime RosterDate)
        {
            SortedList <TimeSpan, ERosterTable> ResultRosterTableList = new SortedList <TimeSpan, ERosterTable>();

            DBFilter rosterTableFilter = new DBFilter();

            rosterTableFilter.add(new Match("EmpID", EmpID));
            rosterTableFilter.add(new Match("RosterTableDate", "=", RosterDate));
            System.Collections.ArrayList rosterTableList = ERosterTable.db.select(dbConn, rosterTableFilter);
            if (rosterTableList.Count > 0)
            {
                int count = 0;
                foreach (ERosterTable rosterTable in rosterTableList)
                {
                    // sort the time if roster table is multiple roster code
                    // use millsecond for first in first out basis if the in time is same
                    ERosterCode rosterCode = new ERosterCode();
                    rosterCode.RosterCodeID = rosterTable.RosterCodeID;
                    if (ERosterCode.db.select(dbConn, rosterCode))
                    {
                        ResultRosterTableList.Add(rosterCode.RosterCodeInTime.TimeOfDay.Add(new TimeSpan(0, 0, 0, 0, count++)), rosterTable);
                    }
                }
            }
            else
            {
                ERosterTable rosterTable = new ERosterTable();
                rosterTable.EmpID           = EmpID;
                rosterTable.RosterTableDate = RosterDate;
                rosterTable.RosterCodeID    = 0;

                EEmpPositionInfo empPosInfo = AppUtils.GetLastPositionInfo(dbConn, RosterDate, EmpID);
                if (empPosInfo != null)
                {
                    if ((empPosInfo.EmpPosEffTo.Ticks.Equals(0) || RosterDate <= empPosInfo.EmpPosEffTo))
                    {
                        EWorkHourPattern workPattern = new EWorkHourPattern();
                        workPattern.WorkHourPatternID = empPosInfo.WorkHourPatternID;
                        if (EWorkHourPattern.db.select(dbConn, workPattern))
                        {
                            ERosterCode rosterCode = new ERosterCode();
                            rosterCode.RosterCodeID = workPattern.GetDefaultRosterCodeID(dbConn, RosterDate);
                            if (ERosterCode.db.select(dbConn, rosterCode))
                            {
                                rosterTable.RosterCodeID = rosterCode.RosterCodeID;
                            }
                        }
                    }
                }
                ResultRosterTableList.Add(new TimeSpan(), rosterTable);
            }
            return(new List <ERosterTable>(ResultRosterTableList.Values));
        }
 public static EEmpPositionInfo GetObject(DatabaseConnection dbConn, object ID)
 {
     if (ID is int)
     {
         EEmpPositionInfo obj = new EEmpPositionInfo();
         obj.EmpPosID = (int)ID;
         if (db.select(dbConn, obj))
         {
             return(obj);
         }
     }
     return(null);
 }
Beispiel #3
0
        public bool IsChangeSite(DatabaseConnection dbConn)
        {
            ERosterCode rosterCode = new ERosterCode();

            rosterCode.RosterCodeID = m_RosterCodeID;
            if (ERosterCode.db.select(dbConn, rosterCode))
            {
                ERosterClientSite site = new ERosterClientSite();
                site.RosterClientSiteID = rosterCode.RosterClientSiteID;
                if (ERosterClientSite.db.select(dbConn, site))
                {
                    ERosterClient client = new ERosterClient();
                    client.RosterClientID = site.RosterClientID;
                    if (ERosterClient.db.select(dbConn, client))
                    {
                        EHierarchyLevel hLevel = new EHierarchyLevel();
                        hLevel.HLevelID = client.RosterClientMappingSiteCodeToHLevelID;
                        if (EHierarchyLevel.db.select(dbConn, hLevel))
                        {
                            EEmpPositionInfo empPos = AppUtils.GetLastPositionInfo(dbConn, m_AttendanceRecordDate, m_EmpID);
                            if (empPos != null)
                            {
                                DBFilter empHierarchyFilter = new DBFilter();
                                empHierarchyFilter.add(new Match("EmpPosID", empPos.EmpPosID));
                                empHierarchyFilter.add(new Match("HLevelID", hLevel.HLevelID));

                                System.Collections.ArrayList empHierarchyList = EEmpHierarchy.db.select(dbConn, empHierarchyFilter);
                                foreach (EEmpHierarchy empHierarchy in empHierarchyList)
                                {
                                    EHierarchyElement hElement = new EHierarchyElement();
                                    hElement.HElementID = empHierarchy.HElementID;
                                    if (EHierarchyElement.db.select(dbConn, hElement))
                                    {
                                        if (!hElement.HElementCode.Trim().Equals(site.RosterClientSiteCode.Trim(), StringComparison.CurrentCultureIgnoreCase))
                                        {
                                            return(true);
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
            return(false);
        }
        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);
        }