using HRM.BO; using Ease.Core.DataAccess; using System; using System.Data; namespace HRM.DA { #region LeaveException public class LeaveExceptionDA { #region Constructor public LeaveExceptionDA() { } #endregion #region Insert function public static void Insert(TransactionContext tc, LeaveException oItem) { tc.ExecuteNonQuery( "INSERT INTO LeaveException(EmployeeID, StartDate, EndDate, LeaveID, OpeningBalance, MaxDays, CFDays)" + " VALUES(%n, %d, %d,%n,%n,%n,%n)", oItem.EmployeeID, oItem.StartDate, oItem.EndDate, oItem.LeaveID, oItem.OpeningBalance, oItem.MaxDays, oItem.CFDays); } #endregion #region Get Function internal static IDataReader Get(TransactionContext tc) { return tc.ExecuteReader(@"SELECT * FROM LeaveException le Order By le.StartDate"); } internal static IDataReader Get2(TransactionContext tc, DateTime dFrom, DateTime dTo) { string sql = SQLParser.MakeSQL(@"SELECT * FROM LeaveException le,employee emp WHERE emp.EMPLOYEEID=le.EmployeeID AND (startdate>=%d AND Enddate<=%d) Order By emp.EMPLOYEENO,le.StartDate", dFrom, dTo); return tc.ExecuteReader(sql); } internal static IDataReader GetByEmpID(TransactionContext tc, int nLeaveID, int nEmpID) { return tc.ExecuteReader(@"SELECT * FROM LeaveException where LeaveExceptionid IN( SELECT MAX(LeaveExceptionid) FROM LeaveException where employeeid=%n AND leaveid=%n GROUP BY employeeid) AND employeeid=%n AND leaveid=%n", nEmpID, nLeaveID, nEmpID, nLeaveID); } #endregion #region Delete function public static void DeleteItem(TransactionContext tc, int nID) { tc.ExecuteNonQuery("DELETE FROM LeaveException WHERE LeaveExceptionID=%n", nID); } public static void Delete(TransactionContext tc, int nEmployeeID) { tc.ExecuteNonQuery("DELETE FROM LeaveException WHERE EmployeeID=%n ", nEmployeeID); } #endregion } #endregion }