377 lines
13 KiB
C#
377 lines
13 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 ProdBonusLineService:ServiceTemplate,IProdBonusLineService
|
|
{
|
|
#region Private functions and declaration
|
|
Cache _cache = new Cache(typeof(ProdBonusLine));
|
|
|
|
#endregion
|
|
public ProdBonusLineService() { }
|
|
|
|
private void MapObject(ProdBonusLine oProdBonusLine, DataReader oReader)
|
|
{
|
|
//oProdBonusLine.ID = oReader.GetID("ProdBonusLineID");
|
|
base.SetObjectID(oProdBonusLine, oReader.GetID("ProdBonusLineID"));
|
|
oProdBonusLine.ProdBonusSetupID = oReader.GetID("ProdBonusSetupID");
|
|
oProdBonusLine.LineName = oReader.GetString("LineName");
|
|
oProdBonusLine.LineAchievedPercent = oReader.GetDouble("LineAchievedPercent").GetValueOrDefault();
|
|
oProdBonusLine.LineOTHour = oReader.GetDouble("LineOTHour").GetValueOrDefault();
|
|
oProdBonusLine.ScheduledHour = oReader.GetDouble("ScheduledHour").GetValueOrDefault();
|
|
|
|
this.SetObjectState(oProdBonusLine,Ease.CoreV35.ObjectState.Saved);
|
|
}
|
|
protected override T CreateObject<T>(DataReader oReader)
|
|
{
|
|
ProdBonusLine oProdBonusLine = new ProdBonusLine();
|
|
MapObject(oProdBonusLine, oReader);
|
|
return oProdBonusLine as T;
|
|
}
|
|
protected ProdBonusLine CreateObject(DataReader oReader)
|
|
{
|
|
ProdBonusLine oProdBonusLine = new ProdBonusLine();
|
|
MapObject(oProdBonusLine, oReader);
|
|
return oProdBonusLine;
|
|
}
|
|
|
|
private void MapProdBonusParameterObject(ProdBonusParameter oProdBonusParameter, DataReader oReader)
|
|
{
|
|
//oProdBonusParameter.ID = oReader.GetID("ProdBonusParameterID");
|
|
base.SetObjectID(oProdBonusParameter, oReader.GetID("ProdBonusParameterID"));
|
|
|
|
oProdBonusParameter.ProdBonusLineID = oReader.GetID("ProdBonusLineID");
|
|
oProdBonusParameter.ProdBonusSetupID = oReader.GetID("ProdBonusSetupID");
|
|
oProdBonusParameter.ItemID = oReader.GetID("ItemID");
|
|
oProdBonusParameter.ItemType = (EnumBonusItemType)oReader.GetInt32("ItemType").Value;
|
|
oProdBonusParameter.ProdBonusLineID = oReader.GetID("ProdBonusLineID");
|
|
|
|
this.SetObjectState(oProdBonusParameter, Ease.CoreV35.ObjectState.Saved);
|
|
}
|
|
|
|
private ProdBonusParameter CreateProdBonusParameterObject(DataReader oReader)
|
|
{
|
|
ProdBonusParameter item = new ProdBonusParameter();
|
|
MapProdBonusParameterObject(item, oReader);
|
|
return item;
|
|
}
|
|
protected ObjectsTemplate<ProdBonusParameter> CreateProdBonusParameterObjects(DataReader oReader)
|
|
{
|
|
ObjectsTemplate<ProdBonusParameter> oItems = new ObjectsTemplate<ProdBonusParameter>();
|
|
while (oReader.Read())
|
|
{
|
|
ProdBonusParameter item = CreateProdBonusParameterObject(oReader);
|
|
oItems.Add(item);
|
|
}
|
|
return oItems;
|
|
}
|
|
private void MapScheduleObject(ProdBonusWorkSchedule oProdBonusWorkSchedule, DataReader oReader)
|
|
{
|
|
//oProdBonusWorkSchedule.ID = oReader.GetID("ProdBonusWorkScheduleID");
|
|
base.SetObjectID(oProdBonusWorkSchedule, oReader.GetID("ProdBonusWorkScheduleID"));
|
|
oProdBonusWorkSchedule.ProdBonusSetupID = oReader.GetID("ProdBonusSetupID");
|
|
oProdBonusWorkSchedule.ProdBonusLineID = oReader.GetID("ProdBonusLineID");
|
|
oProdBonusWorkSchedule.StartDateTime = oReader.GetDateTime("StartDateTime").Value;
|
|
//oProdBonusWorkSchedule.EndDateTime = oReader.GetDateTime("EndDateTime").Value;
|
|
|
|
this.SetObjectState(oProdBonusWorkSchedule, Ease.CoreV35.ObjectState.Saved);
|
|
}
|
|
private ProdBonusWorkSchedule CreateScheduleObject(DataReader oReader)
|
|
{
|
|
ProdBonusWorkSchedule item = new ProdBonusWorkSchedule();
|
|
MapScheduleObject(item, oReader);
|
|
return item;
|
|
}
|
|
protected ObjectsTemplate<ProdBonusWorkSchedule> CreateScheduleObjects(DataReader oReader)
|
|
{
|
|
ObjectsTemplate<ProdBonusWorkSchedule> oItems = new ObjectsTemplate<ProdBonusWorkSchedule>();
|
|
while (oReader.Read())
|
|
{
|
|
ProdBonusWorkSchedule item = CreateScheduleObject(oReader);
|
|
oItems.Add(item);
|
|
}
|
|
return oItems;
|
|
}
|
|
|
|
|
|
private void MapSupervisorObject(ProdBonusSupervisor oProdBonusSupervisor, DataReader oReader)
|
|
{
|
|
//oProdBonusWorkSchedule.ID = oReader.GetID("ProdBonusWorkScheduleID");
|
|
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();
|
|
this.SetObjectState(oProdBonusSupervisor, Ease.CoreV35.ObjectState.Saved);
|
|
}
|
|
private ProdBonusSupervisor CreateSupervisorObject(DataReader oReader)
|
|
{
|
|
ProdBonusSupervisor item = new ProdBonusSupervisor();
|
|
MapSupervisorObject(item, oReader);
|
|
return item;
|
|
}
|
|
protected ObjectsTemplate<ProdBonusSupervisor> CreateSupervisorObjects(DataReader oReader)
|
|
{
|
|
ObjectsTemplate<ProdBonusSupervisor> oItems = new ObjectsTemplate<ProdBonusSupervisor>();
|
|
while (oReader.Read())
|
|
{
|
|
ProdBonusSupervisor item = CreateSupervisorObject(oReader);
|
|
oItems.Add(item);
|
|
}
|
|
return oItems;
|
|
}
|
|
|
|
#region Service implementation
|
|
|
|
|
|
|
|
public ProdBonusLine Get(ID id)
|
|
{
|
|
ProdBonusLine oProdBonusLine = new ProdBonusLine();
|
|
#region Cache Header
|
|
oProdBonusLine = _cache["Get", id] as ProdBonusLine;
|
|
if (oProdBonusLine != null)
|
|
return oProdBonusLine;
|
|
#endregion
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin();
|
|
DataReader oreader = new DataReader(ProdBonusLineDA.Get(tc, id));
|
|
if (oreader.Read())
|
|
{
|
|
oProdBonusLine = this.CreateObject<ProdBonusLine>(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(oProdBonusLine, "Get", id);
|
|
#endregion
|
|
return oProdBonusLine;
|
|
}
|
|
|
|
|
|
public ObjectsTemplate<ProdBonusLine> Get()
|
|
{
|
|
#region Cache Header
|
|
ObjectsTemplate<ProdBonusLine> ProdBonusLines = _cache["Get"] as ObjectsTemplate<ProdBonusLine>;
|
|
if (ProdBonusLines != null)
|
|
return ProdBonusLines;
|
|
#endregion
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin();
|
|
DataReader dr = new DataReader(ProdBonusLineDA.Get(tc));
|
|
ProdBonusLines = this.CreateObjects<ProdBonusLine>(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(ProdBonusLines, "Get");
|
|
#endregion
|
|
return ProdBonusLines;
|
|
}
|
|
|
|
public ObjectsTemplate<ProdBonusParameter> GetProdBonusParameters(ID iD)
|
|
{
|
|
|
|
ObjectsTemplate<ProdBonusParameter> ProdBonusParameters = new ObjectsTemplate<ProdBonusParameter>();
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin();
|
|
|
|
DataReader dr = new DataReader(ProdBonusLineDA.GetProdBonusParameters(tc, iD));
|
|
ProdBonusParameters = this.CreateProdBonusParameterObjects(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 ProdBonusParameters;
|
|
}
|
|
|
|
public ObjectsTemplate<ProdBonusWorkSchedule> GetProdBonusWorkSchedules(ID iD)
|
|
{
|
|
ObjectsTemplate<ProdBonusWorkSchedule> ProdBonusWorkSchedules = new ObjectsTemplate<ProdBonusWorkSchedule>();
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin();
|
|
|
|
DataReader dr = new DataReader(ProdBonusLineDA.GetProdBonusWorkSchedules(tc, iD));
|
|
ProdBonusWorkSchedules = this.CreateScheduleObjects(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 ProdBonusWorkSchedules;
|
|
}
|
|
|
|
public ObjectsTemplate<ProdBonusWorkSchedule> GetProdBonusWorkSchedules(TransactionContext tc,ID iD)
|
|
{
|
|
ObjectsTemplate<ProdBonusWorkSchedule> ProdBonusWorkSchedules = new ObjectsTemplate<ProdBonusWorkSchedule>();
|
|
try
|
|
{
|
|
|
|
DataReader dr = new DataReader(ProdBonusLineDA.GetProdBonusWorkSchedules(tc, iD));
|
|
ProdBonusWorkSchedules = this.CreateScheduleObjects(dr);
|
|
dr.Close();
|
|
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
#region Handle Exception
|
|
|
|
if (tc != null)
|
|
tc.HandleError();
|
|
ExceptionLog.Write(e);
|
|
|
|
throw new ServiceException(e.Message, e);
|
|
|
|
#endregion
|
|
}
|
|
|
|
return ProdBonusWorkSchedules;
|
|
}
|
|
|
|
|
|
public ObjectsTemplate<ProdBonusSupervisor> GetProdBonusSupervisors(ID iD)
|
|
{
|
|
ObjectsTemplate<ProdBonusSupervisor> ProdBonusSupervisors = new ObjectsTemplate<ProdBonusSupervisor>();
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin();
|
|
|
|
DataReader dr = new DataReader(ProdBonusLineDA.GetProdBonusSupervisors(tc, iD));
|
|
ProdBonusSupervisors = this.CreateSupervisorObjects(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 ProdBonusSupervisors;
|
|
}
|
|
public ID Save(ProdBonusLine oProdBonusLine)
|
|
{
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin(true);
|
|
if (oProdBonusLine.IsNew)
|
|
{
|
|
int id = tc.GenerateID("ProdBonusLines", "ProdBonusLineID");
|
|
base.SetObjectID(oProdBonusLine, ID.FromInteger(id));
|
|
int seqNo = tc.GenerateID("ProdBonusLines", "SequenceNO");
|
|
oProdBonusLine.Sequence = seqNo;
|
|
ProdBonusLineDA.Insert(tc, oProdBonusLine);
|
|
}
|
|
else
|
|
{
|
|
ProdBonusLineDA.Update(tc, oProdBonusLine);
|
|
}
|
|
tc.End();
|
|
return oProdBonusLine.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);
|
|
ProdBonusLineDA.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
|
|
|
|
}
|
|
}
|