private void Button1_Click(object sender, EventArgs e) { DialogResult result = MessageBox.Show("Would you want to leave without saving the data?", "You have not saved.", MessageBoxButtons.YesNo, MessageBoxIcon.Warning); if (result.Equals(DialogResult.No)) { return; } parent.Backward(); }
private void button1_Click(object sender, EventArgs e) { if (editMode) { DialogResult result = MessageBox.Show("Save data before leave?", "You have not saved.", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Warning); if (result.Equals(DialogResult.Cancel)) { return; } else if (result.Equals(DialogResult.Yes)) { // Save if (!ValidateFormInput()) { return; } this.UpdateDatabase(); } } parent.Backward(); }