HRM-10/HRM.DA/Service/Tax/TaxChallanService.cs
Mohaimen Hasan 838b8d4480 first commit
2026-11-03 13:06:00 +06:00

568 lines
16 KiB
C#

using Ease.Core.Model;
using Ease.Core.DataAccess;
using HRM.BO;
using Ease.Core.Utility;
using System.Collections.Generic;
using System.Data;
using Ease.Core;
using Payroll.Service;
using System;
namespace HRM.DA
{
public class TaxChallanService : ServiceTemplate, ITaxChallanService
{
public TaxChallanService()
{
}
private void MapObject(TaxChallan oTaxChallan, DataReader oReader)
{
base.SetObjectID(oTaxChallan, oReader.GetInt32("ChallenID").Value);
oTaxChallan.SalaryMonthly = oReader.GetDateTime("salaryMonthly").Value;
oTaxChallan.EmployeeID = oReader.GetInt32("EmployeeID", 0);
oTaxChallan.TaxParameterID = oReader.GetInt32("taxParamID", 0);
oTaxChallan.ChallanNo = oReader.GetString("challenNo");
oTaxChallan.EmployeeAmount = oReader.GetDouble("EmployeeAmount", 0);
oTaxChallan.Amount = oReader.GetDouble("AMOUNT", true, 0);
oTaxChallan.DepositDate = oReader.GetDateTime("depositDate").Value;
oTaxChallan.CreatedBy = oReader.GetInt32("CreatedBy", 0);
oTaxChallan.CreatedDate = oReader.GetDateTime("CreationDate").Value;
oTaxChallan.ModifiedBy = oReader.GetInt32("ModifiedBy");
oTaxChallan.ModifiedDate = oReader.GetDateTime("ModifiedDate");
oTaxChallan.PayrolltypeID = oReader.GetInt32("PayrolltypeID", 0);
oTaxChallan.BranchID = oReader.GetInt32("BranchID", 0);
oTaxChallan.IsBonusAmount = oReader.GetBoolean("IsBonusAmount", true, false);
oTaxChallan.ChallanAmount = oReader.GetDouble("Amount", 0);
//oTaxChallan.BankName = oReader.GetString("BankName","");
//oTaxChallan.Address = oReader.GetString("Address","");
this.SetObjectState(oTaxChallan, Ease.Core.ObjectState.Saved);
}
protected override T CreateObject<T>(DataReader oReader)
{
TaxChallan oTaxChallan = new TaxChallan();
MapObject(oTaxChallan, oReader);
return oTaxChallan as T;
}
protected TaxChallan CreateObject(DataReader oReader)
{
TaxChallan oTaxChallan = new TaxChallan();
MapObject(oTaxChallan, oReader);
return oTaxChallan;
}
#region Service implementation
public TaxChallan Get(int id)
{
TaxChallan oTaxChallan = null;
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin();
DataReader oreader = new DataReader(TaxChallanDA.Get(tc, id));
if (oreader.Read())
{
oTaxChallan = this.CreateObject<TaxChallan>(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 oTaxChallan;
}
public List<TaxChallan> Get()
{
List<TaxChallan> taxChallans = new List<TaxChallan>();
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin();
DataReader dr = new DataReader(TaxChallanDA.Get(tc));
taxChallans = this.CreateObjects<TaxChallan>(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 taxChallans;
}
public DataTable GetGroupChallans(int taxparamid)
{
TransactionContext tc = null;
DataTable otable = null;
try
{
tc = TransactionContext.Begin();
otable =TaxChallanDA.Getchallans(tc, taxparamid);
tc.End();
}
catch (Exception e)
{
#region Handle Exception
if (tc != null)
tc.HandleError();
ExceptionLog.Write(e);
throw new ServiceException(e.Message, e);
#endregion
}
return otable;
}
public List<TaxChallan> Get(int nEmpID, int nTaxParamID)
{
List<TaxChallan> taxChallans = new List<TaxChallan>();
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin();
DataReader dr = new DataReader(TaxChallanDA.Get(tc, nEmpID, nTaxParamID));
taxChallans = this.CreateObjects<TaxChallan>(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 taxChallans;
}
public List<TaxChallan> Get(string sEmpIDs, int nTaxParamID)
{
List<TaxChallan> taxChallans = new List<TaxChallan>();
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin();
DataReader dr = new DataReader(TaxChallanDA.Get(tc, sEmpIDs, nTaxParamID));
taxChallans = this.CreateObjects<TaxChallan>(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 taxChallans;
}
public List<TaxChallan> GetByTaxParamId(int nTaxParamID)
{
List<TaxChallan> taxChallans = new List<TaxChallan>();
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin();
DataReader dr = new DataReader(TaxChallanDA.GetByTaxParamId(tc, nTaxParamID));
taxChallans = this.CreateObjects<TaxChallan>(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 taxChallans;
}
public int Save(TaxChallan oTaxChallan)
{
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin(true);
if (oTaxChallan.IsNew)
{
int id = tc.GenerateID("TaxChallan", "ChallenID");
base.SetObjectID(oTaxChallan, (id));
TaxChallanDA.DeleteByEmpIDandChallanNo(tc, oTaxChallan.EmployeeID, oTaxChallan.ChallanNo);
TaxChallanDA.Insert(tc, oTaxChallan);
}
else
{
TaxChallanDA.Update(tc, oTaxChallan);
}
tc.End();
return oTaxChallan.ID;
}
catch (Exception e)
{
#region Handle Exception
if (tc != null)
tc.HandleError();
ExceptionLog.Write(e);
throw new ServiceException(e.Message, e);
#endregion
}
}
public void SaveForExcelUpload(List<TaxChallan> oTaxChallans)
{
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin(true);
int id = tc.GenerateID("TaxChallan", "ChallenID");
TaxChallanDA.DeleteByChallanNo(tc,oTaxChallans[0].ChallanNo,
oTaxChallans[0].TaxParameterID, oTaxChallans[0].PayrolltypeID);
foreach (TaxChallan oTaxChallan in oTaxChallans)
{
id = id + 1;
if (oTaxChallan.IsNew)
{
base.SetObjectID(oTaxChallan, (id));
//TaxChallanDA.DeleteByEmpIDandChallanNo(tc, oTaxChallan.EmployeeID,
// oTaxChallan.ChallanNo);
TaxChallanDA.Insert(tc, oTaxChallan);
}
else
{
TaxChallanDA.Update(tc, oTaxChallan);
}
}
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 Delete(int id)
{
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin(true);
TaxChallanDA.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
}
}
public void DeleteAllByTaxparamID(int nTaxparamID)
{
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin(true);
TaxChallanDA.DeleteAllByTaxparamID(tc, nTaxparamID);
tc.End();
}
catch (Exception e)
{
#region Handle Exception
if (tc != null)
tc.HandleError();
ExceptionLog.Write(e);
throw new ServiceException(e.Message, e);
#endregion
}
}
public DataTable GetChalaCountByTaxParamID(int nTaxParamID)
{
DataTable dataTableChalanCount = new DataTable("ChalanCount");
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin();
DataSet dataSet = TaxChallanDA.GetChalaCountByTaxParamID(tc, nTaxParamID);
dataTableChalanCount = dataSet.Tables[0];
dataSet.Dispose();
tc.End();
}
catch (Exception e)
{
#region Handle Exception
if (tc != null)
tc.HandleError();
ExceptionLog.Write(e);
throw new ServiceException(e.Message, e);
#endregion
}
return dataTableChalanCount;
}
#endregion
#region Tax Deduction && Challan
public DataSet GetTaxDeductionByIDFromSalaryBonus(int empid, int payrolltypeid, DateTime startdate, DateTime enddate, bool isSeparatebonuschallan)
{
DataSet oTaxDeduction = new DataSet();
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin();
oTaxDeduction = TaxChallanDA.GetTaxDeductionByIDFromSalaryBonus(tc, empid, payrolltypeid, startdate, enddate, isSeparatebonuschallan);
tc.End();
}
catch (Exception e)
{
#region Handle Exception
if (tc != null)
tc.HandleError();
ExceptionLog.Write(e);
throw new ServiceException(e.Message, e);
#endregion
}
return oTaxDeduction;
}
public DataSet GetTaxDeductionByID(int empid, int payrolltypeid)
{
DataSet oTaxDeduction = new DataSet();
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin();
oTaxDeduction = TaxChallanDA.GetTaxDeductionByID(tc, 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 oTaxDeduction;
}
public DataSet GetChallan()
{
DataSet oChallan = new DataSet();
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin();
oChallan = TaxChallanDA.GetChallan(tc);
tc.End();
}
catch (Exception e)
{
#region Handle Exception
if (tc != null)
tc.HandleError();
ExceptionLog.Write(e);
throw new ServiceException(e.Message, e);
#endregion
}
return oChallan;
}
#endregion
public List<TaxChallan> GetByTaxParamIDandPayrolltypeID(int nTaxParamID, int payrolltypeID)
{
List<TaxChallan> taxChallans = new List<TaxChallan>();
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin();
DataReader dr = new DataReader(TaxChallanDA.GetByTaxParamIDandPayrolltypeID(tc, nTaxParamID, payrolltypeID));
taxChallans = this.CreateObjects<TaxChallan>(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 taxChallans;
}
public List<TaxChallan> GetByTaxParamIDandPayrolltypeIDEmployeewise(int nTaxParamID, int payrolltypeID)
{
List<TaxChallan> taxChallans = new List<TaxChallan>();
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin();
DataReader dr = new DataReader(TaxChallanDA.GetByTaxParamIDandPayrolltypeIDEmployeewise(tc, nTaxParamID, payrolltypeID));
taxChallans = this.CreateObjects<TaxChallan>(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 taxChallans;
}
public List<TaxChallan> GetByTaxParamIDandPayrolltypeIDandBranchID(int nTaxParamID, int payrolltypeID,int branchID)
{
List<TaxChallan> taxChallans = new List<TaxChallan>();
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin();
DataReader dr = new DataReader(TaxChallanDA.GetByTaxParamIDandPayrolltypeIDandBranchID(tc, nTaxParamID, payrolltypeID, branchID));
taxChallans = this.CreateObjects<TaxChallan>(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 taxChallans;
}
}
}