private void ucBudget_ButtonAddClick(object sender, EventArgs e) { try { AddEditBudgetForm addBudgetForm; int newId; addBudgetForm = new AddEditBudgetForm(); if (addBudgetForm.ShowDialog() == DialogResult.OK) { newId = Budget.Add(addBudgetForm.BudgetName, addBudgetForm.WeeklyAmount, addBudgetForm.AddedExpenseCategories); ucBudget.PopulateList(new SortableBindingList<IBudgetHeader>(BudgetHeader.GetBudgetHeaders())); ucBudget.SelectRow("id", newId); } addBudgetForm.Dispose(); } catch (Exception exception) { Error.DisplayMessage(exception); } }
private void ucBudget_ButtonEditClick(object sender, EventArgs e) { try { AddEditBudgetForm editBudgetForm; IBudgetHeader budgetHeader; budgetHeader = (IBudgetHeader)ucBudget.SelectedRow; editBudgetForm = new AddEditBudgetForm(budgetHeader.Id, budgetHeader.Name, budgetHeader.WeeklyAmount); if (editBudgetForm.ShowDialog() == DialogResult.OK) { Budget.Edit(budgetHeader.Id, editBudgetForm.BudgetName, editBudgetForm.WeeklyAmount, editBudgetForm.DeletedExpenseCategories, editBudgetForm.AddedExpenseCategories); ucBudget.PopulateList(new SortableBindingList<IBudgetHeader>(BudgetHeader.GetBudgetHeaders())); ucBudget.SelectRow("id", budgetHeader.Id); } editBudgetForm.Dispose(); } catch (Exception exception) { Error.DisplayMessage(exception); } }