167 lines
6.0 KiB
C#
167 lines
6.0 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
|
|
{
|
|
public class ProdBonusSupervisorService:ServiceTemplate,IProdBonusSupervisorService
|
|
{
|
|
#region Private functions and declaration
|
|
Cache _cache = new Cache(typeof(ProdBonusSupervisor));
|
|
|
|
#endregion
|
|
public ProdBonusSupervisorService() { }
|
|
|
|
private void MapObject(ProdBonusSupervisor oProdBonusSupervisor, DataReader oReader)
|
|
{
|
|
//oProdBonusSupervisor.ID = oReader.GetID("ProdBonusSupervisorID");
|
|
base.SetObjectID(oProdBonusSupervisor, oReader.GetID("ProdBonusSupervisorID"));
|
|
oProdBonusSupervisor.ProdBonusSetupID = oReader.GetID("ProdBonusSetupID");
|
|
oProdBonusSupervisor.ProdBonusSetupID = oReader.GetID("ProdBonusLineID");
|
|
oProdBonusSupervisor.EmployeeID = oReader.GetID("EmployeeID");
|
|
oProdBonusSupervisor.BonusPercent = oReader.GetDouble("BonusPercent").GetValueOrDefault();
|
|
oProdBonusSupervisor.Amount = oReader.GetDouble("Amount").GetValueOrDefault();
|
|
this.SetObjectState(oProdBonusSupervisor,Ease.CoreV35.ObjectState.Saved);
|
|
}
|
|
protected override T CreateObject<T>(DataReader oReader)
|
|
{
|
|
ProdBonusSupervisor oProdBonusSupervisor = new ProdBonusSupervisor();
|
|
MapObject(oProdBonusSupervisor, oReader);
|
|
return oProdBonusSupervisor as T;
|
|
}
|
|
protected ProdBonusSupervisor CreateObject(DataReader oReader)
|
|
{
|
|
ProdBonusSupervisor oProdBonusSupervisor = new ProdBonusSupervisor();
|
|
MapObject(oProdBonusSupervisor, oReader);
|
|
return oProdBonusSupervisor;
|
|
}
|
|
#region Service implementation
|
|
|
|
public ProdBonusSupervisor Get(ID id)
|
|
{
|
|
ProdBonusSupervisor oProdBonusSupervisor = new ProdBonusSupervisor();
|
|
#region Cache Header
|
|
oProdBonusSupervisor = _cache["Get", id] as ProdBonusSupervisor;
|
|
if (oProdBonusSupervisor != null)
|
|
return oProdBonusSupervisor;
|
|
#endregion
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin();
|
|
DataReader oreader = new DataReader(ProdBonusSupervisorDA.Get(tc, id));
|
|
if (oreader.Read())
|
|
{
|
|
oProdBonusSupervisor = this.CreateObject<ProdBonusSupervisor>(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(oProdBonusSupervisor, "Get", id);
|
|
#endregion
|
|
return oProdBonusSupervisor;
|
|
}
|
|
|
|
public ObjectsTemplate<ProdBonusSupervisor> Get()
|
|
{
|
|
#region Cache Header
|
|
ObjectsTemplate<ProdBonusSupervisor> ProdBonusSupervisors = _cache["Get"] as ObjectsTemplate<ProdBonusSupervisor>;
|
|
if (ProdBonusSupervisors != null)
|
|
return ProdBonusSupervisors;
|
|
#endregion
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin();
|
|
DataReader dr = new DataReader(ProdBonusSupervisorDA.Get(tc));
|
|
ProdBonusSupervisors = this.CreateObjects<ProdBonusSupervisor>(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(ProdBonusSupervisors, "Get");
|
|
#endregion
|
|
return ProdBonusSupervisors;
|
|
}
|
|
|
|
public ID Save(ProdBonusSupervisor oProdBonusSupervisor)
|
|
{
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin(true);
|
|
if (oProdBonusSupervisor.IsNew)
|
|
{
|
|
int id = tc.GenerateID("ProdBonusSupervisors", "ProdBonusSupervisorID");
|
|
base.SetObjectID(oProdBonusSupervisor, ID.FromInteger(id));
|
|
int seqNo = tc.GenerateID("ProdBonusSupervisors", "SequenceNO");
|
|
oProdBonusSupervisor.Sequence = seqNo;
|
|
ProdBonusSupervisorDA.Insert(tc, oProdBonusSupervisor);
|
|
}
|
|
else
|
|
{
|
|
ProdBonusSupervisorDA.Update(tc, oProdBonusSupervisor);
|
|
}
|
|
tc.End();
|
|
return oProdBonusSupervisor.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);
|
|
ProdBonusSupervisorDA.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
|
|
|
|
}
|
|
}
|