225 lines
6.9 KiB
C#
225 lines
6.9 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 TaxAdjustment Service
|
|||
|
[Serializable]
|
|||
|
public class TaxAdjustmentService : ServiceTemplate, ITaxAdjustmentService
|
|||
|
{
|
|||
|
#region Private functions and declaration
|
|||
|
Cache _cache = new Cache(typeof(TaxAdjustment));
|
|||
|
|
|||
|
#endregion
|
|||
|
public TaxAdjustmentService() { }
|
|||
|
|
|||
|
private void MapObject(TaxAdjustment oTaxAdjustment, DataReader oReader)
|
|||
|
{
|
|||
|
base.SetObjectID(oTaxAdjustment, oReader.GetID("TaxAdjustmentID"));
|
|||
|
oTaxAdjustment.Name = oReader.GetString("name");
|
|||
|
oTaxAdjustment.TaxType = (EnumIncomeTaxSide)oReader.GetInt32("TaxType").Value;
|
|||
|
oTaxAdjustment.Sequence = oReader.GetInt32("SequenceNO").Value;
|
|||
|
oTaxAdjustment.Status = (EnumStatus)oReader.GetInt32("Status").Value;
|
|||
|
oTaxAdjustment.CreatedBy = oReader.GetID("CreatedBy");
|
|||
|
oTaxAdjustment.CreatedDate = oReader.GetDateTime("CreationDate").Value;
|
|||
|
//oTaxAdjustment.ModifiedDate = DataReader.GetNullValue(oReader.GetDateTime("ModifiedDate").Value);
|
|||
|
this.SetObjectState(oTaxAdjustment, Ease.CoreV35.ObjectState.Saved);
|
|||
|
}
|
|||
|
protected override T CreateObject<T>(DataReader oReader)
|
|||
|
{
|
|||
|
TaxAdjustment oTaxAdjustment = new TaxAdjustment();
|
|||
|
MapObject(oTaxAdjustment, oReader);
|
|||
|
return oTaxAdjustment as T;
|
|||
|
}
|
|||
|
protected TaxAdjustment CreateObject(DataReader oReader)
|
|||
|
{
|
|||
|
TaxAdjustment oTaxAdjustment = new TaxAdjustment();
|
|||
|
MapObject(oTaxAdjustment, oReader);
|
|||
|
return oTaxAdjustment;
|
|||
|
}
|
|||
|
#region Service implementation
|
|||
|
public TaxAdjustment Get(ID id)
|
|||
|
{
|
|||
|
TaxAdjustment oTaxAdjustment = new TaxAdjustment();
|
|||
|
#region Cache Header
|
|||
|
oTaxAdjustment = _cache["Get", id] as TaxAdjustment;
|
|||
|
if (oTaxAdjustment != null)
|
|||
|
return oTaxAdjustment;
|
|||
|
#endregion
|
|||
|
TransactionContext tc = null;
|
|||
|
try
|
|||
|
{
|
|||
|
tc = TransactionContext.Begin();
|
|||
|
DataReader oreader = new DataReader(TaxAdjustmentDA.Get(tc, id));
|
|||
|
if (oreader.Read())
|
|||
|
{
|
|||
|
oTaxAdjustment = this.CreateObject<TaxAdjustment>(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(oTaxAdjustment, "Get", id);
|
|||
|
#endregion
|
|||
|
return oTaxAdjustment;
|
|||
|
}
|
|||
|
|
|||
|
public ObjectsTemplate<TaxAdjustment> Get()
|
|||
|
{
|
|||
|
#region Cache Header
|
|||
|
|
|||
|
ObjectsTemplate<TaxAdjustment> taxAdjustments = _cache["Get"] as ObjectsTemplate<TaxAdjustment>;
|
|||
|
if (taxAdjustments != null)
|
|||
|
return taxAdjustments;
|
|||
|
|
|||
|
#endregion
|
|||
|
|
|||
|
TransactionContext tc = null;
|
|||
|
try
|
|||
|
{
|
|||
|
tc = TransactionContext.Begin();
|
|||
|
|
|||
|
DataReader dr = new DataReader(TaxAdjustmentDA.Get(tc));
|
|||
|
taxAdjustments = this.CreateObjects<TaxAdjustment>(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(taxAdjustments, "Get");
|
|||
|
|
|||
|
#endregion
|
|||
|
|
|||
|
return taxAdjustments;
|
|||
|
}
|
|||
|
|
|||
|
public ObjectsTemplate<TaxAdjustment> Get(EnumStatus status)
|
|||
|
{
|
|||
|
#region Cache Header
|
|||
|
|
|||
|
ObjectsTemplate<TaxAdjustment> TaxAdjustments = _cache["Get"] as ObjectsTemplate<TaxAdjustment>;
|
|||
|
if (TaxAdjustments != null)
|
|||
|
return TaxAdjustments;
|
|||
|
|
|||
|
#endregion
|
|||
|
|
|||
|
TransactionContext tc = null;
|
|||
|
try
|
|||
|
{
|
|||
|
tc = TransactionContext.Begin();
|
|||
|
|
|||
|
DataReader dr = new DataReader(TaxAdjustmentDA.Get(tc, status));
|
|||
|
TaxAdjustments = this.CreateObjects<TaxAdjustment>(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(TaxAdjustments, "Get", status);
|
|||
|
|
|||
|
#endregion
|
|||
|
|
|||
|
return TaxAdjustments;
|
|||
|
}
|
|||
|
|
|||
|
public ID Save(TaxAdjustment oTaxAdjustment)
|
|||
|
{
|
|||
|
TransactionContext tc = null;
|
|||
|
try
|
|||
|
{
|
|||
|
tc = TransactionContext.Begin(true);
|
|||
|
if (oTaxAdjustment.IsNew)
|
|||
|
{
|
|||
|
|
|||
|
int id = tc.GenerateID("TaxAdjustment", "TaxAdjustmentID");
|
|||
|
base.SetObjectID(oTaxAdjustment, ID.FromInteger(id));
|
|||
|
int seqNo = tc.GenerateID("TaxAdjustment", "SequenceNo");
|
|||
|
oTaxAdjustment.Sequence = seqNo;
|
|||
|
TaxAdjustmentDA.Insert(tc, oTaxAdjustment);
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
TaxAdjustmentDA.Update(tc, oTaxAdjustment);
|
|||
|
}
|
|||
|
tc.End();
|
|||
|
return oTaxAdjustment.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);
|
|||
|
TaxAdjustmentDA.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
|
|||
|
}
|