public virtual bool Leave(bool changes = false, bool errors = false) { if(Ctx.HasChanges() || changes) { MessageBoxService messageService = new MessageBoxService(); var result = messageService.AskForConfirmation("Er zijn nog onopgeslagen wijzigingen.\nWilt u deze wijzingen nog opslaan?", Header); if (result == MessageBoxResult.Yes) { //Check if there are validation errors!!! try { if (errors) throw new Exception("There is a specific validation error"); Ctx.Complete(); } catch { messageService.ShowMessageBox("Er bevinden zich nog fouten in de data! Kan dit niet opslaan!"); return false; } } else if (result == MessageBoxResult.No) { Ctx.DiscardChanges(); } else { return false; } } return true; }
public void RestoreDatabase() { OpenFileDialogService openFileDialogService = new OpenFileDialogService(); string path = openFileDialogService.Open(); if (!String.IsNullOrWhiteSpace(path)) { try { Ctx.RestoreDatabase(path); var message = new MessageBoxService(); var result = message.AskForConfirmation("Restore van backup van databank is geslaagd. Om effect te hebben moet u de applicatie herstarten! \nWilt u de applicatie nu herstarten?","Strijkdienst Conny Restore Database", System.Windows.MessageBoxButton.YesNo); if (result == MessageBoxResult.Yes) { System.Windows.Forms.Application.Restart(); Process.GetCurrentProcess().Kill(); } } catch { //TODO } } }