161 lines
7.2 KiB
C#
161 lines
7.2 KiB
C#
using System;
|
|
using Ease.Core.Model;
|
|
using Ease.Core.DataAccess;
|
|
using HRM.BO;
|
|
using Ease.Core.Utility;
|
|
using System.Collections.Generic;
|
|
using System.Data;
|
|
using static NPOI.HSSF.Util.HSSFColor;
|
|
|
|
namespace HRM.DA
|
|
{
|
|
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, Payrolltypeid)" +
|
|
" VALUES(%n, %s, %s, %n, %n, %n, %n, %n, %n, %n, %n, %n, %n, %n, %n, %n, %D,%d, %n)", item.ID,
|
|
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, item.CreatedDate, DataReader.GetNullValue(item.InvestmentActiveMonth), item.PayrollTypeID);
|
|
}
|
|
|
|
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, 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," +
|
|
" payrolltypeid=%n 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, item.ModifiedDate, DataReader.GetNullValue(item.InvestmentActiveMonth), item.PayrollTypeID, item.ID);
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region Get Function
|
|
|
|
internal static IDataReader GetbyPayrolltype(TransactionContext tc, int payrolltypeid)
|
|
{
|
|
return tc.ExecuteReader("SELECT * FROM TaxParameter where payrolltypeid=%n ORDER BY TaxParamID DESC", payrolltypeid);
|
|
}
|
|
|
|
internal static IDataReader Get(TransactionContext tc, int nID)
|
|
{
|
|
return tc.ExecuteReader(SQLParser.MakeSQL("SELECT * FROM TaxParameter WHERE TaxParamID=%n", nID));
|
|
}
|
|
|
|
internal static IDataReader Get(TransactionContext tc, string assessmentYear)
|
|
{
|
|
return tc.ExecuteReader("SELECT * FROM TaxParameter WHERE AssessmentYear=%s", assessmentYear);
|
|
}
|
|
|
|
internal static IDataReader GetByFiscalYear(TransactionContext tc, string fiscalYear)
|
|
{
|
|
string sql = SQLParser.MakeSQL("SELECT * FROM TaxParameter WHERE fiscalYear =%s", fiscalYear);
|
|
return tc.ExecuteReader(sql);
|
|
}
|
|
|
|
internal static int GetMaxID(TransactionContext tc, int payrolltypeid)
|
|
{
|
|
Object oBj = tc.ExecuteScalar("SELECT MAX(TAXPARAMID) FROM TaxParameter where payrolltypeid =%n", payrolltypeid );
|
|
if (oBj != DBNull.Value)
|
|
return Convert.ToInt32(oBj);
|
|
else
|
|
return 0;
|
|
}
|
|
|
|
internal static IDataReader GetByDate(TransactionContext tc, DateTime salaryMonth)
|
|
{
|
|
string sql = SQLParser.MakeSQL("SELECT * FROM TaxParameter WHERE %d >= DATEFROMPARTS(CAST(LEFT(FISCALYEAR, 4) AS INT), 7, 1) AND %d <= DATEFROMPARTS(CAST(SUBSTRING(FISCALYEAR, 6, 4) AS INT) , 6, 30)", salaryMonth.Date, salaryMonth.Date);
|
|
return tc.ExecuteReader(sql);
|
|
}
|
|
|
|
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);
|
|
}
|
|
}
|
|
|
|
internal static IDataReader GetTaxSlabs(TransactionContext tc, int nTaxParamID, EnumTaxSlabType TaxType)
|
|
{
|
|
return tc.ExecuteReader("SELECT * FROM TAXPARAMETERSLAB WHERE TAXPARAMID=%n and Type=%n", nTaxParamID,
|
|
TaxType);
|
|
}
|
|
|
|
internal static DataSet GetTSByParamAndType(TransactionContext tc, int nTaxParamID, EnumTaxSlabType TaxType)
|
|
{
|
|
return tc.ExecuteDataSet(
|
|
"SELECT TPS.TAXPERCENT CurrentRate,TPS.INCOMEAMOUNT Parameter,TPS.INCOMEAMOUNT TaxableIncome,(TPS.INCOMEAMOUNT*(TPS.TAXPERCENT/100)) IndividualTaxLiability"
|
|
+ " FROM TAXPARAMETERSLAB TPS WHERE TAXPARAMID=%n AND TYPE=%n ORDER BY SequenceNo", nTaxParamID,
|
|
TaxType);
|
|
}
|
|
|
|
internal static IDataReader GetSlabsByParamID(TransactionContext tc, int nTaxParamID)
|
|
{
|
|
return tc.ExecuteReader("SELECT * FROM TAXPARAMETERSLAB WHERE TAXPARAMID=%n Order by SEQUENCENO", nTaxParamID);
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region Delete function
|
|
|
|
internal static void Delete(TransactionContext tc, int nID, int payrollTypeID)
|
|
{
|
|
tc.ExecuteNonQuery("Update PayrollType set TaxParamID=NULL where TaxParamID=%n and PayrollTypeID=%n", nID,
|
|
payrollTypeID);
|
|
tc.ExecuteNonQuery("DELETE FROM TAXPARAMETERSLAB WHERE TaxParamID=%n", nID);
|
|
tc.ExecuteNonQuery("DELETE FROM TaxParameter WHERE TaxParamID=%n", nID);
|
|
}
|
|
|
|
internal static void DeleteByParamID(TransactionContext tc, int nID)
|
|
{
|
|
tc.ExecuteNonQuery("DELETE FROM TAXPARAMETERSLAB WHERE TAXPARAMID=%n", nID);
|
|
}
|
|
|
|
internal static bool IsExistInPreviousYear(TransactionContext tc, int taxParamID)
|
|
{
|
|
Object oBj = tc.ExecuteScalar("SELECT Count(taxParamID) FROM INCOMETAXYEARLY where taxParamID=%n", taxParamID);
|
|
if (oBj != DBNull.Value)
|
|
return Convert.ToInt32(oBj)>0;
|
|
else
|
|
return false;
|
|
}
|
|
|
|
|
|
#endregion
|
|
}
|
|
} |