using System; using Payroll.BO; using System.Data; using System.Linq; using Ease.CoreV35.Model; using System.Data.SqlClient; using Ease.CoreV35.DataAccess; using System.Collections.Generic; using Ease.CoreV35.DataAccess.SQL; namespace Payroll.Service { #region OpiParameterDA public class OpiParameterDA { #region Constructor public OpiParameterDA() { } #endregion #region Insert function internal static void Insert(TransactionContext tc, OpiParameter oItem, ID payrollTypeID) { tc.ExecuteNonQuery("INSERT INTO OpiParameter(" + " OpiParameterID, OpiType, AmountToDistribute, AvgMonth, " + " ProvisionAmount, FlatAmount, FromDate, ToDate, Gender, Status, " + " IsActive, IsEarnedBasic, IsTaxable, OpiItemID, " + " OpiPeriodicity, PercentOfBasic, PercentOfGross, MinAmount, " + " MaxAmount, IsConfirmed, IsFractionate, IsWithException, " + " EntitleType, OpiAvgPayType, OpiAvgPayItemID, NoOfMonth, " + " CreatedBy, CreationDate,PayrollTypeID,ANNUALGROSSPERBAND,PERFORMANCEACHIEVEMENT)" + " VALUES(%n, %n, %n, %n, " + " %n, %n, %d, %d, %n, %n, " + " %b, %b, %b, %n, " + " %n, %n, %n, %n, " + " %n, %b, %b, %b, " + " %n, %n, %n, %n, " + " %n, %d,%n,%n,%n)", oItem.ID.Integer, oItem.OpiType, oItem.AmountToDistribute, oItem.AvgMonth, oItem.ProvisionAmount, oItem.FlatAmount, DataReader.GetNullValue(oItem.FromDate), DataReader.GetNullValue(oItem.ToDate), oItem.Gender, oItem.Status, oItem.IsActive, oItem.IsEarnedBasic, oItem.IsTaxable, oItem.OpiItemID.Integer, oItem.OpiPeriodicity, oItem.PercentOfBasic, oItem.PercentOfGross, DataReader.GetNullValue(oItem.MinAmount), DataReader.GetNullValue(oItem.MaxAmount), oItem.IsConfirmed, oItem.IsFractionate, oItem.IsWithException, oItem.EntitleType, oItem.OpiAvgPayType, DataReader.GetNullValue(oItem.OpiAvgPayItemID, IDType.Integer), oItem.NoOfMonth, DataReader.GetNullValue(Payroll.BO.User.CurrentUser.ID, IDType.Integer), DataReader.GetNullValue(DateTime.Now), payrollTypeID.Integer, oItem.AnnualGrossPerBand, oItem.PerformanceAchievement); } internal static void InsertGrade(TransactionContext tc, OpiParameterGrade oItem, ID payrollTypeID) { tc.ExecuteNonQuery("INSERT INTO OpiParameterGrade(" + " GradeID, OpiParameterID, OpiItemId, " + " CreatedBy, CreationDate,PayrollTypeID)" + " VALUES(%n, %n, %n, " + " %n, %d,%n)", oItem.GradeId.Integer, oItem.OpiParameterId.Integer, oItem.OpiItemId.Integer, DataReader.GetNullValue(oItem.CreatedBy.Integer), DataReader.GetNullValue(oItem.CreatedDate), payrollTypeID.Integer); } #endregion #region Update function internal static void Update(TransactionContext tc, OpiParameter oItem, ID payrollTypeID) { tc.ExecuteNonQuery("UPDATE OpiParameter SET " + " OpiType=%n, AmountToDistribute=%n, AvgMonth=%n, ProvisionAmount=%n, FlatAmount=%n, " + " FromDate=%d, ToDate=%d, Gender=%n, Status=%n, IsActive=%b, " + " IsEarnedBasic=%b, IsTaxable=%b, OpiItemID=%n, OpiPeriodicity=%n, " + " PercentOfBasic=%n, PercentOfGross=%n, MinAmount=%n, MaxAmount=%n, " + " IsConfirmed=%b, IsFractionate=%b, IsWithException=%n, EntitleType=%n, " + " OpiAvgPayType=%n, OpiAvgPayItemID=%n, NoOfMonth=%n, " + " ModifiedBy=%n, ModifiedDate=%d,ANNUALGROSSPERBAND=%n,PERFORMANCEACHIEVEMENT=%n WHERE OpiParameterID=%n AND PayrollTypeID=%n", oItem.OpiType, oItem.AmountToDistribute, oItem.AvgMonth, oItem.ProvisionAmount, oItem.FlatAmount, DataReader.GetNullValue(oItem.FromDate), DataReader.GetNullValue(oItem.ToDate), oItem.Gender, oItem.Status, oItem.IsActive, oItem.IsEarnedBasic, oItem.IsTaxable, oItem.OpiItemID.Integer, oItem.OpiPeriodicity, oItem.PercentOfBasic, oItem.PercentOfGross, oItem.MinAmount, oItem.MaxAmount, oItem.IsConfirmed, oItem.IsWithException, oItem.IsFractionate, oItem.EntitleType, oItem.OpiAvgPayType, DataReader.GetNullValue(oItem.OpiAvgPayItemID, IDType.Integer), oItem.NoOfMonth, DataReader.GetNullValue(Payroll.BO.User.CurrentUser.ID, IDType.Integer), DataReader.GetNullValue(DateTime.Now),oItem.AnnualGrossPerBand,oItem.PerformanceAchievement, oItem.ID.Integer, payrollTypeID.Integer); } #endregion #region Get Function internal static IDataReader Get(TransactionContext tc, ID payrollTypeID) { return tc.ExecuteReader("SELECT * FROM OpiParameter where PayrollTypeID=%n", payrollTypeID.Integer); } internal static IDataReader Get(TransactionContext tc, ID nID, ID payrollTypeID) { return tc.ExecuteReader("SELECT * FROM OpiParameter WHERE OpiParameterID =%n AND PayrollTypeID=%n", nID.Integer, payrollTypeID.Integer); } internal static IDataReader GetGrades(TransactionContext tc, ID nOpiParameterID, ID payrollTypeID) { return tc.ExecuteReader("Select * from OpiParameterGrade Where OpiParameterID= %n AND PayrollTypeID=%n", nOpiParameterID.Integer, payrollTypeID.Integer); } internal static IDataReader Get(TransactionContext tc, EnumStatus status, ID payrollTypeID) { //return tc.ExecuteReader("SELECT * FROM OpiParameter WHERE Status= %n", status); if (status == EnumStatus.Regardless) return tc.ExecuteReader("SELECT * FROM OpiParameter Where PayrollTypeID=%n", payrollTypeID.Integer); else return tc.ExecuteReader("SELECT OpiParameter.* FROM OpiParameter, OpiItem Where OpiItem.OpiItemID=OpiParameter.OpiItemID AND OpiParameter.Status=%n AND OpiParameter.PayrollTypeID=%n", status, payrollTypeID.Integer); } internal static IDataReader Get(TransactionContext tc, EnumStatus status, EnumOpiType nType, ID payrollTypeID) { if (status == EnumStatus.Regardless) return tc.ExecuteReader("SELECT * FROM OpiParameter WHERE OpiType = %n AND PayrollTypeID=%n Order By OpiPeriodicity", nType, payrollTypeID.Integer); else return tc.ExecuteReader("SELECT * FROM OpiParameter WHERE OpiType = %n AND Status=%n AND PayrollTypeID=%n Order By OpiPeriodicity", nType, status, payrollTypeID.Integer); //return tc.ExecuteReader("SELECT OpiParameter.* FROM OpiParameter, OpiItem Where OpiItem.OpiItemID=OpiParameter.OpiItemID AND OpiParameter.Status=%n", status); } internal static IDataReader Get(TransactionContext tc, EnumStatus enumStatus, EnumOpiType enumOpiType, EnumEntitleType enumEntitleType, ID payrollTypeID) { if (enumStatus == EnumStatus.Regardless) return tc.ExecuteReader("SELECT * FROM OpiParameter WHERE OpiType = %n AND PayrollTypeID=%n AND EntitleType=%n Order By OpiPeriodicity", enumOpiType, payrollTypeID.Integer, enumEntitleType); else return tc.ExecuteReader("SELECT * FROM OpiParameter WHERE OpiType = %n AND Status=%n AND PayrollTypeID=%n AND EntitleType=%n Order By OpiPeriodicity", enumOpiType, enumStatus, payrollTypeID.Integer, enumEntitleType); //return tc.ExecuteReader("SELECT OpiParameter.* FROM OpiParameter, OpiItem Where OpiItem.OpiItemID=OpiParameter.OpiItemID AND OpiParameter.Status=%n", status); } internal static IDataReader Get(TransactionContext tc, EnumStatus enumStatus, EnumEntitleType enumEntitleType, ID payrollTypeID) { if (enumStatus == EnumStatus.Regardless) return tc.ExecuteReader("SELECT * FROM OpiParameter WHERE PayrollTypeID=%n AND EntitleType=%n Order By OpiPeriodicity", payrollTypeID.Integer, enumEntitleType); else return tc.ExecuteReader("SELECT * FROM OpiParameter WHERE Status=%n AND PayrollTypeID=%n AND EntitleType=%n Order By OpiPeriodicity", enumStatus, payrollTypeID.Integer, enumEntitleType); //return tc.ExecuteReader("SELECT OpiParameter.* FROM OpiParameter, OpiItem Where OpiItem.OpiItemID=OpiParameter.OpiItemID AND OpiParameter.Status=%n", status); } #endregion #region Delete function internal static void Delete(TransactionContext tc, ID nID, ID payrollTypeID) { tc.ExecuteNonQuery("DELETE FROM OpiParameterGrade WHERE OpiParameterID=%n AND PayrollTypeID=%n", nID.Integer, payrollTypeID.Integer); tc.ExecuteNonQuery("DELETE FROM OpiParameterIndividual WHERE OpiParameterID=%n AND PayrollTypeID=%n", nID.Integer, payrollTypeID.Integer); tc.ExecuteNonQuery("DELETE FROM OpiParameter WHERE OpiParameterID=%n AND PayrollTypeID=%n", nID.Integer, payrollTypeID.Integer); } internal static void DeleteGrades(TransactionContext tc, ID nOpiParameterID, ID payrollTypeID) { tc.ExecuteNonQuery("DELETE FROM OpiParameterGrade WHERE OpiParameterID=%n AND PayrollTypeID=%n", nOpiParameterID.Integer, payrollTypeID.Integer); } #endregion internal static IDataReader GetGrades(TransactionContext tc, ID payrollTypeID) { string sql = SQLParser.MakeSQL(@"Select * from OpiParameterGrade Where opiitemid=%n", payrollTypeID.Integer); return tc.ExecuteReader(sql); } } #endregion }