DeliveryAdminWindow: Add user confirmation on closing when creating
This commit is contained in:
@ -82,6 +82,14 @@ namespace Elwig.Windows {
|
||||
}
|
||||
|
||||
private void OnClosing(object? sender, CancelEventArgs evt) {
|
||||
if ((IsCreating || IsEditing) && HasChanged) {
|
||||
var r = System.Windows.MessageBox.Show("Soll das Fenster wirklich geschlossen werden?", "Schlie<69>en best<73>tigen",
|
||||
MessageBoxButton.YesNo, MessageBoxImage.Warning, MessageBoxResult.No);
|
||||
if (r != MessageBoxResult.Yes) {
|
||||
evt.Cancel = true;
|
||||
return;
|
||||
}
|
||||
}
|
||||
IsClosing = true;
|
||||
}
|
||||
|
||||
@ -293,12 +301,20 @@ namespace Elwig.Windows {
|
||||
}
|
||||
|
||||
protected bool HasChanged =>
|
||||
IsEditing && (
|
||||
!IsValid ||
|
||||
TextBoxInputs.Any(InputHasChanged) ||
|
||||
ComboBoxInputs.Any(InputHasChanged) ||
|
||||
CheckComboBoxInputs.Any(InputHasChanged) ||
|
||||
CheckBoxInputs.Any(InputHasChanged) ||
|
||||
RadioButtonInputs.Any(InputHasChanged);
|
||||
RadioButtonInputs.Any(InputHasChanged)
|
||||
) || IsCreating && (
|
||||
TextBoxInputs.Any(i => InputIsNotDefault(i) || (!i.IsReadOnly && i.Text != "")) ||
|
||||
ComboBoxInputs.Any(i => InputIsNotDefault(i) || (i.IsEnabled && i.SelectedItem != null)) ||
|
||||
CheckComboBoxInputs.Any(i => InputIsNotDefault(i) || i.SelectedItem != null) ||
|
||||
CheckBoxInputs.Any(InputIsNotDefault) ||
|
||||
RadioButtonInputs.Any(InputIsNotDefault)
|
||||
);
|
||||
|
||||
protected void UpdatePlz(TextBox plzInput, ComboBox ortInput) {
|
||||
var plzInputValid = GetInputValid(plzInput);
|
||||
|
@ -778,6 +778,12 @@ namespace Elwig.Windows {
|
||||
}
|
||||
|
||||
private async void CancelCreatingButton_Click(object sender, RoutedEventArgs evt) {
|
||||
if (IsCreating && HasChanged) {
|
||||
var r = MessageBox.Show("Soll der Vorgang wirklich abgebrochen werden?", "Abbrechen bestätigen",
|
||||
MessageBoxButton.YesNo, MessageBoxImage.Warning, MessageBoxResult.No);
|
||||
if (r != MessageBoxResult.Yes) return;
|
||||
}
|
||||
|
||||
ControlUtils.RenewItemsSource(AttributesInput, await Context.WineAttributes.OrderBy(a => a.Name).ToListAsync(), i => (i as WineAttr)?.AttrId);
|
||||
ControlUtils.RenewItemsSource(MemberInput, await Context.Members.Where(m => m.IsActive || !IsReceipt).OrderBy(m => m.FamilyName).ThenBy(m => m.GivenName).ToListAsync(), i => (i as Member)?.MgNr);
|
||||
if (DeliveryList.SelectedItem is not Delivery d) {
|
||||
|
Reference in New Issue
Block a user