private void AddBtn_Click(object sender, EventArgs e) { productAddModifyForm addProduct = new productAddModifyForm(); addProduct.addProduct = true; DialogResult result = addProduct.ShowDialog(); if (result == DialogResult.OK) { product = addProduct.product; productIDTextBox.Text = product.productID.ToString(); this.DisplayProduct(); } }
private void EditBtn_Click(object sender, EventArgs e) { if (productIDTextBox.Text.Length == 0) { MessageBox.Show("Please select a product first."); return; } int productID = Convert.ToInt32(productIDTextBox.Text); this.GetProduct(productID); productAddModifyForm modifyProduct = new productAddModifyForm(); modifyProduct.addProduct = false; modifyProduct.product = this.product; DialogResult result = modifyProduct.ShowDialog(); if (result == DialogResult.OK) { product = modifyProduct.product; this.DisplayProduct(); } else if (result == DialogResult.Retry) { this.GetProduct(product.productID); if (product != null) { this.DisplayProduct(); } else { this.ClearControls(); } } }