private void btnAdd_Click(object sender, EventArgs e) { frmUpdate_Add add = new frmUpdate_Add(); add.addPackage = true; DialogResult result = add.ShowDialog(); if (result == DialogResult.OK) // Adding accepted { // refresh the grid view LoadPackages(); MessageBox.Show(add.packageNow.PkgName + " has been added to the database"); } }
}//End of form load private void grdPackages_CellContentClick(object sender, DataGridViewCellEventArgs e) { if (e.ColumnIndex == UPDATE) { oldPackage = packages[e.RowIndex].PackageBackup(); frmUpdate_Add update = new frmUpdate_Add(); update.packageNow = packages[e.RowIndex]; // current package update.packageOld = oldPackage; // older package (from frmPackage) DialogResult result = update.ShowDialog(); if (result == DialogResult.OK) // update accepted { // refresh the grid view LoadPackages(); MessageBox.Show(update.packageNow.PkgName + " has been updated successfully!"); } else // update cancelled { packages[e.RowIndex] = oldPackage; // revert to the old values } } }//End of Update click