129 lines
		
	
	
		
			4.5 KiB
		
	
	
	
		
			C#
		
	
	
	
	
	
		
		
			
		
	
	
			129 lines
		
	
	
		
			4.5 KiB
		
	
	
	
		
			C#
		
	
	
	
	
	
|  | using HRM.BO; | |||
|  | using Ease.Core.DataAccess; | |||
|  | using System.Data; | |||
|  | using System; | |||
|  | 
 | |||
|  | namespace HRM.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,SEQUENCENO, STATUS, CREATEDBY, CREATIONDATE,EducationlevelId)" + | |||
|  |                 " VALUES(%n, %s, %s, %n, %n, %n, %d,%n)", item.ID, item.Code, item.Description, item.Sequence, item.Status, | |||
|  |                 item.CreatedBy, item.CreatedDate, item.EducationLevelID); | |||
|  |         } | |||
|  | 
 | |||
|  |         internal static void Insert(TransactionContext tc, Discipline.DisciplineLevel item) | |||
|  |         { | |||
|  |             tc.ExecuteNonQuery("INSERT INTO DisciplineLevel(DisciplineLevelID,DISCIPLINEID,LEVELID)" + | |||
|  |                                " VALUES(%n,%n,%n)", item.ID, item.DiscilineID, item.LevelID); | |||
|  |         } | |||
|  | 
 | |||
|  |         #endregion | |||
|  | 
 | |||
|  |         #region Update function | |||
|  | 
 | |||
|  |         internal static void Update(TransactionContext tc, Discipline item) | |||
|  |         { | |||
|  |             tc.ExecuteNonQuery( | |||
|  |                 "UPDATE DISCIPLINE SET code=%s, description=%s, sequencenO=%n, status=%n, modifiedby=%n, modifieddate=%d,EducationTypeId=%n, EducationlevelId = %n" + | |||
|  |                 " WHERE DISCIPLINEID=%n", item.Code, item.Description, item.Sequence, item.Status, item.ModifiedBy, | |||
|  |                 item.ModifiedDate,item.EducationTypeId, item.EducationLevelID, item.ID); | |||
|  |         } | |||
|  | 
 | |||
|  |         #endregion | |||
|  | 
 | |||
|  |         #region Get function | |||
|  | 
 | |||
|  |         internal static IDataReader Get(TransactionContext tc) | |||
|  |         { | |||
|  |             return tc.ExecuteReader("SELECT * FROM DISCIPLINE ORDER BY SEQUENCENO"); | |||
|  |         } | |||
|  | 
 | |||
|  |         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 SEQUENCENO", status); | |||
|  |             } | |||
|  |             else | |||
|  |             { | |||
|  |                 return tc.ExecuteReader("SELECT * FROM DISCIPLINE ORDER BY SEQUENCENO"); | |||
|  |             } | |||
|  |         } | |||
|  | 
 | |||
|  |         internal static IDataReader Get(TransactionContext tc, int nID) | |||
|  |         { | |||
|  |             return tc.ExecuteReader("SELECT * FROM DISCIPLINE WHERE DISCIPLINEID=%n", nID); | |||
|  |         } | |||
|  | 
 | |||
|  |         internal static IDataReader Get(TransactionContext tc, string sCode) | |||
|  |         { | |||
|  |             return tc.ExecuteReader("SELECT * FROM DISCIPLINE WHERE Code=%s", sCode); | |||
|  |         } | |||
|  | 
 | |||
|  |         internal static IDataReader GetDisplineByDID(TransactionContext tc, int nID) | |||
|  |         { | |||
|  |             return tc.ExecuteReader("SELECT * FROM DisciplineLevel WHERE DISCIPLINEID=%n", nID); | |||
|  |         } | |||
|  | 
 | |||
|  |         internal static IDataReader GetDisByEducationLevel(TransactionContext tc, int nLevelID) | |||
|  |         { | |||
|  |             return tc.ExecuteReader("Select * from DisciplineLevel Where LevelID = %n", nLevelID); | |||
|  |         } | |||
|  | 
 | |||
|  |         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, int nID) | |||
|  |         { | |||
|  |             tc.ExecuteNonQuery("DELETE FROM DisciplineLevel WHERE DisciplineID=%n", nID); | |||
|  |             tc.ExecuteNonQuery("DELETE FROM DISCIPLINE WHERE DISCIPLINEID=%n", nID); | |||
|  |         } | |||
|  | 
 | |||
|  |         public static void DeleteByDisID(TransactionContext tc, int disciplineId) | |||
|  |         { | |||
|  |             tc.ExecuteNonQuery("DELETE FROM DisciplineLevel WHERE DisciplineID=%n", disciplineId); | |||
|  |         } | |||
|  | 
 | |||
|  |         internal static IDataReader GetByID(TransactionContext tc, object id) | |||
|  |         { | |||
|  |             string sql = SQLParser.MakeSQL(@"SELECT * FROM DISCIPLINE WHERE DISCIPLINEID =%n", id); | |||
|  |             return tc.ExecuteReader(sql); | |||
|  |         } | |||
|  | 
 | |||
|  |         internal static IDataReader GetByIDs(TransactionContext tc, string ids) | |||
|  |         { | |||
|  |             string sql = SQLParser.MakeSQL(@"SELECT * FROM DISCIPLINE WHERE DISCIPLINEID in (%q)", ids); | |||
|  |             return tc.ExecuteReader(sql); | |||
|  |         } | |||
|  | 
 | |||
|  |         #endregion | |||
|  |     } | |||
|  | 
 | |||
|  |     #endregion | |||
|  | } |