public static EEmpPayroll GetObject(DatabaseConnection dbConn, int ID) { if (ID > 0) { EEmpPayroll obj = new EEmpPayroll(); obj.EmpPayrollID = ID; if (EEmpPayroll.db.select(dbConn, obj)) { return(obj); } } return(null); }
public bool CanConsiderAsFirstContribution(DatabaseConnection dbConn) { EEmpPayroll empPayroll = new EEmpPayroll(); empPayroll.EmpPayrollID = EmpPayrollID; if (EEmpPayroll.db.select(dbConn, empPayroll)) { // Check if the record is first contribution object DBFilter previousEMPPayrollFilter = new DBFilter(); previousEMPPayrollFilter.add(new Match("EmpID", empPayroll.EmpID)); DBFilter previousMPFRecordFilter = new DBFilter(); previousMPFRecordFilter.add(new IN("EmpPayrollID", "Select EmpPayrollID from EmpPayroll", previousEMPPayrollFilter)); previousMPFRecordFilter.add(new Match("MPFRecPeriodTo", "<", MPFRecPeriodTo)); previousMPFRecordFilter.add(new Match("EmpPayrollID", "<>", EmpPayrollID)); if (EMPFRecord.db.count(dbConn, previousMPFRecordFilter) <= 0) { DBFilter empMPFPlanFilter = new DBFilter(); empMPFPlanFilter.add(new Match("EmpID", "=", empPayroll.EmpID)); empMPFPlanFilter.add(new Match("EmpMPFEffFr", "<=", MPFRecPeriodTo)); empMPFPlanFilter.add("EmpMPFEffFr", true); ArrayList empMPFPlanList = EEmpMPFPlan.db.select(dbConn, empMPFPlanFilter); if (empMPFPlanList.Count > 0) { EEmpMPFPlan firstEMPMPFPlan = (EEmpMPFPlan)empMPFPlanList[0]; if (firstEMPMPFPlan.EmpMPFEffFr >= MPFRecPeriodFr && firstEMPMPFPlan.EmpMPFEffFr <= MPFRecPeriodTo) { EEmpMPFPlan lastEMPMPFPlan = (EEmpMPFPlan)empMPFPlanList[empMPFPlanList.Count - 1]; if (lastEMPMPFPlan.MPFPlanID.Equals(MPFPlanID)) { return(true); } } } } } return(false); }