/// <summary> /// Resto in ascolto dei tasti premuti con la griglia attiva /// se è premuto il tasto delete lo intercetto e pongo la /// domanda se si è sicuri, in caso affermativo elimino la gestione /// </summary> /// <param name="sender">tastiera</param> /// <param name="e">tasto premuto</param> public void DeleteRow(object sender, KeyEventArgs e) { if (e.Key == Key.Delete) { DataGrid dg = sender as DataGrid; if (dg.SelectedIndex > 0) { MessageBoxResult result = MessageBox.Show("Attenzione verrà elemininata la location: " + ((RegistryLocation)dg.SelectedItem).Desc_Conto, "DAF-C Gestione Location", MessageBoxButton.YesNo, MessageBoxImage.Question); if (result == MessageBoxResult.Yes) { try { _services.DeleteLocation(((RegistryLocation)dg.SelectedItem).Id_Conto); LocationList = new ObservableCollection <RegistryLocation>(_services.GetRegistryLocationList()); } catch (Exception err) { MessageBox.Show("Errore nell'eliminazione della location: " + Environment.NewLine + err.Message); e.Handled = true; } } else { e.Handled = true; } } } }