using System; using System.Data; using System.Linq; using Ease.CoreV35; using Ease.CoreV35.Model; using Ease.CoreV35.DataAccess; using System.Collections.Generic; using Payroll.BO; using Ease.CoreV35.Caching; using System.Data.SqlClient; namespace Payroll.Service { #region SalaryMonthly Service [Serializable] public class SalaryMonthlyService : ServiceTemplate, ISalaryMonthlyService { #region Private functions and declaration Cache _cache = new Cache(typeof(SalaryMonthly)); private int _crgSerialId; #endregion public SalaryMonthlyService() { _crgSerialId = 0; } private int _processID = 0; private int _salaryMID = 0; private int _detailID = 0; string _sConnectionName = ""; private void MapObject(SalaryMonthly oSalaryMonthly, DataReader oReader) { base.SetObjectID(oSalaryMonthly, oReader.GetID("SalaryMonthlyID")); oSalaryMonthly.SalaryMonth = oReader.GetDateTime("SalaryMonth").Value; oSalaryMonthly.EmployeeID = oReader.GetID("EmployeeID"); oSalaryMonthly.CategoryID = oReader.GetID("CategoryID"); oSalaryMonthly.DepartmentID = oReader.GetID("DepartmentID"); oSalaryMonthly.DesignationID = oReader.GetID("DesignationID"); oSalaryMonthly.LocationID = oReader.GetID("LocationID"); oSalaryMonthly.GradeID = oReader.GetID("GradeID"); oSalaryMonthly.IsFinalized = oReader.GetBoolean("IsFinalized").Value; oSalaryMonthly.PaymentDate = oReader.GetDateTime("PaymentDate"); oSalaryMonthly.PrevMonthBasic = oReader.GetDouble("PrevMonthBasic").Value; oSalaryMonthly.ThisMonthBasic = oReader.GetDouble("ThisMonthBasic").Value; oSalaryMonthly.ThisMonthGross = oReader.GetDouble("ThisMonthGross").Value; oSalaryMonthly.IsConfirmed = oReader.GetBoolean("IsConfirmed").Value; oSalaryMonthly.IsEligibleOT = oReader.GetBoolean("IsEligibleOT").Value; oSalaryMonthly.ReligionID = oReader.GetID("ReligionID"); oSalaryMonthly.PayrollTypeID = oReader.GetID("PayrollTypeID"); oSalaryMonthly.OutPayBranchID = oReader.GetID("OutPayBranchID"); oSalaryMonthly.OutPayAccountNo = oReader.GetString("OutPayAccountNo"); oSalaryMonthly.Remarks = oReader.GetString("Remarks"); oSalaryMonthly.AccountNo = oReader.GetString("AccountNo"); oSalaryMonthly.BranchID = oReader.GetID("BranchID"); oSalaryMonthly.DesignationText = oReader.GetString("DESIGNATION"); oSalaryMonthly.SalaryProcessID = oReader.GetID("SalaryProcessID"); oSalaryMonthly.PFMembershipType = (EnumPFMembershipType)oReader.GetInt32("PFMEMBERTYPE").Value; oSalaryMonthly.Gender = (EnumGender)oReader.GetInt32("Gender").Value; oSalaryMonthly.RCCode = oReader.GetString("RCCode"); this.SetObjectState(oSalaryMonthly, Ease.CoreV35.ObjectState.Saved); } protected override T CreateObject(DataReader oReader) { SalaryMonthly oSalaryMonthly = new SalaryMonthly(); MapObject(oSalaryMonthly, oReader); return oSalaryMonthly as T; } protected SalaryMonthly CreateObject(DataReader oReader) { SalaryMonthly oSalaryMonthly = new SalaryMonthly(); MapObject(oSalaryMonthly, oReader); return oSalaryMonthly; } private void MapEmpCostCenterObject(SalaryEmpCostCenter oSalaryEmpCostCenter, DataReader oReader) { _crgSerialId = _crgSerialId + 1; base.SetObjectID(oSalaryEmpCostCenter, ID.FromInteger(_crgSerialId)); oSalaryEmpCostCenter.SalaryMontlyID = oReader.GetID("SalaryMonthlyID"); oSalaryEmpCostCenter.CostCenterID = oReader.GetID("CostCenterID"); oSalaryEmpCostCenter.Percentage = oReader.GetDouble("Percentage").Value; oSalaryEmpCostCenter.EmployeeID = oReader.GetID("EmployeeID"); this.SetObjectState(oSalaryEmpCostCenter, Ease.CoreV35.ObjectState.Saved); } protected ObjectsTemplate CreateEmpCostCenterObject(DataReader oReader) { ObjectsTemplate oSalaryEmpCostCenters = new ObjectsTemplate(); while (oReader.Read()) { SalaryEmpCostCenter oSalaryEmpCostCenter = new SalaryEmpCostCenter(); MapEmpCostCenterObject(oSalaryEmpCostCenter, oReader); oSalaryEmpCostCenters.Add(oSalaryEmpCostCenter); } return oSalaryEmpCostCenters; } private void MapSalaryMonthlyDetailObject(SalaryMonthlyDetail oSalaryMonthlyDetail, DataReader oReader) { base.SetObjectID(oSalaryMonthlyDetail, oReader.GetID("DetailID")); oSalaryMonthlyDetail.SalaryMonthlyID = oReader.GetID("SalaryMonthlyID"); oSalaryMonthlyDetail.ItemID = oReader.GetInt32("ItemID").Value; oSalaryMonthlyDetail.SupportID = oReader.GetID("SupportID"); oSalaryMonthlyDetail.Description = oReader.GetString("Description"); oSalaryMonthlyDetail.Position = oReader.GetInt32("Position").Value; oSalaryMonthlyDetail.CalculatedAmount = oReader.GetDouble("CalculatedAmount").Value; oSalaryMonthlyDetail.ChangedAmount = oReader.GetDouble("ChangedAmount").Value; oSalaryMonthlyDetail.ItemCode = (EnumSalaryItemCode)oReader.GetInt32("ItemCode").Value; oSalaryMonthlyDetail.itemGroupCode = (EnumSalaryGroup)oReader.GetInt32("ITEMGROUP"); this.SetObjectState(oSalaryMonthlyDetail, Ease.CoreV35.ObjectState.Saved); } protected ObjectsTemplate CreateSalaryMonthlyDetailObject(DataReader oReader) { ObjectsTemplate oSalaryMonthlyDetails = new ObjectsTemplate(); while (oReader.Read()) { SalaryMonthlyDetail oSalaryMonthlyDetail = new SalaryMonthlyDetail(); MapSalaryMonthlyDetailObject(oSalaryMonthlyDetail, oReader); oSalaryMonthlyDetails.Add(oSalaryMonthlyDetail); } return oSalaryMonthlyDetails; } #region Service implementation public SalaryMonthly Get(ID id) { SalaryMonthly oSalaryMonthly = new SalaryMonthly(); #region Cache Header oSalaryMonthly = _cache["Get", id] as SalaryMonthly; if (oSalaryMonthly != null) return oSalaryMonthly; #endregion TransactionContext tc = null; try { tc = TransactionContext.Begin(); DataReader oreader = new DataReader(SalaryMonthlyDA.Get(tc, id)); if (oreader.Read()) { oSalaryMonthly = this.CreateObject(oreader); } oreader.Close(); tc.End(); } catch (Exception e) { #region Handle Exception if (tc != null) tc.HandleError(); ExceptionLog.Write(e); throw new ServiceException(e.Message, e); #endregion } #region Cache Footer _cache.Add(oSalaryMonthly, "Get", id); #endregion return oSalaryMonthly; } public SalaryMonthly GetLastSalaryMonthDetails(ID empID) { SalaryMonthly oSalaryMonthly = new SalaryMonthly(); TransactionContext tc = null; try { tc = TransactionContext.Begin(); DataReader oreader = new DataReader(SalaryMonthlyDA.GetLastSalaryMonthDetails(tc, empID)); if (oreader.Read()) { oSalaryMonthly = this.CreateObject(oreader); } oreader.Close(); tc.End(); } catch (Exception e) { #region Handle Exception if (tc != null) tc.HandleError(); ExceptionLog.Write(e); throw new ServiceException(e.Message, e); #endregion } return oSalaryMonthly; } public DateTime? GetLastPaidSalaryMonth(int nEmpID) { DateTime? dt; TransactionContext tc = null; try { tc = TransactionContext.Begin(); dt = SalaryMonthlyDA.GetLastPaidSalaryMonth(tc, nEmpID); tc.End(); } catch (Exception e) { #region Handle Exception if (tc != null) tc.HandleError(); ExceptionLog.Write(e); throw new ServiceException(e.Message, e); #endregion } return dt; } public SalaryMonthly Get(ID nEmpID, DateTime dateTime) { SalaryMonthly oSalaryMonthly = new SalaryMonthly(); #region Cache Header oSalaryMonthly = _cache["Get", nEmpID, dateTime] as SalaryMonthly; if (oSalaryMonthly != null) return oSalaryMonthly; #endregion TransactionContext tc = null; try { tc = TransactionContext.Begin(); DataReader oreader = new DataReader(SalaryMonthlyDA.Get(tc, nEmpID, dateTime)); if (oreader.Read()) { oSalaryMonthly = this.CreateObject(oreader); } oreader.Close(); if (oSalaryMonthly != null) { oreader = new DataReader(SalaryMonthlyDA.GetSalaryDetail(tc, oSalaryMonthly.ID)); oSalaryMonthly.Details = this.CreateSalaryMonthlyDetailObject(oreader); } oreader.Close(); tc.End(); } catch (Exception e) { #region Handle Exception if (tc != null) tc.HandleError(); ExceptionLog.Write(e); throw new ServiceException(e.Message, e); #endregion } #region Cache Footer _cache.Add(oSalaryMonthly, "Get", nEmpID, dateTime); #endregion return oSalaryMonthly; } public double GetSumOnRange(ID employeeId, DateTime fromDate, DateTime toDate, EnumSalaryGroup groupCode, EnumSalaryItemCode itemCode, int itemId, ID payrollTypeID) { double amount = 0; TransactionContext tc = null; try { tc = TransactionContext.Begin(); amount = SalaryMonthlyDA.GetSumOnRange(tc, employeeId, fromDate, toDate, groupCode, itemCode, itemId, payrollTypeID); tc.End(); } catch (Exception e) { #region Handle Exception if (tc != null) tc.HandleError(); ExceptionLog.Write(e); throw new ServiceException(e.Message, e); #endregion } return amount; } public double GetAmountOnDateDiff(ID employeeId, DateTime fromDate, DateTime toDate, EnumSalaryGroup groupCode, EnumSalaryItemCode itemCode, int itemId, ID payrollTypeID) { double amount = 0; TransactionContext tc = null; try { tc = TransactionContext.Begin(); amount = SalaryMonthlyDA.GetAmountOnDateDiff(tc, employeeId, fromDate, toDate, groupCode, itemCode, itemId, payrollTypeID); tc.End(); } catch (Exception e) { #region Handle Exception if (tc != null) tc.HandleError(); ExceptionLog.Write(e); throw new ServiceException(e.Message, e); #endregion } return amount; } public double GetThisMonthBasicOnDateDiff(ID employeeId, DateTime fromDate, DateTime toDate, EnumSalaryGroup groupCode, EnumSalaryItemCode itemCode, int itemId, ID payrollTypeID) { double amount = 0; TransactionContext tc = null; try { tc = TransactionContext.Begin(); amount = SalaryMonthlyDA.GetThisMonthBasicOnDateDiff(tc, employeeId, fromDate, toDate, groupCode, itemCode, itemId, payrollTypeID); tc.End(); } catch (Exception e) { #region Handle Exception if (tc != null) tc.HandleError(); ExceptionLog.Write(e); throw new ServiceException(e.Message, e); #endregion } return amount; } ///////////////////////////////////////////////////////////////////////////////////////// public double GetAmountOnDateDiffForAll(ID employeeId, DateTime fromDate, DateTime toDate, ID payrollTypeID) { double amount = 0; TransactionContext tc = null; try { tc = TransactionContext.Begin(); amount = SalaryMonthlyDA.GetAmountOnDateDiffForAll(tc, employeeId, fromDate, toDate, payrollTypeID); tc.End(); } catch (Exception e) { #region Handle Exception if (tc != null) tc.HandleError(); ExceptionLog.Write(e); throw new ServiceException(e.Message, e); #endregion } return amount; } public double GetPrvTaxAmount(EnumIncomeTaxDataFrom dataFrom, ID employeeId, DateTime fromDate, DateTime toDate) { double amount = 0; TransactionContext tc = null; try { tc = TransactionContext.Begin(); amount = SalaryMonthlyDA.GetPrvTaxAmount(tc, dataFrom, employeeId, fromDate, toDate); tc.End(); } catch (Exception e) { #region Handle Exception if (tc != null) tc.HandleError(); ExceptionLog.Write(e); throw new ServiceException(e.Message, e); #endregion } return amount; } ///////////////////////////////////////////////////////////////////////////////////////////// public double GetAmountOnDateDiffForOverTime(ID employeeId, DateTime fromDate, DateTime toDate, EnumSalaryGroup groupCode, EnumSalaryItemCode itemCode, int itemId, ID payrollTypeID) { double amount = 0; TransactionContext tc = null; try { tc = TransactionContext.Begin(); amount = SalaryMonthlyDA.GetAmountOnDateDiffForOverTime(tc, employeeId, fromDate, toDate, groupCode, itemCode, itemId, payrollTypeID); tc.End(); } catch (Exception e) { #region Handle Exception if (tc != null) tc.HandleError(); ExceptionLog.Write(e); throw new ServiceException(e.Message, e); #endregion } return amount; } public double GetUnAuthorizeAmountOnDateRange(ID employeeId, DateTime fromDate, DateTime toDate, EnumSalaryGroup groupCode) { double amount = 0; TransactionContext tc = null; try { tc = TransactionContext.Begin(); amount = SalaryMonthlyDA.GetUnAuthorizeAmountOnDateRange(tc, employeeId, fromDate, toDate, groupCode); tc.End(); } catch (Exception e) { #region Handle Exception if (tc != null) tc.HandleError(); ExceptionLog.Write(e); throw new ServiceException(e.Message, e); #endregion } return amount; } public double GetUnAuthorizeAmountOnDateRange(ID employeeId, DateTime fromDate, DateTime toDate, EnumSalaryGroup groupCode, EnumSalaryItemCode itemCode) { double amount = 0; TransactionContext tc = null; try { tc = TransactionContext.Begin(); amount = SalaryMonthlyDA.GetUnAuthorizeAmountOnDateRange(tc, employeeId, fromDate, toDate, groupCode,itemCode); tc.End(); } catch (Exception e) { #region Handle Exception if (tc != null) tc.HandleError(); ExceptionLog.Write(e); throw new ServiceException(e.Message, e); #endregion } return amount; } // public double GetGrossOnRange(ID employeeId, //DateTime fromDate, DateTime toDate, EnumSalaryItemCode itemCode, int itemId) // { // double amount = 0; // TransactionContext tc = null; // try // { // tc = TransactionContext.Begin(); // amount = SalaryMonthlyDA.GetSumOnRange(tc, employeeId, // fromDate, toDate, groupCode, itemCode, itemId); // tc.End(); // } // catch (Exception e) // { // #region Handle Exception // if (tc != null) // tc.HandleError(); // ExceptionLog.Write(e); // throw new ServiceException(e.Message, e); // #endregion // } // return amount; // } public DataSet GetEmpPaySlipGrossForOthers(DateTime dateTime, string sEmpID) { DataSet oSalaryMonthlys = new DataSet(); TransactionContext tc = null; try { tc = TransactionContext.Begin(); oSalaryMonthlys = SalaryMonthlyDA.GetEmpPaySlipGrossForOthers(tc, dateTime, sEmpID); tc.End(); } catch (Exception e) { #region Handle Exception if (tc != null) tc.HandleError(); ExceptionLog.Write(e); throw new ServiceException(e.Message, e); #endregion } return oSalaryMonthlys; } public DataSet GetEmpPaySlipGrossForOthersOld(DateTime dateTime, string sEmpID) { DataSet oSalaryMonthlys = new DataSet(); TransactionContext tc = null; try { tc = TransactionContext.Begin(); oSalaryMonthlys = SalaryMonthlyDA.GetEmpPaySlipGrossForOthersOld(tc, dateTime, sEmpID); tc.End(); } catch (Exception e) { #region Handle Exception if (tc != null) tc.HandleError(); ExceptionLog.Write(e); throw new ServiceException(e.Message, e); #endregion } return oSalaryMonthlys; } public DataSet GetOldPaySlip(DateTime dateTime, string sEmpID) { DataSet oSalaryMonthlys = new DataSet(); TransactionContext tc = null; try { tc = TransactionContext.Begin(); oSalaryMonthlys = SalaryMonthlyDA.GetOldPayslip(tc, dateTime, sEmpID); tc.End(); } catch (Exception e) { #region Handle Exception if (tc != null) tc.HandleError(); ExceptionLog.Write(e); throw new ServiceException(e.Message, e); #endregion } return oSalaryMonthlys; } public DataSet GetEmpPaySlipDeductForOthers(DateTime dateTime, string sEmpID) { DataSet oSalaryMonthlys = new DataSet(); TransactionContext tc = null; try { tc = TransactionContext.Begin(); oSalaryMonthlys = SalaryMonthlyDA.GetEmpPaySlipDeductForOthers(tc, dateTime, sEmpID); tc.End(); } catch (Exception e) { #region Handle Exception if (tc != null) tc.HandleError(); ExceptionLog.Write(e); throw new ServiceException(e.Message, e); #endregion } return oSalaryMonthlys; } public DataSet GetEmpPaySlipDeductForOthersOld(DateTime dateTime, string sEmpID) { DataSet oSalaryMonthlys = new DataSet(); TransactionContext tc = null; try { tc = TransactionContext.Begin(); oSalaryMonthlys = SalaryMonthlyDA.GetEmpPaySlipDeductForOthersOld(tc, dateTime, sEmpID); tc.End(); } catch (Exception e) { #region Handle Exception if (tc != null) tc.HandleError(); ExceptionLog.Write(e); throw new ServiceException(e.Message, e); #endregion } return oSalaryMonthlys; } public DataSet GetEmpPaySlipDeductForCitiOthers(DateTime dateTime, string sEmpID) { DataSet oSalaryMonthlys = new DataSet(); TransactionContext tc = null; try { tc = TransactionContext.Begin(); oSalaryMonthlys = SalaryMonthlyDA.GetEmpPaySlipDeductForCitiOthers(tc, dateTime, sEmpID); tc.End(); } catch (Exception e) { #region Handle Exception if (tc != null) tc.HandleError(); ExceptionLog.Write(e); throw new ServiceException(e.Message, e); #endregion } return oSalaryMonthlys; } public DataSet GetEmpPaySlipDeductForLR(DateTime dateTime, string sEmpID) { DataSet oSalaryMonthlys = new DataSet(); TransactionContext tc = null; try { tc = TransactionContext.Begin(); oSalaryMonthlys = SalaryMonthlyDA.GetEmpPaySlipDeductForLR(tc, dateTime, sEmpID); tc.End(); } catch (Exception e) { #region Handle Exception if (tc != null) tc.HandleError(); ExceptionLog.Write(e); throw new ServiceException(e.Message, e); #endregion } return oSalaryMonthlys; } public DataSet GetEmpPaySlipDeductForLROld(DateTime dateTime, string sEmpID) { DataSet oSalaryMonthlys = new DataSet(); TransactionContext tc = null; try { tc = TransactionContext.Begin(); oSalaryMonthlys = SalaryMonthlyDA.GetEmpPaySlipDeductForLROld(tc, dateTime, sEmpID); tc.End(); } catch (Exception e) { #region Handle Exception if (tc != null) tc.HandleError(); ExceptionLog.Write(e); throw new ServiceException(e.Message, e); #endregion } return oSalaryMonthlys; } public DataSet GetEmpPaySlipIncomeTaxAmountForOthers(DateTime dateTime, string sEmpID) { DataSet oSalaryMonthlys = new DataSet(); TransactionContext tc = null; try { tc = TransactionContext.Begin(); oSalaryMonthlys = SalaryMonthlyDA.GetEmpPaySlipIncomeTaxAmountForOthers(tc, dateTime, sEmpID); tc.End(); } catch (Exception e) { #region Handle Exception if (tc != null) tc.HandleError(); ExceptionLog.Write(e); throw new ServiceException(e.Message, e); #endregion } return oSalaryMonthlys; } public DataSet GetEmpPaySlipIncomeTaxAmountForOthersOld(DateTime dateTime, string sEmpID) { DataSet oSalaryMonthlys = new DataSet(); TransactionContext tc = null; try { tc = TransactionContext.Begin(); oSalaryMonthlys = SalaryMonthlyDA.GetEmpPaySlipIncomeTaxAmountForOthersOld(tc, dateTime, sEmpID); tc.End(); } catch (Exception e) { #region Handle Exception if (tc != null) tc.HandleError(); ExceptionLog.Write(e); throw new ServiceException(e.Message, e); #endregion } return oSalaryMonthlys; } public DataSet GetEmpSalaryProcessedData(DateTime dateTime, string employeeno) { DataSet oSalaryMonthlys = new DataSet(); TransactionContext tc = null; try { tc = TransactionContext.Begin(); oSalaryMonthlys = SalaryMonthlyDA.GetEmpSalaryProcessedData(tc, dateTime, employeeno); tc.End(); } catch (Exception e) { #region Handle Exception if (tc != null) tc.HandleError(); ExceptionLog.Write(e); throw new ServiceException(e.Message, e); #endregion } return oSalaryMonthlys; } public DataSet GetEmpPaySlipGross(DateTime dateTime, string sEmpID) { DataSet oSalaryMonthlys = new DataSet(); TransactionContext tc = null; try { tc = TransactionContext.Begin(); oSalaryMonthlys = SalaryMonthlyDA.GetEmpPaySlipGross(tc, dateTime, sEmpID); //DataReader oreader = new DataReader(SalaryMonthlyDA.GetEmpPaySlip(tc,dateTime)); tc.End(); } catch (Exception e) { #region Handle Exception if (tc != null) tc.HandleError(); ExceptionLog.Write(e); throw new ServiceException(e.Message, e); #endregion } return oSalaryMonthlys; } public DataSet GetEmpOverAllSummaryGross(DateTime dateTime, string sEmpID) { DataSet oSalaryMonthlys = new DataSet(); TransactionContext tc = null; try { tc = TransactionContext.Begin(); oSalaryMonthlys = SalaryMonthlyDA.GetEmpOverAllSummaryGross(tc, dateTime, sEmpID); tc.End(); } catch (Exception e) { #region Handle Exception if (tc != null) tc.HandleError(); ExceptionLog.Write(e); throw new ServiceException(e.Message, e); #endregion } return oSalaryMonthlys; } public DataSet GetEmpOverAllSummaryDeduct(DateTime dateTime, string sEmpID) { DataSet oSalaryMonthlys = new DataSet(); TransactionContext tc = null; try { tc = TransactionContext.Begin(); oSalaryMonthlys = SalaryMonthlyDA.GetEmpOverAllSummaryDeduct(tc, dateTime, sEmpID); tc.End(); } catch (Exception e) { #region Handle Exception if (tc != null) tc.HandleError(); ExceptionLog.Write(e); throw new ServiceException(e.Message, e); #endregion } return oSalaryMonthlys; } public DataSet GetEmpSalarySheet(DateTime dateTime, string sEmpID) { DataSet oSalaryMonthlys = new DataSet(); TransactionContext tc = null; try { tc = TransactionContext.Begin(); oSalaryMonthlys = SalaryMonthlyDA.GetEmpSalarySheet(tc, dateTime, sEmpID); tc.End(); } catch (Exception e) { #region Handle Exception if (tc != null) tc.HandleError(); ExceptionLog.Write(e); throw new ServiceException(e.Message, e); #endregion } return oSalaryMonthlys; } public DataSet GetEmpReconciliationSalarySheet(DateTime Prevdate, DateTime dateTime, string sEmpID) { DataSet oSalaryMonthlys = new DataSet(); TransactionContext tc = null; try { tc = TransactionContext.Begin(); oSalaryMonthlys = SalaryMonthlyDA.GetEmpReconciliationSalarySheet(tc, Prevdate,dateTime, sEmpID); tc.End(); } catch (Exception e) { #region Handle Exception if (tc != null) tc.HandleError(); ExceptionLog.Write(e); throw new ServiceException(e.Message, e); #endregion } return oSalaryMonthlys; } //New Salary Sheet From Old Tables public DataSet GetEmpSalarySheetOld(DateTime dateTime, string sEmpID) { DataSet oSalaryMonthlys = new DataSet(); TransactionContext tc = null; try { tc = TransactionContext.Begin(); oSalaryMonthlys = SalaryMonthlyDA.GetEmpSalarySheet(tc, dateTime); tc.End(); } catch (Exception e) { #region Handle Exception if (tc != null) tc.HandleError(); ExceptionLog.Write(e); throw new ServiceException(e.Message, e); #endregion } return oSalaryMonthlys; } public DataSet GetEmpSalarySheet2(DateTime dateTime, string sEmpID) { DataSet oSalaryMonthlys = new DataSet(); TransactionContext tc = null; try { tc = TransactionContext.Begin(); oSalaryMonthlys = SalaryMonthlyDA.GetEmpSalarySheet2(tc, dateTime, sEmpID); tc.End(); } catch (Exception e) { #region Handle Exception if (tc != null) tc.HandleError(); ExceptionLog.Write(e); throw new ServiceException(e.Message, e); #endregion } return oSalaryMonthlys; } public DataSet GetEmpEuroSalarySheet(DateTime dateTime, string sEmpID) { DataSet oEuroSalaryMonthlys = new DataSet(); TransactionContext tc = null; try { tc = TransactionContext.Begin(); oEuroSalaryMonthlys = SalaryMonthlyDA.GetEmpEuroSalarySheet(tc, dateTime, sEmpID); tc.End(); } catch (Exception e) { #region Handle Exception if (tc != null) tc.HandleError(); ExceptionLog.Write(e); throw new ServiceException(e.Message, e); #endregion } return oEuroSalaryMonthlys; } public DataSet GetExpatSalarySheet(DateTime dateTime, string sEmpID) { DataSet oExpatSalaryMonthlys = new DataSet(); TransactionContext tc = null; try { tc = TransactionContext.Begin(); oExpatSalaryMonthlys = SalaryMonthlyDA.GetExpatSalarySheet(tc, dateTime, sEmpID); tc.End(); } catch (Exception e) { #region Handle Exception if (tc != null) tc.HandleError(); ExceptionLog.Write(e); throw new ServiceException(e.Message, e); #endregion } return oExpatSalaryMonthlys; } public DataSet GetCasualSalarySheet(DateTime dateTime, string sEmpID) { DataSet oSalaryMonthlys = new DataSet(); TransactionContext tc = null; try { tc = TransactionContext.Begin(); oSalaryMonthlys = SalaryMonthlyDA.GetCasualSalarySheet(tc, dateTime, sEmpID); tc.End(); } catch (Exception e) { #region Handle Exception if (tc != null) tc.HandleError(); ExceptionLog.Write(e); throw new ServiceException(e.Message, e); #endregion } return oSalaryMonthlys; } public DataSet GetEmpSalarySheetForIDLC(DateTime dateTime, string sEmpID) { DataSet oSalaryMonthlys = new DataSet(); TransactionContext tc = null; try { tc = TransactionContext.Begin(); oSalaryMonthlys = SalaryMonthlyDA.GetEmpSalarySheetForIDLC(tc, dateTime, sEmpID); tc.End(); } catch (Exception e) { #region Handle Exception if (tc != null) tc.HandleError(); ExceptionLog.Write(e); throw new ServiceException(e.Message, e); #endregion } return oSalaryMonthlys; } public DataSet GetEmpSalarySheetByYear(DateTime dSalaryMonth, string sEmpID) { DataSet oSalaryMonthlys = new DataSet(); TransactionContext tc = null; try { tc = TransactionContext.Begin(); oSalaryMonthlys = SalaryMonthlyDA.GetEmpSalarySheetByYear(tc, dSalaryMonth, sEmpID); tc.End(); } catch (Exception e) { #region Handle Exception if (tc != null) tc.HandleError(); ExceptionLog.Write(e); throw new ServiceException(e.Message, e); #endregion } return oSalaryMonthlys; } public DataSet GetEmpStartDateAndEndDate(DateTime fstdate, DateTime endDate, string sEmpID) { DataSet oSalaryMonthlys = new DataSet(); TransactionContext tc = null; try { tc = TransactionContext.Begin(); oSalaryMonthlys = SalaryMonthlyDA.GetEmpStartDateAndEndDate(tc, fstdate, endDate, sEmpID); tc.End(); } catch (Exception e) { #region Handle Exception if (tc != null) tc.HandleError(); ExceptionLog.Write(e); throw new ServiceException(e.Message, e); #endregion } return oSalaryMonthlys; } public DataSet GetSalaryForTax(DateTime fstdate, DateTime endDate) { DataSet oSalaryMonthlys = new DataSet(); TransactionContext tc = null; try { tc = TransactionContext.Begin(); oSalaryMonthlys = SalaryMonthlyDA.GetSalaryForTax(tc, fstdate, endDate); tc.End(); } catch (Exception e) { #region Handle Exception if (tc != null) tc.HandleError(); ExceptionLog.Write(e); throw new ServiceException(e.Message, e); #endregion } return oSalaryMonthlys; } public DataSet GetEmpPrevDataForSRecon(DateTime dateTime) { DataSet oSalaryMonthlys = new DataSet(); TransactionContext tc = null; try { tc = TransactionContext.Begin(); oSalaryMonthlys = SalaryMonthlyDA.GetEmpPrevDataForSRecon(tc, dateTime); tc.End(); } catch (Exception e) { #region Handle Exception if (tc != null) tc.HandleError(); ExceptionLog.Write(e); throw new ServiceException(e.Message, e); #endregion } return oSalaryMonthlys; } public DataSet GetEmpSalaryReconForNovertis(DateTime dateTime) { DataSet oSalaryMonthlys = new DataSet(); TransactionContext tc = null; try { tc = TransactionContext.Begin(); oSalaryMonthlys = SalaryMonthlyDA.GetEmpSalaryReconForNovertis(tc, dateTime); tc.End(); } catch (Exception e) { #region Handle Exception if (tc != null) tc.HandleError(); ExceptionLog.Write(e); throw new ServiceException(e.Message, e); #endregion } return oSalaryMonthlys; } public DataSet GetEmpSalarySheetForNovertis(DateTime dateTime, string sEmpID) { DataSet oSalaryMonthlys = new DataSet(); TransactionContext tc = null; try { tc = TransactionContext.Begin(); oSalaryMonthlys = SalaryMonthlyDA.GetEmpSalarySheetForNovertis(tc, dateTime, sEmpID); tc.End(); } catch (Exception e) { #region Handle Exception if (tc != null) tc.HandleError(); ExceptionLog.Write(e); throw new ServiceException(e.Message, e); #endregion } return oSalaryMonthlys; } public DataSet GetEmpSalaryReconForCurrMonth(DateTime dateTime, string sEmpID) { DataSet oSalaryMonthlys = new DataSet(); TransactionContext tc = null; try { tc = TransactionContext.Begin(); oSalaryMonthlys = SalaryMonthlyDA.GetEmpSalaryReconForCurrMonth(tc, dateTime, sEmpID); tc.End(); } catch (Exception e) { #region Handle Exception if (tc != null) tc.HandleError(); ExceptionLog.Write(e); throw new ServiceException(e.Message, e); #endregion } return oSalaryMonthlys; } public DataSet GetEmpSalarySheetByCC(DateTime dateTime, string sEmpID) { DataSet oSalaryMonthlys = new DataSet(); TransactionContext tc = null; try { tc = TransactionContext.Begin(); oSalaryMonthlys = SalaryMonthlyDA.GetEmpSalarySheetByCC(tc, dateTime, sEmpID); tc.End(); } catch (Exception e) { #region Handle Exception if (tc != null) tc.HandleError(); ExceptionLog.Write(e); throw new ServiceException(e.Message, e); #endregion } return oSalaryMonthlys; } public DataSet GetSGSSalarySheet(DateTime dateTime, string sEmpID) { DataSet oSalaryMonthlys = new DataSet(); TransactionContext tc = null; try { tc = TransactionContext.Begin(); oSalaryMonthlys = SalaryMonthlyDA.GetSGSSalarySheet(tc, dateTime, sEmpID); tc.End(); } catch (Exception e) { #region Handle Exception if (tc != null) tc.HandleError(); ExceptionLog.Write(e); throw new ServiceException(e.Message, e); #endregion } return oSalaryMonthlys; } public DataSet GetExtendedSalarySheet(DateTime dateTime, string sEmpID) { DataSet oSalaryMonthlys = new DataSet(); TransactionContext tc = null; try { tc = TransactionContext.Begin(); oSalaryMonthlys = SalaryMonthlyDA.GetExtendedSalarySheet(tc, dateTime, sEmpID); tc.End(); } catch (Exception e) { #region Handle Exception if (tc != null) tc.HandleError(); ExceptionLog.Write(e); throw new ServiceException(e.Message, e); #endregion } return oSalaryMonthlys; } public DataSet GetEmpPaySlipDeduct(DateTime dateTime, string sEmpID) { DataSet oSalaryMonthlys = new DataSet(); TransactionContext tc = null; try { tc = TransactionContext.Begin(); oSalaryMonthlys = SalaryMonthlyDA.GetEmpPaySlipDeduct(tc, dateTime, sEmpID); //DataReader oreader = new DataReader(SalaryMonthlyDA.GetEmpPaySlip(tc,dateTime)); tc.End(); } catch (Exception e) { #region Handle Exception if (tc != null) tc.HandleError(); ExceptionLog.Write(e); throw new ServiceException(e.Message, e); #endregion } return oSalaryMonthlys; } public DataSet GetPrvMonthNetSalary(DateTime dateTime, string sEmpID, bool IsNetSum) { DataSet oSalaryMonthlys = new DataSet(); TransactionContext tc = null; try { tc = TransactionContext.Begin(); oSalaryMonthlys = SalaryMonthlyDA.GetPrvMonthNetSalary(tc, dateTime, sEmpID, IsNetSum); tc.End(); } catch (Exception e) { #region Handle Exception if (tc != null) tc.HandleError(); ExceptionLog.Write(e); throw new ServiceException(e.Message, e); #endregion } return oSalaryMonthlys; } public DataSet GetEmpPaySlipIncomeTaxAmount(DateTime dateTime, string sEmpID) { DataSet oSalaryMonthlys = new DataSet(); TransactionContext tc = null; try { tc = TransactionContext.Begin(); oSalaryMonthlys = SalaryMonthlyDA.GetEmpPaySlipIncomeTaxAmount(tc, dateTime, sEmpID); //DataReader oreader = new DataReader(SalaryMonthlyDA.GetEmpPaySlip(tc,dateTime)); tc.End(); } catch (Exception e) { #region Handle Exception if (tc != null) tc.HandleError(); ExceptionLog.Write(e); throw new ServiceException(e.Message, e); #endregion } return oSalaryMonthlys; } public DataSet GetEmpSSSummaryByDept(DateTime dateTime, string sEmpID) { DataSet oSalaryMonthlys = new DataSet(); TransactionContext tc = null; try { tc = TransactionContext.Begin(); ObjectsTemplate allTerms = Term.Get(EnumStatus.Active); string str = String.Empty; str += "("; int count = 0; foreach (Term item in allTerms) { count++; if (count != allTerms.Count) str += item.ID.Integer.ToString() + ","; else str += item.ID.Integer.ToString(); } str += ")"; oSalaryMonthlys = SalaryMonthlyDA.GetEmpSSSummaryByDeptNew(tc, str, dateTime, sEmpID); tc.End(); } catch (Exception e) { #region Handle Exception if (tc != null) tc.HandleError(); ExceptionLog.Write(e); throw new ServiceException(e.Message, e); #endregion } return oSalaryMonthlys; } public ObjectsTemplate Get(int payrollTypeID) { #region Cache Header ObjectsTemplate salaryMonthlys = _cache["Get"] as ObjectsTemplate; if (salaryMonthlys != null) return salaryMonthlys; #endregion TransactionContext tc = null; try { tc = TransactionContext.Begin(); DataReader dr = new DataReader(SalaryMonthlyDA.Get(tc, payrollTypeID)); salaryMonthlys = this.CreateObjects(dr); dr.Close(); tc.End(); } catch (Exception e) { #region Handle Exception if (tc != null) tc.HandleError(); ExceptionLog.Write(e); throw new ServiceException(e.Message, e); #endregion } #region Cache Footer _cache.Add(salaryMonthlys, "Get"); #endregion return salaryMonthlys; } public ObjectsTemplate GetCostCenter(DateTime salaryMonth) { ObjectsTemplate empCostcenters; TransactionContext tc = null; try { tc = TransactionContext.Begin(); DataReader dr = new DataReader(SalaryMonthlyDA.GetCostCenter(tc, salaryMonth)); empCostcenters = this.CreateEmpCostCenterObject(dr); dr.Close(); tc.End(); } catch (Exception e) { #region Handle Exception if (tc != null) tc.HandleError(); ExceptionLog.Write(e); throw new ServiceException(e.Message, e); #endregion } return empCostcenters; } public ObjectsTemplate Get(DateTime salaryMonth, ID payrollTypeID) { #region Cache Header ObjectsTemplate salaryMonthlys = null; #endregion TransactionContext tc = null; try { tc = TransactionContext.Begin(); DataReader dr = new DataReader(SalaryMonthlyDA.Get(tc, salaryMonth, payrollTypeID)); salaryMonthlys = this.CreateObjects(dr); dr.Close(); dr = new DataReader(SalaryMonthlyDA.GetDetail(tc, salaryMonth)); ObjectsTemplate details = this.CreateSalaryMonthlyDetailObject(dr); dr.Close(); int check = 0; foreach (SalaryMonthly salary in salaryMonthlys) { check = 0; foreach (SalaryMonthlyDetail detail in details) { if (salary.ID.Integer == detail.SalaryMonthlyID.Integer) { salary.Details.Add(detail); check = 1; } else { if (check == 1) break; } } } tc.End(); } catch (Exception e) { #region Handle Exception if (tc != null) tc.HandleError(); ExceptionLog.Write(e); throw new ServiceException(e.Message, e); #endregion } return salaryMonthlys; } public ObjectsTemplate GetForJV(DateTime salaryMonth, ID payrollTypeID) { #region Cache Header ObjectsTemplate salaryMonthlys = null; #endregion TransactionContext tc = null; try { tc = TransactionContext.Begin(); DataReader dr = new DataReader(SalaryMonthlyDA.Get(tc, salaryMonth, payrollTypeID)); salaryMonthlys = this.CreateObjects(dr); dr.Close(); dr = new DataReader(SalaryMonthlyDA.GetDetail(tc, salaryMonth)); ObjectsTemplate details = this.CreateSalaryMonthlyDetailObject(dr); dr.Close(); foreach (SalaryMonthly salary in salaryMonthlys) { foreach (SalaryMonthlyDetail detail in details) { if (salary.ID.Integer == detail.SalaryMonthlyID.Integer) { salary.Details.Add(detail); } } } tc.End(); } catch (Exception e) { #region Handle Exception if (tc != null) tc.HandleError(); ExceptionLog.Write(e); throw new ServiceException(e.Message, e); #endregion } return salaryMonthlys; } public ObjectsTemplate GetByDateRange(DateTime startDate, DateTime endDate, ID payrollTypeID) { #region Cache Header ObjectsTemplate salaryMonthlys = null; #endregion TransactionContext tc = null; try { tc = TransactionContext.Begin(); DataReader dr = new DataReader(SalaryMonthlyDA.Get(tc, startDate, endDate, payrollTypeID)); salaryMonthlys = this.CreateObjects(dr); dr.Close(); dr = new DataReader(SalaryMonthlyDA.GetDetail(tc, startDate, endDate)); ObjectsTemplate details = this.CreateSalaryMonthlyDetailObject(dr); dr.Close(); int check = 0; foreach (SalaryMonthly salary in salaryMonthlys) { check = 0; foreach (SalaryMonthlyDetail detail in details) { if (salary.ID.Integer == detail.SalaryMonthlyID.Integer) { salary.Details.Add(detail); check = 1; } else { if (check == 1) break; } } } tc.End(); } catch (Exception e) { #region Handle Exception if (tc != null) tc.HandleError(); ExceptionLog.Write(e); throw new ServiceException(e.Message, e); #endregion } return salaryMonthlys; } public ObjectsTemplate GetByDateRange(ID nEmpID, DateTime startDate, DateTime endDate, ID payrollTypeID) { #region Cache Header ObjectsTemplate salaryMonthlys = null; #endregion TransactionContext tc = null; try { tc = TransactionContext.Begin(); DataReader dr = new DataReader(SalaryMonthlyDA.Get(tc, nEmpID, startDate, endDate, payrollTypeID)); salaryMonthlys = this.CreateObjects(dr); dr.Close(); dr = new DataReader(SalaryMonthlyDA.GetDetail(tc, nEmpID, startDate, endDate, payrollTypeID)); ObjectsTemplate details = this.CreateSalaryMonthlyDetailObject(dr); dr.Close(); int check = 0; foreach (SalaryMonthly salary in salaryMonthlys) { check = 0; foreach (SalaryMonthlyDetail detail in details) { if (salary.ID.Integer == detail.SalaryMonthlyID.Integer) { salary.Details.Add(detail); check = 1; } else { if (check == 1) break; } } } tc.End(); } catch (Exception e) { #region Handle Exception if (tc != null) tc.HandleError(); ExceptionLog.Write(e); throw new ServiceException(e.Message, e); #endregion } return salaryMonthlys; } public ObjectsTemplate GetForCC(ID nSMonthID) { #region Cache Header ObjectsTemplate salaryEmpCCs = null; #endregion TransactionContext tc = null; try { tc = TransactionContext.Begin(); DataReader dr = new DataReader(SalaryMonthlyDA.GetEmpCostCenter(tc, nSMonthID)); salaryEmpCCs = this.CreateEmpCostCenterObject(dr); dr.Close(); tc.End(); } catch (Exception e) { #region Handle Exception if (tc != null) tc.HandleError(); ExceptionLog.Write(e); throw new ServiceException(e.Message, e); #endregion } return salaryEmpCCs; } public ObjectsTemplate GetHead(int index, DateTime salaryMonth) { #region Cache Header ObjectsTemplate salaryMonthlyDetails = null; #endregion TransactionContext tc = null; try { tc = TransactionContext.Begin(); DataReader dr = new DataReader(SalaryMonthlyDA.GetHead(tc, index, salaryMonth)); salaryMonthlyDetails = this.CreateSalaryMonthlyDetailObject(dr); dr.Close(); tc.End(); } catch (Exception e) { #region Handle Exception if (tc != null) tc.HandleError(); ExceptionLog.Write(e); throw new ServiceException(e.Message, e); #endregion } return salaryMonthlyDetails; } public ObjectsTemplate Get(string sEmpID, DateTime salaryMonth) { #region Cache Header ObjectsTemplate salaryMonthlys = null; #endregion TransactionContext tc = null; try { tc = TransactionContext.Begin(); DataReader dr = new DataReader(SalaryMonthlyDA.Get(tc, sEmpID, salaryMonth)); salaryMonthlys = this.CreateObjects(dr); dr.Close(); dr = new DataReader(SalaryMonthlyDA.GetDetail(tc, salaryMonth)); ObjectsTemplate details = this.CreateSalaryMonthlyDetailObject(dr); dr.Close(); int check = 0; foreach (SalaryMonthly salary in salaryMonthlys) { check = 0; foreach (SalaryMonthlyDetail detail in details) { if (salary.ID.Integer == detail.SalaryMonthlyID.Integer) { salary.Details.Add(detail); check = 1; } else { if (check == 1) break; } } } tc.End(); } catch (Exception e) { #region Handle Exception if (tc != null) tc.HandleError(); ExceptionLog.Write(e); throw new ServiceException(e.Message, e); #endregion } return salaryMonthlys; } public ObjectsTemplate GetForWTP(string sEmpID, DateTime salaryMonth) { #region Cache Header ObjectsTemplate salaryMonthlys = null; #endregion TransactionContext tc = null; try { tc = TransactionContext.Begin(); DataReader dr = new DataReader(SalaryMonthlyDA.GetForWTP(tc, sEmpID, salaryMonth)); salaryMonthlys = this.CreateObjects(dr); dr.Close(); dr = new DataReader(SalaryMonthlyDA.GetDetail(tc, salaryMonth)); ObjectsTemplate details = this.CreateSalaryMonthlyDetailObject(dr); dr.Close(); int check = 0; foreach (SalaryMonthly salary in salaryMonthlys) { check = 0; foreach (SalaryMonthlyDetail detail in details) { if (salary.ID.Integer == detail.SalaryMonthlyID.Integer) { salary.Details.Add(detail); check = 1; } else { if (check == 1) break; } } } tc.End(); } catch (Exception e) { #region Handle Exception if (tc != null) tc.HandleError(); ExceptionLog.Write(e); throw new ServiceException(e.Message, e); #endregion } return salaryMonthlys; } public int GetUnAuthorizeDays(ID employeeid, DateTime salaryMonth) { int leaveDays = 0; TransactionContext tc = null; try { tc = TransactionContext.Begin(); leaveDays = SalaryMonthlyDA.GetUnAuthorizeDays(tc, employeeid, salaryMonth); tc.End(); } catch (Exception e) { #region Handle Exception if (tc != null) tc.HandleError(); ExceptionLog.Write(e); throw new ServiceException(e.Message, e); #endregion } return leaveDays; } public bool IsSalaryProcessed(ID employeeID, DateTime SalaryMonth) { bool isProcessed = false; TransactionContext tc = null; try { tc = TransactionContext.Begin(); isProcessed = SalaryMonthlyDA.IsSalaryProcessed(tc, employeeID, SalaryMonth); tc.End(); } catch (Exception e) { #region Handle Exception if (tc != null) tc.HandleError(); ExceptionLog.Write(e); throw new ServiceException(e.Message, e); #endregion } return isProcessed; } public bool IsSalaryProcessedWeb(DateTime SalaryMonth, ID payrollTypeID) { bool isProcessed = false; TransactionContext tc = null; try { tc = TransactionContext.Begin(); isProcessed = SalaryMonthlyDA.IsSalaryProcessedWeb(tc, SalaryMonth, payrollTypeID); tc.End(); } catch (Exception e) { #region Handle Exception if (tc != null) tc.HandleError(); ExceptionLog.Write(e); throw new ServiceException(e.Message, e); #endregion } return isProcessed; } public bool IsPermanentEmp(ID employeeID, DateTime SalaryMonth, ID payrollTypeID) { bool isPermanent = false; TransactionContext tc = null; try { tc = TransactionContext.Begin(); isPermanent = SalaryMonthlyDA.IsPermanentEmp(tc, employeeID, SalaryMonth, payrollTypeID); tc.End(); } catch (Exception e) { #region Handle Exception if (tc != null) tc.HandleError(); ExceptionLog.Write(e); throw new ServiceException(e.Message, e); #endregion } return isPermanent; } public bool IsPermanentEmpOld(ID employeeID, DateTime SalaryMonth, ID payrollTypeID) { bool isPermanent = false; TransactionContext tc = null; try { tc = TransactionContext.Begin(); isPermanent = SalaryMonthlyDA.IsPermanentEmpOld(tc, employeeID, SalaryMonth, payrollTypeID); tc.End(); } catch (Exception e) { #region Handle Exception if (tc != null) tc.HandleError(); ExceptionLog.Write(e); throw new ServiceException(e.Message, e); #endregion } return isPermanent; } public int GetTotalEmp(ID SProcessID) { int nTotalEmp = 0; TransactionContext tc = null; try { tc = TransactionContext.Begin(); nTotalEmp = SalaryMonthlyDA.GetTotalEmp(tc, SProcessID); tc.End(); } catch (Exception e) { #region Handle Exception if (tc != null) tc.HandleError(); ExceptionLog.Write(e); throw new ServiceException(e.Message, e); #endregion } return nTotalEmp; } public void IsSalaryProcessedAndFinalized(ID employeeID, DateTime SalaryMonth, ref bool isprocessed, ref bool isfinalized) { TransactionContext tc = null; try { tc = TransactionContext.Begin(); isfinalized = false; isprocessed = SalaryMonthlyDA.IsSalaryProcessed(tc, employeeID, SalaryMonth); if (isprocessed) { isfinalized = SalaryMonthlyDA.IsSalaryFinalized(tc, employeeID, SalaryMonth); } tc.End(); } catch (Exception e) { #region Handle Exception if (tc != null) tc.HandleError(); ExceptionLog.Write(e); throw new ServiceException(e.Message, e); #endregion } } public ObjectsTemplate GetEmpCostCenter(ID id) { ObjectsTemplate oSalaryEmpCostCenters = new ObjectsTemplate(); #region Cache Header oSalaryEmpCostCenters = _cache["GetEmpCostCenter", id] as ObjectsTemplate; if (oSalaryEmpCostCenters != null) return oSalaryEmpCostCenters; #endregion TransactionContext tc = null; try { tc = TransactionContext.Begin(); DataReader oreader = new DataReader(SalaryMonthlyDA.GetEmpCostCenter(tc, id)); oSalaryEmpCostCenters = this.CreateEmpCostCenterObject(oreader); oreader.Close(); tc.End(); } catch (Exception e) { #region Handle Exception if (tc != null) tc.HandleError(); ExceptionLog.Write(e); throw new ServiceException(e.Message, e); #endregion } #region Cache Footer _cache.Add(oSalaryEmpCostCenters, "GetEmpCostCenter", id); #endregion return oSalaryEmpCostCenters; } public ObjectsTemplate GetSalaryDetail(ID id) { ObjectsTemplate oSalaryMonthlyDetails = new ObjectsTemplate(); #region Cache Header oSalaryMonthlyDetails = _cache["GetSalaryDetail", id] as ObjectsTemplate; if (oSalaryMonthlyDetails != null) return oSalaryMonthlyDetails; #endregion TransactionContext tc = null; try { tc = TransactionContext.Begin(); DataReader oreader = new DataReader(SalaryMonthlyDA.GetSalaryDetail(tc, id)); oSalaryMonthlyDetails = this.CreateSalaryMonthlyDetailObject(oreader); oreader.Close(); tc.End(); } catch (Exception e) { #region Handle Exception if (tc != null) tc.HandleError(); ExceptionLog.Write(e); throw new ServiceException(e.Message, e); #endregion } #region Cache Footer _cache.Add(oSalaryMonthlyDetails, "GetSalaryDetail", id); #endregion return oSalaryMonthlyDetails; } public void Save(SalaryProcess process, ObjectsTemplate items) { TransactionContext tc = null; try { tc = TransactionContext.Begin(true); SalaryProcessService sv = new SalaryProcessService(); ID processId = sv.Save(tc, process); _salaryMID = tc.GenerateID("SalaryMonthly", "SalaryMonthlyID"); _detailID = tc.GenerateID("SALARYMONTHLYDETAIL", "DetailID"); foreach (SalaryMonthly item in items) { item.SalaryProcessID = processId; item.DesignationText = item.Employee.DescriptionText; _detailID = this.Save(tc, item, _salaryMID, _detailID + 1); _salaryMID++; } tc.End(); } catch (Exception e) { #region Handle Exception if (tc != null) tc.HandleError(); ExceptionLog.Write(e); throw new ServiceException(e.Message, e); #endregion } } public void BulkSave(SalaryProcess process, ObjectsTemplate items) { TransactionContext tc = null; DataTable processTable = new DataTable("SALARYPROCESS"); processTable.Columns.Add(new DataColumn("PROCESSDATE", typeof(DateTime))); processTable.Columns.Add(new DataColumn("SalaryMonth", typeof(DateTime))); processTable.Columns.Add(new DataColumn("WORKDAYS", typeof(int))); processTable.Columns.Add(new DataColumn("CreatedBy", typeof(int))); processTable.Columns.Add(new DataColumn("ISFINALIZED", typeof(int))); processTable.Columns.Add(new DataColumn("PAYMENTDATE", typeof(DateTime))); processTable.Columns.Add(new DataColumn("PAYROLLTYPEID", typeof(string))); processTable.Columns.Add(new DataColumn("SHOWINDESKTOP", typeof(int))); processTable.Columns.Add(new DataColumn("CreationDate", typeof(DateTime))); processTable.Columns.Add(new DataColumn("ModifiedBy", typeof(int))); processTable.Columns.Add(new DataColumn("ModifiedDate", typeof(DateTime))); processTable.Columns.Add(new DataColumn("SalaryProcessID", typeof(Int64))); processTable.Columns.Add(new DataColumn("ProcessCode", typeof(string))); processTable.Columns.Add(new DataColumn("Remarks", typeof(string))); processTable.Columns.Add(new DataColumn("ShowInDesktopDate", typeof(DateTime))); processTable.Columns.Add(new DataColumn("MONTHENDDATE", typeof(DateTime))); DataTable salaryTable = new DataTable("SALARYMONTHLY"); salaryTable.Columns.Add(new DataColumn("SALARYMONTHLYID", typeof(Int64))); salaryTable.Columns.Add(new DataColumn("SalaryMonth", typeof(DateTime))); salaryTable.Columns.Add(new DataColumn("EMPLOYEEID", typeof(int))); salaryTable.Columns.Add(new DataColumn("DEPARTMENTID", typeof(int))); salaryTable.Columns.Add(new DataColumn("FUNCTIONID", typeof(int))); salaryTable.Columns.Add(new DataColumn("DESIGNATIONID", typeof(int))); salaryTable.Columns.Add(new DataColumn("LOCATIONID", typeof(string))); salaryTable.Columns.Add(new DataColumn("GRADEID", typeof(double))); salaryTable.Columns.Add(new DataColumn("CATEGORYID", typeof(int))); salaryTable.Columns.Add(new DataColumn("PREVMONTHBASIC", typeof(double))); salaryTable.Columns.Add(new DataColumn("THISMONTHBASIC", typeof(double))); salaryTable.Columns.Add(new DataColumn("ThisMonthGross", typeof(double))); salaryTable.Columns.Add(new DataColumn("ISFINALIZED", typeof(int))); salaryTable.Columns.Add(new DataColumn("REMARKS", typeof(string))); salaryTable.Columns.Add(new DataColumn("ACCOUNTNO", typeof(string))); salaryTable.Columns.Add(new DataColumn("BRANCHID", typeof(int))); salaryTable.Columns.Add(new DataColumn("PAYMENTDATE", typeof(DateTime))); salaryTable.Columns.Add(new DataColumn("PFMEMBERTYPE", typeof(int))); salaryTable.Columns.Add(new DataColumn("GENDER", typeof(int))); salaryTable.Columns.Add(new DataColumn("ISCONFIRMED", typeof(int))); salaryTable.Columns.Add(new DataColumn("ISELIGIBLEOT", typeof(int))); salaryTable.Columns.Add(new DataColumn("GRATUITYPARAMID", typeof(int))); salaryTable.Columns.Add(new DataColumn("RELIGIONID", typeof(int))); salaryTable.Columns.Add(new DataColumn("PAYROLLTYPEID", typeof(int))); salaryTable.Columns.Add(new DataColumn("WITHNODETAIL", typeof(int))); salaryTable.Columns.Add(new DataColumn("DESIGNATION", typeof(string))); salaryTable.Columns.Add(new DataColumn("SalaryProcessID", typeof(int))); salaryTable.Columns.Add(new DataColumn("SBUID", typeof(int))); salaryTable.Columns.Add(new DataColumn("OUTPAYBRANCHID", typeof(int))); salaryTable.Columns.Add(new DataColumn("OUTPAYACCOUNTNO", typeof(string))); salaryTable.Columns.Add(new DataColumn("rccode", typeof(string))); DataTable detailTable = new DataTable("SALARYMONTHLYDETAIL"); detailTable.Columns.Add(new DataColumn("CHANGEDAMOUNT", typeof(double))); detailTable.Columns.Add(new DataColumn("SALARYMONTHLYID", typeof(Int64))); detailTable.Columns.Add(new DataColumn("ITEMCODE", typeof(int))); detailTable.Columns.Add(new DataColumn("ITEMGROUP", typeof(int))); detailTable.Columns.Add(new DataColumn("ITEMID", typeof(int))); detailTable.Columns.Add(new DataColumn("SUPPORTID", typeof(int))); detailTable.Columns.Add(new DataColumn("DESCRIPTION", typeof(string))); detailTable.Columns.Add(new DataColumn("POSITION", typeof(int))); detailTable.Columns.Add(new DataColumn("CALCULATEDAMOUNT", typeof(double))); detailTable.Columns.Add(new DataColumn("ModifiedBy", typeof(int))); detailTable.Columns.Add(new DataColumn("ModifiedDate", typeof(DateTime))); detailTable.Columns.Add(new DataColumn("DetailID", typeof(Int64))); DataTable taxTable = new DataTable("SALARYTEMPIT"); taxTable.Columns.Add(new DataColumn("EMPLOYEEID", typeof(Int64))); taxTable.Columns.Add(new DataColumn("ITEMCODE", typeof(int))); taxTable.Columns.Add(new DataColumn("ItemId", typeof(int))); taxTable.Columns.Add(new DataColumn("DESCRIPTION", typeof(string))); taxTable.Columns.Add(new DataColumn("THISYEARTOTAL", typeof(double))); taxTable.Columns.Add(new DataColumn("PREVIOUSAMOUNT", typeof(double))); taxTable.Columns.Add(new DataColumn("THISMONTHAMOUNT", typeof(double))); taxTable.Columns.Add(new DataColumn("PROJECTEDAMOUNT", typeof(double))); taxTable.Columns.Add(new DataColumn("SIDE", typeof(int))); taxTable.Columns.Add(new DataColumn("POSITION", typeof(int))); taxTable.Columns.Add(new DataColumn("ModifiedBy", typeof(int))); taxTable.Columns.Add(new DataColumn("ModifiedDate", typeof(DateTime))); taxTable.Columns.Add(new DataColumn("HeadID", typeof(int))); try { tc = TransactionContext.Begin(); _salaryMID = tc.GenerateID("SalaryMonthly", "SalaryMonthlyID"); _detailID = tc.GenerateID("SALARYMONTHLYDETAIL", "DetailID"); _processID = tc.GenerateID("SalaryProcess", "SalaryProcessID"); _sConnectionName = tc.Connection.ConnectionString; SalaryProcessService sv = new SalaryProcessService(); processTable.Rows.Add(process.ProcessDate, process.SalaryMonth, process.WorkDays, process.CreatedBy.Integer, Convert.ToInt16(process.IsFinalized), process.SalaryMonth, process.PayrollTypeID.Integer, Convert.ToInt16(process.ShowInDesktops), process.CreatedDate, 1, process.ModifiedDate, _processID, process.ProcessCode, process.Remarks, DateTime.Now, GlobalFunctions.LastDateOfMonth(process.SalaryMonth)); foreach (SalaryMonthly item in items) { int nDesignationID = 0; if(!item.DesignationID.IsUnassigned) nDesignationID=item.DesignationID.Integer; if (nDesignationID==0) salaryTable.Rows.Add(_salaryMID, item.SalaryMonth, item.EmployeeID.Integer, item.DepartmentID.Integer, null, null, item.LocationID.Integer, item.GradeID.Integer, item.CategoryID.Integer, item.PrevMonthBasic, item.ThisMonthBasic, item.ThisMonthGross, Convert.ToInt16(item.IsFinalized), item.Remarks, item.AccountNo, DataReader.GetNullValue(item.BranchID, IDType.Integer), item.SalaryMonth, item.PFMembershipType, (int)item.Gender, Convert.ToInt16(item.IsConfirmed), Convert.ToInt16(item.IsEligibleOT), null, item.ReligionID.Integer, item.PayrollTypeID.Integer, 0, item.Employee.DescriptionText, _processID, 0, DataReader.GetNullValue(item.OutPayBranchID, IDType.Integer), item.OutPayAccountNo, item.RCCode); else salaryTable.Rows.Add(_salaryMID, item.SalaryMonth, item.EmployeeID.Integer, item.DepartmentID.Integer, null, nDesignationID, item.LocationID.Integer, item.GradeID.Integer, item.CategoryID.Integer, item.PrevMonthBasic, item.ThisMonthBasic, item.ThisMonthGross, Convert.ToInt16(item.IsFinalized), item.Remarks, item.AccountNo, DataReader.GetNullValue(item.BranchID, IDType.Integer), item.SalaryMonth, item.PFMembershipType, (int)item.Gender, Convert.ToInt16(item.IsConfirmed), Convert.ToInt16(item.IsEligibleOT), null, item.ReligionID.Integer, item.PayrollTypeID.Integer, 0, item.Employee.DescriptionText, _processID, 0, DataReader.GetNullValue(item.OutPayBranchID, IDType.Integer), item.OutPayAccountNo, item.RCCode); foreach (SalaryMonthlyDetail detail in item.Details) { detailTable.Rows.Add(double.IsNaN(detail.ChangedAmount) ? 0 : detail.ChangedAmount, _salaryMID, (int)detail.ItemCode, (int)detail.itemGroupCode, detail.ItemID, detail.SupportID.Integer, detail.Description, detail.Position, double.IsNaN(detail.CalculatedAmount) ? 0 : detail.CalculatedAmount, 1, DateTime.Now, _detailID); _detailID++; } //foreach(UnAuthorizeLeave ul in item.UnAuthorizedLeaves) //{ // UnAuthorizeLeaveDA.Update(tc, ul); //} foreach (IncomeTax tax in item.Incometaxes) { tax.ModifiedBy = process.CreatedBy;// User.CurrentUser.ID; tax.ModifiedDate = DateTime.Now; taxTable.Rows.Add(tax.EmployeeID.Integer, tax.ItemGroup, tax.ItemID, tax.Description, double.IsNaN(tax.TotalAmount) ? 0 : tax.TotalAmount, double.IsNaN(tax.PreviousAmount) ? 0 : tax.PreviousAmount, double.IsNaN(tax.ThisMonthAmount) ? 0 : tax.ThisMonthAmount, double.IsNaN(tax.ProjectedAmount) ? 0 : tax.ProjectedAmount, (int)tax.Side, tax.Position, tax.ModifiedBy.Integer, tax.ModifiedDate, 1); } _salaryMID++; } using (SqlBulkCopy bulkCopy = new SqlBulkCopy((SqlConnection)tc.Connection)) { bulkCopy.BulkCopyTimeout = 600; // in seconds bulkCopy.DestinationTableName = "SALARYPROCESS"; bulkCopy.WriteToServer(processTable); bulkCopy.DestinationTableName = "SALARYMONTHLY"; bulkCopy.WriteToServer(salaryTable); bulkCopy.DestinationTableName = "SALARYMONTHLYDETAIL"; bulkCopy.WriteToServer(detailTable); bulkCopy.DestinationTableName = "SALARYTEMPIT"; bulkCopy.WriteToServer(taxTable); } foreach (SalaryMonthly item in items) { if (item.UnAuthorizedLeaves != null && item.UnAuthorizedLeaves.Count>0) SalaryMonthlyDA.Insert(tc, item.UnAuthorizedLeaves[0]); } //UnAuthorizeLeaveDA.UpdateUnauthorizedLeave tc.End(); } catch (Exception e) { #region Handle Exception if (tc != null) tc.HandleError(); ExceptionLog.Write(e); throw new ServiceException(e.Message, e); #endregion } } public void BulkSave(DataTable dt) { TransactionContext tc = null; try { tc = TransactionContext.Begin(); DataRow dr=dt.Rows[0]; tc.ExecuteNonQuery("Delete from GradeWPPF where EffectYear=%n", Convert.ToInt16(dr[0].ToString())); using (SqlBulkCopy bulkCopy = new SqlBulkCopy((SqlConnection)tc.Connection)) { bulkCopy.BulkCopyTimeout = 600; // in seconds bulkCopy.DestinationTableName = "GradeWPPF"; bulkCopy.WriteToServer(dt); } tc.End(); } catch (Exception e) { #region Handle Exception if (tc != null) tc.HandleError(); ExceptionLog.Write(e); throw new ServiceException(e.Message, e); #endregion } } public void WPPFClaimSave(DataTable dt) { TransactionContext tc = null; try { int employeeID = 0; int effectYear = 0; tc = TransactionContext.Begin(); foreach (DataRow dRow in dt.Rows) { employeeID = Convert.ToInt32(dRow[0]); effectYear = Convert.ToInt32(dRow[1]); tc.ExecuteNonQuery("Delete from WPPFClaim where employeeID=%n and EffectYear=%n" , employeeID, effectYear); } using (SqlBulkCopy bulkCopy = new SqlBulkCopy((SqlConnection)tc.Connection)) { bulkCopy.BulkCopyTimeout = 600; // in seconds bulkCopy.DestinationTableName = "WPPFClaim"; bulkCopy.WriteToServer(dt); } tc.End(); } catch (Exception e) { #region Handle Exception if (tc != null) tc.HandleError(); ExceptionLog.Write(e); throw new ServiceException(e.Message, e); #endregion } } public void WPPFSave(DataTable dt) { TransactionContext tc = null; try { int employeeID = 0; int effectYear = 0; tc = TransactionContext.Begin(); foreach (DataRow dRow in dt.Rows) { employeeID = Convert.ToInt32(dRow[0]); effectYear = Convert.ToInt32(dRow[1]); tc.ExecuteNonQuery("Delete from WPPF where employeeID=%n and EffectYear=%n", employeeID, effectYear); } using (SqlBulkCopy bulkCopy = new SqlBulkCopy((SqlConnection)tc.Connection)) { bulkCopy.BulkCopyTimeout = 600; // in seconds bulkCopy.DestinationTableName = "WPPF"; bulkCopy.WriteToServer(dt); } tc.End(); } catch (Exception e) { #region Handle Exception if (tc != null) tc.HandleError(); ExceptionLog.Write(e); throw new ServiceException(e.Message, e); #endregion } } public void WWFSave(DataTable dt) { TransactionContext tc = null; try { int employeeID = 0; int effectYear = 0; tc = TransactionContext.Begin(); foreach (DataRow dRow in dt.Rows) { employeeID = Convert.ToInt32(dRow[0]); effectYear = Convert.ToInt32(dRow[1]); tc.ExecuteNonQuery("Delete from WWF where employeeID=%n and EffectYear=%n", employeeID, effectYear); } using (SqlBulkCopy bulkCopy = new SqlBulkCopy((SqlConnection)tc.Connection)) { bulkCopy.BulkCopyTimeout = 600; // in seconds bulkCopy.DestinationTableName = "WWF"; bulkCopy.WriteToServer(dt); } tc.End(); } catch (Exception e) { #region Handle Exception if (tc != null) tc.HandleError(); ExceptionLog.Write(e); throw new ServiceException(e.Message, e); #endregion } } private int Save(TransactionContext tc, SalaryMonthly oSalaryMonthly, int nSalID, int nDetailID) { string tableName = "SalaryMonthly"; try { //int id = tc.GenerateID("SalaryMonthly", "SalaryMonthlyID"); if (oSalaryMonthly.IsNew) { base.SetObjectID(oSalaryMonthly, ID.FromInteger(nSalID)); SalaryMonthlyDA.Insert(tc, oSalaryMonthly); //id = id + 1; } else { SalaryMonthlyDA.Update(tc, oSalaryMonthly); SalaryMonthlyDA.DeleteSalaryDetail(tc, oSalaryMonthly.ID); SalaryMonthlyDA.DeleteSalaryEmpCC(tc, oSalaryMonthly.ID); IncomeTaxDA.Delete(tc, oSalaryMonthly.EmployeeID, EnumIncomeTaxDataFrom.SalaryITTempData); } tableName = "SalaryDetail"; //id = tc.GenerateID("SALARYMONTHLYDETAIL", "DetailID"); foreach (SalaryMonthlyDetail oSMDetail in oSalaryMonthly.Details) { oSMDetail.SalaryMonthlyID = oSalaryMonthly.ID; base.SetObjectID(oSMDetail, ID.FromInteger(nDetailID)); SalaryMonthlyDA.Insert(tc, oSMDetail); nDetailID++; //id = id + 1; } tableName = "IncomeTax"; foreach (IncomeTax item in oSalaryMonthly.Incometaxes) { IncomeTaxService iis = new IncomeTaxService(); this.SetObjectState(item, ObjectState.New); item.ModifiedBy = User.CurrentUser.ID; item.ModifiedDate = DateTime.Now; iis.SaveForEdit(tc, item, EnumIncomeTaxDataFrom.SalaryITTempData); } tableName = "Salary CostCenter"; foreach (SalaryEmpCostCenter oSEmpCostCenter in oSalaryMonthly.CostCentersInvolments) { oSEmpCostCenter.SalaryMontlyID = oSalaryMonthly.ID; SalaryMonthlyDA.Insert(tc, oSEmpCostCenter); } return nDetailID; } catch (Exception e) { #region Handle Exception if (tc != null) tc.HandleError(); ExceptionLog.Write(e); string smessage = "Faliled to save salary (table:" + tableName + ") for the employee:(" + oSalaryMonthly.Employee.EmployeeNo + ") " + oSalaryMonthly.Employee.Name + ". Error :"; throw new ServiceException(smessage + e.Message, e); #endregion } } public void Update(SalaryMonthly item) { TransactionContext tc = null; try { tc = TransactionContext.Begin(true); SalaryProcessService sv = new SalaryProcessService(); this.Save(tc, item); tc.End(); } catch (Exception e) { #region Handle Exception if (tc != null) tc.HandleError(); ExceptionLog.Write(e); throw new ServiceException(e.Message, e); #endregion } } public void UpdateDetail(ObjectsTemplate oSalaryDetails, ObjectsTemplate taxdeducteditems) { TransactionContext tc = null; try { tc = TransactionContext.Begin(true); foreach (SalaryMonthlyDetail odetail in oSalaryDetails) { if (odetail.IsNew == false) SalaryMonthlyDA.UpdateSalaryDetail(tc, odetail); else { int id = tc.GenerateID("SALARYMONTHLYDETAIL", "DetailID"); this.SetObjectID(odetail, ID.FromInteger(id)); SalaryMonthlyDA.Insert(tc, odetail); } } foreach (IncomeTax taxItem in taxdeducteditems) { IncomeTaxDA.UpdateTaxAmountFromSalary(tc, taxItem.ThisMonthAmount, taxItem.EmployeeID); } tc.End(); } catch (Exception e) { #region Handle Exception if (tc != null) tc.HandleError(); ExceptionLog.Write(e); throw new ServiceException(e.Message, e); #endregion } } private ID Save(TransactionContext tc, SalaryMonthly oSalaryMonthly) { string tableName = "SalaryMonthly"; try { int id = tc.GenerateID("SalaryMonthly", "SalaryMonthlyID"); if (oSalaryMonthly.IsNew) { base.SetObjectID(oSalaryMonthly, ID.FromInteger(id)); SalaryMonthlyDA.Insert(tc, oSalaryMonthly); id = id + 1; } else { SalaryMonthlyDA.Update(tc, oSalaryMonthly); SalaryMonthlyDA.DeleteSalaryDetail(tc, oSalaryMonthly.ID); SalaryMonthlyDA.DeleteSalaryEmpCC(tc, oSalaryMonthly.ID); IncomeTaxDA.Delete(tc, oSalaryMonthly.EmployeeID, EnumIncomeTaxDataFrom.SalaryITTempData); } tableName = "SalaryDetail"; id = tc.GenerateID("SALARYMONTHLYDETAIL", "DetailID"); foreach (SalaryMonthlyDetail oSMDetail in oSalaryMonthly.Details) { oSMDetail.SalaryMonthlyID = oSalaryMonthly.ID; base.SetObjectID(oSMDetail, ID.FromInteger(id)); SalaryMonthlyDA.Insert(tc, oSMDetail); id = id + 1; } tableName = "IncomeTax"; foreach (IncomeTax item in oSalaryMonthly.Incometaxes) { IncomeTaxService iis = new IncomeTaxService(); this.SetObjectState(item, ObjectState.New); item.ModifiedBy = User.CurrentUser.ID; item.ModifiedDate = DateTime.Now; iis.SaveForEdit(tc, item, EnumIncomeTaxDataFrom.SalaryITTempData); } tableName = "Salary CostCenter"; foreach (SalaryEmpCostCenter oSEmpCostCenter in oSalaryMonthly.CostCentersInvolments) { oSEmpCostCenter.SalaryMontlyID = oSalaryMonthly.ID; SalaryMonthlyDA.Insert(tc, oSEmpCostCenter); } return oSalaryMonthly.ID; } catch (Exception e) { #region Handle Exception if (tc != null) tc.HandleError(); ExceptionLog.Write(e); string smessage = "Faliled to save salary (table:" + tableName + ") for the employee:(" + oSalaryMonthly.Employee.EmployeeNo + ") " + oSalaryMonthly.Employee.Name + ". Error :"; throw new ServiceException(smessage + e.Message, e); #endregion } } public void Delete(ID id) { TransactionContext tc = null; try { tc = TransactionContext.Begin(true); SalaryMonthlyDA.Delete(tc, id); tc.End(); } catch (Exception e) { #region Handle Exception if (tc != null) tc.HandleError(); ExceptionLog.Write(e); throw new ServiceException(e.Message, e); #endregion } } #endregion public DataSet GetLastPayDate(int empid) { DataSet lastPayDate = new DataSet(); TransactionContext tc = null; try { tc = TransactionContext.Begin(); lastPayDate = SalaryMonthlyDA.GetLastPayDate(tc, empid); tc.End(); } catch (Exception e) { #region Handle Exception if (tc != null) tc.HandleError(); ExceptionLog.Write(e); throw new ServiceException(e.Message, e); #endregion } return lastPayDate; } public DataSet GetEmpSalaryReconciliationSummary(DateTime dateTime, string sEmpID) { DataSet oSalaryMonthlys = new DataSet(); TransactionContext tc = null; try { tc = TransactionContext.Begin(); oSalaryMonthlys = SalaryMonthlyDA.GetEmpSalaryReconciliationSummary(tc, dateTime, sEmpID); tc.End(); } catch (Exception e) { #region Handle Exception if (tc != null) tc.HandleError(); ExceptionLog.Write(e); throw new ServiceException(e.Message, e); #endregion } return oSalaryMonthlys; } public DataSet GetCCWiseSalarySheet(DateTime dateTime, string sEmpID) { DataSet oSalaryMonthlys = new DataSet(); TransactionContext tc = null; try { tc = TransactionContext.Begin(); oSalaryMonthlys = SalaryMonthlyDA.GetCCWiseSalarySheet(tc, dateTime, sEmpID); tc.End(); } catch (Exception e) { #region Handle Exception if (tc != null) tc.HandleError(); ExceptionLog.Write(e); throw new ServiceException(e.Message, e); #endregion } return oSalaryMonthlys; } public DataSet GetEmpSalarySheetForManagement(DateTime sdMonth, string empId) { DataSet oSalarymonthformngt = new DataSet(); TransactionContext tc = null; try { tc = TransactionContext.Begin(); oSalarymonthformngt = SalaryMonthlyDA.GetEmpSalarySheetForManagement(tc, sdMonth, empId); } catch (Exception ex) { throw new ServiceException(ex.Message); } return oSalarymonthformngt; } public DataSet GetCCWiseSalarySheetDetail(DateTime dSMonthDate, string sEmpID) { DataSet oSalaryMonthlys = new DataSet(); TransactionContext tc = null; try { tc = TransactionContext.Begin(); oSalaryMonthlys = SalaryMonthlyDA.GetCCWiseSalarySheetDetail(tc, dSMonthDate, sEmpID); tc.End(); } catch (Exception e) { #region Handle Exception if (tc != null) tc.HandleError(); ExceptionLog.Write(e); throw new ServiceException(e.Message, e); #endregion } return oSalaryMonthlys; } public DataSet CostCenterCount(DateTime dSMonthDate) { DataSet oSalaryMonthlys = new DataSet(); TransactionContext tc = null; try { tc = TransactionContext.Begin(); oSalaryMonthlys = SalaryMonthlyDA.CostCenterCount(tc, dSMonthDate); tc.End(); } catch (Exception e) { #region Handle Exception if (tc != null) tc.HandleError(); ExceptionLog.Write(e); throw new ServiceException(e.Message, e); #endregion } return oSalaryMonthlys; } public DataSet GetWPPFByGrade(int nYear) { DataSet oSalaryMonthlys = new DataSet(); TransactionContext tc = null; try { tc = TransactionContext.Begin(); oSalaryMonthlys = SalaryMonthlyDA.GetWPPFByGrade(tc, nYear); tc.End(); } catch (Exception e) { #region Handle Exception if (tc != null) tc.HandleError(); ExceptionLog.Write(e); throw new ServiceException(e.Message, e); #endregion } return oSalaryMonthlys; } public DataSet GetWPPF(int empID) { DataSet ds = new DataSet(); TransactionContext tc = null; try { tc = TransactionContext.Begin(); ds = SalaryMonthlyDA.GetWPPF(tc, empID); tc.End(); } catch (Exception e) { #region Handle Exception if (tc != null) tc.HandleError(); ExceptionLog.Write(e); throw new ServiceException(e.Message, e); #endregion } return ds; } public DataSet GetWPPFFormEmployee(int nYear) { DataSet oSalaryMonthlys = new DataSet(); TransactionContext tc = null; try { tc = TransactionContext.Begin(); oSalaryMonthlys = SalaryMonthlyDA.GetWPPFFormEmployee(tc, nYear); tc.End(); } catch (Exception e) { #region Handle Exception if (tc != null) tc.HandleError(); ExceptionLog.Write(e); throw new ServiceException(e.Message, e); #endregion } return oSalaryMonthlys; } public DataSet GetBasic() { DataSet oSalaryMonthlys = new DataSet(); TransactionContext tc = null; try { tc = TransactionContext.Begin(); oSalaryMonthlys = SalaryMonthlyDA.GetBasic(tc); tc.End(); } catch (Exception e) { #region Handle Exception if (tc != null) tc.HandleError(); ExceptionLog.Write(e); throw new ServiceException(e.Message, e); #endregion } return oSalaryMonthlys; } public DataTable GetGrade() { DataTable dtGrade = null; TransactionContext tc = null; try { tc = TransactionContext.Begin(); dtGrade = SalaryMonthlyDA.GetGrade(tc) == null ? new DataTable() : SalaryMonthlyDA.GetGrade(tc).Tables[0]; tc.End(); } catch (Exception e) { #region Handle Exception if (tc != null) tc.HandleError(); ExceptionLog.Write(e); throw new ServiceException(e.Message, e); #endregion } return dtGrade; } public DataTable GetCustomDataTable(string sQuery) { DataTable dtGrade = null; TransactionContext tc = null; try { tc = TransactionContext.Begin(); dtGrade = SalaryMonthlyDA.GetCustomDataTable(tc, sQuery) == null ? new DataTable() : SalaryMonthlyDA.GetCustomDataTable(tc, sQuery).Tables[0]; tc.End(); } catch (Exception e) { #region Handle Exception if (tc != null) tc.HandleError(); ExceptionLog.Write(e); throw new ServiceException(e.Message, e); #endregion } return dtGrade; } public DataSet GetRewardStatementReportData(ID payrollTypeID, EnumAllowOrDeduct allowOrDeduct, ID empID, EnumADEmpType adEmpType, int previousYear, int currentYear, ID gradeID, string bonusIDs, EnmSetupManagerTranType setupManagerType) { DataSet dsRewardStatementData = new DataSet(); TransactionContext tc = null; try { tc = TransactionContext.Begin(); DataSet dsTemp = null; dsTemp = SalaryMonthlyDA.GetBasic(tc); if (dsTemp != null) dsRewardStatementData.Tables.Add(dsTemp.Tables[0].Copy()); else dsRewardStatementData.Tables.Add(new DataTable()); dsRewardStatementData.Tables[0].TableName = "Basic"; dsTemp = ADParameterEmployeeDA.GetByEmployee(tc, payrollTypeID, allowOrDeduct, empID, adEmpType); if (dsTemp != null) dsRewardStatementData.Tables.Add(dsTemp.Tables[0].Copy()); else dsRewardStatementData.Tables.Add(new DataTable()); dsRewardStatementData.Tables[1].TableName = "ADPARAM"; dsTemp = SalaryMonthlyDA.GetWPPFClaim(tc, empID, previousYear, currentYear); if (dsTemp != null) dsRewardStatementData.Tables.Add(dsTemp.Tables[0].Copy()); else dsRewardStatementData.Tables.Add(new DataTable()); dsRewardStatementData.Tables[2].TableName = "WPPFClaim"; dsTemp = SalaryMonthlyDA.GetWPPF(tc, empID.Integer, previousYear, currentYear); if (dsTemp != null) dsRewardStatementData.Tables.Add(dsTemp.Tables[0].Copy()); else dsRewardStatementData.Tables.Add(new DataTable()); dsRewardStatementData.Tables[3].TableName = "WPPF"; dsTemp = SalaryMonthlyDA.GetWWF(tc, empID.Integer, previousYear, currentYear); if (dsTemp != null) dsRewardStatementData.Tables.Add(dsTemp.Tables[0].Copy()); else dsRewardStatementData.Tables.Add(new DataTable()); dsRewardStatementData.Tables[4].TableName = "WWF"; dsTemp = BonusParameterDA.GetByBonusIDAndTranType(tc, bonusIDs, setupManagerType); if (dsTemp != null) dsRewardStatementData.Tables.Add(dsTemp.Tables[0].Copy()); else dsRewardStatementData.Tables.Add(new DataTable()); dsRewardStatementData.Tables[5].TableName = "BONUS"; dsTemp = SalaryMonthlyDA.GetGrade(tc); if (dsTemp != null) dsRewardStatementData.Tables.Add(dsTemp.Tables[0].Copy()); else dsRewardStatementData.Tables.Add(new DataTable()); dsRewardStatementData.Tables[6].TableName = "Grade"; tc.End(); } catch (Exception e) { #region Handle Exception if (tc != null) tc.HandleError(); ExceptionLog.Write(e); throw new ServiceException(e.Message, e); #endregion } return dsRewardStatementData; } public DataSet GetCCWiseSalarySummary(DateTime dateTime, string sEmpID) { DataSet oSalaryMonthlys = new DataSet(); TransactionContext tc = null; try { tc = TransactionContext.Begin(); oSalaryMonthlys = SalaryMonthlyDA.GetCCWiseSalarySummary(tc, dateTime, sEmpID); tc.End(); } catch (Exception e) { #region Handle Exception if (tc != null) tc.HandleError(); ExceptionLog.Write(e); throw new ServiceException(e.Message, e); #endregion } return oSalaryMonthlys; } public DataSet GetNewCCWiseSalarySummary(DateTime dateTime, string sEmpID) { DataSet oSalaryMonthlys = new DataSet(); TransactionContext tc = null; try { tc = TransactionContext.Begin(); oSalaryMonthlys = SalaryMonthlyDA.GetNewCCWiseSalarySummary(tc, dateTime, sEmpID); tc.End(); } catch (Exception e) { #region Handle Exception if (tc != null) tc.HandleError(); ExceptionLog.Write(e); throw new ServiceException(e.Message, e); #endregion } return oSalaryMonthlys; } public SalaryMonthlyDetail GetDetail(ID employeeId, DateTime SalaryMonth, EnumSalaryGroup groupCode, EnumSalaryItemCode itemCode, int itemId) { SalaryMonthlyDetail odetail = null; TransactionContext tc = null; try { tc = TransactionContext.Begin(); DataReader oreader = new DataReader(SalaryMonthlyDA.GetDetail(tc, employeeId, SalaryMonth, groupCode, itemCode, itemId)); ObjectsTemplate details = this.CreateSalaryMonthlyDetailObject(oreader); oreader.Close(); if (details.Count > 0) odetail = details[0]; tc.End(); } catch (Exception e) { #region Handle Exception if (tc != null) tc.HandleError(); ExceptionLog.Write(e); throw new ServiceException(e.Message, e); #endregion } return odetail; } public ObjectsTemplate Get(string sEmpID, DateTime fromdate, DateTime toDate) { #region Cache Header ObjectsTemplate salaryMonthlys = null; #endregion TransactionContext tc = null; try { tc = TransactionContext.Begin(); DataReader dr = new DataReader(SalaryMonthlyDA.Get(tc, sEmpID, fromdate, toDate)); salaryMonthlys = this.CreateObjects(dr); dr.Close(); dr = new DataReader(SalaryMonthlyDA.GetDetail(tc, fromdate, toDate)); ObjectsTemplate details = this.CreateSalaryMonthlyDetailObject(dr); dr.Close(); int check = 0; foreach (SalaryMonthly salary in salaryMonthlys) { check = 0; foreach (SalaryMonthlyDetail detail in details) { if (salary.ID.Integer == detail.SalaryMonthlyID.Integer) { salary.Details.Add(detail); check = 1; } else { if (check == 1) break; } } } tc.End(); } catch (Exception e) { #region Handle Exception if (tc != null) tc.HandleError(); ExceptionLog.Write(e); throw new ServiceException(e.Message, e); #endregion } return salaryMonthlys; } public DataSet GetSalaryStracture(string SempIds) { DataSet oSalaryStracture = new DataSet(); TransactionContext tc = null; try { tc = TransactionContext.Begin(); oSalaryStracture = SalaryMonthlyDA.GetSalaryStracture(tc, SempIds); tc.End(); } catch (Exception e) { #region Handle Exception if (tc != null) tc.HandleError(); ExceptionLog.Write(e); throw new ServiceException(e.Message, e); #endregion } return oSalaryStracture; } public DataSet GetEmpPNL(DateTime dateTime, string sEmpID) { DataSet oSalaryMonthlys = new DataSet(); TransactionContext tc = null; try { tc = TransactionContext.Begin(); oSalaryMonthlys = SalaryMonthlyDA.GetEmpPNL(tc, dateTime, sEmpID); tc.End(); } catch (Exception e) { #region Handle Exception if (tc != null) tc.HandleError(); ExceptionLog.Write(e); throw new ServiceException(e.Message, e); #endregion } return oSalaryMonthlys; } public DataSet GetEmpSalarySheet(DateTime dSMonthDate, DateTime dEMonthDate, string sEmpID) { DataSet oSalaryMonthlys = new DataSet(); TransactionContext tc = null; try { tc = TransactionContext.Begin(); oSalaryMonthlys = SalaryMonthlyDA.GetEmpSalarySheet(tc, dSMonthDate, dEMonthDate, sEmpID); tc.End(); } catch (Exception e) { #region Handle Exception if (tc != null) tc.HandleError(); ExceptionLog.Write(e); throw new ServiceException(e.Message, e); #endregion } return oSalaryMonthlys; } public DataSet GetSMAndBPForRewardYear(string employeeID, DateTime currentYearFromDate, DateTime currentYearToDate, DateTime previousYearFromDate, DateTime previousYearToDate) { DataSet dtSMAndBP = new DataSet(); TransactionContext tc = null; try { tc = TransactionContext.Begin(); dtSMAndBP = SalaryMonthlyDA.GetSMAndBPForRewardYear(tc, employeeID, currentYearFromDate, currentYearToDate, previousYearFromDate, previousYearToDate); tc.End(); } catch (Exception e) { #region Handle Exception if (tc != null) tc.HandleError(); ExceptionLog.Write(e); throw new ServiceException(e.Message, e); #endregion } return dtSMAndBP; } public DataTable GetGradeWPPF(int previousYear, int currentYear, int gradeID) { DataTable dtGradeWPPF = new DataTable(); TransactionContext tc = null; try { tc = TransactionContext.Begin(); dtGradeWPPF = SalaryMonthlyDA.GetGradeWPPF(tc, previousYear, currentYear, gradeID).Tables[0]; tc.End(); } catch (Exception e) { #region Handle Exception if (tc != null) tc.HandleError(); ExceptionLog.Write(e); throw new ServiceException(e.Message, e); #endregion } return dtGradeWPPF; } public DataTable GetCalCulatedAmountByAllowDeductID(ID empID, ID allowDeductID, DateTime salaryMonth) { DataTable dtSalaryMonthly = null; TransactionContext tc = null; try { tc = TransactionContext.Begin(); DataSet ds = SalaryMonthlyDA.GetCalCulatedAmountByAllowDeductID(tc, empID, allowDeductID, salaryMonth); dtSalaryMonthly = ds == null ? new DataTable() : ds.Tables[0]; tc.End(); } catch (Exception e) { #region Handle Exception if (tc != null) tc.HandleError(); ExceptionLog.Write(e); throw new ServiceException(e.Message, e); #endregion } return dtSalaryMonthly; } public void SalaryProcess( ObjectsTemplate _employees, DateTime dateTime) { //ObjectsTemplate ProcessItems = ProcessItem.Get(); //SalaryCalculator _calculate = new SalaryCalculator(ProcessItems); //_calculate.Process(_employees, dateTime); ////if (_calculate.ErrorList.Count > 0) ////{ //// fPayslip errorlist = new fPayslip(); //// if (errorlist.ShowDlg(_calculate.ErrorList)) //// { //// foreach (SalaryProcessStatus item in _calculate.ErrorList) //// { //// _calculate.SalaryMonthlies.Remove(_calculate.SalaryMonthlies.FirstOrDefault(o => o.EmployeeNo == item.EmployeeNo)); //// } //// } //// else //// { //// return; //// } ////} //SalaryProcess process = new SalaryProcess(); ////process.ProcessCode = txtProcessID.Text; ////process.Remarks = txtDescription.Text; //process.ProcessDate = DateTime.Today;// dtpProcessDate.Value; //process.PayrollTypeID = Payroll.BO.SystemInformation.CurrentSysInfo.PayrollTypeID; //process.SalaryMonth = Payroll.BO.SystemInformation.CurrentSysInfo.NextPayProcessDate; //SalaryMonthly.BulkSave(process, _calculate.SalaryMonthlies); } } #endregion }