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 BadliProcessDA { #region Constructor private BadliProcessDA() { } #endregion #region Insert function internal static void Insert(TransactionContext tc, BadliProcess item) { tc.ExecuteNonQuery( "INSERT INTO BadliProcess(BadliProcessID, FromDate, ToDate, ProcessDate, Description, ProcessCode, CreatedBy, CreationDate, WorkPlanGroupID)" + " VALUES(%n, %d, %d, %d, %s, %s, %n, %d, %n)", item.ID, item.FromDate, item.ToDate, item.ProcessDate, item.Description, item.ProcessCode, item.CreatedBy, item.CreatedDate, item.WorkPlanGroupID); } #endregion #region Update function internal static void Update(TransactionContext tc, BadliProcess item) { tc.ExecuteNonQuery( "UPDATE BadliProcess SET FromDate=%d, ToDate=%d, EmployeeID=%n, ProcessDate=%d, Description=%s, ProcessCode=%s, MODIFIEDBY=%n, MODIFIEDDATE=%d, WorkPlanGroupID=%n" + " WHERE BadliDailyRecruitID=%n", item.FromDate, item.ToDate, item.EmployeeID, item.ProcessDate, item.Description, item.ProcessCode, item.ModifiedBy, item.ModifiedDate, item.WorkPlanGroupID, item.ID); } #endregion #region Get Function internal static IDataReader Get(TransactionContext tc) { return tc.ExecuteReader("SELECT * FROM BadliProcess"); } internal static IDataReader Get(TransactionContext tc, DateTime processDate) { return tc.ExecuteReader("SELECT * FROM BadliProcess Where FROMDATE=%d", processDate); } internal static IDataReader GetLastProcessDate(TransactionContext tc) { try { string sql = SQLParser.MakeSQL("SELECT MAX(bp.FROMDATE+1) LastProcessDate FROM BADLIPROCESS bp"); return tc.ExecuteReader(sql); } catch (Exception ex) { throw new Exception(ex.Message); } } internal static IDataReader Get(TransactionContext tc, DateTime processDate, int WorkPlanGroupID) { return tc.ExecuteReader("SELECT * FROM BadliProcess Where FromDate=%d AND WorkPlanGroupID=%n", processDate, WorkPlanGroupID); } internal static IDataReader Get(TransactionContext tc, DateTime fromdate, DateTime toDate) { return tc.ExecuteReader("SELECT * FROM BadliProcess Where FromDate>=%d AND ToDate<=%d", fromdate, toDate); } internal static IDataReader Get(TransactionContext tc, DateTime fromdate, DateTime toDate, int WorkPlanGroupID) { return tc.ExecuteReader( "SELECT * FROM BadliProcess Where FromDate>=%d AND ToDate<=%d AND WorkPlanGroupID=%n", fromdate, toDate, WorkPlanGroupID); } internal static IDataReader Get(TransactionContext tc, int WorkPlanGroupID) { return tc.ExecuteReader("SELECT * FROM BadliProcess WHERE WorkPlanGroupID=%n", WorkPlanGroupID); } internal static IDataReader Get(TransactionContext tc, string WorkPlanGroupIDs) { return tc.ExecuteReader("SELECT * FROM BadliProcess WHERE WorkPlanGroupID in (%q)", WorkPlanGroupIDs); } internal static void Delete(TransactionContext tc, int workPlanGroupID, DateTime entryDate) { tc.ExecuteNonQuery("DELETE FROM BadliProcess WHERE WorkplanGroupID=%n AND fromDate=%d", workPlanGroupID, entryDate); } internal static bool IsExist(TransactionContext tc, int workPlanGroupID, DateTime processDate) { bool Exist = false; Object obj = tc.ExecuteScalar("Select COUNT (*) FROM BadliProcess WHERE WorkplanGroupID=%n AND fromDate=%d", workPlanGroupID, processDate); Exist = Convert.ToInt32(obj) > 0 ? true : false; return Exist; } #endregion } }