private void btnAdd_Click(object sender, EventArgs e) { frmAddModifyProduct addProductForm = new frmAddModifyProduct(); //instantiate new Add form addProductForm.addProduct = true; //set bool to true that we are adding a product //this is used to differentiate adding and modifying (form heading) DialogResult result = addProductForm.ShowDialog(); if (result == DialogResult.OK) { product = addProductForm.product; //grab the object from the Add/Modify Product form // txtProductCode.Text = product.ProductCode.ToString(); this.DisplayProduct(); // populate textboxes with data from the newly created product } }
private void btnModify_Click(object sender, EventArgs e) { frmAddModifyProduct modProductForm = new frmAddModifyProduct(); //instantiate new Add form modProductForm.addProduct = false; //set bool to false that we are NOT adding a product, but modifying //this is used to differentiate adding and modifying (form heading) modProductForm.product = product; // populates modify form with the product info DialogResult result = modProductForm.ShowDialog(); if (result == DialogResult.OK) { product = modProductForm.product; this.DisplayProduct(); } else if (result == DialogResult.Retry) { this.GetProduct(product.ProductCode); if (product != null) this.DisplayProduct(); else this.ClearControls(); } }