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(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 GetEmployeeDataUsingExceptionType(string ExceptionType) { TransactionContext tc = null; List employees = new List(); try { tc = TransactionContext.Begin(); DataReader dr = new DataReader(EmployeeDA.GetEmployeeDataUsingExceptionType(tc, ExceptionType)); employees = this.CreateObjects(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 GetEmployeeDataUsingPersonType(int ExceptionType) { TransactionContext tc = null; List employees = new List(); try { tc = TransactionContext.Begin(); DataReader dr = new DataReader(EmployeeDA.GetEmployeeDataUsingPersonType(tc, ExceptionType)); employees = this.CreateObjects(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 GetEmployeeDataUsingTaxCircle(int TaxCircleType) { TransactionContext tc = null; List employees = new List(); try { tc = TransactionContext.Begin(); DataReader dr = new DataReader(EmployeeDA.GetEmployeeDataUsingTaxCircle(tc, TaxCircleType)); employees = this.CreateObjects(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 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 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 } }