EchoTex_Payroll/HRM.DA/Service/Bonus/BonusProcessService.cs

1037 lines
34 KiB
C#
Raw Permalink Normal View History

2024-10-14 10:01:49 +06:00
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
{
#region BonusProcess Service
public class BonusProcessService : ServiceTemplate, IBonusProcessService
{
#region Private functions and declaration
private int _crgSerialId;
#endregion
public BonusProcessService()
{
_crgSerialId = 0;
}
private void MapObject(BonusProcess oBonusProcess, DataReader oReader)
{
base.SetObjectID(oBonusProcess, oReader.GetInt32("BonusProcessID" ).Value);
oBonusProcess.BonusID = oReader.GetInt32("bonusID").Value;
oBonusProcess.BonusMonth = oReader.GetDateTime("bonusMonth").Value;
oBonusProcess.BasicOnMonth = oReader.GetDateTime("basicOnMonth").Value;
oBonusProcess.DisburseDate = oReader.GetDateTime("disburseDate");
oBonusProcess.Remarks = oReader.GetString("remarks");
oBonusProcess.ShowInWeb = oReader.GetBoolean("showInWeb").Value;
oBonusProcess.IsDisburseWithSalary = oReader.GetBoolean("ISDISBURSEWITHSALARY").Value;
oBonusProcess.IsTaxProcess = oReader.GetBoolean("IsTaxProcess").Value;
oBonusProcess.CreatedBy = oReader.GetInt32("CreatedBy").Value;
oBonusProcess.CreatedDate = oReader.GetDateTime("CreationDate").HasValue
? oReader.GetDateTime("CreationDate").Value
: DateTime.MinValue;
oBonusProcess.ModifiedBy = oReader.GetInt32("ModifiedBy");
oBonusProcess.ModifiedDate = oReader.GetDateTime("ModifiedDate");
oBonusProcess.UsedProcess = oReader.GetInt32("UsedProcess").Value;
oBonusProcess.PayrollTypeID = oReader.GetInt32("PayrollTypeID").Value;
oBonusProcess.IsApprove = oReader.GetBoolean("IsApprove").Value;
this.SetObjectState(oBonusProcess, Ease.Core.ObjectState.Saved);
}
protected override T CreateObject<T>(DataReader oReader)
{
BonusProcess oBonusProcess = new BonusProcess();
MapObject(oBonusProcess, oReader);
return oBonusProcess as T;
}
protected BonusProcess CreateObject(DataReader oReader)
{
BonusProcess oBonusProcess = new BonusProcess();
MapObject(oBonusProcess, oReader);
return oBonusProcess;
}
private void MapBonusProDetailObject(BonusProcess.BonusProcessDetail oBonusPDetail, DataReader oReader)
{
base.SetObjectID(oBonusPDetail, oReader.GetInt32("BonusProcessDetailID").Value);
oBonusPDetail.BonusProcessID = oReader.GetInt32("bonusProcessID").Value;
oBonusPDetail.BonusID = oReader.GetInt32("bonusID").Value;
oBonusPDetail.EmployeeID = oReader.GetInt32("EmployeeID").Value;
oBonusPDetail.BonusMonth = oReader.GetDateTime("disburseDate").Value;
oBonusPDetail.BonusAmount = oReader.GetDouble("BonusAmount").Value;
oBonusPDetail.BasicSalary = oReader.GetDouble("BasicSalary").Value;
oBonusPDetail.GrossSalary = oReader.GetDouble("GrossSalary",true , 0);
oBonusPDetail.ChangeBonusAmount = oReader.GetDouble("ChangeBonusAmount").Value;
oBonusPDetail.ChangeTaxAmount = oReader.GetDouble("ChangeTaxAmount").Value;
oBonusPDetail.ChangeAdjustAmount = oReader.GetDouble("ChangeAdjustAmount").Value;
oBonusPDetail.ChangeSalaryItemAmount = oReader.GetDouble("ChangeSalaryItemAmount").Value;
oBonusPDetail.CalculatedAdjustAmount = oReader.GetDouble("CalculatedAdjustAmount").Value;
oBonusPDetail.CalculatedSalaryItemAmount = oReader.GetDouble("CalculatedSalaryItemAmount").Value;
oBonusPDetail.TaxAmount = oReader.GetDouble("taxAmount").Value;
oBonusPDetail.ModifiedBy = oReader.GetInt32("ModifiedBy");
oBonusPDetail.ModifiedDate = oReader.GetDateTime("ModifiedDate").HasValue
? oReader.GetDateTime("ModifiedDate").Value
: (DateTime?)null;
this.SetObjectState(oBonusPDetail, Ease.Core.ObjectState.Saved);
}
protected List<BonusProcess.BonusProcessDetail> CreateBonusProcessDetailObject(DataReader oReader)
{
List<BonusProcess.BonusProcessDetail> oBonusProDetails = new List<BonusProcess.BonusProcessDetail>();
while (oReader.Read())
{
BonusProcess.BonusProcessDetail oBonusPDetail = new BonusProcess.BonusProcessDetail();
MapBonusProDetailObject(oBonusPDetail, oReader);
oBonusProDetails.Add(oBonusPDetail);
}
return oBonusProDetails;
}
private void MapBonusProDetailCumalativeObject(BonusProcess.BonusProcessDetail oBonusPDetail,
DataReader oReader)
{
oBonusPDetail.BonusID = oReader.GetInt32("bonusID", 0);
oBonusPDetail.EmployeeID = oReader.GetInt32("EmployeeID", 0);
oBonusPDetail.ChangeBonusAmount = oReader.GetDouble("BonusAmount").Value;
oBonusPDetail.ChangeSalaryItemAmount = oReader.GetDouble("Count").Value;
this.SetObjectState(oBonusPDetail, Ease.Core.ObjectState.Saved);
}
protected List<BonusProcess.BonusProcessDetail> CreateBonusProcessDetailCumalativeObject(DataReader oReader)
{
List<BonusProcess.BonusProcessDetail> oBonusProDetails = new List<BonusProcess.BonusProcessDetail>();
while (oReader.Read())
{
BonusProcess.BonusProcessDetail oBonusPDetail = new BonusProcess.BonusProcessDetail();
MapBonusProDetailCumalativeObject(oBonusPDetail, oReader);
oBonusProDetails.Add(oBonusPDetail);
}
return oBonusProDetails;
}
#region Service implementation
public double GetBonusAmount(DateTime bonusMonthFirstDate, int employeeID, int bonusID, int payrolltypeid)
{
double bonusAmount = 0;
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin();
bonusAmount =
BonusProcessDA.GetBonusAmount(tc, bonusMonthFirstDate, employeeID, bonusID, payrolltypeid);
tc.End();
}
catch (Exception e)
{
#region Handle Exception
if (tc != null)
tc.HandleError();
ExceptionLog.Write(e);
throw new ServiceException(e.Message, e);
#endregion
}
return bonusAmount;
}
public List<BonusProcess> GetProcess(int nBonusID, DateTime dBonusMonth, int payrolltypeid)
{
List<BonusProcess> bonusProcesss = null;
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin();
DataReader dr = new DataReader(BonusProcessDA.GetProcess(tc, nBonusID, dBonusMonth, payrolltypeid));
bonusProcesss = this.CreateObjects<BonusProcess>(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 bonusProcesss;
}
public double GetUsedBonusWithinYear(DateTime bonusMonthFirstDate, int bonusID, int payrolltypeid)
{
double usedBonus = 0;
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin();
usedBonus = BonusProcessDA.GetUsedBonusWithinYear(tc, bonusMonthFirstDate, bonusID, payrolltypeid);
tc.End();
}
catch (Exception e)
{
#region Handle Exception
if (tc != null)
tc.HandleError();
ExceptionLog.Write(e);
throw new ServiceException(e.Message, e);
#endregion
}
return usedBonus;
}
public double GetBonusAmountWithinYear(DateTime bonusYearDate, int employeeID, int bonusID, int payrolltypeid)
{
double bonusAmount = 0;
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin();
bonusAmount =
BonusProcessDA.GetBonusAmountWithinYear(tc, bonusYearDate, employeeID, bonusID, payrolltypeid);
tc.End();
}
catch (Exception e)
{
#region Handle Exception
if (tc != null)
tc.HandleError();
ExceptionLog.Write(e);
throw new ServiceException(e.Message, e);
#endregion
}
return bonusAmount;
}
public BonusProcess Get(int id)
{
BonusProcess oBonusProcess = new BonusProcess();
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin();
DataReader oreader = new DataReader(BonusProcessDA.Get(tc, id));
if (oreader.Read())
{
oBonusProcess = this.CreateObject<BonusProcess>(oreader);
}
oreader.Close();
if (oBonusProcess != null)
{
DataReader ddetail = new DataReader(BonusProcessDA.GetBonusDetails(tc, id));
oBonusProcess.BonusProcessDetails = this.CreateBonusProcessDetailObject(ddetail);
ddetail.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 oBonusProcess;
}
public List<BonusProcess> Get(EnumStatus status, int payrolltypeid)
{
List<BonusProcess> bonusProcesss = null;
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin();
DataReader dr = new DataReader(BonusProcessDA.Get(tc, status, payrolltypeid));
bonusProcesss = this.CreateObjects<BonusProcess>(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 bonusProcesss;
}
public int GetForNoOfPaidForEmp(DateTime bonusMonthFirstDate, int bonusID, int empid, int payrolltypeid)
{
int bonusAmount = 0;
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin();
bonusAmount =
BonusProcessDA.GetForNoOfPaidForEmp(tc, bonusMonthFirstDate, bonusID, empid, payrolltypeid);
tc.End();
}
catch (Exception e)
{
#region Handle Exception
if (tc != null)
tc.HandleError();
ExceptionLog.Write(e);
throw new ServiceException(e.Message, e);
#endregion
}
return bonusAmount;
}
public int GetForNoOfPaid(DateTime bonusMonthFirstDate, int bonusID, int payrolltypeid)
{
int bonusAmount = 0;
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin();
bonusAmount = BonusProcessDA.GetForNoOfPaid(tc, bonusMonthFirstDate, bonusID, payrolltypeid);
tc.End();
}
catch (Exception e)
{
#region Handle Exception
if (tc != null)
tc.HandleError();
ExceptionLog.Write(e);
throw new ServiceException(e.Message, e);
#endregion
}
return bonusAmount;
}
public List<BonusProcess.BonusProcessDetail> GetBonusDetails(int processID)
{
List<BonusProcess.BonusProcessDetail> bonusProcessDetails = null;
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin();
DataReader dr = new DataReader(BonusProcessDA.GetBonusDetails(tc, processID));
bonusProcessDetails = this.CreateBonusProcessDetailObject(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 bonusProcessDetails;
}
public List<BonusProcess.BonusProcessDetail> GetBonusDetailsByEmps(string empsIDs, DateTime fromDate, DateTime toDate, int payrollTypeID)
{
List<BonusProcess.BonusProcessDetail> bonusProcessDetails = new List<BonusProcess.BonusProcessDetail>();
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin();
DataReader dr = new DataReader(BonusProcessDA.GetBonusDetailsbyEmps(tc, empsIDs, fromDate, toDate, payrollTypeID));
bonusProcessDetails = this.CreateBonusProcessDetailObject(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 bonusProcessDetails;
}
public BonusProcess Get(int bonusID, DateTime dBonusMonth, int payrolltypeid)
{
BonusProcess oProcess = null;
//bjectsTemplate<BonusProcess.BonusProcessDetail.BonusProcessAdjustItem> oBonusProcessAdjustItems = null;
//List<BonusProcess.BonusProcessDetail.BonusProcessSalaryItem> oBonusProcessSalaryItems = null;
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin();
DataReader dr = new DataReader(BonusProcessDA.Get(tc, bonusID, dBonusMonth, payrolltypeid));
if (dr.Read())
{
oProcess = this.CreateObject<BonusProcess>(dr);
}
dr.Close();
if (oProcess != null)
{
dr = new DataReader(BonusProcessDA.GetBonusDetails(tc, oProcess.ID));
oProcess.BonusProcessDetails = this.CreateBonusProcessDetailObject(dr);
dr.Close();
//if(oProcess.BonusProcessDetails!=null && oProcess.BonusProcessDetails.Count>0)
//{
// dr = new DataReader(BonusProcessDA.GetBProcessSalaryItem(tc, oProcess.ID));
// if(dr.Read())
// {
// oBonusProcessSalaryItems = this.CreateBonusPSItemObject(dr);
// }
// dr.Close();
// dr = new DataReader(BonusProcessDA.GetBProcessAdjust(tc, oProcess.ID));
// if(dr.Read())
// {
// oBonusProcessAdjustItems=this.CreateBonusProcessAItemObject(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 oProcess;
}
public List<BonusProcess> GetProcess(DateTime dBonusMonth, int payrolltypeid)
{
List<BonusProcess> bonusProcesss = null;
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin();
DataReader dr = new DataReader(BonusProcessDA.GetProcess(tc, dBonusMonth, payrolltypeid));
bonusProcesss = this.CreateObjects<BonusProcess>(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 bonusProcesss;
}
public List<BonusProcess.BonusProcessDetail> GetSumOfBonusDetails(DateTime fromMonth, DateTime toMonth,
int payrolltypeid)
{
List<BonusProcess.BonusProcessDetail> bonusProcessDetails = null;
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin();
DataReader dr =
new DataReader(BonusProcessDA.GetSumOfBonusDetails(tc, fromMonth, toMonth, payrolltypeid));
bonusProcessDetails = this.CreateBonusProcessDetailCumalativeObject(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 bonusProcessDetails;
}
public List<BonusProcess.BonusProcessDetail> GetBonusDetails(DateTime dMonth, bool bPayWithalary,
int payrolltypeid)
{
List<BonusProcess.BonusProcessDetail> bonusProcessDetails = null;
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin();
DataReader dr =
new DataReader(BonusProcessDA.GetBonusDetails(tc, dMonth, bPayWithalary, payrolltypeid));
bonusProcessDetails = this.CreateBonusProcessDetailObject(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 bonusProcessDetails;
}
//public List<BonusProcess.BonusProcessDetail.BonusProcessAdjustItem> GetBProcessAdjust(int processDetailID)
//{
// #region Cache Header
// List<BonusProcess.BonusProcessDetail.BonusProcessAdjustItem> bonusProcessAdjustItems = _cache["GetBProcessAdjust", processDetailID] as List<BonusProcess.BonusProcessDetail.BonusProcessAdjustItem>;
// if (bonusProcessAdjustItems != null)
// return bonusProcessAdjustItems;
// #endregion
// TransactionContext tc = null;
// try
// {
// tc = TransactionContext.Begin();
// DataReader dr = new DataReader(BonusProcessDA.GetBProcessAdjust(tc, processDetailID));
// bonusProcessAdjustItems = this.CreateBonusProcessAItemObject(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
// }
// #region Cache Footer
// _cache.Add(bonusProcessAdjustItems, "GetBProcessAdjust", processDetailID);
// #endregion
// return bonusProcessAdjustItems;
//}
public DataSet GetBonusRegister(int bonusID, DateTime dBonusMonth, string sEmpID, int payrolltypeid)
{
DataSet oBonusRegisters = new DataSet();
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin();
oBonusRegisters = BonusProcessDA.GetBonusRegister(tc, bonusID, dBonusMonth, sEmpID, payrolltypeid);
tc.End();
}
catch (Exception e)
{
#region Handle Exception
if (tc != null)
tc.HandleError();
ExceptionLog.Write(e);
throw new ServiceException(e.Message, e);
#endregion
}
return oBonusRegisters;
}
public DataSet GetBonusBankAdvice(int bonusID, DateTime dBonusMonth, string sEmpID, int payrolltypeid)
{
DataSet oBonusRegisters = new DataSet();
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin();
oBonusRegisters = BonusProcessDA.GetBonusBankAdvice(tc, bonusID, dBonusMonth, sEmpID, payrolltypeid);
tc.End();
}
catch (Exception e)
{
#region Handle Exception
if (tc != null)
tc.HandleError();
ExceptionLog.Write(e);
throw new ServiceException(e.Message, e);
#endregion
}
return oBonusRegisters;
}
public DataSet GetBonusPaySlip(int bonusID, DateTime dBonusMonth, string sEmpID, int payrolltypeid)
{
DataSet oBonusBankSlip = new DataSet();
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin();
oBonusBankSlip = BonusProcessDA.GetBonusPaySlip(tc, bonusID, dBonusMonth, sEmpID, payrolltypeid);
tc.End();
}
catch (Exception e)
{
#region Handle Exception
if (tc != null)
tc.HandleError();
ExceptionLog.Write(e);
throw new ServiceException(e.Message, e);
#endregion
}
return oBonusBankSlip;
}
public DataTable GetBonusItemsForESSBonusPayslip(int EmployeeID)
{
DataTable dSet = null;
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin();
dSet = BonusProcessDA.GetBonusItemsForESSBonusPayslip(tc, EmployeeID);
tc.End();
}
catch (Exception e)
{
#region Handle Exception
if (tc != null)
tc.HandleError();
ExceptionLog.Write(e);
throw new ServiceException(e.Message, e);
#endregion
}
return dSet;
}
public int Save(BonusProcess oBonusProcess)
{
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin(true);
if (oBonusProcess.IsNew)
{
int id = tc.GenerateID("BONUSPROCESS", "BONUSPROCESSID");
base.SetObjectID(oBonusProcess, (id));
BonusProcessDA.Insert(tc, oBonusProcess);
}
else
{
BonusProcessDA.Update(tc, oBonusProcess);
BonusProcessDA.DeleteProcessDetailByProcessID(tc, oBonusProcess.BonusID, oBonusProcess.ID,
oBonusProcess.PayrollTypeID);
}
List<IncomeTax> incometaxes = new List<IncomeTax>();
foreach (BonusProcess.BonusProcessDetail oBonusProcessDetail in oBonusProcess.BonusProcessDetails)
{
int id = tc.GenerateID("BONUSPROCESSDETAIL", "BonusProcessDetailID");
base.SetObjectID(oBonusProcessDetail, (id));
oBonusProcessDetail.BonusProcessID = oBonusProcess.ID;
BonusProcessDA.Insert(tc, oBonusProcessDetail);
IncomeTaxService osvr = new IncomeTaxService();
// IncomeTaxcoll null mean tax process not required
if (oBonusProcessDetail.IncomeTaxcoll != null && oBonusProcessDetail.IncomeTaxcoll.Count > 0)
{
foreach(IncomeTax tx in oBonusProcessDetail.IncomeTaxcoll)
{
incometaxes.Add(tx);
}
}
}
if(incometaxes.Count >0)
{
new IncomeTaxService().SaveBulk(tc, incometaxes, EnumIncomeTaxDataFrom.BonusITTempData);
}
tc.End();
return oBonusProcess.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(BonusProcess oProcess)
{
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin(true);
BonusProcessDA.UndoProcess(tc, oProcess);
if (oProcess.IsTaxProcess == true)
new IncomeTaxService().Delete(tc, oProcess.getEmpID(), EnumIncomeTaxDataFrom.BonusITTempData);
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 ApproveBonus(int bonusID, DateTime bonusMonth, int payrolltypeid)
{
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin(true);
BonusProcessDA.ApproveBonus(tc, bonusID, bonusMonth);
List<IncomeTax> intx = new IncomeTaxService().Get(EnumIncomeTaxDataFrom.BonusITTempData, payrolltypeid);
if(intx != null && intx.Count >0)
{
new IncomeTaxService().Delete(tc, new IncomeTax().getEmpID(intx), EnumIncomeTaxDataFrom.ProcessTempData);
new IncomeTaxService().Delete(tc, new IncomeTax().getEmpID(intx), EnumIncomeTaxDataFrom.BonusITTempData);
new IncomeTaxService().SaveBulk(tc, intx, EnumIncomeTaxDataFrom.ProcessTempData);
}
tc.End();
}
catch (Exception e)
{
#region Handle Exception
if (tc != null)
tc.HandleError();
ExceptionLog.Write(e);
throw new ServiceException(e.Message, e);
#endregion
}
}
public bool IsApproved(int bonusID, DateTime bonusMonth, int payrolltypeid)
{
TransactionContext tc = null;
bool isApproved = false;
try
{
tc = TransactionContext.Begin(true);
isApproved =BonusProcessDA.IsApproved(tc, payrolltypeid, bonusID, bonusMonth);
tc.End();
}
catch (Exception e)
{
#region Handle Exception
if (tc != null)
tc.HandleError();
ExceptionLog.Write(e);
throw new ServiceException(e.Message, e);
#endregion
}
return isApproved;
}
public DataTable GetUnApprovedBonuses(DateTime dMonthDate, int payrollTypeID)
{
DataTable ot = null;
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin();
ot = BonusProcessDA.GetUnApprovedBonuses(tc, dMonthDate, payrollTypeID);
tc.End();
}
catch (Exception e)
{
#region Handle Exception
if (tc != null)
tc.HandleError();
ExceptionLog.Write(e);
throw new ServiceException(e.Message, e);
#endregion
}
return ot;
}
public double GetBonusAmount(DateTime bonusMonthFirstDate, int employeeID, int bonusID)
{
throw new NotImplementedException();
}
public double GetBonusAmountWithinYear(DateTime bonusYearDate, int employeeID, int bonusID)
{
throw new NotImplementedException();
}
public double GetUsedBonusWithinYear(DateTime bonusYearDate, int bonusID)
{
throw new NotImplementedException();
}
public BonusProcess CalculateBonus(int payrolltypeid, List<Employee> employees, int bonusid, DateTime dBasicMonth,
DateTime dPayDate, DateTime dCuttOfDate, double CurrProcess, bool IsDisburseWithSalary, bool IsTaxProcess)
{
return new BonusCalculator().CalCulate(payrolltypeid, employees, bonusid, dBasicMonth,
dPayDate, dCuttOfDate, CurrProcess, IsDisburseWithSalary, IsTaxProcess);
}
public List< BonusProcess.BonusProcessDetail> CalculateBonusTax(List<BonusProcess.BonusProcessDetail> bonusDetails,
List<Employee> employees, int bonusid, int payrolltypeid)
{
Bonus obonus = new BonusService().Get(bonusid);
new BonusCalculator().CalculateTax(bonusDetails, employees, obonus, payrolltypeid);
return bonusDetails;
}
public void UndoBonusProcess(BonusProcess bonusProcess)
{
try
{
bonusProcess = new BonusProcessService().Get(bonusProcess.ID);
if(bonusProcess.IsApprove ==true)
{
throw new Exception("Approved Bonus is not allowed to delete.");
}
this.Delete(bonusProcess);
}
catch (Exception ex)
{
throw new Exception(ex.Message);
}
}
public int GetForNoOfPaid(DateTime bonusYear, int bonusID)
{
throw new NotImplementedException();
}
public BonusProcess Get(int bonusID, DateTime bonusMonth)
{
throw new NotImplementedException();
}
public List<BonusProcess.BonusProcessDetail> GetBonusDetails(int payrolltypeid, int bonusid, DateTime dMonth)
{
List<BonusProcess.BonusProcessDetail> bonusProcessDetails = null;
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin();
DataReader dr = new DataReader(BonusProcessDA.GetBonusDetails(tc, payrolltypeid, bonusid, dMonth));
bonusProcessDetails = this.CreateBonusProcessDetailObject(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 bonusProcessDetails;
}
public List<BonusProcess.BonusProcessDetail> GetSumOfBonusDetails(DateTime fromMonth, DateTime toDate)
{
throw new NotImplementedException();
}
public DataSet GetBonusRegisterNew(int BonusID, DateTime dBonusMonth, string sEmpID, int payrolltypeid)
{
DataSet oBonusRegisters = new DataSet();
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin();
oBonusRegisters = BonusProcessDA.GetBonusRegisterNew(tc, BonusID, dBonusMonth, sEmpID, payrolltypeid);
tc.End();
}
catch (Exception e)
{
#region Handle Exception
if (tc != null)
tc.HandleError();
ExceptionLog.Write(e);
throw new ServiceException(e.Message, e);
#endregion
}
return oBonusRegisters;
}
public DataSet GetBonusBankAdvice(int BonusID, DateTime dBonusMonth, string sEmpID)
{
throw new NotImplementedException();
}
public DataSet GetBonusPaySlip(int BonusID, DateTime dBonusMonth, string sEmpID)
{
throw new NotImplementedException();
}
public List<BonusProcess> GetProcess(int bonusID, DateTime bonusMonth)
{
throw new NotImplementedException();
}
public List<BonusProcess> GetProcess(DateTime bonusMonth)
{
throw new NotImplementedException();
}
public int GetForNoOfPaidForEmp(DateTime bonusYearDate, int bonusID, int empId)
{
throw new NotImplementedException();
}
#endregion
}
#endregion
}