using System; using System.Collections.Generic; using System.Linq; using System.Text; using Ease.CoreV35; using Ease.CoreV35.Model; using Ease.CoreV35.DataAccess; using Payroll.BO; using Ease.CoreV35.Caching; namespace Payroll.Service { #region JVSetupCC Service [Serializable] public class JVSetupCCService : ServiceTemplate, IJVSetupCCService { #region Private functions and declaration Cache _cache = new Cache(typeof(JVSetupCC)); public JVSetupCCService() { } private void MapObject(JVSetupCC oJVSetupCC, DataReader oReader) { base.SetObjectID(oJVSetupCC, ID.FromInteger(oReader.GetInt32("JVSetupCCID").Value)); oJVSetupCC.CCID = oReader.GetString("CCID") == null ? null : ID.FromInteger(oReader.GetInt32("CCID").Value); oJVSetupCC.JVSetupID = oReader.GetString("JVSetupID") == null ? null : ID.FromInteger(oReader.GetInt32("JVSetupID").Value); oJVSetupCC.CreatedBy = oReader.GetString("CreatedBy") == null ? null : ID.FromInteger(oReader.GetInt32("CreatedBy").Value); oJVSetupCC.CreatedDate = oReader.GetDateTime("CreationDate").Value; oJVSetupCC.ModifiedBy = oReader.GetString("ModifiedBy") == null ? null : ID.FromInteger(oReader.GetInt32("ModifiedBy").Value); oJVSetupCC.ModifiedDate = oReader.GetDateTime("ModifiedDate"); this.SetObjectState(oJVSetupCC, Ease.CoreV35.ObjectState.Saved); } protected override T CreateObject(DataReader oReader) { JVSetupCC oJVSetupCC = new JVSetupCC(); MapObject(oJVSetupCC, oReader); return oJVSetupCC as T; } protected JVSetupCC CreateObject(DataReader oReader) { JVSetupCC oJVSetupCC = new JVSetupCC(); MapObject(oJVSetupCC, oReader); return oJVSetupCC; } #endregion #region Service implementation public JVSetupCC Get(ID id) { JVSetupCC oJVSetupDetail = new JVSetupCC(); #region Cache Header oJVSetupDetail = (JVSetupCC)_cache["Get", id]; if (oJVSetupDetail != null) return oJVSetupDetail; #endregion TransactionContext tc = null; try { tc = TransactionContext.Begin(); DataReader oreader = new DataReader(JVSetupCCDA.Get(tc, id)); if (oreader.Read()) { oJVSetupDetail = 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 } #region Cache Footer _cache.Add(oJVSetupDetail, "Get", id); #endregion return oJVSetupDetail; } public ObjectsTemplate Get() { #region Cache Header ObjectsTemplate oJVSetupDetails = _cache["Get"] as ObjectsTemplate; if (oJVSetupDetails != null) return oJVSetupDetails; #endregion TransactionContext tc = null; try { tc = TransactionContext.Begin(); DataReader oreader = new DataReader(JVSetupCCDA.Get(tc)); oJVSetupDetails = 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 } #region Cache Footer _cache.Add(oJVSetupDetails, "Get"); #endregion return oJVSetupDetails; } public ObjectsTemplate GetByJVSetup(ID JVSetupID) { #region Cache Header ObjectsTemplate JVSetupDetails = _cache["GetByJVSetup", JVSetupID] as ObjectsTemplate; if (JVSetupDetails != null) return JVSetupDetails; #endregion TransactionContext tc = null; try { tc = TransactionContext.Begin(); DataReader dr = new DataReader(JVSetupCCDA.GetByJVSetup(tc, JVSetupID)); JVSetupDetails = 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 } #region Cache Footer _cache.Add(JVSetupDetails, "GetByJVSetup", JVSetupID); #endregion return JVSetupDetails; } public ID Save(JVSetupCC oJVSetupCC) { TransactionContext tc = null; try { tc = TransactionContext.Begin(true); if (oJVSetupCC.IsNew) { int id = tc.GenerateID("JVSetupCC", "JVSetupCCID"); base.SetObjectID(oJVSetupCC, ID.FromInteger(id)); JVSetupCCDA.Insert(tc, oJVSetupCC); } else { JVSetupCCDA.Update(tc, oJVSetupCC); } return oJVSetupCC.ID; tc.End(); } catch (Exception e) { #region Handle Exception if (tc != null) tc.HandleError(); ExceptionLog.Write(e); throw new ServiceException("Failed to GetJVSetupDetail", e); #endregion } } public void Delete(ID id) { TransactionContext tc = null; try { tc = TransactionContext.Begin(true); JVSetupCCDA.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 } #endregion }