using System; using Payroll.BO; using System.Data; using System.Linq; using Ease.CoreV35.Model; using System.Data.SqlClient; using Ease.CoreV35.DataAccess; using System.Collections.Generic; using Ease.CoreV35.DataAccess.SQL; namespace Payroll.Service.HRBasic.DA { #region class DisciplineDA internal class DisciplineDA { #region constructor public DisciplineDA() { } #endregion #region Insert function internal static void Insert(TransactionContext tc, Discipline item) { tc.ExecuteNonQuery("INSERT INTO DISCIPLINE(DISCIPLINEID, CODE, DESCRIPTION, EDUCATIONLEVELID,SEQUENCENO, STATUS, CREATEDBY, CREATIONDATE)" + " VALUES(%n, %s, %s, %n, %n, %n, %n, %d)", item.ID.Integer, item.Code, item.Description,DataReader.GetNullValue(item.EducationLevelID,IDType.Integer), item.Sequence, item.Status, item.CreatedBy.Integer, item.CreatedDate); } internal static void Insert(TransactionContext tc, Discipline.DisciplineLevel item) { tc.ExecuteNonQuery("INSERT INTO DisciplineLevel(DisciplineLevelID,DISCIPLINEID,LEVELID)" + " VALUES(%n,%n,%n)",item.ID.Integer,item.DiscilineID.Integer,item.LevelID.Integer); } #endregion #region Update function internal static void Update(TransactionContext tc, Discipline item) { tc.ExecuteNonQuery("UPDATE DISCIPLINE SET code=%s, description=%s, educationlevelid=%n, sequencenO=%n, status=%n, modifiedby=%n, modifieddate=%d" + " WHERE DISCIPLINEID=%n", item.Code, item.Description, DataReader.GetNullValue(item.EducationLevelID,IDType.Integer), item.Sequence, item.Status, item.ModifiedBy.Integer, item.ModifiedDate, item.ID.Integer); } #endregion #region Get function internal static IDataReader Get(TransactionContext tc) { return tc.ExecuteReader("SELECT * FROM DISCIPLINE"); } internal static IDataReader Get(TransactionContext tc, EnumStatus status) { if (EnumStatus.Active == status || EnumStatus.Inactive == status) { return tc.ExecuteReader("SELECT * FROM DISCIPLINE Where Status=%n Order By Code", status); } else { return tc.ExecuteReader("SELECT * FROM DISCIPLINE order by Code"); } } internal static IDataReader Get(TransactionContext tc, ID nID) { return tc.ExecuteReader("SELECT * FROM DISCIPLINE WHERE DISCIPLINEID=%n", nID.Integer); } internal static IDataReader Get(TransactionContext tc, string sCode) { return tc.ExecuteReader("SELECT * FROM DISCIPLINE WHERE Code=%s", sCode); } internal static IDataReader GetDisplineByDID(TransactionContext tc, ID nID) { return tc.ExecuteReader("SELECT * FROM DisciplineLevel WHERE DISCIPLINEID=%n", nID.Integer); } internal static IDataReader GetDisByEducationLevel(TransactionContext tc, ID nLevelID) { return tc.ExecuteReader("Select * from DisciplineLevel Where LevelID = %n", nLevelID.Integer); } internal static IDataReader GetByEducationLevel(TransactionContext tc, int levelID) { //return tc.ExecuteReader("SELECT * FROM DISCIPLINE where DISCIPLINEID IN ( " // + " SELECT DISTINCT DISCIPLINEID FROM DisciplineLevel WHERE levelid=%n" // + " ) ORDER BY Description", levelID); return tc.ExecuteReader("Select * from Discipline where EducationLevelID = %n", levelID); } #endregion #region Delete function internal static void Delete(TransactionContext tc, ID nID) { tc.ExecuteNonQuery("DELETE FROM DisciplineLevel WHERE DisciplineID=%n", nID.Integer); tc.ExecuteNonQuery("DELETE FROM [DISCIPLINE] WHERE DISCIPLINEID=%n", nID.Integer); } public static void DeleteByDisID(TransactionContext tc, int disciplineId) { tc.ExecuteNonQuery("DELETE FROM DisciplineLevel WHERE DisciplineID=%n", disciplineId); } #endregion } #endregion }