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.");
        }