using System; using System.Collections.Generic; using System.Linq; using System.Text; using Ease.CoreV35.DataAccess; using System.Data; using System.Data.SqlClient; using HRM.BO; using Ease.Core.DataAccess; namespace HRM.DA { internal class BadliDailyPaymentDA { #region Constructor private BadliDailyPaymentDA() { } #endregion #region Insert function internal static void Insert(TransactionContext tc, BadliDailyPayment item) { tc.ExecuteNonQuery( "INSERT INTO BadliPayment(BadliPaymentID, ItemID, ItemType, Description, Amount, ChangedAmount, PaidDate, BADLIDAILYRECRUITID, CreatedBy, CreationDate, BadliProcessID)" + " VALUES(%n, %n, %n, %s, %n, %n, %d, %n, %n, %d, %n)", item.ID, item.ItemID, item.ItemType, item.Description, item.Amount, item.ChangedAmount, item.PaidDate, item.BadliRecruitID, item.CreatedBy, item.CreatedDate, item.BadliProcessID); } #endregion #region Update function internal static void Update(TransactionContext tc, BadliDailyPayment item) { tc.ExecuteNonQuery( "UPDATE BadliPayment SET ItemID=%n, ItemType=%n, Description=%s, Amount=%n, ChangedAmount=%n, PaidDate=%d, BADLIDAILYRECRUITID=%n, MODIFIEDBY=%n, MODIFIEDDATE=%d, BadliProcessID=%n " + " WHERE BadliPaymentID=%n", item.ItemID, item.ItemType, item.Description, item.Amount, item.ChangedAmount, item.PaidDate, item.BadliRecruitID, item.ModifiedBy, item.ModifiedDate, item.BadliProcessID, item.ID); } #endregion #region Get internal static IDataReader Get(TransactionContext tc) { return tc.ExecuteReader("SELECT * FROM BadliPayment"); } internal static IDataReader Get(TransactionContext tc, DateTime paidDate) { return tc.ExecuteReader("SELECT * FROM BadliPayment where PaidDate=%d", paidDate); } internal static IDataReader Get(TransactionContext tc, int employeeID, DateTime paidDate) { return tc.ExecuteReader("SELECT * FROM BadliPayment where EmployeeID=%n AND PaidDate=%d", employeeID, paidDate); } internal static IDataReader Get(TransactionContext tc, int badliRecruitId) { return tc.ExecuteReader("SELECT * FROM BadliPayment Where BADLIDAILYRECRUITID = %n", badliRecruitId); } internal static IDataReader Get(TransactionContext tc, DateTime fromdate, DateTime todate, string badliRecruitIds) { return tc.ExecuteReader( "SELECT * FROM BadliPayment Where BADLIDAILYRECRUITID in (%q) and PaidDate Between %d and %d ", badliRecruitIds, fromdate, todate); } internal static DataSet GetBadliWeeklyPaymentSheet(TransactionContext tc, string ids, DateTime fromdate, DateTime todate) { DataSet dSet = new DataSet(); try { DateTime paymentDate = todate.AddDays(1); string sSQL = SQLParser.MakeSQL( @"SELECT row_number() OVER (ORDER BY e.EMPLOYEENO) Serial, %d paymentdate, e.employeeno, e.NAME, e.ACCOUNTNO, SUM(bp.CHANGEDAMOUNT) Amount FROM BADLIDAILYRECRUIT br INNER JOIN EMPLOYEE e ON e.EMPLOYEEID = br.EMPLOYEEID INNER JOIN BADLIPAYMENT bp ON bp.BADLIDAILYRECRUITID = br.BADLIDAILYRECRUITID WHERE br.ENTRYDATE BETWEEN %d AND %d AND br.EmployeeID in (%q) GROUP BY e.EMPLOYEENO, e.NAME, e.ACCOUNTNO ORDER BY e.EMPLOYEENO, e.ACCOUNTNO, Amount, paymentdate", paymentDate, fromdate, todate, ids); dSet = tc.ExecuteDataSet(sSQL); } catch (Exception ex) { throw new Exception(ex.Message); } return dSet; } internal static IDataReader Get(TransactionContext tc, DateTime fromdate, DateTime todate) { return tc.ExecuteReader("SELECT * FROM BadliPayment Where PaidDate Between %d and %d ", fromdate, todate); } internal static IDataReader Get(TransactionContext tc, DateTime paidDate, string badliRecruitIds) { return tc.ExecuteReader("SELECT * FROM BadliPayment Where BADLIDAILYRECRUITID in (%q) and PaidDate = %d", badliRecruitIds, paidDate); } public static bool IsExist(TransactionContext tc, int badliRecruitId, int itemId, enumPayrollComponentType itemType, DateTime paymentDate) { bool Exist = false; Object obj = tc.ExecuteScalar( "Select COUNT (*) FROM BadliPayment WHERE BADLIDAILYRECRUITID=%n AND ItemID=%n AND ItemType=%n AND PaidDate=%d", badliRecruitId, itemId, itemType, paymentDate); Exist = Convert.ToInt32(obj) > 0 ? true : false; return Exist; } public static void Delete(TransactionContext tc, BadliDailyPayment oItem) { tc.ExecuteNonQuery( "Delete from BadliPayment Where BADLIDAILYRECRUITID=%n AND ItemID=%n AND ItemType=%n AND PaidDate=%d", oItem.BadliRecruitID, oItem.ItemID, oItem.ItemType, oItem.PaidDate); } #endregion } }