using Ease.Core.DataAccess; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using HRM.BO; using System.Data; using static HRM.BO.SettlmentAdvice; namespace HRM.DA { #region SettlmentAdvice public class SettlmentAdviceDA { #region Constructor public SettlmentAdviceDA() { } #endregion #region Insert function public static void Insert(TransactionContext tc, SettlmentAdvice item) { string sql = SQLParser.MakeSQL(@" INSERT INTO SettlmentAdvice(SettlementAdviceID, SettlmentAdviceStatus, TranDate, PaymentDate, CreatedBy, CreatedDate) VALUES(%n, %n, %d, %d, %n, %d)", item.ID, (int)item.SettlmentAdviceStatus, item.TranDate, item.PaymentDate, item.CreatedBy, item.CreatedDate); tc.ExecuteNonQuery(sql); } #endregion #region Update function public static void Update(TransactionContext tc, SettlmentAdvice item) { string sql = SQLParser.MakeSQL(@" UPDATE SettlmentAdvice SET SettlmentAdviceStatus=%n, TranDate=%d, PaymentDate=%d, ModifiedBy=%n, ModifiedDate=%d) WHERE SettlementAdviceID=%n", (int)item.SettlmentAdviceStatus, item.TranDate, item.PaymentDate, item.CreatedBy, item.CreatedDate, item.ID); tc.ExecuteNonQuery(sql); } public static void UpdateItem(TransactionContext tc, int settlementClearanceID, int ResignationID) { string sql = SQLParser.MakeSQL(@" UPDATE EmpResignationRequest SET SettlementAdviceID=%n WHERE ResignationRequestId=%n", settlementClearanceID, ResignationID); tc.ExecuteNonQuery(sql); } public static void InsertAdviceItem(TransactionContext tc, SettlmentAdviceItem item) { string sql = SQLParser.MakeSQL(@" INSERT INTO SettlmentAdviceItem(SettlmentAdviceID, EmpResignID) VALUES(%n, %n)", item.SettlmentAdviceID, item.EmpResignID); tc.ExecuteNonQuery(sql); } internal static IDataReader Get(TransactionContext tc) { return tc.ExecuteReader("SELECT * FROM SettlmentAdvice"); } internal static IDataReader Get(TransactionContext tc, int id) { string sql = SQLParser.MakeSQL(@" SELECT * FROM SettlmentAdvice WHERE SettlmentAdviceID = %n", id); return tc.ExecuteReader(sql); } internal static void Delete(TransactionContext tc, int id) { string sql = SQLParser.MakeSQL(@" DELETE SettlmentAdvice WHERE SettlmentAdviceID = %n", id); tc.ExecuteNonQuery(sql); } internal static IDataReader GetByStatus(TransactionContext tc, EnumSettlmentAdviceStatus saStatus) { string sql = SQLParser.MakeSQL(@" SELECT * FROM SettlmentAdvice WHERE SettlmentAdvice = %n", saStatus); return tc.ExecuteReader(sql); } internal static IDataReader GetByTranDate(TransactionContext tc, DateTime tranDate) { string sql = SQLParser.MakeSQL(@" SELECT * FROM SettlmentAdvice WHERE TranDate = %d", tranDate); return tc.ExecuteReader(sql); } internal static IDataReader Get(TransactionContext tc, DateTime fromTranDate, DateTime toTranDate) { string sql = SQLParser.MakeSQL(@" SELECT * FROM SettlmentAdvice WHERE TranDate BETWEEN %d AND %d", fromTranDate, toTranDate); return tc.ExecuteReader(sql); } internal static IDataReader GetDetail(TransactionContext tc, DateTime fromTranDate, DateTime toTranDate) { string sql = SQLParser.MakeSQL(@" SELECT sa.SettlementAdviceID , e.EmpResignID FROM SettlmentAdvice sa , SettlmentAdviceItem e where sa.SettlementAdviceID = e.SettlmentAdviceID and sa.TranDate BETWEEN %d AND %d", fromTranDate, toTranDate); return tc.ExecuteReader(sql); } internal static IDataReader GetByPaymentDate(TransactionContext tc, DateTime paymentDate) { string sql = SQLParser.MakeSQL(@" SELECT * FROM SettlmentAdvice WHERE PaymentDate = %d", paymentDate); return tc.ExecuteReader(sql); } internal static IDataReader GetByPaymentDateRange(TransactionContext tc, DateTime fromPaymentDate, DateTime toPaymentDate) { string sql = SQLParser.MakeSQL(@" SELECT * FROM SettlmentAdvice WHERE PaymentDate BETWEEN %d AND %d", fromPaymentDate, toPaymentDate); return tc.ExecuteReader(sql); } internal static void DeleteByAdviceId(int oID, TransactionContext tc) { string sql = SQLParser.MakeSQL(@"Delete From SettlmentAdviceItem Where SettlmentAdviceID = %n", oID); tc.ExecuteNonQuery(sql); } #endregion } #endregion }