221 lines
6.8 KiB
C#
221 lines
6.8 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 ProdBonusParameterService : ServiceTemplate, IProdBonusParameterService
|
|||
|
{
|
|||
|
public ProdBonusParameterService()
|
|||
|
{
|
|||
|
}
|
|||
|
|
|||
|
private void MapObject(ProdBonusParameter oProdBonusParameter, DataReader oReader)
|
|||
|
{
|
|||
|
//oProdBonusParameter.int = oReader.GetInt32("ProdBonusParameterID");
|
|||
|
base.SetObjectID(oProdBonusParameter, (oReader.GetInt32("ProdBonusParameterID").Value));
|
|||
|
oProdBonusParameter.ProdBonusLineID = oReader.GetInt32("ProdBonusLineID", 0);
|
|||
|
oProdBonusParameter.ProdBonusSetupID = oReader.GetInt32("ProdBonusSetupID", 0);
|
|||
|
oProdBonusParameter.ItemID = oReader.GetInt32("ItemID", 0);
|
|||
|
oProdBonusParameter.ItemType = (EnumBonusItemType)oReader.GetInt32("ItemType").Value;
|
|||
|
oProdBonusParameter.ProdBonusLineID = oReader.GetInt32("ProdBonusLineID", 0);
|
|||
|
|
|||
|
this.SetObjectState(oProdBonusParameter, Ease.Core.ObjectState.Saved);
|
|||
|
}
|
|||
|
|
|||
|
protected override T CreateObject<T>(DataReader oReader)
|
|||
|
{
|
|||
|
ProdBonusParameter oProdBonusParameter = new ProdBonusParameter();
|
|||
|
MapObject(oProdBonusParameter, oReader);
|
|||
|
return oProdBonusParameter as T;
|
|||
|
}
|
|||
|
|
|||
|
protected ProdBonusParameter CreateObject(DataReader oReader)
|
|||
|
{
|
|||
|
ProdBonusParameter oProdBonusParameter = new ProdBonusParameter();
|
|||
|
MapObject(oProdBonusParameter, oReader);
|
|||
|
return oProdBonusParameter;
|
|||
|
}
|
|||
|
|
|||
|
#region Service implementation
|
|||
|
|
|||
|
public ProdBonusParameter Get(int id)
|
|||
|
{
|
|||
|
ProdBonusParameter oProdBonusParameter = new ProdBonusParameter();
|
|||
|
|
|||
|
TransactionContext tc = null;
|
|||
|
try
|
|||
|
{
|
|||
|
tc = TransactionContext.Begin();
|
|||
|
DataReader oreader = new DataReader(ProdBonusParameterDA.Get(tc, id));
|
|||
|
if (oreader.Read())
|
|||
|
{
|
|||
|
oProdBonusParameter = this.CreateObject<ProdBonusParameter>(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 oProdBonusParameter;
|
|||
|
}
|
|||
|
|
|||
|
public List<ProdBonusParameter> Get()
|
|||
|
{
|
|||
|
List<ProdBonusParameter> ProdBonusParameters = null;
|
|||
|
TransactionContext tc = null;
|
|||
|
try
|
|||
|
{
|
|||
|
tc = TransactionContext.Begin();
|
|||
|
DataReader dr = new DataReader(ProdBonusParameterDA.Get(tc));
|
|||
|
ProdBonusParameters = this.CreateObjects<ProdBonusParameter>(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 List<ProdBonusParameter> GetByLineID(int lineID)
|
|||
|
{
|
|||
|
List<ProdBonusParameter> ProdBonusParameters = new List<ProdBonusParameter>();
|
|||
|
TransactionContext tc = null;
|
|||
|
try
|
|||
|
{
|
|||
|
tc = TransactionContext.Begin();
|
|||
|
|
|||
|
DataReader dr = new DataReader(ProdBonusParameterDA.GetByLineID(tc, lineID));
|
|||
|
ProdBonusParameters = this.CreateObjects<ProdBonusParameter>(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 List<ProdBonusParameter> GetWithSetupID(int nSetupID)
|
|||
|
{
|
|||
|
List<ProdBonusParameter> ProdBonusParameters = null;
|
|||
|
|
|||
|
TransactionContext tc = null;
|
|||
|
try
|
|||
|
{
|
|||
|
tc = TransactionContext.Begin();
|
|||
|
DataReader dr = new DataReader(ProdBonusParameterDA.GetBySetupId(tc, nSetupID));
|
|||
|
ProdBonusParameters = this.CreateObjects<ProdBonusParameter>(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 int Save(ProdBonusParameter oProdBonusParameter)
|
|||
|
{
|
|||
|
TransactionContext tc = null;
|
|||
|
try
|
|||
|
{
|
|||
|
tc = TransactionContext.Begin(true);
|
|||
|
if (oProdBonusParameter.IsNew)
|
|||
|
{
|
|||
|
int id = tc.GenerateID("ProdBonusParameter", "ProdBonusParameterID");
|
|||
|
base.SetObjectID(oProdBonusParameter, (id));
|
|||
|
int seqNo = tc.GenerateID("ProdBonusParameter", "SequenceNO");
|
|||
|
oProdBonusParameter.Sequence = seqNo;
|
|||
|
ProdBonusParameterDA.Insert(tc, oProdBonusParameter);
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
ProdBonusParameterDA.Update(tc, oProdBonusParameter);
|
|||
|
}
|
|||
|
|
|||
|
tc.End();
|
|||
|
return oProdBonusParameter.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);
|
|||
|
ProdBonusParameterDA.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
|
|||
|
}
|
|||
|
}
|