using Ease.Core.DataAccess; using Ease.Core.Model; using Ease.Core.Utility; using System; using System.Collections.Generic; using System.Data; using System.Linq; using HRM.BO; namespace HRM.DA { #region GLTranDetail Service [Serializable] public class GLTranDetailService : ServiceTemplate //, IGLTranDetailService { public GLTranDetailService() { } #region Map Objects private void MapObject(GLTranDetail gLTranDetail, DataReader nhReader) { this.SetObjectID(gLTranDetail, nhReader.GetInt32("GLTranDetailID").Value); gLTranDetail.GLTranID = nhReader.GetInt32("GLTranID").Value; gLTranDetail.GLID = nhReader.GetInt32("GLID").Value; gLTranDetail.IsContra = nhReader.GetBoolean("IsContra").Value; gLTranDetail.ContraGLID = nhReader.GetInt32("ContraGLID").Value; gLTranDetail.ChequeDate = nhReader.GetDateTime("ChequeDate").Value; gLTranDetail.ChequeNo = nhReader.GetString("ChequeNo"); gLTranDetail.Transide = (EnumTranSide)nhReader.GetInt32("Transide"); gLTranDetail.Amount = nhReader.GetDecimal("Amount").Value; gLTranDetail.DetailParamID = nhReader.GetInt32("DetailParamID").Value; // gLTranDetail.CostCenterID = ID.FromInteger(nhReader.GetInt32("CostCenterID")); gLTranDetail.Description = nhReader.GetString("Description"); gLTranDetail.BankDetail = nhReader.GetString("BankDetail"); gLTranDetail.InstrumentNo = nhReader.GetString("InstrumentNo"); gLTranDetail.OperationalStatus = (EnumOperationalStatus)nhReader.GetInt32("OperationalStatus"); gLTranDetail.Modifiedby = nhReader.GetInt32("Modifiedby").Value; gLTranDetail.ModifiedDate = nhReader.GetDateTime("ModifiedDate").Value; this.SetObjectState(gLTranDetail, Ease.Core.ObjectState.Saved); } protected override T CreateObject(DataReader oReader) { GLTranDetail oGLTranDetail = new GLTranDetail(); MapObject(oGLTranDetail, oReader); return oGLTranDetail as T; } protected GLTranDetail CreateObject(DataReader oReader) { GLTranDetail oGLTranDetail = new GLTranDetail(); MapObject(oGLTranDetail, oReader); return oGLTranDetail; } //private GLTranDetails CreateObjects(IDataReader oReader) //{ // GLTranDetails oGLTranDetails = new GLTranDetails(); // NullHandler oreader = new NullHandler(oReader); // while (oReader.Read()) // { // GLTranDetail oItem = CreateObject(oreader); // oGLTranDetails.Add(oItem); // } // return oGLTranDetails; //} #endregion #region Map Open private void OpenMapObject(GLTranDetail gLTranDetail, DataReader nhReader) { this.SetObjectID(gLTranDetail, nhReader.GetInt32("OpenGLTranDetailID").Value); gLTranDetail.GLTranID = nhReader.GetInt32("OpenGLTranID").Value; gLTranDetail.GLID = nhReader.GetInt32("GLID").Value; gLTranDetail.IsContra = nhReader.GetBoolean("IsContra").Value; gLTranDetail.ContraGLID = nhReader.GetInt32("ContraGLID").Value; gLTranDetail.ChequeDate = nhReader.GetDateTime("ChequeDate").Value; gLTranDetail.ChequeNo = nhReader.GetString("ChequeNo"); gLTranDetail.Transide = (EnumTranSide)nhReader.GetInt32("Transide"); gLTranDetail.Amount = nhReader.GetDecimal("Amount").Value; gLTranDetail.DetailParamID = nhReader.GetInt32("DetailParamID").Value; //gLTranDetail.CostCenterID = ID.FromInteger(nhReader.GetInt32("CostCenterID")); gLTranDetail.Description = nhReader.GetString("Description"); gLTranDetail.BankDetail = nhReader.GetString("BankDetail"); gLTranDetail.InstrumentNo = nhReader.GetString("InstrumentNo"); gLTranDetail.OperationalStatus = (EnumOperationalStatus)nhReader.GetInt32("OperationalStatus"); gLTranDetail.Modifiedby = nhReader.GetInt32("Modifiedby").Value; gLTranDetail.ModifiedDate = nhReader.GetDateTime("ModifiedDate").Value; this.SetObjectState(gLTranDetail, Ease.Core.ObjectState.Saved); } //protected override T OpenCreateObject(DataReader oReader) //{ // GLTranDetail oGLTran = new GLTranDetail(); // MapObject(oGLTran, oReader); // return oGLTran as T; //} protected GLTranDetail OpenCreateObject(DataReader oReader) { GLTranDetail oGLTran = new GLTranDetail(); MapObject(oGLTran, oReader); return oGLTran; } //private GLTranDetails OpenCreateObjects(IDataReader oReader) //{ // GLTranDetails oGLTranDetails = new GLTranDetails(); // NullHandler oreader = new NullHandler(oReader); // while (oReader.Read()) // { // GLTranDetail oItem = OpenCreateObject(oreader); // oGLTranDetails.Add(oItem); // } // return oGLTranDetails; //} #endregion #region Map Year End private void YearEndMapObject(GLTranDetail gLTranDetail, DataReader nhReader) { this.SetObjectID(gLTranDetail, nhReader.GetInt32("YearEndGLTranDetailID").Value); gLTranDetail.GLTranID = nhReader.GetInt32("YearEndGLTranID").Value; gLTranDetail.GLID = nhReader.GetInt32("GLID").Value; gLTranDetail.IsContra = nhReader.GetBoolean("IsContra").Value; gLTranDetail.ContraGLID = nhReader.GetInt32("ContraGLID").Value; gLTranDetail.ChequeDate = nhReader.GetDateTime("ChequeDate").Value; gLTranDetail.ChequeNo = nhReader.GetString("ChequeNo"); gLTranDetail.Transide = (EnumTranSide)nhReader.GetInt32("Transide"); gLTranDetail.Amount = nhReader.GetDecimal("Amount").Value; gLTranDetail.DetailParamID = nhReader.GetInt32("DetailParamID").Value; // gLTranDetail.CostCenterID = nhReader.GetInt32("CostCenterID").Value; gLTranDetail.Description = nhReader.GetString("Description"); gLTranDetail.BankDetail = nhReader.GetString("BankDetail"); gLTranDetail.InstrumentNo = nhReader.GetString("InstrumentNo"); gLTranDetail.OperationalStatus = (EnumOperationalStatus)nhReader.GetInt32("OperationalStatus"); gLTranDetail.Modifiedby = nhReader.GetInt32("Modifiedby").Value; gLTranDetail.ModifiedDate = nhReader.GetDateTime("ModifiedDate").Value; this.SetObjectState(gLTranDetail, Ease.Core.ObjectState.Saved); } protected GLTranDetail YearEndCreateObject(DataReader oReader) { GLTranDetail oGLTran = new GLTranDetail(); MapObject(oGLTran, oReader); return oGLTran; } //private GLTranDetails YearEndCreateObjects(IDataReader oReader) //{ // GLTranDetails oGLTranDetails = new GLTranDetails(); // NullHandler oreader = new NullHandler(oReader); // while (oReader.Read()) // { // GLTranDetail oItem = YearEndCreateObject(oreader); // oGLTranDetails.Add(oItem); // } // return oGLTranDetails; //} #endregion #region Service implementation public GLTranDetail Get(int id) { GLTranDetail oGLTranDetail = null; TransactionContext tc = null; try { tc = TransactionContext.Begin(); DataReader oreader = new DataReader(GLTranDetailDA.Get(tc, id)); if (oreader.Read()) { oGLTranDetail = 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 oGLTranDetail; } public List Get() { List oGLTranDetails = new List(); TransactionContext tc = null; try { tc = TransactionContext.Begin(); DataReader dr = new DataReader(GLTranDetailDA.Get(tc)); oGLTranDetails = 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 oGLTranDetails; } public List GetByGLTranID(int gLTranID) { List oGLTranDetails = new List(); TransactionContext tc = null; try { tc = TransactionContext.Begin(); DataReader dr = new DataReader(GLTranDetailDA.GetByGLTranID(tc, gLTranID)); oGLTranDetails = 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 oGLTranDetails; } public List Get(int gLTranID, int glID) { List oGLTranDetails = new List(); TransactionContext tc = null; try { tc = TransactionContext.Begin(); DataReader dr = new DataReader(GLTranDetailDA.Get(tc, gLTranID, glID)); oGLTranDetails = 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 oGLTranDetails; } public List GetByGLTranID(TransactionContext tc, int gLTranID) { List oGLTranDetails = new List(); // TransactionContext tc = null; try { tc = TransactionContext.Begin(); DataReader dr = new DataReader(GLTranDetailDA.GetByGLTranID(tc, gLTranID)); oGLTranDetails = 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 oGLTranDetails; } public List GetByGLTranIDOpen(TransactionContext tc, int gLTranID) { List oGLTranDetails = new List(); // TransactionContext tc = null; try { tc = TransactionContext.Begin(); DataReader dr = new DataReader(GLTranDetailDA.GetByGLTranIDOpen(tc, gLTranID)); oGLTranDetails = 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 oGLTranDetails; } public List GetByVoucherDate(TransactionContext tc, DateTime firstDate, DateTime lastDate) { List oGLTranDetails = new List(); // TransactionContext tc = null; try { tc = TransactionContext.Begin(); DataReader dr = new DataReader(GLTranDetailDA.GetByVoucherDate(tc, firstDate, lastDate)); oGLTranDetails = 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 oGLTranDetails; } //private void MapOpen(List oGLTranDetails, IDataReader oReader) //{ // DataReader oreader = new DataReader(oReader); // while (oReader.Read()) // { // GLTranDetail oItem = OpenCreateObject(oreader); // oGLTranDetails.Add(oItem); // } //} //private void MapYearEnd(GLTranDetails oGLTranDetails, IDataReader oReader) //{ // NullHandler oreader = new NullHandler(oReader); // while (oReader.Read()) // { // GLTranDetail oItem = YearEndCreateObject(oreader); // oGLTranDetails.Add(oItem); // } //} public int Save(GLTranDetail gLTranDetail) { TransactionContext tc = null; try { tc = TransactionContext.Begin(true); if (gLTranDetail.IsNew) { int id = tc.GenerateID("GLTranDetail", "GLTranDetailID"); base.SetObjectID(gLTranDetail, id); GLTranDetailDA.Insert(tc, gLTranDetail); } else { GLTranDetailDA.Update(tc, gLTranDetail); } tc.End(); return gLTranDetail.ID; } catch (Exception e) { #region Handle Exception if (tc != null) tc.HandleError(); ExceptionLog.Write(e); throw new ServiceException(e.Message, e); #endregion } } internal int Save(TransactionContext tc, GLTranDetail gLTranDetail) { try { // tc = TransactionContext.Begin(true); if (gLTranDetail.IsNew) { int id = tc.GenerateID("GLTranDetail", "GLTranDetailID"); base.SetObjectID(gLTranDetail, id); GLTranDetailDA.Insert(tc, gLTranDetail); } else { GLTranDetailDA.Update(tc, gLTranDetail); } tc.End(); return gLTranDetail.ID; } catch (Exception e) { #region Handle Exception if (tc != null) tc.HandleError(); ExceptionLog.Write(e); throw new ServiceException(e.Message, e); #endregion } } //internal int SaveOpen(TransactionContext tc, GLTranDetail gLTranDetail) //{ // try // { // if (gLTranDetail.IsNew) // { // #region Creator // //gLTranDetail.CreatedBy = User.CurrentUser.ID; // //gLTranDetail.CreateDate = DateTime.Now; // #endregion // this.SetObjectID(gLTranDetail, ID.FromInteger(GLTranDetailDA.GetNewIDOpen(tc))); // GLTranDetailDA.InsertOpen(tc, gLTranDetail); // } // else // { // #region Modifier // gLTranDetail.Modifiedby = User.CurrentUser.ID; // gLTranDetail.ModifiedDate = DateTime.Now; // #endregion // GLTranDetailDA.UpdateOpen(tc, gLTranDetail); // } // } // catch (Exception e) // { // #region Handle Exception // if (tc != null) // tc.HandleError(); // ExceptionLog.Write(e); // throw new ServiceException("Failed to Get GLTranDetail", e); // #endregion // } // return gLTranDetail.ID; //} //internal int SaveYearEnd(TransactionContext tc, GLTranDetail gLTranDetail) //{ // try // { // if (gLTranDetail.IsNew) // { // #region Creator // //gLTranDetail.CreatedBy = User.CurrentUser.ID; // //gLTranDetail.CreateDate = DateTime.Now; // #endregion // this.SetObjectID(gLTranDetail, ID.FromInteger(GLTranDetailDA.GetNewIDYearEnd(tc))); // GLTranDetailDA.InsertYearEnd(tc, gLTranDetail); // } // else // { // #region Modifier // gLTranDetail.Modifiedby = User.CurrentUser.ID; // gLTranDetail.ModifiedDate = DateTime.Now; // #endregion // GLTranDetailDA.UpdateYearEnd(tc, gLTranDetail); // } // } // catch (Exception e) // { // #region Handle Exception // if (tc != null) // tc.HandleError(); // ExceptionLog.Write(e); // throw new ServiceException("Failed to Get GLTranDetail", e); // #endregion // } // return gLTranDetail.ID; //} public void Delete(int id) { TransactionContext tc = null; try { tc = TransactionContext.Begin(true); GLTranDetailDA.Delete(tc, id); tc.End(); } catch (Exception e) { #region Handle Exception if (tc != null) tc.HandleError(); ExceptionLog.Write(e); throw new ServiceException("Failed to Delete " + e.Message); #endregion } } #endregion } #endregion }