300 lines
10 KiB
C#
300 lines
10 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 ProdBonusAttnService:ServiceTemplate,IProdBonusAttnService
|
|||
|
{
|
|||
|
#region Private functions and declaration
|
|||
|
Cache _cache = new Cache(typeof(ProdBonusAttn));
|
|||
|
|
|||
|
#endregion
|
|||
|
public ProdBonusAttnService() { }
|
|||
|
|
|||
|
private void MapObject(ProdBonusAttn oProdBonusAttn, DataReader oReader)
|
|||
|
{
|
|||
|
//oProdBonusAttn.ID = oReader.GetID("ProdBonusAttnID");
|
|||
|
base.SetObjectID(oProdBonusAttn, oReader.GetID("ProdBonusAttnID"));
|
|||
|
oProdBonusAttn.ProdBonusSetupID = oReader.GetID("ProdBonusSetupID");
|
|||
|
oProdBonusAttn.BonusScheduleID = oReader.GetID("BonusScheduleID");
|
|||
|
oProdBonusAttn.ProdBonusLineID = oReader.GetID("ProdBonusLineID");
|
|||
|
oProdBonusAttn.EmployeeID = oReader.GetID("EmployeeID");
|
|||
|
oProdBonusAttn.BonusHour = oReader.GetFloat("BonusHour").GetValueOrDefault();
|
|||
|
oProdBonusAttn.InTime = oReader.GetDateTime("InTime").Value;
|
|||
|
oProdBonusAttn.OutTime = oReader.GetDateTime("OutTime").Value;
|
|||
|
oProdBonusAttn.IsCommon = oReader.GetBoolean("IsCommon").Value;
|
|||
|
this.SetObjectState(oProdBonusAttn,Ease.CoreV35.ObjectState.Saved);
|
|||
|
}
|
|||
|
protected override T CreateObject<T>(DataReader oReader)
|
|||
|
{
|
|||
|
ProdBonusAttn oProdBonusAttn = new ProdBonusAttn();
|
|||
|
MapObject(oProdBonusAttn, oReader);
|
|||
|
return oProdBonusAttn as T;
|
|||
|
}
|
|||
|
protected ProdBonusAttn CreateObject(DataReader oReader)
|
|||
|
{
|
|||
|
ProdBonusAttn oProdBonusAttn = new ProdBonusAttn();
|
|||
|
MapObject(oProdBonusAttn, oReader);
|
|||
|
return oProdBonusAttn;
|
|||
|
}
|
|||
|
#region Service implementation
|
|||
|
|
|||
|
public ProdBonusAttn Get(ID id)
|
|||
|
{
|
|||
|
ProdBonusAttn oProdBonusAttn = new ProdBonusAttn();
|
|||
|
#region Cache Header
|
|||
|
oProdBonusAttn = _cache["Get", id] as ProdBonusAttn;
|
|||
|
if (oProdBonusAttn != null)
|
|||
|
return oProdBonusAttn;
|
|||
|
#endregion
|
|||
|
TransactionContext tc = null;
|
|||
|
try
|
|||
|
{
|
|||
|
tc = TransactionContext.Begin();
|
|||
|
DataReader oreader = new DataReader(ProdBonusAttnDA.Get(tc, id));
|
|||
|
if (oreader.Read())
|
|||
|
{
|
|||
|
oProdBonusAttn = this.CreateObject<ProdBonusAttn>(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(oProdBonusAttn, "Get", id);
|
|||
|
#endregion
|
|||
|
return oProdBonusAttn;
|
|||
|
}
|
|||
|
|
|||
|
public ObjectsTemplate<ProdBonusAttn> Get()
|
|||
|
{
|
|||
|
#region Cache Header
|
|||
|
ObjectsTemplate<ProdBonusAttn> ProdBonusAttns = _cache["Get"] as ObjectsTemplate<ProdBonusAttn>;
|
|||
|
if (ProdBonusAttns != null)
|
|||
|
return ProdBonusAttns;
|
|||
|
#endregion
|
|||
|
TransactionContext tc = null;
|
|||
|
try
|
|||
|
{
|
|||
|
tc = TransactionContext.Begin();
|
|||
|
DataReader dr = new DataReader(ProdBonusAttnDA.Get(tc));
|
|||
|
ProdBonusAttns = this.CreateObjects<ProdBonusAttn>(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(ProdBonusAttns, "Get");
|
|||
|
#endregion
|
|||
|
return ProdBonusAttns;
|
|||
|
}
|
|||
|
public ObjectsTemplate<ProdBonusAttn> Get(int setupID,int ScheduleID)
|
|||
|
{
|
|||
|
|
|||
|
ObjectsTemplate<ProdBonusAttn> ProdBonusAttns = new ObjectsTemplate<ProdBonusAttn>();
|
|||
|
|
|||
|
TransactionContext tc = null;
|
|||
|
try
|
|||
|
{
|
|||
|
tc = TransactionContext.Begin();
|
|||
|
DataReader dr = new DataReader(ProdBonusAttnDA.Get(tc, setupID, ScheduleID));
|
|||
|
ProdBonusAttns = this.CreateObjects<ProdBonusAttn>(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 ProdBonusAttns;
|
|||
|
}
|
|||
|
public ObjectsTemplate<ProdBonusAttn> Get(int setupID, DateTime dateTime)
|
|||
|
{
|
|||
|
|
|||
|
ObjectsTemplate<ProdBonusAttn> ProdBonusAttns = new ObjectsTemplate<ProdBonusAttn>();
|
|||
|
|
|||
|
TransactionContext tc = null;
|
|||
|
try
|
|||
|
{
|
|||
|
tc = TransactionContext.Begin();
|
|||
|
DataReader dr = new DataReader(ProdBonusAttnDA.Get(tc, setupID, dateTime));
|
|||
|
ProdBonusAttns = this.CreateObjects<ProdBonusAttn>(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 ProdBonusAttns;
|
|||
|
}
|
|||
|
public ObjectsTemplate<ProdBonusAttn> GetBySetupID(ID setupID)
|
|||
|
{
|
|||
|
|
|||
|
ObjectsTemplate<ProdBonusAttn> ProdBonusAttns = new ObjectsTemplate<ProdBonusAttn>();
|
|||
|
|
|||
|
TransactionContext tc = null;
|
|||
|
try
|
|||
|
{
|
|||
|
tc = TransactionContext.Begin();
|
|||
|
DataReader dr = new DataReader(ProdBonusAttnDA.GetBySetupID(tc, setupID));
|
|||
|
ProdBonusAttns = this.CreateObjects<ProdBonusAttn>(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 ProdBonusAttns;
|
|||
|
}
|
|||
|
public ObjectsTemplate<ProdBonusAttn> GetByLineID(ID lineID)
|
|||
|
{
|
|||
|
|
|||
|
ObjectsTemplate<ProdBonusAttn> ProdBonusAttns = new ObjectsTemplate<ProdBonusAttn>();
|
|||
|
|
|||
|
TransactionContext tc = null;
|
|||
|
try
|
|||
|
{
|
|||
|
tc = TransactionContext.Begin();
|
|||
|
DataReader dr = new DataReader(ProdBonusAttnDA.GetByLineID(tc, lineID));
|
|||
|
ProdBonusAttns = this.CreateObjects<ProdBonusAttn>(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 ProdBonusAttns;
|
|||
|
}
|
|||
|
public ID Save(ProdBonusAttn oProdBonusAttn)
|
|||
|
{
|
|||
|
TransactionContext tc = null;
|
|||
|
try
|
|||
|
{
|
|||
|
tc = TransactionContext.Begin(true);
|
|||
|
if (oProdBonusAttn.IsNew)
|
|||
|
{
|
|||
|
int id = tc.GenerateID("ProdBonusAttn", "ProdBonusAttnID");
|
|||
|
base.SetObjectID(oProdBonusAttn, ID.FromInteger(id));
|
|||
|
|
|||
|
ProdBonusAttnDA.Insert(tc, oProdBonusAttn);
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
ProdBonusAttnDA.Update(tc, oProdBonusAttn);
|
|||
|
}
|
|||
|
tc.End();
|
|||
|
return oProdBonusAttn.ID;
|
|||
|
}
|
|||
|
catch (Exception e)
|
|||
|
{
|
|||
|
#region Handle Exception
|
|||
|
if (tc != null)
|
|||
|
tc.HandleError();
|
|||
|
ExceptionLog.Write(e);
|
|||
|
throw new ServiceException(e.Message, e);
|
|||
|
#endregion
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
public void Save(List<ProdBonusAttn> oProdBonusAttns, ID bSetupID, ID scheduleID)
|
|||
|
{
|
|||
|
TransactionContext tc = null;
|
|||
|
try
|
|||
|
{
|
|||
|
tc = TransactionContext.Begin(true);
|
|||
|
ProdBonusAttnDA.Delete(tc, bSetupID, oProdBonusAttns[0].InTime);
|
|||
|
if (oProdBonusAttns.Count > 0)
|
|||
|
{
|
|||
|
|
|||
|
foreach (ProdBonusAttn item in oProdBonusAttns)
|
|||
|
{
|
|||
|
int id = tc.GenerateID("ProdBonusAttn", "ProdBonusAttnID");
|
|||
|
base.SetObjectID(item, ID.FromInteger(id));
|
|||
|
ProdBonusAttnDA.Insert(tc, item);
|
|||
|
}
|
|||
|
}
|
|||
|
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 Delete(ID id)
|
|||
|
{
|
|||
|
TransactionContext tc = null;
|
|||
|
try
|
|||
|
{
|
|||
|
tc = TransactionContext.Begin(true);
|
|||
|
ProdBonusAttnDA.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
|
|||
|
}
|
|||
|
}
|