Exemplo n.º 1
0
        private void GradeModification(object sender, RoutedEventArgs e)
        {
            GradeWindow gw = new GradeWindow
            {
                comboBoxCourses =
                {
                    ItemsSource = _factory.GetRepository().Courses,
                    SelectedIndex = 0
                }
            };

            if (gw.ShowDialog() != true)
                return;

            //Since the starting index is predetermined, the Course value cannot be null
            var newGrade = new Grade(gw.comboBoxCourses.SelectionBoxItem as Course, int.Parse(gw.textBoxMark.Text));

            try
            {
                _factory.GetRepository().AddGrade(newGrade);
            }
            catch (ArgumentNullException)
            {
                MessageBox.Show("Could not add/edit the grade. Please try again.", "Null error", MessageBoxButton.OK,
                    MessageBoxImage.Error);
            }
            catch (ArgumentException)
            {
                _factory.GetRepository().EditGrade(newGrade);
            }
        }
Exemplo n.º 2
0
        private void GradeModification(object sender, RoutedEventArgs e)
        {
            GradeWindow gw = new GradeWindow
            {
                comboBoxCourses =
                {
                    ItemsSource   = _factory.GetRepository().Courses,
                    SelectedIndex = 0
                }
            };

            if (gw.ShowDialog() != true)
            {
                return;
            }

            //Since the starting index is predetermined, the Course value cannot be null
            var newGrade = new Grade(gw.comboBoxCourses.SelectionBoxItem as Course, int.Parse(gw.textBoxMark.Text));

            try
            {
                _factory.GetRepository().AddGrade(newGrade);
            }
            catch (ArgumentNullException)
            {
                MessageBox.Show("Could not add/edit the grade. Please try again.", "Null error", MessageBoxButton.OK,
                                MessageBoxImage.Error);
            }
            catch (ArgumentException)
            {
                _factory.GetRepository().EditGrade(newGrade);
            }
        }
 private void buttonEdit_Click(object sender, RoutedEventArgs e)
 {
     var g = new GradeWindow(ref _repository, sender);
     g.ShowDialog();
 }