Ejemplo n.º 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.");
        }
Ejemplo n.º 2
0
 private void ComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
 {
     for (int i = 0; i < comboBox.Items.Count; i++)
     {
         if (courses[i].getCourseId() == (string)comboBox.Items.CurrentItem)
         {
             course = courses[i];
             string courseIdSelected = courses[i].getCourseId();
             Course currentSelection = courses[i];
             string courseDesc       = currentSelection.getCourseDesc();
             this.courseIdtxtblk.Text       = currentSelection.getCourseId();
             this.coursedesctxtblk.Text     = courseDesc;
             this.seatsremainingtxtblk.Text = (currentSelection.getClassSize() - currentSelection.getStudentsRegistered()).ToString();
             this.credithourstxtblk.Text    = currentSelection.getCreditHours().ToString();
         }
     }
 }