示例#1
0
        private void DeleteCategory()
        {
            СonfirmationViewModel confirmVM = new СonfirmationViewModel("Do you really want to delete this category?");

            Views.СonfirmationView confirmView = new Views.СonfirmationView();
            confirmView.DataContext = confirmVM;
            confirmView.ShowDialog();

            if (confirmVM.Result)
            {
                try
                {
                    storageHandler.RemoveCategory(SelectedCategory);
                }
                catch (FileNotFoundException ex)
                { MessageBox.Show($"File not found {ex.Message}."); }
                catch (InvalidOperationException ex)
                { MessageBox.Show($"Can't save data to file {ex.Message}."); }
                catch (Exception ex)
                { MessageBox.Show($"Something is wrong {ex.Message}."); }

                SelectedCategory = null;
                GetCategories();
            }
        }
        private void DeleteData()
        {
            СonfirmationViewModel confirmVM = new СonfirmationViewModel("Do you really want to delete this data?");

            Views.СonfirmationView confirmView = new Views.СonfirmationView();
            confirmView.DataContext = confirmVM;
            confirmView.ShowDialog();

            if (confirmVM.Result)
            {
                try
                {
                    storageHandler.RemoveData(SelectedData);
                }
                catch (FileNotFoundException ex)
                { MessageBox.Show($"File not found {ex.Message}."); }
                catch (InvalidOperationException ex)
                { MessageBox.Show($"Can't write data to file {ex.Message}."); }
                catch (Exception ex)
                { MessageBox.Show($"Something is wrong {ex.Message}."); }

                DataChanged();
            }
        }