449 lines
16 KiB
C#
449 lines
16 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using Ease.CoreV35.Model;
|
|
using Ease.CoreV35.DataAccess;
|
|
using Ease.CoreV35;
|
|
using Payroll.BO;
|
|
using System.Data;
|
|
|
|
namespace Payroll.Service
|
|
{
|
|
class ProdBonusProcessService : ServiceTemplate, IProdBonusProcessService
|
|
{
|
|
#region Object Mapping
|
|
|
|
private void MapObject(ProdBonusProcess oProdBonusProcess, DataReader oReader)
|
|
{
|
|
base.SetObjectID(oProdBonusProcess, oReader.GetID("ProdBonusProcessID"));
|
|
oProdBonusProcess.SalaryMonth = oReader.GetDateTime("SalaryMonth").Value;
|
|
oProdBonusProcess.ProcessDate = oReader.GetDateTime("ProcessDate").Value;
|
|
|
|
this.SetObjectState(oProdBonusProcess, ObjectState.Saved);
|
|
}
|
|
|
|
|
|
protected override T CreateObject<T>(DataReader oReader)
|
|
{
|
|
ProdBonusProcess oProdBonusProcess = new ProdBonusProcess();
|
|
MapObject(oProdBonusProcess, oReader);
|
|
return oProdBonusProcess as T;
|
|
}
|
|
|
|
private void MapProdBonusProcessEmpObject(ProdBonusProcessEmp oProdBonusProcessEmp, DataReader oReader)
|
|
{
|
|
SetObjectID(oProdBonusProcessEmp, oReader.GetID("ProdBonusProcessEmpID"));
|
|
oProdBonusProcessEmp.EmployeeID = oReader.GetID("EmployeeID");
|
|
oProdBonusProcessEmp.Description = oReader.GetString("Description");
|
|
oProdBonusProcessEmp.ProdBonusProcessID = oReader.GetID("ProdBonusProcessID");
|
|
oProdBonusProcessEmp.Amount = oReader.GetDouble("Amount").Value == 0.0 ? 0.0 : oReader.GetDouble("Amount").Value;
|
|
this.SetObjectState(oProdBonusProcessEmp, ObjectState.Saved);
|
|
}
|
|
private ProdBonusProcessEmp CreateProdBonusProcessEmpObject(DataReader oReader)
|
|
{
|
|
ProdBonusProcessEmp item = new ProdBonusProcessEmp();
|
|
MapProdBonusProcessEmpObject(item, oReader);
|
|
return item;
|
|
}
|
|
protected ObjectsTemplate<ProdBonusProcessEmp> CreateProdBonusProcessEmpObjects(DataReader oReader)
|
|
{
|
|
ObjectsTemplate<ProdBonusProcessEmp> oItems = new ObjectsTemplate<ProdBonusProcessEmp>();
|
|
while (oReader.Read())
|
|
{
|
|
ProdBonusProcessEmp item = CreateProdBonusProcessEmpObject(oReader);
|
|
oItems.Add(item);
|
|
}
|
|
return oItems;
|
|
}
|
|
private void MapProdBonusProcessItemObject(ProdBonusProcessItem oProdBonusProcessItem, DataReader oReader)
|
|
{
|
|
SetObjectID(oProdBonusProcessItem, oReader.GetID("ProdBonusProcessItemID"));
|
|
oProdBonusProcessItem.ProdBonusSetupID = oReader.GetID("ProdBonusSetupID");
|
|
oProdBonusProcessItem.ProdBonusProcessID = oReader.GetID("ProdBonusProcessID");
|
|
oProdBonusProcessItem.EmployeeID = oReader.GetID("EmployeeID");
|
|
oProdBonusProcessItem.ProdBonusLineID = oReader.GetID("ProdBonusLineID");
|
|
oProdBonusProcessItem.Amount = oReader.GetDouble("Amount").Value == 0.0 ? 0.0 : oReader.GetDouble("Amount").Value;
|
|
oProdBonusProcessItem.OTHour = oReader.GetDouble("OTHour").Value == 0.0 ? 0.0 : oReader.GetDouble("OTHour").Value;
|
|
oProdBonusProcessItem.AchievePercent = oReader.GetDouble("AchievePercent").Value == 0.0 ? 0.0 : oReader.GetDouble("AchievePercent").Value;
|
|
oProdBonusProcessItem.WorkingHour = oReader.GetDouble("WorkingHour").Value == 0.0 ? 0.0 : oReader.GetDouble("WorkingHour").Value;
|
|
this.SetObjectState(oProdBonusProcessItem, ObjectState.Saved);
|
|
}
|
|
private ProdBonusProcessItem CreateProdBonusProcessItemObject(DataReader oReader)
|
|
{
|
|
ProdBonusProcessItem item = new ProdBonusProcessItem();
|
|
MapProdBonusProcessItemObject(item, oReader);
|
|
return item;
|
|
}
|
|
protected ObjectsTemplate<ProdBonusProcessItem> CreateProdBonusProcessItemObjects(DataReader oReader)
|
|
{
|
|
ObjectsTemplate<ProdBonusProcessItem> oItems = new ObjectsTemplate<ProdBonusProcessItem>();
|
|
while (oReader.Read())
|
|
{
|
|
ProdBonusProcessItem item = CreateProdBonusProcessItemObject(oReader);
|
|
oItems.Add(item);
|
|
}
|
|
return oItems;
|
|
}
|
|
#endregion
|
|
|
|
#region Service Implementation
|
|
|
|
#region Get All
|
|
|
|
public ObjectsTemplate<ProdBonusProcess> Get()
|
|
{
|
|
ObjectsTemplate<ProdBonusProcess> oProdBonusProcess = null;
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin();
|
|
DataReader oreader = new DataReader(ProdBonusProcessDA.Get(tc));
|
|
oProdBonusProcess = this.CreateObjects<ProdBonusProcess>(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 oProdBonusProcess;
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region Get All
|
|
|
|
public ObjectsTemplate<ProdBonusProcess> Get(DateTime dtSalaryMonth)
|
|
{
|
|
ObjectsTemplate<ProdBonusProcess> oProdBonusProcess = null;
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin();
|
|
DataReader oreader = new DataReader(ProdBonusProcessDA.Get(tc, dtSalaryMonth));
|
|
oProdBonusProcess = this.CreateObjects<ProdBonusProcess>(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 oProdBonusProcess;
|
|
}
|
|
public DataSet GetDetailItems(DateTime dtSalaryMonth)
|
|
{
|
|
DataSet oProdBonusProcess = null;
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin();
|
|
oProdBonusProcess = ProdBonusProcessDA.GetDetailItems(tc, dtSalaryMonth);
|
|
tc.End();
|
|
}
|
|
|
|
catch (Exception e)
|
|
{
|
|
#region Handle Exception
|
|
if (tc != null)
|
|
tc.HandleError();
|
|
ExceptionLog.Write(e);
|
|
throw new ServiceException(e.Message, e);
|
|
#endregion
|
|
}
|
|
return oProdBonusProcess;
|
|
}
|
|
public ObjectsTemplate<ProdBonusProcessEmp> GetProdBonusProcessEmps(ID nID)
|
|
{
|
|
ObjectsTemplate<ProdBonusProcessEmp> oProdBonusProcess = null;
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin();
|
|
DataReader oreader = new DataReader(ProdBonusProcessDA.GetProdBonusProcessEmp(tc, nID));
|
|
oProdBonusProcess = this.CreateProdBonusProcessEmpObjects(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 oProdBonusProcess;
|
|
}
|
|
public ObjectsTemplate<ProdBonusProcessItem> GetProdBonusProcessItems(ID nID)
|
|
{
|
|
ObjectsTemplate<ProdBonusProcessItem> oProdBonusProcess = null;
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin();
|
|
DataReader oreader = new DataReader(ProdBonusProcessDA.GetProdBonusProcessItem(tc, nID));
|
|
oProdBonusProcess = this.CreateProdBonusProcessItemObjects(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 oProdBonusProcess;
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region Get Single
|
|
|
|
public ProdBonusProcess Get(ID id)
|
|
{
|
|
ProdBonusProcess oProdBonusProcess = null;
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin();
|
|
DataReader oreader = new DataReader(ProdBonusProcessDA.Get(tc, id));
|
|
oProdBonusProcess = this.CreateObject<ProdBonusProcess>(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 oProdBonusProcess;
|
|
}
|
|
|
|
|
|
public ProdBonusProcessEmp GetProdBonusEmp(ID Id, DateTime salaryMonth)
|
|
{
|
|
ProdBonusProcessEmp oProdBonusProcessEmp = null;
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin();
|
|
DataReader oreader = new DataReader(ProdBonusProcessDA.GetProdBonusEmp(tc, Id, salaryMonth));
|
|
if (oreader.Read())
|
|
oProdBonusProcessEmp = this.CreateProdBonusProcessEmpObject(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 oProdBonusProcessEmp;
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region Get DataSet For Report
|
|
|
|
public DataSet GetMontlyProdBonus(DateTime dBonusMonth)
|
|
{
|
|
DataSet oProdBonus = new DataSet();
|
|
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin();
|
|
oProdBonus = BonusProcessDA.GetMontlyProdBonus(tc, dBonusMonth);
|
|
tc.End();
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
#region Handle Exception
|
|
if (tc != null)
|
|
tc.HandleError();
|
|
ExceptionLog.Write(e);
|
|
throw new ServiceException(e.Message, e);
|
|
#endregion
|
|
}
|
|
return oProdBonus;
|
|
}
|
|
public DataSet GetProdBonusDetail(int designID)
|
|
{
|
|
DataSet oProdBonus = new DataSet();
|
|
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin();
|
|
oProdBonus = BonusProcessDA.GetProdBonusDetail(tc, designID);
|
|
tc.End();
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
#region Handle Exception
|
|
if (tc != null)
|
|
tc.HandleError();
|
|
ExceptionLog.Write(e);
|
|
throw new ServiceException(e.Message, e);
|
|
#endregion
|
|
}
|
|
return oProdBonus;
|
|
}
|
|
public DataSet EmpDesignWiseProdBonus(DateTime dBonusMonth)
|
|
{
|
|
DataSet oProdBonus = new DataSet();
|
|
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin();
|
|
oProdBonus = BonusProcessDA.EmpDesignWiseProdBonus(tc, dBonusMonth);
|
|
tc.End();
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
#region Handle Exception
|
|
if (tc != null)
|
|
tc.HandleError();
|
|
ExceptionLog.Write(e);
|
|
throw new ServiceException(e.Message, e);
|
|
#endregion
|
|
}
|
|
return oProdBonus;
|
|
}
|
|
#endregion
|
|
|
|
#region Insert
|
|
|
|
public void Save(ObjectsTemplate<ProdBonusProcess> items)
|
|
{
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin(true);
|
|
if (items.Count > 0)
|
|
ProdBonusProcessDA.DeleteBySalaryMonth(tc, items[0].SalaryMonth);
|
|
foreach (ProdBonusProcess item in items)
|
|
{
|
|
int id = tc.GenerateID("ProdBonusProcess", "ProdBonusProcessID");
|
|
base.SetObjectID(item, ID.FromInteger(id));
|
|
ProdBonusProcessDA.Save(tc, item);
|
|
foreach (ProdBonusProcessEmp og in item.ProdBonusProcessEmps)
|
|
{
|
|
int id1 = tc.GenerateID("ProdBonusProcessEmp", "ProdBonusProcessEmpID");
|
|
base.SetObjectID(og, ID.FromInteger(id1));
|
|
og.ProdBonusProcessID = item.ID;
|
|
ProdBonusProcessDA.SaveEmp(tc, og);
|
|
}
|
|
foreach (ProdBonusProcessItem og in item.ProdBonusProcessItems)
|
|
{
|
|
int id1 = tc.GenerateID("ProdBonusProcessItem", "ProdBonusProcessItemID");
|
|
base.SetObjectID(og, ID.FromInteger(id1));
|
|
og.ProdBonusProcessID = item.ID;
|
|
ProdBonusProcessDA.SaveItem(tc, og);
|
|
}
|
|
}
|
|
tc.End();
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
#region Handle Exception
|
|
if (tc != null)
|
|
tc.HandleError();
|
|
ExceptionLog.Write(e);
|
|
throw new ServiceException(e.Message, e);
|
|
#endregion
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region Delete
|
|
|
|
public void Delete(ID id)
|
|
{
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin(true);
|
|
ProdBonusProcessDA.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
|
|
|
|
#region Undo
|
|
public void UndoProcess(ObjectsTemplate<ProdBonusProcess> oProdBonusProsses, ADParameter _ADParam, DateTime dtSalaryMonth)
|
|
{
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin(true);
|
|
foreach (ProdBonusProcess item in oProdBonusProsses)
|
|
{
|
|
foreach (ProdBonusProcessItem processItem in item.ProdBonusProcessItems)
|
|
{
|
|
ADParameterEmployeeDA.DeleteByAllowDeductMonth(tc, processItem.EmployeeID, _ADParam.AllowDeductID, dtSalaryMonth);
|
|
}
|
|
}
|
|
ProdBonusProcessDA.DeleteBySalaryMonth(tc, dtSalaryMonth);
|
|
tc.End();
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
#region Handle Exception
|
|
if (tc != null)
|
|
tc.HandleError();
|
|
ExceptionLog.Write(e);
|
|
throw new ServiceException(e.Message, e);
|
|
#endregion
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
#endregion
|
|
|
|
}
|
|
|
|
} |