388 lines
11 KiB
C#
388 lines
11 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
|
|
{
|
|
#region InvestmentTran Service
|
|
|
|
[Serializable]
|
|
public class InvestmentTranService : ServiceTemplate, IInvestmentTranService
|
|
{
|
|
#region Private functions and declaration
|
|
|
|
public InvestmentTranService()
|
|
{
|
|
}
|
|
|
|
private void MapObject(InvestmentTran oInvestmentTran, DataReader oReader)
|
|
{
|
|
base.SetObjectID(oInvestmentTran, oReader.GetInt32("TranID").Value);
|
|
oInvestmentTran.ActivityID = oReader.GetInt32("ActivityID");
|
|
oInvestmentTran.TranTypeID =(EnumInvestmentActivities) oReader.GetInt32("TranTypeID").Value;
|
|
oInvestmentTran.CategoryID = oReader.GetInt32("CategoryID").Value;
|
|
oInvestmentTran.InvestmentID = oReader.GetInt32("InvestmentID").Value;
|
|
oInvestmentTran.TemplateVoucherID = oReader.GetInt32("TemplateVoucherID").Value;
|
|
oInvestmentTran.FundTypeID = oReader.GetInt32("FundTypeID").Value;
|
|
oInvestmentTran.TranDate = oReader.GetDateTime("TranDate").Value;
|
|
oInvestmentTran.PrincipalAmount = oReader.GetDouble("Amount").Value;
|
|
oInvestmentTran.CreatedBy = oReader.GetInt32("CreatedBy").Value;
|
|
oInvestmentTran.CreatedDate = oReader.GetDateTime("CreatedDate").Value;
|
|
oInvestmentTran.ModifiedBy = oReader.GetInt32("ModifiedBy");
|
|
oInvestmentTran.ModifiedDate = oReader.GetDateTime("ModifiedDate");
|
|
oInvestmentTran.InvestmentAIT = oReader.GetDouble("InvestmentAIT");
|
|
oInvestmentTran.InterestGlTranID = oReader.GetInt32("InterestGlTranID") == null ? 0 : oReader.GetInt32("InterestGlTranID").Value;
|
|
oInvestmentTran.AITGLTranID = oReader.GetInt32("AITGLTranID") == null ? 0 : oReader.GetInt32("AITGLTranID").Value;
|
|
|
|
base.SetObjectState(oInvestmentTran, ObjectState.Modified);
|
|
}
|
|
|
|
private InvestmentTran CreateObject(DataReader oReader)
|
|
{
|
|
InvestmentTran oInvestmentTran = new InvestmentTran();
|
|
MapObject(oInvestmentTran, oReader);
|
|
return oInvestmentTran;
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region Service implementation
|
|
|
|
public InvestmentTran Get(int id)
|
|
{
|
|
InvestmentTran oInvestmentTran = new InvestmentTran();
|
|
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin();
|
|
IDataReader oreader = InvestmentTranDA.Get(tc, id);
|
|
DataReader oReader = new DataReader(oreader);
|
|
if (oreader.Read())
|
|
{
|
|
oInvestmentTran = CreateObject(oReader);
|
|
}
|
|
|
|
oreader.Close();
|
|
tc.End();
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
#region Handle Exception
|
|
|
|
if (tc != null)
|
|
tc.HandleError();
|
|
ExceptionLog.Write(e);
|
|
throw new ServiceException("Failed to GetInvestmentTran", e);
|
|
|
|
#endregion
|
|
}
|
|
|
|
return oInvestmentTran;
|
|
}
|
|
|
|
public InvestmentTran GetbyGLTranId(TransactionContext tc,int glTranID)
|
|
{
|
|
InvestmentTran oInvestmentTran = new InvestmentTran();
|
|
|
|
try
|
|
{
|
|
IDataReader oreader = InvestmentTranDA.Get(tc, glTranID);
|
|
DataReader oReader = new DataReader(oreader);
|
|
if (oreader.Read())
|
|
{
|
|
oInvestmentTran = CreateObject(oReader);
|
|
}
|
|
|
|
oreader.Close();
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
#region Handle Exception
|
|
|
|
if (tc != null)
|
|
tc.HandleError();
|
|
ExceptionLog.Write(e);
|
|
throw new ServiceException("Failed to GetInvestmentTran", e);
|
|
|
|
#endregion
|
|
}
|
|
|
|
return oInvestmentTran;
|
|
}
|
|
|
|
public List<InvestmentTran> Get(InvestmentInfo investmentInfo)
|
|
{
|
|
#region Cache Header
|
|
|
|
List<InvestmentTran> items = new List<InvestmentTran>();
|
|
if (items != null)
|
|
return items;
|
|
|
|
#endregion
|
|
|
|
items = new List<InvestmentTran>();
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin();
|
|
|
|
DataReader dataReader = new DataReader(InvestmentTranDA.Get(tc, investmentInfo));
|
|
while (dataReader.Read())
|
|
{
|
|
InvestmentTran item = this.CreateObject(dataReader);
|
|
items.Add(item);
|
|
}
|
|
|
|
dataReader.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
|
|
|
|
#endregion
|
|
|
|
return items;
|
|
}
|
|
|
|
public List<InvestmentTran> Get(TransactionContext tc, InvestmentInfo investmentInfo)
|
|
{
|
|
List<InvestmentTran> items = new List<InvestmentTran>();
|
|
items = new List<InvestmentTran>();
|
|
try
|
|
{
|
|
DataReader dataReader = new DataReader(InvestmentTranDA.Get(tc, investmentInfo));
|
|
while (dataReader.Read())
|
|
{
|
|
InvestmentTran item = this.CreateObject(dataReader);
|
|
items.Add(item);
|
|
}
|
|
|
|
dataReader.Close();
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
#region Handle Exception
|
|
|
|
if (tc != null)
|
|
tc.HandleError();
|
|
ExceptionLog.Write(e);
|
|
|
|
throw new ServiceException(e.Message, e);
|
|
|
|
#endregion
|
|
}
|
|
return items;
|
|
}
|
|
|
|
public DataTable GetTable(int fundtypeid)
|
|
{
|
|
DataTable dataTable = new DataTable("InvestmentTran");
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin();
|
|
|
|
IDataReader iDataReader = InvestmentTranDA.Get(tc, fundtypeid);
|
|
dataTable.Load(iDataReader);
|
|
iDataReader.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 dataTable;
|
|
}
|
|
|
|
public List<InvestmentTran> Getbyfundtype(int fundtypeid)
|
|
{
|
|
#region Cache Header
|
|
|
|
List<InvestmentTran> items = new List<InvestmentTran>();
|
|
if (items != null)
|
|
return items;
|
|
|
|
#endregion
|
|
|
|
items = new List<InvestmentTran>();
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin();
|
|
|
|
DataReader dataReader = new DataReader(InvestmentTranDA.Get(tc, fundtypeid));
|
|
while (dataReader.Read())
|
|
{
|
|
InvestmentTran item = this.CreateObject(dataReader);
|
|
items.Add(item);
|
|
}
|
|
|
|
dataReader.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
|
|
|
|
#endregion
|
|
|
|
return items;
|
|
}
|
|
|
|
protected override T CreateObject<T>(DataReader dataReader)
|
|
{
|
|
InvestmentTran oInvestmentTran = new InvestmentTran();
|
|
|
|
MapObject(oInvestmentTran, dataReader);
|
|
|
|
return oInvestmentTran as T;
|
|
}
|
|
|
|
public void Save(InvestmentTran oInvestmentTran)
|
|
{
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin(true);
|
|
if (oInvestmentTran.IsNew)
|
|
{
|
|
int id = tc.GenerateID("InvestmentTran", "ID");
|
|
base.SetObjectID(oInvestmentTran, (id));
|
|
InvestmentTranDA.Insert(tc, oInvestmentTran);
|
|
}
|
|
else
|
|
{
|
|
InvestmentTranDA.Update(tc, oInvestmentTran);
|
|
}
|
|
|
|
tc.End();
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
#region Handle Exception
|
|
|
|
if (tc != null)
|
|
tc.HandleError();
|
|
ExceptionLog.Write(e);
|
|
throw new ServiceException("Failed to GetInvestmentTran", e);
|
|
|
|
#endregion
|
|
}
|
|
}
|
|
|
|
public void Delete(int id)
|
|
{
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin(true);
|
|
InvestmentTranDA.Delete(tc, id);
|
|
tc.End();
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
#region Handle Exception
|
|
|
|
if (tc != null)
|
|
tc.HandleError();
|
|
ExceptionLog.Write(e);
|
|
throw new ServiceException("Failed to GetInvestmentTran", e);
|
|
|
|
#endregion
|
|
}
|
|
}
|
|
|
|
void IInvestmentTranService.Save(InvestmentTran investmentTran)
|
|
{
|
|
throw new NotImplementedException();
|
|
}
|
|
|
|
void IInvestmentTranService.Delete(int investmentTranID)
|
|
{
|
|
throw new NotImplementedException();
|
|
}
|
|
|
|
InvestmentTran IInvestmentTranService.Get(int investmentTranID)
|
|
{
|
|
throw new NotImplementedException();
|
|
}
|
|
|
|
List<InvestmentTran> IInvestmentTranService.Get(InvestmentInfo investmentInfo)
|
|
{
|
|
throw new NotImplementedException();
|
|
}
|
|
|
|
public DataSet Get(DateTime fromDate, DateTime toDate)
|
|
{
|
|
DataSet ds = new DataSet();
|
|
TransactionContext tc = null;
|
|
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin();
|
|
ds = InvestmentTranDA.Get(tc, fromDate, toDate);
|
|
tc.End();
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
#region Handle Exception
|
|
|
|
if (tc != null)
|
|
tc.HandleError();
|
|
ExceptionLog.Write(e);
|
|
|
|
throw new ServiceException(e.Message, e);
|
|
|
|
#endregion
|
|
}
|
|
|
|
return ds;
|
|
}
|
|
|
|
#endregion
|
|
}
|
|
|
|
#endregion
|
|
} |