EchoTex_Payroll/HRM.DA/Service/Employee/EmployeeTaxExceptionService.cs

196 lines
5.8 KiB
C#
Raw Normal View History

2024-10-14 10:01:49 +06:00
using Ease.Core.DataAccess;
using Ease.Core.Model;
using Ease.Core.Utility;
using HRM.BO;
using System;
using System.Collections.Generic;
namespace HRM.DA
{
public class EmployeeTaxExceptionService : ServiceTemplate, IEmployeeTaxExcecptionService
{
public EmployeeTaxExceptionService()
{
}
private void MapObject(EmployeeTaxException oEmployeeException, DataReader oReader)
{
try
{
oEmployeeException.EmployeeID = oReader.GetInt32("employeeID", 0);
oEmployeeException.EmployeeNo = oReader.GetString("employeeNo");
oEmployeeException.Name = oReader.GetString("name");
oEmployeeException.ItemValue = oReader.GetBoolean("itemValue").Value;
oEmployeeException.Type = oReader.GetInt32("type").Value;
this.SetObjectState(oEmployeeException, Ease.Core.ObjectState.Saved);
}
catch (Exception e)
{
ExceptionLog.Write(e);
throw new ServiceException(e.Message, e);
}
}
protected override T CreateObject<T>(DataReader oReader)
{
EmployeeTaxException oEmployeeException = new EmployeeTaxException();
MapObject(oEmployeeException, oReader);
return oEmployeeException as T;
}
protected EmployeeTaxException CreateObject(DataReader oReader)
{
EmployeeTaxException oEmployeeException = new EmployeeTaxException();
MapObject(oEmployeeException, oReader);
return oEmployeeException;
}
#region Service implementation
public List<EmployeeTaxException> GetEmployeeDataUsingExceptionType(string ExceptionType)
{
TransactionContext tc = null;
List<EmployeeTaxException> employees = new List<EmployeeTaxException>();
try
{
tc = TransactionContext.Begin();
DataReader dr = new DataReader(EmployeeDA.GetEmployeeDataUsingExceptionType(tc, ExceptionType));
employees = this.CreateObjects<EmployeeTaxException>(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 employees;
}
public List<EmployeeTaxException> GetEmployeeDataUsingPersonType(int ExceptionType)
{
TransactionContext tc = null;
List<EmployeeTaxException> employees = new List<EmployeeTaxException>();
try
{
tc = TransactionContext.Begin();
DataReader dr = new DataReader(EmployeeDA.GetEmployeeDataUsingPersonType(tc, ExceptionType));
employees = this.CreateObjects<EmployeeTaxException>(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 employees;
}
public List<EmployeeTaxException> GetEmployeeDataUsingTaxCircle(int TaxCircleType)
{
TransactionContext tc = null;
List<EmployeeTaxException> employees = new List<EmployeeTaxException>();
try
{
tc = TransactionContext.Begin();
DataReader dr = new DataReader(EmployeeDA.GetEmployeeDataUsingTaxCircle(tc, TaxCircleType));
employees = this.CreateObjects<EmployeeTaxException>(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 employees;
}
public void UpdateEmployeeByPersonType(List<EmployeeTaxException> EmployeeInfo)
{
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin(true);
foreach (var item in EmployeeInfo)
{
EmployeeDA.UpdateEmployeeByPersonType(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 UpdateEmployeeByTaxCircle(List<EmployeeTaxException> EmployeeInfo)
{
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin(true);
foreach (var item in EmployeeInfo)
{
EmployeeDA.UpdateEmployeeByTaxCircle(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
}
}
#endregion
}
}