219 lines
6.9 KiB
C#
219 lines
6.9 KiB
C#
|
using System;
|
|||
|
using System.Data;
|
|||
|
using Ease.Core.Model;
|
|||
|
using Ease.Core.DataAccess;
|
|||
|
using Ease.Core;
|
|||
|
using System.Collections.Generic;
|
|||
|
using Ease.Core.Utility;
|
|||
|
using HRM.BO;
|
|||
|
|
|||
|
namespace HRM.DA
|
|||
|
{
|
|||
|
public class ProdBonusWorkScheduleService : ServiceTemplate, IProdBonusWorkScheduleService
|
|||
|
{
|
|||
|
public ProdBonusWorkScheduleService()
|
|||
|
{
|
|||
|
}
|
|||
|
|
|||
|
private void MapObject(ProdBonusWorkSchedule oProdBonusWorkSchedule, DataReader oReader)
|
|||
|
{
|
|||
|
//oProdBonusWorkSchedule.int = oReader.GetInt32("ProdBonusWorkScheduleID");
|
|||
|
|
|||
|
base.SetObjectID(oProdBonusWorkSchedule, (oReader.GetInt32("ProdBonusWorkScheduleID").Value));
|
|||
|
oProdBonusWorkSchedule.ProdBonusSetupID = oReader.GetInt32("ProdBonusSetupID", 0);
|
|||
|
oProdBonusWorkSchedule.ProdBonusLineID = oReader.GetInt32("ProdBonusLineID", 0);
|
|||
|
oProdBonusWorkSchedule.StartDateTime = oReader.GetDateTime("StartDateTime").Value;
|
|||
|
//oProdBonusWorkSchedule.EndDateTime = oReader.GetDateTime("EndDateTime").Value;
|
|||
|
|
|||
|
this.SetObjectState(oProdBonusWorkSchedule, Ease.Core.ObjectState.Saved);
|
|||
|
}
|
|||
|
|
|||
|
protected override T CreateObject<T>(DataReader oReader)
|
|||
|
{
|
|||
|
ProdBonusWorkSchedule oProdBonusWorkSchedule = new ProdBonusWorkSchedule();
|
|||
|
MapObject(oProdBonusWorkSchedule, oReader);
|
|||
|
return oProdBonusWorkSchedule as T;
|
|||
|
}
|
|||
|
|
|||
|
protected ProdBonusWorkSchedule CreateObject(DataReader oReader)
|
|||
|
{
|
|||
|
ProdBonusWorkSchedule oProdBonusWorkSchedule = new ProdBonusWorkSchedule();
|
|||
|
MapObject(oProdBonusWorkSchedule, oReader);
|
|||
|
return oProdBonusWorkSchedule;
|
|||
|
}
|
|||
|
|
|||
|
#region Service implementation
|
|||
|
|
|||
|
public ProdBonusWorkSchedule Get(int id)
|
|||
|
{
|
|||
|
ProdBonusWorkSchedule oProdBonusWorkSchedule = new ProdBonusWorkSchedule();
|
|||
|
|
|||
|
TransactionContext tc = null;
|
|||
|
try
|
|||
|
{
|
|||
|
tc = TransactionContext.Begin();
|
|||
|
DataReader oreader = new DataReader(ProdBonusWorkScheduleDA.Get(tc, id));
|
|||
|
if (oreader.Read())
|
|||
|
{
|
|||
|
oProdBonusWorkSchedule = this.CreateObject<ProdBonusWorkSchedule>(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
|
|||
|
}
|
|||
|
|
|||
|
return oProdBonusWorkSchedule;
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
public List<ProdBonusWorkSchedule> Get()
|
|||
|
{
|
|||
|
List<ProdBonusWorkSchedule> ProdBonusWorkSchedules = null;
|
|||
|
TransactionContext tc = null;
|
|||
|
try
|
|||
|
{
|
|||
|
tc = TransactionContext.Begin();
|
|||
|
DataReader dr = new DataReader(ProdBonusWorkScheduleDA.Get(tc));
|
|||
|
ProdBonusWorkSchedules = this.CreateObjects<ProdBonusWorkSchedule>(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 List<ProdBonusWorkSchedule> GetByLineID(int lineID)
|
|||
|
{
|
|||
|
List<ProdBonusWorkSchedule> ProdBonusWorkSchedules = null;
|
|||
|
TransactionContext tc = null;
|
|||
|
try
|
|||
|
{
|
|||
|
tc = TransactionContext.Begin();
|
|||
|
DataReader dr = new DataReader(ProdBonusWorkScheduleDA.GetByLineID(tc, lineID));
|
|||
|
ProdBonusWorkSchedules = this.CreateObjects<ProdBonusWorkSchedule>(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 List<ProdBonusWorkSchedule> GetWithSetupID(int nSetupID)
|
|||
|
{
|
|||
|
List<ProdBonusWorkSchedule> ProdBonusWorkSchedules = null;
|
|||
|
TransactionContext tc = null;
|
|||
|
try
|
|||
|
{
|
|||
|
tc = TransactionContext.Begin();
|
|||
|
DataReader dr = new DataReader(ProdBonusWorkScheduleDA.GetBySetupId(tc, nSetupID));
|
|||
|
ProdBonusWorkSchedules = this.CreateObjects<ProdBonusWorkSchedule>(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 int Save(ProdBonusWorkSchedule oProdBonusWorkSchedule)
|
|||
|
{
|
|||
|
TransactionContext tc = null;
|
|||
|
try
|
|||
|
{
|
|||
|
tc = TransactionContext.Begin(true);
|
|||
|
if (oProdBonusWorkSchedule.IsNew)
|
|||
|
{
|
|||
|
int id = tc.GenerateID("ProdBonusWorkSchedule", "ProdBonusWorkScheduleID");
|
|||
|
base.SetObjectID(oProdBonusWorkSchedule, (id));
|
|||
|
int seqNo = tc.GenerateID("ProdBonusWorkSchedule", "SequenceNO");
|
|||
|
oProdBonusWorkSchedule.Sequence = seqNo;
|
|||
|
ProdBonusWorkScheduleDA.Insert(tc, oProdBonusWorkSchedule);
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
ProdBonusWorkScheduleDA.Update(tc, oProdBonusWorkSchedule);
|
|||
|
}
|
|||
|
|
|||
|
tc.End();
|
|||
|
return oProdBonusWorkSchedule.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(int id)
|
|||
|
{
|
|||
|
TransactionContext tc = null;
|
|||
|
try
|
|||
|
{
|
|||
|
tc = TransactionContext.Begin(true);
|
|||
|
ProdBonusWorkScheduleDA.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
|
|||
|
}
|
|||
|
}
|