Beispiel #1
0
        private void fill_transactionDataGrid()
        {
            balanceDatabaseOperationsClass balanceDatabaseOperations = new balanceDatabaseOperationsClass();
            DataTable table = balanceDatabaseOperations.getTransactionTable();

            transactionDataGrid.ItemsSource = table.DefaultView;
        }
        private void loadCategoryDataGrid()
        {
            balanceDatabaseOperationsClass balanceDatabaseOperations = new balanceDatabaseOperationsClass();
            DataTable table = balanceDatabaseOperations.getCategoryTable();

            categoryDataGrid.ItemsSource = table.DefaultView;
        }
 private void submitButton_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         balanceDatabaseOperationsClass balanceDatabaseOperations = new balanceDatabaseOperationsClass();
         balanceDatabaseOperations.addCategory(categoryNameTextbox.Text);
         this.Close();
     }
     catch (ArgumentException exception)
     {
         MessageBox.Show("Category with this name already exists");
         categoryNameTextbox.Text = "";
     }
     catch (Exception exception)
     {
         MessageBox.Show(exception.ToString());
         categoryNameTextbox.Text = "";
     }
 }
        private void deleteButton_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                balanceDatabaseOperationsClass balanceDatabaseOperations = new balanceDatabaseOperationsClass();
                DataRowView row          = categoryDataGrid.SelectedItem as DataRowView;
                string      categoryName = row["CategoryName"].ToString();
                balanceDatabaseOperations.deleteCategory(categoryName);
            }
            catch (ArgumentException exception)
            {
                MessageBox.Show("You cannot delete 'Other' category");
            }
            catch (NullReferenceException exception)
            {
                MessageBox.Show("You have not checked anything to delete");
            }

            refresh();
        }