Exemplo n.º 1
0
        protected override void afterUpdate(DatabaseConnection dbConn, DBManager db)
        {
            int      oldLeaveCodeID   = 0;
            int      newLeaveCodeID   = m_LeaveCodeID;
            DateTime oldLeaveDateFrom = new DateTime();
            DateTime newLeaveDateFrom = m_LeaveAppDateFrom;

            if (oldValueObject != null)
            {
                ELeaveApplication oldLeaveApp = (ELeaveApplication)oldValueObject;
                oldLeaveCodeID   = oldLeaveApp.LeaveCodeID;
                oldLeaveDateFrom = oldLeaveApp.LeaveAppDateFrom;
            }
            {
                ELeaveCode leaveCode = new ELeaveCode();
                leaveCode.LeaveCodeID = oldLeaveCodeID;
                if (ELeaveCode.db.select(dbConn, leaveCode))
                {
                    ELeaveBalance.DeleteLeaveBalanceAfter(dbConn, this.EmpID, leaveCode.LeaveTypeID, oldLeaveDateFrom);
                }
                leaveCode.LeaveCodeID = newLeaveCodeID;
                if (ELeaveCode.db.select(dbConn, leaveCode))
                {
                    ELeaveBalance.DeleteLeaveBalanceAfter(dbConn, this.EmpID, leaveCode.LeaveTypeID, newLeaveDateFrom);
                }
            }

            base.afterUpdate(dbConn, db);
        }
Exemplo n.º 2
0
        private static void DeleteLeaveApplication(DatabaseConnection dbConn, ERosterTable rosterTable)
        {
            if (rosterTable.LeaveAppID > 0)
            {
                DBFilter attendanceRecordFilter = new DBFilter();
                attendanceRecordFilter.add(new Match("LeaveAppID", rosterTable.LeaveAppID));

                //  do not delete leave application if the attendance record use that leave application
                if (EAttendanceRecord.db.count(dbConn, attendanceRecordFilter) > 0)
                {
                    return;
                }

                ERosterCode rosterCode = new ERosterCode();
                rosterCode.RosterCodeID = rosterTable.RosterCodeID;
                if (ERosterCode.db.select(dbConn, rosterCode))
                {
                    ELeaveApplication leaveApp = new ELeaveApplication();
                    leaveApp.LeaveAppID = rosterTable.LeaveAppID;
                    if (ELeaveApplication.db.select(dbConn, leaveApp))
                    {
                        if (leaveApp.EmpPayrollID <= 0 &&
                            rosterCode.LeaveCodeID.Equals(leaveApp.LeaveCodeID) &&
                            rosterTable.RosterTableDate.Equals(leaveApp.LeaveAppDateFrom) &&
                            rosterTable.RosterTableDate.Equals(leaveApp.LeaveAppDateTo)
                            )
                        {
                            ELeaveCode leaveCode = new ELeaveCode();
                            leaveCode.LeaveCodeID = leaveApp.LeaveCodeID;
                            if (ELeaveCode.db.select(dbConn, leaveCode))
                            {
                                ELeaveApplication.db.delete(dbConn, leaveApp);
                            }
                        }
                    }
                }
            }
            if (rosterTable.RosterCodeID > 0 && rosterTable.LeaveAppID <= 0)
            {
                ERosterCode rosterCode = new ERosterCode();
                rosterCode.RosterCodeID = rosterTable.RosterCodeID;
                if (ERosterCode.db.select(dbConn, rosterCode))
                {
                    if (rosterCode.RosterCodeType.Equals(ERosterCode.ROSTERTYPE_CODE_RESTDAY))
                    {
                        ELeaveBalance.DeleteLeaveBalanceAfter(dbConn, rosterTable.EmpID, ELeaveType.RESTDAY_LEAVE_TYPE(dbConn).LeaveTypeID, rosterTable.RosterTableDate);
                    }
                    else if (rosterCode.RosterCodeType.Equals(ERosterCode.ROSTERTYPE_CODE_STATUTORYHOLIDAY))
                    {
                        ELeaveBalance.DeleteLeaveBalanceAfter(dbConn, rosterTable.EmpID, ELeaveType.STATUTORYHOLIDAY_LEAVE_TYPE(dbConn).LeaveTypeID, rosterTable.RosterTableDate);
                    }
                    else if (rosterCode.RosterCodeType.Equals(ERosterCode.ROSTERTYPE_CODE_PUBLICHOLIDAY))
                    {
                        ELeaveBalance.DeleteLeaveBalanceAfter(dbConn, rosterTable.EmpID, ELeaveType.PUBLICHOLIDAY_LEAVE_TYPE(dbConn).LeaveTypeID, rosterTable.RosterTableDate);
                    }
                }
            }
        }
Exemplo n.º 3
0
        protected override void afterDelete(DatabaseConnection dbConn, DBManager db)
        {
            base.afterDelete(dbConn, db);

            ELeaveCode leaveCode = new ELeaveCode();

            leaveCode.LeaveCodeID = this.LeaveCodeID;
            if (ELeaveCode.db.select(dbConn, leaveCode))
            {
                ELeaveBalance.DeleteLeaveBalanceAfter(dbConn, this.EmpID, leaveCode.LeaveTypeID, this.LeaveAppDateFrom);
            }
        }
Exemplo n.º 4
0
        private static void CreateLeaveApplication(DatabaseConnection dbConn, EAttendanceRecord attendanceRecord)
        {
            if (attendanceRecord.LeaveAppID > 0)
            {
                ELeaveApplication leaveApp = new ELeaveApplication();
                leaveApp.LeaveAppID = attendanceRecord.LeaveAppID;
                if (!ELeaveApplication.db.select(dbConn, leaveApp))
                {
                    attendanceRecord.LeaveAppID = 0;
                }
            }

            //  Check  LeaveAppID <= 0 To prevent override LeaveAppID created by external function
            if (attendanceRecord.RosterCodeID > 0 && attendanceRecord.LeaveAppID <= 0)
            {
                ERosterCode rosterCode = new ERosterCode();
                rosterCode.RosterCodeID = attendanceRecord.RosterCodeID;
                if (ERosterCode.db.select(dbConn, rosterCode))
                {
                    if (rosterCode.RosterCodeType.Equals(ERosterCode.ROSTERTYPE_CODE_LEAVE) && rosterCode.LeaveCodeID > 0)
                    {
                        ELeaveCode leaveCode = new ELeaveCode();
                        leaveCode.LeaveCodeID = rosterCode.LeaveCodeID;
                        if (ELeaveCode.db.select(dbConn, leaveCode))
                        {
                            ELeaveApplication leaveApp = ELeaveApplication.GetOrCreateSingleDayLeaveApplicationObject(dbConn, attendanceRecord.EmpID, rosterCode.LeaveCodeID, attendanceRecord.AttendanceRecordDate);

                            if (leaveApp != null)
                            {
                                if (leaveApp.LeaveAppID <= 0)
                                {
                                    ELeaveApplication.db.insert(dbConn, leaveApp);
                                    attendanceRecord.LeaveAppID = leaveApp.LeaveAppID;
                                }
                            }
                        }
                    }
                    else if (rosterCode.RosterCodeType.Equals(ERosterCode.ROSTERTYPE_CODE_RESTDAY))
                    {
                        ELeaveBalance.DeleteLeaveBalanceAfter(dbConn, attendanceRecord.EmpID, ELeaveType.RESTDAY_LEAVE_TYPE(dbConn).LeaveTypeID, attendanceRecord.AttendanceRecordDate);
                    }
                    else if (rosterCode.RosterCodeType.Equals(ERosterCode.ROSTERTYPE_CODE_STATUTORYHOLIDAY))
                    {
                        ELeaveBalance.DeleteLeaveBalanceAfter(dbConn, attendanceRecord.EmpID, ELeaveType.STATUTORYHOLIDAY_LEAVE_TYPE(dbConn).LeaveTypeID, attendanceRecord.AttendanceRecordDate);
                    }
                    else if (rosterCode.RosterCodeType.Equals(ERosterCode.ROSTERTYPE_CODE_PUBLICHOLIDAY))
                    {
                        ELeaveBalance.DeleteLeaveBalanceAfter(dbConn, attendanceRecord.EmpID, ELeaveType.PUBLICHOLIDAY_LEAVE_TYPE(dbConn).LeaveTypeID, attendanceRecord.AttendanceRecordDate);
                    }
                }
            }
        }
Exemplo n.º 5
0
        public static WFValueList VLLeaveCode = new AppUtils.EncryptedDBCodeList(ELeaveCode.db, "LeaveCodeID", new string[] { "LeaveCode", "LeaveCodeDesc" }, " - ", "LeaveCode");//new WFDBList(ELeaveCode.db, "LeaveCodeID", "LeaveCodeDesc", "LeaveCodeDesc");

        public static ELeaveCode GetObject(DatabaseConnection dbConn, int ID)
        {
            ELeaveCode obj = new ELeaveCode();

            obj.LeaveCodeID = ID;

            if (ELeaveCode.db.select(dbConn, obj))
            {
                return(obj);
            }

            return(null);
        }
Exemplo n.º 6
0
        private static void CreateLeaveApplication(DatabaseConnection dbConn, ERosterTable rosterTable)
        {
            if (rosterTable.LeaveAppID == 0)
            {
                DBFilter attendanceRecordFilter = new DBFilter();
                attendanceRecordFilter.add(new Match("EmpID", rosterTable.EmpID));
                attendanceRecordFilter.add(new Match("AttendanceRecordDate", rosterTable.RosterTableDate));
                attendanceRecordFilter.add(new Match("RosterCodeID", rosterTable.RosterCodeID));
                attendanceRecordFilter.add(new Match("LeaveAppID", ">", 0));
                System.Collections.ArrayList existingAttendanceRecordList = EAttendanceRecord.db.select(dbConn, attendanceRecordFilter);
                //  do not create leave application if the attendance record for that day exists
                if (existingAttendanceRecordList.Count > 0)
                {
                    rosterTable.LeaveAppID = ((EAttendanceRecord)existingAttendanceRecordList[0]).LeaveAppID;
                    return;
                }
            }
            if (rosterTable.LeaveAppID == 0)
            {
                DBFilter attendanceRecordFilter = new DBFilter();
                attendanceRecordFilter.add(new Match("EmpID", rosterTable.EmpID));
                attendanceRecordFilter.add(new Match("AttendanceRecordDate", rosterTable.RosterTableDate));
                attendanceRecordFilter.add(new Match("RosterCodeID", "<>", rosterTable.RosterCodeID));
                //  do not create leave application if the attendance record for that day exists
                if (EAttendanceRecord.db.count(dbConn, attendanceRecordFilter) > 0)
                {
                    return;
                }
            }
            if (rosterTable.LeaveAppID > 0)
            {
                ELeaveApplication leaveApp = new ELeaveApplication();
                leaveApp.LeaveAppID = rosterTable.LeaveAppID;
                if (!ELeaveApplication.db.select(dbConn, leaveApp))
                {
                    rosterTable.LeaveAppID = 0;
                }
            }
            //  Check  LeaveAppID <= 0 To prevent override LeaveAppID created by external function
            if (rosterTable.RosterCodeID > 0 && rosterTable.LeaveAppID <= 0)
            {
                ERosterCode rosterCode = new ERosterCode();
                rosterCode.RosterCodeID = rosterTable.RosterCodeID;
                if (ERosterCode.db.select(dbConn, rosterCode))
                {
                    if (rosterCode.RosterCodeType.Equals(ERosterCode.ROSTERTYPE_CODE_LEAVE) && rosterCode.LeaveCodeID > 0)
                    {
                        ELeaveCode leaveCode = new ELeaveCode();
                        leaveCode.LeaveCodeID = rosterCode.LeaveCodeID;
                        if (ELeaveCode.db.select(dbConn, leaveCode))
                        {
                            ELeaveApplication leaveApp = ELeaveApplication.GetOrCreateSingleDayLeaveApplicationObject(dbConn, rosterTable.EmpID, rosterCode.LeaveCodeID, rosterTable.RosterTableDate);

                            if (leaveApp != null)
                            {
                                if (leaveApp.LeaveAppID <= 0)
                                {
                                    ELeaveApplication.db.insert(dbConn, leaveApp);
                                    rosterTable.LeaveAppID = leaveApp.LeaveAppID;
                                }
                            }
                        }
                    }
                    else if (rosterCode.RosterCodeType.Equals(ERosterCode.ROSTERTYPE_CODE_RESTDAY))
                    {
                        ELeaveBalance.DeleteLeaveBalanceAfter(dbConn, rosterTable.EmpID, ELeaveType.RESTDAY_LEAVE_TYPE(dbConn).LeaveTypeID, rosterTable.RosterTableDate);
                    }
                    else if (rosterCode.RosterCodeType.Equals(ERosterCode.ROSTERTYPE_CODE_STATUTORYHOLIDAY))
                    {
                        ELeaveBalance.DeleteLeaveBalanceAfter(dbConn, rosterTable.EmpID, ELeaveType.STATUTORYHOLIDAY_LEAVE_TYPE(dbConn).LeaveTypeID, rosterTable.RosterTableDate);
                    }
                    else if (rosterCode.RosterCodeType.Equals(ERosterCode.ROSTERTYPE_CODE_PUBLICHOLIDAY))
                    {
                        ELeaveBalance.DeleteLeaveBalanceAfter(dbConn, rosterTable.EmpID, ELeaveType.PUBLICHOLIDAY_LEAVE_TYPE(dbConn).LeaveTypeID, rosterTable.RosterTableDate);
                    }
                }
            }
        }
Exemplo n.º 7
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);
        }