CEL_Payroll/Payroll.Service/Basic/DA/WeeklyHolidayDA.cs
2024-09-17 14:30:13 +06:00

90 lines
3.0 KiB
C#

using System;
using Payroll.BO;
using System.Data;
using System.Linq;
using Ease.CoreV35.Model;
using System.Data.SqlClient;
using Ease.CoreV35.DataAccess;
using System.Collections.Generic;
using Ease.CoreV35.DataAccess.SQL;
namespace Payroll.Service
{
#region WeeklyHolidayDA
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, CreatedBy, CreatedDate, SequenceNo, Status)" +
" VALUES(%n, %n, %n, %n, %d, %n, %n)", item.ID.Integer, item.DateType,DataReader.GetNullValue(item.LocationID,IDType.Integer) , item.CreatedBy.Integer, 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, ModifiedBy=%n, ModifiedDate=%d, SequenceNo=%n, Status=%n" +
" WHERE WeeklyHolidayID=%n", item.DateType, DataReader.GetNullValue(item.LocationID,IDType.Integer), item.ModifiedBy.Integer, item.ModifiedDate, item.Sequence, item.Status, item.ID.Integer);
}
#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, ID nID)
{
return tc.ExecuteReader("SELECT * FROM WeeklyHoliday WHERE WeeklyHolidayID=%n", nID.Integer);
}
internal static IDataReader GetCompanyEntireHolidays(TransactionContext tc)
{
return tc.ExecuteReader("SELECT * FROM WeeklyHoliday WHERE LocationID is null");
}
internal static IDataReader GetByLocation(TransactionContext tc, ID nID)
{
return tc.ExecuteReader("SELECT * FROM WeeklyHoliday WHERE LocationID=%n", nID.Integer);
}
internal static IDataReader GetByEmployee(TransactionContext tc, ID nID)
{
return tc.ExecuteReader("SELECT * FROM WeeklyHoliday WHERE LocationID=(select LocationID from Employee where EmployeeID=%n)", nID.Integer);
}
#endregion
#region Delete function
internal static void Delete(TransactionContext tc, ID nID)
{
tc.ExecuteNonQuery("DELETE FROM [WeeklyHoliday] WHERE WeeklyHolidayID=%n", nID.Integer);
}
#endregion
}
#endregion
}