add delete option and error handling to tours
This commit is contained in:
@@ -174,7 +174,51 @@ namespace Sernatur {
|
||||
}
|
||||
}
|
||||
else if (button == delete_tour) {
|
||||
print ("Delete tour clicked\n");
|
||||
var msg = new Gtk.MessageDialog (this,
|
||||
Gtk.DialogFlags.MODAL,
|
||||
Gtk.MessageType.ERROR,
|
||||
Gtk.ButtonsType.YES_NO,
|
||||
dgettext(null, "Are you sure you wish to delete this tour?"));
|
||||
msg.response.connect ((response_id) => {
|
||||
switch (response_id) {
|
||||
case Gtk.ResponseType.YES:
|
||||
try {
|
||||
Gtk.TreeModel model;
|
||||
Gtk.TreeIter iter;
|
||||
Tour tour;
|
||||
if (selection.get_selected (out model, out iter)) {
|
||||
model.get (iter,
|
||||
Column.TOUR, out tour);
|
||||
Tour.delete_tour (conn.db, tour);
|
||||
}
|
||||
}
|
||||
catch (DBError e) {
|
||||
if (e.code == 1) {
|
||||
var msg2 = new Gtk.MessageDialog (this,
|
||||
Gtk.DialogFlags.MODAL,
|
||||
Gtk.MessageType.ERROR,
|
||||
Gtk.ButtonsType.CLOSE,
|
||||
dgettext(null, "Error: Could not delete tour because there are still associated arrival and departure dates and times!"));
|
||||
msg2.response.connect ((response_id) => {
|
||||
msg2.destroy ();
|
||||
});
|
||||
msg2.set_title (dgettext (null, "Error"));
|
||||
msg2.show ();
|
||||
}
|
||||
else {
|
||||
#if DEBUG
|
||||
error (e.message);
|
||||
#else
|
||||
warning (e.message);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
msg.destroy ();
|
||||
});
|
||||
msg.set_title (dgettext (null, "Error"));
|
||||
msg.show ();
|
||||
}
|
||||
else if (button == close_tour) {
|
||||
this.close ();
|
||||
|
Reference in New Issue
Block a user