using System; using System.Data; using Ease.Core.Model; using Ease.Core.DataAccess; using HRM.BO; using Ease.Core.Utility; using System.Collections.Generic; namespace HRM.DA { public class AllowanceDeductionService : ServiceTemplate, IAllowanceDeductionService { public AllowanceDeductionService() { } private void MapObject(AllowanceDeduction oAllowanceDeduction, DataReader oReader) { base.SetObjectID(oAllowanceDeduction, oReader.GetInt32("ALLOWDEDUCTID").Value); oAllowanceDeduction.Code = oReader.GetString("code"); oAllowanceDeduction.Name = oReader.GetString("name"); oAllowanceDeduction.NameInBangla = oReader.GetString("nameinbangla", true, null); oAllowanceDeduction.AllowOrDeductType = (EnumAllowOrDeduct)oReader.GetInt32("allowOrDeduct").Value; oAllowanceDeduction.Sequence = oReader.GetInt32("SequenceNo").Value; oAllowanceDeduction.Status = (EnumStatus)oReader.GetInt32("Status").Value; //oAllowanceDeduction.Periodicity = (EnumPeriodicity)oReader.GetInt32("Periodicity").Value; oAllowanceDeduction.CreatedBy = oReader.GetInt32("CreatedBy", 0); oAllowanceDeduction.CreatedDate = oReader.GetDateTime("CreationDate").Value; oAllowanceDeduction.ModifiedBy = oReader.GetInt32("ModifiedBy", 0); oAllowanceDeduction.ModifiedDate = oReader.GetDateTime("ModifiedDate"); oAllowanceDeduction.payrolltypeid = oReader.GetInt32("payrolltypeid").Value; this.SetObjectState(oAllowanceDeduction, Ease.Core.ObjectState.Saved); } protected override T CreateObject(DataReader oReader) { AllowanceDeduction oAllowanceDeduction = new AllowanceDeduction(); MapObject(oAllowanceDeduction, oReader); return oAllowanceDeduction as T; } #region Service implementation public AllowanceDeduction Get(int id) { AllowanceDeduction oAllowanceDeduction = null; TransactionContext tc = null; try { tc = TransactionContext.Begin(); DataReader oreader = new DataReader(AllowanceDeductionDA.Get(tc, id)); if (oreader.Read()) { oAllowanceDeduction = 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 oAllowanceDeduction; } public List GetAllAllowance(int payrollTypeID, EnumAllowOrDeduct allowOrDeduct, EnumStatus status, string code, string name) { List allowanceList = new List(); TransactionContext tc = null; try { tc = TransactionContext.Begin(); DataReader dr = new DataReader(AllowanceDeductionDA.GetAllAllowance(tc, payrollTypeID, allowOrDeduct, status, code, name)); allowanceList = 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 } return allowanceList; } public List GetByGradeID(EnumStatus status, int gradeID, EnumAllowOrDeduct type) { List allowDeduct = new List(); TransactionContext tc = null; try { tc = TransactionContext.Begin(); DataReader dr = new DataReader(AllowanceDeductionDA.GetByGradeID(tc, status, gradeID, type)); allowDeduct = 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 } return allowDeduct; } public List Get(EnumStatus status) { List allowanceDeductions = new List(); TransactionContext tc = null; try { tc = TransactionContext.Begin(); DataReader dr = new DataReader(AllowanceDeductionDA.Get(tc, status)); allowanceDeductions = 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 } return allowanceDeductions; } public List GetAllowance(EnumStatus status, int payrolltypeid) { List allowanceDeductions = new List(); TransactionContext tc = null; try { tc = TransactionContext.Begin(); DataReader dr = new DataReader(AllowanceDeductionDA.GetAllowance(tc, status, payrolltypeid)); allowanceDeductions = 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 } return allowanceDeductions; } public List GetADparamAllowance(EnumStatus status, int payrollTypeID) { List allowanceDeductions = new List(); TransactionContext tc = null; try { tc = TransactionContext.Begin(); DataReader dr = new DataReader(AllowanceDeductionDA.GetADparamAllowance(tc, status, payrollTypeID)); allowanceDeductions = 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 } return allowanceDeductions; } public List GetAllowance(EnumPeriodicity periodicity, EnumAllowOrDeduct allowOrdeduct) { List allowanceDeductions = new List(); TransactionContext tc = null; try { tc = TransactionContext.Begin(); DataReader dr = new DataReader(AllowanceDeductionDA.GetAllowance(tc, periodicity, allowOrdeduct)); allowanceDeductions = 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 } return allowanceDeductions; } public List GetAllowance(EnumPeriodicity periodicity, EnumEntitleType enumEntitleType, EnumAllowOrDeduct allowOrdeduct) { List allowanceDeductions = new List(); TransactionContext tc = null; try { tc = TransactionContext.Begin(); DataReader dr = new DataReader(AllowanceDeductionDA.GetAllowance(tc, periodicity, enumEntitleType, allowOrdeduct)); allowanceDeductions = 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 } return allowanceDeductions; } public List GetDeduction(EnumStatus status, int payrolltypeid) { List allowanceDeductions = new List(); TransactionContext tc = null; try { tc = TransactionContext.Begin(); DataReader dr = new DataReader(AllowanceDeductionDA.GetDeduction(tc, status, payrolltypeid)); allowanceDeductions = 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 } return allowanceDeductions; } // internal static IDataReader GetMonthyIndividualAndOneOff(TransactionContext tc, int payrolltypeid, EnumStatus status, EnumAllowOrDeduct nType) public List GetMonthyIndividualAndOneOff(int payrolltypeid, EnumStatus status, EnumAllowOrDeduct nType) { List allowanceDeductions = new List(); TransactionContext tc = null; try { tc = TransactionContext.Begin(); DataReader dr = new DataReader(AllowanceDeductionDA.GetMonthyIndividualAndOneOff(tc, payrolltypeid, status, nType)); allowanceDeductions = 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 } return allowanceDeductions; } public List Get(int payrolltypeid, EnumStatus status, EnumAllowOrDeduct nType, EnumPeriodicity nPeriodcity) { List allowanceDeductions = new List(); TransactionContext tc = null; try { tc = TransactionContext.Begin(); DataReader dr = new DataReader(AllowanceDeductionDA.Get(tc, payrolltypeid, status, nType, nPeriodcity)); allowanceDeductions = 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 } return allowanceDeductions; } public List Get(EnumStatus status, EnumAllowOrDeduct nType, int payrollTypeID) { List allowanceDeductions = new List(); TransactionContext tc = null; try { tc = TransactionContext.Begin(); DataReader dr = new DataReader(AllowanceDeductionDA.Get(tc, status, nType, payrollTypeID)); allowanceDeductions = 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 } return allowanceDeductions; } public List Get(EnumStatus status, int payrollTypeID) { List allowanceDeductions = new List(); TransactionContext tc = null; try { tc = TransactionContext.Begin(); DataReader dr = new DataReader(AllowanceDeductionDA.Get(tc, status, payrollTypeID)); allowanceDeductions = 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 } return allowanceDeductions; } public List GetException(EnumStatus status, EnumAllowOrDeduct nType, int payrollTypeID) { List allowanceDeductions = new List(); TransactionContext tc = null; try { tc = TransactionContext.Begin(); DataReader dr = new DataReader(AllowanceDeductionDA.GetException(tc, status, nType, payrollTypeID)); allowanceDeductions = 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 } return allowanceDeductions; } public int Save(AllowanceDeduction oAllowanceDeduction) { TransactionContext tc = null; try { tc = TransactionContext.Begin(true); if (oAllowanceDeduction.IsNew) { int id = tc.GenerateID("AllowanceDeduction", "ALLOWDEDUCTID"); base.SetObjectID(oAllowanceDeduction, (id)); int seqNo = tc.GenerateID("AllowanceDeduction", "SequenceNO"); oAllowanceDeduction.Sequence = seqNo; AllowanceDeductionDA.Insert(tc, oAllowanceDeduction); } else { AllowanceDeductionDA.Update(tc, oAllowanceDeduction); } tc.End(); return oAllowanceDeduction.ID; } catch (Exception e) { #region Handle Exception if (tc != null) tc.HandleError(); ExceptionLog.Write(e); throw new ServiceException(e.Message, e); #endregion } } public void Delete(int id) { TransactionContext tc = null; try { tc = TransactionContext.Begin(true); AllowanceDeductionDA.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 } } public string GetNextCode() { TransactionContext tc = null; string _code = ""; try { tc = TransactionContext.Begin(); _code = GlobalFunctionService.GetMaxCode(tc, "AllowanceDeduction", "Code"); tc.End(); } catch (Exception e) { #region Handle Exception if (tc != null) tc.HandleError(); ExceptionLog.Write(e); throw new ServiceException(e.Message, e); #endregion } return _code; } public DataSet GetEmpAllowDeduc(DateTime dEffectDate, int AllowDeducID, int payrollTypeID) { DataSet oEmpAllowDeduc = new DataSet(); TransactionContext tc = null; try { tc = TransactionContext.Begin(); oEmpAllowDeduc = AllowanceDeductionDA.GetEmpAllowDeduc(tc, dEffectDate, AllowDeducID, 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 oEmpAllowDeduc; } public DataSet GetEmpAllowDeduc2(DateTime dEffectDate, DateTime dEffectDate2, int AllowDeducID, int payrollTypeID) { DataSet oEmpAllowDeduc = new DataSet(); TransactionContext tc = null; try { tc = TransactionContext.Begin(); oEmpAllowDeduc = AllowanceDeductionDA.GetEmpAllowDeduc2(tc, dEffectDate, dEffectDate2, AllowDeducID, 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 oEmpAllowDeduc; } #endregion } }