// ====================================================================
        // Update the Data Grid View
        // ====================================================================
        private void UpdateDataGridView()
        {
            // don't do anything if budget is not yest defined
            if (budget == null)
            {
                return;
            }
            // filter options
            bool FilterFlag = cbFilterCategories.IsChecked == true;
            int  id         = -1;

            if (cmbCategories.SelectedItem != null)
            {
                id = ((Category)cmbCategories.SelectedItem).Id;
            }

            // ----------------------------------------------------------------
            // standard display
            // ----------------------------------------------------------------
            if (cbByCategory.IsChecked != true && cbByMonth.IsChecked != true)
            {
                // create columns for standard display
                CreateDataGridStandardDisplay();

                // set the ItemSource
                dataBudget.ItemsSource = null;
                dataBudget.ItemsSource = budget.GetExpenses(dpStartDate.SelectedDate, dpEndDate.SelectedDate, FilterFlag, id);
            }
            // ----------------------------------------------------------------
            // total by month
            // ----------------------------------------------------------------
            if (cbByMonth.IsChecked == true && cbByCategory.IsChecked != true)
            {
                MonthDisplayMode();

                dataBudget.ItemsSource = null;
                dataBudget.ItemsSource = budget.GetExpensesByMonth(dpStartDate.SelectedDate, dpEndDate.SelectedDate, FilterFlag, id);
            }

            // ----------------------------------------------------------------
            // total by category
            // ----------------------------------------------------------------
            if (cbByMonth.IsChecked != true && cbByCategory.IsChecked == true)
            {
                CategoryDisplayMode();

                dataBudget.ItemsSource = null;
                dataBudget.ItemsSource = budget.GetExpensesByCategory(dpStartDate.SelectedDate, dpEndDate.SelectedDate, FilterFlag, id);
            }
            // ----------------------------------------------------------------
            // total by category and month
            // ----------------------------------------------------------------
            if (cbByMonth.IsChecked == true && cbByCategory.IsChecked == true)
            {
                CategoryAndMonthDisplayMode();

                dataBudget.ItemsSource = null;
                dataBudget.ItemsSource = budget.GetExpensesByCategoryAndMonth(dpStartDate.SelectedDate, dpEndDate.SelectedDate, FilterFlag, id);
            }
        }
        // ====================================================================
        // Create the Columns for the DataGrid by Category And Month Display mode
        // ====================================================================
        private void CreateDataGridCategoryAndMonthDisplayMode(DateTime?StartDate, DateTime?EndDate, bool Flag, int ID)
        {
            dataBudget.Columns.Clear();
            dataBudget.ItemsSource = null;
            dataBudget.ItemsSource = budget.GetExpensesByCategoryAndMonth(StartDate, EndDate, Flag, ID);

            //Momth column
            var col = new DataGridTextColumn();

            col.Header  = "Months";
            col.Binding = new Binding("Month");
            dataBudget.Columns.Add(col);

            //column for each category in budget
            foreach (var item in budget.GetExpensesByCategory(StartDate, EndDate, Flag, ID))
            {
                string category = item.Category;
                col         = new DataGridTextColumn();
                col.Header  = category;
                col.Binding = new Binding(category);
                col.Binding.StringFormat = "F2";
                dataBudget.Columns.Add(col);
            }

            //column for total
            col         = new DataGridTextColumn();
            col.Header  = "Total";
            col.Binding = new Binding("Total");
            col.Binding.StringFormat = "F2";
            dataBudget.Columns.Add(col);
        }