private void btnAdd_Click(object sender, EventArgs e) { frmNewProduct newProductForm = new frmNewProduct(); Product product = newProductForm.GetNewProduct(); if (product != null) { products.Add(product); products.Save(); FillProductListBox(); } }
private void btnDelete_Click(object sender, System.EventArgs e) { int i = lstProducts.SelectedIndex; if (i != -1) { Product product = products[i]; string message = "Are you sure you want to delete " + product.Description + "?"; DialogResult button = MessageBox.Show(message, "Confirm Delete", MessageBoxButtons.YesNo); if (button == DialogResult.Yes) { products -= product; products.Save(); FillProductListBox(); } } }
private void HandleChange(ProductList products) { products.Save(); FillProductListBox(); }