示例#1
0
        protected override void OnEditClick(object sender, RoutedEventArgs e)
        {
            if (SelectedItems.Count != 1)
            {
                return;
            }

            int        selectedID = ((Dealers)SelectedItem).ID;
            DealerInfo dealerInfo = new DealerInfo();

            if (!dealersData.SelectWhereID(selectedID, out dealerInfo))
            {
                MessageBoxes.ShowError(MessageBoxes.PreviewErrorMessage);
                return;
            }

            DealersDialog drugsDialog  = new DealersDialog(dealerInfo, DialogModes.Edit, this);
            bool?         dialogResult = drugsDialog.ShowDialog();

            if (dialogResult == false)
            {
                return;
            }

            if (!dealersData.UpdateWhereID(selectedID, dealerInfo))
            {
                MessageBoxes.ShowError(MessageBoxes.EditErrorMessage);
                return;
            }

            itemsSource[SelectedIndex] = dealerInfo.dealer;
        }
示例#2
0
        /* Context menu override */
        protected override void OnAddClick(object sender, RoutedEventArgs e)
        {
            DealersDialog drugsDialog  = new DealersDialog(new DealerInfo(), DialogModes.Add, this);
            bool?         dialogResult = drugsDialog.ShowDialog();

            if (dialogResult == false)
            {
                return;
            }

            DealerInfo dealerInfo = drugsDialog.dealerInfo;

            if (!dealersData.Insert(dealerInfo.dealer))
            {
                MessageBoxes.ShowError(MessageBoxes.AddErrorMessage);
                return;
            }

            itemsSource.Add(dealerInfo.dealer);
        }
示例#3
0
        /* Context menu override */
        protected override void OnPreviewClick(object sender, RoutedEventArgs e)
        {
            if (SelectedItems.Count != 1)
            {
                return;
            }

            int        selectedID = ((Dealers)SelectedItem).ID;
            DealerInfo dealerInfo = new DealerInfo();

            if (!dealersData.SelectWhereID(selectedID, out dealerInfo))
            {
                MessageBoxes.ShowError(MessageBoxes.PreviewErrorMessage);
                return;
            }

            DealersDialog drugsDialog = new DealersDialog(dealerInfo, DialogModes.Preview, this);

            drugsDialog.ShowDialog();
        }