EchoTex_Payroll/HRM.DA/DA/Attendance/GatePassDA.cs

138 lines
5.9 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 FactoryWorkSpaceDA
internal class GatePassDA
{
#region Constructor
private GatePassDA()
{
}
#endregion
#region Insert function
internal static void Insert(TransactionContext tc, GatePass item)
{
string sql = SQLParser.MakeSQL(@"INSERT INTO GatePass(GatePassID, TelephoneNo, Remarks, EmployeeID,
LineManagerID, ClaimWFStatus, TotalHour, EntryDate,
DepartureTime, ReturnTime, CreatedBy, CreatedDate,
SystemMode, ApprovedBy, ApprovedDate)
VALUES(%n, %s, %s, %n,
%n, %n, %n, %d,
%D, %D, %n,%d,
%n, %n, %d)",
item.ID, item.TelephoneNo, item.Remarks,
DataReader.GetNullValue(item.EmployeeID, 0),
DataReader.GetNullValue(item.LineManagerID, 0),
item.ClaimWFStatus, item.TotalHour, item.EntryDate, item.DepartureTime,
item.ReturnTime, item.CreatedBy, item.CreatedDate, item.SystemMode,
DataReader.GetNullValue(item.ApprovedBy, 0), DataReader.GetNullValue(item.ApprovedDate));
int a = 1;
tc.ExecuteNonQuery(@"INSERT INTO GatePass(GatePassID, TelephoneNo, Remarks, EmployeeID,
LineManagerID, ClaimWFStatus, TotalHour, EntryDate,
DepartureTime, CreatedBy, CreatedDate,
SystemMode, ApprovedBy, ApprovedDate)
VALUES(%n, %s, %s, %n,
%n, %n, %n, %d,
%D, %n,%d,
%n, %n, %d)",
item.ID, item.TelephoneNo, item.Remarks,
DataReader.GetNullValue(item.EmployeeID, 0),
DataReader.GetNullValue(item.LineManagerID, 0),
item.ClaimWFStatus, item.TotalHour, item.EntryDate, item.DepartureTime,
item.CreatedBy, item.CreatedDate, item.SystemMode,
DataReader.GetNullValue(item.ApprovedBy, 0), DataReader.GetNullValue(item.ApprovedDate));
}
#endregion
#region Update function
internal static void Update(TransactionContext tc, GatePass item)
{
tc.ExecuteNonQuery(
"UPDATE GatePass SET TelephoneNo=%s, Remarks=%s, EmployeeID=%n, LineManagerID=%n, ClaimWFStatus=%n, TotalHour=%n, EntryDate=%d, DepartureTime=%D, ReturnTime=%D, ModifiedBy=%n, ModifiedDate=%d, SystemMode=%n, ApprovedBy=%n, ApprovedDate=%D" +
" WHERE GatePassID=%n", item.TelephoneNo, item.Remarks, DataReader.GetNullValue(item.EmployeeID, 0),
DataReader.GetNullValue(item.LineManagerID, 0), item.ClaimWFStatus, item.TotalHour, item.EntryDate,
item.DepartureTime, item.ReturnTime, item.ModifiedBy, item.ModifiedDate, item.SystemMode,
DataReader.GetNullValue(item.ApprovedBy, 0), item.ApprovedDate, item.ID);
}
#endregion
#region Get Function
internal static int GetGatePassDataByWFStatusCount(TransactionContext tc, DateTime fromDate, DateTime toDate,
EnumWFAttnStatus status)
{
string sql = string.Empty;
sql = SQLParser.MakeSQL(@"Select Count(*) from GatePass
where ClaimWFStatus=%n and EntryDate between %d and %d", (int)status,
fromDate, toDate);
return Convert.ToInt32(tc.ExecuteScalar(sql).ToString());
}
internal static IDataReader Get(TransactionContext tc)
{
return tc.ExecuteReader("SELECT * FROM GatePass");
}
internal static IDataReader Get(TransactionContext tc, int nID)
{
return tc.ExecuteReader("SELECT * FROM GatePass WHERE GatePassID=%n", nID);
}
internal static IDataReader GetByEmployeeID(TransactionContext tc, int employeeID, DateTime fromDate,
DateTime toDate)
{
return tc.ExecuteReader("SELECT * FROM GatePass WHERE EmployeeID=%n and EntryDate between %d and %d ",
employeeID, fromDate, toDate);
}
internal static IDataReader GetByEmployeeID(TransactionContext tc, string employeeIDs, EnumClaimWFStatus status)
{
return tc.ExecuteReader("SELECT * FROM GatePass WHERE EmployeeID In (%q) and ClaimWFStatus = %n ",
employeeIDs, status);
}
internal static IDataReader GetByShiftManagerID(TransactionContext tc, int employeeID, EnumClaimWFStatus status)
{
return tc.ExecuteReader("SELECT * FROM GatePass WHERE LINEMANAGERID =%n and ClaimWFStatus = %n ",
employeeID, status);
}
internal static IDataReader GetByApproverID(TransactionContext tc, int employeeID, DateTime fromDate,
DateTime toDate)
{
return tc.ExecuteReader("SELECT * FROM GatePass WHERE ApprovedBy =%n and EntryDate between %d and %d",
employeeID, fromDate, toDate);
}
#endregion
#region Delete function
internal static void Delete(TransactionContext tc, int nID)
{
tc.ExecuteNonQuery("DELETE FROM GatePass WHERE GatePassID=%n", nID);
}
#endregion
}
#endregion
}