195 lines
6.7 KiB
C#
195 lines
6.7 KiB
C#
|
using System;
|
|||
|
using System.Collections.Generic;
|
|||
|
using System.Linq;
|
|||
|
using System.Text;
|
|||
|
using Ease.CoreV35.Model;
|
|||
|
using Payroll.BO;
|
|||
|
using Ease.CoreV35.Caching;
|
|||
|
using Ease.CoreV35.DataAccess;
|
|||
|
using Payroll.Service.Attendence.DA;
|
|||
|
|
|||
|
namespace Payroll.Service.Attendence.Service
|
|||
|
{
|
|||
|
#region ShiftTermDetail Service
|
|||
|
[Serializable]
|
|||
|
public class ShiftTermDetailService : ServiceTemplate, IShiftTermDetailService
|
|||
|
{
|
|||
|
#region Private functions and declaration
|
|||
|
Cache _cache = new Cache(typeof(ShiftTermDetail));
|
|||
|
|
|||
|
#endregion
|
|||
|
public ShiftTermDetailService() { }
|
|||
|
|
|||
|
private void MapObject(ShiftTermDetail oShiftTermDetail, DataReader oReader)
|
|||
|
{
|
|||
|
base.SetObjectID(oShiftTermDetail, oReader.GetID("ShiftTermDetailID"));
|
|||
|
oShiftTermDetail.ShiftTermID = oReader.GetID("ShiftTermID");
|
|||
|
oShiftTermDetail.Hour = oReader.GetDouble("OTHour").Value;
|
|||
|
oShiftTermDetail.SequenceNo = oReader.GetInt32("SequenceNo").Value;
|
|||
|
oShiftTermDetail.TermID = oReader.GetID("TermID");
|
|||
|
this.SetObjectState(oShiftTermDetail, Ease.CoreV35.ObjectState.Saved);
|
|||
|
}
|
|||
|
protected override T CreateObject<T>(DataReader oReader)
|
|||
|
{
|
|||
|
ShiftTermDetail oShiftTermDetail = new ShiftTermDetail();
|
|||
|
MapObject(oShiftTermDetail, oReader);
|
|||
|
return oShiftTermDetail as T;
|
|||
|
}
|
|||
|
protected ShiftTermDetail CreateObject(DataReader oReader)
|
|||
|
{
|
|||
|
ShiftTermDetail oShiftTermDetail = new ShiftTermDetail();
|
|||
|
MapObject(oShiftTermDetail, oReader);
|
|||
|
return oShiftTermDetail;
|
|||
|
}
|
|||
|
#region Service implementation
|
|||
|
public ShiftTermDetail Get(ID id)
|
|||
|
{
|
|||
|
ShiftTermDetail oShiftTermDetail = new ShiftTermDetail();
|
|||
|
#region Cache Header
|
|||
|
oShiftTermDetail = _cache["Get", id] as ShiftTermDetail;
|
|||
|
if (oShiftTermDetail != null)
|
|||
|
return oShiftTermDetail;
|
|||
|
#endregion
|
|||
|
TransactionContext tc = null;
|
|||
|
try
|
|||
|
{
|
|||
|
tc = TransactionContext.Begin();
|
|||
|
DataReader oreader = new DataReader(ShiftTermDetailDA.Get(tc, id));
|
|||
|
if (oreader.Read())
|
|||
|
{
|
|||
|
oShiftTermDetail = this.CreateObject<ShiftTermDetail>(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(oShiftTermDetail, "Get", id);
|
|||
|
#endregion
|
|||
|
return oShiftTermDetail;
|
|||
|
}
|
|||
|
|
|||
|
public ObjectsTemplate<ShiftTermDetail> Get()
|
|||
|
{
|
|||
|
#region Cache Header
|
|||
|
ObjectsTemplate<ShiftTermDetail> shiftTermDetails = _cache["Get"] as ObjectsTemplate<ShiftTermDetail>;
|
|||
|
if (shiftTermDetails != null)
|
|||
|
return shiftTermDetails;
|
|||
|
#endregion
|
|||
|
TransactionContext tc = null;
|
|||
|
try
|
|||
|
{
|
|||
|
tc = TransactionContext.Begin();
|
|||
|
DataReader dr = new DataReader(ShiftTermDetailDA.Get(tc));
|
|||
|
shiftTermDetails = this.CreateObjects<ShiftTermDetail>(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(shiftTermDetails, "Get");
|
|||
|
#endregion
|
|||
|
return shiftTermDetails;
|
|||
|
}
|
|||
|
|
|||
|
public ObjectsTemplate<ShiftTermDetail> GetByShiftTermID(ID nShiftTermID)
|
|||
|
{
|
|||
|
#region Cache Header
|
|||
|
ObjectsTemplate<ShiftTermDetail> shiftTermDetails = _cache["GetByShiftTermID", nShiftTermID] as ObjectsTemplate<ShiftTermDetail>;
|
|||
|
if (shiftTermDetails != null)
|
|||
|
return shiftTermDetails;
|
|||
|
#endregion
|
|||
|
TransactionContext tc = null;
|
|||
|
try
|
|||
|
{
|
|||
|
tc = TransactionContext.Begin();
|
|||
|
DataReader dr = new DataReader(ShiftTermDetailDA.GetByShiftTermID(tc, nShiftTermID));
|
|||
|
shiftTermDetails = this.CreateObjects<ShiftTermDetail>(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(shiftTermDetails, "GetByShiftTermID", nShiftTermID);
|
|||
|
#endregion
|
|||
|
return shiftTermDetails;
|
|||
|
}
|
|||
|
|
|||
|
public ID Save(ShiftTermDetail oShiftTermDetail)
|
|||
|
{
|
|||
|
TransactionContext tc = null;
|
|||
|
try
|
|||
|
{
|
|||
|
tc = TransactionContext.Begin(true);
|
|||
|
if (oShiftTermDetail.IsNew)
|
|||
|
{
|
|||
|
int id = tc.GenerateID("ShiftTermDetail", "ShiftTermDetailID");
|
|||
|
base.SetObjectID(oShiftTermDetail, ID.FromInteger(id));
|
|||
|
ShiftTermDetailDA.Insert(tc, oShiftTermDetail);
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
ShiftTermDetailDA.Update(tc, oShiftTermDetail);
|
|||
|
}
|
|||
|
tc.End();
|
|||
|
return oShiftTermDetail.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);
|
|||
|
ShiftTermDetailDA.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
|
|||
|
}
|