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

141 lines
6.1 KiB
C#

using HRM.BO;
using Ease.Core.DataAccess;
using System;
using System.Collections.Generic;
using System.Data;
namespace HRM.DA
{
class TrainingNeedAnalysisDA
{
#region Get Function
public static IDataReader Get(TransactionContext tc, int id)
{
return tc.ExecuteReader("SELECT * from TrainingNeedAnalysis WHERE TrainingNeedAnalysisID=%n", id);
}
public static IDataReader Get(TransactionContext tc)
{
return tc.ExecuteReader("SELECT * from TrainingNeedAnalysis");
}
internal static IDataReader GetByYear(TransactionContext tc, int year)
{
return tc.ExecuteReader("SELECT * from TrainingNeedAnalysis WHERE TrainingYear=%n", year);
}
internal static IDataReader GetByParam(TransactionContext tc, int year, string sDeptIDs, string sDeptForIDs)
{
//string sql = string.Format(@"SELECT * from TrainingNeedAnalysis tna WHERE tna.TrainingYear={0} {1} {2}",
// year,sDeptIDs!=string.Empty?" AND tna.DepartmentID IN (" + sDeptIDs + ")":"",sDeptForIDs != string.Empty?" AND tna.trainingNeedAnalysisID IN ( select trainingNeedAnalysisID from TrainingDepartment where DepartmentID IN (" + sDeptForIDs + "))":"");
string sql = string.Format(@"SELECT * from TrainingNeedAnalysis tna WHERE tna.TrainingYear={0} {1} {2}",
year, sDeptIDs != string.Empty ? " AND tna.DepartmentID IN (" + sDeptIDs + ")" : "",
sDeptForIDs != string.Empty
? " AND tna.trainingNeedAnalysisID IN ( select trainingNeedAnalysisID from TrainingDepartment where DepartmentID IN (" +
sDeptForIDs + "))"
: "");
return tc.ExecuteReader(sql);
}
internal static IDataReader Get(TransactionContext tc, int trainingID, int departmentID, int departmentForID,
int trainingType)
{
return tc.ExecuteReader("SELECT * from TrainingNeedAnalysis WHERE TrainingID=%n AND departmentID=%n",
trainingID, departmentID);
}
internal static IDataReader Get(TransactionContext tc, string query)
{
return tc.ExecuteReader(query);
}
#endregion
#region Insert Function
public static void Insert(TransactionContext tc, TrainingNeedAnalysis oItem)
{
string sql = SQLParser.MakeSQL(
@"INSERT INTO TrainingNeedAnalysis(TrainingNeedAnalysisID, TrainingYear, Name,EmployeeID,TrainingID,Description,MaxParticipent,Conduct_Required,DepartmentID, CREATEDBY,CREATEDDATE)" +
" VALUES(%n,%n,%s,%n,%n,%s,%n,%n,%n,%n,%d)", oItem.ID, oItem.TrainingYear, oItem.Name, oItem.EmployeeID,
oItem.TrainingID, oItem.Description, oItem.MaxParticipent, oItem.Conduct_Required, oItem.DepartmentID,
DataReader.GetNullValue(oItem.CreatedBy), DataReader.GetNullValue(oItem.CreatedDate));
tc.ExecuteNonQuery(sql);
}
public static void Insert(TransactionContext tc, SubordinateTrainee oItem)
{
tc.ExecuteNonQuery(
"INSERT INTO SubordinateTrainee(SubordinateTraineeID, TrainingNeedAnalysisID, EmployeeID, Remarks)" +
" VALUES(%n,%n,%n,%s)", oItem.ID, DataReader.GetNullValue(oItem.TrainingNeedAnalysisID),
DataReader.GetNullValue(oItem.EmployeeID), oItem.Remarks);
}
#endregion
#region Update Function
public static void Update(TransactionContext tc, TrainingNeedAnalysis oItem)
{
tc.ExecuteNonQuery(
"UPDATE TrainingNeedAnalysis SET TrainingYear=%n,Name=%s,EmployeeID=%n,TrainingID=%n,Description=%s,MaxParticipent=%n,Conduct_Required=%n, DepartmentID=%n, MODIFIEDBY=%n,MODIFIEDDATE=%d" +
" WHERE TrainingNeedAnalysisID=%n", oItem.TrainingYear, oItem.Name, oItem.EmployeeID, oItem.TrainingID,
oItem.Description, oItem.MaxParticipent, oItem.Conduct_Required, oItem.DepartmentID,
DataReader.GetNullValue(oItem.ModifiedBy), DataReader.GetNullValue(oItem.ModifiedDate), oItem.ID);
}
public static void Update(TransactionContext tc, SubordinateTrainee oItem)
{
tc.ExecuteNonQuery("UPDATE SubordinateTrainee SET TrainingNeedAnalysisID=%n,EmployeeID=%n,Remarks=%s" +
" WHERE SubordinateTraineeID=%n", DataReader.GetNullValue(oItem.TrainingNeedAnalysisID),
DataReader.GetNullValue(oItem.EmployeeID), oItem.Remarks, oItem.ID);
}
#endregion
#region Delete Function
public static void Delete(TransactionContext tc, int id)
{
tc.ExecuteNonQuery("Delete from TrainingNeedAnalysis where TrainingNeedAnalysisID=%n", id);
}
#endregion
public static bool IsExists(string TableName, string ColName, int id, TransactionContext tc)
{
object ob = tc.ExecuteScalar("SELECT COUNT(*) FROM " + TableName + " WHERE " + ColName + "=%s", id);
return (Convert.ToInt32(ob) > 0);
}
internal static IDataReader GetSubordinate(TransactionContext tc)
{
return tc.ExecuteReader("SELECT * from SubordinateTrainee");
}
internal static IDataReader SubordinateGet(TransactionContext tc, int p)
{
throw new NotImplementedException();
}
internal static IDataReader GetByTrainingNeedAnalysisID(TransactionContext tc, int TrainingNeedAnalysisID)
{
return tc.ExecuteReader("SELECT * from SubordinateTrainee where TrainingNeedAnalysisID=%n",
TrainingNeedAnalysisID);
}
internal static IDataReader GetByEmployeeID(TransactionContext tc, string employeeNo)
{
return tc.ExecuteReader("SELECT * FROM TRAININGNEEDANALYSIS WHERE EMPLOYEEID =%s", employeeNo);
}
internal static IDataReader IsExist(TransactionContext tc, int trainingID)
{
return tc.ExecuteReader("SELECT * FROM TRAININGNEEDANALYSIS WHERE TRAININGID = %n", trainingID);
}
}
}