Esempio n. 1
0
        public static List <ExamClass> GetAllExamsByDeptId(int DeptId)
        {
            Database         db        = new Database();
            List <ExamClass> ExamsList = new List <ExamClass>();

            using (SqlCommand cmd = new SqlCommand("FetchExamListByDeptId", db.DbConnect()))
            {
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Parameters.AddWithValue("@DeptId", DeptId);
                SqlDataReader rdr = cmd.ExecuteReader();
                while (rdr.Read())
                {
                    ExamClass exams = new ExamClass();
                    exams.ExamId           = Convert.ToInt16(rdr["exam_id"].ToString());
                    exams.ExamName         = rdr["exam_name"].ToString();
                    exams.ExamType         = rdr["exam_type"].ToString();
                    exams.DeptpartmentName = rdr["dept_id"].ToString();
                    exams.SemId            = Convert.ToInt16(rdr["sem_id"].ToString());
                    exams.SubjectName      = FetchSubjectNameById(Convert.ToInt16(rdr["subject_id"].ToString()));
                    exams.ExamCode         = rdr["exam_code"].ToString();
                    exams.ExamDate         = rdr["exam_date"].ToString();
                    ExamsList.Add(exams);
                }
            }
            return(ExamsList);
        }
Esempio n. 2
0
        public static List <ExamClass> GetUpCommingExam(string Dept_ID, string SemId, string CurDate)
        {
            Database         db        = new Database();
            List <ExamClass> ExamsList = new List <ExamClass>();

            using (SqlCommand cmd = new SqlCommand("FetchUpCommingExams", db.DbConnect()))
            {
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Parameters.AddWithValue("@DeptId", Convert.ToInt16(Dept_ID));
                cmd.Parameters.AddWithValue("@SemId", Convert.ToInt16(SemId));
                //cmd.Parameters.AddWithValue("@CurrentDate", CurDate);
                SqlDataReader rdr = cmd.ExecuteReader();
                if (rdr.HasRows)
                {
                    while (rdr.Read())
                    {
                        DateTime ExamDate      = DateTime.Parse(rdr["exam_date"].ToString());
                        DateTime CurrentDate   = DateTime.Parse(DateTime.Now.ToShortDateString());
                        int      ResultCompare = DateTime.Compare(CurrentDate, ExamDate);
                        if (ResultCompare == 0 || ResultCompare == -1)
                        {
                            ExamClass UpCommingExams = new ExamClass();
                            UpCommingExams.ExamName    = rdr["exam_name"].ToString();
                            UpCommingExams.ExamType    = DetermineExamType(rdr["exam_type"].ToString());
                            UpCommingExams.ExamDate    = rdr["exam_date"].ToString();
                            UpCommingExams.ExamCode    = rdr["exam_code"].ToString();
                            UpCommingExams.SubjectName = FetchSubjectNameById(Convert.ToInt16(rdr["subject_id"].ToString()));
                            ExamsList.Add(UpCommingExams);
                        }
                    }
                }
            }
            return(ExamsList);
        }