/// <summary> /// Handles the <see cref="Views.IncomeEdit"/> form being opened from the <see cref="Views.IncomeView"/> form /// </summary> /// <param name="sender">The sender object</param> /// <param name="e">Event arguments</param> public static void EditButtonClicked(object sender, EventArgs e) { if (IncomeEdit == null) { IncomeEdit = new IncomeEdit(); IncomeEdit.FormClosed += IncomeEditViewOnFormClosed; } var selectedListItems = IncomeView.IncomeListView.SelectedItems; if (selectedListItems.Count > 0) { var selectedItem = selectedListItems[0]; var incomeId = Guid.Parse(selectedItem.SubItems[0].Text); var income = ListAccessHelper.FindIncome(incomeId); EditIncome = income; } else { EditIncome = null; } IncomeEdit.Show(IncomeView); IncomeView.Hide(); }
/// <summary> /// Handles deleting an <see cref="Income"/> record /// </summary> /// <param name="sender"></param> /// <param name="e"></param> public static void DeleteIncome(object sender, EventArgs e) { try { var selectedListItems = IncomeView.IncomeListView.SelectedItems; if (selectedListItems.Count > 0) { var selectedItem = selectedListItems[0]; var incomeId = Guid.Parse(selectedItem.SubItems[0].Text); var income = ListAccessHelper.FindIncome(incomeId); ListAccessHelper.IncomeList.Remove(income); XmlDA.SaveXml(); DA.DeleteIncome(incomeId); PopulateListView(); } } catch (Exception ex) { ErrorHelper.SendError(ex); } }