//When the add button is clicked private void btnAdd_Click(object sender, EventArgs e) { //Create a new add or edit route dialog box var objCustomDialogBox = new AddEditGUI(_environment, _systemScheduler.DispatchDatabase, false, new[] {""}); //Give it a name too, because why not? objCustomDialogBox.Text = "Dispatch Editor"; //Show it to the user //If they do things and then hit "OK" if (objCustomDialogBox.ShowDialog() == DialogResult.OK) { //Update the GridView UpdateGUI(); } //When its all done null out the dialog box to save memory objCustomDialogBox = null; //Check if we should have all of our buttons enabled CheckButtonEnable(); }
//When the edit button is clicked private void btnEdit_Click(object sender, EventArgs e) { //Create a new add edit dialog box and pre-populate it with all of the existing information var objCustomDialogBox = new AddEditGUI(_environment, _systemScheduler.DispatchDatabase, true, new[] { ((string) grdDispatches[0, grdDispatches.CurrentRow.Index].Value), ((string) grdDispatches[1, grdDispatches.CurrentRow.Index].Value), ((string) grdDispatches[2, grdDispatches.CurrentRow.Index].Value), ((string) grdDispatches[3, grdDispatches.CurrentRow.Index].Value), ((string) grdDispatches[4, grdDispatches.CurrentRow.Index].Value) }); //Give it a name too, because why not? objCustomDialogBox.Text = "Dispatch Editor"; //If the user did stuff and then clicked the OK button if (objCustomDialogBox.ShowDialog() == DialogResult.OK) { //Update the GridView to reflect the changes UpdateGUI(); } //Null out the dialog box to save memory objCustomDialogBox = null; //Check to see if we should still enable all of our buttons CheckButtonEnable(); }