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; using HRM.DA; namespace HRM.DA.Fund { [Serializable] public class MemberBalaneMonthlyService : ServiceTemplate { #region Private Function And Declaration public MemberBalaneMonthlyService() { } private void MapObject(MemberBalaneMonthly oMemberBalaneMonthly, DataReader dr) { this.SetObjectID(oMemberBalaneMonthly, dr.GetInt32("RecordID").Value); oMemberBalaneMonthly.ProjectID = dr.GetInt32("ProjectID").Value; oMemberBalaneMonthly.MembersID = dr.GetInt32("MembersID").Value; oMemberBalaneMonthly.MonthDate = dr.GetDateTime("MonthDate").Value; oMemberBalaneMonthly.FundTypeID = dr.GetInt32("FundTypeID").Value; oMemberBalaneMonthly.EmpCode = dr.GetString("EmpCode"); oMemberBalaneMonthly.MembershipDate = dr.GetDateTime("MembershipDate").Value; oMemberBalaneMonthly.MembershipNo = dr.GetString("MembershipNo"); oMemberBalaneMonthly.CMOpeningContributionBalance = dr.GetDouble("CMOpeningContributionBalance").Value; oMemberBalaneMonthly.CMClosingContributionBalance = dr.GetDouble("CMClosingContributionBalance").Value; oMemberBalaneMonthly.CMActualOpeningInterest = dr.GetDouble("CMActualOpeningInterest").Value; oMemberBalaneMonthly.CMActualClosingInterest = dr.GetDouble("CMActualClosingInterest").Value; oMemberBalaneMonthly.CMOpeningProvisionalInterest = dr.GetDouble("CMOpeningProvisionalInterest").Value; oMemberBalaneMonthly.CMOpeningActualBalance = dr.GetDouble("CMOpeningActualBalance").Value; oMemberBalaneMonthly.CMClosingActualBalance = dr.GetDouble("CMClosingActualBalance").Value; oMemberBalaneMonthly.CMClosingActualBalance = dr.GetDouble("CMClosingActualBalance").Value; oMemberBalaneMonthly.CMClosingProvisionalInterest = dr.GetDouble("CMClosingProvisionalInterest").Value; oMemberBalaneMonthly.CMOpeningProvisionalBalance = dr.GetDouble("CMOpeningProvisionalBalance").Value; oMemberBalaneMonthly.CMClosingProvisionalBalance = dr.GetDouble("CMClosingProvisionalBalance").Value; oMemberBalaneMonthly.CreatedBy = dr.GetInt32("CreatedBy").Value; oMemberBalaneMonthly.CreatedDate = dr.GetDateTime("CreatedDate").Value; oMemberBalaneMonthly.ModifiedBy = dr.GetInt32("ModifiedBy").Value; oMemberBalaneMonthly.ModifiedDate = dr.GetDateTime("ModifiedDate"); this.SetObjectState(oMemberBalaneMonthly, ObjectState.Saved); } protected override T CreateObject(DataReader dr) { MemberBalaneMonthly item = new MemberBalaneMonthly(); MapObject(item, dr); return item as T; } private MemberBalaneMonthly CreateObject(DataReader dr) { MemberBalaneMonthly oMemberBalaneMonthly = new MemberBalaneMonthly(); MapObject(oMemberBalaneMonthly, dr); return oMemberBalaneMonthly; } private List CreateObjects(IDataReader dr) { List oMemberBalaneMonthlys = new List(); DataReader oreader = new DataReader(dr); while (dr.Read()) { MemberBalaneMonthly Item = CreateObject(oreader); oMemberBalaneMonthlys.Add(Item); } return oMemberBalaneMonthlys; } #endregion public MemberBalaneMonthly Get(int id) { MemberBalaneMonthly oMemberBalaneMonthly = new MemberBalaneMonthly(); #region Cache Header oMemberBalaneMonthly = new MemberBalaneMonthly(); if (oMemberBalaneMonthly != null) return oMemberBalaneMonthly; #endregion TransactionContext tc = null; try { tc = TransactionContext.Begin(); IDataReader oreader = MemberBalaneMonthlyDA.Get(tc, id); DataReader dr = new DataReader(oreader); if (oreader.Read()) { oMemberBalaneMonthly = CreateObject(dr); } oreader.Close(); tc.End(); } catch (Exception e) { #region Handle Exception if (tc != null) tc.HandleError(); ExceptionLog.Write(e); throw new ServiceException("Failed to Get MemberBalaneMonthly", e); #endregion } #region Cache Footer #endregion return oMemberBalaneMonthly; } public MemberBalaneMonthly GetByMemberID(int memberID, int fundtypeid) { MemberBalaneMonthly oMemberBalaneMonthly = new MemberBalaneMonthly(); #region Cache Header if (oMemberBalaneMonthly != null) return oMemberBalaneMonthly; #endregion TransactionContext tc = null; try { tc = TransactionContext.Begin(); IDataReader oreader = MemberBalaneMonthlyDA.GetByMemberID(tc, memberID, fundtypeid); DataReader dr = new DataReader(oreader); if (oreader.Read()) { oMemberBalaneMonthly = CreateObject(dr); } oreader.Close(); tc.End(); } catch (Exception e) { #region Handle Exception if (tc != null) tc.HandleError(); ExceptionLog.Write(e); throw new ServiceException("Failed to Get MemberBalaneMonthly", e); #endregion } #region Cache Footer #endregion return oMemberBalaneMonthly; } public List Getbyfundtype(int fundtypeid) { List MemberBalaneMonthlys = new List(); #region Cache Header if (MemberBalaneMonthlys != null) return MemberBalaneMonthlys; #endregion TransactionContext tc = null; try { tc = TransactionContext.Begin(); IDataReader dr = MemberBalaneMonthlyDA.Get(tc, fundtypeid); MemberBalaneMonthlys = CreateObjects(dr); dr.Close(); tc.End(); } catch (Exception e) { #region Handle Exception if (tc != null) tc.HandleError(); ExceptionLog.Write(e); throw new ServiceException("Failed to Get MemberBalaneMonthly ", e); #endregion } #region Cache Footer #endregion return MemberBalaneMonthlys; } //DateTime selectedMonth public List Get(DateTime selectedMonth, int fundtypeid) { List MemberBalaneMonthlys = new List(); #region Cache Header if (MemberBalaneMonthlys != null) return MemberBalaneMonthlys; #endregion TransactionContext tc = null; try { tc = TransactionContext.Begin(); IDataReader dr = MemberBalaneMonthlyDA.Get(tc, selectedMonth, fundtypeid); MemberBalaneMonthlys = CreateObjects(dr); dr.Close(); tc.End(); } catch (Exception e) { #region Handle Exception if (tc != null) tc.HandleError(); ExceptionLog.Write(e); throw new ServiceException("Failed to Get MemberBalaneMonthly: " + e.Message, e); #endregion } #region Cache Footer #endregion return MemberBalaneMonthlys; } public void Delete(int id) { TransactionContext tc = null; try { tc = TransactionContext.Begin(true); MemberBalaneMonthlyDA.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 MemberBalaneMonthly", e); #endregion } } #region Insert public int Save(MemberBalaneMonthly MemberBalaneMonthly) { MemberBalaneMonthly oMemberBalaneMonthly = new MemberBalaneMonthly(); oMemberBalaneMonthly = MemberBalaneMonthly; TransactionContext tc = null; try { tc = TransactionContext.Begin(true); if (oMemberBalaneMonthly.IsNew) { int id = tc.GenerateID("MemberBalaneMonthly", "MemberBalaneMonthlyID"); base.SetObjectID(oMemberBalaneMonthly, (id)); MemberBalaneMonthlyDA.Insert(tc, oMemberBalaneMonthly); } else { MemberBalaneMonthlyDA.Update(tc, oMemberBalaneMonthly); } tc.End(); } catch (Exception e) { #region Handle Exception if (tc != null) tc.HandleError(); ExceptionLog.Write(e); throw new ServiceException(e.Message, e); #endregion } return oMemberBalaneMonthly.ID; } #endregion public DataTable GetLeftMemberTable(DateTime fromDate, DateTime toDate, int fundtypeid) { DataTable dTbl = new DataTable(); TransactionContext tc = null; try { tc = TransactionContext.Begin(true); dTbl = MemberBalaneMonthlyDA.GetLeftMemberTable(tc, fromDate, toDate, fundtypeid); tc.End(); } catch (Exception e) { #region Handle Exception if (tc != null) tc.HandleError(); ExceptionLog.Write(e); throw new ServiceException(e.Message, e); #endregion } return dTbl; } public DataTable GetTable(DateTime fromDate, DateTime toDate, int fundtypeid) { DataTable dTbl = new DataTable(); TransactionContext tc = null; try { tc = TransactionContext.Begin(); dTbl = MemberBalaneMonthlyDA.GetTable(tc, fromDate, toDate, fundtypeid); tc.End(); } catch (Exception e) { #region Handle Exception if (tc != null) tc.HandleError(); ExceptionLog.Write(e); throw new ServiceException(e.Message, e); #endregion } return dTbl; } } }