154 lines
4.3 KiB
C#
154 lines
4.3 KiB
C#
using Ease.Core.DataAccess;
|
|
using Ease.Core.Model;
|
|
using Ease.Core.Utility;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using HRM.BO;
|
|
|
|
namespace HRM.DA
|
|
{
|
|
#region PLDailyInterest Service
|
|
|
|
public class PLDailyInterestService : ServiceTemplate, IPLDailyInterestService
|
|
{
|
|
public PLDailyInterestService()
|
|
{
|
|
}
|
|
|
|
private void MapObject(PLDailyInterest oInt, DataReader oReader)
|
|
{
|
|
base.SetObjectID(oInt, oReader.GetInt32("PLDailyInterestID").Value);
|
|
oInt.InterestDate = oReader.GetDateTime("InterestDate").Value;
|
|
oInt.DailyRate = oReader.GetDouble("DailyRate").Value;
|
|
oInt.AnnualRate = oReader.GetDouble("AnnualRate").Value;
|
|
this.SetObjectState(oInt, Ease.Core.ObjectState.Saved);
|
|
}
|
|
|
|
protected override T CreateObject<T>(DataReader oReader)
|
|
{
|
|
PLDailyInterest oInt = new PLDailyInterest();
|
|
MapObject(oInt, oReader);
|
|
return oInt as T;
|
|
}
|
|
|
|
#region Service implementation
|
|
|
|
public List<PLDailyInterest> Get(DateTime FrominterestDate, DateTime ToIntDate)
|
|
{
|
|
List<PLDailyInterest> oInt = new List<PLDailyInterest>();
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin();
|
|
|
|
DataReader dr = new DataReader(PLDailyInterestDA.Get(tc, FrominterestDate, ToIntDate));
|
|
oInt = this.CreateObjects<PLDailyInterest>(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 oInt;
|
|
}
|
|
|
|
public PLDailyInterest Get(DateTime issueDate)
|
|
{
|
|
PLDailyInterest oInt = null;
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin();
|
|
|
|
DataReader dr = new DataReader(PLDailyInterestDA.Get(tc, issueDate));
|
|
if (dr.Read())
|
|
oInt = this.CreateObject<PLDailyInterest>(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 oInt;
|
|
}
|
|
|
|
public int Save(DateTime FrominterestDate, DateTime ToIntDate, List<PLDailyInterest> oItems)
|
|
{
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin(true);
|
|
this.Delete(FrominterestDate, ToIntDate);
|
|
foreach (PLDailyInterest oItem in oItems)
|
|
{
|
|
int id = tc.GenerateID("PLDailyInterest", "PLDailyInterestID");
|
|
base.SetObjectID(oItem, id);
|
|
PLDailyInterestDA.Insert(tc, oItem);
|
|
}
|
|
|
|
tc.End();
|
|
return oItems[0].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(DateTime FrominterestDate, DateTime ToIntDate)
|
|
{
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin(true);
|
|
PLDailyInterestDA.Delete(tc, FrominterestDate, ToIntDate);
|
|
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
|
|
} |