552 lines
17 KiB
C#
552 lines
17 KiB
C#
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;
|
|
|
|
namespace Payroll.Service
|
|
{
|
|
#region AllowanceDeduction Service
|
|
[Serializable]
|
|
public class AllowanceDeductionService : ServiceTemplate, IAllowanceDeductionService
|
|
{
|
|
#region Private functions and declaration
|
|
Cache _cache = new Cache(typeof(AllowanceDeduction));
|
|
|
|
#endregion
|
|
public AllowanceDeductionService() { }
|
|
|
|
private void MapObject(AllowanceDeduction oAllowanceDeduction, DataReader oReader)
|
|
{
|
|
base.SetObjectID(oAllowanceDeduction, oReader.GetID("ALLOWDEDUCTID"));
|
|
oAllowanceDeduction.Code = oReader.GetString("code");
|
|
oAllowanceDeduction.Name = oReader.GetString("name");
|
|
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.GetID("CreatedBy");
|
|
oAllowanceDeduction.CreatedDate = oReader.GetDateTime("CreationDate").Value;
|
|
oAllowanceDeduction.ModifiedBy = oReader.GetID("ModifiedBy");
|
|
oAllowanceDeduction.ModifiedDate = oReader.GetDateTime("ModifiedDate");
|
|
this.SetObjectState(oAllowanceDeduction, Ease.CoreV35.ObjectState.Saved);
|
|
}
|
|
protected override T CreateObject<T>(DataReader oReader)
|
|
{
|
|
AllowanceDeduction oAllowanceDeduction = new AllowanceDeduction();
|
|
MapObject(oAllowanceDeduction, oReader);
|
|
return oAllowanceDeduction as T;
|
|
}
|
|
protected AllowanceDeduction CreateObject(DataReader oReader)
|
|
{
|
|
AllowanceDeduction oAllowanceDeduction = new AllowanceDeduction();
|
|
MapObject(oAllowanceDeduction, oReader);
|
|
return oAllowanceDeduction;
|
|
}
|
|
#region Service implementation
|
|
public AllowanceDeduction Get(ID id)
|
|
{
|
|
AllowanceDeduction oAllowanceDeduction = new AllowanceDeduction();
|
|
#region Cache Header
|
|
oAllowanceDeduction = _cache["Get", id] as AllowanceDeduction;
|
|
if (oAllowanceDeduction != null)
|
|
return oAllowanceDeduction;
|
|
#endregion
|
|
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
|
|
}
|
|
#region Cache Footer
|
|
_cache.Add(oAllowanceDeduction, "Get", id);
|
|
#endregion
|
|
return oAllowanceDeduction;
|
|
}
|
|
|
|
public ObjectsTemplate<AllowanceDeduction> GetByGradeID(EnumStatus status, ID gradeID, EnumAllowOrDeduct type)
|
|
{
|
|
#region Cache Header
|
|
|
|
ObjectsTemplate<AllowanceDeduction> allowDeduct = _cache["GetByGradeID", status, gradeID, type] as ObjectsTemplate<AllowanceDeduction>;
|
|
if (allowDeduct != null)
|
|
return allowDeduct;
|
|
|
|
#endregion
|
|
|
|
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
|
|
}
|
|
|
|
#region Cache Footer
|
|
|
|
_cache.Add(allowDeduct, "GetByGradeID", status);
|
|
|
|
#endregion
|
|
|
|
return allowDeduct;
|
|
}
|
|
|
|
|
|
public ObjectsTemplate<AllowanceDeduction> Get(EnumStatus status)
|
|
{
|
|
#region Cache Header
|
|
|
|
ObjectsTemplate<AllowanceDeduction> allowanceDeductions = _cache["Get"] as ObjectsTemplate<AllowanceDeduction>;
|
|
if (allowanceDeductions != null)
|
|
return allowanceDeductions;
|
|
|
|
#endregion
|
|
|
|
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
|
|
}
|
|
|
|
#region Cache Footer
|
|
|
|
_cache.Add(allowanceDeductions, "Get",status);
|
|
|
|
#endregion
|
|
|
|
return allowanceDeductions;
|
|
}
|
|
|
|
|
|
public ObjectsTemplate<AllowanceDeduction> GetAllowance(EnumStatus status)
|
|
{
|
|
#region Cache Header
|
|
|
|
ObjectsTemplate<AllowanceDeduction> allowanceDeductions = _cache["GetAllowance"] as ObjectsTemplate<AllowanceDeduction>;
|
|
if (allowanceDeductions != null)
|
|
return allowanceDeductions;
|
|
|
|
#endregion
|
|
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin();
|
|
|
|
DataReader dr = new DataReader(AllowanceDeductionDA.GetAllowance(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
|
|
}
|
|
|
|
#region Cache Footer
|
|
|
|
_cache.Add(allowanceDeductions, "GetAllowance", status);
|
|
|
|
#endregion
|
|
|
|
return allowanceDeductions;
|
|
}
|
|
|
|
public ObjectsTemplate<AllowanceDeduction> GetAllowance(EnumPeriodicity periodicity,EnumAllowOrDeduct allowOrdeduct)
|
|
{
|
|
#region Cache Header
|
|
|
|
ObjectsTemplate<AllowanceDeduction> allowanceDeductions = _cache["GetAllowance"] as ObjectsTemplate<AllowanceDeduction>;
|
|
if (allowanceDeductions != null)
|
|
return allowanceDeductions;
|
|
|
|
#endregion
|
|
|
|
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
|
|
|
|
}
|
|
#region Cache Footer
|
|
|
|
_cache.Add(allowanceDeductions, "GetAllowance", periodicity,allowOrdeduct);
|
|
|
|
#endregion
|
|
|
|
return allowanceDeductions;
|
|
}
|
|
|
|
public ObjectsTemplate<AllowanceDeduction> GetAllowance(EnumPeriodicity periodicity, EnumEntitleType enumEntitleType, EnumAllowOrDeduct allowOrdeduct)
|
|
{
|
|
#region Cache Header
|
|
|
|
ObjectsTemplate<AllowanceDeduction> allowanceDeductions = _cache["GetAllowance"] as ObjectsTemplate<AllowanceDeduction>;
|
|
if (allowanceDeductions != null)
|
|
return allowanceDeductions;
|
|
|
|
#endregion
|
|
|
|
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
|
|
|
|
}
|
|
#region Cache Footer
|
|
|
|
_cache.Add(allowanceDeductions, "GetAllowance", periodicity, allowOrdeduct);
|
|
|
|
#endregion
|
|
|
|
return allowanceDeductions;
|
|
}
|
|
|
|
public ObjectsTemplate<AllowanceDeduction> GetDeduction(EnumStatus status)
|
|
{
|
|
#region Cache Header
|
|
|
|
ObjectsTemplate<AllowanceDeduction> allowanceDeductions = _cache["GetDeduction"] as ObjectsTemplate<AllowanceDeduction>;
|
|
if (allowanceDeductions != null)
|
|
return allowanceDeductions;
|
|
|
|
#endregion
|
|
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin();
|
|
|
|
DataReader dr = new DataReader(AllowanceDeductionDA.GetDeduction(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
|
|
}
|
|
|
|
#region Cache Footer
|
|
|
|
_cache.Add(allowanceDeductions, "GetDeduction",status);
|
|
|
|
#endregion
|
|
|
|
return allowanceDeductions;
|
|
}
|
|
|
|
public ObjectsTemplate<AllowanceDeduction> Get(EnumStatus status, EnumAllowOrDeduct nType, EnumPeriodicity nPeriodcity)
|
|
{
|
|
#region Cache Header
|
|
|
|
ObjectsTemplate<AllowanceDeduction> allowanceDeductions = _cache["Get", status, nType, nPeriodcity] as ObjectsTemplate<AllowanceDeduction>;
|
|
if (allowanceDeductions != null)
|
|
return allowanceDeductions;
|
|
|
|
#endregion
|
|
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin();
|
|
|
|
DataReader dr = new DataReader(AllowanceDeductionDA.Get(tc, 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
|
|
}
|
|
|
|
#region Cache Footer
|
|
|
|
_cache.Add(allowanceDeductions, "Get", status, nType, nPeriodcity);
|
|
|
|
#endregion
|
|
|
|
return allowanceDeductions;
|
|
}
|
|
|
|
public ObjectsTemplate<AllowanceDeduction> Get(EnumStatus status, EnumAllowOrDeduct nType)
|
|
{
|
|
#region Cache Header
|
|
|
|
ObjectsTemplate<AllowanceDeduction> allowanceDeductions = _cache["Get", status, nType] as ObjectsTemplate<AllowanceDeduction>;
|
|
if (allowanceDeductions != null)
|
|
return allowanceDeductions;
|
|
|
|
#endregion
|
|
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin();
|
|
|
|
DataReader dr = new DataReader(AllowanceDeductionDA.Get(tc, 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
|
|
}
|
|
|
|
#region Cache Footer
|
|
|
|
_cache.Add(allowanceDeductions, "Get", status, nType);
|
|
|
|
#endregion
|
|
|
|
return allowanceDeductions;
|
|
}
|
|
|
|
public ID Save(AllowanceDeduction oAllowanceDeduction)
|
|
{
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin(true);
|
|
if (oAllowanceDeduction.IsNew)
|
|
{
|
|
int id = tc.GenerateID("AllowanceDeduction", "ALLOWDEDUCTID");
|
|
|
|
base.SetObjectID(oAllowanceDeduction, ID.FromInteger(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 string GetNextCode()
|
|
{
|
|
TransactionContext tc = null;
|
|
string _code = "";
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin();
|
|
_code = GlobalFunctionService.GetMaxCode(tc, "allowance", "codeautogenerate", "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 void Delete(ID 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 DataSet GetEmpAllowDeduc(DateTime dEffectDate, ID AllowDeducID, ID 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, ID AllowDeducID, ID 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
|
|
}
|
|
#endregion
|
|
}
|