396 lines
12 KiB
C#
396 lines
12 KiB
C#
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 MembersBalanceSummaryService : ServiceTemplate
|
|
{
|
|
#region Private Function And Declaration
|
|
|
|
public MembersBalanceSummaryService()
|
|
{
|
|
}
|
|
|
|
private void MapObject(MembersBalanceSummary oMembersBalanceSummary, DataReader dr)
|
|
{
|
|
oMembersBalanceSummary.MembersID = dr.GetInt32("MembersID").Value;
|
|
oMembersBalanceSummary.FundTypeID = dr.GetInt32("FundTypeID").Value;
|
|
this.SetObjectID(oMembersBalanceSummary, dr.GetInt32("MembersID").Value);
|
|
oMembersBalanceSummary.ProjectID = dr.GetInt32("ProjectID").Value;
|
|
oMembersBalanceSummary.EmpCode = dr.GetString("EmpCode");
|
|
oMembersBalanceSummary.MembershipDate = dr.GetDateTime("MembershipDate").Value;
|
|
oMembersBalanceSummary.MembershipNo = dr.GetString("MembershipNo");
|
|
|
|
oMembersBalanceSummary.OpeningContribution = dr.GetDouble("OpeningContribution").Value;
|
|
oMembersBalanceSummary.Contribution = dr.GetDouble("Contribution").Value;
|
|
oMembersBalanceSummary.Total = dr.GetDouble("Total").Value;
|
|
|
|
oMembersBalanceSummary.OpeningActualInterest = dr.GetDouble("OpeningActualInterest").Value;
|
|
oMembersBalanceSummary.ContributionActualInterest = dr.GetDouble("ContributionActualInterest").Value;
|
|
oMembersBalanceSummary.TotalInterest = dr.GetDouble("TotalInterest").Value;
|
|
oMembersBalanceSummary.OpeningBalance = dr.GetDouble("OpeningBalance").Value;
|
|
oMembersBalanceSummary.ContributionWithInterest = dr.GetDouble("ContributionWithInterest").Value;
|
|
oMembersBalanceSummary.TotalBalance = dr.GetDouble("TotalBalance").Value;
|
|
oMembersBalanceSummary.CurrentYearTotalContribution = dr.GetDouble("CurrentYearTotalContribution").Value;
|
|
oMembersBalanceSummary.CurrentYearTotalBenifitProvisioned =
|
|
dr.GetDouble("CurrentYearTotalBenifitProvisioned").Value;
|
|
oMembersBalanceSummary.CurrentYearTotalBalanceProvisioned =
|
|
dr.GetDouble("CurrentYearTotalBalanceProvisioned").Value;
|
|
oMembersBalanceSummary.MostRecentYearActualInterest = dr.GetDouble("MostRecentYearActualInterest").Value;
|
|
|
|
oMembersBalanceSummary.CreatedBy = dr.GetInt32("CreatedBy").Value;
|
|
oMembersBalanceSummary.CreatedDate = dr.GetDateTime("CreatedDate").Value;
|
|
oMembersBalanceSummary.ModifiedBy = dr.GetInt32("ModifiedBy").Value;
|
|
oMembersBalanceSummary.ModifiedDate = dr.GetDateTime("ModifiedDate");
|
|
|
|
this.SetObjectState(oMembersBalanceSummary, ObjectState.Saved);
|
|
}
|
|
|
|
protected override T CreateObject<T>(DataReader dr)
|
|
{
|
|
MembersBalanceSummary item = new MembersBalanceSummary();
|
|
|
|
MapObject(item, dr);
|
|
|
|
return item as T;
|
|
}
|
|
|
|
private MembersBalanceSummary CreateObject(DataReader dr)
|
|
{
|
|
MembersBalanceSummary oMembersBalanceSummary = new MembersBalanceSummary();
|
|
MapObject(oMembersBalanceSummary, dr);
|
|
return oMembersBalanceSummary;
|
|
}
|
|
|
|
private List<MembersBalanceSummary> CreateObjects(IDataReader dr)
|
|
{
|
|
List<MembersBalanceSummary> oMembersBalanceSummarys = new List<MembersBalanceSummary>();
|
|
DataReader oreader = new DataReader(dr);
|
|
while (dr.Read())
|
|
{
|
|
MembersBalanceSummary Item = CreateObject(oreader);
|
|
oMembersBalanceSummarys.Add(Item);
|
|
}
|
|
|
|
return oMembersBalanceSummarys;
|
|
}
|
|
|
|
#endregion
|
|
|
|
public MembersBalanceSummary Get(int id)
|
|
{
|
|
MembersBalanceSummary oMembersBalanceSummary = new MembersBalanceSummary();
|
|
|
|
#region Cache Header
|
|
|
|
oMembersBalanceSummary = new MembersBalanceSummary();
|
|
if (oMembersBalanceSummary != null)
|
|
return oMembersBalanceSummary;
|
|
|
|
#endregion
|
|
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin();
|
|
IDataReader oreader = MembersBalanceSummaryDA.Get(tc, id);
|
|
DataReader dr = new DataReader(oreader);
|
|
if (oreader.Read())
|
|
{
|
|
oMembersBalanceSummary = CreateObject<MembersBalanceSummary>(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 MembersBalanceSummary", e);
|
|
|
|
#endregion
|
|
}
|
|
|
|
#region Cache Footer
|
|
|
|
#endregion
|
|
|
|
return oMembersBalanceSummary;
|
|
}
|
|
|
|
public List<MembersBalanceSummary> GetBothFund(int id, int fundtypeid) // Accroding to ID have fund type
|
|
{
|
|
List<MembersBalanceSummary> MembersBalanceSummarys = new List<MembersBalanceSummary>();
|
|
|
|
#region Cache Header
|
|
|
|
if (MembersBalanceSummarys != null)
|
|
return MembersBalanceSummarys;
|
|
|
|
#endregion
|
|
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin();
|
|
IDataReader dr = MembersBalanceSummaryDA.GetBothFund(tc, id, fundtypeid);
|
|
MembersBalanceSummarys = 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 MembersBalanceSummary ", e);
|
|
|
|
#endregion
|
|
}
|
|
|
|
#region Cache Footer
|
|
|
|
#endregion
|
|
|
|
return MembersBalanceSummarys;
|
|
}
|
|
|
|
public MembersBalanceSummary Get(int memberID, int fundID, int fundtypeid)
|
|
{
|
|
MembersBalanceSummary oMembersBalanceSummary = new MembersBalanceSummary();
|
|
|
|
#region Cache Header
|
|
|
|
if (oMembersBalanceSummary != null)
|
|
return oMembersBalanceSummary;
|
|
|
|
#endregion
|
|
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin();
|
|
IDataReader oreader = MembersBalanceSummaryDA.GetByID(tc, memberID, fundID, fundtypeid);
|
|
DataReader dr = new DataReader(oreader);
|
|
if (oreader.Read())
|
|
{
|
|
oMembersBalanceSummary = CreateObject<MembersBalanceSummary>(dr);
|
|
}
|
|
|
|
oreader.Close();
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
throw e;
|
|
}
|
|
|
|
#region Cache Footer
|
|
|
|
#endregion
|
|
|
|
return oMembersBalanceSummary;
|
|
}
|
|
|
|
internal MembersBalanceSummary GetByID(TransactionContext tc, int memberID, int fundID, int fundtypeid)
|
|
{
|
|
MembersBalanceSummary oMembersBalanceSummary = new MembersBalanceSummary();
|
|
|
|
#region Cache Header
|
|
|
|
if (oMembersBalanceSummary != null)
|
|
return oMembersBalanceSummary;
|
|
|
|
#endregion
|
|
|
|
try
|
|
{
|
|
IDataReader oreader = MembersBalanceSummaryDA.GetByID(tc, memberID, fundID, fundtypeid);
|
|
DataReader dr = new DataReader(oreader);
|
|
if (oreader.Read())
|
|
{
|
|
oMembersBalanceSummary = CreateObject<MembersBalanceSummary>(dr);
|
|
}
|
|
|
|
oreader.Close();
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
throw e;
|
|
}
|
|
|
|
#region Cache Footer
|
|
|
|
#endregion
|
|
|
|
return oMembersBalanceSummary;
|
|
}
|
|
|
|
public List<MembersBalanceSummary> Getfundtype(int fundtypeid)
|
|
{
|
|
List<MembersBalanceSummary> MembersBalanceSummarys = new List<MembersBalanceSummary>();
|
|
|
|
#region Cache Header
|
|
|
|
if (MembersBalanceSummarys != null)
|
|
return MembersBalanceSummarys;
|
|
|
|
#endregion
|
|
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin();
|
|
IDataReader dr = MembersBalanceSummaryDA.Get(tc, fundtypeid);
|
|
MembersBalanceSummarys = 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 MembersBalanceSummary ", e);
|
|
|
|
#endregion
|
|
}
|
|
|
|
#region Cache Footer
|
|
|
|
#endregion
|
|
|
|
return MembersBalanceSummarys;
|
|
}
|
|
|
|
public void Delete(int id)
|
|
{
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin(true);
|
|
MembersBalanceSummaryDA.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 MembersBalanceSummary", e);
|
|
|
|
#endregion
|
|
}
|
|
}
|
|
|
|
|
|
#region Insert
|
|
|
|
public int Save(MembersBalanceSummary MembersBalanceSummary)
|
|
{
|
|
MembersBalanceSummary oMembersBalanceSummary = new MembersBalanceSummary();
|
|
oMembersBalanceSummary = MembersBalanceSummary;
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin(true);
|
|
|
|
if (oMembersBalanceSummary.IsNew)
|
|
{
|
|
int id = tc.GenerateID("MembersBalanceSummary", "MembersBalanceSummaryID");
|
|
base.SetObjectID(oMembersBalanceSummary, (id));
|
|
MembersBalanceSummaryDA.Insert(tc, oMembersBalanceSummary);
|
|
}
|
|
else
|
|
{
|
|
MembersBalanceSummaryDA.Update(tc, oMembersBalanceSummary);
|
|
}
|
|
|
|
tc.End();
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
#region Handle Exception
|
|
|
|
if (tc != null)
|
|
tc.HandleError();
|
|
ExceptionLog.Write(e);
|
|
|
|
throw new ServiceException(e.Message, e);
|
|
|
|
#endregion
|
|
}
|
|
|
|
return oMembersBalanceSummary.ID;
|
|
}
|
|
|
|
#endregion
|
|
|
|
public DataTable GetTable()
|
|
{
|
|
DataTable dTbl = new DataTable();
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin();
|
|
|
|
dTbl = MembersBalanceSummaryDA.GetTable(tc);
|
|
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 GetFunds(int memberID, int fundtypeid)
|
|
{
|
|
DataSet ds = new DataSet();
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin(true);
|
|
if (memberID != null && memberID > 0)
|
|
{
|
|
ds = MembersBalanceSummaryDA.GetFunds(tc, memberID, fundtypeid);
|
|
}
|
|
|
|
tc.End();
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
throw new ServiceException("Failed to Get Funds" + e.Message, e);
|
|
}
|
|
|
|
return ds.Tables[0];
|
|
}
|
|
}
|
|
} |