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 BonusDA internal class BonusDA { #region Constructor private BonusDA() { } #endregion #region Insert function internal static void Insert(TransactionContext tc, Bonus item) { tc.ExecuteNonQuery("INSERT INTO Bonus(BonusID, code, name, CreatedBy, CreatedDate, SequenceNo, Status)" + " VALUES(%n, %s, %s, %n, %d, %n, %n)", item.ID.Integer, item.Code, item.Name, item.CreatedBy.Integer, item.CreatedDate, item.Sequence, item.Status); } #endregion #region Update function internal static void Update(TransactionContext tc, Bonus item) { tc.ExecuteNonQuery("UPDATE Bonus SET code=%s, name=%s, ModifiedBy=%n, ModifiedDate=%d, SequenceNo=%n, Status=%n" + " WHERE BonusID=%n", item.Code, item.Name, item.ModifiedBy.Integer, item.ModifiedDate, item.Sequence, item.Status, item.ID.Integer); } #endregion #region Get Function internal static IDataReader Get(TransactionContext tc,EnumStatus status) { if (EnumStatus.Active == status || EnumStatus.Inactive == status) { return tc.ExecuteReader("SELECT * FROM Bonus where Status=%n Order By SequenceNo", status); } else { return tc.ExecuteReader("SELECT * FROM Bonus Order By SequenceNo"); } } internal static IDataReader Get(TransactionContext tc, ID nID) { return tc.ExecuteReader("SELECT * FROM Bonus WHERE BonusID=%n", nID.Integer); } internal static DataSet GetOldBonus(TransactionContext tc, int payrollTypeID) { return tc.ExecuteDataSet("SELECT * FROM GP_BonusParamDatam WHERE PAYROLLTYPEID=%n ORDER BY BonusName", payrollTypeID); } internal static IDataReader GetActiveProccessedBonus(TransactionContext tc, int payrollTypeID, DateTime bonusMonth) { string sql = SQLParser.MakeSQL("SELECT B.*, BP.Bonusmonth FROM BONUS B INNER JOIN BONUSPROCESS BP ON BP.BONUSID = B.BONUSID Where B.Status=%n AND BP.BONUSMONTH=%d AND BP.PAYROLLTYPEID=%n Order by Name", EnumStatus.Active, bonusMonth, payrollTypeID); return tc.ExecuteReader(sql); } internal static DataSet GetOldActiveProccessedBonus(TransactionContext tc, int payrollTypeID, DateTime bonusMonth) { string sql = SQLParser.MakeSQL("SELECT B.*, BP.PAYDATE FROM GP_BonusParamDatam B INNER JOIN GP_BonusPayDetail BP ON BP.BONUSID = B.BONUSID Where BP.PAYDATE=%d AND B.PAYROLLTYPEID=%n Order by B.BONUSNAME", bonusMonth, payrollTypeID); return tc.ExecuteDataSet(sql); } #endregion #region Delete function internal static void Delete(TransactionContext tc, ID nID) { tc.ExecuteNonQuery("DELETE FROM [Bonus] WHERE BonusID=%n", nID.Integer); } #endregion } #endregion }