using HRM.BO; using Ease.Core.DataAccess; using System; using System.Data; namespace HRM.DA { #region EmployeeOverTimeDA internal class EmployeeOverTimeDA { #region Constructor private EmployeeOverTimeDA() { } #endregion #region Insert function internal static void Insert(TransactionContext tc, EmployeeOverTime item) { tc.ExecuteNonQuery( "INSERT INTO EMPOVERTIME(TermID,TermParameterID,employeeID, monthDate, OTHours, amount, CreatedBy, CreationDate,OTMonth,EMPOVERTIMEID,PayrollTypeID)" + " VALUES(%n, %n, %n, %d, %n, %n, %n, %d, %d, %n,%n)", item.TermID, item.TermParameterID, item.EmployeeID, item.MonthDate, item.OTHours, item.Value, item.CreatedBy, item.CreatedDate, item.OTMonth, item.ID, item.PayrollTypeID); } #endregion #region Update function internal static void Update(TransactionContext tc, EmployeeOverTime item) { tc.ExecuteNonQuery( "UPDATE EMPOVERTIME SET TermID=%n, TermParameterID=%n, MonthDate=%d, OTHours=%n, Amount=%n, ModifiedBy=%n, ModifiedDate=%d,OTMonth=%d,PayrollTypeID=%n" + " WHERE EmpOverTimeID=%n", item.TermID, item.TermParameterID, item.MonthDate, item.OTHours, item.Value, item.ModifiedBy, item.ModifiedDate, item.OTMonth, item.PayrollTypeID, item.ID); } #endregion #region Get Function internal static IDataReader Get(TransactionContext tc) { return tc.ExecuteReader("SELECT * FROM EmployeeOverTime"); } internal static IDataReader GetByEmpID(TransactionContext tc, int nEmpID, DateTime dMonthDate) { return tc.ExecuteReader( "SELECT * FROM EMPOVERTIME Where MonthDate=%d AND EmployeeID=%n Order By EmployeeID, OTMonth, TermParameterID", dMonthDate, nEmpID); } internal static IDataReader GetEmpOvertimeByOTMonth(TransactionContext tc, int nEmpID, DateTime dOTMonth, int TermID, int TermParameterID) { string sql = SQLParser.MakeSQL( "SELECT * FROM EMPOVERTIME Where EmployeeID=%n AND OTMonth=%d AND TermID=%n AND TermParameterID=%n Order By EmployeeID, OTMonth, TermParameterID", nEmpID, dOTMonth, TermID, TermParameterID); return tc.ExecuteReader(sql); } internal static IDataReader Get(TransactionContext tc, int nID) { return tc.ExecuteReader("SELECT * FROM EMPOVERTIME WHERE EMPOVERTIMEID=%n", nID); } internal static IDataReader Get(TransactionContext tc, DateTime dSalaryMonth, int nPayrollTypeID) { return tc.ExecuteReader("SELECT * FROM EMPOVERTIME WHERE MonthDate=%d AND PayrollTypeID=%n", dSalaryMonth, nPayrollTypeID); } #endregion #region Delete function //internal static void Delete(TransactionContext tc, int nID) //{ // tc.ExecuteNonQuery("DELETE FROM [EMPOVERTIME] WHERE EmployeeID=%n", nID); //} internal static void DeleteByMonth(TransactionContext tc, DateTime dOTMonth) { tc.ExecuteNonQuery("DELETE FROM EMPOVERTIME WHERE MonthDate=%d", dOTMonth); } internal static void DeleteByEmpID(TransactionContext tc, int nEmpID, DateTime dMonthDate) { tc.ExecuteNonQuery("DELETE FROM EMPOVERTIME WHERE EmployeeID=%n and MonthDate=%d", nEmpID, dMonthDate); } internal static void Delete(TransactionContext tc, int id) { tc.ExecuteNonQuery("DELETE FROM EMPOVERTIME WHERE EMPOVERTIMEID=%n", id ); } #endregion #region Other function public static bool IsExist(TransactionContext tc, int empId, int termId, DateTime sMonth) { bool Exist = false; Object obj = tc.ExecuteScalar( "Select COUNT (*) FROM EMPOVERTIME WHERE EMPLOYEEID=%n AND TermID=%n AND MONTHDATE= %d", empId, termId, sMonth); Exist = Convert.ToInt32(obj) > 0 ? true : false; return Exist; } #endregion } #endregion }