private void button_Click(object sender, RoutedEventArgs e)
        {
            choice = (Course)(this.comboBox.SelectedItem);
            int totalCredits = Convert.ToInt32(textBox.Text);


            if (choice.IsRegisteredAlready() == false && totalCredits < 9)
            {
                this.listBox.Items.Add(choice);
                choice.SetToRegistered();
                totalCredits   = totalCredits + 3;
                textBox.Text   = Convert.ToString(totalCredits);
                label3.Content = String.Format("Registration confirmed for course {0}", choice);
            }
            else if (choice.IsRegisteredAlready() == true)
            {
                label3.Content = String.Format("You have already registered for this {0} course.", choice);
            }
            else if (totalCredits == 9)
            {
                label3.Content = ("You can not register for more than 9 credit hours.");
            }



            // TO DO - Create code to validate user selection (the choice object)
            // and to display an error or a registation confirmation message accordinlgy
            // Also update the total credit hours textbox if registration is confirmed for a selected course
        }
        private void button_Click(object sender, RoutedEventArgs e)
        {
            choice = (Course)(this.comboBox.SelectedItem);
            string courseName = choice.ToString();

            switch (validateUserSelection(choice))
            {
            case 0:    //Display error confirmation: Already registered
                label3.Content = "You have already registered for this course " + courseName;
                break;

            case 1:     //Display error confirmation: Too many credit hours
                label3.Content = "You cannot register for more than 9 credit hours.";
                break;

            case 2:
                choice.SetToRegistered();     //Sets registration bool to true (See ValidateUserSelection function)

                listBox.Items.Add(choice);    // Display a registration confirmation message
                label3.Content = "Registration confirmed for course " + courseName;

                TotalCreditHours += 3;     // update the total credit hours textbox if registration is confirmed for a selected course
                textBox.Text      = TotalCreditHours.ToString();

                break;
            }
        }
        private void button_Click(object sender, RoutedEventArgs e)
        {
            choice = (Course)(this.comboBox.SelectedItem);

            /**************************************************************************************************
             *
             * // TO DO - Create code to validate user selection (the choice object)
             * // and to display an error or a registation confirmation message accordinlgy
             * // Also update the total credit hours textbox if registration is confirmed for a selected course
             *
             *                                  COMPLETED 12/13/2019 - RH
             ***************************************************************************************************/

            /*******************************RH CODE ADDED FOR PROJECT IN THIS FUNCTION BELOW*******************/

            if (this.listBox.Items.Contains(choice) && choice.IsRegisteredAlready())
            {
                this.textBlock1.Text = "You have already registered for this " + choice.ToString() + " course"; // Add string to custom text block and print it to window.
            }
            else if (creditHours < 9)                                                                           // Total credit hours cannot exceed 9 credit hours
            {
                this.listBox.Items.Add(choice);                                                                 // Add each select to the output box of course.
                choice.SetToRegistered();
                creditHours         += 3;                                                                       // Each course has 3 credit hours each and is updated.
                this.textBox.Text    = Convert.ToString(creditHours);                                           // TextBox is the credit hour text box displayed.
                this.textBlock1.Text = "Registration confirmed for course " + choice.ToString();                // Print string when each eligible course is added.
            }
            else
            {
                this.textBlock1.Text = "You cannot register for more than 9 credit hours.";
            }
        }
#pragma warning disable IDE1006 // Naming Styles
        private void button_Click(object sender, RoutedEventArgs e)
#pragma warning restore IDE1006 // Naming Styles
        {
            //Adds the choice to the registered courses textbox
            choice = (Course)(this.comboBox.SelectedItem);

            //Performs the validation

            //Starts a nested if statement that first checks if class
            //has already been registered
            if (choice.IsRegisteredAlready() == true)
            {
                label3.Content = ("You have already registered for this course " + choice + ".");
            }

            //Validates no more that 9 credits have been chosen
            else if (this.textBox.Text == "9")
            {
                label3.Content = ("You cannot register for more than 9 credit hours.");
            }

            //If class is not registered it performs this else statement
            else
            {
                //Adds choice to list box
                this.listBox.Items.Add(choice);
                //Assigns course to registered
                choice.SetToRegistered();

                //Starts the Total credit hours to 0
                //If credit hours is 0 once course is registered it adds 3 credits
                if (this.textBox.Text == "")
                {
                    this.textBox.Text = "3";
                }

                //If credit hours is 3 once course is registered it adds 3 credits
                else if (this.textBox.Text == "3")
                {
                    this.textBox.Text = "6";
                }

                //If credit hours is 6 once course is registered it adds 3 credits
                else if (this.textBox.Text == "6")
                {
                    this.textBox.Text = "9";
                }

                //After course is sucessfully registered it displays confirmation
                label3.Content = ("Registration confirmed for course " + choice + ".");
            }
        }
예제 #5
0
        private void button_Click(object sender, RoutedEventArgs e)
        {
            // TO DO - Create code to validate user selection (the choice object) -- DONE

            choice = (Course)(this.comboBox.SelectedItem);

            // and to display an error or a registation confirmation message accordinlgy -- DONE added label to layout in Main XAML File to display messages.

            if (choice.IsRegisteredAlready() == true)
            {
                userMsg.Content = "You are already registered for this course.";
            }

            else if (this.textBox.Text == "9")
            {
                userMsg.Content = "You have registered for the maximum number of credits (9).";
            }

            else
            {
                // Also update the total credit hours textbox if registration is confirmed for a selected course -- DONE

                choice.SetToRegistered();
                this.listBox.Items.Add(choice);

                if (this.textBox.Text == "")
                {
                    this.textBox.Text = "3";
                }

                else if (this.textBox.Text == "3")
                {
                    this.textBox.Text = "6";
                }

                else if (this.textBox.Text == "6")
                {
                    this.textBox.Text = "9";
                }

                userMsg.Content = "You have registered for " + choice + ".";
            }
        }
예제 #6
0
        private void button_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                bool   registerValidate = false;
                String hoursString      = "";
                String courseName       = "";

                choice           = (Course)(comboBox.SelectedItem);
                registerValidate = choice.IsRegisteredAlready();
                courseName       = Convert.ToString(choice.getName());

                if (courseHours >= 9)
                {
                    label3.Foreground = Brushes.Red;
                    label3.Content    = "You cannot register for more than 9 credit hours";
                }

                else if (registerValidate == false)
                {
                    choice.SetToRegistered();
                    listBox.Items.Add(choice);
                    courseHours      += 3;
                    hoursString       = Convert.ToString(courseHours);
                    textBox.Text      = hoursString;
                    label3.Foreground = Brushes.Black;
                    label3.Content    = "Registration confirmed for " + courseName;
                }

                else if (registerValidate == true)
                {
                    label3.Foreground = Brushes.Red;
                    label3.Content    = "You are already registered for " + courseName;
                }
            }
            catch (NullReferenceException)
            {
                label3.Foreground = Brushes.Red;
                label3.Content    = "No selection made. Please make a selection";
            }
        }
        public void button_Click(object sender, RoutedEventArgs e)
        {
            //Adds choice to the selected courses
            choice = (Course)(this.comboBox.SelectedItem);

            //Determines if you are already registered for the class
            if (choice.IsRegisteredAlready() == true)
            {
                MessageBox.Show("User is already registered in this course");
            }
            //Stops user after 9 credits
            else if (this.textBox.Text == "9")
            {
                MessageBox.Show("User is already registered in 3 courses");
            }

            else

            {
                this.listBox.Items.Add(choice);
                choice.SetToRegistered();

                if (this.textBox.Text == "")
                {
                    this.textBox.Text = "3";
                }

                else if (this.textBox.Text == "3")
                {
                    this.textBox.Text = "6";
                }

                else if (this.textBox.Text == "6")
                {
                    this.textBox.Text = "9";
                }

                MessageBox.Show("Congratulations! User registered in " + choice + ".");
            }
        }
        private void button_Click(object sender, RoutedEventArgs e)
        {
            choice = (Course)(this.comboBox.SelectedItem);
            int    creditHours = 0;
            String message     = "";

            // Validate user selection
            if (choice.IsRegisteredAlready())
            {
                message = "Already registered for course: " + choice.ToString();
            }
            else
            {
                if (this.textBox.Text != "") // First selection has "" for the Text value.
                {
                    creditHours = int.Parse(this.textBox.Text);
                }

                if (creditHours >= 9)
                {
                    message = "You cannot register for more than 9 credit hours.";
                }
                else
                {
                    message = "Registration confirmed for course " + choice.ToString() + ".";
                    choice.SetToRegistered();

                    // Update credit hours
                    creditHours += 3;
                    this.listBox.Items.Add(choice.ToString());
                    this.textBox.Text = creditHours.ToString();
                }
            }
            // Display error or confirmation
            this.label3.Content = message;
        }
예제 #9
0
        private void button_Click(object sender, RoutedEventArgs e)
        {
            choice = (Course)(this.comboBox.SelectedItem);

            /*
             * Section added by Joshua Langer 2/15/2021
             */
            if (choice.IsRegisteredAlready())                                         //confirm if registration for the selected course has happened.
            {
                label3.Content = "You are already registered for that course.";       //UI note for the user.
            }
            else if (!choice.IsRegisteredAlready() && courseHours < 9)                //if the course is not currently registered and the user is under 9 credit hours
            {
                listBox.Items.Add(choice);                                            //register the course
                label3.Content = "Registration Confirmed for course " + choice + "."; //UI note for the user, showing they successfully registered for their course.
                choice.SetToRegistered();                                             //set the registration flag
                courseHours += 3;                                                     //add the credit hours to the user
                textBox.Text = courseHours.ToString();
            }
            else if (courseHours >= 9)                                                 //if the user has 9 or more credit hours, deny their selection.
            {
                label3.Content = "You can not register for more than 9 credit hours."; //UI note for the user explaining they can't register for more courses.
            }
        }
        private void button_Click(object sender, RoutedEventArgs e)
        {
            /*int numericalCourseIdentifier = 0;
             *
             * choice = (Course)(this.comboBox.SelectedItem);
             * string chosenCourseName = choice.ToString(); //Retrieves string of course name
             *
             * numericalCourseIdentifier = IdentifyCourse(chosenCourseName, numericalCourseIdentifier); //Takes the course name and converts it to an integer representative
             *
             * switch (ValidateUserSelection(numericalCourseIdentifier, firstChoice, secondChoice, thirdChoice, TotalCredits)) //Updates the label3 text based on selection
             * {
             *  case -1:
             *      label3.Content = chosenCourseName + " is not a recognized course."; //Not really necessary, but I included it just in case
             *      break;
             *  case -2:
             *      label3.Content = "You have already registered for this " + chosenCourseName + " course.";
             *      break;
             *  case -3:
             *      label3.Content = "You cannot register for more than 9 credit hours.";
             *      break;
             *  case -4:
             *      label3.Content = "Registration confirmed for course " + chosenCourseName; //Updates label to confirm registration
             *
             *      TotalCredits += 3;
             *      textBox.Text = TotalCredits.ToString();
             *
             *      if (firstChoice == 0)
             *          firstChoice = numericalCourseIdentifier;
             *      else if (secondChoice == 0)
             *          secondChoice = numericalCourseIdentifier;
             *      else if (thirdChoice == 0)
             *          thirdChoice = numericalCourseIdentifier;
             *
             *      listBox.Items.Add(choice); //Update the listBox with each registration
             *
             *      break;
             * }
             * choice = (Course)(this.comboBox.SelectedItem);
             * string chosenCourseName = choice.ToString(); //Retrieves string of course name
             *
             * switch (validateSelection(choice))
             * {
             *  case 1:
             *      label3.Content = "You have already registered for this " + chosenCourseName + " course.";
             *      break;
             *  case 2:
             *      label3.Content = "You cannot register for more than 9 credit hours.";
             *      break;
             *  case 0:
             *      label3.Content = "Registration confirmed for course " + chosenCourseName; //Updates label to confirm registration
             *      choice.SetToRegistered();
             *      TotalCredits += 3;
             *      textBox.Text = TotalCredits.ToString();
             *      listBox.Items.Add(choice); //Update the listBox with each registration
             *      break;
             * }
             * }
             *
             * int ValidateUserSelection (int choice, int firstChoice, int secondChoice, int thirdChoice, int totalCredit)
             * {
             * if (choice < 1 || choice > 7)
             *  return -1;
             * else if (choice == firstChoice || choice == secondChoice || choice == thirdChoice)
             *  return -2;
             * else if (totalCredit > 8)
             *  return -3;
             * return -4;
             */
            choice = (Course)(this.comboBox.SelectedItem);
            string chosenCourseName = choice.ToString(); //Retrieves string of course name

            switch (ValidateUserSelection(choice))
            {
            case 1:
                label3.Content = "You have already registered for this " + chosenCourseName + " course.";
                break;

            case 2:
                label3.Content = "You cannot register for more than 9 credit hours.";
                break;

            case 0:
                label3.Content = "Registration confirmed for course " + chosenCourseName;     //Updates label to confirm registration
                choice.SetToRegistered();
                TotalCredits += 3;
                textBox.Text  = TotalCredits.ToString();
                listBox.Items.Add(choice);     //Update the listBox with each registration
                break;
            }
        }