EchoTex_Payroll/HRM.DA/Service/AllowDeduct/AllowanceDeductionService.cs

622 lines
19 KiB
C#
Raw Permalink Normal View History

2024-10-14 10:01:49 +06:00
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<T>(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<AllowanceDeduction>(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<AllowanceDeduction> GetAllAllowance(int payrollTypeID, EnumAllowOrDeduct allowOrDeduct, EnumStatus status, string code, string name)
{
List<AllowanceDeduction> allowanceList = new List<AllowanceDeduction>();
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin();
DataReader dr =
new DataReader(AllowanceDeductionDA.GetAllAllowance(tc, payrollTypeID, allowOrDeduct, status, code, name));
allowanceList = this.CreateObjects<AllowanceDeduction>(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<AllowanceDeduction> GetByGradeID(EnumStatus status, int gradeID, EnumAllowOrDeduct type)
{
List<AllowanceDeduction> allowDeduct = new List<AllowanceDeduction>();
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin();
DataReader dr = new DataReader(AllowanceDeductionDA.GetByGradeID(tc, status, gradeID, type));
allowDeduct = this.CreateObjects<AllowanceDeduction>(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<AllowanceDeduction> Get(EnumStatus status)
{
List<AllowanceDeduction> allowanceDeductions = new List<AllowanceDeduction>();
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin();
DataReader dr = new DataReader(AllowanceDeductionDA.Get(tc, status));
allowanceDeductions = this.CreateObjects<AllowanceDeduction>(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<AllowanceDeduction> GetAllowance(EnumStatus status, int payrolltypeid)
{
List<AllowanceDeduction> allowanceDeductions = new List<AllowanceDeduction>();
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin();
DataReader dr = new DataReader(AllowanceDeductionDA.GetAllowance(tc, status, payrolltypeid));
allowanceDeductions = this.CreateObjects<AllowanceDeduction>(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<AllowanceDeduction> GetADparamAllowance(EnumStatus status, int payrollTypeID)
{
List<AllowanceDeduction> allowanceDeductions = new List<AllowanceDeduction>();
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin();
DataReader dr = new DataReader(AllowanceDeductionDA.GetADparamAllowance(tc, status, payrollTypeID));
allowanceDeductions = this.CreateObjects<AllowanceDeduction>(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<AllowanceDeduction> GetAllowance(EnumPeriodicity periodicity, EnumAllowOrDeduct allowOrdeduct)
{
List<AllowanceDeduction> allowanceDeductions = new List<AllowanceDeduction>();
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin();
DataReader dr = new DataReader(AllowanceDeductionDA.GetAllowance(tc, periodicity, allowOrdeduct));
allowanceDeductions = this.CreateObjects<AllowanceDeduction>(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<AllowanceDeduction> GetAllowance(EnumPeriodicity periodicity, EnumEntitleType enumEntitleType,
EnumAllowOrDeduct allowOrdeduct)
{
List<AllowanceDeduction> allowanceDeductions = new List<AllowanceDeduction>();
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin();
DataReader dr =
new DataReader(AllowanceDeductionDA.GetAllowance(tc, periodicity, enumEntitleType, allowOrdeduct));
allowanceDeductions = this.CreateObjects<AllowanceDeduction>(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<AllowanceDeduction> GetDeduction(EnumStatus status, int payrolltypeid)
{
List<AllowanceDeduction> allowanceDeductions = new List<AllowanceDeduction>();
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin();
DataReader dr = new DataReader(AllowanceDeductionDA.GetDeduction(tc, status, payrolltypeid));
allowanceDeductions = this.CreateObjects<AllowanceDeduction>(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<AllowanceDeduction> GetMonthyIndividualAndOneOff(int payrolltypeid, EnumStatus status, EnumAllowOrDeduct nType)
{
List<AllowanceDeduction> allowanceDeductions = new List<AllowanceDeduction>();
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin();
DataReader dr = new DataReader(AllowanceDeductionDA.GetMonthyIndividualAndOneOff(tc, payrolltypeid, status, nType));
allowanceDeductions = this.CreateObjects<AllowanceDeduction>(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<AllowanceDeduction> Get(int payrolltypeid, EnumStatus status, EnumAllowOrDeduct nType, EnumPeriodicity nPeriodcity)
{
List<AllowanceDeduction> allowanceDeductions = new List<AllowanceDeduction>();
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin();
DataReader dr = new DataReader(AllowanceDeductionDA.Get(tc, payrolltypeid, status, nType, nPeriodcity));
allowanceDeductions = this.CreateObjects<AllowanceDeduction>(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<AllowanceDeduction> Get(EnumStatus status, EnumAllowOrDeduct nType, int payrollTypeID)
{
List<AllowanceDeduction> allowanceDeductions = new List<AllowanceDeduction>();
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin();
DataReader dr = new DataReader(AllowanceDeductionDA.Get(tc, status, nType, payrollTypeID));
allowanceDeductions = this.CreateObjects<AllowanceDeduction>(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<AllowanceDeduction> Get(EnumStatus status, int payrollTypeID)
{
List<AllowanceDeduction> allowanceDeductions = new List<AllowanceDeduction>();
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin();
DataReader dr = new DataReader(AllowanceDeductionDA.Get(tc, status, payrollTypeID));
allowanceDeductions = this.CreateObjects<AllowanceDeduction>(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<AllowanceDeduction> GetException(EnumStatus status, EnumAllowOrDeduct nType, int payrollTypeID)
{
List<AllowanceDeduction> allowanceDeductions = new List<AllowanceDeduction>();
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin();
DataReader dr = new DataReader(AllowanceDeductionDA.GetException(tc, status, nType, payrollTypeID));
allowanceDeductions = this.CreateObjects<AllowanceDeduction>(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
}
}