Beispiel #1
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
        }