417 lines
15 KiB
C#
417 lines
15 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 TaxMergeMaster Service
|
|||
|
[Serializable]
|
|||
|
public class TaxMergeMasterService : ServiceTemplate, ITaxMergeMasterService
|
|||
|
{
|
|||
|
#region Private functions and declaration
|
|||
|
Cache _cache = new Cache(typeof(TaxMergeMaster));
|
|||
|
|
|||
|
#endregion
|
|||
|
public TaxMergeMasterService() { }
|
|||
|
|
|||
|
private void MapObject(TaxMergeMaster oTaxMergeMaster, DataReader oReader)
|
|||
|
{
|
|||
|
base.SetObjectID(oTaxMergeMaster, oReader.GetID("TaxMergeID"));
|
|||
|
oTaxMergeMaster.TaxParameterID = oReader.GetID("TAXPARAMID");
|
|||
|
oTaxMergeMaster.ItemID = oReader.GetInt32("ItemID").Value;
|
|||
|
oTaxMergeMaster.ItemGroup =(EnumIncomeTaxItemGroup)oReader.GetInt32("ItemGroup").Value;
|
|||
|
oTaxMergeMaster.Description = oReader.GetString("DESCRIPTION");
|
|||
|
oTaxMergeMaster.Position = oReader.GetInt32("position").Value;
|
|||
|
oTaxMergeMaster.Type = (EnumTaxMergeType)oReader.GetInt32("Type").Value;
|
|||
|
oTaxMergeMaster.CreatedBy = oReader.GetID("CreatedBy");
|
|||
|
oTaxMergeMaster.CreatedDate = oReader.GetDateTime("CreationDate").Value;
|
|||
|
oTaxMergeMaster.ModifiedBy = oReader.GetID("ModifiedBy");
|
|||
|
oTaxMergeMaster.ModifiedDate = oReader.GetDateTime("ModifiedDate");
|
|||
|
this.SetObjectState(oTaxMergeMaster, Ease.CoreV35.ObjectState.Saved);
|
|||
|
}
|
|||
|
protected override T CreateObject<T>(DataReader oReader)
|
|||
|
{
|
|||
|
TaxMergeMaster oTaxMergeMaster = new TaxMergeMaster();
|
|||
|
MapObject(oTaxMergeMaster, oReader);
|
|||
|
return oTaxMergeMaster as T;
|
|||
|
}
|
|||
|
protected TaxMergeMaster CreateObject(DataReader oReader)
|
|||
|
{
|
|||
|
TaxMergeMaster oTaxMergeMaster = new TaxMergeMaster();
|
|||
|
MapObject(oTaxMergeMaster, oReader);
|
|||
|
return oTaxMergeMaster;
|
|||
|
}
|
|||
|
|
|||
|
private void MapTaxMDetailObject(TaxMergeMaster.TaxMergeDetail oTaxMergeDetail, DataReader oReader)
|
|||
|
{
|
|||
|
base.SetObjectID(oTaxMergeDetail, oReader.GetID("detailId"));
|
|||
|
oTaxMergeDetail.TaxMergeID = oReader.GetID("TaxMergeID");
|
|||
|
oTaxMergeDetail.TaxParameterID = oReader.GetID("TaxParameterID");
|
|||
|
oTaxMergeDetail.ItemGroup = (EnumIncomeTaxItemGroup)oReader.GetInt32("ItemGroup").Value;
|
|||
|
oTaxMergeDetail.ItemID = oReader.GetInt32("ItemID").Value;
|
|||
|
oTaxMergeDetail.Type = (EnumTaxMergeType)oReader.GetInt32("Type").Value;
|
|||
|
oTaxMergeDetail.Description = oReader.GetString("Description");
|
|||
|
this.SetObjectState(oTaxMergeDetail, Ease.CoreV35.ObjectState.Saved);
|
|||
|
}
|
|||
|
protected ObjectsTemplate<TaxMergeMaster.TaxMergeDetail> CreateTaxMDetailObject(DataReader oReader)
|
|||
|
{
|
|||
|
ObjectsTemplate<TaxMergeMaster.TaxMergeDetail> oTaxMergeDetails = new ObjectsTemplate<TaxMergeMaster.TaxMergeDetail>();
|
|||
|
while (oReader.Read())
|
|||
|
{
|
|||
|
TaxMergeMaster.TaxMergeDetail oTaxMergeDetail = new TaxMergeMaster.TaxMergeDetail();
|
|||
|
MapTaxMDetailObject(oTaxMergeDetail, oReader);
|
|||
|
oTaxMergeDetails.Add(oTaxMergeDetail);
|
|||
|
}
|
|||
|
return oTaxMergeDetails;
|
|||
|
}
|
|||
|
public void Save(List<TaxMergeMaster> oTaxMergeMasters, TransactionContext tc)
|
|||
|
{
|
|||
|
try
|
|||
|
{
|
|||
|
|
|||
|
foreach (TaxMergeMaster oTaxMergeMaster in oTaxMergeMasters)
|
|||
|
{
|
|||
|
int id = tc.GenerateID("TaxMergeMaster", "TaxMergeID");
|
|||
|
int position = tc.GenerateID("TaxMergeMaster", "Position");
|
|||
|
oTaxMergeMaster.Position = position;
|
|||
|
base.SetObjectID(oTaxMergeMaster, ID.FromInteger(id));
|
|||
|
TaxMergeMasterDA.Insert(tc, oTaxMergeMaster);
|
|||
|
foreach (TaxMergeMaster.TaxMergeDetail oTaxMergeDetail in oTaxMergeMaster.TaxMergeDetails)
|
|||
|
{
|
|||
|
int detailid = tc.GenerateID("TaxMergeDetail", "DetailId");
|
|||
|
base.SetObjectID(oTaxMergeDetail, ID.FromInteger(detailid));
|
|||
|
oTaxMergeDetail.TaxMergeID = oTaxMergeMaster.ID;
|
|||
|
oTaxMergeDetail.TaxParameterID = oTaxMergeMaster.TaxParameterID;
|
|||
|
TaxMergeMasterDA.Insert(tc, oTaxMergeDetail);
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
}
|
|||
|
catch (Exception e)
|
|||
|
{
|
|||
|
#region Handle Exception
|
|||
|
if (tc != null)
|
|||
|
tc.HandleError();
|
|||
|
ExceptionLog.Write(e);
|
|||
|
throw new ServiceException(e.Message, e);
|
|||
|
#endregion
|
|||
|
}
|
|||
|
}
|
|||
|
public ObjectsTemplate<TaxMergeMaster> GetPrevByTaxParamID(TransactionContext tc, int payrollTypeID)
|
|||
|
{
|
|||
|
ObjectsTemplate<TaxMergeMaster> taxMergeMasters = null;
|
|||
|
|
|||
|
try
|
|||
|
{
|
|||
|
|
|||
|
DataReader dr = new DataReader(TaxMergeMasterDA.GetPrevByTaxParamID(tc, payrollTypeID));
|
|||
|
taxMergeMasters = this.CreateObjects<TaxMergeMaster>(dr);
|
|||
|
dr.Close();
|
|||
|
|
|||
|
if (taxMergeMasters != null)
|
|||
|
{
|
|||
|
foreach (TaxMergeMaster item in taxMergeMasters)
|
|||
|
{
|
|||
|
dr = new DataReader(TaxMergeMasterDA.GetDetail(tc, item.ID, payrollTypeID));
|
|||
|
item.TaxMergeDetails = this.CreateTaxMDetailObject(dr);
|
|||
|
dr.Close();
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
}
|
|||
|
catch (Exception e)
|
|||
|
{
|
|||
|
#region Handle Exception
|
|||
|
|
|||
|
if (tc != null)
|
|||
|
tc.HandleError();
|
|||
|
ExceptionLog.Write(e);
|
|||
|
|
|||
|
throw new ServiceException(e.Message, e);
|
|||
|
|
|||
|
#endregion
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
return taxMergeMasters;
|
|||
|
}
|
|||
|
|
|||
|
#region Service implementation
|
|||
|
public TaxMergeMaster Get(ID id)
|
|||
|
{
|
|||
|
TaxMergeMaster oTaxMergeMaster = null ;
|
|||
|
#region Cache Header
|
|||
|
oTaxMergeMaster = _cache["Get", id] as TaxMergeMaster;
|
|||
|
if (oTaxMergeMaster != null)
|
|||
|
return oTaxMergeMaster;
|
|||
|
#endregion
|
|||
|
TransactionContext tc = null;
|
|||
|
try
|
|||
|
{
|
|||
|
tc = TransactionContext.Begin();
|
|||
|
DataReader oreader = new DataReader(TaxMergeMasterDA.Get(tc, id));
|
|||
|
if (oreader.Read())
|
|||
|
{
|
|||
|
oTaxMergeMaster = this.CreateObject<TaxMergeMaster>(oreader);
|
|||
|
}
|
|||
|
oreader.Close();
|
|||
|
|
|||
|
if (oTaxMergeMaster != null)
|
|||
|
{
|
|||
|
DataReader dr = new DataReader(TaxMergeMasterDA.GetDetail(tc, oTaxMergeMaster.ID));
|
|||
|
oTaxMergeMaster.TaxMergeDetails = this.CreateTaxMDetailObject(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(oTaxMergeMaster, "Get", id);
|
|||
|
#endregion
|
|||
|
return oTaxMergeMaster;
|
|||
|
}
|
|||
|
|
|||
|
public ObjectsTemplate<TaxMergeMaster> GetbyTaxParameter(ID TaxParameterID)
|
|||
|
{
|
|||
|
ObjectsTemplate<TaxMergeMaster> taxMergeMasters = null;
|
|||
|
|
|||
|
TransactionContext tc = null;
|
|||
|
try
|
|||
|
{
|
|||
|
tc = TransactionContext.Begin();
|
|||
|
|
|||
|
DataReader dr = new DataReader(TaxMergeMasterDA.GetbyTaxParameter(tc, TaxParameterID.Integer));
|
|||
|
taxMergeMasters = this.CreateObjects<TaxMergeMaster>(dr);
|
|||
|
dr.Close();
|
|||
|
|
|||
|
if (taxMergeMasters != null)
|
|||
|
{
|
|||
|
foreach (TaxMergeMaster item in taxMergeMasters)
|
|||
|
{
|
|||
|
dr = new DataReader(TaxMergeMasterDA.GetDetail(tc, item.ID));
|
|||
|
item.TaxMergeDetails = this.CreateTaxMDetailObject(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 taxMergeMasters;
|
|||
|
}
|
|||
|
|
|||
|
public ObjectsTemplate<TaxMergeMaster> Get()
|
|||
|
{
|
|||
|
ObjectsTemplate<TaxMergeMaster> taxMergeMasters = null;
|
|||
|
|
|||
|
TransactionContext tc = null;
|
|||
|
try
|
|||
|
{
|
|||
|
tc = TransactionContext.Begin();
|
|||
|
|
|||
|
DataReader dr = new DataReader(TaxMergeMasterDA.Get(tc));
|
|||
|
taxMergeMasters = this.CreateObjects<TaxMergeMaster>(dr);
|
|||
|
dr.Close();
|
|||
|
|
|||
|
if (taxMergeMasters != null)
|
|||
|
{
|
|||
|
foreach (TaxMergeMaster item in taxMergeMasters)
|
|||
|
{
|
|||
|
dr = new DataReader(TaxMergeMasterDA.GetDetail(tc, item.ID));
|
|||
|
item.TaxMergeDetails = this.CreateTaxMDetailObject(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 taxMergeMasters;
|
|||
|
}
|
|||
|
|
|||
|
public ObjectsTemplate<TaxMergeMaster> GetByTaxParamID(TransactionContext tc, int id)
|
|||
|
{
|
|||
|
ObjectsTemplate<TaxMergeMaster> taxMergeMasters = null;
|
|||
|
|
|||
|
try
|
|||
|
{
|
|||
|
|
|||
|
DataReader dr = new DataReader(TaxMergeMasterDA.GetByTaxParamID(tc,id));
|
|||
|
taxMergeMasters = this.CreateObjects<TaxMergeMaster>(dr);
|
|||
|
dr.Close();
|
|||
|
|
|||
|
if (taxMergeMasters != null)
|
|||
|
{
|
|||
|
foreach (TaxMergeMaster item in taxMergeMasters)
|
|||
|
{
|
|||
|
dr = new DataReader(TaxMergeMasterDA.GetDetail(tc, item.ID));
|
|||
|
item.TaxMergeDetails = this.CreateTaxMDetailObject(dr);
|
|||
|
dr.Close();
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
}
|
|||
|
catch (Exception e)
|
|||
|
{
|
|||
|
#region Handle Exception
|
|||
|
|
|||
|
if (tc != null)
|
|||
|
tc.HandleError();
|
|||
|
ExceptionLog.Write(e);
|
|||
|
|
|||
|
throw new ServiceException(e.Message, e);
|
|||
|
|
|||
|
#endregion
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
return taxMergeMasters;
|
|||
|
}
|
|||
|
|
|||
|
//public ObjectsTemplate<TaxMergeMaster.TaxMergeDetail> GetTMDetailByParamID(ID nID)
|
|||
|
//{
|
|||
|
// #region Cache Header
|
|||
|
|
|||
|
// ObjectsTemplate<TaxMergeMaster.TaxMergeDetail> taxMergeDetails = _cache["GetTMDetailByParamID", nID] as ObjectsTemplate<TaxMergeDetail>;
|
|||
|
// if (taxMergeDetails != null)
|
|||
|
// return taxMergeDetails;
|
|||
|
|
|||
|
// #endregion
|
|||
|
|
|||
|
// TransactionContext tc = null;
|
|||
|
// try
|
|||
|
// {
|
|||
|
// tc = TransactionContext.Begin();
|
|||
|
|
|||
|
// DataReader dr = new DataReader(TaxParameterDA.GetSlabsByParamID(tc, nID));
|
|||
|
// taxMergeDetails = this.CreateTaxMDetailObject(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(taxMergeDetails, "GetTMDetailByParamID", nID);
|
|||
|
|
|||
|
// #endregion
|
|||
|
|
|||
|
// return taxMergeDetails;
|
|||
|
|
|||
|
//}
|
|||
|
|
|||
|
public ID Save(TaxMergeMaster oTaxMergeMaster)
|
|||
|
{
|
|||
|
TransactionContext tc = null;
|
|||
|
try
|
|||
|
{
|
|||
|
tc = TransactionContext.Begin(true);
|
|||
|
if (oTaxMergeMaster.IsNew)
|
|||
|
{
|
|||
|
int id = tc.GenerateID("TaxMergeMaster", "TaxMergeID");
|
|||
|
int position = tc.GenerateID("TaxMergeMaster", "Position");
|
|||
|
oTaxMergeMaster.Position = position;
|
|||
|
base.SetObjectID(oTaxMergeMaster, ID.FromInteger(id));
|
|||
|
TaxMergeMasterDA.Insert(tc, oTaxMergeMaster);
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
TaxMergeMasterDA.Update(tc, oTaxMergeMaster);
|
|||
|
TaxMergeMasterDA.DeleteMDetailByMergeID(tc, oTaxMergeMaster.ID);
|
|||
|
}
|
|||
|
foreach(TaxMergeMaster.TaxMergeDetail oTaxMergeDetail in oTaxMergeMaster.TaxMergeDetails)
|
|||
|
{
|
|||
|
int detailid = tc.GenerateID("TaxMergeDetail", "DetailId");
|
|||
|
base.SetObjectID(oTaxMergeDetail, ID.FromInteger(detailid));
|
|||
|
oTaxMergeDetail.TaxMergeID = oTaxMergeMaster.ID;
|
|||
|
oTaxMergeDetail.TaxParameterID = oTaxMergeMaster.TaxParameterID;
|
|||
|
TaxMergeMasterDA.Insert(tc,oTaxMergeDetail);
|
|||
|
}
|
|||
|
tc.End();
|
|||
|
return oTaxMergeMaster.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(ID id)
|
|||
|
{
|
|||
|
TransactionContext tc = null;
|
|||
|
try
|
|||
|
{
|
|||
|
tc = TransactionContext.Begin(true);
|
|||
|
TaxMergeMasterDA.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
|
|||
|
}
|
|||
|
#endregion
|
|||
|
}
|