EchoTex_Payroll/HRM.DA/DA/Attendance/AttnNationalHolidayDA.cs

160 lines
6.4 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 AttnNationalHolidayDA
internal class AttnNationalHolidayDA
{
#region Constructor
private AttnNationalHolidayDA()
{
}
#endregion
#region Insert function
internal static void Insert(TransactionContext tc, AttnNationalHoliday item, int payrollTypeID)
{
tc.ExecuteNonQuery(
"INSERT INTO AttnNationalHoliday(AttnNationalHolidayID, Description, FromDate, ToDate, CreatedBy, CreatedDate,SequenceNo,Status, HolidayType, HolidayHour, PayrollTypeID, FromTime, ToTime,LocationID)" +
" VALUES(%n, %s, %D, %D, %n, %d,%n,%n, %n, %n, %n, %D, %D, %n)", item.ID, item.Description, item.FromDate,
item.ToDate, item.CreatedBy, item.CreatedDate, item.Sequence, (int)item.Status, (int)item.HolidayType,
item.HolidayHour, payrollTypeID, item.FromTime, item.ToTime, item.LocationID);
}
internal static void InsertChild(TransactionContext tc, AttnNationalHolidayLocation item)
{
tc.ExecuteNonQuery(
"INSERT INTO AttnNationalHolidayLocation(AttnNationalHolidayLocationID, AttnNationalHolidayID, LocationID)" +
" VALUES(%n, %n, %n)", item.ID, item.AttnNationalHolidayID, item.LocationID);
}
internal static void InsertShift(TransactionContext tc, AttnShiftWiseNationalHoliday item)
{
tc.ExecuteNonQuery(
"INSERT INTO AttnNationalHolidayShift(AttnNationalHolidayShiftID, AttnNationalHolidayID, ShiftID, WorkPlanGroupID)" +
" VALUES(%n, %n, %n, %n)", item.ID, item.ANationalHolidayID, item.ShiftID, item.WorkPlanGroupID);
}
#endregion
#region Update function
internal static void Update(TransactionContext tc, AttnNationalHoliday item)
{
tc.ExecuteNonQuery(
"UPDATE AttnNationalHoliday SET Description=%s, FromDate=%D, ToDate=%D, ModifiedBy=%n, ModifiedDate=%d,Status=%n,SequenceNo=%n, HolidayType=%n, HolidayHour=%n, FromTime=%D, ToTime=%D" +
", LocationID=%n WHERE AttnNationalHolidayID=%n", item.Description, item.FromDate, item.ToDate, item.ModifiedBy,
item.ModifiedDate, (int)item.Status, item.Sequence, (int)item.HolidayType, item.HolidayHour,
item.FromTime, item.ToTime, item.LocationID, item.ID);
}
#endregion
#region Get Function
internal static IDataReader Get(TransactionContext tc, EnumStatus status, int payrollTypeID)
{
string sql = string.Empty;
if (EnumStatus.Active == status)
{
sql = SQLParser.MakeSQL(@"
SELECT * FROM AttnNationalHoliday a, LEAVEYEAR cy
WHERE a.Status=%n AND a.PayRollTypeID = %n AND cy.PAYROLLTYPEID = %n AND cy.ISCURRENT = %b AND a.FROMDATE BETWEEN cy.STARTDATE AND cy.ENDDATE
ORDER BY a.FromDate ASC", status, payrollTypeID, payrollTypeID, true);
}
else
{
sql = SQLParser.MakeSQL(@"
SELECT * FROM AttnNationalHoliday a, LEAVEYEAR cy
WHERE a.PayRollTypeID = %n AND cy.PAYROLLTYPEID = %n AND cy.ISCURRENT = %b AND a.FROMDATE BETWEEN cy.STARTDATE AND cy.ENDDATE
ORDER BY a.FromDate ASC", payrollTypeID, payrollTypeID, true);
}
return tc.ExecuteReader(sql);
}
internal static IDataReader Get(TransactionContext tc, int nID)
{
return tc.ExecuteReader(
"SELECT * FROM AttnNationalHoliday WHERE AttnNationalHolidayID=%n and PayRollTypeID = %n", nID);
}
internal static IDataReader Get(TransactionContext tc, DateTime fromDate, DateTime todate)
{
return tc.ExecuteReader("SELECT * FROM AttnNationalHoliday WHERE FromDate between %d and %d", fromDate, todate);
}
internal static IDataReader Get(TransactionContext tc, DateTime fromDate, DateTime todate, int payrollTypeID)
{
string sql = SQLParser.MakeSQL(@"
SELECT * FROM AttnNationalHoliday WHERE FromDate between %d and %d and PayRollTypeID = %n ORDER BY FromDate DESC",
fromDate,todate, payrollTypeID);
return tc.ExecuteReader(sql);
}
internal static IDataReader getupcommingHoliday(TransactionContext tc, DateTime fromDate, int payrollTypeID)
{
return tc.ExecuteReader(
"SELECT * FROM AttnNationalHoliday WHERE FromDate >= %d and PayRollTypeID = %n", fromDate,
payrollTypeID);
}
internal static IDataReader GetupcommintHolidayByUserId(TransactionContext tc, DateTime fromDate, int userId)
{
//return tc.ExecuteReader(@"
//SELECT *
//FROM AttnNationalHoliday anh
//JOIN LOCATION l ON anh.LOCATIONID = l.LOCATIONID
//JOIN EMPLOYEE e ON l.LOCATIONID = e.LOCATIONID
//JOIN USERS u ON u.EMPLOYEEID = e.EMPLOYEEID
//WHERE u.USERID = %n AND anh.FROMDATE >= %d",
//userId, fromDate);
return tc.ExecuteReader(@"select * from AttnNationalHoliday where FROMDATE >= %d And PAYROLLTYPEID = %n order by FromDate ASC", fromDate, userId);
}
internal static IDataReader GetChild(TransactionContext tc, int attnNationalHolidayID)
{
return tc.ExecuteReader("SELECT * FROM AttnNationalHolidayLocation WHERE AttnNationalHolidayID=%n",
attnNationalHolidayID);
}
internal static IDataReader GetHolidayShift(TransactionContext tc, int attnNationalHolidayID)
{
return tc.ExecuteReader("SELECT * FROM AttnNationalHolidayShift WHERE AttnNationalHolidayID=%n",
attnNationalHolidayID);
}
#endregion
#region Delete function
internal static void Delete(TransactionContext tc, int nID)
{
tc.ExecuteNonQuery("DELETE FROM AttnNationalHoliday WHERE AttnNationalHolidayID=%n", nID);
}
internal static void DeleteChild(TransactionContext tc, int nID)
{
tc.ExecuteNonQuery("DELETE FROM AttnNationalHolidayLocation WHERE AttnNationalHolidayID=%n", nID);
tc.ExecuteNonQuery("DELETE FROM AttnNationalHolidayShift WHERE AttnNationalHolidayID=%n", nID);
}
#endregion
}
#endregion
}