Example #1
0
 private void Window_Loaded(object sender, RoutedEventArgs e)
 {
     expenses = DataStorage.ReadXML <ObservableCollection <Expense> >("ExpenseData.xml");
     if (expenses == null)
     {
         expenses = new ObservableCollection <Expense> {
             new Expense {
                 description = "Edit Description", category = "Others", amount = 0.0, expenseDate = DateTime.Today
             }
         };
         DataStorage.WriteXML <ObservableCollection <Expense> >(expenses, "ExpenseData.xml");
     }
     categories = GenerateCategory();
     Lbx_expenses.ItemsSource          = expenses;
     Lbx_categories.ItemsSource        = categories;
     Cbx_category.ItemsSource          = categoryNames;
     Cbx_filterByCategory.ItemsSource  = categoryNamesForFilter;
     Cbx_filterByCategory.SelectedItem = "All";
     ChangeTotalBudgetValues(totalBudget);
     UpdateTotalBudget(totalBudget);
     Tbx_filter.Text = "Enter text to Filter Expenses";
 }
Example #2
0
        private void Cbx_filterByCategory_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (Cbx_filterByCategory.SelectedItem == null)
            {
                Cbx_filterByCategory.SelectedItem = "All";
                return;
            }
            filterByCategory = Cbx_filterByCategory.SelectedItem.ToString();
            ObservableCollection <Expense> allExpenses = DataStorage.ReadXML <ObservableCollection <Expense> >("ExpenseData.xml");

            if (filterByCategory != "All")
            {
                ObservableCollection <Expense> filteredExpenses = new ObservableCollection <Expense>(from expense in allExpenses where expense.category.Equals(filterByCategory) select expense);
                Lbx_expenses.ItemsSource = filteredExpenses;
                Category category = (from cat in categories where cat.name.Equals(filterByCategory) select cat).First <Category>();
                Lbx_categories.SelectedItem = category;
            }
            else
            {
                Lbx_expenses.ItemsSource = allExpenses;
            }
        }
Example #3
0
        private ObservableCollection <Category> GetExistingCategories()
        {
            ObservableCollection <Category> existingCategories = DataStorage.ReadXML <ObservableCollection <Category> >("CategoryData.xml");

            return(existingCategories);
        }