示例#1
0
        private void ucPaymentCategory_ButtonAddClick(object sender, EventArgs e)
        {
            try
            {
                AddEditPaymentCategoryForm addCategoryForm;
                int newId;

                addCategoryForm = new AddEditPaymentCategoryForm();

                if (addCategoryForm.ShowDialog() == DialogResult.OK)
                {
                    newId = _paymentCategory.Add(addCategoryForm.CategoryName);

                    ucPaymentCategory.PopulateList(new SortableBindingList<IPaymentCategory>(_paymentCategory.GetCategories()));
                    ucPaymentCategory.SelectRow("id", newId);
                }

                addCategoryForm.Dispose();
            }
            catch (Exception exception)
            {
                Error.DisplayMessage(exception);
            }
        }
示例#2
0
        private void ucPaymentCategory_ButtonEditClick(object sender, EventArgs e)
        {
            try
            {
                AddEditPaymentCategoryForm editCategoryForm;
                IPaymentCategory paymentCategory;

                paymentCategory = (IPaymentCategory)ucPaymentCategory.SelectedRow;

                editCategoryForm = new AddEditPaymentCategoryForm(paymentCategory.Name);

                if (editCategoryForm.ShowDialog() == DialogResult.OK)
                {
                    _paymentCategory.Edit(paymentCategory.Id, editCategoryForm.CategoryName);

                    ucPaymentCategory.PopulateList(new SortableBindingList<IPaymentCategory>(_paymentCategory.GetCategories()));
                    ucPaymentCategory.SelectRow("id", paymentCategory.Id);
                }

                editCategoryForm.Dispose();
            }
            catch (Exception exception)
            {
                Error.DisplayMessage(exception);
            }
        }