using HRM.BO; using Ease.Core.DataAccess; using System; using System.Data; namespace HRM.DA { internal class RecognitionDA { #region Constructor private RecognitionDA() { } #endregion #region Recognition Methods internal static IDataReader Get(TransactionContext tc, int recognitionID) { return tc.ExecuteReader("SELECT * FROM Recognitions WHERE RecognitionID=%n", recognitionID); } internal static IDataReader Get(TransactionContext tc) { return tc.ExecuteReader("SELECT * FROM Recognitions"); } internal static void Insert(TransactionContext tc, Recognition item) { string sql = SQLParser.MakeSQL( @"INSERT INTO Recognitions(RecognitionID, NominateBy, NominateDate, Justification, SalaryMonth, IsCash, WfStatus, RequestType, CreatedBy, CreatedDate) VALUES(%n, %n, %d, %s, %d, %n, %n, %n, %n, %d)", item.ID, item.NominateBy, item.NominateDate, item.Justification, item.SalaryMonth, item.IsCash, item.WfStatus, item.RequestType, DataReader.GetNullValue(item.CreatedBy), DataReader.GetNullValue(item.CreatedDate)); tc.ExecuteNonQuery(sql); } internal static void Update(TransactionContext tc, Recognition item) { tc.ExecuteNonQuery( "UPDATE Recognitions SET NominateBy=%n, NominateDate=%d, Justification=%s, SalaryMonth=%d, IsCash=%b, WfStatus=%n, RequestType=%n, ModifiedBy=%n, ModifiedDate=%d" + " WHERE RecognitionID=%n", item.NominateBy, item.NominateDate, item.Justification, item.SalaryMonth, item.IsCash, item.WfStatus, item.RequestType, DataReader.GetNullValue(item.ModifiedBy), DataReader.GetNullValue(item.ModifiedDate), item.ID); } internal static void Delete(TransactionContext tc, int recognitionID) { tc.ExecuteNonQuery("DELETE FROM Recognitions WHERE RecognitionID=%n", recognitionID); } #endregion #region RecognitionDetail Methods internal static IDataReader GetRecognitionDetails(TransactionContext tc, int recognitionID) { return tc.ExecuteReader("SELECT * FROM RecognitionDetails WHERE RecognitionID=%n", recognitionID); } internal static IDataReader GetRecognitionDetails(TransactionContext tc, EnumwfStatus enumwfStatus, DateTime fromDate, DateTime toDate, bool p) { return tc.ExecuteReader( "SELECT * FROM RecognitionDetails WHERE RecognitionID in (select RecognitionID from Recognitions where WFSTATUS=%n) AND RequestDate >= %d AND RequestDate <= %d ", (int)enumwfStatus, fromDate, toDate); } internal static void InsertRecognitionDetail(TransactionContext tc, RecognitionDetail item) { tc.ExecuteNonQuery( "INSERT INTO RecognitionDetails(RecognitionDetailID, RecognitionID, EmployeeID, Amount,SalaryMonth,RequestDate)" + " VALUES(%n, %n, %n, %n,%d,%d)", item.ID, item.RecognitionID, item.EmployeeID, item.Amount, item.SalaryMonth, item.RequestDate); } internal static void UpdateRecognitionDetail(TransactionContext tc, RecognitionDetail item) { tc.ExecuteNonQuery( "UPDATE RecognitionDetails SET RecognitionID=%n, EmployeeID=%n, Amount=%n, ModifiedBy=%n, ModifiedDate=%d, SalaryMonth=%d,PaidDate=%d " + " WHERE RecognitionDetailID=%n", item.RecognitionID, item.EmployeeID, item.Amount, DataReader.GetNullValue(item.ModifiedBy), DataReader.GetNullValue(item.ModifiedDate), DataReader.GetNullValue(item.SalaryMonth), DataReader.GetNullValue(item.PaidDate), item.ID); } internal static void UpdatePaidDate(TransactionContext tc, RecognitionDetail item) { string sql = SQLParser.MakeSQL(@"Update RecognitionDetails Set PaidDate=%d Where RecognitionDetailID = %n", DataReader.GetNullValue(item.PaidDate), item.ID); tc.ExecuteNonQuery(sql); } internal static void DeleteRecognitionDetail(TransactionContext tc, int recognitionID) { tc.ExecuteNonQuery("DELETE FROM RecognitionDetails WHERE RecognitionID=%n", recognitionID); } #endregion internal static IDataReader GetRecognitionDetails(TransactionContext tc, EnumwfStatus enumwfStatus, bool p) { throw new NotImplementedException(); } } }