public Form1() { InitializeComponent(); database = new RegistrationDatabase(); UpdateCourseListLabel(); UpdateComboBox(); }
private void addCourseButton_Click(object sender, EventArgs e) { Course newCourse = new Course() { Department = courseDepartmentTextBox.Text, Name = courseNameTextBox.Text, Code = courseCodeTextBox.Text, Credits = 3 }; database.Courses.Add(newCourse); // should always try catch when doing database SaveChanges try { database.SaveChanges(); } catch (Exception ex) { MessageBox.Show(ex.ToString()); database.Dispose(); database = new RegistrationDatabase(); } UpdateCourseListLabel(); UpdateComboBox(); }
public Sections(RegistrationDatabase database) { InitializeComponent(); this.database = database; RefreshListBox(); }