using Ease.Core.DataAccess; using Ease.Core.Model; using Ease.Core.Utility; using System; using System.Collections.Generic; using HRM.BO; namespace HRM.DA { public class PayScaleDetailService : ServiceTemplate, IPayScaleDetailService { public PayScaleDetailService() { } private void MapObject(PayScaleDetail oPayScaleDetail, DataReader oReader) { base.SetObjectID(oPayScaleDetail, oReader.GetInt32("PAYSCALEITEMID").Value); oPayScaleDetail.PayscaleID = oReader.GetInt32("PAYSCALEID", 0); oPayScaleDetail.GradeID = oReader.GetInt32("GradeID", 0); oPayScaleDetail.StepNo = oReader.GetInt32("SCALESERIALNO").Value; oPayScaleDetail.Amount = oReader.GetDouble("AMOUNT").Value; oPayScaleDetail.StepAmount = oReader.GetDouble("SLABAMOUNT").Value; oPayScaleDetail.StepIncrement = oReader.GetDouble("StepIncrement").Value; this.SetObjectState(oPayScaleDetail, Ease.Core.ObjectState.Saved); } protected override T CreateObject(DataReader oReader) { PayScaleDetail oPayScaleDetail = new PayScaleDetail(); MapObject(oPayScaleDetail, oReader); return oPayScaleDetail as T; } #region Service implementation public PayScaleDetail Get(int id) { PayScaleDetail oPayScaleDetail = null; TransactionContext tc = null; try { tc = TransactionContext.Begin(); DataReader oreader = new DataReader(PayScaleDetailDA.Get(tc, id)); if (oreader.Read()) { oPayScaleDetail = this.CreateObject(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 oPayScaleDetail; } public PayScaleDetail Get(TransactionContext tc, int id) { PayScaleDetail oPayScaleDetail = null; try { DataReader oreader = new DataReader(PayScaleDetailDA.Get(tc, id)); if (oreader.Read()) { oPayScaleDetail = this.CreateObject(oreader); } oreader.Close(); } catch (Exception e) { #region Handle Exception ExceptionLog.Write(e); throw new ServiceException(e.Message, e); #endregion } return oPayScaleDetail; } public List GetByPayScale(int payscaleID) { List payScaleDetails = new List(); TransactionContext tc = null; try { tc = TransactionContext.Begin(); DataReader dr = new DataReader(PayScaleDetailDA.GetByPayScale(tc, payscaleID)); payScaleDetails = 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 payScaleDetails; } public List GetByPayScale(TransactionContext tc, int payscaleID) { List payScaleDetails = new List(); try { DataReader dr = new DataReader(PayScaleDetailDA.GetByPayScale(tc, payscaleID)); payScaleDetails = this.CreateObjects(dr); dr.Close(); } catch (Exception e) { #region Handle Exception ExceptionLog.Write(e); throw new ServiceException(e.Message, e); #endregion } return payScaleDetails; } public List GetByGradeID(int GradeID, int payrollTypeID) { List payScaleDetails = new List(); TransactionContext tc = null; try { tc = TransactionContext.Begin(); DataReader dr = new DataReader(PayScaleDetailDA.GetByGradeID(tc, GradeID, payrollTypeID)); payScaleDetails = 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 payScaleDetails; } public List Get(int GradeID, int AllowID) { List payScaleDetails = new List(); TransactionContext tc = null; try { tc = TransactionContext.Begin(); DataReader dr = new DataReader(PayScaleDetailDA.Get(tc, GradeID, AllowID)); payScaleDetails = 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 payScaleDetails; } public List Get() { List payScaleDetails = new List(); TransactionContext tc = null; try { tc = TransactionContext.Begin(); DataReader dr = new DataReader(PayScaleDetailDA.Get(tc)); payScaleDetails = 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 payScaleDetails; } public int Save(PayScaleDetail oPayScaleDetail) { TransactionContext tc = null; try { tc = TransactionContext.Begin(true); int id = tc.GenerateID("PayScaleDetail", "PayScaleDetailID"); base.SetObjectID(oPayScaleDetail, id); PayScaleDetailDA.Insert(tc, oPayScaleDetail); tc.End(); return oPayScaleDetail.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); PayScaleDetailDA.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 } }