using HRM.BO; using Ease.Core.DataAccess; using System; using System.Collections.Generic; using System.Data; namespace HRM.DA { class TrainingDepartmentDA { #region Get Function public static IDataReader Get(TransactionContext tc, int id) { return tc.ExecuteReader("SELECT * from TrainingDepartment WHERE TrainDepartmentID=%n", id); } public static IDataReader Get(TransactionContext tc) { return tc.ExecuteReader("SELECT * from TrainingDepartment"); } public static IDataReader GetByTrainingNeedAnalysisID(TransactionContext tc, int TrainingNeedAnalysisID) { return tc.ExecuteReader("SELECT * from TrainingDepartment where TrainingNeedAnalysisID=%n", TrainingNeedAnalysisID); } #endregion #region Insert Function public static void Insert(TransactionContext tc, TrainingDepartment oItem) { tc.ExecuteNonQuery( "INSERT INTO TrainingDepartment(TrainDepartmentID, TrainingNeedAnalysisID, DepartmentID, Remarks)" + " VALUES(%n,%n,%n,%s)", oItem.ID, DataReader.GetNullValue(oItem.TrainingNeedAnalysisID, 0), DataReader.GetNullValue(oItem.DepartmentID, 0), oItem.Remarks); } #endregion #region Update Function public static void Update(TransactionContext tc, TrainingDepartment oItem) { tc.ExecuteNonQuery("UPDATE TrainingDepartment SET TrainingNeedAnalysisID=%n,DepartmentID=%n,Remarks=%s" + " WHERE TrainDepartmentID=%n", DataReader.GetNullValue(oItem.TrainingNeedAnalysisID, 0), DataReader.GetNullValue(oItem.DepartmentID, 0), oItem.Remarks, oItem.ID); } #endregion #region Delete Function public static void Delete(TransactionContext tc, int id) { tc.ExecuteNonQuery("Delete from TrainingDepartment where TrainDepartmentID=%n", id); } public static void DeletebyTrainingNeedAnalysisID(TransactionContext tc, int TrainingNeedAnalysisID) { tc.ExecuteNonQuery("Delete from TrainingDepartment where TrainingNeedAnalysisID=%n", TrainingNeedAnalysisID); } #endregion public static bool DoesTrainingDepartmentExists(TransactionContext tc, int TrainDepartmentID) { object ob = tc.ExecuteScalar("SELECT COUNT(*) FROM TrainingDepartment WHERE TrainDepartmentID=%n", TrainDepartmentID); return (Convert.ToInt32(ob) > 0); } } }