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(DataReader oReader) { PLDailyInterest oInt = new PLDailyInterest(); MapObject(oInt, oReader); return oInt as T; } #region Service implementation public List Get(DateTime FrominterestDate, DateTime ToIntDate) { List oInt = new List(); TransactionContext tc = null; try { tc = TransactionContext.Begin(); DataReader dr = new DataReader(PLDailyInterestDA.Get(tc, FrominterestDate, ToIntDate)); oInt = this.CreateObjects(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(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 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 }