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);

            /**************************************************************************************************
             *
             * // 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.";
            }
        }
 int ValidateUserSelection(Course selectedCourse)
 {
     if (selectedCourse.IsRegisteredAlready())
     {
         return(1);
     }
     else if (TotalCredits > 8)
     {
         return(2);
     }
     return(0);
 }
#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 + ".");
            }
        }
        private int validateUserSelection(Course selectedCourse) //Create code to validate user selection (the choice object)

        {
            if (selectedCourse.IsRegisteredAlready()) //Checks to see if course is already registered
            {
                return(0);
            }
            else if (TotalCreditHours > 8) //Checks to see if exceeded 8/ reached 9 credit hours
            {
                return(1);
            }
            return(2);
        }
Exemple #6
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.
            }
        }
Exemple #7
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 + ".";
            }
        }
Exemple #8
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;
        }