示例#1
0
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            var(name, surname) = (student_name__txt_box.Text, student_surname__txt_box.Text);

            if (string.IsNullOrEmpty(name) || string.IsNullOrEmpty(surname))
            {
                MessageBox.Show("Name or surname is empty.");
                return;
            }

            if (education__combo_box.SelectedItem == null)
            {
                MessageBox.Show("Educational level is empty.");
                return;
            }

            try
            {
                var birthday = new DateTime(
                    int.Parse(birthday_year__txt_box.Text),
                    int.Parse(birthday_month__txt_box.Text),
                    int.Parse(birthday_day__txt_box.Text));

                viewModel.AddStudent(new Student(new Person(name, surname, birthday),
                                                 (EducationalLevel)education__combo_box.SelectedItem));
            }
            catch (Exception)
            {
                MessageBox.Show("Wrong birthday date.");
            }
        }