Beispiel #1
0
        private void Acceptchangebtn_Click(object sender, RoutedEventArgs e)
        {
            //sends data in textboxes to SQL database
            choice.setCourseId(courseidtxtbox.Text);
            choice.setName(coursenametxtbox.Text);
            choice.setCourseDesc(descriptiontxtbox.Text);
            choice.setCreditHours(Convert.ToInt32(credithourstxtbox.Text));
            choice.setClassSize(Convert.ToInt32(classsizetxtbox.Text));
            choice.setStudentsRegistered(Convert.ToInt32(registeredtxtbox.Text));
            SqlCommand courseUpdateQuery = new SqlCommand("UPDATE classes SET courseId = '" + choice.getCourseId() + "', name = '" + choice.getName() + "', credithours = " + choice.getCreditHours() + ", classSize = " + choice.getClassSize() + ", studentsRegistered = " + choice.getStudentsRegistered() + ", courseDescription = '" + choice.getCourseDesc() + "' WHERE courseId = '" + choice.getCourseId() + "'", clsDB.Get_DB_Connection());

            courseUpdateQuery.ExecuteNonQuery();
            clsDB.Close_DB_Connection();
            MessageBox.Show(choice.getCourseId() + " was successfully updated.");
        }
Beispiel #2
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";
            }
        }