Esempio n. 1
0
        /* 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;
        }
Esempio n. 2
0
        /* 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();
        }
Esempio n. 3
0
        /* 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);
        }
Esempio n. 4
0
        /* 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);
        }
Esempio n. 5
0
 public bool Insert(Pharmacies pharmacy)
 {
     return(pharmacyTable.InsertRecord(pharmacy));
 }
Esempio n. 6
0
 public bool UpdateWhereID(int ID, Pharmacies pharmacy)
 {
     return(pharmacyTable.EditRecord(ID, pharmacy));
 }
Esempio n. 7
0
 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();
 }