240 lines
7.6 KiB
C#
240 lines
7.6 KiB
C#
using System;
|
|
using System.Data;
|
|
using System.Linq;
|
|
using Ease.CoreV35;
|
|
using Ease.CoreV35.Model;
|
|
using Ease.CoreV35.DataAccess;
|
|
using System.Collections.Generic;
|
|
using Payroll.BO;
|
|
using Ease.CoreV35.Caching;
|
|
|
|
namespace Payroll.Service
|
|
{
|
|
#region ITEmpHead Service
|
|
[Serializable]
|
|
public class ITEmpHeadService : ServiceTemplate, IITEmpHeadService
|
|
{
|
|
#region Private functions and declaration
|
|
Cache _cache = new Cache(typeof(ITEmpHead));
|
|
|
|
#endregion
|
|
public ITEmpHeadService() { }
|
|
|
|
private void MapObject(ITEmpHead oITEmpHead, DataReader oReader)
|
|
{
|
|
base.SetObjectID(oITEmpHead, oReader.GetID("ITEMPHEADID"));
|
|
oITEmpHead.EmployeeID = oReader.GetID("employeeID");
|
|
oITEmpHead.HeadID = (EnumIncomeTaxHead)oReader.GetInt32("HEADID");
|
|
oITEmpHead.StartDate = oReader.GetDateTime("STARTDATE").Value;
|
|
oITEmpHead.EndDate = oReader.GetDateTime("ENDDATE").Value;
|
|
oITEmpHead.HouseRent = oReader.GetDouble("HOUSERENT").Value;
|
|
oITEmpHead.CreatedBy = oReader.GetID("CreatedBy");
|
|
oITEmpHead.CreatedDate = oReader.GetDateTime("CreationDate").Value;
|
|
oITEmpHead.ModifiedBy = oReader.GetID("ModifiedBy");
|
|
oITEmpHead.ModifiedDate = oReader.GetDateTime("ModifiedDate");
|
|
oITEmpHead.TaxparamID = oReader.GetID("TaxparamID");
|
|
oITEmpHead.IsArrear = oReader.GetInt16("IsArrear").Value;
|
|
this.SetObjectState(oITEmpHead, Ease.CoreV35.ObjectState.Saved);
|
|
}
|
|
protected override T CreateObject<T>(DataReader oReader)
|
|
{
|
|
ITEmpHead oITEmpHead = new ITEmpHead();
|
|
MapObject(oITEmpHead, oReader);
|
|
return oITEmpHead as T;
|
|
}
|
|
protected ITEmpHead CreateObject(DataReader oReader)
|
|
{
|
|
ITEmpHead oITEmpHead = new ITEmpHead();
|
|
MapObject(oITEmpHead, oReader);
|
|
return oITEmpHead;
|
|
}
|
|
#region Service implementation
|
|
public ITEmpHead Get(ID id)
|
|
{
|
|
ITEmpHead oITEmpHead = new ITEmpHead();
|
|
#region Cache Header
|
|
oITEmpHead = _cache["Get", id] as ITEmpHead;
|
|
if (oITEmpHead != null)
|
|
return oITEmpHead;
|
|
#endregion
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin();
|
|
DataReader oreader = new DataReader(ITEmpHeadDA.Get(tc, id));
|
|
if (oreader.Read())
|
|
{
|
|
oITEmpHead = this.CreateObject<ITEmpHead>(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
|
|
}
|
|
#region Cache Footer
|
|
_cache.Add(oITEmpHead, "Get", id);
|
|
#endregion
|
|
return oITEmpHead;
|
|
}
|
|
public ITEmpHead Get(int nEmpID, int taxparamID)
|
|
{
|
|
ITEmpHead oITEmpHead = new ITEmpHead();
|
|
#region Cache Header
|
|
oITEmpHead = _cache["Get", nEmpID, taxparamID] as ITEmpHead;
|
|
if (oITEmpHead != null)
|
|
return oITEmpHead;
|
|
#endregion
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin();
|
|
DataReader oreader = new DataReader(ITEmpHeadDA.Get(tc, nEmpID, taxparamID));
|
|
if (oreader.Read())
|
|
{
|
|
oITEmpHead = this.CreateObject<ITEmpHead>(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
|
|
}
|
|
#region Cache Footer
|
|
_cache.Add(oITEmpHead, "Get", nEmpID, taxparamID);
|
|
#endregion
|
|
return oITEmpHead;
|
|
}
|
|
|
|
public ObjectsTemplate<ITEmpHead> Get(int taxparamID)
|
|
{
|
|
#region Cache Header
|
|
|
|
ObjectsTemplate<ITEmpHead> ITEmpHeads = _cache["Get",taxparamID] as ObjectsTemplate<ITEmpHead>;
|
|
if (ITEmpHeads != null)
|
|
return ITEmpHeads;
|
|
|
|
#endregion
|
|
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin();
|
|
|
|
DataReader dr = new DataReader(ITEmpHeadDA.Get(tc,taxparamID));
|
|
ITEmpHeads = this.CreateObjects<ITEmpHead>(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
|
|
}
|
|
|
|
#region Cache Footer
|
|
|
|
_cache.Add(ITEmpHeads, "Get",taxparamID);
|
|
|
|
#endregion
|
|
|
|
return ITEmpHeads;
|
|
}
|
|
|
|
public ID Save(ITEmpHead oITEmpHead)
|
|
{
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin(true);
|
|
if (oITEmpHead.IsNew)
|
|
{
|
|
int id = tc.GenerateID("ITEmpHead", "ITEMPHEADID");
|
|
base.SetObjectID(oITEmpHead, ID.FromInteger(id));
|
|
ITEmpHeadDA.Insert(tc, oITEmpHead);
|
|
}
|
|
else
|
|
{
|
|
ITEmpHeadDA.Update(tc, oITEmpHead);
|
|
}
|
|
tc.End();
|
|
return oITEmpHead.ID;
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
#region Handle Exception
|
|
if (tc != null)
|
|
tc.HandleError();
|
|
ExceptionLog.Write(e);
|
|
throw new ServiceException(e.Message, e);
|
|
#endregion
|
|
}
|
|
}
|
|
public ID Save2(ITEmpHead oITEmpHead)
|
|
{
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin(true);
|
|
|
|
int id = tc.GenerateID("ITEmpHead", "ITEMPHEADID");
|
|
base.SetObjectID(oITEmpHead, ID.FromInteger(id));
|
|
ITEmpHeadDA.Insert(tc, oITEmpHead);
|
|
tc.End();
|
|
return oITEmpHead.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(ID id)
|
|
{
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin(true);
|
|
ITEmpHeadDA.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
|
|
}
|
|
#endregion
|
|
}
|