private void Course_Registration_Load(object sender, EventArgs e) { // should check that they are not empty first // get distinct years yearComboBox.DataSource = collegeDB.executeFetchCommand("select distinct s.[year] from section s;").Tables[0]; // get every department departmentComboBox.DataSource = collegeDB.executeFetchCommand("select d.name from department d;").Tables[0]; // get distinct terms termComboBox.DataSource = collegeDB.executeFetchCommand("select distinct s.[term] from section s;").Tables[0]; }
/// <summary> /// Adds the courses to the database. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void Register_Button_Click(object sender, EventArgs e) { SQLController SQLhandler = new SQLController(); foreach (Dictionary <string, string> course in courses) { // Check if prerequisites are met if (course.TryGetValue("Course", out string courseID)) { // query for checking prerequisites String query = "EXEC dbo.checkPreRequsite @studentID = '" + studentID + "', @courseID = '" + courseID + "';"; DataSet queryResult = SQLhandler.executeFetchCommand(query); // pass that data set over if (queryResult.Tables.Count > 0) { // If prerequisites are all met if (queryResult.Tables[0].Rows.Count == 0) { // Get section if (course.TryGetValue("Section", out string sectionID)) { // query for inserting for section query = "EXEC dbo.insertSection @studentID = '" + studentID + "', @sectionID = '" + sectionID + "';"; SQLhandler.executeSetCommand(query); Error_Text.Visible = true; Error_Text.Text = "Yay you registered into your classes... b.b.baka it's not like I wanted you to register or anything o.o"; Error_Text.ForeColor = Color.Green; } else { Error_Text.Visible = true; Error_Text.Text = "Error adding the sections (ಠ_ಠ)"; return; } } // Prerequisites are not met else { Error_Text.Visible = true; Error_Text.Text = @"You do not have the cowwect prerequisites (ノಠ ∩ಠ)ノ彡( \o°o)\"; return; } } // Error getting prerequisites else { Error_Text.Visible = true; Error_Text.Text = "Ewwow checking prerequisites (・`ω´・) "; return; } } } //TODO: call subscribed method }
private void Student_Homepage_Load(object sender, EventArgs e) { String query = "SELECT first_name, last_name FROM student WHERE s_id = '" + this.student_id + "';"; DataSet queryResult = collegeDB.executeFetchCommand(query); if (queryResult.Tables[0].Rows.Count > 0) { StudentNameLabel.Text = queryResult.Tables[0].Rows[0][0].ToString() + " " + queryResult.Tables[0].Rows[0][1].ToString(); } else { StudentNameLabel.Text = "Name not found"; } }
private void Button1_Click(object sender, EventArgs e) { int student_id; if (Int32.TryParse(login_input.Text, out student_id)) { student_id = Int32.Parse(login_input.Text); if (collegeDB.executeFetchCommand("SELECT * FROM student s WHERE s.s_id = '" + student_id.ToString() + "';").Tables[0].Rows.Count > 0) { this.Hide(); Student_Homepage StudentHomepageForm = new Student_Homepage(student_id); StudentHomepageForm.ShowDialog(); this.Close(); } else { // shame them shameText.Text = "Shame on you. Pwease enter a valid student ID"; shameText.ForeColor = Color.FromName("Red"); shameText.Visible = true; } } }
private void EnrolledCourses_Load(object sender, EventArgs e) { enrolledCoursesDataGridView1.DataSource = collegeDB.executeFetchCommand("EXEC checkEnrolled @studentID = '" + this.studentID + "';").Tables[0]; }