コード例 #1
0
 public List <Courses> EECourse()
 {
     try
     {
         List <Courses> ct = null;
         try
         {
             string             sql       = "select * from dbo.Table_Courses where DepartmentID = @DepartmentID";
             List <DbParameter> ParamList = new List <DbParameter>();
             SqlParameter       p1        = new SqlParameter("@DepartmentID", SqlDbType.VarChar);
             p1.Value = 1003;
             ParamList.Add(p1);
             DataTable dt = _idac.GetManyRowsandColumns(sql, ParamList);
             ct = DBList.ToList <Courses>(dt);
         }
         catch (Exception)
         {
             throw;
         }
         return(ct);
     }
     catch (Exception)
     {
         throw;
     }
 }
コード例 #2
0
 public List <Student> GetStudentsByCourse(string courseNum)
 {
     try
     {
         List <Student> SList = null;
         try
         {
             string sql = "select * from Students" +
                          " join StudentCourses sc on s.StudentId = sc.StudentId" +
                          " where sc.CourseNum = @CourseNum ";
             List <DbParameter> paramList = new List <DbParameter>();
             SqlParameter       p1        = new SqlParameter("@CategoryId", SqlDbType.VarChar);
             p1.Value = courseNum;
             paramList.Add(p1);
             DataTable dt = _idac.GetManyRowsCols(sql, paramList);
             SList = DBList.ToList <Student>(dt);
         }
         catch (Exception)
         {
             throw; //NO STUDENT WHATEVER
         }
         return(SList);
     }
     catch (Exception)
     {
         throw; //no such class exist
     }
 }
コード例 #3
0
        public List <Course> GetAllCourse()
        {
            List <Course> CourseList = null;

            try
            {
                string    sql = "select * from Courses";
                DataTable dt  = _idac.GetManyRowsCols(sql, null);
                CourseList = DBList.ToList <Course>(dt);
            }
            catch (Exception)
            { throw; }
            return(CourseList);
        }
コード例 #4
0
 public List <Course> GetCoursesBySemester(string semester)
 {
     try
     {
         List <Course> courseList = new List <Course>();
         Console.WriteLine("Semester: " + semester);
         string sql = "select * from Courses c "
                      + " join CoursesOffered co on c.CourseNum = co.CourseNum"
                      + " where co.Semester = @semester";
         List <DbParameter> paramList = new List <DbParameter>();
         SqlParameter       p1        = new SqlParameter("@semester", SqlDbType.VarChar);
         p1.Value = semester;
         paramList.Add(p1);
         DataTable dt = _idac.GetManyRowsCols(sql, paramList);
         courseList = DBList.ToList <Course>(dt);
         return(courseList);
     }
     catch (Exception)
     {
         throw; //semester not found
     }
 }