private void btnAdd_Click(object sender, EventArgs e) { frmAddModifyPackage addPackageForm = new frmAddModifyPackage(); //instantiate new Add form addPackageForm.addPackage = true; //set bool to true that we are adding a product //this is used to differentiate adding and modifying (form heading) DialogResult result = addPackageForm.ShowDialog(); if (result == DialogResult.OK) { package = addPackageForm.package; //grab the object from the Add/Modify Product form this.DisplayPackage(); // populate textboxes with data from the newly created product } }
private void btnModify_Click(object sender, EventArgs e) { frmAddModifyPackage modifyPackageForm = new frmAddModifyPackage(); modifyPackageForm.addPackage = false; //this is used to differentaite betwwn adding and modifying modifyPackageForm.package = package; DialogResult result = modifyPackageForm.ShowDialog(); if (result == DialogResult.OK) { package = modifyPackageForm.package; this.DisplayPackage(); } else if (result == DialogResult.Retry) { int packageId = Convert.ToInt32(packageIdTextBox.Text); package = PackageDB.GetPackage(packageId); //calls GetPackage method of PackageDB class if (package != null) this.DisplayPackage(); else this.ClearControls(); } }