EchoTex_Payroll/HRM.DA/DA/Attendance/ShiftTermDA.cs

109 lines
3.9 KiB
C#
Raw Normal View History

2024-10-14 10:01:49 +06:00
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Ease.CoreV35.DataAccess;
using System.Data;
using HRM.BO;
using Ease.Core.DataAccess;
namespace HRM.DA
{
#region ShiftTermDA
internal class ShiftTermDA
{
#region Constructor
private ShiftTermDA()
{
}
#endregion
#region Insert function
internal static void Insert(TransactionContext tc, ShiftTerm item)
{
tc.ExecuteNonQuery(
"INSERT INTO ShiftTerm(ShiftTermID, ShiftID, WeekendTermID, HolidayTermID, CreatedBy, CreatedDate)" +
" VALUES(%n, %n, %n, %n, %n, %d)", item.ID, item.ShiftID, item.WeekendTermID, item.HolidayTermID,
item.CreatedBy, item.CreatedDate);
}
#endregion
#region Update function
internal static void Update(TransactionContext tc, ShiftTerm item)
{
tc.ExecuteNonQuery(
"UPDATE ShiftTerm SET ShiftID=%n, WeekendTermID=%n, HolidayTermID=%n, ModifiedBy=%n, ModifiedDate=%d" +
" WHERE ShiftTermID=%n", item.ShiftID, item.WeekendTermID, item.HolidayTermID, item.ModifiedBy,
item.ModifiedDate, item.ID);
}
#endregion
#region Get Function
internal static IDataReader Get(TransactionContext tc)
{
return tc.ExecuteReader("SELECT * FROM ShiftTerm");
}
internal static IDataReader Get(TransactionContext tc, int nID)
{
return tc.ExecuteReader("SELECT * FROM ShiftTerm WHERE ShiftTermID=%n", nID);
}
internal static IDataReader GetByShiftID(TransactionContext tc, int shiftID)
{
return tc.ExecuteReader("SELECT * FROM ShiftTerm WHERE ShiftID=%n", shiftID);
}
internal static DataSet GetEmpOT(TransactionContext tc, DateTime date, int termID)
{
DataSet empOT = new DataSet();
try
{
//string sql = SQLParser.MakeSQL("select d.EmployeeID, "
// + "((sum (floor(d.OTHour))+ floor(((sum (d.OTHour-floor(d.OTHour)))*100)/60)) + cast(((cast(((sum(d.OTHour-floor(d.OTHour)))*100) AS INT))*(60/100)) AS FLOAT)/100) TotalOT "
// + "from DailyAttnProcess d "
// + "where d.ShiftID in (select distinct shiftID from ShiftTerm st, ShiftTermDetail std, Term t "
// + "where st.ShiftTermID=std.ShiftTermID and std.TermID=t.TermID and t.TermID=%n) "
// + "and d.AttnDate between %d and %d "
// + "Group By d.EmployeeID", termID,
// GlobalFunctions.FirstDateOfMonth(date), GlobalFunctions.LastDateOfMonth(date));
string sql = SQLParser.MakeSQL(@"select d.EmployeeID, sum (ISNULL(d.OTHour,0)) AS TotalOT
from DailyAttnProcess d where d.ShiftID in(select distinct shiftID from ShiftTerm st, ShiftTermDetail std, Term t
where st.ShiftTermID=std.ShiftTermID and std.TermID=t.TermID and t.TermID=%n)
and d.AttnDate between %d and %d
Group By d.EmployeeID", termID, GlobalFunctions.FirstDateOfMonth(date), GlobalFunctions.LastDateOfMonth(date));
empOT = tc.ExecuteDataSet(sql);
}
catch (Exception ex)
{
throw new Exception(ex.Message);
}
return empOT;
}
#endregion
#region Delete function
internal static void Delete(TransactionContext tc, int nID)
{
tc.ExecuteNonQuery("DELETE FROM ShiftTerm WHERE ShiftTermID=%n", nID);
}
#endregion
}
#endregion
}