Windows: Minor cleanups
This commit is contained in:
@ -117,7 +117,7 @@ namespace Elwig.Windows {
|
||||
FinishInputFilling();
|
||||
}
|
||||
|
||||
private async void InitInputs() {
|
||||
private async Task InitInputs() {
|
||||
ClearOriginalValues();
|
||||
ClearDefaultValues();
|
||||
await ViewModel.InitInputs();
|
||||
@ -159,14 +159,14 @@ namespace Elwig.Windows {
|
||||
NewAreaCommitmentButton_Click(null, null);
|
||||
}
|
||||
|
||||
private void NewAreaCommitmentButton_Click(object? sender, RoutedEventArgs? evt) {
|
||||
private async void NewAreaCommitmentButton_Click(object? sender, RoutedEventArgs? evt) {
|
||||
IsCreating = true;
|
||||
AreaCommitmentList.IsEnabled = false;
|
||||
AreaCommitmentList.SelectedItem = null;
|
||||
HideAreaCommitmentNewEditDeleteButtons();
|
||||
ShowAreaCommitmentSaveResetCancelButtons();
|
||||
UnlockInputs();
|
||||
InitInputs();
|
||||
await InitInputs();
|
||||
LockSearchInputs();
|
||||
}
|
||||
|
||||
@ -197,17 +197,25 @@ namespace Elwig.Windows {
|
||||
}
|
||||
|
||||
private async void DeleteAreaCommitmentButton_Click(object? sender, RoutedEventArgs? evt) {
|
||||
AreaCom a = (AreaCom)AreaCommitmentList.SelectedItem;
|
||||
if (a == null) return;
|
||||
|
||||
if (AreaCommitmentList.SelectedItem is not AreaCom a)
|
||||
return;
|
||||
var r = MessageBox.Show(
|
||||
$"Soll die Flächenbindung {a.GstNr} ({a.Area} m²) wirklich unwiderruflich gelöscht werden?",
|
||||
"Flächenbindung löschen", MessageBoxButton.OKCancel, MessageBoxImage.Warning, MessageBoxResult.Cancel);
|
||||
if (r == MessageBoxResult.OK) {
|
||||
using var ctx = new AppDbContext();
|
||||
ctx.Remove(a);
|
||||
await ctx.SaveChangesAsync();
|
||||
await RefreshList();
|
||||
Mouse.OverrideCursor = Cursors.AppStarting;
|
||||
try {
|
||||
using (var ctx = new AppDbContext()) {
|
||||
ctx.Remove(a);
|
||||
await ctx.SaveChangesAsync();
|
||||
}
|
||||
await App.HintContextChange();
|
||||
} catch (Exception exc) {
|
||||
var str = "Der Eintrag konnte nicht in der Datenbank aktualisiert werden!\n\n" + exc.Message;
|
||||
if (exc.InnerException != null) str += "\n\n" + exc.InnerException.Message;
|
||||
MessageBox.Show(str, "Flächenbindung löschen", MessageBoxButton.OK, MessageBoxImage.Error);
|
||||
}
|
||||
Mouse.OverrideCursor = null;
|
||||
}
|
||||
}
|
||||
|
||||
@ -246,11 +254,11 @@ namespace Elwig.Windows {
|
||||
AreaCommitmentResetButton_Click(null, null);
|
||||
}
|
||||
|
||||
private void AreaCommitmentResetButton_Click(object? sender, RoutedEventArgs? evt) {
|
||||
private async void AreaCommitmentResetButton_Click(object? sender, RoutedEventArgs? evt) {
|
||||
if (IsEditing) {
|
||||
RefreshInputs();
|
||||
} else if (IsCreating) {
|
||||
InitInputs();
|
||||
await InitInputs();
|
||||
}
|
||||
UpdateButtons();
|
||||
}
|
||||
|
Reference in New Issue
Block a user