using HRM.BO; using Ease.Core.DataAccess; using System; using System.Data; namespace HRM.Service { class LeaveEncashmentDA { #region Constructor public LeaveEncashmentDA() { } #endregion #region Insert function public static void Insert(TransactionContext tc, LeaveEncashment oItem) { tc.ExecuteNonQuery("INSERT INTO LeaveEncashment(LeaveEncashmentID, LeaveYearID, LeaveID, EmployeeID, EncashmentDays, Amount,TaxAmount, " + " IsFromWeb, GrossSalary, LeaveBalance,TaxParamID,EncashmentFromDate,EncashmentToDate, EnjoyedLeave, PresentDays, AbsentDays, HoliDays, CreatedBy, CreatedDate, BasicSalary, ESSSubmittedDays)" + " VALUES(%n, %n, %n, %n, %n,%n,%n,%b, %n, %n,%n, %d, %d, %n, %n, %n, %n, %n, %d, %n, %n)", oItem.ID, oItem.LeaveYearID, oItem.LeaveID, oItem.EmployeeID, oItem.EncashmentDays, oItem.Amount,oItem.TaxAmount, oItem.IsFromWeb, oItem.GrossSalary, oItem.LeaveBalance, oItem.TaxParamID, DataReader.GetNullValue(oItem.encashmentFromDate), DataReader.GetNullValue(oItem.encashmentToDate), oItem.enjoyedLeave, oItem.presentDays, oItem.absentDays,oItem.holiDays, DataReader.GetNullValue(oItem.CreatedBy), DataReader.GetNullValue(oItem.CreatedDate), oItem.BasicSalary, oItem.ESSSubmittedDays); } #endregion #region Update function public static void Update(TransactionContext tc, LeaveEncashment oItem) { tc.ExecuteNonQuery("UPDATE LeaveEncashment SET LeaveYearID=%n, LeaveID=%n, EmployeeID=%n, EncashmentDays=%n, Amount=%n,TaxAmount=%n," + " IsFromWeb=%b, GrossSalary=%n, LeaveBalance=%n,TaxParamID=%n, ModifiedBy=%n, ModifiedDate=%d, BasicSalary=%n, ESSSubmittedDays=%n" + " WHERE LeaveEncashmentID=%n", oItem.LeaveYearID, oItem.LeaveID, oItem.EmployeeID, oItem.EncashmentDays, oItem.Amount, oItem.TaxAmount, oItem.IsFromWeb, oItem.GrossSalary, oItem.LeaveBalance, oItem.TaxParamID, oItem.ModifiedBy, DataReader.GetNullValue(oItem.ModifiedDate), oItem.BasicSalary, oItem.ESSSubmittedDays, oItem.ID); } #endregion #region Get function public static IDataReader Get(TransactionContext tc, int leaveYearID, int employeeID) { return tc.ExecuteReader("SELECT * FROM LeaveEncashment where LeaveYearID=%n AND EmployeeID=%n", leaveYearID, employeeID); } public static IDataReader Get(TransactionContext tc, int leaveYearID) { return tc.ExecuteReader("SELECT * FROM LeaveEncashment where LeaveYearID=%n", leaveYearID); } #endregion #region Delete function public static void Delete(TransactionContext tc, int nLeaveEnID) { tc.ExecuteNonQuery("DELETE FROM LeaveEncashment WHERE LeaveEncashmentID=%n", nLeaveEnID); } internal static IDataReader GetByEmpIDs(TransactionContext tc, string empIDs, DateTime FirstDateOfYear, DateTime LastDateOfYear) { //return tc.ExecuteReader("SELECT * FROM LEAVEEncashment WHERE EmployeeID IN (%q) AND Encashmentfromdate >= %d AND Encashmenttodate<=%d", empIDs, FirstDateOfYear, LastDateOfYear); return tc.ExecuteReader("SELECT * FROM LEAVEEncashment WHERE EmployeeID IN (%q) AND Encashmentfromdate >= %d ", empIDs, FirstDateOfYear); } internal static DataSet GetData(TransactionContext tc, int nYearID) { DataSet rawData = new DataSet(); try { string sql = SQLParser.MakeSQL(@"SELECT cc.DESCRIPTION,sum(Amount)Amout FROM LeaveEncashment le,EMPCOSTCENTER ecc, CRG cc WHERE le.EmployeeID=ecc.EMPLOYEEID AND ecc.COSTCENTERID=cc.CRGID AND ecc.CurrentCC=1 AND le.LeaveYearID=%n GROUP BY cc.DESCRIPTION ORDER BY cc.DESCRIPTION", nYearID); rawData = tc.ExecuteDataSet(sql); } catch (Exception ex) { throw new Exception(ex.Message); } return rawData; } internal static DataSet GetSalaryData(TransactionContext tc, DateTime dt) { DataSet rawData = new DataSet(); try { string sql = SQLParser.MakeSQL(@"SELECT * FROM ( SELECT cc.CRGID, cc.DESCRIPTION CostCenter,isnull(tab1.TotalGross,0)TotalGross,isnull(tab2.PF,0)PF,isnull(tab3.PFLoan,0)PFLoan,isnull(tab4.TotalDeduction,0)TotalDeduction ,isnull(tab5.NetPay,0)NetPay ,isnull(tab6.HR,0)HR ,isnull(tab7.Convence,0)Convence ,isnull(tab8.Medical,0)Medical ,isnull(tab11.Basic,0)Basic FROM CRG cc LEFT OUTER JOIN (SELECT scc.COSTCENTERID,sum(smd.CHANGEDAMOUNT) TotalGross FROM SALARYMONTHLY sm,SALARYMONTHLYDETAIL smd, SALARYEMPCOSTCENTER scc WHERE sm.SALARYMONTHLYID=smd.SALARYMONTHLYID AND sm.SALARYMONTHLYID=scc.SALARYMONTHLYID AND sm.SalaryMonth=%d AND sm.CATEGORYID <> 7 AND ITEMGROUP IN(1,8) GROUP BY scc.COSTCENTERID)tab1 ON cc.CRGID = tab1.COSTCENTERID LEFT OUTER JOIN (SELECT scc.COSTCENTERID,sum(smd.CHANGEDAMOUNT) HR FROM SALARYMONTHLY sm,SALARYMONTHLYDETAIL smd, SALARYEMPCOSTCENTER scc WHERE sm.SALARYMONTHLYID=smd.SALARYMONTHLYID AND sm.SALARYMONTHLYID=scc.SALARYMONTHLYID AND sm.SalaryMonth=%d AND sm.CATEGORYID <> 7 AND itemcode=-113 AND itemid=13 GROUP BY scc.COSTCENTERID)tab6 ON cc.CRGID = tab6.COSTCENTERID LEFT OUTER JOIN (SELECT scc.COSTCENTERID,sum(smd.CHANGEDAMOUNT) Basic FROM SALARYMONTHLY sm,SALARYMONTHLYDETAIL smd, SALARYEMPCOSTCENTER scc WHERE sm.SALARYMONTHLYID=smd.SALARYMONTHLYID AND sm.SALARYMONTHLYID=scc.SALARYMONTHLYID AND sm.SalaryMonth=%d AND sm.CATEGORYID <> 7 AND itemcode=-101 AND itemid=-101 GROUP BY scc.COSTCENTERID)tab11 ON cc.CRGID = tab11.COSTCENTERID LEFT OUTER JOIN (SELECT scc.COSTCENTERID,sum(smd.CHANGEDAMOUNT) Convence FROM SALARYMONTHLY sm,SALARYMONTHLYDETAIL smd, SALARYEMPCOSTCENTER scc WHERE sm.SALARYMONTHLYID=smd.SALARYMONTHLYID AND sm.SALARYMONTHLYID=scc.SALARYMONTHLYID AND sm.SalaryMonth=%d AND sm.CATEGORYID <> 7 AND itemcode=-113 AND itemid=15 GROUP BY scc.COSTCENTERID)tab7 ON cc.CRGID = tab7.COSTCENTERID LEFT OUTER JOIN (SELECT scc.COSTCENTERID,sum(smd.CHANGEDAMOUNT) Medical FROM SALARYMONTHLY sm,SALARYMONTHLYDETAIL smd, SALARYEMPCOSTCENTER scc WHERE sm.SALARYMONTHLYID=smd.SALARYMONTHLYID AND sm.SALARYMONTHLYID=scc.SALARYMONTHLYID AND sm.SalaryMonth=%d AND sm.CATEGORYID <> 7 AND itemcode=-113 AND itemid=14 GROUP BY scc.COSTCENTERID)tab8 ON cc.CRGID = tab8.COSTCENTERID LEFT OUTER JOIN (SELECT scc.COSTCENTERID,sum(smd.CHANGEDAMOUNT) PF FROM SALARYMONTHLY sm,SALARYMONTHLYDETAIL smd, SALARYEMPCOSTCENTER scc WHERE sm.SALARYMONTHLYID=smd.SALARYMONTHLYID AND sm.SALARYMONTHLYID=scc.SALARYMONTHLYID AND sm.SalaryMonth=%d AND sm.CATEGORYID <> 7 AND ITEMGROUP IN(3) AND itemcode=-128 AND itemid=-128 GROUP BY scc.COSTCENTERID)tab2 ON cc.CRGID = tab2.COSTCENTERID LEFT OUTER JOIN (SELECT scc.COSTCENTERID,sum(smd.CHANGEDAMOUNT) PFLoan FROM SALARYMONTHLY sm,SALARYMONTHLYDETAIL smd, SALARYEMPCOSTCENTER scc WHERE sm.SALARYMONTHLYID=smd.SALARYMONTHLYID AND sm.SALARYMONTHLYID=scc.SALARYMONTHLYID AND sm.SalaryMonth=%d AND sm.CATEGORYID <> 7 AND ITEMGROUP IN(3) AND itemcode=-118 AND itemid=1 GROUP BY scc.COSTCENTERID)tab3 ON cc.CRGID = tab3.COSTCENTERID LEFT OUTER JOIN (SELECT scc.COSTCENTERID,sum(smd.CHANGEDAMOUNT) TotalDeduction FROM SALARYMONTHLY sm,SALARYMONTHLYDETAIL smd, SALARYEMPCOSTCENTER scc WHERE sm.SALARYMONTHLYID=smd.SALARYMONTHLYID AND sm.SALARYMONTHLYID=scc.SALARYMONTHLYID AND sm.SalaryMonth=%d AND sm.CATEGORYID <> 7 AND ITEMGROUP IN(3) AND itemcode NOT IN(-118,-128) GROUP BY scc.COSTCENTERID)tab4 ON cc.CRGID = tab4.COSTCENTERID LEFT OUTER JOIN (SELECT scc.COSTCENTERID,sum(smd.CHANGEDAMOUNT) NetPay FROM SALARYMONTHLY sm,SALARYMONTHLYDETAIL smd, SALARYEMPCOSTCENTER scc WHERE sm.SALARYMONTHLYID=smd.SALARYMONTHLYID AND sm.SALARYMONTHLYID=scc.SALARYMONTHLYID AND sm.SalaryMonth=%d AND sm.CATEGORYID <> 7 AND itemcode=-132 AND itemid=-132 GROUP BY scc.COSTCENTERID)tab5 ON cc.CRGID = tab5.COSTCENTERID)tab WHERE (TotalGross<>0 OR PF<>0 OR PFLoan<>0 OR TotalDeduction<>0 OR NetPay<>0) ORDER BY CostCenter", dt, dt, dt, dt, dt, dt, dt, dt, dt); rawData = tc.ExecuteDataSet(sql); } catch (Exception ex) { throw new Exception(ex.Message); } return rawData; } internal static DataSet GetSalaryDataExpat(TransactionContext tc, DateTime dt) { DataSet rawData = new DataSet(); try { string sql = SQLParser.MakeSQL(@"SELECT * FROM ( SELECT cc.CRGID, cc.DESCRIPTION CostCenter, isnull(tab11.Basic,0)Basic , isnull(tab2.MonthlyLocationAllowanceEURO,0)MonthlyLocationAllowanceEURO, isnull(tab1.TotalGross,0)ActualGross, isnull(tab1.TotalGross,0)TotalGross, isnull(tab3.ChildDeductionEURO,0)ChildDeductionEURO ,isnull(tab6.HousingDeductionEURO,0)HousingDeductionEURO , isnull(tab4.TotalDeduction,0)TotalDeduction ,isnull(tab5.NetPay,0)NetPay FROM CRG cc LEFT OUTER JOIN (SELECT scc.COSTCENTERID,sum(smd.CHANGEDAMOUNT) TotalGross FROM SALARYMONTHLY sm,SALARYMONTHLYDETAIL smd, SALARYEMPCOSTCENTER scc WHERE sm.SALARYMONTHLYID=smd.SALARYMONTHLYID AND sm.SALARYMONTHLYID=scc.SALARYMONTHLYID AND sm.SalaryMonth=%d AND sm.CATEGORYID = 7 AND ITEMGROUP IN(1,8) GROUP BY scc.COSTCENTERID)tab1 ON cc.CRGID = tab1.COSTCENTERID LEFT OUTER JOIN (SELECT scc.COSTCENTERID,sum(smd.CHANGEDAMOUNT) HousingDeductionEURO FROM SALARYMONTHLY sm,SALARYMONTHLYDETAIL smd, SALARYEMPCOSTCENTER scc WHERE sm.SALARYMONTHLYID=smd.SALARYMONTHLYID AND sm.SALARYMONTHLYID=scc.SALARYMONTHLYID AND sm.SalaryMonth=%d AND sm.CATEGORYID = 7 AND ITEMGROUP IN(3) AND itemcode=-115 AND itemid=10 GROUP BY scc.COSTCENTERID)tab6 ON cc.CRGID = tab6.COSTCENTERID LEFT OUTER JOIN (SELECT scc.COSTCENTERID,sum(smd.CHANGEDAMOUNT) Basic FROM SALARYMONTHLY sm,SALARYMONTHLYDETAIL smd, SALARYEMPCOSTCENTER scc WHERE sm.SALARYMONTHLYID=smd.SALARYMONTHLYID AND sm.SALARYMONTHLYID=scc.SALARYMONTHLYID AND sm.SalaryMonth=%d AND sm.CATEGORYID = 7 AND itemcode=-101 AND itemid=-101 GROUP BY scc.COSTCENTERID)tab11 ON cc.CRGID = tab11.COSTCENTERID LEFT OUTER JOIN (SELECT scc.COSTCENTERID,sum(smd.CHANGEDAMOUNT) MonthlyLocationAllowanceEURO FROM SALARYMONTHLY sm,SALARYMONTHLYDETAIL smd, SALARYEMPCOSTCENTER scc WHERE sm.SALARYMONTHLYID=smd.SALARYMONTHLYID AND sm.SALARYMONTHLYID=scc.SALARYMONTHLYID AND sm.SalaryMonth=%d AND sm.CATEGORYID = 7 AND ITEMGROUP IN(1) AND smd.ItemCode not in(-133,-101) GROUP BY scc.COSTCENTERID)tab2 ON cc.CRGID = tab2.COSTCENTERID LEFT OUTER JOIN (SELECT scc.COSTCENTERID,sum(smd.CHANGEDAMOUNT) ChildDeductionEURO FROM SALARYMONTHLY sm,SALARYMONTHLYDETAIL smd, SALARYEMPCOSTCENTER scc WHERE sm.SALARYMONTHLYID=smd.SALARYMONTHLYID AND sm.SALARYMONTHLYID=scc.SALARYMONTHLYID AND sm.SalaryMonth=%d AND sm.CATEGORYID = 7 AND ITEMGROUP IN(3) AND itemcode=-115 AND itemid=24 GROUP BY scc.COSTCENTERID)tab3 ON cc.CRGID = tab3.COSTCENTERID LEFT OUTER JOIN (SELECT scc.COSTCENTERID,sum(smd.CHANGEDAMOUNT) TotalDeduction FROM SALARYMONTHLY sm,SALARYMONTHLYDETAIL smd, SALARYEMPCOSTCENTER scc WHERE sm.SALARYMONTHLYID=smd.SALARYMONTHLYID AND sm.SALARYMONTHLYID=scc.SALARYMONTHLYID AND sm.SalaryMonth=%d AND sm.CATEGORYID = 7 AND ITEMGROUP IN(3) AND itemcode NOT IN(-118,-128) GROUP BY scc.COSTCENTERID)tab4 ON cc.CRGID = tab4.COSTCENTERID LEFT OUTER JOIN (SELECT scc.COSTCENTERID,sum(smd.CHANGEDAMOUNT) NetPay FROM SALARYMONTHLY sm,SALARYMONTHLYDETAIL smd, SALARYEMPCOSTCENTER scc WHERE sm.SALARYMONTHLYID=smd.SALARYMONTHLYID AND sm.SALARYMONTHLYID=scc.SALARYMONTHLYID AND sm.SalaryMonth=%d AND sm.CATEGORYID = 7 AND itemcode=-132 AND itemid=-132 GROUP BY scc.COSTCENTERID)tab5 ON cc.CRGID = tab5.COSTCENTERID)tab WHERE (TotalGross<>0 OR MonthlyLocationAllowanceEURO<>0 OR ChildDeductionEURO<>0 OR TotalDeduction<>0 OR NetPay<>0) ORDER BY CostCenter", dt, dt, dt, dt, dt, dt, dt); rawData = tc.ExecuteDataSet(sql); } catch (Exception ex) { throw new Exception(ex.Message); } return rawData; } internal static IDataReader GetLeaves(TransactionContext tc) { return tc.ExecuteReader("SELECT * FROM Leave"); } #endregion } }