EchoTex_Payroll/HRM.DA/DA/Bonus/ProdBonusAttnDA.cs

118 lines
4.7 KiB
C#
Raw Normal View History

2024-10-14 10:01:49 +06:00
using HRM.BO;
using Ease.Core.DataAccess;
using System;
using System.Data;
namespace HRM.DA
{
internal class ProdBonusAttnDA
{
#region Constructor
private ProdBonusAttnDA()
{
}
#endregion
#region Insert function
internal static void Insert(TransactionContext tc, ProdBonusAttn item)
{
string sql = SQLParser.MakeSQL(
"INSERT INTO ProdBonusAttn(ProdBonusAttnID, ProdBonusSetupID,BonusScheduleID,ProdBonusLineID,InTime,OutTime,BonusHour, EmployeeID,IsCommon)" +
" VALUES(%n, %n, %n,%n,%D,%D,%n,%n, %b)", item.ID, item.ProdBonusSetupID, item.BonusScheduleID,
item.ProdBonusLineID, item.InTime, item.OutTime, item.BonusHour, item.EmployeeID, item.IsCommon);
tc.ExecuteNonQuery(sql);
}
#endregion
#region Update function
internal static void Update(TransactionContext tc, ProdBonusAttn item)
{
tc.ExecuteNonQuery(
"UPDATE ProdBonusAttn SET ProdBonusSetupID=%n,BonusScheduleID=%n,ProdBonusLineID=%n,InTime=%d,OutTime=%d,BonusHour=%n, EmployeeID=%n, IsCommon=%b " +
"WHERE ProdBonusAttnID=%n", item.ProdBonusSetupID, item.ProdBonusLineID, item.InTime, item.OutTime,
item.BonusHour, item.EmployeeID, item.IsCommon, item.ID);
}
#endregion
#region Get Function
internal static IDataReader Get(TransactionContext tc)
{
return tc.ExecuteReader("SELECT * FROM ProdBonusAttn");
}
internal static IDataReader Get(TransactionContext tc, int setupID, int scheduleID)
{
return tc.ExecuteReader("SELECT * FROM ProdBonusAttn WHERE ProdBonusSetupID=%n AND BonusScheduleID=%n",
setupID, scheduleID);
}
internal static IDataReader GetBySetupID(TransactionContext tc, int setupID)
{
return tc.ExecuteReader("SELECT * FROM ProdBonusAttn WHERE ProdBonusSetupID=%n ", setupID);
}
internal static IDataReader GetBySetupIDs(TransactionContext tc, string setupIDs)
{
return tc.ExecuteReader("SELECT * FROM ProdBonusAttn WHERE ProdBonusSetupID in (%q) ", setupIDs);
}
internal static IDataReader Get(TransactionContext tc, int nID)
{
return tc.ExecuteReader("SELECT * FROM ProdBonusAttn WHERE ProdBonusAttnID=%n", nID);
}
internal static IDataReader GetByLineID(TransactionContext tc, int lineID)
{
return tc.ExecuteReader("SELECT * FROM ProdBonusAttn WHERE ProdBonusLineID=%n ", lineID);
}
internal static IDataReader GetbySetupAndLineID(TransactionContext tc, int setupID, int lineID)
{
return tc.ExecuteReader("SELECT * FROM ProdBonusAttn WHERE ProdBonusSetupID=%n AND ProdBonusLineID=%n ", setupID, lineID);
}
internal static IDataReader GetbySetupAndLineIDbyInSQL(TransactionContext tc, string setupID, string lineID)
{
return tc.ExecuteReader("SELECT * FROM ProdBonusAttn pt Inner join " +
" ProductionBonusSetup ps on ps.ProdBonusSetupID =pt.ps.ProdBonusSetupID " +
"where ps.ProdBonusSetupID IN (%s) AND ProdBonusLineID IN ( %s) ", setupID, lineID);
}
internal static IDataReader Get(TransactionContext tc, int setupID, DateTime dateTime)
{
2024-10-29 14:51:13 +06:00
string sql = SQLParser.MakeSQL("SELECT PBA.*, E.EMPLOYEENO FROM ProdBonusAttn PBA Left Join EMPLOYEE E on E.EMPLOYEEID = PBA.EmployeeID WHERE PBA.ProdBonusSetupID=%n AND year(PBA.InTime)= %n AND month(PBA.InTime)= %n AND day(PBA.InTime)= %n ORDER BY TRY_CAST(E.EMPLOYEENO AS INT) ASC",
2024-10-14 10:01:49 +06:00
setupID, dateTime.Year, dateTime.Month,dateTime.Day);
return tc.ExecuteReader(sql);
//return tc.ExecuteReader("SELECT * FROM ProdBonusAttn WHERE ProdBonusSetupID=%n AND CAST(InTime AS date)=%d", setupID, dateTime);
}
#endregion
#region Delete function
internal static void Delete(TransactionContext tc, int nID)
{
tc.ExecuteNonQuery("DELETE FROM ProdBonusAttn WHERE ProdBonusAttnID=%n", nID);
}
internal static void Delete(TransactionContext tc, int setupID, int scheduleID)
{
tc.ExecuteNonQuery("DELETE FROM ProdBonusAttn WHERE ProdBonusSetupID=%n AND BonusScheduleID=%n", setupID,
scheduleID);
}
internal static void Delete(TransactionContext tc, int setupID, DateTime inTime)
{
tc.ExecuteNonQuery("DELETE FROM ProdBonusAttn WHERE ProdBonusSetupID=%n AND CAST(InTime AS date)=%d", setupID, inTime);
}
#endregion
}
}