/// <summary> /// Class constructor /// </summary> /// <param name="studID">Students ID</param> /// <param name="studName">Students Name</param> public frmCourseInfo(string studID, string studName) { // Initalize components on the form InitializeComponent(); // The global Student object has the studID and studName parameters passed into it LoggedInStudent = new Student(studID, studName); }
/// <summary> /// Drops all courses in the students study plan /// </summary> /// <param name="student">Student to drop study plan from</param> public static void DropAllCourses(Student student) { // Create the connection to the resource using (SqlConnection conn = new SqlConnection()) { // Create the connectionString conn.ConnectionString = "Data Source=tfs;Initial Catalog=study3;Integrated Security=True"; // Create the command SqlCommand command = new SqlCommand("db_owner.DROP_ALL_STUDY_COURSE", conn); // Type of query set command.CommandType = CommandType.StoredProcedure; // Parameters are added command.Parameters.Add("@student_id", SqlDbType.VarChar).Value = student.ID; // Connection is opened and query is executed conn.Open(); command.ExecuteNonQuery(); // Connection is then closed conn.Close(); } }
/// <summary> /// Constructs class /// </summary> /// <param name="studID">Students ID</param> /// <param name="studName">Name of the student</param> public frmPlanOfStudy(string studID, string studName) { InitializeComponent(); // Instance variable setup LoggedInStudent = new Student(studID, studName); }
/// <summary> /// Saves study plan to the database /// </summary> /// <param name="courses">Courses to save</param> /// <param name="student">Student to save to</param> public static void SaveStudyPlan(Course[] courses, Student student) { // Create the connection to the resource using (SqlConnection conn = new SqlConnection()) { // Create the connectionString // Trusted_Connection is used to denote the connection uses Windows Authentication conn.ConnectionString = "Data Source=tfs;Initial Catalog=study3;Integrated Security=True"; // Loop through length of courses array and add the courses to the study plan in the database for (int i = 0; i < courses.Length; i++) { // Close the connection incase one is already opened conn.Close(); // Create the command SqlCommand command = new SqlCommand("db_owner.UDSP_INSERT_STUDY_COURSE", conn); // set procedure command.CommandType = CommandType.StoredProcedure; //// Add the parameters. command.Parameters.Add("@student_id", SqlDbType.VarChar).Value = student.ID; command.Parameters.Add("@course_id", SqlDbType.VarChar).Value = courses[i].ID; command.Parameters.Add("@semester", SqlDbType.Int).Value = courses[i].Semester; // Execute conn.Open(); command.ExecuteNonQuery(); } } }
/// <summary> /// Updates the course semester relative to the study plan /// </summary> /// <param name="course">Course object to update</param> /// <returns>Updated Course object</returns> public static int UpdateCourseSemester(Course course, Student student) { // Create the connection to the resource using (SqlConnection conn = new SqlConnection()) { // Create the connectionString conn.ConnectionString = "Data Source=tfs;Initial Catalog=study3;Integrated Security=True"; // Create the command SqlCommand command = new SqlCommand("select semester from study_course where course_id = '" + course.ID + "'" + "and student_id = '" + student.ID + "'" , conn); // Type of query set command.CommandType = CommandType.Text; // Connection is opened and query is executed conn.Open(); int i = (int)command.ExecuteScalar(); // Connection is then closed conn.Close(); // int returned return i; } }
public frmPlanOfStudy(string studID, string studName) { InitializeComponent(); LoggedInStudent = new Student(studID,studName); }