Пример #1
0
        /// <summary>
        ///     Sets up the data bindings to the combo box and the text box
        ///     Refreshes also -by deleting and rebinding
        /// </summary>
        private void CategryDataBinding()
        {
            // Clears any old data bindings
            cmbIncomeCategories.DataSource = null;
            txtIncomeCategoryTotal.DataBindings.Clear();
            cmbExpenseCategories.DataSource = null;
            txtExpenseCategoryTotal.DataBindings.Clear();

            // Intializes the category total dictionarys
            IncomeCategoriesTotals  = new Dictionary <string, decimal>();
            ExpenseCategoriesTotals = new Dictionary <string, decimal>();


            ExpenseCategoriesTotals.Add("Total Expenses", _expenseService.GetMonthTotal(dtPick.Value));
            ExpenseCategoriesTotals.AddRange(_expenseService.GetAllCategoryTotals(dtPick.Value));

            IncomeCategoriesTotals.Add("Total Income", _incomeService.GetMonthTotal(dtPick.Value));
            IncomeCategoriesTotals.AddRange(_incomeService.GetAllCategoryTotals(dtPick.Value));


            // Sets the bindings for the controls
            cmbIncomeCategories.DataSource    = new ArrayList(IncomeCategoriesTotals);
            cmbIncomeCategories.DisplayMember = "KEY";
            txtIncomeCategoryTotal.DataBindings.Add("Text", cmbIncomeCategories.DataSource, "VALUE");

            cmbExpenseCategories.DataSource    = new ArrayList(ExpenseCategoriesTotals);
            cmbExpenseCategories.DisplayMember = "KEY";
            txtExpenseCategoryTotal.DataBindings.Add("Text", cmbExpenseCategories.DataSource, "VALUE");
        }
Пример #2
0
        /// <summary>
        ///     Loads the data for the requested month and connects it to the form
        /// </summary>
        private void LoadMe()
        {
            // Updates the label to display the name of the month being viewed
            lblMonth.Text = _dtMonth.GetDateTimeFormats('Y')[0];

            // Connects the data of the expenses to the corresponding chart
            var expenseData = _expenseService.GetAllCategoryTotals(_dtMonth);

            crtExpenses.Series[0].Points.DataBind(expenseData, "KEY", "VALUE", "");
            UpdatePoints(crtExpenses.Series[0].Points);

            // Connects the data of the income to the corresponding chart
            var incomeData = _incomeService.GetAllCategoryTotals(_dtMonth);

            crtIncome.Series[0].Points.DataBind(incomeData, "KEY", "VALUE", "");
            UpdatePoints(crtIncome.Series[0].Points);
        }