224 lines
7.0 KiB
C#
224 lines
7.0 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 ProdBonusSupervisorService : ServiceTemplate, IProdBonusSupervisorService
|
|
{
|
|
public ProdBonusSupervisorService()
|
|
{
|
|
}
|
|
|
|
private void MapObject(ProdBonusSupervisor oProdBonusSupervisor, DataReader oReader)
|
|
{
|
|
//oProdBonusSupervisor.int = oReader.GetInt32("ProdBonusSupervisorID");
|
|
|
|
base.SetObjectID(oProdBonusSupervisor, (oReader.GetInt32("ProdBonusSupervisorID").Value));
|
|
oProdBonusSupervisor.ProdBonusSetupID = oReader.GetInt32("ProdBonusSetupID", 0);
|
|
oProdBonusSupervisor.ProdBonusLineID = oReader.GetInt32("ProdBonusLineID", 0);
|
|
oProdBonusSupervisor.EmployeeID = oReader.GetInt32("EmployeeID", 0);
|
|
oProdBonusSupervisor.BonusPercent = oReader.GetDouble("BonusPercent").GetValueOrDefault();
|
|
oProdBonusSupervisor.Amount = oReader.GetDouble("Amount").GetValueOrDefault();
|
|
this.SetObjectState(oProdBonusSupervisor, Ease.Core.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(int id)
|
|
{
|
|
ProdBonusSupervisor oProdBonusSupervisor = new ProdBonusSupervisor();
|
|
|
|
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
|
|
}
|
|
|
|
return oProdBonusSupervisor;
|
|
}
|
|
|
|
public List<ProdBonusSupervisor> Get()
|
|
{
|
|
List<ProdBonusSupervisor> ProdBonusSupervisors = null;
|
|
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
|
|
}
|
|
|
|
return ProdBonusSupervisors;
|
|
}
|
|
public List<ProdBonusSupervisor> GetByLineID(int lineID)
|
|
{
|
|
List<ProdBonusSupervisor> ProdBonusSupervisors = new List<ProdBonusSupervisor>();
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin();
|
|
|
|
DataReader dr = new DataReader(ProdBonusSupervisorDA.GetByLineID(tc, lineID));
|
|
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
|
|
}
|
|
|
|
return ProdBonusSupervisors;
|
|
}
|
|
public List<ProdBonusSupervisor> GetBySetupLineIDByInSQL(string setupid)
|
|
{
|
|
List<ProdBonusSupervisor> ProdBonusSupervisors = new List<ProdBonusSupervisor>();
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin();
|
|
|
|
DataReader dr = new DataReader(ProdBonusSupervisorDA.GetBySetupLineIDByInSQL(tc, setupid));
|
|
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
|
|
}
|
|
|
|
return ProdBonusSupervisors;
|
|
}
|
|
|
|
|
|
public int Save(ProdBonusSupervisor oProdBonusSupervisor)
|
|
{
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin(true);
|
|
if (oProdBonusSupervisor.IsNew)
|
|
{
|
|
int id = tc.GenerateID("ProdBonusSupervisors", "ProdBonusSupervisorID");
|
|
base.SetObjectID(oProdBonusSupervisor, (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(int 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
|
|
}
|
|
} |