コード例 #1
0
        protected override void afterUpdate(DatabaseConnection dbConn, DBManager db)
        {
            int      oldLeaveTypeID = 0;
            int      newLeaveTypeID = m_LeaveTypeID;
            DateTime oldLeaveBalanceEntitleDateExpiry = new DateTime();
            DateTime newLeaveBalanceEntitleDateExpiry = m_LeaveBalanceEntitleDateExpiry;

            if (oldValueObject != null)
            {
                ELeaveBalanceEntitle oldLeaveBalanceEntitle = (ELeaveBalanceEntitle)oldValueObject;
                oldLeaveTypeID = oldLeaveBalanceEntitle.LeaveTypeID;
                oldLeaveBalanceEntitleDateExpiry = oldLeaveBalanceEntitle.LeaveBalanceEntitleDateExpiry;
            }
            {
                ELeaveType leaveType = new ELeaveType();
                if (!oldLeaveBalanceEntitleDateExpiry.Ticks.Equals(0))
                {
                    leaveType.LeaveTypeID = oldLeaveTypeID;
                    if (ELeaveType.db.select(dbConn, leaveType))
                    {
                        ELeaveBalance.DeleteLeaveBalanceAfter(dbConn, this.EmpID, leaveType.LeaveTypeID, oldLeaveBalanceEntitleDateExpiry);
                    }
                }
                if (!newLeaveBalanceEntitleDateExpiry.Ticks.Equals(0))
                {
                    leaveType.LeaveTypeID = newLeaveTypeID;
                    if (ELeaveType.db.select(dbConn, leaveType))
                    {
                        ELeaveBalance.DeleteLeaveBalanceAfter(dbConn, this.EmpID, leaveType.LeaveTypeID, newLeaveBalanceEntitleDateExpiry);
                    }
                }
            }

            base.afterUpdate(dbConn, db);
        }
コード例 #2
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);
        }
コード例 #3
0
ファイル: RosterTable.cs プロジェクト: dhamotharang/H-R-One
        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);
                    }
                }
            }
        }
コード例 #4
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);
            }
        }
コード例 #5
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);
                    }
                }
            }
        }
コード例 #6
0
 private static void DeleteLeaveApplication(DatabaseConnection dbConn, EAttendanceRecord attendanceRecord)
 {
     if (attendanceRecord.LeaveAppID > 0)
     {
         ERosterCode rosterCode = new ERosterCode();
         rosterCode.RosterCodeID = attendanceRecord.RosterCodeID;
         if (ERosterCode.db.select(dbConn, rosterCode))
         {
             ELeaveApplication leaveApp = new ELeaveApplication();
             leaveApp.LeaveAppID = attendanceRecord.LeaveAppID;
             if (ELeaveApplication.db.select(dbConn, leaveApp))
             {
                 if (leaveApp.EmpPayrollID <= 0 &&
                     rosterCode.LeaveCodeID.Equals(leaveApp.LeaveCodeID) &&
                     attendanceRecord.AttendanceRecordDate.Equals(leaveApp.LeaveAppDateFrom) &&
                     attendanceRecord.AttendanceRecordDate.Equals(leaveApp.LeaveAppDateTo)
                     )
                 {
                     //ELeaveCode leaveCode = new ELeaveCode();
                     //leaveCode.LeaveCodeID = leaveApp.LeaveCodeID;
                     //if (ELeaveCode.db.select(dbConn, leaveCode))
                     ELeaveApplication.db.delete(dbConn, leaveApp);
                 }
             }
         }
     }
     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_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);
             }
         }
     }
 }
コード例 #7
0
        protected override void afterUpdate(DatabaseConnection dbConn, DBManager db)
        {
            DateTime oldLeaveAdjustDate = new DateTime();
            DateTime newLeaveAdjustDate = m_CompensationLeaveEntitleEffectiveDate;

            if (oldValueObject != null)
            {
                ECompensationLeaveEntitle oldCompLeaveEntitle = (ECompensationLeaveEntitle)oldValueObject;
                oldLeaveAdjustDate = oldCompLeaveEntitle.CompensationLeaveEntitleEffectiveDate;
            }
            {
                ELeaveBalance.DeleteLeaveBalanceAfter(dbConn, m_EmpID, ELeaveType.COMPENSATION_LEAVE_TYPE(dbConn).LeaveTypeID, oldLeaveAdjustDate);
                ELeaveBalance.DeleteLeaveBalanceAfter(dbConn, m_EmpID, ELeaveType.COMPENSATION_LEAVE_TYPE(dbConn).LeaveTypeID, newLeaveAdjustDate);
            }

            base.afterUpdate(dbConn, db);
        }
コード例 #8
0
        protected override void afterUpdate(DatabaseConnection dbConn, DBManager db)
        {
            int      oldLeaveTypeID     = 0;
            int      newLeaveTypeID     = m_LeaveTypeID;
            DateTime oldLeaveAdjustDate = new DateTime();
            DateTime newLeaveAdjustDate = m_LeaveBalAdjDate;

            if (oldValueObject != null)
            {
                ELeaveBalanceAdjustment oldLeaveBalanceAdjust = (ELeaveBalanceAdjustment)oldValueObject;
                oldLeaveTypeID     = oldLeaveBalanceAdjust.LeaveTypeID;
                oldLeaveAdjustDate = oldLeaveBalanceAdjust.LeaveBalAdjDate;
            }
            {
                ELeaveBalance.DeleteLeaveBalanceAfter(dbConn, this.EmpID, oldLeaveTypeID, oldLeaveAdjustDate);
                ELeaveBalance.DeleteLeaveBalanceAfter(dbConn, this.EmpID, newLeaveTypeID, newLeaveAdjustDate);
            }

            base.afterUpdate(dbConn, db);
        }
コード例 #9
0
ファイル: RosterTable.cs プロジェクト: dhamotharang/H-R-One
        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);
                    }
                }
            }
        }
コード例 #10
0
        protected override void afterInsert(DatabaseConnection dbConn, DBManager db)
        {
            base.afterInsert(dbConn, db);

            ELeaveBalance.DeleteLeaveBalanceAfter(dbConn, m_EmpID, m_LeaveTypeID, m_LeaveBalAdjDate);
        }
コード例 #11
0
        protected override void afterDelete(DatabaseConnection dbConn, DBManager db)
        {
            base.afterDelete(dbConn, db);

            ELeaveBalance.DeleteLeaveBalanceAfter(dbConn, m_EmpID, ELeaveType.COMPENSATION_LEAVE_TYPE(dbConn).LeaveTypeID, m_CompensationLeaveEntitleEffectiveDate);
        }