Page 1 of 1
Confirmation message when exiting OD
Posted: Wed May 18, 2011 10:04 am
by alhalwachi
Dear All
I would like to add a confirmation pop up window with a "Are you sure you want to exit Open Dental" message when the user clicks on the "X" Exit button, how can I do that?
Alos, i want to do the same when the user clicks on the exit button of the patient edit form...
Please help, thanks
Re: Confirmation message when exiting OD
Posted: Wed May 18, 2011 11:13 am
by wjstarck
Just put this at the top of the FormOpenDental_FormClosing method on FormOpenDental like so:
Code: Select all
private void FormOpenDental_FormClosing(object sender,FormClosingEventArgs e) {
DialogResult result = MessageBox.Show(Lan.g(this, "Are you sure you want to quit Open Dental?"), "", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1);
if (result == DialogResult.No) {
e.Cancel = true;
return;
}
try {
Computers.ClearHeartBeat(Environment.MachineName);
} catch { }
FormUAppoint.AbortThread();
//ICat.AbortThread
//earlier, this wasn't working. But I haven't tested it since moving it from Closing to FormClosing.
if (ThreadCommandLine != null) {
ThreadCommandLine.Abort();
}
}
You can do something similar on FormPatientEdit
Re: Confirmation message when exiting OD
Posted: Thu May 19, 2011 4:24 am
by alhalwachi
Perfect, that worked just great form me BUT, how can i achieve the same with the Patient Edit form?
Thanks;
Re: Confirmation message when exiting OD
Posted: Thu May 19, 2011 7:16 am
by wjstarck
Just stick this at the top of method FormPatientEdit_Closing like so:
Code: Select all
private void FormPatientEdit_Closing(object sender, System.ComponentModel.CancelEventArgs e) {
DialogResult result = MessageBox.Show(Lan.g(this, "Are you sure you want to close this window?"), "", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1);
if (result == DialogResult.No) {
e.Cancel = true;
return;
}
if(DialogResult==DialogResult.OK){
return;
}
if(IsNew){
//for(int i=0;i<RefList.Length;i++){
// RefAttaches.Delete(RefList[i]);
//}
Patients.Delete(PatCur);
}
}
Re: Confirmation message when exiting OD
Posted: Tue May 24, 2011 3:02 am
by alhalwachi
Thanks a lot for your help. I applied the above on the patient edit for as advised and it works perfectly BUT i get the same message when i click on the "OK"/"Cancel" buttons on the form, i only want this message to appear when i close the form or click 'Cancel" and not when clicking OK.
How can i do that?
Re: Confirmation message when exiting OD
Posted: Tue May 24, 2011 3:42 am
by jordansparks
Use a variable to keep track of when the user clicks ok or cancel. And then skip the message if they did so.