EchoTex_Payroll/HRM.DA/DA/Basic/WeeklyHolidayDA.cs
2024-10-14 10:01:49 +06:00

91 lines
3.1 KiB
C#

using HRM.BO;
using Ease.Core.DataAccess;
using System.Data;
namespace HRM.DA
{
internal class WeeklyHolidayDA
{
#region Constructor
private WeeklyHolidayDA()
{
}
#endregion
#region Insert function
internal static void Insert(TransactionContext tc, WeeklyHoliday item)
{
item.Status = EnumStatus.Active;
tc.ExecuteNonQuery(
"INSERT INTO WeeklyHoliday(WeeklyHolidayID, DateType, LocationID, HolidayMonth, IsAlternative, IsHalfDay, CreatedBy, CreatedDate, SequenceNo, Status)" +
" VALUES(%n, %n, %n, %n, %n, %n, %n, %d, %n, %n)", item.ID, item.DateType,
item.LocationID, DataReader.GetNullValue(item.HolidayMonth),
item.IsAlternative, item.IsHalfDay, item.CreatedBy, item.CreatedDate, item.Sequence, item.Status);
}
#endregion
#region Update function
internal static void Update(TransactionContext tc, WeeklyHoliday item)
{
tc.ExecuteNonQuery(
"UPDATE WeeklyHoliday SET DateType=%n, LocationID=%n, HolidayMonth=%n, IsAlternative=%n, IsHalfDay=%n, ModifiedBy=%n, ModifiedDate=%d, SequenceNo=%n, Status=%n" +
" WHERE WeeklyHolidayID=%n", item.DateType, item.LocationID,
DataReader.GetNullValue(item.HolidayMonth), item.IsAlternative, item.IsHalfDay, item.ModifiedBy,
item.ModifiedDate, item.Sequence, item.Status, item.ID);
}
#endregion
#region Get Function
internal static IDataReader Get(TransactionContext tc, EnumStatus status)
{
if (EnumStatus.Active == status || EnumStatus.Inactive == status)
{
return tc.ExecuteReader("SELECT * FROM WeeklyHoliday where Status=%n Order By SequenceNo", status);
}
else
{
return tc.ExecuteReader("SELECT * FROM WeeklyHoliday Order By SequenceNo");
}
}
internal static IDataReader Get(TransactionContext tc, int ID)
{
return tc.ExecuteReader("SELECT * FROM WeeklyHoliday WHERE WeeklyHolidayID=%n", ID);
}
internal static IDataReader GetCompanyEntireHolidays(TransactionContext tc)
{
return tc.ExecuteReader("SELECT * FROM WeeklyHoliday WHERE LocationID is null");
}
internal static IDataReader GetByLocation(TransactionContext tc, int ID)
{
return tc.ExecuteReader("SELECT * FROM WeeklyHoliday WHERE LocationID=%n", ID);
}
internal static IDataReader GetByEmployee(TransactionContext tc, int ID)
{
return tc.ExecuteReader(
"SELECT * FROM WeeklyHoliday WHERE LocationID=(select LocationID from Employee where EmployeeID=%n)",
ID);
}
#endregion
#region Delete function
internal static void Delete(TransactionContext tc, int ID)
{
tc.ExecuteNonQuery("DELETE FROM WeeklyHoliday WHERE WeeklyHolidayID=%n", ID);
}
#endregion
}
}