192 lines
6.1 KiB
C#
192 lines
6.1 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using Ease.CoreV35;
|
|
using Ease.CoreV35.Model;
|
|
using Ease.CoreV35.DataAccess;
|
|
using Payroll.BO;
|
|
using Ease.CoreV35.Caching;
|
|
|
|
namespace Payroll.Service
|
|
{
|
|
#region LoanSettlement Service
|
|
[Serializable]
|
|
public class LoanSettlementService : ServiceTemplate, ILoanSettlementService
|
|
{
|
|
#region Private functions and declaration
|
|
Cache _cache = new Cache(typeof(LoanSettlement));
|
|
#endregion
|
|
|
|
public LoanSettlementService() { }
|
|
|
|
#region MapObject For LoanSettlement
|
|
private void MapObject(LoanSettlement oLoanSettlement, DataReader oReader)
|
|
{
|
|
base.SetObjectID(oLoanSettlement, oReader.GetID("LoanSettlementID"));
|
|
oLoanSettlement.LoanIssueID = oReader.GetID("LoanIssueID");
|
|
oLoanSettlement.WFStatus = (enumwfStatus)oReader.GetInt32("WFStatus").Value;
|
|
oLoanSettlement.BankID = oReader.GetID("BankID");
|
|
oLoanSettlement.BranchID = oReader.GetID("BranchID");
|
|
oLoanSettlement.ChequeNo = oReader.GetString("ChequeNo");
|
|
oLoanSettlement.AccountNo = oReader.GetString("AccountNo");
|
|
oLoanSettlement.SubmitDate = oReader.GetDateTime("SubmitDate").Value;
|
|
oLoanSettlement.Remarks = oReader.GetString("Remarks");
|
|
oLoanSettlement.CreatedBy = oReader.GetID("CreatedBy");
|
|
oLoanSettlement.CreatedDate = oReader.GetDateTime("CreationDate").Value;
|
|
oLoanSettlement.ModifiedBy = oReader.GetID("ModifiedBy");
|
|
oLoanSettlement.ModifiedDate = oReader.GetDateTime("ModifiedDate");
|
|
this.SetObjectState(oLoanSettlement, Ease.CoreV35.ObjectState.Saved);
|
|
}
|
|
protected override T CreateObject<T>(DataReader oReader)
|
|
{
|
|
LoanSettlement oLoanSettlement = new LoanSettlement();
|
|
MapObject(oLoanSettlement, oReader);
|
|
return oLoanSettlement as T;
|
|
}
|
|
protected LoanSettlement CreateObject(DataReader oReader)
|
|
{
|
|
LoanSettlement oLoanSettlement = new LoanSettlement();
|
|
MapObject(oLoanSettlement, oReader);
|
|
return oLoanSettlement;
|
|
}
|
|
#endregion
|
|
|
|
#region Service Implementation of Loan Settlement
|
|
public LoanSettlement Get(ID id)
|
|
{
|
|
LoanSettlement oLoanSettlement = new LoanSettlement();
|
|
#region Cache Header
|
|
oLoanSettlement = _cache["Get", id] as LoanSettlement;
|
|
if (oLoanSettlement != null)
|
|
return oLoanSettlement;
|
|
#endregion
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin();
|
|
DataReader oreader = new DataReader(LoanSettlementDA.Get(tc, id));
|
|
if (oreader.Read())
|
|
{
|
|
oLoanSettlement = this.CreateObject<LoanSettlement>(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(oLoanSettlement, "Get", id);
|
|
#endregion
|
|
return oLoanSettlement;
|
|
}
|
|
|
|
public ObjectsTemplate<LoanSettlement> Get()
|
|
{
|
|
#region Cache Header
|
|
|
|
ObjectsTemplate<LoanSettlement> LoanSettlements = _cache["Get"] as ObjectsTemplate<LoanSettlement>;
|
|
if (LoanSettlements != null)
|
|
return LoanSettlements;
|
|
|
|
#endregion
|
|
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin();
|
|
|
|
DataReader dr = new DataReader(LoanSettlementDA.Get(tc));
|
|
LoanSettlements = this.CreateObjects<LoanSettlement>(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(LoanSettlements, "Get");
|
|
|
|
#endregion
|
|
|
|
return LoanSettlements;
|
|
}
|
|
|
|
public ID Save(LoanSettlement oLoanSettlement)
|
|
{
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
|
|
tc = TransactionContext.Begin(true);
|
|
if (oLoanSettlement.IsNew)
|
|
{
|
|
int id = tc.GenerateID("LoanSettlement", "LoanSettlementID");
|
|
base.SetObjectID(oLoanSettlement, ID.FromInteger(id));
|
|
LoanSettlementDA.Insert(tc, oLoanSettlement);
|
|
}
|
|
else
|
|
{
|
|
LoanSettlementDA.Update(tc, oLoanSettlement);
|
|
}
|
|
|
|
return oLoanSettlement.ID;
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
#region Handle Exception
|
|
if (tc != null)
|
|
tc.HandleError();
|
|
ExceptionLog.Write(e);
|
|
throw new ServiceException(e.Message, e);
|
|
#endregion
|
|
}
|
|
finally
|
|
{
|
|
tc.End();
|
|
}
|
|
}
|
|
|
|
public void Delete(ID id)
|
|
{
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin(true);
|
|
LoanSettlementDA.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
|
|
}
|