/* Context menu override */ protected override void OnPreviewClick(object sender, RoutedEventArgs e) { if (SelectedItems.Count != 1) { return; } Pharmacies pharmacy = ((Pharmacies)SelectedItem); if (!pharmacyData.SelectWhereID(pharmacy.ID, out pharmacy)) { MessageBoxes.ShowError(MessageBoxes.PreviewErrorMessage); return; } PharmaciesDialog pharmacyDialog = new PharmaciesDialog(pharmacy, DialogModes.Preview, this); pharmacyDialog.ShowDialog(); }
/* Context menu override */ protected override void OnAddClick(object sender, RoutedEventArgs e) { PharmaciesDialog pharmacyDialog = new PharmaciesDialog(new Pharmacies(), DialogModes.Add, this); bool? dialogResult = pharmacyDialog.ShowDialog(); if (dialogResult == false) { return; } Pharmacies pharmacy = pharmacyDialog.pharmacy; if (!pharmacyData.Insert(pharmacy)) { MessageBoxes.ShowError(MessageBoxes.AddErrorMessage); return; } itemsSource.Add(pharmacy); }