787 lines
25 KiB
C#
787 lines
25 KiB
C#
using Ease.Core.DataAccess;
|
|
using Ease.Core.Model;
|
|
using Ease.Core.Utility;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Data;
|
|
using HRM.BO;
|
|
|
|
namespace HRM.DA
|
|
{
|
|
public class EmployeeBankAccountService : ServiceTemplate, IEmployeeBankAccountService
|
|
{
|
|
public EmployeeBankAccountService()
|
|
{
|
|
}
|
|
|
|
private void MapObject(EmployeeBankAccount oEmployeeBankAccount, DataReader oReader)
|
|
{
|
|
base.SetObjectID(oEmployeeBankAccount, oReader.GetInt32("EmpBankAccountID").Value);
|
|
oEmployeeBankAccount.EmployeeID = oReader.GetInt32("EmployeeID", 0);
|
|
oEmployeeBankAccount.EffectDate = oReader.GetDateTime("changeDate").Value;
|
|
oEmployeeBankAccount.AccountNo = oReader.GetString("accountNo");
|
|
oEmployeeBankAccount.BranchID = oReader.GetInt32("branchID", 0);
|
|
oEmployeeBankAccount.AccountType = (EnumBankAccountType)oReader.GetInt32("accountType").Value;
|
|
oEmployeeBankAccount.CreatedBy = oReader.GetInt32("CreatedBy", 0);
|
|
oEmployeeBankAccount.CreatedDate = oReader.GetDateTime("CreationDate").Value;
|
|
oEmployeeBankAccount.ModifiedBy = oReader.GetInt32("ModifiedBy", 0);
|
|
oEmployeeBankAccount.ModifiedDate = oReader.GetDateTime("ModifiedDate");
|
|
this.SetObjectState(oEmployeeBankAccount, Ease.Core.ObjectState.Saved);
|
|
}
|
|
|
|
protected override T CreateObject<T>(DataReader oReader)
|
|
{
|
|
EmployeeBankAccount oEmployeeBankAccount = new EmployeeBankAccount();
|
|
MapObject(oEmployeeBankAccount, oReader);
|
|
return oEmployeeBankAccount as T;
|
|
}
|
|
|
|
#region Service implementation
|
|
|
|
public List<EmployeeBankAccount> GetNotYetProcessUptoToday()
|
|
{
|
|
List<EmployeeBankAccount> oEmployees = new List<EmployeeBankAccount>();
|
|
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin();
|
|
DataReader oreader = new DataReader(EmployeeBankAccountDA.GetNotYetProcessUptoToday(tc));
|
|
oEmployees = this.CreateObjects<EmployeeBankAccount>(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 oEmployees;
|
|
}
|
|
|
|
public EmployeeBankAccount Get(int id)
|
|
{
|
|
EmployeeBankAccount oEmployeeBankAccount = null;
|
|
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin();
|
|
DataReader oreader = new DataReader(EmployeeBankAccountDA.Get(tc, id));
|
|
if (oreader.Read())
|
|
{
|
|
oEmployeeBankAccount = this.CreateObject<EmployeeBankAccount>(oreader);
|
|
oreader.Close();
|
|
//oEmployeeBankAccount.Branch = (new BranchService()).Get(oEmployeeBankAccount.BranchID, tc);
|
|
oEmployeeBankAccount.Employee = (new EmployeeService()).Get(tc, oEmployeeBankAccount.EmployeeID);
|
|
}
|
|
|
|
//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 oEmployeeBankAccount;
|
|
}
|
|
|
|
public EmployeeBankAccount Get(int nEmpID, DateTime dEffectDate, int payrollTypeID)
|
|
{
|
|
EmployeeBankAccount oEmployeeBankAccount = null;
|
|
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin();
|
|
DataReader oreader = new DataReader(EmployeeBankAccountDA.Get(tc, nEmpID, dEffectDate, payrollTypeID));
|
|
if (oreader.Read())
|
|
{
|
|
oEmployeeBankAccount = this.CreateObject<EmployeeBankAccount>(oreader);
|
|
oEmployeeBankAccount.Employee = (new EmployeeService()).Get(tc, oEmployeeBankAccount.EmployeeID);
|
|
}
|
|
|
|
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 oEmployeeBankAccount;
|
|
}
|
|
|
|
public List<EmployeeBankAccount> Get()
|
|
{
|
|
List<EmployeeBankAccount> employeeBankAccounts = new List<EmployeeBankAccount>();
|
|
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin();
|
|
|
|
DataReader dr = new DataReader(EmployeeBankAccountDA.Get(tc));
|
|
employeeBankAccounts = this.CreateObjects<EmployeeBankAccount>(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 employeeBankAccounts;
|
|
}
|
|
|
|
|
|
public List<EmployeeBankAccount> GetByEmployeeID(int ID)
|
|
{
|
|
List<EmployeeBankAccount> employeeBankAccounts = new List<EmployeeBankAccount>();
|
|
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin();
|
|
|
|
DataReader dr = new DataReader(EmployeeBankAccountDA.GetByEmployeeID(tc, ID));
|
|
employeeBankAccounts = this.CreateObjects<EmployeeBankAccount>(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 employeeBankAccounts;
|
|
}
|
|
public List<EmployeeBankAccount> GetByEmployeeIDAndType(int ID, int AccountType)
|
|
{
|
|
List<EmployeeBankAccount> employeeBankAccounts = new List<EmployeeBankAccount>();
|
|
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin();
|
|
|
|
DataReader dr = new DataReader(EmployeeBankAccountDA.GetByEmployeeIDAndType(tc, ID, AccountType));
|
|
employeeBankAccounts = this.CreateObjects<EmployeeBankAccount>(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 employeeBankAccounts;
|
|
}
|
|
public DataSet GetEmpBankAdvice(DateTime dateTime, string sEmpID)
|
|
{
|
|
DataSet oBankAdvices = new DataSet();
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin();
|
|
oBankAdvices = EmployeeBankAccountDA.GetEmpBankAdvice(tc, dateTime, sEmpID);
|
|
tc.End();
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
#region Handle Exception
|
|
|
|
if (tc != null)
|
|
tc.HandleError();
|
|
ExceptionLog.Write(e);
|
|
throw new ServiceException(e.Message, e);
|
|
|
|
#endregion
|
|
}
|
|
|
|
return oBankAdvices;
|
|
}
|
|
public DataTable GetEmpBankAdvice2(DateTime dateTime, string sEmpID)
|
|
{
|
|
DataTable oBankAdvices = new DataTable();
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin();
|
|
oBankAdvices = EmployeeBankAccountDA.GetEmpBankAdvice2(tc, dateTime, sEmpID);
|
|
tc.End();
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
#region Handle Exception
|
|
|
|
if (tc != null)
|
|
tc.HandleError();
|
|
ExceptionLog.Write(e);
|
|
throw new ServiceException(e.Message, e);
|
|
|
|
#endregion
|
|
}
|
|
|
|
return oBankAdvices;
|
|
}
|
|
public DataSet GetEmpCashAdvice(DateTime dateTime, string sEmpID)
|
|
{
|
|
DataSet oBankAdvices = new DataSet();
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin();
|
|
oBankAdvices = EmployeeBankAccountDA.GetEmpCashAdvice(tc, dateTime, sEmpID);
|
|
tc.End();
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
#region Handle Exception
|
|
|
|
if (tc != null)
|
|
tc.HandleError();
|
|
ExceptionLog.Write(e);
|
|
throw new ServiceException(e.Message, e);
|
|
|
|
#endregion
|
|
}
|
|
|
|
return oBankAdvices;
|
|
}
|
|
|
|
public DataSet GetOPIEmpBankAdvice(DateTime dateTime, string sEmpID, int bankID)
|
|
{
|
|
DataSet oBankAdvices = new DataSet();
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin();
|
|
oBankAdvices = EmployeeBankAccountDA.GetEmpOPIBankAdvice(tc, dateTime, sEmpID, bankID);
|
|
tc.End();
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
#region Handle Exception
|
|
|
|
if (tc != null)
|
|
tc.HandleError();
|
|
ExceptionLog.Write(e);
|
|
throw new ServiceException(e.Message, e);
|
|
|
|
#endregion
|
|
}
|
|
|
|
return oBankAdvices;
|
|
}
|
|
|
|
public DataSet GetHNMOPIEmpBankAdvice(DateTime dateTime, string sEmpID)
|
|
{
|
|
DataSet oBankAdvices = new DataSet();
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin();
|
|
oBankAdvices = EmployeeBankAccountDA.GetHNMEmpOPIBankAdvice(tc, dateTime, sEmpID);
|
|
tc.End();
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
#region Handle Exception
|
|
|
|
if (tc != null)
|
|
tc.HandleError();
|
|
ExceptionLog.Write(e);
|
|
throw new ServiceException(e.Message, e);
|
|
|
|
#endregion
|
|
}
|
|
|
|
return oBankAdvices;
|
|
}
|
|
|
|
//public DataSet GetEmpExpenseAmount(DateTime dateTime, string sEmpID)
|
|
//{
|
|
// DataSet oEmpExpenseAmount = new DataSet();
|
|
// TransactionContext tc = null;
|
|
// try
|
|
// {
|
|
// tc = TransactionContext.Begin();
|
|
// oEmpExpenseAmount = EmployeeBankAccountDA.GetEmpExpenseAmount(tc, dateTime, sEmpID);
|
|
// tc.End();
|
|
// }
|
|
// catch (Exception e)
|
|
// {
|
|
// #region Handle Exception
|
|
// if (tc != null)
|
|
// tc.HandleError();
|
|
// ExceptionLog.Write(e);
|
|
// throw new ServiceException(e.Message, e);
|
|
// #endregion
|
|
// }
|
|
// return oEmpExpenseAmount;
|
|
//}
|
|
|
|
public DataSet GetEmpBankHistory(DateTime dateTime, int payrollTypeID)
|
|
{
|
|
DataSet oBankHistories = new DataSet();
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin();
|
|
oBankHistories = EmployeeBankAccountDA.GetEmpBankHistory(tc, dateTime, 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 oBankHistories;
|
|
}
|
|
|
|
public DataSet GetEmpBankHistory(DateTime dSFromDate, DateTime dSToDate, int payrollTypeID)
|
|
{
|
|
DataSet oBankHistories = new DataSet();
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin();
|
|
oBankHistories = EmployeeBankAccountDA.GetEmpBankHistory(tc, dSFromDate, dSToDate, 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 oBankHistories;
|
|
}
|
|
|
|
public DataSet GetEmpPrvBankHistory(DateTime dateTime, int payrollTypeID)
|
|
{
|
|
DataSet oBankHistories = new DataSet();
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin();
|
|
oBankHistories = EmployeeBankAccountDA.GetEmpPrvBankHistory(tc, dateTime, 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 oBankHistories;
|
|
}
|
|
|
|
public DataSet GetEmpBankAdvice(DateTime salaryMonthDate, int bankID)
|
|
{
|
|
DataSet oBankHistories = new DataSet();
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin();
|
|
oBankHistories = EmployeeBankAccountDA.GetEmpBankAdvice(tc, salaryMonthDate, bankID);
|
|
tc.End();
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
#region Handle Exception
|
|
|
|
if (tc != null)
|
|
tc.HandleError();
|
|
ExceptionLog.Write(e);
|
|
throw new ServiceException(e.Message, e);
|
|
|
|
#endregion
|
|
}
|
|
|
|
return oBankHistories;
|
|
}
|
|
|
|
public DataSet GetEmpOPIBankAdvice(DateTime salaryMonthDate, int bankID)
|
|
{
|
|
DataSet oBankHistories = new DataSet();
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin();
|
|
oBankHistories = EmployeeBankAccountDA.GetEmpOPIBankAdvice(tc, salaryMonthDate, bankID);
|
|
tc.End();
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
#region Handle Exception
|
|
|
|
if (tc != null)
|
|
tc.HandleError();
|
|
ExceptionLog.Write(e);
|
|
throw new ServiceException(e.Message, e);
|
|
|
|
#endregion
|
|
}
|
|
|
|
return oBankHistories;
|
|
}
|
|
|
|
public void SaveIntegration(EmployeeBankAccount oEmployeeBankAccount, TransactionContext tc)
|
|
{
|
|
// TransactionContext tc = null;
|
|
try
|
|
{
|
|
// tc = TransactionContext.Begin(true);
|
|
EmployeeService empservice = new EmployeeService();
|
|
//if (oEmployeeBankAccount.IsNew)
|
|
//{
|
|
EmployeeBankAccountDA.DeleteByBankEffectDate(tc, oEmployeeBankAccount.EffectDate,
|
|
oEmployeeBankAccount.EmployeeID, oEmployeeBankAccount.AccountType);
|
|
|
|
int id = tc.GenerateID("BANKACCOUNTHISTORY", "EmpBankAccountID");
|
|
base.SetObjectID(oEmployeeBankAccount, id);
|
|
EmployeeBankAccountDA.Insert(tc, oEmployeeBankAccount);
|
|
|
|
//}
|
|
//else
|
|
//{
|
|
// EmployeeBankAccountDA.Update(tc, oEmployeeBankAccount);
|
|
//}
|
|
|
|
if (oEmployeeBankAccount.AccountType == EnumBankAccountType.SalaryAccount)
|
|
{
|
|
empservice.UpdateBankAcc(tc, oEmployeeBankAccount.EmployeeID, oEmployeeBankAccount.BranchID,
|
|
oEmployeeBankAccount.AccountNo, EnumPaymentMode.BankTransfer);
|
|
}
|
|
else
|
|
{
|
|
empservice.UpdateOPIBankAcc(tc, oEmployeeBankAccount.EmployeeID, oEmployeeBankAccount.BranchID,
|
|
oEmployeeBankAccount.AccountNo, EnumPaymentMode.BankTransfer);
|
|
}
|
|
|
|
//tc.End();
|
|
// return oEmployeeBankAccount.ID;
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
#region Handle Exception
|
|
|
|
if (tc != null)
|
|
tc.HandleError();
|
|
ExceptionLog.Write(e);
|
|
throw new ServiceException(e.Message, e);
|
|
|
|
#endregion
|
|
}
|
|
}
|
|
|
|
//public void Insert(TransactionContext tc, List<EmployeeBankAccount> EmpBankAccounts, DateTime salaryCutoffDate)
|
|
//{
|
|
// try
|
|
// {
|
|
// foreach (EmployeeBankAccount item in EmpBankAccounts)
|
|
// {
|
|
// this.Insert(tc, item, salaryCutoffDate);
|
|
// }
|
|
// }
|
|
// catch (Exception ex)
|
|
// {
|
|
// throw new ServiceException(ex.Message);
|
|
// }
|
|
//}
|
|
|
|
public void Save(List<EmployeeBankAccount> EmpBankAccounts)
|
|
{
|
|
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin(true);
|
|
foreach (EmployeeBankAccount item in EmpBankAccounts)
|
|
{
|
|
this.Save(tc, item);
|
|
}
|
|
tc.End();
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
if (tc == null)
|
|
tc.HandleError();
|
|
throw new ServiceException(ex.Message);
|
|
}
|
|
}
|
|
|
|
public int Save(TransactionContext tc, EmployeeBankAccount oEmployeeBankAccount)
|
|
{
|
|
try
|
|
{
|
|
|
|
EmployeeService empservice = new EmployeeService();
|
|
if (oEmployeeBankAccount.IsNew)
|
|
{
|
|
EmployeeBankAccountDA.DeleteByBankEffectDate(tc, oEmployeeBankAccount.EffectDate,
|
|
oEmployeeBankAccount.EmployeeID);
|
|
|
|
int id = tc.GenerateID("BANKACCOUNTHISTORY", "EmpBankAccountID");
|
|
base.SetObjectID(oEmployeeBankAccount, id);
|
|
EmployeeBankAccountDA.Insert(tc, oEmployeeBankAccount);
|
|
empservice.UpdateBankAcc(tc, oEmployeeBankAccount.EmployeeID, oEmployeeBankAccount.BranchID,
|
|
oEmployeeBankAccount.AccountNo, EnumPaymentMode.BankTransfer);
|
|
}
|
|
else
|
|
{
|
|
EmployeeBankAccountDA.Update(tc, oEmployeeBankAccount);
|
|
empservice.UpdateBankAcc(tc, oEmployeeBankAccount.EmployeeID, oEmployeeBankAccount.BranchID,
|
|
oEmployeeBankAccount.AccountNo, EnumPaymentMode.BankTransfer);
|
|
}
|
|
|
|
return oEmployeeBankAccount.ID;
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
#region Handle Exception
|
|
|
|
if (tc != null)
|
|
tc.HandleError();
|
|
ExceptionLog.Write(e);
|
|
throw new ServiceException(e.Message, e);
|
|
|
|
#endregion
|
|
}
|
|
}
|
|
|
|
public int Save(EmployeeBankAccount oEmployeeBankAccount)
|
|
{
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin(true);
|
|
EmployeeService empservice = new EmployeeService();
|
|
if (oEmployeeBankAccount.IsNew)
|
|
{
|
|
EmployeeBankAccountDA.DeleteByBankEffectDate(tc, oEmployeeBankAccount.EffectDate,
|
|
oEmployeeBankAccount.EmployeeID, oEmployeeBankAccount.AccountType);
|
|
//EmployeeBankAccountDA.DeleteByBankAccountNoEffectDate(tc, oEmployeeBankAccount.EffectDate,
|
|
// oEmployeeBankAccount.EmployeeID, oEmployeeBankAccount.AccountType, oEmployeeBankAccount.AccountNo);
|
|
|
|
int id = tc.GenerateID("BANKACCOUNTHISTORY", "EmpBankAccountID");
|
|
base.SetObjectID(oEmployeeBankAccount, id);
|
|
EmployeeBankAccountDA.Insert(tc, oEmployeeBankAccount);
|
|
}
|
|
else
|
|
{
|
|
EmployeeBankAccountDA.Update(tc, oEmployeeBankAccount);
|
|
}
|
|
|
|
if (oEmployeeBankAccount.AccountType == EnumBankAccountType.SalaryAccount)
|
|
{
|
|
empservice.UpdateBankAcc(tc, oEmployeeBankAccount.EmployeeID, oEmployeeBankAccount.BranchID,
|
|
oEmployeeBankAccount.AccountNo, EnumPaymentMode.BankTransfer);
|
|
}
|
|
else
|
|
{
|
|
empservice.UpdateOPIBankAcc(tc, oEmployeeBankAccount.EmployeeID, oEmployeeBankAccount.BranchID,
|
|
oEmployeeBankAccount.AccountNo, EnumPaymentMode.BankTransfer);
|
|
}
|
|
|
|
tc.End();
|
|
return oEmployeeBankAccount.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(int id)
|
|
{
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
EmployeeBankAccount oacc = (new EmployeeBankAccountService()).Get(id);
|
|
tc = TransactionContext.Begin(true);
|
|
EmployeeBankAccountDA.Delete(tc, id);
|
|
EmployeeService sv = new EmployeeService();
|
|
if (oacc.AccountType == EnumBankAccountType.SalaryAccount)
|
|
{
|
|
sv.UpdateBankAcc(tc, oacc.EmployeeID, 0,
|
|
string.Empty, EnumPaymentMode.CashPayment);
|
|
}
|
|
else
|
|
{
|
|
sv.UpdateOPIBankAcc(tc, oacc.EmployeeID, 0,
|
|
string.Empty, EnumPaymentMode.CashPayment);
|
|
}
|
|
|
|
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 DeleteAll()
|
|
{
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin(true);
|
|
EmployeeBankAccountDA.DeleteAll(tc);
|
|
tc.End();
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
#region Handle Exception
|
|
|
|
if (tc != null)
|
|
tc.HandleError();
|
|
ExceptionLog.Write(e);
|
|
throw new ServiceException(e.Message, e);
|
|
|
|
#endregion
|
|
}
|
|
}
|
|
|
|
public List<EmployeeBankAccount> GetByDate(DateTime startDate, DateTime endDate, int payrollTypeID)
|
|
{
|
|
List<EmployeeBankAccount> oEmployees = new List<EmployeeBankAccount>();
|
|
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin();
|
|
DataReader oreader =
|
|
new DataReader(EmployeeBankAccountDA.GetByDate(tc, startDate, endDate, payrollTypeID));
|
|
oEmployees = this.CreateObjects<EmployeeBankAccount>(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 oEmployees;
|
|
}
|
|
|
|
public DataSet GetEmpBankAdviceWithRoutingNo(DateTime dateTime, string sEmpID)
|
|
{
|
|
DataSet oBankAdvices = new DataSet();
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin();
|
|
oBankAdvices = EmployeeBankAccountDA.GetEmpBankAdviceWithRoutingNo(tc, dateTime, sEmpID);
|
|
tc.End();
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
#region Handle Exception
|
|
|
|
if (tc != null)
|
|
tc.HandleError();
|
|
ExceptionLog.Write(e);
|
|
throw new ServiceException(e.Message, e);
|
|
|
|
#endregion
|
|
}
|
|
|
|
return oBankAdvices;
|
|
}
|
|
|
|
#endregion
|
|
}
|
|
} |