using HRM.BO; using Ease.Core.DataAccess; using System; using System.Data; namespace HRM.DA { internal static class BudgetProcessMonthlyDA { #region Parent Class Data Access public static IDataReader Get(TransactionContext tc, int nID, int payrollTypeID) { return tc.ExecuteReader( "Select * from BudgetProcessMonthly where BudgetProcessMonthlyID=%n AND PayrollTypeID=%n", nID, payrollTypeID); } public static IDataReader Get(TransactionContext tc, int payrollTypeID) { return tc.ExecuteReader("Select * from BudgetProcessMonthly WHERE PAyrollTypeID=%n", payrollTypeID); } public static IDataReader GetByBudgetIdAndPayrolltypeId(TransactionContext tc, int nID, int payrollTypeID) { return tc.ExecuteReader("Select * from BudgetProcessMonthly where BudgetID=%n AND PayrollTypeID=%n", nID, payrollTypeID); } public static void Insert(TransactionContext tc, BudgetProcessMonthly item) { tc.ExecuteNonQuery( "Insert into BudgetProcessMonthly(BudgetProcessMonthlyID,BudgetID,DepartmentID,EmployeeID,GradeID,IsConfirm,LocationID,Month,NewJoinerID,NewJoinerName,PayrollTypeID) Values" + "(%n,%n,%n,%n,%n,%n,%n,%d,%n,%s,%n)", item.ID, item.BudgetID, DataReader.GetNullValue(item.DepartmentID), DataReader.GetNullValue(item.EmployeeID), DataReader.GetNullValue(item.GradeID), item.IsConfirm, DataReader.GetNullValue(item.LocationID), item.Month, DataReader.GetNullValue(item.NewJoinerID), item.NewJoinerName, item.PayrollTypeID); } public static void Update(TransactionContext tc, BudgetProcessMonthly item) { tc.ExecuteNonQuery( "Update BudgetProcessMonthly SET BudgetID=%n,DepartmentID=%n,EmployeeID=%n,GradeID=%n,IsConfirm=%n,LocationID=%n,Month=%d,NewJoinerID=%n,NewJoinerName=%s,PayrollTypeID=%n where BudgetProcessMonthlyID=%n" , item.BudgetID, item.DepartmentID, item.EmployeeID, item.GradeID, item.IsConfirm, item.LocationID, item.Month, DataReader.GetNullValue(item.NewJoinerID), item.NewJoinerName, item.PayrollTypeID, item.ID); } public static void Delete(TransactionContext tc, int nID, int payrollTypeID) { tc.ExecuteNonQuery("Delete from BudgetProcessMonthly where BudgetProcessMonthlyID=%n AND payrollTypeID=%n", nID, payrollTypeID); } #endregion #region Child Class Data Access public static IDataReader GetBudgetDetails(TransactionContext tc, int id) { return tc.ExecuteReader("Select * from BudgetProcessMonthlyDetail where BudgetProcessMonthlyID=%n", id); } public static IDataReader GetBudgetMonthlyCCs(TransactionContext tc, int id) { return tc.ExecuteReader("Select * from BudgetMonthlyCC where BudgetProcessMonthlyID=%n ", id); } public static IDataReader GetBudgetMonthlyCCs(TransactionContext tc, int nBudID, DateTime fromdate, DateTime todate) { return tc.ExecuteReader( "select * from BudgetMonthlyCC where (Month>=%d AND Month<=%d) AND BudgetProcessMonthlyID in(select BudgetProcessMonthlyID from BudgetProcessMonthly where BudgetID=%n)", Ease.Core.Utility.Global.DateFunctions.FirstDateOfMonth(fromdate), Ease.Core.Utility.Global.DateFunctions.LastDateOfMonth(todate), nBudID); } public static void Delete(TransactionContext tc, string tableName, string columnName, int id) { tc.ExecuteNonQuery("Delete from %s where %s=%n", tableName, columnName, id); } public static void Insert(TransactionContext tc, BudgetProcessMonthlyDetail item) { tc.ExecuteNonQuery( "Insert into BudgetProcessMonthlyDetail(BudgetProcessMonthlyDetailID,BudgetProcessMonthlyID,BudgetComponentID,Amount,EmployeeID,Month,Name,BudgetGroup,BudgetCode,Changedamount,OriginID,Position) Values" + "(%n,%n,%n,%n,%n,%d,%s,%n,%n,%n,%n,%n)", item.ID, item.BudgetProcessMonthlyID, DataReader.GetNullValue(item.BudgetComponentID), item.Calculatedamount, DataReader.GetNullValue(item.EmployeeID), item.Month, item.Name, (int)item.BudgetGroup, (int)item.BudgetCode, item.Changedamount, DataReader.GetNullValue(item.OriginID), item.Position); } public static void Insert(TransactionContext tc, BudgetMonthlyCC item) { tc.ExecuteNonQuery( "Insert into BudgetMonthlyCC(BudgetMonthlyCCID,BudgetProcessMonthlyID,CCID,EmployeeID,Month,Percentage) Values" + "(%n,%n,%n,%n,%d,%n)", item.ID, item.BudgetProcessMonthlyID, item.CCID, DataReader.GetNullValue(item.EmployeeID), item.Month, item.Percentage); } public static IDataReader GetBudgetDetail(TransactionContext tc, DateTime stDate, DateTime endDate, int nBudgetID, int payrolltypeid) { string sSql = ""; sSql = SQLParser.MakeSQL( "select EmployeeID EmpId,Name ItemName,sum(Amount) Amount from BudgetProcessMonthlyDetail " + " where BudgetProcessMonthlyID in(select BudgetProcessMonthlyID from BudgetProcessMonthly where (Month>=%d AND Month<=%d) AND BudgetID=%n AND PayrollTypeID=%n) " + " group by EmployeeID,BudgetComponentID,Name " + " order By EmployeeID,BudgetComponentID", stDate, endDate, nBudgetID, payrolltypeid); return tc.ExecuteReader(sSql); } public static IDataReader Get(TransactionContext tc, DateTime dtFrom, DateTime dtTo, int id, int payrollTypeID) { return tc.ExecuteReader( "(select 1 SERIALNO,EmployeeID EmpId,originID,Budgetcode,Name ItemName,sum(Amount) Amount,Position from BudgetProcessMonthlyDetail" + " where BudgetProcessMonthlyID in(select BudgetProcessMonthlyID from BudgetProcessMonthly where (Month>=%d AND Month<=%d) AND BudgetID=%n AND PayrollTypeID=%n)" + " and name<>'CTC'" + " group by EmployeeID,BudgetComponentID,originID,Budgetcode,Name,Position )UNION " + " (select 2 SERIALNO,EmployeeID EmpId,originID,Budgetcode,Name ItemName,sum(Amount) Amount,Position from BudgetProcessMonthlyDetail " + " where BudgetProcessMonthlyID in(select BudgetProcessMonthlyID from BudgetProcessMonthly where (Month>=%d AND Month<=%d) AND BudgetID=%n AND PayrollTypeID=%n) " + " and name='CTC'" + " group by EmployeeID,BudgetComponentID,originID,Budgetcode,Name,Position)", dtFrom, dtTo, id, payrollTypeID, dtFrom, dtTo, id, payrollTypeID); } public static IDataReader Get2(TransactionContext tc, DateTime dtFrom, DateTime dtTo, int id, int payrollTypeID) { return tc.ExecuteReader( @"(select BudgetProcessMonthlyID, EmployeeID EmpId,originID,Budgetcode,Name ItemName, Amount,Position from BudgetProcessMonthlyDetail where BudgetProcessMonthlyID in(select BudgetProcessMonthlyID from BudgetProcessMonthly where (Month>=%d AND Month<=%d) AND BudgetID=%n AND PayrollTypeID=%n) and name<>'CTC' ) UNION (select BudgetProcessMonthlyID,EmployeeID EmpId,originID,Budgetcode,Name ItemName, Amount,Position from BudgetProcessMonthlyDetail where BudgetProcessMonthlyID in(select BudgetProcessMonthlyID from BudgetProcessMonthly where (Month>=%d AND Month<=%d) AND BudgetID=%n AND PayrollTypeID=%n) and name='CTC' ) ", dtFrom, dtTo, id, payrollTypeID, dtFrom, dtTo, id, payrollTypeID); } public static IDataReader GetCTC(TransactionContext tc, DateTime dtFrom, DateTime dtTo, int id, int payrollTypeID) { return tc.ExecuteReader( "select EmployeeID EmpId,Name ItemName,sum(Amount) Amount from BudgetProcessMonthlyDetail " + " where Name='CTC' AND BudgetProcessMonthlyID in(select BudgetProcessMonthlyID from BudgetProcessMonthly where (Month>=%d AND Month<=%d) AND BudgetID=%n AND PayrollTypeID=%n) " + " group by EmployeeID,BudgetComponentID,Name " + " order By EmployeeID,BudgetComponentID", dtFrom, dtTo, id, payrollTypeID); } #endregion } }