using System; using System.Collections.Generic; using System.Linq; using System.Text; using Ease.CoreV35.DataAccess; using System.Data; using Ease.CoreV35.Model; using Payroll.BO; namespace Payroll.Service { #region UPDAttendanceDA internal class UPDAttendanceDA { #region Constructor private UPDAttendanceDA() { } #endregion #region Insert function internal static void Insert(TransactionContext tc, UPDAttendance item) { string sql = SQLParser.MakeSQL("INSERT INTO UPDAttendance(AttendanceID ,EmployeeID ,EmployeeNo ,AttnDate,InTime ,OutTime ,UpdStatus ,ChangeStatus ,EmpRemarks ,LMRemarks ,EmpRemarksDate ,LMRemarksDate )" + " VALUES(%n, %s, %D, %D, %D, %n, %n, %s, %s, %D, %D)", item.ID.Integer, item.EmployeeID.Integer, item.EmployeeNo, item.AttnDate, item.InTime, item.OutTime, item.UpdStatus, item.ChangeStatus, item.EmpRemarks, item.LMRemarks,DataReader.GetNullValue(item.EmpRemarksDate),DataReader.GetNullValue(item.LMRemarksDate)); tc.ExecuteNonQuery(sql); } #endregion #region Update function internal static void Update(TransactionContext tc, UPDAttendance item) { tc.ExecuteNonQuery("UPDATE UPDAttendance SET EmployeeID=%n ,EmployeeNo=%s ,AttnDate=%D,InTime=%D ,OutTime=%D ,UpdStatus=%n ,ChangeStatus=%n ,EmpRemarks=%s ,LMRemarks=%s ,EmpRemarksDate=%D ,LMRemarksDate=%D,LMID=%n,HRID=%n,HRRemarks=%s WHERE AttendanceID=%n", item.EmployeeID.Integer, item.EmployeeNo, item.AttnDate, item.InTime, item.OutTime, item.UpdStatus, item.ChangeStatus, item.EmpRemarks, item.LMRemarks, DataReader.GetNullValue(item.EmpRemarksDate), DataReader.GetNullValue(item.LMRemarksDate), DataReader.GetNullValue(item.LMID, IDType.Integer), DataReader.GetNullValue(item.HRID, IDType.Integer), item.HRRemarks, item.ID.Integer); } #endregion #region Get Function internal static IDataReader Get(TransactionContext tc, DateTime dt,EnumUPDStatus eType) { if(eType==EnumUPDStatus.None) return tc.ExecuteReader("SELECT * FROM UPDAttendance where Month(AttnDate)=%n AND Year(AttnDate)=%n AND Day(AttnDate)=%n",dt.Month,dt.Year,dt.Day); else return tc.ExecuteReader("SELECT * FROM UPDAttendance where UpdStatus=%n AND Month(AttnDate)=%n AND Year(AttnDate)=%n AND Day(AttnDate)=%n", eType, dt.Month, dt.Year, dt.Day); } internal static IDataReader Get(TransactionContext tc, DateTime dtFrom, DateTime dtTo, int EmpID, EnumUPDStatus eType) { if (eType == EnumUPDStatus.None) return tc.ExecuteReader("SELECT * FROM UPDAttendance Where EmployeeID=%n And attndate between dateadd(d, datediff(d, 0, %d), 0) AND DATEADD(day, DATEDIFF(day, 0 , %d), '23:59') ORDER BY attndate", EmpID, dtFrom, dtTo); else return tc.ExecuteReader("SELECT * FROM UPDAttendance Where UpdStatus=%n AND EmployeeID=%n And attndate between dateadd(d, datediff(d, 0, %d), 0) AND DATEADD(day, DATEDIFF(day, 0 , %d), '23:59') ORDER BY attndate", eType, EmpID, dtFrom, dtTo); } internal static IDataReader Get(TransactionContext tc, DateTime dtFrom, DateTime dtTo, EnumUPDStatus eType) { if (eType == EnumUPDStatus.None) return tc.ExecuteReader("SELECT * FROM UPDAttendance Where attndate between dateadd(d, datediff(d, 0, %d), 0) AND DATEADD(day, DATEDIFF(day, 0 , %d), '23:59')", dtFrom, dtTo); else return tc.ExecuteReader("SELECT * FROM UPDAttendance Where UpdStatus=%n AND attndate between dateadd(d, datediff(d, 0, %d), 0) AND DATEADD(day, DATEDIFF(day, 0 , %d), '23:59')", eType, dtFrom, dtTo); } internal static IDataReader Get(TransactionContext tc, ID nID) { return tc.ExecuteReader("SELECT * FROM UPDAttendance WHERE AttendanceID=%n", nID.Integer); } #endregion #region Delete function internal static void Delete(TransactionContext tc, ID nID) { tc.ExecuteNonQuery("DELETE FROM [UPDAttendance] WHERE AttendanceID=%n", nID.Integer); } #endregion } #endregion }