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(); } }
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(); } }