389 lines
12 KiB
C#
389 lines
12 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 ProdBonusAttnService : ServiceTemplate, IProdBonusAttnService
|
|
{
|
|
public ProdBonusAttnService()
|
|
{
|
|
}
|
|
|
|
private void MapObject(ProdBonusAttn oProdBonusAttn, DataReader oReader)
|
|
{
|
|
//oProdBonusAttn.int = oReader.GetInt32("ProdBonusAttnID");
|
|
|
|
base.SetObjectID(oProdBonusAttn, (oReader.GetInt32("ProdBonusAttnID").Value));
|
|
oProdBonusAttn.ProdBonusSetupID = oReader.GetInt32("ProdBonusSetupID", 0);
|
|
oProdBonusAttn.BonusScheduleID = oReader.GetInt32("BonusScheduleID", 0);
|
|
oProdBonusAttn.ProdBonusLineID = oReader.GetInt32("ProdBonusLineID", 0);
|
|
oProdBonusAttn.EmployeeID = oReader.GetInt32("EmployeeID", 0);
|
|
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.Core.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(int id)
|
|
{
|
|
ProdBonusAttn oProdBonusAttn = new ProdBonusAttn();
|
|
|
|
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
|
|
}
|
|
|
|
return oProdBonusAttn;
|
|
}
|
|
|
|
public List<ProdBonusAttn> Get()
|
|
{
|
|
List<ProdBonusAttn> ProdBonusAttns = null;
|
|
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
|
|
}
|
|
|
|
return ProdBonusAttns;
|
|
}
|
|
|
|
public List<ProdBonusAttn> Get(int setupID, int ScheduleID)
|
|
{
|
|
List<ProdBonusAttn> ProdBonusAttns = new List<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 List<ProdBonusAttn> Get(int setupID, DateTime dateTime)
|
|
{
|
|
|
|
List<ProdBonusAttn> ProdBonusAttns = new List<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 List<ProdBonusAttn> GetBySetupID(int setupID)
|
|
{
|
|
List<ProdBonusAttn> ProdBonusAttns = new List<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 List<ProdBonusAttn> GetBySetupIDs(string setupIDs)
|
|
{
|
|
|
|
List<ProdBonusAttn> ProdBonusAttns = new List<ProdBonusAttn>();
|
|
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin();
|
|
DataReader dr = new DataReader(ProdBonusAttnDA.GetBySetupIDs(tc, setupIDs));
|
|
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 List<ProdBonusAttn> GetByLineID(int lineID)
|
|
{
|
|
List<ProdBonusAttn> ProdBonusAttns = new List<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 List<ProdBonusAttn> GetbySetupAndLineID(int setupID, int lineID)
|
|
{
|
|
List<ProdBonusAttn> ProdBonusAttns = new List<ProdBonusAttn>();
|
|
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin();
|
|
DataReader dr = new DataReader(ProdBonusAttnDA.GetbySetupAndLineID(tc, setupID, 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 List<ProdBonusAttn> GetbySetupAndLineIDbyInSQL(string setupID, string lineID)
|
|
{
|
|
List<ProdBonusAttn> ProdBonusAttns = new List<ProdBonusAttn>();
|
|
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin();
|
|
DataReader dr = new DataReader(ProdBonusAttnDA.GetbySetupAndLineIDbyInSQL(tc, setupID, 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 int Save(ProdBonusAttn oProdBonusAttn)
|
|
{
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin(true);
|
|
if (oProdBonusAttn.IsNew)
|
|
{
|
|
int id = tc.GenerateID("ProdBonusAttn", "ProdBonusAttnID");
|
|
base.SetObjectID(oProdBonusAttn, (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, int bSetupID, int scheduleID, DateTime date)
|
|
{
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin(true);
|
|
//ProdBonusAttnDA.Delete(tc, bSetupID, scheduleID);
|
|
ProdBonusAttnDA.Delete(tc, bSetupID, date);
|
|
if (oProdBonusAttns.Count > 0)
|
|
{
|
|
foreach (ProdBonusAttn item in oProdBonusAttns)
|
|
{
|
|
int id = tc.GenerateID("ProdBonusAttn", "ProdBonusAttnID");
|
|
base.SetObjectID(item, (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(int 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
|
|
}
|
|
} |