using HRM.BO; using Ease.Core.DataAccess; using System; using System.Data; namespace HRM.DA { internal static class BudgetComponentDA { #region Parent Class Data Access public static IDataReader GetByBudgetComponentId(TransactionContext tc, int nId) { return tc.ExecuteReader("Select * from BudgetComponent where BudgetComponentID=%n", nId); } public static IDataReader Get(TransactionContext tc) { return tc.ExecuteReader("Select * from BudgetComponent"); } public static IDataReader Get(TransactionContext tc, int nID) { return tc.ExecuteReader("Select * from BudgetComponent Where BudgetID=%n", nID); } public static void Insert(TransactionContext tc, BudgetComponent item) { tc.ExecuteNonQuery( "Insert into BudgetComponent(BudgetComponentID,BasedOn,BudgetID,ComponentType,FlatAmount,Name,OriginID,ParameterID,Percentage,Periodicity,Taxable,PayrollTypeID,IndivisuallyDefined) Values" + "(%n,%n,%n,%n,%n,%s,%n,%n,%n,%n,%n,%n,%n)", item.ID, item.BasedOn, item.BudgetID, item.ComponentType, item.FlatAmount, item.Name, DataReader.GetNullValue(item.OriginID), DataReader.GetNullValue(item.ParameterID), item.Percentage, item.Periodicity, item.Taxable, item.PayrollTypeID, item.IndivisuallyDefined); } public static void Update(TransactionContext tc, BudgetComponent item) { tc.ExecuteNonQuery( "Update BudgetComponent SET BasedOn=%n,BudgetID=%n,ComponentType=%n,FlatAmount=%n,Name=%s,OriginID=%n,ParameterID=%n,Percentage=%n,Periodicity=%n,Taxable=%n,PayrollTypeID=%n,IndivisuallyDefined=%n where BudgetComponentID=%n" , item.BasedOn, item.BudgetID, item.ComponentType, item.FlatAmount, item.Name, item.OriginID, item.ParameterID, item.Percentage, item.Periodicity, item.Taxable, item.PayrollTypeID, item.IndivisuallyDefined, item.ID); } public static void Delete(TransactionContext tc, int nId) { tc.ExecuteNonQuery("Delete from BudgetComponent where BudgetComponentID=%n", nId); } #endregion #region Child Class Data Access public static IDataReader GetBudgetComponentIndivisuals(TransactionContext tc, int id) { return tc.ExecuteReader("Select * from BudgetComponentIndivisual where BudgetComponentID=%n", id); } public static IDataReader GetBudgetComponentGrades(TransactionContext tc, int id) { return tc.ExecuteReader("Select * from BudgetComponentGrade where BudgetComponentID=%n", id); } 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, BudgetComponentIndivisual item) { tc.ExecuteNonQuery( "Insert into BudgetComponentIndivisual(BudgetComponentIndivisualID,Amount,BudgetComponentID,DetailType,EmployeeID,FromDate,ToDate,ValueType) Values" + "(%n,%n,%n,%n,%n,%d,%d,%n)", item.ID, item.Amount, item.BudgetComponentID, item.DetailType, item.EmployeeID, DataReader.GetNullValue(item.FromDate), DataReader.GetNullValue(item.ToDate), item.ValueType); } public static void Insert(TransactionContext tc, BudgetComponentGrade item) { tc.ExecuteNonQuery( "Insert into BudgetComponentGrade(BudgetComponentGradeID,BudgetComponentID,GradeID) Values" + "(%n,%n,%n)", item.ID, item.BudgetComponentID, item.GradeID); } public static void DeleteBudgetComponentGrade(TransactionContext tc, int nBudId) { tc.ExecuteNonQuery( "Delete from BudgetComponentGrade where BudgetComponentID in(select BudgetComponentID from BudgetComponent where BudgetID=%n", nBudId); } public static void DeleteBudgetComponentIndivisual(TransactionContext tc, int nId) { tc.ExecuteNonQuery( "Delete from BudgetComponentIndivisual where BudgetComponentID in(select BudgetComponentID from BudgetComponent where BudgetID=%n", nId); } public static void DeleteBudgetNewJoinerCrG(TransactionContext tc, int nId) { tc.ExecuteNonQuery("Delete from BudgetNewJoinerCrG where BudgetNewJoinerCrGID=%n", nId); } public static void DeleteBudgetProcessMonthlyDetail(TransactionContext tc, int nId) { tc.ExecuteNonQuery("Delete from BudgetProcessMonthlyDetail where BudgetProcessMonthlyID=%n", nId); } public static void DeleteBudgetMonthlyCC(TransactionContext tc, int nId) { tc.ExecuteNonQuery("Delete from BudgetMonthlyCC where BudgetProcessMonthlyID=%n", nId); } #endregion } }