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

77 lines
2.9 KiB
C#

using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using Ease.CoreV35.DataAccess;
using Ease.CoreV35.Model;
using Payroll.BO;
namespace Payroll.Service
{
class TrainingScheduleAttnDA
{
#region Get Function
public static IDataReader Get(TransactionContext tc, int id)
{
return tc.ExecuteReader("SELECT * from TrainingScheduleAttn WHERE TSAttnID=%n", id);
}
public static IDataReader Get(TransactionContext tc)
{
return tc.ExecuteReader("SELECT * from TrainingScheduleAttn");
}
public static IDataReader GetByTrainingScheduleID(TransactionContext tc, ID trainingScheduleID)
{
return tc.ExecuteReader("SELECT * from TrainingScheduleAttn where TrainingScheduleID=%n", trainingScheduleID.Integer);
}
public static IDataReader GetByTrainingScheduleDateID(TransactionContext tc, ID trainingScheduleDateID)
{
return tc.ExecuteReader("SELECT * from TrainingScheduleAttn where TSDateID=%n", trainingScheduleDateID.Integer);
}
#endregion
#region Insert Function
public static void Insert(TransactionContext tc, TrainingScheduleAttn oItem)
{
tc.ExecuteNonQuery("INSERT INTO TrainingScheduleAttn(TSAttnID, TrainingScheduleID, TSDateID, EmployeeID)" +
" VALUES(%n,%n,%n,%n)", oItem.ID.Integer,DataReader.GetNullValue(oItem.TrainingScheduleID,IDType.Integer),DataReader.GetNullValue(oItem.TSDateID,IDType.Integer),DataReader.GetNullValue(oItem.EmployeeID,IDType.Integer));
}
#endregion
#region Update Function
public static void Update(TransactionContext tc, TrainingScheduleAttn oItem)
{
tc.ExecuteNonQuery("UPDATE TrainingScheduleAttn SET TrainingScheduleID=%n,TSDateID=%n,EmployeeID=%n" +
" WHERE TSAttnID=%n",DataReader.GetNullValue(oItem.TrainingScheduleID,IDType.Integer), DataReader.GetNullValue(oItem.TSDateID,IDType.Integer), DataReader.GetNullValue(oItem.EmployeeID,IDType.Integer),oItem.ID.Integer);
}
#endregion
#region Delete Function
public static void Delete(TransactionContext tc, int id)
{
tc.ExecuteNonQuery("Delete from TrainingScheduleAttn where TSAttnID=%n", id);
}
public static void DeletebyTrainingScheduleID(TransactionContext tc, int trainingScheduleID)
{
tc.ExecuteNonQuery("Delete from TrainingScheduleAttn where TrainingScheduleID=%n", trainingScheduleID);
}
#endregion
public static bool DoesTrainingScheduleAttnExists(TransactionContext tc, ID trainingScheduleDateID)
{
object ob = tc.ExecuteScalar("SELECT COUNT(*) FROM TrainingScheduleAttn WHERE TSDateID=%n", trainingScheduleDateID.Integer);
return (Convert.ToInt32(ob) > 0);
}
}
}