using System; using Ease.Core.Model; using Ease.Core.DataAccess; using HRM.BO; using Ease.Core.Utility; using System.Collections.Generic; namespace HRM.DA { public class AdvanceIncomeTaxService : ServiceTemplate, IAdvanceIncomeTaxService { #region MapObjects private void MapObject(AdvanceIncomeTax oAdvanceIncomeTax, DataReader oReader) { base.SetObjectID(oAdvanceIncomeTax, oReader.GetInt32("AdvanceIncomeTaxID").Value); oAdvanceIncomeTax.EmployeeID = oReader.GetInt32("EmployeeID", 0); oAdvanceIncomeTax.TaxParameterID = oReader.GetInt32("TaxParameterID", 0); oAdvanceIncomeTax.Amount = oReader.GetDouble("Amount").Value; oAdvanceIncomeTax.Remarks = oReader.GetString("Remarks"); oAdvanceIncomeTax.CreatedBy = oReader.GetInt32("CreatedBy", 0); oAdvanceIncomeTax.CreatedDate = oReader.GetDateTime("CreationDate").Value; oAdvanceIncomeTax.ModifiedBy = oReader.GetInt32("ModifiedBy", 0); oAdvanceIncomeTax.ModifiedDate = oReader.GetDateTime("ModifiedDate"); this.SetObjectState(oAdvanceIncomeTax, Ease.Core.ObjectState.Saved); } protected override T CreateObject(DataReader oReader) { AdvanceIncomeTax oAdvanceIncomeTax = new AdvanceIncomeTax(); MapObject(oAdvanceIncomeTax, oReader); return oAdvanceIncomeTax as T; } #endregion #region Service Methods public AdvanceIncomeTax Get(int id) { AdvanceIncomeTax oAdvanceIncomeTax = null; TransactionContext tc = null; try { tc = TransactionContext.Begin(); DataReader oreader = new DataReader(AdvanceIncomeTaxDA.Get(tc, id)); if (oreader.Read()) { oAdvanceIncomeTax = 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 oAdvanceIncomeTax; } public List Get() { List oAdvanceIncomeTaxs = new List(); TransactionContext tc = null; try { tc = TransactionContext.Begin(); DataReader dr = new DataReader(AdvanceIncomeTaxDA.Get(tc)); oAdvanceIncomeTaxs = 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 oAdvanceIncomeTaxs; } public int Save(AdvanceIncomeTax oAdvanceIncomeTax) { TransactionContext tc = null; try { tc = TransactionContext.Begin(true); if (oAdvanceIncomeTax.IsNew) { int id = tc.GenerateID("AdvanceIncomeTax", "AdvanceIncomeTaxID"); base.SetObjectID(oAdvanceIncomeTax, id); AdvanceIncomeTaxDA.Insert(tc, oAdvanceIncomeTax); } else { AdvanceIncomeTaxDA.Update(tc, oAdvanceIncomeTax); } tc.End(); return oAdvanceIncomeTax.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); AdvanceIncomeTaxDA.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 } }