EchoTex_Payroll/HRM.DA/Service/Fund/MemberInfo/PensionSettlementService.cs
2024-10-14 10:01:49 +06:00

353 lines
14 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 PensionSettlementService : ServiceTemplate
{
public PensionSettlementService()
{
}
#region Private methods
private void MapObject(PensionSettlement oPensionSettlement, DataReader oReader)
{
base.SetObjectID(oPensionSettlement, oReader.GetInt32("PensionSettlementID").Value);
oPensionSettlement.MemberID = oReader.GetInt32("MemberID").Value;
oPensionSettlement.GLTranID = oReader.GetInt32("GLTranID").Value;
oPensionSettlement.SettlementDate = oReader.GetDateTime("SettlementDate").Value;
oPensionSettlement.PensionAmount = oReader.GetDecimal("PensionAmount").Value;
oPensionSettlement.CreatedDate = oReader.GetDateTime("CreatedDate").Value;
oPensionSettlement.CreatedBy = oReader.GetInt32("CreatedBy").Value;
oPensionSettlement.ModifiedDate = oReader.GetDateTime("ModifiedDate") != null
? oReader.GetDateTime("ModifiedDate").Value
: DateTime.MinValue; //oReader.GetDateTime("ModifiedDate");
oPensionSettlement.ModifiedBy = oReader.GetInt32("ModifiedBy").Value != null
? oReader.GetInt32("ModifiedBy").Value
: (0); // oReader.GetInt32("ModifiedBy");
base.SetObjectState(oPensionSettlement, ObjectState.Saved);
}
private PensionSettlement CreateObject(DataReader oReader)
{
PensionSettlement oPensionSettlement = new PensionSettlement();
MapObject(oPensionSettlement, oReader);
return oPensionSettlement;
}
private List<PensionSettlement> CreateObjects(IDataReader oReader)
{
List<PensionSettlement> oPensionSettlements = new List<PensionSettlement>();
DataReader oreader = new DataReader(oReader);
while (oReader.Read())
{
PensionSettlement oItem = CreateObject(oreader);
oPensionSettlements.Add(oItem);
}
return oPensionSettlements;
}
#endregion Private methods
#region Service implementation
protected override T CreateObject<T>(DataReader dataReader)
{
PensionSettlement oPensionSettlement = new PensionSettlement();
MapObject(oPensionSettlement, dataReader);
return oPensionSettlement as T;
}
public PensionSettlement Get(int id)
{
PensionSettlement oPensionSettlement = new PensionSettlement();
#region Cache Header
oPensionSettlement = new PensionSettlement();
if (oPensionSettlement != null)
return oPensionSettlement;
#endregion
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin();
DataReader dr = new DataReader(PensionSettlementDA.Get(tc, id));
if (dr.Read())
{
oPensionSettlement = this.CreateObject<PensionSettlement>(dr);
}
dr.Close();
tc.End();
}
catch (Exception e)
{
#region Handle Exception
if (tc != null)
tc.HandleError();
ExceptionLog.Write(e);
throw new ServiceException("Failed to GetFinalSettlement", e);
#endregion
}
#region Cache Footer
#endregion
return oPensionSettlement;
}
public List<PensionSettlement> Get()
{
List<PensionSettlement> oPensionSettlements = new List<PensionSettlement>();
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin();
DataReader dataReader = new DataReader(PensionSettlementDA.Get(tc));
while (dataReader.Read())
{
PensionSettlement item = new PensionSettlement();
item = this.CreateObject<PensionSettlement>(dataReader);
oPensionSettlements.Add(item);
}
tc.End();
}
catch (Exception e)
{
#region Handle Exception
if (tc != null)
tc.HandleError();
ExceptionLog.Write(e);
throw new ServiceException("Failed to GetFinalSettlement", e);
#endregion
}
#region Cache Footer
#endregion
return oPensionSettlements;
}
public List<PensionSettlement> Get(string sSql)
{
List<PensionSettlement> oPensionSettlements = new List<PensionSettlement>();
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin();
DataReader dataReader = new DataReader(PensionSettlementDA.Get(tc, sSql));
while (dataReader.Read())
{
PensionSettlement item = this.CreateObject<PensionSettlement>(dataReader);
oPensionSettlements.Add(item);
}
tc.End();
}
catch (Exception e)
{
#region Handle Exception
if (tc != null)
tc.HandleError();
ExceptionLog.Write(e);
throw new ServiceException("Failed to GetFinalSettlement", e);
#endregion
}
return oPensionSettlements;
}
//public void Insert(PensionSettlement oPensionSettlement, GLTran glTran, List<MembersTransactionDetails> memberTrans, List<MemberBalaneMonthly> membersMonthlyBalances)
//{
// TransactionContext tc = null;
// Ease.Core.DataAccess.TransactionContext tc1 = null;
// try
// {
// tc = TransactionContext.Begin(true);
// tc1 = Ease.Core.DataAccess.TransactionContext.Begin(true);
// EaseFAS.Service.GLTranService glTranService = new EaseFAS.Service.GLTranService();
// MembersTransactionDetailsService meberTranDetailService = new MembersTransactionDetailsService();
// Ease.Core.Framework.ID glTranID = null;
// glTranID = glTranService.Insert(glTran, tc1);
// if (oPensionSettlement.IsNew)
// {
// oPensionSettlement.CreatedBy = User.CurrentUser.ID;
// oPensionSettlement.CreatedDate = GlobalFunctionDA.ServerDate(tc);
// int id = tc.GenerateID("PensionSettlement", "PensionSettlementID");
// base.SetObjectID(oPensionSettlement, (id));
// oPensionSettlement.GLTranID = Ease.CoreV35.Model.(glTranID);
// PensionSettlementDA.Insert(tc, oPensionSettlement);
// }
// else if (oPensionSettlement.IsModified)
// {
// oPensionSettlement.ModifiedBy = User.CurrentUser.ID;
// oPensionSettlement.ModifiedDate = new PayrollGlobalFunctionservice().GetServerDate().Date;
// PensionSettlementDA.Update(tc, oPensionSettlement);
// }
// meberTranDetailService.UploadOpeningTranForGF(tc, memberTrans, membersMonthlyBalances);
// tc.End();
// tc1.End();
// }
// catch (Exception e)
// {
// #region Handle Exception
// if (tc != null)
// tc.HandleError();
// if (tc1 != null)
// tc1.HandleError();
// ExceptionLog.Write(e);
// throw new ServiceException("Failed to Insert GF settlement: " + e.Message);
// #endregion
// }
//}
//public void Insert(PensionSettlement oPensionSettlement, GLTran glTran, GLTran glTranInterest, List<MembersTransactionDetails> memberTrans, List<MemberBalaneMonthly> membersMonthlyBalances)
//{
// TransactionContext tc = null;
// Ease.Core.DataAccess.TransactionContext tc1 = null;
// try
// {
// tc = TransactionContext.Begin(true);
// tc1 = Ease.Core.DataAccess.TransactionContext.Begin(true);
// EaseFAS.Service.GLTranService glTranService = new EaseFAS.Service.GLTranService();
// MembersTransactionDetailsService meberTranDetailService = new MembersTransactionDetailsService();
// Ease.Core.Framework.ID glTranID = null;
// Ease.Core.Framework.ID glTranInterestID = null;
// glTranID = glTranService.Insert(glTran, tc1);
// if (glTranInterest != null && glTranInterest.DebitAmount > 0)
// glTranInterestID = glTranService.Insert(glTranInterest, tc1);
// else
// glTranInterestID = Ease.Core.Framework.(0);
// if (oPensionSettlement.IsNew)
// {
// oPensionSettlement.CreatedBy = User.CurrentUser.ID;
// oPensionSettlement.CreatedDate = GlobalFunctionDA.ServerDate(tc);
// int id = tc.GenerateID("PensionSettlement", "PensionSettlementID");
// base.SetObjectID(oPensionSettlement, (id));
// oPensionSettlement.GLTranID = Ease.CoreV35.Model.(glTranID);
// PensionSettlementDA.Insert(tc, oPensionSettlement);
// }
// else if (oPensionSettlement.IsModified)
// {
// oPensionSettlement.ModifiedBy = User.CurrentUser.ID;
// oPensionSettlement.ModifiedDate = new PayrollGlobalFunctionservice().GetServerDate().Date;
// PensionSettlementDA.Update(tc, oPensionSettlement);
// }
// meberTranDetailService.UploadOpeningTranForGF(tc, memberTrans, membersMonthlyBalances);
// tc.End();
// tc1.End();
// }
// catch (Exception e)
// {
// #region Handle Exception
// if (tc != null)
// tc.HandleError();
// if (tc1 != null)
// tc1.HandleError();
// ExceptionLog.Write(e);
// throw new ServiceException("Failed to Insert GF settlement: " + e.Message);
// #endregion
// }
//}
//public void Insert(PensionSettlement oPensionSettlement)
//{
// TransactionContext tc = null;
// try
// {
// tc = TransactionContext.Begin(true);
// if (oPensionSettlement.IsNew)
// {
// oPensionSettlement.CreatedBy = User.CurrentUser.ID;
// oPensionSettlement.CreatedDate = GlobalFunctionDA.ServerDate(tc);
// int id = tc.GenerateID("PensionSettlement", "PensionSettlementID");
// base.SetObjectID(oPensionSettlement, (id));
// PensionSettlementDA.Insert(tc, oPensionSettlement);
// }
// else if (oPensionSettlement.IsModified)
// {
// oPensionSettlement.ModifiedBy = User.CurrentUser.ID;
// oPensionSettlement.ModifiedDate = new PayrollGlobalFunctionservice().GetServerDate().Date;
// PensionSettlementDA.Update(tc, oPensionSettlement);
// }
// tc.End();
// }
// catch (Exception e)
// {
// #region Handle Exception
// if (tc != null)
// tc.HandleError();
// ExceptionLog.Write(e);
// throw new ServiceException("Failed to Insert GF settlement: " + e.Message);
// #endregion
// }
//}
//public void DeleteSettlement(PensionSettlement gfSettlement)
//{
// int projectID = FM.BO.Common.User.CurrentMasterParam.ID;
// TransactionContext tc = null;
// decimal totalAmount = gfSettlement.PensionAmount;
// Ease.Core.DataAccess.TransactionContext tc1 = null;
// try
// {
// tc = TransactionContext.Begin(true);
// tc1 = Ease.Core.DataAccess.TransactionContext.Begin(true);
// EaseFAS.Service.GLTranService glTranService = new EaseFAS.Service.GLTranService();
// glTranService.Delete(tc1, Ease.Core.Framework.(gfSettlement.GLTranID));
// MembersTransactionDetailsDA.DeleteGFMemberSettlement(tc, gfSettlement.MemberID, gfSettlement.SettlementDate.Date, gfSettlement.PensionAmount, projectID);
// MemberBalaneMonthlyDA.DeleteGFSettlementData(tc, gfSettlement.MemberID, gfSettlement.SettlementDate.Date, projectID, totalAmount);
// PensionSettlementDA.Delete(tc, gfSettlement.ID);
// tc.End();
// tc1.End();
// }
// catch (Exception e)
// {
// #region Handle Exception
// if (tc != null)
// tc.HandleError();
// if (tc1 != null)
// tc1.HandleError();
// ExceptionLog.Write(e);
// throw new ServiceException("Failed to Delete PensionSettlement" + e.Message);
// #endregion
// }
//}
#endregion Service implementation
}
}