297 lines
9.5 KiB
C#
297 lines
9.5 KiB
C#
using System;
|
|
using System.Data;
|
|
using System.Linq;
|
|
using Ease.CoreV35;
|
|
using Ease.CoreV35.DataAccess;
|
|
using System.Collections.Generic;
|
|
using Payroll.BO;
|
|
using Ease.Core.Model;
|
|
using HRM.BO;
|
|
using Ease.Core.DataAccess;
|
|
using Ease.Core.Utility;
|
|
|
|
namespace Payroll.Service
|
|
{
|
|
#region ClaimBasicItemService
|
|
public class ClaimBasicItemService : ServiceTemplate, IClaimBasicItemService
|
|
{
|
|
public ClaimBasicItemService()
|
|
{
|
|
}
|
|
|
|
private void MapObject(ClaimBasicItem oClaimBasicItem, DataReader oReader)
|
|
{
|
|
base.SetObjectID(oClaimBasicItem,oReader.GetInt32("ClaimBasicItemID").Value);
|
|
oClaimBasicItem.ClaimBasicID = oReader.GetInt32("ClaimBasicID").Value;
|
|
oClaimBasicItem.Name = oReader.GetString("Name");
|
|
oClaimBasicItem.Serial = (int)oReader.GetInt32("Serial");
|
|
//oClaimBasic.Status = (EnumStatus)oReader.GetInt32("Status").Value;
|
|
//oClaimBasic.ClaimType = (EnumClaimType)oReader.GetInt32("ClaimType").Value;
|
|
oClaimBasicItem.IsFamilyMemberNeeded= oReader.GetBoolean("IsFamilyMemberNeeded", false);
|
|
oClaimBasicItem.MonthlyOnce = oReader.GetBoolean("MonthlyOnce", false);
|
|
oClaimBasicItem.FixedAmount = oReader.GetDouble("FixedAmount", 0);
|
|
oClaimBasicItem.GlCode = oReader.GetString("GlCode");
|
|
oClaimBasicItem.GlSide = oReader.GetString("GlSide");
|
|
oClaimBasicItem.GlSideCode = oReader.GetString("GlSideCode");
|
|
oClaimBasicItem.CreatedBy = oReader.GetString("CreatedBy") == null ? 0 : oReader.GetInt32("CreatedBy").Value;
|
|
oClaimBasicItem.CreatedDate = oReader.GetDateTime("CreatedDate").Value;
|
|
oClaimBasicItem.ModifiedBy = oReader.GetString("ModifiedBy") == null ? 0 : oReader.GetInt32("ModifiedBy").Value;
|
|
oClaimBasicItem.ModifiedDate = oReader.GetDateTime("ModifiedDate");
|
|
oClaimBasicItem.IsAttachment = oReader.GetBoolean("IsAttachment", true,false);
|
|
this.SetObjectState(oClaimBasicItem, Ease.Core.ObjectState.Saved);
|
|
}
|
|
|
|
protected override T CreateObject<T>(DataReader oReader)
|
|
{
|
|
ClaimBasicItem oClaimBasicItem = new ClaimBasicItem();
|
|
MapObject(oClaimBasicItem, oReader);
|
|
return oClaimBasicItem as T;
|
|
}
|
|
|
|
#region Service implementation
|
|
|
|
public ClaimBasicItem Get(int id)
|
|
{
|
|
ClaimBasicItem oClaimBasicItem = new ClaimBasicItem();
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin();
|
|
DataReader oreader = new DataReader(ClaimBasicItemDA.Get(tc, id));
|
|
if (oreader.Read())
|
|
{
|
|
oClaimBasicItem = this.CreateObject<ClaimBasicItem>(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 oClaimBasicItem;
|
|
}
|
|
|
|
public List<ClaimBasicItem> Get()
|
|
{
|
|
List<ClaimBasicItem> claimBasicItems = new List<ClaimBasicItem>();
|
|
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin();
|
|
|
|
DataReader dr = new DataReader(ClaimBasicItemDA.Get(tc));
|
|
claimBasicItems = this.CreateObjects<ClaimBasicItem>(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 claimBasicItems;
|
|
}
|
|
|
|
public List<ClaimBasicItem> GetByClaimBasicID(int claimBasicID)
|
|
{
|
|
#region Cache Header
|
|
|
|
List<ClaimBasicItem> claimBasicItems = new List<ClaimBasicItem>();
|
|
//if (claimBasicItems != null)
|
|
// return claimBasicItems;
|
|
|
|
#endregion
|
|
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin();
|
|
|
|
DataReader dr = new DataReader(ClaimBasicItemDA.GetByClaimBasicID(tc, claimBasicID));
|
|
claimBasicItems = this.CreateObjects<ClaimBasicItem>(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 claimBasicItems;
|
|
}
|
|
|
|
public void Save(List<ClaimBasicItem> oClaimBasicItems)
|
|
{
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin(true);
|
|
int id = tc.GenerateID("ClaimBasicItem", "ClaimBasicItemID");
|
|
foreach (ClaimBasicItem oClaimBasicItem in oClaimBasicItems)
|
|
{
|
|
if (oClaimBasicItem.IsNew)
|
|
{
|
|
base.SetObjectID(oClaimBasicItem, id);
|
|
ClaimBasicItemDA.Insert(tc, oClaimBasicItem);
|
|
id++;
|
|
}
|
|
else
|
|
{
|
|
ClaimBasicItemDA.Update(tc, oClaimBasicItem);
|
|
}
|
|
}
|
|
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(ClaimBasicItem oClaimBasicItem)
|
|
{
|
|
TransactionContext tc = null;
|
|
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin(true);
|
|
if (oClaimBasicItem.IsNew)
|
|
{
|
|
int id = tc.GenerateID("ClaimBasicItem", "ClaimBasicItemID");
|
|
base.SetObjectID(oClaimBasicItem, id);
|
|
ClaimBasicItemDA.Insert(tc, oClaimBasicItem);
|
|
}
|
|
else
|
|
{
|
|
ClaimBasicItemDA.Update(tc, oClaimBasicItem);
|
|
}
|
|
tc.End();
|
|
return oClaimBasicItem.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);
|
|
ClaimBasicItemDA.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
|
|
}
|
|
}
|
|
|
|
public void DeleteByClaimBasicID(int id)
|
|
{
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin(true);
|
|
ClaimBasicItemDA.DeleteByClaimBasicID(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
|
|
|
|
internal void Save(TransactionContext tc, List<ClaimBasicItem> oClaimBasicItems)
|
|
{
|
|
try
|
|
{
|
|
int id = tc.GenerateID("ClaimBasicItem", "ClaimBasicItemID");
|
|
|
|
foreach (ClaimBasicItem oClaimBasicItem in oClaimBasicItems)
|
|
{
|
|
if (oClaimBasicItem.IsNew)
|
|
{
|
|
base.SetObjectID(oClaimBasicItem, id);
|
|
//oClaimBasicItem.CreatedBy = User.CurrentUser.ID;
|
|
oClaimBasicItem.CreatedDate = DateTime.Today;
|
|
ClaimBasicItemDA.Insert(tc, oClaimBasicItem);
|
|
id++;
|
|
}
|
|
else
|
|
{
|
|
//oClaimBasicItem.ModifiedBy = User.CurrentUser.ID;
|
|
oClaimBasicItem.ModifiedDate = DateTime.Today;
|
|
|
|
ClaimBasicItemDA.Update(tc, oClaimBasicItem);
|
|
}
|
|
}
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
#region Handle Exception
|
|
if (tc != null)
|
|
tc.HandleError();
|
|
ExceptionLog.Write(e);
|
|
throw new ServiceException(e.Message, e);
|
|
#endregion
|
|
}
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
}
|