コード例 #1
0
        private void Add_Click(object sender, RoutedEventArgs e)
        {
            var dialog = new TeacherAddEditDialog();

            dialog.Title = "Добавить преподавателя";
            if (dialog.ShowDialog() == true)
            {
                var teacher = new Teacher {
                    Name = dialog.TeacherName
                };
                db.Teachers.Add(teacher);
                UpdateGrid();
            }
        }
コード例 #2
0
        private void Edit_Click(object sender, RoutedEventArgs e)
        {
            if (Data.SelectedItem == null || Data.SelectedItem as Teacher == null)
            {
                return;
            }
            var teacher = Data.SelectedItem as Teacher;

            var dialog = new TeacherAddEditDialog();

            dialog.Title       = "Редактировать преподавателя";
            dialog.TeacherName = teacher.Name;
            if (dialog.ShowDialog() == true)
            {
                teacher.Name = dialog.TeacherName;
                UpdateGrid();
            }
        }