private void btnUpdate_Click(object sender, EventArgs e) { if (lvProducts.SelectedItems.Count == 0) { MessageBox.Show("Please select a product to update", "Update Product", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return; } GlobalVariable.selectedProductID = int.Parse(lvProducts.SelectedItems[0].SubItems[1].Text); frmProductsAdd editForm = new frmProductsAdd(); editForm.FormClosing += new FormClosingEventHandler(frmProductsAdd_FormClosing); editForm.ChangeAddToEdit("Edit Product Details", " Edit Product Details", "Update"); editForm.ShowDialog(); void frmProductsAdd_FormClosing(object bender, FormClosingEventArgs i) { frmProductsView productsView = new frmProductsView(); productsView.Show(); Hide(); } lvProducts.Items.Clear(); DisplayProducts(); Hide(); }
private void productsToolStripMenuItem_Click(object sender, EventArgs e) { frmProductsView productsView = new frmProductsView(); productsView.Show(); Hide(); }
//button events private void btnAdd_Click(object sender, EventArgs e) { /*By not defining a FormClosing event on ProductssAdd.cs, I can add an individual closing event per form * object that is created. Allows for flexibility when creating forms ie Can call the add product form from the * add sale form and not have to worry about the form closing event running everytime (This would close form and * launch the view products form) */ GlobalVariable.selectedProductID = 0; frmProductsAdd productsAdd = new frmProductsAdd(); productsAdd.FormClosing += new FormClosingEventHandler(frmProductsAdd_FormClosing); productsAdd.ShowDialog(); void frmProductsAdd_FormClosing(object bender, FormClosingEventArgs i) { frmProductsView productsView = new frmProductsView(); productsView.Show(); Hide(); } lvProducts.Items.Clear(); DisplayProducts(); Hide(); }