EchoTex_Payroll/HRM.DA/DA/Attendance/EmployeeOutsideDutyDA.cs

124 lines
4.1 KiB
C#
Raw Permalink 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 EmployeeOutsideDutyDA
internal class EmployeeOutsideDutyDA
{
#region Constructor
private EmployeeOutsideDutyDA()
{
}
#endregion
#region Insert function
internal static void Insert(TransactionContext tc, EmployeeOutsideDuty item)
{
tc.ExecuteNonQuery(
"INSERT INTO EmployeeOutsideDuty(EmployeeOutsideDutyID, EmployeeID, ShiftID, EntryDate, StartDate, EndDate, Comments, OutsideDutyID, CreatedBy, CreatedDate)" +
" VALUES(%n, %n, %n, %d, %d, %d, %s, %n, %n, %d)", item.ID, item.EmployeeID, 1, item.EntryDate, item.StartDate,
item.EndDate, item.Comments, item.OutsideDutyID, item.CreatedBy, item.CreatedDate);
}
#endregion
#region Update function
internal static void Update(TransactionContext tc, EmployeeOutsideDuty item)
{
tc.ExecuteNonQuery(
"UPDATE EmployeeOutsideDuty SET EmployeeID=%n, EntryDate=%d, StartDate=%D, EndDate=%D, Comments=%s, OutsideDutyID=%n, ModifiedBy=%n, ModifiedDate=%d" +
" WHERE EmployeeOutsideDutyID=%n", item.EmployeeID, item.EntryDate, item.StartDate, item.EndDate,
item.Comments, item.OutsideDutyID, item.ModifiedBy, item.ModifiedDate, item.ID);
}
#endregion
#region Get Function
internal static IDataReader Get(TransactionContext tc)
{
return tc.ExecuteReader("SELECT * FROM EmployeeOutsideDuty");
}
internal static IDataReader Get(TransactionContext tc, int nID)
{
return tc.ExecuteReader("SELECT * FROM EmployeeOutsideDuty WHERE EmployeeOutsideDutyID=%n", nID);
}
internal static IDataReader GetByEmpID(TransactionContext tc, int empID)
{
return tc.ExecuteReader("SELECT * FROM EmployeeOutsideDuty WHERE EmployeeID=%n", empID);
}
internal static IDataReader GetByEmpIdDetails(TransactionContext tc, int empID)
{
string sql = string.Empty;
if (empID == 0)
{
sql = SQLParser.MakeSQL(@"
SELECT e.EMPLOYEENO, e.NAME AS EmployeeName, eod.*
FROM EmployeeOutsideDuty eod
JOIN EMPLOYEE e ON eod.EmployeeID = e.EMPLOYEEID");
return tc.ExecuteReader(sql);
}
sql = SQLParser.MakeSQL(@"
SELECT e.EMPLOYEENO, e.NAME AS EmployeeName, eod.*
FROM EmployeeOutsideDuty eod
JOIN EMPLOYEE e ON eod.EmployeeID = e.EMPLOYEEID
WHERE eod.EmployeeID=%n", empID);
return tc.ExecuteReader(sql);
}
internal static IDataReader Get(TransactionContext tc, DateTime attnDate)
{
return tc.ExecuteReader(
"SELECT * FROM EmployeeOutsideDuty WHERE %d >= CAST(StartDate AS date) AND %d <= CAST(EndDate AS date)",
attnDate, attnDate);
}
#endregion
#region Delete function
internal static void Delete(TransactionContext tc, int nID)
{
tc.ExecuteNonQuery("DELETE FROM [EmployeeOutsideDuty] WHERE EmployeeOutsideDutyID=%n", nID);
}
#endregion
#region IsExist
internal static bool IsOutsideDutyAvailable(TransactionContext tc, DateTime startDate, DateTime endDate,
int empID)
{
bool isExist = false;
string sql = SQLParser.MakeSQL(
"SELECT Count(*) from EmployeeOutsideDuty where EmployeeID=%n AND (StartDate>=%d AND EndDate<=%d OR %d between StartDate AND EndDate OR %d between StartDate AND EndDate)",
empID, startDate, endDate, startDate, endDate);
object obj = tc.ExecuteScalar(sql);
isExist = Convert.ToInt32(obj) > 0 ? true : false;
return isExist;
}
#endregion
}
#endregion
}