private void btnEdit_Click(object sender, RoutedEventArgs e) { WindowNewClient wnClient = new WindowNewClient { Title = "Редактирование должности", Owner = this }; Client role = Clients.SelectedItem as Client; if (role != null) { Client tempRole = role.ShallowCopy(); wnClient.DataContext = tempRole; if (wnClient.ShowDialog() == true) { role.FirstName = tempRole.FirstName; role.LastName = tempRole.LastName; role.Status = tempRole.Status; role.Phone = tempRole.Phone; role.Email = tempRole.Email; Clients.ItemsSource = null; Clients.ItemsSource = vmClient.ClientPerson; } } else { MessageBox.Show("Необходимо выбрать запись для редактированния", "Предупреждение", MessageBoxButton.OK, MessageBoxImage.Warning); } }
private void btnAdd_Click(object sender, RoutedEventArgs e) { WindowNewClient wnClient = new WindowNewClient { Title = "Новый клиент", Owner = this }; // формирование кода новой должности int maxId = vmClient.MaxId() + 1; Client role = new Client { Id = maxId }; wnClient.DataContext = role; if (wnClient.ShowDialog() == true) { vmClient.ClientPerson.Add(role); } }