//if the accpet button is clicked private void btnAccept_Click(object sender, EventArgs e) { if (ValidDate()) //checks to see if valid data is present { if (addPackage) //if add button was picked on main form { package = new Package(); this.PackageData(package); try { package.PackageId = PackageDB.AddPackage(package); this.DialogResult = DialogResult.OK; } catch (Exception ex) { throw ex; } } else //if modify button was picked on the main form { Package newPackage = new Package(); newPackage.PackageId = package.PackageId; this.PackageData(newPackage); try { if (!PackageDB.UpdatePackages(package, newPackage)) { MessageBox.Show("Another user has updated or deleted " + package.PkgName, "Database Error"); this.DialogResult = DialogResult.Retry; } else { this.DialogResult = DialogResult.OK; } } catch (Exception ex) { MessageBox.Show(ex.Message, ex.GetType().ToString()); } } } }