using HRM.BO; using Ease.Core.DataAccess; using Ease.Core.Utility; using System; using System.Data; namespace HRM.DA { #region BonusProcessDA internal class BonusProcessDA { #region Constructor private BonusProcessDA() { } #endregion #region Insert function internal static void Insert(TransactionContext tc, BonusProcess item) { tc.ExecuteNonQuery( "INSERT INTO BONUSPROCESS(BonusProcessID, bonusID, bonusMonth, basicOnMonth, disburseDate, remarks, showInWeb, CreatedBy, CreationDate,ISDISBURSEWITHSALARY," + "IsTaxProcess,UsedProcess,PayrollTypeID, isApprove, wfstatus )" + " VALUES(%n, %n, %d, %d, %d, %s, %n, %n, %d,%n,%n,%n,%n, %b, %n)", item.ID, item.BonusID, item.BonusMonth, item.BasicOnMonth, item.DisburseDate, item.Remarks, item.ShowInWeb, item.CreatedBy, DataReader.GetNullValue(item.CreatedDate), item.IsDisburseWithSalary, item.IsTaxProcess, item.UsedProcess, item.PayrollTypeID, item.IsApprove, item.wfstatus); } internal static void Insert(TransactionContext tc, BonusProcess.BonusProcessDetail item) { string sql = SQLParser.MakeSQL( "INSERT INTO BONUSPROCESSDETAIL(BonusProcessDetailID, bonusProcessID, bonusID, employeeID, disburseDate, BonusAmount, GrossSalary, BasicSalary, ChangeBonusAmount, ChangeTaxAmount, ChangeAdjustAmount,ChangeSalaryItemAmount,CalculatedAdjustAmount,calculatedSalaryItemAmount,TaxAmount)" + " VALUES(%n, %n, %n, %n, %d, %n, %n, %n, %n,%n, %n,%n,%n,%n,%n)", item.ID, item.BonusProcessID, item.BonusID, item.EmployeeID, item.BonusMonth, item.BonusAmount, item.GrossSalary, item.BasicSalary, item.ChangeBonusAmount, item.ChangeTaxAmount, item.ChangeAdjustAmount, item.ChangeSalaryItemAmount, item.CalculatedAdjustAmount, item.CalculatedSalaryItemAmount, item.TaxAmount); tc.ExecuteNonQuery(sql); } //internal static void Insert(TransactionContext tc, BonusProcess.BonusProcessDetail.BonusProcessSalaryItem item) //{ // tc.ExecuteNonQuery("INSERT INTO BonusProcessSalaryItem(BonusProcessDetailID,AllowDeductID,Amount,SalaryGroupCode)" + // " VALUES(%n,%n,%n,%n)", item.BonusProcessDetailID,item.AllowDeductID,item.Amount,item.SalaryGroupCode); //} //internal static void Insert(TransactionContext tc, BonusProcess.BonusProcessDetail.BonusProcessAdjustItem item) //{ // tc.ExecuteNonQuery("INSERT INTO BonusProcessAdjustItem(BonusProcessDetailID,BonusAdjustID,AdjustAmount)" + // " VALUES(%n,%n,%n)", item.BonusProcessDetailID, item.BonusAdjustID,item.AdjustAmount); //} //internal static void Insert(TransactionContext tc, BonusEmpCostCenter item) //{ // tc.ExecuteNonQuery("INSERT INTO BonusEmpCostCenter(BonusProcessID, COSTCENTERID, PERCENTAGE, EMPLOYEEID)" + // " VALUES( %n, %n, %n, %n)", item.BonusProcessID, item.CostCenterID, item.Percentage, item.EmployeeID); //} #endregion #region Update function internal static void Update(TransactionContext tc, BonusProcess item) { tc.ExecuteNonQuery( "UPDATE BONUSPROCESS SET bonusID=%n, bonusMonth=%d, basicOnMonth=%d, disburseDate=%d, remarks=%s, showInWeb=%b, ModifiedBy=%n, ModifiedDate=%d,ISDISBURSEWITHSALARY=%n,IsTaxProcess=%n,UsedProcess=%n" + " , isapprove=%b, wfstatus=%n WHERE BonusProcessID=%n", item.BonusID, item.BonusMonth, item.BasicOnMonth, item.DisburseDate, item.Remarks, item.ShowInWeb, item.ModifiedBy, item.ModifiedDate, item.IsDisburseWithSalary, item.IsTaxProcess, item.UsedProcess, item.IsApprove, item.wfstatus, item.ID ); } internal static void Update(TransactionContext tc, BonusProcess.BonusProcessDetail item) { tc.ExecuteNonQuery( "UPDATE BONUSPROCESSDETAIL SET bonusProcessID=%n,bonusID=%n, employeeID=%n, disburseDate=%d, BonusAmount=%n, GrossSalary=%n, BasicSalary=%n, ChangeBonusAmount=%n, ChangeTaxAmount=%n, ChangeSalaryItemAmount=%n,CalculatedAdjustAmount=%n,calculatedSalaryItemAmount=%n,TaxAmount=%n" + " WHERE BonusProcessDetailID=%n", item.BonusProcessID, item.BonusID, item.EmployeeID, item.BonusMonth, item.BonusAmount, item.GrossSalary, item.BasicSalary, item.ChangeBonusAmount, item.ChangeTaxAmount, item.ChangeSalaryItemAmount, item.CalculatedAdjustAmount, item.CalculatedSalaryItemAmount, item.TaxAmount, item.ID); } #endregion #region Get Function // GetBonusAmountWithinYear internal static double GetBonusAmount(TransactionContext tc, DateTime bonusMonthFirstDate, int employeeID, int bonusID, int payrolltypeid) { object bonusAmount = tc.ExecuteScalar( "select BonusAmount from BonusProcessDetail WHERE EmployeeID =%n AND BonusID=%n AND BonusProcessID = (select BonusProcessID from BonusProcess Where BonusMonth = %d AND PayrollTypeID=%n)", employeeID, bonusID, bonusMonthFirstDate, payrolltypeid); double amount = 0; if (bonusAmount != DBNull.Value) { amount = Convert.ToDouble(bonusAmount); } return amount; } internal static double GetUsedBonusWithinYear(TransactionContext tc, DateTime bonusMonthFirstDate, int bonusID, int payrolltypeid) { DateTime firstDateOfYear = Global.DateFunctions.FirstDateOfYear(bonusMonthFirstDate); DateTime lastDateOfYear = Global.DateFunctions.LastDateOfYear(bonusMonthFirstDate); object bonusAmount = tc.ExecuteScalar( "select SUM(UsedProcess) from BONUSPROCESS where BONUSID=%n and BONUSMONTH Between %d and %d AND PayrollTypeID=%n", bonusID, firstDateOfYear, lastDateOfYear, payrolltypeid); double amount = 0; if (bonusAmount != DBNull.Value) { amount = Convert.ToDouble(bonusAmount); } return amount; } internal static IDataReader GetBonusDetailsbyEmps(TransactionContext tc, string emps, DateTime FromDate, DateTime ToDate, int payrollTypeID) { return tc.ExecuteReader(@"Select BPD.* from BONUSPROCESS BP,BONUSPROCESSDETAIL BPD WHERE bpd.employeeID in (%q) AND BP.BonusProcessID = BPD.BonusProcessID AND BP.BonusMonth >=%d AND BP.BonusMonth <=%d AND BP.PayrollTypeID=%n", emps, FromDate, ToDate, payrollTypeID); } internal static double GetBonusAmountWithinYear(TransactionContext tc, DateTime bonusYearDate, int employeeID, int bonusID, int payrolltypeid) { DateTime firstDateOfYear = Global.DateFunctions.FirstDateOfYear(bonusYearDate); DateTime lastDateOfYear = Global.DateFunctions.LastDateOfYear(bonusYearDate); string strSql = SQLParser.MakeSQL("select SUM(BonusAmount) from BonusProcessDetail" + " WHERE EmployeeID =%n AND BonusID=%n AND BonusProcessID " + " IN (select BonusProcessID from BonusProcess Where BonusMonth BETWEEN %d AND %d AND PayrollTypeID=%n)", employeeID, bonusID, firstDateOfYear, lastDateOfYear, payrolltypeid); object bonusAmount = tc.ExecuteScalar(strSql); double amount = 0; if (bonusAmount != DBNull.Value) { amount = Convert.ToDouble(bonusAmount); } return amount; } internal static IDataReader Get(TransactionContext tc, EnumStatus status, int payrolltypeid) { if (EnumStatus.Active == status || EnumStatus.Inactive == status) { return tc.ExecuteReader( "SELECT * FROM BONUSPROCESS Where Status=%n AND PayrollTypeID=%n Order By SequenceNo", status, payrolltypeid); } else { return tc.ExecuteReader("SELECT * FROM BONUSPROCESS Where PayrollTypeID=%n Order By SequenceNo", payrolltypeid); } } internal static IDataReader GetProcess(TransactionContext tc, DateTime dBonusMonth, int payrolltypeid) { return tc.ExecuteReader("SELECT * FROM BONUSPROCESS Where BonusMonth=%d AND PayrollTypeID=%n", dBonusMonth, payrolltypeid); } internal static IDataReader GetProcess(TransactionContext tc, int nBonusID, DateTime dBonusMonth, int payrolltypeid) { return tc.ExecuteReader( "SELECT * FROM BONUSPROCESS WHERE BonusID=%n AND BonusMonth=%d AND PayrollTypeID=%n", nBonusID, GlobalFunctions.LastDateOfMonth(dBonusMonth), payrolltypeid); //return tc.ExecuteReader("SELECT * FROM BONUSPROCESS Where BonusMonth=%d AND PayrollTypeID=%n", dBonusMonth, SystemInformation.CurrentSysInfo.PayrollTypeID); } internal static IDataReader Get(TransactionContext tc, int nID) { return tc.ExecuteReader("SELECT * FROM BONUSPROCESS WHERE BonusProcessID=%n ", nID); } internal static IDataReader Get(TransactionContext tc, int nID, int payrolltypeid) { return tc.ExecuteReader("SELECT * FROM BONUSPROCESS WHERE BonusProcessID=%n AND PayrollTypeID=%n", nID, payrolltypeid); } internal static IDataReader Get(TransactionContext tc, int bonusID, DateTime bonusMonth, int payrolltypeid) { return tc.ExecuteReader( "SELECT * FROM BONUSPROCESS WHERE BonusID=%n AND BonusMonth between %d and %d AND PayrollTypeID=%n", bonusID, PayrollGlobalFunctions.PayrollFirstDateOfMonth(bonusMonth), PayrollGlobalFunctions.PayrollLastDateOfMonth(bonusMonth), payrolltypeid); } internal static IDataReader GetBonusDetails(TransactionContext tc, int nID) { return tc.ExecuteReader( "SELECT * FROM BONUSPROCESSDETAIL WHERE BonusProcessID=(Select BonusProcessID from BonusProcess where BonusProcessID=%n )", nID); } internal static IDataReader GetBonusDetails(TransactionContext tc, int payrolltypeid, int bonusid, DateTime bonusMonth) { return tc.ExecuteReader( "SELECT * FROM BONUSPROCESSDETAIL bd, BonusProcess b WHERE b.BonusProcessID= bd.BonusProcessID" + " and b.BonusMonth=%d and b.payrolltypeid=%n and b.bonusid=%n", bonusMonth, payrolltypeid, bonusid); } internal static IDataReader GetBonusDetailsByBonID(TransactionContext tc, int nID, DateTime dBonusMonth, int payrolltypeid) { return tc.ExecuteReader( "SELECT * FROM BONUSPROCESSDETAIL WHERE BonusID=(Select Distinct BonusID from BONUSPROCESS where BonusID=%n AND PayrollTypeID=%n) and DisburseDate=%d", nID, payrolltypeid, PayrollGlobalFunctions.PayrollLastDateOfMonth(dBonusMonth)); } internal static IDataReader GetBonusDetails(TransactionContext tc, DateTime dMonth, bool bPayWithSalary, int payrolltypeid) { return tc.ExecuteReader("Select BPD.* from BONUSPROCESS BP,BONUSPROCESSDETAIL BPD " + "WHERE BP.BonusProcessID = BPD.BonusProcessID AND BP.BonusMonth = %d " + "AND BP.IsDisbursewithSalary = %b AND BP.PayrollTypeID=%n", dMonth, bPayWithSalary, payrolltypeid); } internal static IDataReader GetSumOfBonusDetails(TransactionContext tc, DateTime fromMonth, DateTime toMonth, int payrolltypeid) { return tc.ExecuteReader( "Select BPD.bonusID, employeeID, SUM(ChangeBonusAmount-ChangeTaxAmount) BonusAmount, count(*) Count from BONUSPROCESS BP,BONUSPROCESSDETAIL BPD " + "WHERE BP.BonusProcessID = BPD.BonusProcessID AND BP.BonusMonth BETWEEN %d AND %d " + " AND BP.PayrollTypeID=%n group by EmployeeID, BPD.BonusID ", fromMonth, toMonth, payrolltypeid); } //internal static IDataReader GetBProcessSalaryItem(TransactionContext tc, int nBonusProID) //{ // return tc.ExecuteReader("Select * FROM BonusProcessSalaryItem WHERE BonusProcessDetailID IN ( Select BONUSPROCESSDETAILID " // + " from BonusProcessDetail WHERE BonusProcessID=%n)", nBonusProID); //} //internal static IDataReader GetBProcessAdjust(TransactionContext tc, int nBonusProID) //{ // return tc.ExecuteReader("Select * FROM BonusProcessAdjustItem WHERE BonusProcessDetailID IN ( Select BONUSPROCESSDETAILID " // + " from BonusProcessDetail WHERE BonusProcessID=%n)", nBonusProID); //} //internal static IDataReader GetEmpCostCenter(TransactionContext tc, int nID) //{ // return tc.ExecuteReader("SELECT * FROM BonusEmpCostCenter WHERE BonusProcessID=%n", nID); //} internal static DataSet GetBonusRegister(TransactionContext tc, int BonusID, DateTime dBonusMonth, string sEmpID, int payrolltypeid) { DataSet oBonusRegs = new DataSet(); string sql = SQLParser.MakeSQL( @"SELECT Emp.EMPLOYEENO,Emp.NAME,BPD.GROSSSALARY,Emp.JOININGDATE,Convert(varchar(20),Emp.DATEOFCONFIRMATION,106)DATEOFCONFIRMATION,BPD.BasicSalary,BPD.ChangeBonusAmount,BPD.ChangeTaxAmount, datediff(yy,Emp.JOININGDATE,BPD.DisburseDate) ServiceLength, ACCOUNTNO " + " FROM EMPLOYEE AS Emp,BonusProcessDetail AS BPD" + " WHERE Emp.EMPLOYEEID =BPD.EmployeeID" + " AND BPD.BonusID=(Select Distinct BonusID from BONUSPROCESS where BonusID=%n AND PayrollTypeID=%n)" + " AND BPD.DisburseDate between %d and %d AND Emp.EMPLOYEEID IN (%q) Order By Emp.EMPLOYEENO", BonusID, payrolltypeid, dBonusMonth, PayrollGlobalFunctions.PayrollLastDateOfMonth(dBonusMonth), sEmpID); oBonusRegs = tc.ExecuteDataSet(sql); return oBonusRegs; } internal static DataSet GetBonusRegisterNew(TransactionContext tc, int BonusID, DateTime dBonusMonth, string sEmpID,int payrolltypeid) { DataSet oBonusRegs = new DataSet(); oBonusRegs = tc.ExecuteDataSet("SELECT Emp.EMPLOYEENO,Emp.NAME,Emp.GROSSSALARY,Emp.JOININGDATE,Convert(varchar(20),Emp.DATEOFCONFIRMATION,106)DATEOFCONFIRMATION,BPD.BasicSalary,BPD.ChangeBonusAmount,BPD.ChangeTaxAmount, datediff(yy,Emp.JOININGDATE,BPD.DisburseDate) ServiceLength, ACCOUNTNO " + " FROM EMPLOYEE AS Emp,BonusProcessDetail AS BPD" + " WHERE Emp.EMPLOYEEID =BPD.EmployeeID" + " AND BPD.BonusID=(Select Distinct BonusID from BONUSPROCESS where BonusID=%n AND PayrollTypeID=%n)" + " AND BPD.DisburseDate between %d and %d AND Emp.EMPLOYEEID IN (%q) Order By Emp.EMPLOYEENO", BonusID, payrolltypeid, dBonusMonth, GlobalFunctions.LastDateOfMonth(dBonusMonth), sEmpID); return oBonusRegs; } internal static DataSet GetBonusBankAdvice(TransactionContext tc, int BonusID, DateTime dBonusMonth, string sEmpID, int payrolltypeid) { DataSet oBonusRegs = new DataSet(); string sBonus = SQLParser.MakeSQL(@"SELECT distinct Emp.EMPLOYEENO,Emp.NAME,Emp.ACCOUNTNO,Emp.EMAILADDRESS, (BPD.ChangeBonusAmount-BPD.ChangeTaxAmount) as BonusAmount FROM EMPLOYEE AS Emp,BonusProcessDetail AS BPD,BANKACCOUNTHISTORY as BAH WHERE Emp.EMPLOYEEID =BPD.EmployeeID AND BPD.BonusID=(Select Distinct BonusID from BONUSPROCESS where BonusID=%n AND PayrollTypeID=%n) AND EMP.EMPLOYEEID=BAH.EMPLOYEEID AND Emp.BRANCHID=BAH.BRANCHID AND BPD.DisburseDate between %d and %d AND Emp.EMPLOYEEID IN (%q) Order By Emp.EMPLOYEENO", BonusID, payrolltypeid, PayrollGlobalFunctions.PayrollFirstDateOfMonth(dBonusMonth), PayrollGlobalFunctions.PayrollLastDateOfMonth(dBonusMonth), sEmpID); oBonusRegs = tc.ExecuteDataSet(sBonus); return oBonusRegs; } internal static DataTable GetBonusItemsForESSBonusPayslip(TransactionContext tc, int employeeid) { DataTable presentDays = new DataTable(); try { string sql = string.Empty; presentDays = tc.ExecuteDataTable(@"SELECT bp.BONUSID, b.NAME + ' - ' + CAST(YEAR(bp.BONUSMONTH) AS VARCHAR) AS Name, bp.BONUSMONTH FROM BONUSPROCESSDETAIL bpd LEFT JOIN BONUSPROCESS bp ON bp.BONUSPROCESSID = bpd.BONUSPROCESSID LEFT JOIN BONUS b ON b.BONUSID = bp.BONUSID WHERE bpd.EMPLOYEEID = %n ORDER BY bp.BONUSMONTH DESC;", employeeid); } catch (Exception ex) { throw new Exception(ex.Message); } return presentDays; } internal static DataSet GetBonusPaySlip(TransactionContext tc, int BonusID, DateTime dBonusMonth, string sEmpID, int payrolltypeid) { DataSet oBonusPaySlip = new DataSet(); oBonusPaySlip = tc.ExecuteDataSet(@"SELECT BPD.GROSSSALARY,Emp.EMPLOYEENO,Emp.accountno,Emp.branchid,Emp.NAME,Emp.PAYMENTMODE,Dept.DESCRIPTION as Department,Degs.NAME as Designation,BPD.BasicSalary,BPD.ChangeBonusAmount as BonusAmount,BPD.TaxAmount,b.Name bonusName FROM EMPLOYEE AS Emp,BonusProcessDetail AS BPD,DEPARTMENT as Dept,DESIGNATION as Degs,Bonus b WHERE Emp.EMPLOYEEID =BPD.EmployeeID AND Emp.DEPARTMENTID =Dept.DEPARTMENTID AND Emp.DESIGNATIONID =Degs.DESIGNATIONID AND BPD.BonusID=(Select Distinct BonusID from BONUSPROCESS where BonusID=%n AND PayrollTypeID=%n) And b.Bonusid=BPD.BonusID AND BPD.DisburseDate between %d and %d AND Emp.EMPLOYEEID IN (%q) Order By Emp.EMPLOYEENO", BonusID, payrolltypeid, dBonusMonth, PayrollGlobalFunctions.PayrollLastDateOfMonth(dBonusMonth), sEmpID); return oBonusPaySlip; } internal static int GetForNoOfPaid(TransactionContext tc, DateTime bonusYear, int nID, int payrolltypeid) { DateTime firstDateOfYear = Global.DateFunctions.FirstDateOfYear(bonusYear); DateTime lastDateOfYear = Global.DateFunctions.LastDateOfYear(bonusYear); object oPaidItem = tc.ExecuteScalar( "Select count(*) from BONUSPROCESS where BONUSMONTH between %d and %d and BONUSID=%n AND PayrollTypeID=%n", firstDateOfYear, lastDateOfYear, nID, payrolltypeid); int nPaidItem = 0; if (oPaidItem != DBNull.Value) { nPaidItem = Convert.ToInt32(oPaidItem); } return nPaidItem; } internal static int GetForNoOfPaidForEmp(TransactionContext tc, DateTime bonusYear, int nID, int EmpID, int payrolltypeid) { DateTime firstDateOfYear = Global.DateFunctions.FirstDateOfYear(bonusYear); DateTime lastDateOfYear = Global.DateFunctions.LastDateOfYear(bonusYear); object oPaidItem = tc.ExecuteScalar( @"SELECT COUNT (*) FROM BONUSPROCESSDETAIL b WHERE b.EmployeeID=%n AND b.BonusProcessID IN (Select bonusProcessID from BONUSPROCESS where BONUSMONTH between %d and %d and BONUSID=%n AND PayrollTypeID=%n)", EmpID, firstDateOfYear, lastDateOfYear, nID, payrolltypeid); int nPaidItem = 0; if (oPaidItem != DBNull.Value) { nPaidItem = Convert.ToInt32(oPaidItem); } return nPaidItem; } #endregion #region Delete function internal static void Delete(TransactionContext tc, int nID, int payrolltypeid) { tc.ExecuteNonQuery("DELETE FROM [BONUSPROCESS] WHERE BonusProcessID=%n AND PayrollTypeID=%n", nID, payrolltypeid); } internal static void DeleteBonusProcrss(TransactionContext tc, int nbonusID, DateTime dBMonthDate, int payrolltypeid) { tc.ExecuteNonQuery("DELETE FROM [BONUSPROCESS] WHERE BONUSID=%n AND BONUSMONTH=%d AND PayrollTypeID=%n", nbonusID, PayrollGlobalFunctions.PayrollLastDateOfMonth(dBMonthDate), payrolltypeid); } internal static void DeleteProcessDetailByProcessID(TransactionContext tc, int nbonusID, int nbonusProcessID, int payrolltypeid) { tc.ExecuteNonQuery( "DELETE FROM [BonusProcessDetail] WHERE BonusID=%n AND BonusProcessID=(Select BonusProcessID from BonusProcess where BonusProcessID=%n AND PayrollTypeID=%n)", nbonusID, nbonusProcessID, payrolltypeid); } //internal static void DeletePAdjustItemByProcessDetailID(TransactionContext tc, int nBonusProcesesID) //{ // tc.ExecuteNonQuery("delete from BonusProcessAdjustItem where BonusProcessDetailID in(Select BonusProcessDetailID from BONUSPROCESSDETAIL where BonusProcessID=%n)", nBonusProcesesID); //} //internal static void DeletePSalaryItemByProcessDetailID(TransactionContext tc, int nBonusProcessID) //{ // tc.ExecuteNonQuery("delete from BonusProcessSalaryItem where BonusProcessDetailID in(Select BonusProcessDetailID from BONUSPROCESSDETAIL where BonusProcessID=%n)", nBonusProcessID); //} //internal static void DeleteSalaryEmpCC(TransactionContext tc, int nID) //{ // tc.ExecuteNonQuery("DELETE FROM BonusEmpCostCenter WHERE BonusProcessID=%n", nID); //} internal static void UndoProcess(TransactionContext tc, BonusProcess oBonusPro) { // tc.ExecuteNonQuery("DELETE FROM BonusEmpCostCenter WHERE BonusProcessID=%n", oBonusPro.ID); //tc.ExecuteNonQuery("DELETE FROM BonusProcessAdjustItem WHERE BonusProcessDetailID IN ( Select BONUSPROCESSDETAILID " // + " from BonusProcessDetail WHERE BonusProcessID=%n)", oBonusPro.ID); //tc.ExecuteNonQuery("DELETE FROM BonusProcessSalaryItem WHERE BonusProcessDetailID IN ( Select BONUSPROCESSDETAILID " // + " from BonusProcessDetail WHERE BonusProcessID=%n)", oBonusPro.ID); tc.ExecuteNonQuery( "DELETE FROM BonusProcessDetail WHERE BonusProcessID=(Select BonusProcessID from BONUSPROCESS where BonusProcessID=%n AND PayrollTypeID=%n)", oBonusPro.ID, oBonusPro.PayrollTypeID); tc.ExecuteNonQuery("DELETE FROM BONUSPROCESS WHERE BonusProcessID=%n AND PayrollTypeID=%n", oBonusPro.ID, oBonusPro.PayrollTypeID); } internal static void ApproveBonus(TransactionContext tc, int bonusid, DateTime bonusMonth) { tc.ExecuteNonQuery( "update bonusProcess set IsApprove =1 where bonusid=%n and BonusMonth=%d", bonusid, bonusMonth); } internal static bool IsApproved(TransactionContext tc, int payrolltypeid, int bonusid, DateTime bonusMonth) { object isApprove = tc.ExecuteScalar( "select Count(*) from bonusProcess where payrolltypeid=%n and " + "BONUSMONTH=%d and BONUSID=%n and ISAPPROVE=1", payrolltypeid, bonusMonth, bonusid); bool approved = false; if (isApprove != DBNull.Value) { if (Convert.ToInt32(isApprove) > 0) { approved = true; } } return approved; } #endregion internal static DataSet GetMontlyProdBonus(TransactionContext tc, DateTime dBonusMonth) { DataSet oPrdBonus = new DataSet(); string sql = SQLParser.MakeSQL(@"SELECT e.EMPLOYEENO,e.[NAME],e.DEPARTMENTID,dpt.[DESCRIPTION] Department,dsg.[NAME] Designation,Sum(pbpe.Amount) Amount FROM ProdBonusProcessEmp pbpe, ProdBonusProcess pbp,Employee e, DESIGNATION dsg, DEPARTMENT dpt WHERE pbpe.ProdBonusProcessID=pbp.ProdBonusProcessID AND pbpe.EmployeeID=e.EMPLOYEEID AND e.DEPARTMENTID=dpt.DEPARTMENTID AND e.DESIGNATIONID=dsg.DESIGNATIONID AND pbp.SalaryMonth BETWEEN %d and %d Group By e.EMPLOYEENO,e.[NAME],e.DEPARTMENTID,dpt.[DESCRIPTION],dsg.[NAME] Order By e.EMPLOYEENO", PayrollGlobalFunctions.PayrollFirstDateOfMonth(dBonusMonth), PayrollGlobalFunctions.PayrollLastDateOfMonth(dBonusMonth)); oPrdBonus = tc.ExecuteDataSet(sql); return oPrdBonus; } internal static DataSet GetProdBonusDetail(TransactionContext tc, int designID) { DataSet oPrdBonus = new DataSet(); oPrdBonus = tc.ExecuteDataSet( @"SELECT e.EMPLOYEENO,e.[NAME],e.DEPARTMENTID,dpt.[DESCRIPTION] Department,dsg.[NAME] Designation,pbpe.Amount,pbpe.WorkingHour,pbpe.OTHour,pbl.ScheduledHour FROM ProdBonusProcessItem pbpe,ProdBonusLine pbl, ProdBonusProcess pbp,Employee e, DESIGNATION dsg, DEPARTMENT dpt WHERE pbl.ProdBonusLineID= pbpe.ProdBonusLineID AND pbpe.ProdBonusProcessID=pbp.ProdBonusProcessID AND pbpe.EmployeeID=e.EMPLOYEEID AND e.DEPARTMENTID=dpt.DEPARTMENTID AND e.DESIGNATIONID=dsg.DESIGNATIONID AND pbpe.ProdBonusSetupID=%n Order By e.EMPLOYEENO", designID ); return oPrdBonus; } internal static DataSet EmpDesignWiseProdBonus(TransactionContext tc, DateTime dBonusMonth) { DataSet oPrdBonus = new DataSet(); oPrdBonus = tc.ExecuteDataSet( @"SELECT pbs.DesignNo,pbs.FromDate StartDate,pbs.ToDate EndDate, e.EMPLOYEENO,e.[NAME],e.DEPARTMENTID,dpt.[DESCRIPTION] Department,dsg.[NAME] Designation,SUM(pbpe.Amount) Amount,pbpe.WorkingHour,pbpe.OTHour,pbl.ScheduledHour, pbs.OTHour BonusHour FROM ProductionBonusSetup pbs, ProdBonusProcessItem pbpe,ProdBonusLine pbl, ProdBonusProcess pbp,Employee e, DESIGNATION dsg, DEPARTMENT dpt WHERE pbs.ProductionBonusSetupID=pbpe.ProdBonusSetupID AND pbs.ProductionBonusSetupID=pbl.ProdBonusSetupID AND pbl.ProdBonusLineID= pbpe.ProdBonusLineID AND pbpe.ProdBonusProcessID=pbp.ProdBonusProcessID AND pbpe.EmployeeID=e.EMPLOYEEID AND e.DEPARTMENTID=dpt.DEPARTMENTID AND e.DESIGNATIONID=dsg.DESIGNATIONID AND pbp.SalaryMonth BETWEEN %d and %d GROUP BY pbs.DesignNo,pbs.FromDate ,pbs.ToDate , e.EMPLOYEENO,e.[NAME],e.DEPARTMENTID,dpt.[DESCRIPTION],dsg.[NAME],pbpe.WorkingHour,pbpe.OTHour,pbl.ScheduledHour, pbs.OTHour Order By e.EMPLOYEENO", PayrollGlobalFunctions.PayrollFirstDateOfMonth(dBonusMonth), PayrollGlobalFunctions.PayrollLastDateOfMonth(dBonusMonth)); return oPrdBonus; } internal static DataTable GetUnApprovedBonuses(TransactionContext tc, DateTime dMonthDate, int payrollTypeID) { return tc.ExecuteDataTable("SELECT *, b.name , (select Count(*) Count From bonusProcessDetail bdetail where bdetail.bonusProcessid=bp.bonusProcessid) " + "Count FROM bonusProcess bp, bonus b Where b.bonusid =bp.bonusid and bp.IsApprove=%b and bp.BonusMonth = %d And bp.PayrollTypeID=%n", false, dMonthDate, payrollTypeID); } } #endregion }