/* 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); }
/* Context menu override */ protected override void OnDeleteClick(object sender, RoutedEventArgs e) { if (SelectedItems.Count != 1) { return; } MessageBoxResult result = MessageBoxes.MessageBoxShowDeleteMessage(); if (result == MessageBoxResult.No) { return; } Pharmacies phramacy = (Pharmacies)SelectedItem; if (!pharmacyData.DeleteWhereID(phramacy.ID)) { MessageBoxes.ShowError(MessageBoxes.DeleteErrorMessage); return; } itemsSource.RemoveAt(SelectedIndex); }
public bool Insert(Pharmacies pharmacy) { return(pharmacyTable.InsertRecord(pharmacy)); }
public bool UpdateWhereID(int ID, Pharmacies pharmacy) { return(pharmacyTable.EditRecord(ID, pharmacy)); }
public bool SelectWhereID(int ID, out Pharmacies pharmacy) { return(pharmacyTable.SelectRecord(ID, out pharmacy)); }
public PharmaciesDialog(Pharmacies _pharmacy, DialogModes _dialogMode, DependencyObject parent = null) : base(_dialogMode, parent) { pharmacy = _pharmacy; InitializeComponent(); }