CEL_Payroll/Payroll.Service/Tax/DA/TaxParameterDA.cs

155 lines
7.2 KiB
C#
Raw Permalink Normal View History

2024-09-17 14:30:13 +06:00
using System;
using Payroll.BO;
using System.Data;
using System.Linq;
using Ease.CoreV35.Model;
using System.Data.SqlClient;
using Ease.CoreV35.DataAccess;
using System.Collections.Generic;
using Ease.CoreV35.DataAccess.SQL;
namespace Payroll.Service
{
#region TaxParameterDA
internal class TaxParameterDA
{
#region Constructor
private TaxParameterDA() { }
#endregion
#region Insert function
internal static void Insert(TransactionContext tc, TaxParameter item)
{
tc.ExecuteNonQuery("INSERT INTO TaxParameter(TaxParamID, fiscalYear, assessmentYear, maxInvestPercent, maxHRPercent, maxHRAmount,MaxMedicalPercent,maxMedicalAmount, maxConvAmount, maxCPFPercent, maxInvExempPercent, maxInvAmount, minTaxAmount, pfIntProjection, maxAge, CreatedBy, CreationDate,InvestmentActiveMonth)" +
" VALUES(%n, %s, %s, %n, %n, %n, %n, %n, %n, %n, %n, %n, %n, %n, %n, %n, %d,%d)", item.ID.Integer, item.FiscalYear, item.AssessmentYear, item.MaxInvestPercent, item.MaxHRPercent, item.MaxHRAmount, item.MaxMedicalPercent, item.MaxMedicalAmount, item.MaxConvAmount, item.MaxCPFPercent, item.MaxInvExempPercent, item.MaxInvAmount, item.MinTaxAmount, item.PfIntProjection, item.MaxAge, item.CreatedBy.Integer, item.CreatedDate, DataReader.GetNullValue(item.InvestmentActiveMonth));
}
internal static void Insert(TransactionContext tc, TaxParameterSlab item)
{
tc.ExecuteNonQuery("INSERT INTO TAXPARAMETERSLAB(TaxParamID,SEQUENCENO,INCOMEAMOUNT,TAXPERCENT,TYPE)" +
" VALUES(%n,%n,%n,%n,%n)", item.TaxparamID.Integer, item.SequenceNo, item.IncomeAmount, item.TaxPercent, item.ParamType);
}
#endregion
#region Update function
internal static void Update(TransactionContext tc, TaxParameter item)
{
tc.ExecuteNonQuery("UPDATE TaxParameter SET fiscalYear=%s, assessmentYear=%s, maxInvestPercent=%n, maxHRPercent=%n, maxHRAmount=%n,MaxMedicalPercent=%n,maxMedicalAmount=%n, maxConvAmount=%n, maxCPFPercent=%n, maxInvExempPercent=%n, maxInvAmount=%n, minTaxAmount=%n, pfIntProjection=%n, maxAge=%n, ModifiedBy=%n, ModifiedDate=%d,InvestmentActiveMonth=%d" +
" WHERE TaxParamID=%n", item.FiscalYear, item.AssessmentYear, item.MaxInvestPercent, item.MaxHRPercent, item.MaxHRAmount, item.MaxMedicalPercent, item.MaxMedicalAmount, item.MaxConvAmount, item.MaxCPFPercent, item.MaxInvExempPercent, item.MaxInvAmount, item.MinTaxAmount, item.PfIntProjection, item.MaxAge, item.ModifiedBy.Integer, item.ModifiedDate, DataReader.GetNullValue(item.InvestmentActiveMonth), item.ID.Integer);
}
#endregion
#region Get Function
internal static IDataReader Get(TransactionContext tc)
{
return tc.ExecuteReader("SELECT * FROM TaxParameter ORDER BY TaxParamID DESC");
}
internal static IDataReader Get(TransactionContext tc, ID nID)
{
return tc.ExecuteReader("SELECT * FROM TaxParameter WHERE TaxParamID=%n", nID.Integer);
}
internal static IDataReader GetOldTaxParameter(TransactionContext tc, ID nID)
{
return tc.ExecuteReader("SELECT * FROM GP_TaxParameter WHERE TaxParamID=%n", nID.Integer);
}
internal static IDataReader Get(TransactionContext tc, string assessmentYear)
{
return tc.ExecuteReader("SELECT * FROM TaxParameter WHERE AssessmentYear=%s", assessmentYear);
}
internal static int GetMaxID(TransactionContext tc)
{
Object oBj = tc.ExecuteScalar("SELECT MAX(TAXPARAMID) FROM TaxParameter");
if (oBj != DBNull.Value)
return Convert.ToInt32(oBj);
else
return 0;
}
internal static IDataReader Get(TransactionContext tc, bool IsForCurrentYear, int payrollTypeID)
{
if (IsForCurrentYear)
{
return tc.ExecuteReader("SELECT * FROM TaxParameter WHERE TaxParamID IN( SELECT TaxParamID FROM PayrollType where PayrollTypeId=%n) ORDER BY TaxParamID DESC", payrollTypeID);
}
else
{
return tc.ExecuteReader("SELECT * FROM TaxParameter WHERE TaxParamID NOT IN( SELECT TaxParamID FROM PayrollType where PayrollTypeId=%n) ORDER BY TaxParamID DESC", payrollTypeID);
}
}
//Tax Card From Old Table
internal static DataSet GetOldTaxCard(TransactionContext tc, bool IsForCurrentYear, int payrollTypeID)
{
if (IsForCurrentYear)
{
return tc.ExecuteDataSet("SELECT * FROM GP_TaxParameter WHERE TaxParamID =%n", payrollTypeID);
}
else
{
return tc.ExecuteDataSet("SELECT * FROM GP_TaxParameter WHERE TaxParamID NOT IN( SELECT TaxParamID FROM GP_PayrollType where PayrollTypeId=%n) ORDER BY TaxParamID DESC", payrollTypeID);
}
}
internal static IDataReader GetTaxSlabs(TransactionContext tc, ID nTaxParamID, EnumTaxSlabType TaxType)
{
return tc.ExecuteReader("SELECT * FROM TAXPARAMETERSLAB WHERE TAXPARAMID=%n and Type=%n", nTaxParamID.Integer, TaxType);
}
internal static DataSet GetTSByParamAndType(TransactionContext tc, ID nTaxParamID, EnumTaxSlabType TaxType)
{
return tc.ExecuteDataSet("SELECT TPS.TAXPERCENT AS CurrentRate,TPS.INCOMEAMOUNT AS Parameter,TPS.INCOMEAMOUNT AS TaxableIncome,(TPS.INCOMEAMOUNT*(TPS.TAXPERCENT/100)) AS IndividualTaxLiability"
+ " FROM TAXPARAMETERSLAB TPS WHERE TAXPARAMID=%n AND TYPE=%n ORDER BY SequenceNo", nTaxParamID.Integer, TaxType);
}
internal static IDataReader GetSlabsByParamID(TransactionContext tc, ID nTaxParamID)
{
return tc.ExecuteReader("SELECT * FROM TAXPARAMETERSLAB WHERE TAXPARAMID=%n", nTaxParamID.Integer);
}
internal static DataSet GetFiscalYearFromOldTable(TransactionContext tc, ID payrollTypeID)
{
return tc.ExecuteDataSet("SELECT TaxParamID As ID, FiscalYear FROM GP_TaxParameter WHERE TaxParamID NOT IN( SELECT TaxParamID FROM GP_PayrollType Where PayrollTypeId=%n) ORDER BY TaxParamID DESC", payrollTypeID.Integer);
}
internal static IDataReader GetOldSlabsByParamID(TransactionContext tc, ID nTaxParamID)
{
return tc.ExecuteReader("SELECT * FROM GP_TAXPARAMETERSLAB WHERE TAXPARAMID=%n", nTaxParamID.Integer);
}
#endregion
#region Delete function
internal static void Delete(TransactionContext tc, ID nID, int payrollTypeID)
{
tc.ExecuteNonQuery("Update PayrollType set TaxParamID=NULL where TaxParamID=%n and PayrollTypeID=%n", nID.Integer, payrollTypeID);
tc.ExecuteNonQuery("DELETE FROM [TAXPARAMETERSLAB] WHERE TaxParamID=%n", nID.Integer);
tc.ExecuteNonQuery("DELETE FROM [TaxParameter] WHERE TaxParamID=%n", nID.Integer);
}
internal static void DeleteByParamID(TransactionContext tc, ID nID)
{
tc.ExecuteNonQuery("DELETE FROM TAXPARAMETERSLAB WHERE TAXPARAMID=%n", nID.Integer);
}
#endregion
}
#endregion
}