예제 #1
0
        /// <summary>
        ///     Sets the data bindings of the form,
        ///     including the selected value of the combo boxes, and events
        /// </summary>
        private void SetDataBindings()
        {
            //Simple control bindings
            txtAmount.Text = currentIncome.Amount.ToString();
            txtDetail.Text = currentIncome.Comments;
            dtPick.Value   = currentIncome.Date;

            //Expense category bindings
            cmbCategory.DataSource    = _incomeCategoryService.GetAll();
            cmbCategory.DisplayMember = "NAME";
            cmbCategory.ValueMember   = "ID";
            cmbCategory.SelectedIndex = cmbCategory.FindString(currentIncome.Category.Name);

            //Payment Method bindings
            cmbPayment.DataSource    = _paymentMethodService.GetAll();
            cmbPayment.DisplayMember = "NAME";
            cmbPayment.ValueMember   = "ID";
            cmbPayment.SelectedIndex = cmbPayment.FindString(currentIncome.Method.Name);

            //Event Bindings
            // This is to keep events firing until all the data bindings are fully set
            cmbCategory.SelectedIndexChanged += cmbCategory_SelectedIndexChanged;
            cmbPayment.SelectedIndexChanged  += cmbPayment_SelectedIndexChanged;
            txtAmount.TextChanged            += txtAmount_TextChanged;
            txtDetail.TextChanged            += txtDetail_TextChanged;
            dtPick.ValueChanged += dtPick_ValueChanged;
        }
예제 #2
0
        public void DeleteAllPaymentMethods()
        {
            var methods = PaymentMethodService.GetAll();

            foreach (var method in methods)
            {
                PaymentMethodService.Delete(method);
            }
        }
예제 #3
0
        private void SetDataBindings()
        {
            // Sets up the combo box of the income categories
            cmbCategory.DataSource    = _incomeCategoryService.GetAll();
            cmbCategory.DisplayMember = "NAME";
            cmbCategory.ValueMember   = "ID";

            // Sets up the combo box with the payment methods
            cmbPayment.DataSource    = _paymentMethodService.GetAll();
            cmbPayment.DisplayMember = "NAME";
            cmbPayment.ValueMember   = "ID";
        }
예제 #4
0
        /// <summary>
        /// Connects the combo boxes on the form with the data from the cache
        ///  and sets the date time pickers with data bindings to keep them
        ///  from crossing over
        /// </summary>
        /// <param name="sender">Standard sender object</param>
        /// <param name="e">Standard event object</param>
        private void RecurringIncomeInput_Load(object sender, EventArgs e)
        {
            // Sets up the combo box of the income categories
            cmbCategory.DataSource =
                _incomeCategoryService.GetAll();
            cmbCategory.DisplayMember = "NAME";
            cmbCategory.ValueMember   = "ID";

            // Sets up the combo box with the payment methods
            cmbPayment.DataSource =
                _paymentMethodService.GetAll();
            cmbPayment.DisplayMember = "NAME";
            cmbPayment.ValueMember   = "ID";

            // Sets up the date time pickers with data bindings to keep the dates from
            // crossing over in the wrong direction
            dtpStartDate.DataBindings.Add("MaxDate", dtpEndDate, "Value");
            dtpEndDate.DataBindings.Add("MinDate", dtpStartDate, "Value");
        }