예제 #1
0
 public Form1()
 {
     InitializeComponent();
     database = new RegistrationDatabase();
     UpdateCourseListLabel();
     UpdateComboBox();
 }
예제 #2
0
        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();
        }