181 lines
6.2 KiB
C#
181 lines
6.2 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 PFinterestProvision Service
|
|
[Serializable]
|
|
public class PFinterestProvisionService : ServiceTemplate, IPFinterestProvisionService
|
|
{
|
|
#region Private functions and declaration
|
|
Cache _cache = new Cache(typeof(PFinterestProvision));
|
|
|
|
#endregion
|
|
public PFinterestProvisionService() { }
|
|
|
|
private void MapObject(PFinterestProvision oPFinterestProvision, DataReader oReader)
|
|
{
|
|
//base.SetObjectID(oPFinterestProvision, oReader.GetID("PFinterestProvisionID"));
|
|
oPFinterestProvision.EmployeeID = oReader.GetID("employeeID");
|
|
oPFinterestProvision.ProcessedMonthDate = oReader.GetDateTime("processedMonthDate").Value;
|
|
oPFinterestProvision.PFamount = oReader.GetDouble("pFamount").Value;
|
|
oPFinterestProvision.CPFAmount = oReader.GetDouble("cPFAmount").Value;
|
|
oPFinterestProvision.PFIntProvision = oReader.GetDouble("pFIntProvision").Value;
|
|
oPFinterestProvision.CPFIntProvision = oReader.GetDouble("cPFIntProvision").Value;
|
|
oPFinterestProvision.Pending = oReader.GetBoolean("pending").Value;
|
|
oPFinterestProvision.CreatedBy = oReader.GetID("CreatedBy");
|
|
oPFinterestProvision.CreatedDate = oReader.GetDateTime("CreationDate").Value;
|
|
this.SetObjectState(oPFinterestProvision, Ease.CoreV35.ObjectState.Saved);
|
|
}
|
|
protected override T CreateObject<T>(DataReader oReader)
|
|
{
|
|
PFinterestProvision oPFinterestProvision = new PFinterestProvision();
|
|
MapObject(oPFinterestProvision, oReader);
|
|
return oPFinterestProvision as T;
|
|
}
|
|
protected PFinterestProvision CreateObject(DataReader oReader)
|
|
{
|
|
PFinterestProvision oPFinterestProvision = new PFinterestProvision();
|
|
MapObject(oPFinterestProvision, oReader);
|
|
return oPFinterestProvision;
|
|
}
|
|
#region Service implementation
|
|
public PFinterestProvision Get(ID id)
|
|
{
|
|
PFinterestProvision oPFinterestProvision = new PFinterestProvision();
|
|
#region Cache Header
|
|
oPFinterestProvision = _cache["Get", id] as PFinterestProvision;
|
|
if (oPFinterestProvision != null)
|
|
return oPFinterestProvision;
|
|
#endregion
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin();
|
|
DataReader oreader = new DataReader(PFinterestProvisionDA.Get(tc, id));
|
|
if (oreader.Read())
|
|
{
|
|
oPFinterestProvision = this.CreateObject<PFinterestProvision>(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(oPFinterestProvision, "Get", id);
|
|
#endregion
|
|
return oPFinterestProvision;
|
|
}
|
|
|
|
public ObjectsTemplate<PFinterestProvision> Get()
|
|
{
|
|
#region Cache Header
|
|
|
|
ObjectsTemplate<PFinterestProvision> pFinterestProvisions = _cache["Get"] as ObjectsTemplate<PFinterestProvision>;
|
|
if (pFinterestProvisions != null)
|
|
return pFinterestProvisions;
|
|
|
|
#endregion
|
|
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin();
|
|
|
|
DataReader dr = new DataReader(PFinterestProvisionDA.Get(tc));
|
|
pFinterestProvisions = this.CreateObjects<PFinterestProvision>(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(pFinterestProvisions, "Get");
|
|
|
|
#endregion
|
|
|
|
return pFinterestProvisions;
|
|
}
|
|
|
|
public ID Save(PFinterestProvision oPFinterestProvision)
|
|
{
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin(true);
|
|
if (oPFinterestProvision.IsNew)
|
|
{
|
|
//int id = tc.GenerateID("PFINTPROVISION", "PFinterestProvisionID");
|
|
//base.SetObjectID(oPFinterestProvision, ID.FromInteger(id));
|
|
PFinterestProvisionDA.Insert(tc, oPFinterestProvision);
|
|
}
|
|
else
|
|
{
|
|
PFinterestProvisionDA.Update(tc, oPFinterestProvision);
|
|
}
|
|
tc.End();
|
|
return oPFinterestProvision.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);
|
|
PFinterestProvisionDA.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
|
|
}
|