private void InitCarsEditBtnsHandlers() { _carsContainer.AddB.MouseLeftButtonDown += (object sender, MouseButtonEventArgs e) => { NewCarRecordDialog newCarDialog = new NewCarRecordDialog(_connection); if (newCarDialog.DialogResult == true) { AddTableTab(_carRentalDb.Cars.TableName); } }; _carsContainer.EditB.MouseLeftButtonDown += (object sender, MouseButtonEventArgs e) => { DataRowView row = null; try { row = _carsContainer.DataGrid.SelectedItem as DataRowView; NewCarRecordDialog editCar = new NewCarRecordDialog(_connection, row); if (editCar.DialogResult == true) { AddTableTab(_carRentalDb.Cars.TableName); } } catch (Exception) { MessageBox.Show("Не выбрано ни одной строки"); } }; _carsContainer.DeleteB.MouseLeftButtonDown += (object sender, MouseButtonEventArgs e) => { DataRowView row = null; try { row = _carsContainer.DataGrid.SelectedItem as DataRowView; string message = "Удалить из базы автомобиль Гос.Номер: " + row[1].ToString() + "?"; string caption = "Удалить запись"; MessageBoxButton buttons = MessageBoxButton.OKCancel; MessageBoxImage icon = MessageBoxImage.Question; MessageBoxResult defaultResult = MessageBoxResult.OK; MessageBoxResult result = MessageBox.Show(message, caption, buttons, icon, defaultResult); if (result == MessageBoxResult.OK) { CarRentalDbWorker.DeleteCar(_connection, row[1].ToString()); AddTableTab(_carRentalDb.Cars.TableName); } } catch (Exception) { MessageBox.Show("Не выбрано ни одной строки"); } }; _carsContainer.NewRentB.MouseLeftButtonDown += (object sender, MouseButtonEventArgs e) => { DataRowView row = null; try { row = _carsContainer.DataGrid.SelectedItem as DataRowView; FormalizeRent NewRent = new FormalizeRent(_connection, row); if (NewRent.DialogResult == true) { AddTableTab(_carRentalDb.Cars.TableName); } } catch (Exception) { MessageBox.Show("Не выбрано ни одной строки"); } }; }