172 lines
5.3 KiB
C#
172 lines
5.3 KiB
C#
using HRM.BO;
|
|
using Ease.Core.DataAccess;
|
|
using Ease.Core.Model;
|
|
using Ease.Core.Utility;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
|
|
namespace HRM.DA
|
|
{
|
|
#region PFinterestProvision Service
|
|
|
|
public class PFinterestProvisionService : ServiceTemplate
|
|
{
|
|
#region Private functions and declaration
|
|
|
|
#endregion
|
|
|
|
public PFinterestProvisionService()
|
|
{
|
|
}
|
|
|
|
private void MapObject(PFinterestProvision oPFinterestProvision, DataReader oReader)
|
|
{
|
|
//base.SetObjectID(oPFinterestProvision, oReader.GetID("PFinterestProvisionID"));
|
|
oPFinterestProvision.EmployeeID = oReader.GetInt32("EmployeeID").Value;
|
|
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.GetString("CreatedBy") == null ? 0 : oReader.GetInt32("CreatedBy").Value;
|
|
oPFinterestProvision.CreatedDate = oReader.GetDateTime("CreationDate").Value;
|
|
this.SetObjectState(oPFinterestProvision, Ease.Core.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(int id)
|
|
{
|
|
PFinterestProvision oPFinterestProvision = new PFinterestProvision();
|
|
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
|
|
}
|
|
|
|
return oPFinterestProvision;
|
|
}
|
|
|
|
public List<PFinterestProvision> Get()
|
|
{
|
|
List<PFinterestProvision> pFinterestProvisions = new List<PFinterestProvision>();
|
|
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
|
|
}
|
|
|
|
return pFinterestProvisions;
|
|
}
|
|
|
|
public int Save(PFinterestProvision oPFinterestProvision)
|
|
{
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin(true);
|
|
if (oPFinterestProvision.IsNew)
|
|
{
|
|
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(int 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
|
|
} |