467 lines
18 KiB
C#
467 lines
18 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 FinalSettlementService : ServiceTemplate,IFinalSettlementService
|
|
{
|
|
public FinalSettlementService()
|
|
{
|
|
}
|
|
|
|
#region Private methods
|
|
|
|
private void MapObject(FinalSettlement oFinalSettlement, DataReader oReader)
|
|
{
|
|
base.SetObjectID(oFinalSettlement, oReader.GetInt32("FinalSettlementID").Value);
|
|
|
|
//BusinessObject.Factory.SetID(oFinalSettlement, new ID(oReader.Getint("FinalSettlementID")));
|
|
|
|
oFinalSettlement.MemberID = oReader.GetInt32("MemberID").Value;
|
|
oFinalSettlement.EmpCode = oReader.GetString("EmpCode");
|
|
oFinalSettlement.SettlementDate = oReader.GetDateTime("SettlementDate").Value;
|
|
oFinalSettlement.TotalPayment = oReader.GetDecimal("TotalPayment").Value;
|
|
oFinalSettlement.PaymentMode = oReader.GetString("PaymentMode");
|
|
oFinalSettlement.CreatedDate = oReader.GetDateTime("CreatedDate").Value;
|
|
oFinalSettlement.CreatedBy = oReader.GetInt32("CreatedBy").Value;
|
|
oFinalSettlement.ModifiedDate = oReader.GetDateTime("ModifiedDate") != null
|
|
? oReader.GetDateTime("ModifiedDate").Value
|
|
: DateTime.MinValue; //oReader.GetDateTime("ModifiedDate");
|
|
oFinalSettlement.ModifiedBy = oReader.GetInt32("ModifiedBy").Value != null
|
|
? oReader.GetInt32("ModifiedBy").Value
|
|
: (0); // oReader.GetInt32("ModifiedBy");
|
|
oFinalSettlement.GLTranID = oReader.GetInt32("GLTranID").Value;
|
|
oFinalSettlement.LastAudCPF = oReader.GetDecimal("LastAudCPF").GetValueOrDefault();
|
|
oFinalSettlement.LastAudEPF = oReader.GetDecimal("LastAudEPF").GetValueOrDefault();
|
|
oFinalSettlement.LastAudCPFInterest = oReader.GetDecimal("LastAudCPFInterest").GetValueOrDefault();
|
|
oFinalSettlement.LastAudEPFInterest = oReader.GetDecimal("LastAudEPFInterest").GetValueOrDefault();
|
|
oFinalSettlement.LastAudCurrentEPFInterest =
|
|
oReader.GetDecimal("LastAudCurrentEPFInterest").GetValueOrDefault();
|
|
oFinalSettlement.LastAudCurrentCPFInterest =
|
|
oReader.GetDecimal("LastAudCurrentCPFInterest").GetValueOrDefault();
|
|
oFinalSettlement.CurrYearEPF = oReader.GetDecimal("CurrYearEPF").GetValueOrDefault();
|
|
oFinalSettlement.CurrYearCPF = oReader.GetDecimal("CurrYearCPF").GetValueOrDefault();
|
|
oFinalSettlement.CurrYearEPFInterest = oReader.GetDecimal("CurrYearEPFInterest").GetValueOrDefault();
|
|
oFinalSettlement.CurrYearCPFInterest = oReader.GetDecimal("CurrYearCPFInterest").GetValueOrDefault();
|
|
oFinalSettlement.CurrYearInterestPercent =
|
|
oReader.GetDecimal("CurrYearInterestPercent").GetValueOrDefault();
|
|
base.SetObjectState(oFinalSettlement, ObjectState.Saved);
|
|
//BusinessObject.Factory.SetObjectState(oFinalSettlement, ObjectState.Saved);
|
|
}
|
|
|
|
private FinalSettlement CreateObject(DataReader oReader)
|
|
{
|
|
FinalSettlement oFinalSettlement = new FinalSettlement();
|
|
MapObject(oFinalSettlement, oReader);
|
|
return oFinalSettlement;
|
|
}
|
|
|
|
private List<FinalSettlement> CreateObjects(IDataReader oReader)
|
|
{
|
|
List<FinalSettlement> oFinalSettlements = new List<FinalSettlement>();
|
|
DataReader oreader = new DataReader(oReader);
|
|
while (oReader.Read())
|
|
{
|
|
FinalSettlement oItem = CreateObject(oreader);
|
|
oFinalSettlements.Add(oItem);
|
|
}
|
|
|
|
return oFinalSettlements;
|
|
}
|
|
|
|
#endregion Private methods
|
|
|
|
|
|
#region Service implementation
|
|
|
|
protected override T CreateObject<T>(DataReader dataReader)
|
|
{
|
|
FinalSettlement oFinalSettlement = new FinalSettlement();
|
|
|
|
MapObject(oFinalSettlement, dataReader);
|
|
|
|
return oFinalSettlement as T;
|
|
}
|
|
|
|
public FinalSettlement Get(int id)
|
|
{
|
|
FinalSettlement oFinalSettlement = new FinalSettlement();
|
|
|
|
#region Cache Header
|
|
|
|
oFinalSettlement = new FinalSettlement();
|
|
if (oFinalSettlement != null)
|
|
return oFinalSettlement;
|
|
|
|
#endregion
|
|
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin();
|
|
DataReader dr = new DataReader(FinalSettlementDA.Get(tc, id));
|
|
if (dr.Read())
|
|
{
|
|
oFinalSettlement = this.CreateObject<FinalSettlement>(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 oFinalSettlement;
|
|
}
|
|
|
|
public List<FinalSettlement> Get()
|
|
{
|
|
List<FinalSettlement> oFinalSettlements = new List<FinalSettlement>();
|
|
//#region Cache Header
|
|
//oFinalSettlements = (List<FinalSettlement>)_cache["Get"];
|
|
//if (oFinalSettlements != null)
|
|
// return oFinalSettlements;
|
|
//#endregion
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin();
|
|
|
|
DataReader dataReader = new DataReader(FinalSettlementDA.Get(tc));
|
|
while (dataReader.Read())
|
|
{
|
|
FinalSettlement item = new FinalSettlement();
|
|
item = this.CreateObject<FinalSettlement>(dataReader);
|
|
oFinalSettlements.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 oFinalSettlements;
|
|
}
|
|
|
|
public List<FinalSettlement> Get(string sSql)
|
|
{
|
|
List<FinalSettlement> oFinalSettlements = new List<FinalSettlement>();
|
|
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin();
|
|
|
|
DataReader dataReader = new DataReader(FinalSettlementDA.Get(tc, sSql));
|
|
while (dataReader.Read())
|
|
{
|
|
FinalSettlement item = this.CreateObject<FinalSettlement>(dataReader);
|
|
oFinalSettlements.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 oFinalSettlements;
|
|
}
|
|
|
|
public void Save(FinalSettlement oFinalSettlement)
|
|
{
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin(true);
|
|
if (oFinalSettlement.IsNew)
|
|
{
|
|
oFinalSettlement.CreatedBy = oFinalSettlement.CreatedBy;
|
|
oFinalSettlement.CreatedDate = DateTime.Now;
|
|
|
|
int id = tc.GenerateID("FinalSettlement", "FinalSettlementID");
|
|
base.SetObjectID(oFinalSettlement, (id));
|
|
FinalSettlementDA.Insert(tc, oFinalSettlement);
|
|
}
|
|
else
|
|
{
|
|
oFinalSettlement.ModifiedBy = oFinalSettlement.ModifiedBy;
|
|
oFinalSettlement.ModifiedDate = DateTime.Now;
|
|
FinalSettlementDA.Update(tc, oFinalSettlement);
|
|
}
|
|
|
|
tc.End();
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
#region Handle Exception
|
|
|
|
if (tc != null)
|
|
tc.HandleError();
|
|
ExceptionLog.Write(e);
|
|
throw new ServiceException("Failed to GetFinalSettlement", e);
|
|
|
|
#endregion
|
|
}
|
|
}
|
|
|
|
internal void Save(TransactionContext tc, FinalSettlement oFinalSettlement)
|
|
{
|
|
try
|
|
{
|
|
if (oFinalSettlement.IsNew)
|
|
{
|
|
oFinalSettlement.CreatedBy = oFinalSettlement.CreatedBy;
|
|
oFinalSettlement.CreatedDate = DateTime.Now;
|
|
|
|
int id = tc.GenerateID("FinalSettlement", "FinalSettlementID");
|
|
base.SetObjectID(oFinalSettlement, (id));
|
|
FinalSettlementDA.Insert(tc, oFinalSettlement);
|
|
}
|
|
else
|
|
{
|
|
oFinalSettlement.ModifiedBy = oFinalSettlement.ModifiedBy;
|
|
oFinalSettlement.ModifiedDate = DateTime.Now;
|
|
FinalSettlementDA.Update(tc, oFinalSettlement);
|
|
}
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
#region Handle Exception
|
|
|
|
if (tc != null)
|
|
tc.HandleError();
|
|
ExceptionLog.Write(e);
|
|
throw new ServiceException("Failed to Insert Final settlement: " + e.Message);
|
|
|
|
#endregion
|
|
}
|
|
}
|
|
|
|
public List<FinalSettlementClerance> GetClearanceNotifications(int regEmpId)
|
|
{
|
|
List<FinalSettlementClerance> oFinalSettlementClearance = new List<FinalSettlementClerance>();
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin();
|
|
DataReader oreader = new DataReader(FinalSettlementDA.GetClearanceNotifications(tc, regEmpId));
|
|
while (oreader.Read())
|
|
{
|
|
FinalSettlementClerance oFileSettlement = new FinalSettlementClerance();
|
|
oFileSettlement.EmployeeId = oreader.GetInt32("EMPLOYEEID").Value;
|
|
oFileSettlement.EmployeeNo = oreader.GetString("EmployeeNo");
|
|
oFileSettlement.EmployeeName = oreader.GetString("EmployeeName");
|
|
oFileSettlement.ClearanceDate = oreader.GetDateTime("ClearanceDate",DateTime.MinValue);
|
|
oFileSettlement.SendDate = oreader.GetDateTime("SentDate", DateTime.MinValue);
|
|
oFileSettlement.SettlementClearanceStatus = (EnumSettlementClearanceStatus)oreader.GetInt32("SettlementClearanceStatus").GetValueOrDefault();
|
|
oFileSettlement.ClearanceStatus = ((EnumSettlementClearanceStatus)oreader.GetInt32("SettlementClearanceStatus").GetValueOrDefault()).ToString();
|
|
oFileSettlement.FsHeadName = oreader.GetString("Name", null);
|
|
oFinalSettlementClearance.Add(oFileSettlement);
|
|
}
|
|
oreader.Close();
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
#region Handle Exception
|
|
|
|
if (tc != null)
|
|
tc.HandleError();
|
|
ExceptionLog.Write(ex);
|
|
throw new ServiceException("Failed to Get IRNotifications: " + ex.Message, ex);
|
|
|
|
#endregion
|
|
}
|
|
|
|
return oFinalSettlementClearance;
|
|
}
|
|
|
|
//public void Insert(FinalSettlement finalSettlement, Member member, List<MembersTransactionDetails> memberTransactionDetails, List<Loan> loanCollection, List<LoanLog> loanLogCollection, GLTran glTran, GLTran newglTran)
|
|
//{
|
|
// TransactionContext tc = null;
|
|
// try
|
|
// {
|
|
// MemberService memberService = new MemberService();
|
|
// MembersTransactionDetailsService memberTransactionService = new MembersTransactionDetailsService();
|
|
// LoanService loanService = new LoanService();
|
|
// EaseFAS.Service.GLTranService glTranService = new EaseFAS.Service.GLTranService();
|
|
|
|
// tc = TransactionContext.Begin(true);
|
|
// this.Insert(tc, finalSettlement);
|
|
// memberService.UpdateSettlement(tc,member);
|
|
// memberTransactionService.SaveFinalSettlement(tc, memberTransactionDetails);
|
|
// int logCounter = 0;
|
|
// foreach (Loan loan in loanCollection)
|
|
// {
|
|
// loanService.SaveEarlySettlement(tc, loan, loanLogCollection[logCounter]);
|
|
// logCounter++;
|
|
// }
|
|
// Ease.Core.DataAccess.TransactionContext coretc = Ease.Core.DataAccess.TransactionContext.SetConnection(tc.Connection, tc.Transaction);
|
|
// GLTrans otrans = new GLTrans();
|
|
// otrans.Add(glTran);
|
|
// otrans.Add(newglTran);
|
|
// glTranService.Insert(coretc, otrans);
|
|
// //memberTransactionService.UpdateMemberBalance(tc, memberTransactionDetails,otrans[0].VoucherNo);
|
|
// FinalSettlementDA.UpdateGLTranID(tc, finalSettlement.ID, otrans[0].ID);
|
|
// tc.End();
|
|
// }
|
|
// catch (ServiceException e)
|
|
// {
|
|
// if (tc != null)
|
|
// tc.HandleError();
|
|
// ExceptionLog.Write(e);
|
|
// throw new ServiceException(e.Message, e);
|
|
// }
|
|
//}
|
|
|
|
//public void Insert(FinalSettlement finalSettlement, Member member, List<MembersTransactionDetails> memberTransactionDetails, List<Loan> loanCollection, List<LoanLog> loanLogCollection, GLTran glTran)
|
|
//{
|
|
// TransactionContext tc = null;
|
|
// try
|
|
// {
|
|
// MemberService memberService = new MemberService();
|
|
// MembersTransactionDetailsService memberTransactionService = new MembersTransactionDetailsService();
|
|
// LoanService loanService = new LoanService();
|
|
// EaseFAS.Service.GLTranService glTranService = new EaseFAS.Service.GLTranService();
|
|
|
|
// tc = TransactionContext.Begin(true);
|
|
// this.Insert(tc, finalSettlement);
|
|
// memberService.UpdateSettlement(tc, member);
|
|
// memberTransactionService.SaveFinalSettlement(tc, memberTransactionDetails);
|
|
// int logCounter = 0;
|
|
// foreach (Loan loan in loanCollection)
|
|
// {
|
|
// loanService.SaveEarlySettlement(tc, loan, loanLogCollection[logCounter]);
|
|
// logCounter++;
|
|
// }
|
|
// Ease.Core.DataAccess.TransactionContext coretc = Ease.Core.DataAccess.TransactionContext.SetConnection(tc.Connection, tc.Transaction);
|
|
// GLTrans otrans = new GLTrans();
|
|
// otrans.Add(glTran);
|
|
// glTranService.Insert(coretc, otrans);
|
|
// //memberTransactionService.UpdateMemberBalance(tc, memberTransactionDetails,otrans[0].VoucherNo);
|
|
// FinalSettlementDA.UpdateGLTranID(tc, finalSettlement.ID, otrans[0].ID);
|
|
// tc.End();
|
|
// }
|
|
// catch (ServiceException e)
|
|
// {
|
|
// if (tc != null)
|
|
// tc.HandleError();
|
|
// ExceptionLog.Write(e);
|
|
// throw new ServiceException(e.Message, e);
|
|
// }
|
|
//}
|
|
|
|
//public void DeleteSettlement(int settlementID, Member _member, List<Loan> _loanCollection, GLTran _glTran, List<MembersTransactionDetails> _details)
|
|
//{
|
|
// TransactionContext tc = null;
|
|
// EaseFAS.Service.GLTranService glTranService = new EaseFAS.Service.GLTranService();
|
|
// LoanService loanService = new LoanService();
|
|
// MemberService memberService = new MemberService();
|
|
// MembersTransactionDetailsService memberTransactionService = new MembersTransactionDetailsService();
|
|
// try
|
|
// {
|
|
// tc = TransactionContext.Begin(true);
|
|
|
|
// Ease.Core.DataAccess.TransactionContext coretc = Ease.Core.DataAccess.TransactionContext.SetConnection(tc.Connection, tc.Transaction);
|
|
// GLTrans otrans = new GLTrans();
|
|
// otrans.Add(_glTran);
|
|
// glTranService.Delete(coretc, _glTran.ID);
|
|
// //foreach(Loan loan in _loanCollection)
|
|
// //{
|
|
// // loanService.Delete(tc,loan);
|
|
// //}
|
|
// memberService.UpdateSettlement(tc,_member);
|
|
// memberTransactionService.DeleteMemberTran(tc, _details);
|
|
// FinalSettlementDA.Delete(tc,settlementID);
|
|
// tc.End();
|
|
|
|
// }
|
|
// catch (Exception e)
|
|
// {
|
|
// #region Handle Exception
|
|
// if (tc != null)
|
|
// tc.HandleError();
|
|
// ExceptionLog.Write(e);
|
|
// throw new ServiceException("Failed to Delete MembersTransactionDetails", e);
|
|
// #endregion
|
|
// }
|
|
//}
|
|
|
|
//public DataTable GetCPFContributionData()
|
|
//{
|
|
// DataTable dCpFContris = new DataTable();
|
|
// #region Cache Header
|
|
// dCpFContris = (DataTable)_cache["GetCPFContributionData"];
|
|
// if (dCpFContris != null)
|
|
// return dCpFContris;
|
|
// #endregion
|
|
// TransactionContext tc = null;
|
|
// try
|
|
// {
|
|
// tc = TransactionContext.Begin();
|
|
|
|
// dCpFContris = FinalSettlementDA.GetCPFContributionData(tc);
|
|
|
|
// tc.End();
|
|
// }
|
|
// catch (Exception e)
|
|
// {
|
|
// #region Handle Exception
|
|
// if (tc != null)
|
|
// tc.HandleError();
|
|
// ExceptionLog.Write(e);
|
|
// throw new ServiceException("Failed to CPFContribution", e);
|
|
// #endregion
|
|
// }
|
|
// #region Cache Footer
|
|
|
|
// #endregion
|
|
// return dCpFContris;
|
|
//}
|
|
|
|
#endregion Service implementation
|
|
}
|
|
} |