968 lines
37 KiB
C#
968 lines
37 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 InvestmentService : ServiceTemplate
|
|
{
|
|
#region Private functions and declaration
|
|
|
|
public InvestmentService()
|
|
{
|
|
}
|
|
|
|
private void MapObject(InvestmentInfo oInvestment, DataReader oReader)
|
|
{
|
|
oInvestment.AccountNo = oReader.GetString("AccountNo");
|
|
oInvestment.BankID = oReader.GetInt32("BankID").Value;
|
|
oInvestment.BranchID = oReader.GetInt32("BranchID").Value;
|
|
oInvestment.CategoryID = oReader.GetInt32("CategoryID").Value;
|
|
oInvestment.ProjectID = oReader.GetInt32("ProjectID").Value;
|
|
oInvestment.CertificateNo = oReader.GetString("CertificateNo");
|
|
oInvestment.Amount = oReader.GetDouble("Amount").Value;
|
|
oInvestment.TotalProAccruedAmount = oReader.GetDouble("TotalProAccruedAmount").Value;
|
|
oInvestment.LastProAccruedDate = oReader.GetDateTime("LastProAccruedDate") != null
|
|
? oReader.GetDateTime("LastProAccruedDate").Value
|
|
: DateTime.MinValue;
|
|
oInvestment.CurrentStatus = oReader.GetInt32("CurrentStatus").Value;
|
|
oInvestment.Description = oReader.GetString("Description");
|
|
oInvestment.TenureType =
|
|
oReader.GetInt32("TenureType").Value != null ? oReader.GetInt32("TenureType").Value : 0;
|
|
base.SetObjectID(oInvestment, oReader.GetInt32("ID").Value);
|
|
|
|
oInvestment.IssueDate = oReader.GetDateTime("IssueDate").Value;
|
|
oInvestment.MatureDate = oReader.GetDateTime("MatureDate").Value;
|
|
oInvestment.RefID = oReader.GetInt32("RefID").Value;
|
|
oInvestment.Tenure = oReader.GetInt32("Tenure").Value;
|
|
oInvestment.CalculationBase = oReader.GetInt32("CalculationBase").Value;
|
|
oInvestment.EncashmentDate = oReader.GetDateTime("EncashmentDate") != null
|
|
? oReader.GetDateTime("EncashmentDate").Value
|
|
: DateTime.MinValue;
|
|
oInvestment.RenewalDate = oReader.GetDateTime("RenewalDate") != null
|
|
? oReader.GetDateTime("RenewalDate").Value
|
|
: DateTime.MinValue;
|
|
oInvestment.UserRecordID = oReader.GetInt32("UserRecordID").Value;
|
|
oInvestment.GLTranID = oReader.GetInt32("GLTranID").Value;
|
|
oInvestment.CreatedBy = oReader.GetInt32("CreatedBy").Value;
|
|
oInvestment.CreatedDate = oReader.GetDateTime("CreatedDate").Value;
|
|
oInvestment.ModifiedBy =
|
|
oReader.GetInt32("ModifiedBy").Value != null ? oReader.GetInt32("ModifiedBy").Value : (0);
|
|
oInvestment.ModifiedDate = oReader.GetDateTime("ModifiedDate") != null
|
|
? oReader.GetDateTime("ModifiedDate").Value
|
|
: DateTime.MinValue;
|
|
|
|
base.SetObjectState(oInvestment, ObjectState.Saved);
|
|
}
|
|
|
|
private InvestmentInfo CreateObject(DataReader oReader)
|
|
{
|
|
InvestmentInfo oInvestment = new InvestmentInfo();
|
|
MapObject(oInvestment, oReader);
|
|
return oInvestment;
|
|
}
|
|
|
|
private List<InvestmentInfo> CreateObjects(IDataReader oReader)
|
|
{
|
|
List<InvestmentInfo> oInvestmentInfos = new List<InvestmentInfo>();
|
|
DataReader oreader = new DataReader(oReader);
|
|
while (oReader.Read())
|
|
{
|
|
InvestmentInfo oItem = CreateObject(oreader);
|
|
oInvestmentInfos.Add(oItem);
|
|
}
|
|
|
|
return oInvestmentInfos;
|
|
}
|
|
|
|
#region InvestmentSchedule child load
|
|
|
|
private void MapInvestmentSchedule(InvestmentSchedule investSchedule, DataReader dr)
|
|
{
|
|
base.SetObjectID(investSchedule, dr.GetInt32("ID").Value);
|
|
investSchedule.InvestmentID = dr.GetInt32("InvestmentID").Value;
|
|
investSchedule.ProjectID = dr.GetInt32("ProjectID").Value;
|
|
investSchedule.FromDate = dr.GetDateTime("FromDate").Value;
|
|
investSchedule.Percentage = dr.GetFloat("Percentage").Value;
|
|
investSchedule.RecalculationNeeded = dr.GetBoolean("RecalculationNeeded").Value;
|
|
investSchedule.TillDate = dr.GetDateTime("TillDate").Value;
|
|
investSchedule.TranDate = dr.GetDateTime("TranDate").Value;
|
|
investSchedule.CreatedBy = dr.GetInt32("CreatedBy").Value;
|
|
investSchedule.CreatedDate = dr.GetDateTime("CreatedDate").Value;
|
|
investSchedule.ModifiedBy = dr.GetInt32("ModifiedBy").Value != null ? dr.GetInt32("ModifiedBy").Value : (0);
|
|
investSchedule.ModifiedDate = dr.GetDateTime("ModifiedDate") != null
|
|
? dr.GetDateTime("ModifiedDate").Value
|
|
: DateTime.MinValue;
|
|
base.SetObjectState(investSchedule, ObjectState.Saved);
|
|
}
|
|
|
|
private void MapInvestmentSignatory(InvestmentSignatory investSignatory, DataReader dr)
|
|
{
|
|
base.SetObjectID(investSignatory, dr.GetInt32("ID").Value);
|
|
investSignatory.InvestmentID = dr.GetInt32("InvestmentID").Value;
|
|
investSignatory.ProjectID = dr.GetInt32("ProjectID").Value;
|
|
investSignatory.TrustyID = dr.GetInt32("TrustyID").Value;
|
|
investSignatory.CreatedBy = dr.GetInt32("CreatedBy").Value;
|
|
investSignatory.CreatedDate = dr.GetDateTime("CreatedDate").Value;
|
|
investSignatory.ModifiedBy =
|
|
dr.GetInt32("ModifiedBy").Value != null ? dr.GetInt32("ModifiedBy").Value : (0);
|
|
investSignatory.ModifiedDate = dr.GetDateTime("ModifiedDate") != null
|
|
? dr.GetDateTime("ModifiedDate").Value
|
|
: DateTime.MinValue;
|
|
base.SetObjectState(investSignatory, ObjectState.Saved);
|
|
}
|
|
|
|
private InvestmentSchedule CreateInvestmentSchedules(DataReader dr)
|
|
{
|
|
InvestmentSchedule investSchedule = new InvestmentSchedule();
|
|
MapInvestmentSchedule(investSchedule, dr);
|
|
return investSchedule;
|
|
}
|
|
|
|
private InvestmentSignatory CreateInvestmentSignatorys(DataReader dr)
|
|
{
|
|
InvestmentSignatory investSignatory = new InvestmentSignatory();
|
|
MapInvestmentSignatory(investSignatory, dr);
|
|
return investSignatory;
|
|
}
|
|
|
|
private void FillInvestmentSchedules(InvestmentInfo parent, DataReader dr)
|
|
{
|
|
while (dr.Read())
|
|
{
|
|
InvestmentSchedule item = this.CreateInvestmentSchedules(dr);
|
|
parent.InvestmentSchedulesCollection.Add(item);
|
|
}
|
|
}
|
|
|
|
private void FillInvestmentSignatorys(InvestmentInfo parent, DataReader dr)
|
|
{
|
|
while (dr.Read())
|
|
{
|
|
InvestmentSignatory item = this.CreateInvestmentSignatorys(dr);
|
|
parent.InvestmentSignatorysCollection.Add(item);
|
|
}
|
|
}
|
|
|
|
|
|
private void LoadChildren(TransactionContext tc, InvestmentInfo investment)
|
|
{
|
|
try
|
|
{
|
|
if (investment != null && investment.ID != null && investment.ID != 0)
|
|
{
|
|
//Get InvestmentSchedule
|
|
DataReader dr = new DataReader(InvestmentScheduleDA.GetByParent(tc, investment.ID));
|
|
FillInvestmentSchedules(investment, dr);
|
|
dr.Close();
|
|
dr = new DataReader(InvestmentDA.GetByParentSinatory(tc, investment.ID));
|
|
FillInvestmentSignatorys(investment, dr);
|
|
dr.Close();
|
|
|
|
//InvestmentTranService investmentTranService = new InvestmentTranService();
|
|
//List<InvestmentTran> investmentTrans = investmentTranService.Get(tc, investment);
|
|
//foreach (InvestmentTran item in investmentTrans)
|
|
//{
|
|
// investment.InvestmentTranCollection.Add(item);
|
|
//}
|
|
}
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
throw e;
|
|
}
|
|
}
|
|
|
|
#endregion InvestmentSchedule child load
|
|
|
|
#endregion
|
|
|
|
#region Service implementation
|
|
|
|
#region Get By InvestmentInfoID
|
|
|
|
public InvestmentInfo Get(int investmentInfoID)
|
|
{
|
|
#region Cache Header
|
|
|
|
InvestmentInfo investment = new InvestmentInfo();
|
|
if (investment != null)
|
|
return investment;
|
|
|
|
#endregion
|
|
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin();
|
|
DataReader dr = new DataReader(InvestmentDA.Get(tc, investmentInfoID));
|
|
if (dr.Read())
|
|
{
|
|
investment = this.CreateObject<InvestmentInfo>(dr);
|
|
}
|
|
|
|
dr.Close();
|
|
LoadChildren(tc, investment);
|
|
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 investment;
|
|
}
|
|
|
|
#endregion
|
|
|
|
|
|
public DataTable GetPFInvestment(DateTime Fromdate, DateTime toDate)
|
|
{
|
|
DataTable dTbl = new DataTable("PFInvestment");
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin();
|
|
|
|
IDataReader ir = InvestmentDA.GetPFInvestment(tc, Fromdate, toDate);
|
|
dTbl.Load(ir);
|
|
ir.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 dTbl;
|
|
}
|
|
|
|
public DataTable GetInvestmentBSP(DateTime Fromdate, DateTime toDate)
|
|
{
|
|
DataTable dTbl = new DataTable("Investment");
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin();
|
|
|
|
IDataReader ir = InvestmentDA.GetInvestmentBSP(tc, Fromdate, toDate);
|
|
dTbl.Load(ir);
|
|
ir.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 dTbl;
|
|
}
|
|
|
|
public DataSet GetStatementInvestment(string ssta1glID, DateTime dtFirst, DateTime dtLast)
|
|
{
|
|
DataSet dTbl = new DataSet("StatementInvestment");
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin();
|
|
dTbl = InvestmentDA.GetStatementInvestment(tc, ssta1glID, dtFirst, dtLast);
|
|
|
|
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 List<InvestmentInfo> Getbyfundtype(int fundtypeid)
|
|
{
|
|
#region Cache Header
|
|
|
|
List<InvestmentInfo> items = new List<InvestmentInfo>();
|
|
List<InvestmentInfo> itemsRead = new List<InvestmentInfo>();
|
|
if (items != null)
|
|
return items;
|
|
|
|
#endregion
|
|
|
|
items = new List<InvestmentInfo>();
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin();
|
|
|
|
DataReader dataReader = new DataReader(InvestmentDA.Getbyfundtype(tc, fundtypeid));
|
|
while (dataReader.Read())
|
|
{
|
|
InvestmentInfo item = this.CreateObject(dataReader);
|
|
//LoadChildren(tc, item);
|
|
itemsRead.Add(item);
|
|
}
|
|
|
|
dataReader.Close();
|
|
foreach (InvestmentInfo item in itemsRead)
|
|
{
|
|
//LoadChildren(tc, item);
|
|
items.Add(item);
|
|
}
|
|
|
|
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 bool GetIsUsedUserObjectName(int categoryid)
|
|
{
|
|
bool found = false;
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin();
|
|
DataReader dataReader = new DataReader(InvestmentDA.Get(tc, categoryid));
|
|
if (dataReader.Read())
|
|
found = true;
|
|
tc.End();
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
#region Handle Exception
|
|
|
|
if (tc != null)
|
|
tc.HandleError();
|
|
ExceptionLog.Write(e);
|
|
|
|
throw new ServiceException(e.Message, e);
|
|
|
|
#endregion
|
|
}
|
|
|
|
return found;
|
|
}
|
|
|
|
public List<InvestmentInfo> GetBySearch(string sSearch, DateTime fromDate, DateTime toDate, int fundtypeid)
|
|
{
|
|
List<InvestmentInfo> oInvestmentInfos = new List<InvestmentInfo>();
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin();
|
|
IDataReader oReader = InvestmentDA.GetBySearch(tc, sSearch, fromDate, toDate, fundtypeid);
|
|
oInvestmentInfos = CreateObjects(oReader);
|
|
oReader.Close();
|
|
tc.End();
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
#region Handle Exception
|
|
|
|
if (tc != null)
|
|
tc.HandleError();
|
|
throw new ServiceException(e.Message);
|
|
|
|
#endregion
|
|
}
|
|
|
|
return oInvestmentInfos;
|
|
}
|
|
|
|
//public List<InvestmentInfo> GetBySearch(string sSearch)
|
|
//{
|
|
// List<InvestmentInfo> oInvestmentInfos = new List<InvestmentInfo>();
|
|
// TransactionContext tc = null;
|
|
// try
|
|
// {
|
|
// tc = TransactionContext.Begin();
|
|
// IDataReader oReader = InvestmentDA.GetBySearch(tc, sSearch);
|
|
// oInvestmentInfos = CreateObjects(oReader);
|
|
// oReader.Close();
|
|
// tc.End();
|
|
// }
|
|
// catch (Exception e)
|
|
// {
|
|
// #region Handle Exception
|
|
// if (tc != null)
|
|
// tc.HandleError();
|
|
// throw new ServiceException(e.Message);
|
|
// #endregion
|
|
// }
|
|
// return oInvestmentInfos;
|
|
//}
|
|
|
|
public decimal GetAmountBySearch(string sSearch)
|
|
{
|
|
decimal amount = 0;
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin();
|
|
amount = InvestmentDA.GetAmountBySearch(tc, sSearch);
|
|
tc.End();
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
#region Handle Exception
|
|
|
|
if (tc != null)
|
|
tc.HandleError();
|
|
throw new ServiceException(e.Message);
|
|
|
|
#endregion
|
|
}
|
|
|
|
return amount;
|
|
}
|
|
|
|
protected override T CreateObject<T>(DataReader dataReader)
|
|
{
|
|
InvestmentInfo investment = new InvestmentInfo();
|
|
|
|
MapObject(investment, dataReader);
|
|
|
|
return investment as T;
|
|
}
|
|
|
|
public void Save(InvestmentInfo investment)
|
|
{
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin(true);
|
|
|
|
if (!investment.IsNew)
|
|
{
|
|
InvestmentDA.Update(tc, investment);
|
|
}
|
|
else
|
|
{
|
|
//SaveUserRecords(tc, investment.iFASUserObject_helperForSubsidiarysUpload);
|
|
//investment.UserRecordID = (_uploadedUserRecordID);
|
|
int id = tc.GenerateID("Investment", "ID");
|
|
//int id1 = tc.GenerateID("Investment", "ID");
|
|
base.SetObjectID(investment, (id));
|
|
InvestmentDA.Insert(tc, investment);
|
|
}
|
|
|
|
if (investment.IsNew)
|
|
{
|
|
//Delete Children
|
|
InvestmentDA.DeleteSingnatoryByParent(tc, investment.ID);
|
|
InvestmentScheduleDA.DeleteByParent(tc, investment.ID);
|
|
InvestmentTranDA.DeleteByParent(tc, investment.ID);
|
|
InvestmentLogDA.DeleteByParent(tc, investment.ID);
|
|
}
|
|
|
|
foreach (InvestmentSchedule item in investment.InvestmentSchedulesCollection)
|
|
{
|
|
item.InvestmentID = investment.ID;
|
|
int id = tc.GenerateID("InvestmentSchedule", "ID");
|
|
base.SetObjectID(item, (id));
|
|
InvestmentScheduleDA.Insert(tc, item);
|
|
}
|
|
|
|
foreach (InvestmentSignatory item in investment.InvestmentSignatorysCollection)
|
|
{
|
|
item.InvestmentID = investment.ID;
|
|
int id = tc.GenerateID("InvestmentSignatory", "ID");
|
|
base.SetObjectID(item, (id));
|
|
InvestmentDA.Insert(tc, item);
|
|
}
|
|
|
|
foreach (InvestmentTran item in investment.InvestmentTranCollection)
|
|
{
|
|
item.InvestmentID = investment.ID;
|
|
int id = tc.GenerateID("InvestmentTran", "TranID");
|
|
base.SetObjectID(item, (id));
|
|
InvestmentTranDA.Insert(tc, item);
|
|
}
|
|
|
|
foreach (InvestmentLog item in investment.InvestmentLogCollection)
|
|
{
|
|
item.InvestmentID = investment.ID;
|
|
int id = tc.GenerateID("InvestmentLog", "recordID");
|
|
base.SetObjectID(item, (id));
|
|
InvestmentLogDA.Insert(tc, item);
|
|
}
|
|
|
|
//SaveUserRecords(tc, investment.iFASUserObject_helperForSubsidiarysUpload);
|
|
ProjectProcess pp = new ProjectProcess();
|
|
//pp = pp.getByDescription(Regex.Replace(EnumProjectProcess.InvestmentPurchase.ToString(), "([A-Z])", " $1").Trim());
|
|
//SaveVoucher(tc, investment.ForVoucher_glTrans, pp.ID);
|
|
|
|
//SaveVoucher(tc, investment.ForVoucher_glTrans, (int)EnumInvestmentActivities.InvestmentPurchase);
|
|
//InvestmentDA.UPdateInvestmentWithGLTranID(tc, investment.ID, investment.ForVoucher_glTrans[0].ID);
|
|
tc.End();
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
#region Handle Exception
|
|
|
|
if (tc != null)
|
|
tc.HandleError();
|
|
ExceptionLog.Write(e);
|
|
|
|
throw new ServiceException(e.Message, e);
|
|
|
|
#endregion
|
|
}
|
|
}
|
|
|
|
public void ReschduleInterestRate(InvestmentInfo investment, bool isCollectionModified)
|
|
{
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin(true);
|
|
|
|
if (!investment.IsNew)
|
|
{
|
|
investment.ModifiedBy = investment.ModifiedBy;
|
|
investment.ModifiedDate = DateTime.Now;
|
|
InvestmentDA.Update(tc, investment);
|
|
}
|
|
|
|
if (isCollectionModified)
|
|
{
|
|
InvestmentScheduleDA.DeleteByParent(tc, investment.ID);
|
|
foreach (InvestmentSchedule item in investment.InvestmentSchedulesCollection)
|
|
{
|
|
item.ModifiedBy = investment.ModifiedBy;
|
|
item.ModifiedDate = DateTime.Now;
|
|
item.InvestmentID = investment.ID;
|
|
int id = tc.GenerateID("InvestmentSchedule", "ID");
|
|
base.SetObjectID(item, (id));
|
|
InvestmentScheduleDA.Insert(tc, item);
|
|
}
|
|
|
|
foreach (InvestmentLog item in investment.InvestmentLogCollection)
|
|
{
|
|
item.InvestmentID = investment.ID;
|
|
int id = tc.GenerateID("InvestmentLog", "ID");
|
|
base.SetObjectID(item, (id));
|
|
InvestmentLogDA.Insert(tc, item);
|
|
}
|
|
}
|
|
|
|
tc.End();
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
#region Handle Exception
|
|
|
|
if (tc != null)
|
|
tc.HandleError();
|
|
ExceptionLog.Write(e);
|
|
|
|
throw new ServiceException(e.Message, e);
|
|
|
|
#endregion
|
|
}
|
|
}
|
|
|
|
//public void UpdateAccruedAndStatus(InvestmentInfo investment)
|
|
//{
|
|
// TransactionContext tc = null;
|
|
// try
|
|
// {
|
|
// tc = TransactionContext.Begin(true);
|
|
|
|
// SaveVoucher(tc, investment.ForVoucher_glTrans, (int)EnumInvestmentActivities.InvestmentLiquidation);
|
|
// InvestmentDA.UpdateAccruedAndStatus(tc, investment);
|
|
// InvestmentDA.UPdateInvestmentWithGLTranID(tc, investment.ID, investment.ForVoucher_glTrans[0].ID);
|
|
|
|
// //Insert InvestmentTranCollection
|
|
// foreach (InvestmentTran item in investment.InvestmentTranCollection)
|
|
// {
|
|
// item.InvestmentID = investment.ID;
|
|
// int id = tc.GenerateID("InvestmentTran", "TranID");
|
|
// base.SetObjectID(item, (id));
|
|
// InvestmentTranDA.Insert(tc, item);
|
|
// }
|
|
|
|
// //Insert InvestmentLogCollection
|
|
// foreach (InvestmentLog item in investment.InvestmentLogCollection)
|
|
// {
|
|
// item.InvestmentID = investment.ID;
|
|
// int id = tc.GenerateID("InvestmentLog", "RecordID");
|
|
// base.SetObjectID(item, (id));
|
|
// InvestmentLogDA.Insert(tc, item);
|
|
// }
|
|
// tc.End();
|
|
// //
|
|
// }
|
|
// catch (Exception e)
|
|
// {
|
|
// #region Handle Exception
|
|
|
|
// if (tc != null)
|
|
// tc.HandleError();
|
|
// ExceptionLog.Write(e);
|
|
|
|
// throw new ServiceException(e.Message, e);
|
|
|
|
// #endregion
|
|
// }
|
|
//}
|
|
|
|
//public void UpdateAccruedAndStatus(List<InvestmentInfo> _objTemInvestments)
|
|
//{
|
|
// TransactionContext tc = null;
|
|
// try
|
|
// {
|
|
// tc = TransactionContext.Begin(true);
|
|
// foreach (InvestmentInfo investment in _objTemInvestments)
|
|
// {
|
|
|
|
// EaseFAS.Service.GLTranService oglsrv = new EaseFAS.Service.GLTranService();
|
|
// Ease.Core.DataAccess.TransactionContext Coretc = Ease.Core.DataAccess.TransactionContext.SetConnection(tc.Connection, tc.Transaction);
|
|
// oglsrv.Insert(Coretc, investment.ForVoucher_glTrans);
|
|
// InvestmentDA.UpdateAccruedAndStatus(tc, investment);
|
|
|
|
// //Insert InvestmentTranCollection
|
|
// foreach (InvestmentTran item in investment.InvestmentTranCollection)
|
|
// {
|
|
// item.InvestmentID = investment.ID;
|
|
// int id = tc.GenerateID("InvestmentTran", "TranID");
|
|
// base.SetObjectID(item, (id));
|
|
// InvestmentTranDA.Insert(tc, item);
|
|
// }
|
|
|
|
// //Insert InvestmentLogCollection
|
|
// foreach (InvestmentLog item in investment.InvestmentLogCollection)
|
|
// {
|
|
// item.InvestmentID = investment.ID;
|
|
// int id = tc.GenerateID("InvestmentLog", "RecordID");
|
|
// base.SetObjectID(item, (id));
|
|
// InvestmentLogDA.Insert(tc, item);
|
|
// }
|
|
// }
|
|
// tc.End();
|
|
|
|
// }
|
|
// catch (Exception e)
|
|
// {
|
|
// #region Handle Exception
|
|
|
|
// if (tc != null)
|
|
// tc.HandleError();
|
|
// ExceptionLog.Write(e);
|
|
|
|
// throw new ServiceException(e.Message, e);
|
|
|
|
// #endregion
|
|
// }
|
|
//}
|
|
//public void UpdateAccruedAndMaturity(List<InvestmentInfo> _objTemInvestments)
|
|
//{
|
|
// TransactionContext tc = null;
|
|
// try
|
|
// {
|
|
// tc = TransactionContext.Begin(true);
|
|
// SaveVoucher(tc, _objTemInvestments[0].ForVoucher_glTrans, (int)EnumInvestmentActivities.InvestMonthlyAccrualInterest);
|
|
// foreach (InvestmentInfo investment in _objTemInvestments)
|
|
// {
|
|
|
|
// InvestmentDA.UpdateAccruedAndMaturity(tc, investment);
|
|
|
|
// //Insert InvestmentTranCollection
|
|
// foreach (InvestmentTran item in investment.InvestmentTranCollection)
|
|
// {
|
|
// item.InvestmentID = investment.ID;
|
|
// int id = tc.GenerateID("InvestmentTran", "TranID");
|
|
// base.SetObjectID(item, (id));
|
|
// InvestmentTranDA.Insert(tc, item);
|
|
// }
|
|
|
|
// //Insert InvestmentLogCollection
|
|
// foreach (InvestmentLog item in investment.InvestmentLogCollection)
|
|
// {
|
|
// item.InvestmentID = investment.ID;
|
|
// int id = tc.GenerateID("InvestmentLog", "RECORDID");
|
|
// base.SetObjectID(item, (id));
|
|
// InvestmentLogDA.Insert(tc, item);
|
|
// }
|
|
// }
|
|
// tc.End();
|
|
|
|
// }
|
|
// catch (Exception e)
|
|
// {
|
|
// #region Handle Exception
|
|
|
|
// if (tc != null)
|
|
// tc.HandleError();
|
|
// ExceptionLog.Write(e);
|
|
|
|
// throw new ServiceException(e.Message, e);
|
|
|
|
// #endregion
|
|
// }
|
|
//}
|
|
|
|
//public void Renewal(List<InvestmentInfo> investmentCollection)
|
|
//{
|
|
// int index = 0;
|
|
// TransactionContext tc = null;
|
|
// try
|
|
// {
|
|
// tc = TransactionContext.Begin(true);
|
|
// while (investmentCollection.Count>index)
|
|
// {
|
|
// if (investmentCollection[index].IsModified)
|
|
// {
|
|
// InvestmentDA.UpdateAccruedAndStatus(tc, investmentCollection[index]);
|
|
// foreach (InvestmentTran item in investmentCollection[index].InvestmentTranCollection)
|
|
// {
|
|
// item.InvestmentID = investmentCollection[index].ID;
|
|
// int id = tc.GenerateID("InvestmentTran", "TranID");
|
|
// base.SetObjectID(item, (id));
|
|
// InvestmentTranDA.Insert(tc, item);
|
|
// }
|
|
// foreach (InvestmentLog item in investmentCollection[index].InvestmentLogCollection)
|
|
// {
|
|
// item.InvestmentID = investmentCollection[index].ID;
|
|
// int id = tc.GenerateID("InvestmentLog", "ID");
|
|
// base.SetObjectID(item, (id));
|
|
// InvestmentLogDA.Insert(tc, item);
|
|
// }
|
|
// }
|
|
// else if (investmentCollection[index].IsNew)
|
|
// {
|
|
// //SaveUserRecords(tc, investmentCollection[index].iFASUserObject_helperForSubsidiarysUpload);
|
|
// int idParent = tc.GenerateID("Investment", "ID");
|
|
// base.SetObjectID(investmentCollection[index], (idParent));
|
|
|
|
// //investmentCollection[index].UserRecordID = Ease.CoreV35.Model.(_uploadedUserRecordID);
|
|
// InvestmentDA.Insert(tc, investmentCollection[index]);
|
|
// _uploadedUserRecordID = Ease.Core.Framework.(investmentCollection[index].UserRecordID);
|
|
// //Delete Children
|
|
// InvestmentDA.DeleteSingnatoryByParent(tc, investmentCollection[index].ID);
|
|
// InvestmentScheduleDA.DeleteByParent(tc, investmentCollection[index].ID);
|
|
// InvestmentTranDA.DeleteByParent(tc, investmentCollection[index].ID);
|
|
// InvestmentLogDA.DeleteByParent(tc, investmentCollection[index].ID);
|
|
|
|
// foreach (InvestmentSchedule item in investmentCollection[index].InvestmentSchedulesCollection)
|
|
// {
|
|
// item.InvestmentID = investmentCollection[index].ID;
|
|
// int id = tc.GenerateID("InvestmentSchedule", "ID");
|
|
// base.SetObjectID(item, (id));
|
|
// InvestmentScheduleDA.Insert(tc, item);
|
|
// }
|
|
// foreach (InvestmentSignatory item in investmentCollection[index].InvestmentSignatorysCollection)
|
|
// {
|
|
// item.InvestmentID = investmentCollection[index].ID;
|
|
// int id = tc.GenerateID("InvestmentSignatory", "ID");
|
|
// base.SetObjectID(item, (id));
|
|
// InvestmentDA.Insert(tc, item);
|
|
// }
|
|
// foreach (InvestmentTran item in investmentCollection[index].InvestmentTranCollection)
|
|
// {
|
|
// item.InvestmentID = investmentCollection[index].ID;
|
|
// int id = tc.GenerateID("InvestmentTran", "TranID");
|
|
// base.SetObjectID(item, (id));
|
|
// InvestmentTranDA.Insert(tc, item);
|
|
// }
|
|
// foreach (InvestmentLog item in investmentCollection[index].InvestmentLogCollection)
|
|
// {
|
|
// item.InvestmentID = investmentCollection[index].ID;
|
|
// int id = tc.GenerateID("InvestmentLog", "RECORDID");
|
|
// base.SetObjectID(item, (id));
|
|
// InvestmentLogDA.Insert(tc, item);
|
|
// }
|
|
// ProjectProcess pp = new ProjectProcess();
|
|
// pp = pp.getByDescription(Regex.Replace(EnumProjectProcess.InvestmentPurchase.ToString(), "([A-Z])", " $1").Trim());
|
|
// SaveVoucher(tc, investmentCollection[index].ForVoucher_glTrans, pp.ID);
|
|
|
|
// //SaveVoucher(tc, investmentCollection[index].ForVoucher_glTrans, (int)EnumInvestmentActivities.InvestmentPurchase);
|
|
// InvestmentDA.UPdateInvestmentWithGLTranID(tc, investmentCollection[index].ID, investmentCollection[index].ForVoucher_glTrans[0].ID);
|
|
// }
|
|
// index++;
|
|
// }
|
|
// tc.End();
|
|
|
|
// }
|
|
// catch (Exception e)
|
|
// {
|
|
// #region Handle Exception
|
|
|
|
// if (tc != null)
|
|
// tc.HandleError();
|
|
// ExceptionLog.Write(e);
|
|
|
|
// throw new ServiceException(e.Message, e);
|
|
|
|
// #endregion
|
|
// }
|
|
//}
|
|
|
|
public void Delete(int id)
|
|
{
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin(true);
|
|
InvestmentDA.Delete(tc, id);
|
|
tc.End();
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
#region Handle Exception
|
|
|
|
if (tc != null)
|
|
tc.HandleError();
|
|
ExceptionLog.Write(e);
|
|
throw new ServiceException("Failed to GetInvestment", e);
|
|
|
|
#endregion
|
|
}
|
|
}
|
|
|
|
//public void DeleteInvestment(int investmentid, Ease.Core.Framework.ID glTranID)
|
|
//{
|
|
// TransactionContext tc = null;
|
|
// EaseFAS.Service.GLTranService glTranService = new EaseFAS.Service.GLTranService();
|
|
// try
|
|
// {
|
|
// tc = TransactionContext.Begin(true);
|
|
// Ease.Core.DataAccess.TransactionContext coretc = Ease.Core.DataAccess.TransactionContext.SetConnection(tc.Connection, tc.Transaction);
|
|
// glTranService.Delete(coretc, glTranID);
|
|
|
|
// InvestmentDA.DeleteSingnatoryByParent(tc, investmentid);
|
|
// InvestmentScheduleDA.DeleteByParent(tc, investmentid);
|
|
// InvestmentTranDA.DeleteByParent(tc, investmentid);
|
|
// InvestmentLogDA.DeleteByParent(tc, investmentid);
|
|
// InvestmentDA.DeleteInvestment(tc, investmentid);
|
|
// tc.End();
|
|
// }
|
|
// catch (Exception e)
|
|
// {
|
|
// #region Handle Exception
|
|
// if (tc != null)
|
|
// tc.HandleError();
|
|
// ExceptionLog.Write(e);
|
|
// throw new ServiceException("Failed to GetInvestment", e);
|
|
// #endregion
|
|
// }
|
|
//}
|
|
|
|
//private void DeleteVoucher(int glTranID)
|
|
//{
|
|
// throw new NotImplementedException();
|
|
//}
|
|
|
|
//public void SaveUserRecords(TransactionContext tc, List<HelperForSubsidiaryUpload> subsidiarysUpload)
|
|
//{
|
|
// UserRecordService userRecordService = new UserRecordService();
|
|
// foreach (HelperForSubsidiaryUpload subUpload in subsidiarysUpload)
|
|
// {
|
|
// if (subUpload.UserRcds.Count > 0)
|
|
// {
|
|
// foreach (UserRecord userRecord in subUpload.UserRcds)
|
|
// {
|
|
// _uploadedUserRecordID = userRecordService.Insert(tc, userRecord);
|
|
// }
|
|
// }
|
|
// }
|
|
//}
|
|
|
|
//public void SaveVoucher(TransactionContext tc, GLTrans glTrans, int investActivitiesInInt)
|
|
//{
|
|
// EaseFAS.Service.GLTranService glTranService = new EaseFAS.Service.GLTranService();
|
|
// if (glTrans != null)
|
|
// {
|
|
// ProjectProcess pp = new ProjectProcess();
|
|
// pp = pp.getByDescription(Regex.Replace(EnumProjectProcess.InvestmentPurchase.ToString(), "([A-Z])", " $1").Trim());
|
|
|
|
|
|
// //if ((int)EnumInvestmentActivities.InvestmentPurchase == investActivitiesInInt)
|
|
// if (pp.ID == investActivitiesInInt)
|
|
|
|
// {
|
|
// if (glTrans.Count == 1)
|
|
// {
|
|
// foreach (GLTranDetail glTranDetail in glTrans[0].GlTranDetails)
|
|
// {
|
|
// if (glTranDetail.Transide == EaseFAS.Global.EnumTranSide.Debit)
|
|
// {
|
|
// foreach (GLTranUserRecord glTUR in glTranDetail.GlTranUserRecords)
|
|
// {
|
|
// glTUR.UserRecord1ID = _uploadedUserRecordID;
|
|
// break;
|
|
// }
|
|
// }
|
|
// }
|
|
// }
|
|
// }
|
|
|
|
// Ease.Core.DataAccess.TransactionContext tcEaseCore= Ease.Core.DataAccess.TransactionContext.SetConnection(tc.Connection, tc.Transaction);
|
|
// glTranService.Insert(tcEaseCore, glTrans);
|
|
// }
|
|
//}
|
|
|
|
#endregion
|
|
}
|
|
} |