using System; using System.Data; using Ease.Core.Model; using Ease.Core.DataAccess; using Ease.Core; using System.Collections.Generic; using Ease.Core.Utility; using HRM.BO; namespace HRM.DA { #region RewardStatementParameterIndividual Service public class RewardStatementParameterIndividualService : ServiceTemplate, IRewardStatementParameterIndividualService { #region Private functions and declaration public RewardStatementParameterIndividualService() { } private void MapObject(RewardStatementParameterIndividual oRewIndividual, DataReader oReader) { base.SetObjectID(oRewIndividual, (oReader.GetInt32("RSParameterIndividualID").Value)); oRewIndividual.EmployeeID = oReader.GetInt32("EmployeeId", 0); oRewIndividual.RewardStatementParameterID = oReader.GetInt32("RewardStatementParameterID", 0); oRewIndividual.FlatAmount = oReader.GetDouble("FlatAmount").Value; oRewIndividual.BasicAmount = oReader.GetDouble("BasicAmount").Value; oRewIndividual.GCAmount = oReader.GetDouble("GCAmount").Value; this.SetObjectState(oRewIndividual, Ease.Core.ObjectState.Saved); } protected override T CreateObject(DataReader oReader) { RewardStatementParameterIndividual oOpiIndividual = new RewardStatementParameterIndividual(); MapObject(oOpiIndividual, oReader); return oOpiIndividual as T; } protected RewardStatementParameterIndividual CreateObject(DataReader oReader) { RewardStatementParameterIndividual oOpiIndividual = new RewardStatementParameterIndividual(); MapObject(oOpiIndividual, oReader); return oOpiIndividual; } #endregion #region Service implementation public RewardStatementParameterIndividual Get(int id) { RewardStatementParameterIndividual oOpiIndividual = null; TransactionContext tc = null; try { tc = TransactionContext.Begin(); DataReader oreader = new DataReader(RewardStatementParameterIndividualDA.Get(tc, id)); if (oreader.Read()) { oOpiIndividual = 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 oOpiIndividual; } public List Get() { List oOpiIndividuals = null; TransactionContext tc = null; try { tc = TransactionContext.Begin(); DataReader oreader = new DataReader(RewardStatementParameterIndividualDA.Get(tc)); oOpiIndividuals = this.CreateObjects(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 oOpiIndividuals; } public List GetByParameterID(int nParamaterID) { List oOpiIndividuals = null; TransactionContext tc = null; try { tc = TransactionContext.Begin(); DataReader oreader = new DataReader(RewardStatementParameterIndividualDA.GetByParameterID(tc, nParamaterID)); oOpiIndividuals = this.CreateObjects(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 oOpiIndividuals; } public RewardStatementParameterIndividual Get(int nPAramID, int EmployeeID) { RewardStatementParameterIndividual opiParameters = null; TransactionContext tc = null; try { tc = TransactionContext.Begin(); DataReader dr = new DataReader(RewardStatementParameterIndividualDA.Get(tc, nPAramID, EmployeeID)); if (dr.Read()) { opiParameters = 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 opiParameters; } public int Save(RewardStatementParameterIndividual oRewIndividual) { TransactionContext tc = null; try { tc = TransactionContext.Begin(true); if (oRewIndividual.IsNew) { int id = tc.GenerateID("RewardStatementParameterIndividual", "RewardStatementParameterIndividualID"); base.SetObjectID(oRewIndividual, (id)); RewardStatementParameterIndividualDA.Insert(tc, oRewIndividual); } else { RewardStatementParameterIndividualDA.Update(tc, oRewIndividual); } return oRewIndividual.ID; tc.End(); } catch (Exception e) { #region Handle Exception if (tc != null) tc.HandleError(); ExceptionLog.Write(e); throw new ServiceException("Failed to GetRewardStatementParameterIndividual", e); #endregion } } public void BulkSave(List oParamIndvdls) { TransactionContext tc = null; try { tc = TransactionContext.Begin(true); foreach (var oOpiIndividual in oParamIndvdls) { if (oOpiIndividual.IsNew) { int id = tc.GenerateID("RewardStatementParameterIndividual", "RewardStatementParameterIndividualID"); base.SetObjectID(oOpiIndividual, (id)); RewardStatementParameterIndividualDA.Insert(tc, oOpiIndividual); } else { RewardStatementParameterIndividualDA.Update(tc, oOpiIndividual); } } tc.End(); } catch (Exception e) { #region Handle Exception if (tc != null) tc.HandleError(); ExceptionLog.Write(e); throw new ServiceException("Failed to GetRewardStatementParameterIndividual", e); #endregion } } public void Delete(int id) { TransactionContext tc = null; try { tc = TransactionContext.Begin(true); RewardStatementParameterIndividualDA.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 #region IRewardStatementParameterIndividualService Members #endregion } #endregion }