/* Context menu override */ protected override void OnEditClick(object sender, RoutedEventArgs e) { if (SelectedItems.Count != 1) { return; } Pharmacies pharmacy = (Pharmacies)SelectedItem; if (!pharmacyData.SelectWhereID(pharmacy.ID, out pharmacy)) { MessageBoxes.ShowError(MessageBoxes.EditErrorMessage); return; } PharmaciesDialog phramacyDialog = new PharmaciesDialog(pharmacy, DialogModes.Edit, this); bool? dialogResult = phramacyDialog.ShowDialog(); if (dialogResult == false) { return; } pharmacy = phramacyDialog.pharmacy; if (!pharmacyData.UpdateWhereID(pharmacy.ID, pharmacy)) { MessageBoxes.ShowError(MessageBoxes.EditErrorMessage); return; } itemsSource[SelectedIndex] = pharmacy; }
/* 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); }