230 lines
7.6 KiB
C#
230 lines
7.6 KiB
C#
|
using System;
|
|||
|
using System.Collections.Generic;
|
|||
|
using System.Linq;
|
|||
|
using System.Text;
|
|||
|
using Payroll.BO;
|
|||
|
using Ease.CoreV35.DataAccess;
|
|||
|
using Ease.Core.Model;
|
|||
|
using Ease.Core.Utility;
|
|||
|
using Ease.Core.DataAccess;
|
|||
|
using HRM.BO;
|
|||
|
|
|||
|
namespace Payroll.Service
|
|||
|
{
|
|||
|
[Serializable]
|
|||
|
public class ClaimPaymentDetailService : ServiceTemplate, IClaimPaymentDetailService
|
|||
|
{
|
|||
|
#region Constructor
|
|||
|
public ClaimPaymentDetailService()
|
|||
|
{
|
|||
|
|
|||
|
}
|
|||
|
#endregion
|
|||
|
|
|||
|
#region Map Object
|
|||
|
private void MapObject(ClaimPaymentDetail oClaimPaymentDetail, DataReader oReader)
|
|||
|
{
|
|||
|
base.SetObjectID(oClaimPaymentDetail, oReader.GetInt32("ClaimPaymentDetailID").Value);
|
|||
|
oClaimPaymentDetail.ClaimID = oReader.GetString("ClaimID") == null ? 0 : oReader.GetInt32("ClaimID").Value;
|
|||
|
oClaimPaymentDetail.ClaimPaymentID = oReader.GetString("ClaimPaymentNewID") == null ? 0 : oReader.GetInt32("ClaimPaymentNewID").Value;
|
|||
|
this.SetObjectState(oClaimPaymentDetail, Ease.Core.ObjectState.Saved);
|
|||
|
}
|
|||
|
|
|||
|
protected override T CreateObject<T>(DataReader oReader)
|
|||
|
{
|
|||
|
ClaimPaymentDetail oClaimPaymentDetailNew = new ClaimPaymentDetail();
|
|||
|
MapObject(oClaimPaymentDetailNew, oReader);
|
|||
|
return oClaimPaymentDetailNew as T;
|
|||
|
}
|
|||
|
protected ClaimPaymentDetail CreateObject(DataReader oReader)
|
|||
|
{
|
|||
|
ClaimPaymentDetail oClaimPaymentDetailNew = new ClaimPaymentDetail();
|
|||
|
MapObject(oClaimPaymentDetailNew, oReader);
|
|||
|
return oClaimPaymentDetailNew;
|
|||
|
}
|
|||
|
#endregion
|
|||
|
|
|||
|
#region Service implementation
|
|||
|
|
|||
|
public List<ClaimPaymentDetail> GetByClaimPaymentNewID(int id)
|
|||
|
{
|
|||
|
List<ClaimPaymentDetail> oClaimPaymentDetails =new List<ClaimPaymentDetail>();
|
|||
|
|
|||
|
TransactionContext tc = null;
|
|||
|
try
|
|||
|
{
|
|||
|
tc = TransactionContext.Begin();
|
|||
|
DataReader oreader = new DataReader(ClaimPaymentDetailDA.GetByClaimPaymentNewID(tc, id));
|
|||
|
oClaimPaymentDetails = this.CreateObjects<ClaimPaymentDetail>(oreader);
|
|||
|
oreader.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 oClaimPaymentDetails;
|
|||
|
}
|
|||
|
public ClaimPaymentDetail Get(int id)
|
|||
|
{
|
|||
|
ClaimPaymentDetail oClaimPaymentDetail = new ClaimPaymentDetail();
|
|||
|
|
|||
|
TransactionContext tc = null;
|
|||
|
try
|
|||
|
{
|
|||
|
tc = TransactionContext.Begin();
|
|||
|
DataReader oreader = new DataReader(ClaimPaymentDetailDA.Get(tc, id));
|
|||
|
if (oreader.Read())
|
|||
|
{
|
|||
|
oClaimPaymentDetail = this.CreateObject<ClaimPaymentDetail>(oreader);
|
|||
|
}
|
|||
|
oreader.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 oClaimPaymentDetail;
|
|||
|
}
|
|||
|
|
|||
|
public List<ClaimPaymentDetail> Get(EnumStatus status, int payrollTypeID)
|
|||
|
{
|
|||
|
#region Cache Header
|
|||
|
List<ClaimPaymentDetail> attnNationalHolidays = null;
|
|||
|
//if (attnNationalHolidays != null)
|
|||
|
// return attnNationalHolidays;
|
|||
|
#endregion
|
|||
|
TransactionContext tc = null;
|
|||
|
try
|
|||
|
{
|
|||
|
tc = TransactionContext.Begin();
|
|||
|
DataReader dr = new DataReader(ClaimPaymentDetailDA.Get(tc, status, payrollTypeID));
|
|||
|
attnNationalHolidays = this.CreateObjects<ClaimPaymentDetail>(dr);
|
|||
|
|
|||
|
dr.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 attnNationalHolidays;
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
public void Save(List<ClaimPaymentDetail> oClaimPaymentDetails)
|
|||
|
{
|
|||
|
TransactionContext tc = null;
|
|||
|
try
|
|||
|
{
|
|||
|
tc = TransactionContext.Begin(true);
|
|||
|
int ClaimPaymentDetailID = tc.GenerateID("ClaimPaymentDetail", "ClaimPaymentDetailID");
|
|||
|
int ClaimPaymentDetailGradesID = tc.GenerateID("ClaimPaymentDetailGrades", "ClaimPaymentDetailGradesID");
|
|||
|
foreach (ClaimPaymentDetail oClaimPaymentDetail in oClaimPaymentDetails)
|
|||
|
{
|
|||
|
if (oClaimPaymentDetail.IsNew)
|
|||
|
{
|
|||
|
base.SetObjectID(oClaimPaymentDetail, ClaimPaymentDetailID);
|
|||
|
ClaimPaymentDetailDA.Insert(tc, oClaimPaymentDetail);
|
|||
|
ClaimPaymentDetailID++;
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
ClaimPaymentDetailDA.Update(tc, oClaimPaymentDetail);
|
|||
|
ClaimPaymentDetailDA.DeleteChild(tc, oClaimPaymentDetail.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 int Save(ClaimPaymentDetail oClaimPaymentDetail)
|
|||
|
{
|
|||
|
TransactionContext tc = null;
|
|||
|
try
|
|||
|
{
|
|||
|
tc = TransactionContext.Begin(true);
|
|||
|
if (oClaimPaymentDetail.IsNew)
|
|||
|
{
|
|||
|
int id = tc.GenerateID("ClaimPaymentDetail", "ClaimPaymentDetailID");
|
|||
|
base.SetObjectID(oClaimPaymentDetail, id);
|
|||
|
ClaimPaymentDetailDA.Insert(tc, oClaimPaymentDetail);
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
ClaimPaymentDetailDA.Update(tc, oClaimPaymentDetail);
|
|||
|
ClaimPaymentDetailDA.DeleteChild(tc, oClaimPaymentDetail.ID);
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
|
|||
|
tc.End();
|
|||
|
return oClaimPaymentDetail.ID;
|
|||
|
}
|
|||
|
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);
|
|||
|
ClaimPaymentDetailDA.Delete(tc, id);
|
|||
|
|
|||
|
tc.End();
|
|||
|
}
|
|||
|
catch (Exception e)
|
|||
|
{
|
|||
|
#region Handle Exception
|
|||
|
if (tc != null)
|
|||
|
tc.HandleError();
|
|||
|
ExceptionLog.Write(e);
|
|||
|
throw new ServiceException(e.Message, e);
|
|||
|
#endregion
|
|||
|
}
|
|||
|
}
|
|||
|
#endregion
|
|||
|
}
|
|||
|
}
|