//To add a new product to the system when 'Add' button is clicked private void btnAddProduct_Click(object sender, EventArgs e) { //Displays a new window where the user can fill in the details for a new product NewProductWindow npw = new NewProductWindow("Add"); npw.ShowDialog(); //Calls method ShowProduct() to reflect the changes made to the list of products ShowProducts("All"); }
//To edit the product selected when 'Edit' button is clicked private void btnEditProduct_Click(object sender, EventArgs e) { string productRecord = Convert.ToString(listBoxProduct.SelectedItem); string[] productID = productRecord.Split(' '); //Displays a new window where the user can edit the details of the product selected NewProductWindow npw = new NewProductWindow("Edit", productID[0]); npw.ShowDialog(); //Calls method ShowProduct() to reflect the changes made to the list of products ShowProducts(Convert.ToString(cmBoxCategory.SelectedItem)); }