Esempio n. 1
0
        private void DeleteClick(object sender, RoutedEventArgs e)
        {
            MessageBoxButton button = MessageBoxButton.YesNo;
            MessageBoxImage  icon   = MessageBoxImage.Warning;
            //MessageBoxResult result = MessageBox.Show(MessageBoxDeleteConfirm, MessageBoxDeleteConfirmCaption, button, icon);
            MessageBoxResult result = MessageBox.Show(TerritoriesDataContext.WPFMessageAndLabelForList.MessageBoxDeleteConfirm,
                                                      TerritoriesDataContext.WPFMessageAndLabelForList.MessageBoxDeleteConfirmCaption, button, icon);
            string error = null;

            switch (result)
            {
            case MessageBoxResult.Yes:
                ModelNotifiedForTerritories itemSelected = (ModelNotifiedForTerritories)DataGridTerritories.SelectedItem;
                dataConnection.DeleteData(itemSelected, out error);
                if (string.IsNullOrEmpty(error))
                {
                    TerritoriesDataContext.modelNotifiedForTerritoriesMain.Remove(itemSelected);
                }
                break;

            case MessageBoxResult.No:
                return;
            }

            if (error != null)
            {
                MessageBox.Show(error);
            }
            else
            {
                //MessageBox.Show(MessageBoxDeleteOK);
                MessageBox.Show(TerritoriesDataContext.WPFMessageAndLabelForList.MessageBoxDeleteOK);
                btnReload_Click(null, null);
            }
        }
Esempio n. 2
0
        private void btnDelete_Click(object sender, RoutedEventArgs e)
        {
            btnNew.Visibility = Visibility.Visible;
            string           messageBoxText = "Do you want to delete changes?";
            string           caption        = "Word Processor";
            MessageBoxButton button         = MessageBoxButton.YesNo;
            MessageBoxImage  icon           = MessageBoxImage.Warning;
            MessageBoxResult result         = MessageBox.Show(messageBoxText, caption, button, icon);
            string           error          = null;

            switch (result)
            {
            case MessageBoxResult.Yes:
                dataConnection.DeleteData(TerritoriesDataContext.modelNotifiedForTerritoriesMain, out error);
                break;

            case MessageBoxResult.No:
                return;
            }

            if (error != null)
            {
                MessageBox.Show(error);
            }
            else
            {
                btnNew_Click(null, null);
                MessageBox.Show("Deleted");
            }
        }