// get availabe exams for student without course type public static ExamCollection GetAvailabeExams(int id) { ExamCollection result = new ExamCollection(); string s = String.Format( " select DISTINCT * from Exam, ExamSession " + " where {0} not in (select Student_Exam.FK_StudID from Student_Exam where Exam.id " + " <> Student_Exam.FK_ExamID) and Exam.flag <> 0 " + " and Exam.id in (Select ExamSession.FK_ExamID from ExamSession) " + " and Exam.id in (select Exam_Course_Instructor.FK_ExamID " + "from Exam_Course_Instructor,Course_Student " + "where Course_Student.FK_CourseID = Exam_Course_Instructor.FK_CourseID) " + " and Exam.id = ExamSession.FK_ExamID ", id); DataTable dt = DBLayer.ExecuteQuery(s); for (int i = 0; i < dt.Rows.Count; i++) { Admin admin = new Admin(int.Parse(dt.Rows[i]["FK_AdminID"].ToString())); int ids = int.Parse(dt.Rows[i]["session_ID"].ToString()); ExamSession examSession = new ExamSession(ids, DateTime.Parse(dt.Rows[i]["session_date"].ToString()), new Exam(int.Parse(dt.Rows[i]["id"].ToString()), true, admin), admin); Exam exam = new Exam(Convert.ToInt32(dt.Rows[i]["id"]), (bool)dt.Rows[i]["flag"], admin); exam.ExamSessions = new ExamSessionCollection(); exam.ExamSessions.Add(examSession); result.Add(exam); } result = RearangeExams(result); result = getExamCourse(result); return(result); }
public static ExamCollection getAll(Admin adm) { DataTable dt = database.DBLayer.ExecuteQuery("select * from Exam"); ExamCollection result = new ExamCollection(); for (int i = 0; i < dt.Rows.Count; i++) { int examId = Convert.ToInt32(dt.Rows[i]["id"]); bool flag = Convert.ToBoolean(dt.Rows[i]["flag"]); adm.Id = Convert.ToInt32(dt.Rows[i]["FK_AdminID"]); Exam exam = new Exam(examId, flag, adm); result.Add(exam); } return(result); }