using System; using Ease.Core.Model; using Ease.Core.DataAccess; using HRM.BO; using Ease.Core.Utility; using System.Collections.Generic; using System.Data; namespace HRM.DA { internal class TaxChallanDA { #region Constructor private TaxChallanDA() { } #endregion #region Insert function internal static void Insert(TransactionContext tc, TaxChallan item) { tc.ExecuteNonQuery( "INSERT INTO TaxChallan(ChallenID, salaryMonthly, employeeID, taxParamID, challenNo, Amount, depositDate, CreatedBy, CreationDate,PayrolltypeID,BranchID, EmployeeAmount)" + " VALUES(%n, %d, %n, %n, %s, %n, %d, %n, %D, %n, %n, %n)", item.ID, item.SalaryMonthly, item.EmployeeID, item.TaxParameterID, item.ChallanNo, item.ChallanAmount, item.DepositDate, item.CreatedBy, item.CreatedDate, item.PayrolltypeID, item.BranchID, item.EmployeeAmount); } #endregion #region Update function internal static void Update(TransactionContext tc, TaxChallan item) { string sql = SQLParser.MakeSQL( @"UPDATE TaxChallan SET salaryMonthly=%d, employeeID=%n, taxParamID=%n, challenNo=%s, Amount=%n, EmployeeAmount=%n, depositDate=%d, ModifiedBy=%n, ModifiedDate=%D" + " WHERE ChallenID=%n", item.SalaryMonthly, item.EmployeeID, item.TaxParameterID, item.ChallanNo, item.ChallanAmount, item.EmployeeAmount, item.DepositDate, item.ModifiedBy, item.ModifiedDate, item.ID); tc.ExecuteNonQuery(sql); } #endregion #region Get Function internal static IDataReader Get(TransactionContext tc) { return tc.ExecuteReader("SELECT * FROM TaxChallan"); } internal static IDataReader Get(TransactionContext tc, int nEmpID, int nTaxParamID) { return tc.ExecuteReader("Select TC.*, Br.NAME as 'BankName', Br.ADDRESS from TaxChallan TC left join BRANCHES Br on TC.BranchID = Br.BRANCHID where TC.EMPLOYEEID=%n AND TC.TAXPARAMID=%n", nEmpID, nTaxParamID); } internal static IDataReader Get(TransactionContext tc, string nEmpIDs, int nTaxParamID) { return tc.ExecuteReader("Select * from TaxChallan where EMPLOYEEID IN (%q) AND TAXPARAMID=%n " + "--AND (IsWPPF IS NULL OR IsWPPF=0) " + "ORDER BY EMPLOYEEID,salaryMonthly", nEmpIDs, nTaxParamID); } internal static DataTable Getchallans(TransactionContext tc, int taxparamid) { return tc.ExecuteDataTable("SELECT challenNo, depositDate, Amount, Count(*) as EmpCount" + " FROM TaxChallan where TaxParamID=%n Group by challenNo, depositDate, Amount ", taxparamid); } internal static IDataReader GetByTaxParamId(TransactionContext tc, int nTaxParamID) { return tc.ExecuteReader("Select TC.*, Br.NAME as 'BankName', Br.ADDRESS from TaxChallan TC left join BRANCHES Br on TC.BranchID = Br.BRANCHID where TC.TAXPARAMID= %n", nTaxParamID); } internal static IDataReader Get(TransactionContext tc, int nID) { return tc.ExecuteReader("SELECT * FROM TaxChallan WHERE ChallanID=%n", nID); } internal static DataSet GetChalaCountByTaxParamID(TransactionContext tc, int nTaxParamID) { string strSQLQuery = SQLParser.MakeSQL( "select Salarymonthly,Challenno,count(employeeid) TotalEmployee from TAXCHALLAN where Taxparamid=%n group by Salarymonthly,Challenno order by Salarymonthly,Challenno", nTaxParamID); return tc.ExecuteDataSet(strSQLQuery); } #endregion #region Delete function internal static void Delete(TransactionContext tc, int nID) { tc.ExecuteNonQuery("DELETE FROM TaxChallan WHERE ChallenID=%n", nID); } internal static void DeleteByChallanNo(TransactionContext tc, string ChallanNo, int taxparameterid, int payrolltypeid) { tc.ExecuteNonQuery("DELETE FROM TaxChallan WHERE challenNo=%s " + " and taxParamID=%n and payrolltypeid=%n", ChallanNo, taxparameterid, payrolltypeid); } internal static void DeleteAllByTaxparamID(TransactionContext tc, int nTaxparamID) { tc.ExecuteNonQuery("DELETE FROM TaxChallan WHERE taxParamID=%n", nTaxparamID); } internal static void DeleteByEmpIDandChallanNo(TransactionContext tc, int nEmpid, string sChallanNo) { tc.ExecuteNonQuery("DELETE FROM TaxChallan WHERE employeeid=%n AND Challenno=%s", nEmpid, sChallanNo); } #endregion #region TAX DEDUCTION && CHALLAN internal static DataSet GetTaxDeductionByIDFromSalaryBonusOld(TransactionContext tc, int empid, int payrolltypeid, DateTime startDate, DateTime EndDate) { DataSet oTaxDeduction = new DataSet(); string sSQL = SQLParser.MakeSQL(@"select a.SALARYMONTH, a.EMPLOYEEID,sum(a.Amount) Amount from (Select s.SALARYMONTH, s.EMPLOYEEID,sd.CHANGEDAMOUNT Amount from SALARYMONTHLYDETAIL sd,SALARYMONTHLY s where s.SALARYMONTHLYID=sd.SALARYMONTHLYID and s.SALARYMONTH between %d and %d and sd.ITEMCODE=-129 and s.employeeid = %n Union select b.BONUSMONTH SALARYMONTH,d.EMPLOYEEID,d.CHANGETAXAMOUNT Amount from BONUSPROCESSDETAIL d,BONUSPROCESS b where d.BONUSPROCESSID=b.BONUSPROCESSID and b.BONUSMONTH between %d and %d and d.EMPLOYEEID=%n) a group by a.SALARYMONTH, a.EMPLOYEEID order by a.SALARYMONTH", startDate, EndDate, empid, startDate, EndDate, empid); DataTable taxdata = tc.ExecuteDataTable(sSQL); oTaxDeduction.Tables.Add(taxdata); return oTaxDeduction; } internal static DataSet GetTaxDeductionByIDFromSalaryBonus(TransactionContext tc, int empid, int payrolltypeid, DateTime startDate, DateTime EndDate, bool isSeparatebonuschallan) { DataSet oTaxDeduction = new DataSet(); string sSQL = string.Empty; if (isSeparatebonuschallan) { sSQL = SQLParser.MakeSQL(@"select a.SALARYMONTH, a.EMPLOYEEID,a.Amount,IsSeparateBonus from (Select s.SALARYMONTH, s.EMPLOYEEID,sd.CHANGEDAMOUNT Amount,0 IsSeparateBonus from SALARYMONTHLYDETAIL sd,SALARYMONTHLY s where s.SALARYMONTHLYID=sd.SALARYMONTHLYID and s.SALARYMONTH between %d and %d and sd.ITEMCODE=-129 and s.employeeid = %n AND sd.CHANGEDAMOUNT<>0 Union select b.BONUSMONTH SALARYMONTH,d.EMPLOYEEID,d.CHANGETAXAMOUNT Amount,1 IsSeparateBonus from BONUSPROCESSDETAIL d,BONUSPROCESS b where d.BONUSPROCESSID=b.BONUSPROCESSID and b.BONUSMONTH between %d and %d and d.EMPLOYEEID=%n and d.CHANGETAXAMOUNT<>0) a order by a.SALARYMONTH", startDate, EndDate, empid, startDate, EndDate, empid); } else { sSQL = SQLParser.MakeSQL(@"select a.SALARYMONTH, a.EMPLOYEEID,sum(a.Amount) Amount from (Select s.SALARYMONTH, s.EMPLOYEEID,sd.CHANGEDAMOUNT Amount from SALARYMONTHLYDETAIL sd,SALARYMONTHLY s where s.SALARYMONTHLYID=sd.SALARYMONTHLYID and s.SALARYMONTH between %d and %d and sd.ITEMCODE=-129 and s.employeeid = %n AND sd.CHANGEDAMOUNT<>0 Union select b.BONUSMONTH SALARYMONTH,d.EMPLOYEEID,d.CHANGETAXAMOUNT Amount from BONUSPROCESSDETAIL d,BONUSPROCESS b where d.BONUSPROCESSID=b.BONUSPROCESSID and b.BONUSMONTH between %d and %d and d.EMPLOYEEID=%n and d.CHANGETAXAMOUNT<>0) a group by a.SALARYMONTH, a.EMPLOYEEID order by a.SALARYMONTH", startDate, EndDate, empid, startDate, EndDate, empid); } DataTable taxdata = tc.ExecuteDataTable(sSQL); oTaxDeduction.Tables.Add(taxdata); return oTaxDeduction; } internal static DataSet GetTaxDeductionByID(TransactionContext tc, int empid, int payrolltypeid) { DataSet oTaxDeduction = new DataSet(); string sSQL = SQLParser.MakeSQL(@"Select * from TaxDeduction t,employee e where e.employeeno=t.EmployeeNo and e.employeeid = %n", empid); DataTable taxdata = tc.ExecuteDataTable(sSQL); oTaxDeduction.Tables.Add(taxdata); if (payrolltypeid == 1) sSQL = SQLParser.MakeSQL(@"Select * from Challan where payrolltypeid=1 order by dateofChallan"); else sSQL = SQLParser.MakeSQL(@"Select * from Challan where payrolltypeid<>1 order by dateofChallan"); DataTable oChallan = tc.ExecuteDataTable(sSQL); oTaxDeduction.Tables.Add(oChallan); return oTaxDeduction; } internal static DataSet GetChallan(TransactionContext tc) { DataSet oChallan = new DataSet(); string sSQL = SQLParser.MakeSQL(@"Select * from Challan"); return oChallan = tc.ExecuteDataSet(sSQL); } #endregion internal static IDataReader GetByTaxParamIDandPayrolltypeID(TransactionContext tc, int nTaxParamID, int payrolltypeID) { return tc.ExecuteReader("Select TC.*,Br.NAME as 'BankName', Br.ADDRESS from TaxChallan TC left join BRANCHES Br on TC.BranchID = Br.BRANCHID where TC.TAXPARAMID=%n and TC.EmployeeID = 0 and TC.payrolltypeID = %n", nTaxParamID, payrolltypeID); } internal static IDataReader GetByTaxParamIDandPayrolltypeIDEmployeewise(TransactionContext tc, int nTaxParamID, int payrolltypeID) { return tc.ExecuteReader("Select TC.*,Br.NAME as 'BankName', Br.ADDRESS from TaxChallan TC left join BRANCHES Br on TC.BranchID = Br.BRANCHID where TC.TAXPARAMID=%n and TC.payrolltypeID = %n", nTaxParamID, payrolltypeID); } internal static IDataReader GetByTaxParamIDandPayrolltypeIDandBranchID(TransactionContext tc, int nTaxParamID, int payrolltypeID,int branchID) { return tc.ExecuteReader("Select TC.*,B.NAME as 'BankName', Br.ADDRESS from TaxChallan TC left join BRANCHES Br on TC.BranchID = Br.BRANCHID left join BANKS B on Br.BANKID = B.BANKID where TC.TAXPARAMID=%n and TC.EmployeeID = 0 and TC.payrolltypeID = %n and Br.BRANCHID = %n", nTaxParamID, payrolltypeID, branchID); } } }