using System; using System.Collections.Generic; using System.Data; using System.Linq; using System.Text; using Ease.CoreV35.DataAccess; using Ease.CoreV35.Model; using Payroll.BO; namespace Payroll.Service { [Serializable] internal static class BudgetComponentDA { #region Parent Class Data Access public static IDataReader Get(TransactionContext tc, ID nId) { return tc.ExecuteReader("Select * from BudgetComponent where BudgetComponentID=%n", nId.Integer); } 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.Integer, item.BasedOn, item.BudgetID.Integer, item.ComponentType, item.FlatAmount, item.Name,DataReader.GetNullValue(item.OriginID,IDType.Integer) , DataReader.GetNullValue(item.ParameterID,IDType.Integer), item.Percentage, item.Periodicity, item.Taxable, item.PayrollTypeID.Integer,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.Integer, item.ComponentType, item.FlatAmount, item.Name, item.OriginID.Integer, item.ParameterID.Integer, item.Percentage, item.Periodicity, item.Taxable,item.PayrollTypeID,item.IndivisuallyDefined, item.ID.Integer); } public static void Delete(TransactionContext tc, ID nId) { tc.ExecuteNonQuery("Delete from BudgetComponent where BudgetComponentID=%n", nId.Integer); } #endregion #region Child Class Data Access public static IDataReader GetBudgetComponentIndivisuals(TransactionContext tc, ID id) { return tc.ExecuteReader("Select * from BudgetComponentIndivisual where BudgetComponentID=%n", id.Integer); } public static IDataReader GetBudgetComponentGrades(TransactionContext tc, ID id) { return tc.ExecuteReader("Select * from BudgetComponentGrade where BudgetComponentID=%n", id.Integer); } public static void Delete(TransactionContext tc, string tableName, string columnName, ID id) { tc.ExecuteNonQuery("Delete from %s where %s=%n", tableName, columnName, id.Integer); } 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.Integer,item.Amount,item.BudgetComponentID.Integer,item.DetailType,item.EmployeeID.Integer,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.Integer,item.BudgetComponentID.Integer,item.GradeID.Integer); } public static void DeleteBudgetComponentGrade(TransactionContext tc, ID nBudId) { tc.ExecuteNonQuery("Delete from BudgetComponentGrade where BudgetComponentID in(select BudgetComponentID from BudgetComponent where BudgetID=%n", nBudId.Integer); } public static void DeleteBudgetComponentIndivisual(TransactionContext tc, ID nId) { tc.ExecuteNonQuery("Delete from BudgetComponentIndivisual where BudgetComponentID in(select BudgetComponentID from BudgetComponent where BudgetID=%n", nId.Integer); } public static void DeleteBudgetNewJoinerCrG(TransactionContext tc, ID nId) { tc.ExecuteNonQuery("Delete from BudgetNewJoinerCrG where BudgetNewJoinerCrGID=%n", nId.Integer); } public static void DeleteBudgetProcessMonthlyDetail(TransactionContext tc, ID nId) { tc.ExecuteNonQuery("Delete from BudgetProcessMonthlyDetail where BudgetProcessMonthlyID=%n", nId.Integer); } public static void DeleteBudgetMonthlyCC(TransactionContext tc, ID nId) { tc.ExecuteNonQuery("Delete from BudgetMonthlyCC where BudgetProcessMonthlyID=%n", nId.Integer); } #endregion } }