86 lines
3.7 KiB
C#
86 lines
3.7 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using Ease.CoreV35.DataAccess;
|
|
using System.Data;
|
|
using Payroll.BO;
|
|
|
|
namespace Payroll.Service
|
|
{
|
|
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 + "))":"");
|
|
|
|
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)
|
|
{
|
|
tc.ExecuteNonQuery("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.Integer, oItem.TrainingYear, oItem.Name,oItem.EmployeeID,oItem.TrainingID, oItem.Description,oItem.MaxParticipent,oItem.Conduct_Required,oItem.DepartmentID, DataReader.GetNullValue(oItem.CreatedBy.Integer), DataReader.GetNullValue(oItem.CreatedDate));
|
|
|
|
}
|
|
#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.Integer), DataReader.GetNullValue(oItem.ModifiedDate), oItem.ID.Integer);
|
|
|
|
}
|
|
|
|
#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);
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
}
|