public static Course getCourseByDeptCourseNum(string dept, string courseNum) { Course rvalue = new Course(); MySqlConnection con = new MySqlConnection(connectionString); string query = "SELECT * FROM `classes` WHERE Department = " + dept + " AND Course_Num = " + courseNum; MySqlCommand cmd = new MySqlCommand(query); MySqlDataReader reader = null; string result = null; con.Open(); cmd.Connection = con; reader = cmd.ExecuteReader(); while (reader.Read()) { rvalue = new Course(reader.GetString(0), reader.GetInt32(1), reader.GetString(2), reader.GetInt32(3), reader.GetString(4)); } con.Close(); return rvalue; }
public static List<Course> getAllCoursesFromTable(String tableName) { List<Course> courses = new List<Course>(); MySqlConnection con = new MySqlConnection(connectionString); string query = "SELECT * FROM `" + tableName + "`"; MySqlCommand cmd = new MySqlCommand(query); MySqlDataReader reader = null; string result = null; con.Open(); cmd.Connection = con; reader = cmd.ExecuteReader(); while (reader.Read()) { result = reader.GetString(0) + " " + reader.GetString(1) + '\n'; Course addCourse = new Course(reader.GetString(0), reader.GetInt32(1), reader.GetString(2), reader.GetInt32(3), reader.GetString(4)); courses.Add(addCourse); } con.Close(); return courses; }
public void addPrerequisite(Course pre) { prerequisitesList.Add(pre); }