DeliveryAdminWindow: Small quality of life fixes
This commit is contained in:
@ -60,6 +60,8 @@ namespace Elwig.Windows {
|
||||
SearchInput.TextChanged -= SearchInput_TextChanged;
|
||||
SeasonInput.Value = Utils.CurrentLastSeason;
|
||||
|
||||
DoShowWarningWindows = false;
|
||||
|
||||
if (IsReceipt) {
|
||||
Title = "Übernahme - Elwig";
|
||||
TodayOnlyInput.IsChecked = true;
|
||||
@ -149,7 +151,7 @@ namespace Elwig.Windows {
|
||||
ClearDefaultValues();
|
||||
|
||||
HandPickedInput.IsChecked = null;
|
||||
if (App.Client.IsMatzen) {
|
||||
if (App.Client.IsMatzen || App.Client.IsWolkersdorf) {
|
||||
GerebeltGewogenInput.IsChecked = true;
|
||||
GerebeltGewogenInput.IsEnabled = false;
|
||||
SetDefaultValue(GerebeltGewogenInput);
|
||||
@ -159,6 +161,8 @@ namespace Elwig.Windows {
|
||||
UnsetDefaultValue(GerebeltGewogenInput);
|
||||
}
|
||||
|
||||
WineQualityLevelInput.IsEnabled = false;
|
||||
|
||||
SetDefaultValue(HandPickedInput);
|
||||
ValidateRequiredInputs();
|
||||
}
|
||||
@ -180,6 +184,16 @@ namespace Elwig.Windows {
|
||||
CancelCreatingButton.IsEnabled = DeliveryList.SelectedItem == null || DeliveryPartList.SelectedItem == null;
|
||||
}
|
||||
|
||||
private void Input_KeyUp(object sender, KeyEventArgs evt) {
|
||||
if (sender is not Control ctrl) return;
|
||||
if (evt.Key != Key.Enter) return;
|
||||
if (ctrl == MgNrInput || ctrl == MemberInput) {
|
||||
SortIdInput.Focus(); SortIdInput.SelectAll();
|
||||
} else if (ctrl == SortIdInput || ctrl == WineVarietyInput || ctrl == AttributesInput) {
|
||||
GradationOeInput.Focus(); GradationOeInput.SelectAll();
|
||||
}
|
||||
}
|
||||
|
||||
private async Task RefreshDeliveryList() {
|
||||
await RefreshDeliveryListQuery();
|
||||
}
|
||||
@ -412,7 +426,7 @@ namespace Elwig.Windows {
|
||||
await RefreshDeliveryList();
|
||||
var d = DeliveryList.SelectedItem as Delivery;
|
||||
var y = d?.Year ?? Utils.CurrentLastSeason;
|
||||
ControlUtils.RenewItemsSource(MemberInput, await Context.Members.OrderBy(m => m.FamilyName).ThenBy(m => m.GivenName).ToListAsync(), i => (i as Member)?.MgNr);
|
||||
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);
|
||||
ControlUtils.RenewItemsSource(BranchInput, await Context.Branches.OrderBy(b => b.Name).ToListAsync(), i => (i as Branch)?.ZwstId);
|
||||
ControlUtils.RenewItemsSource(WineVarietyInput, await Context.WineVarieties.OrderBy(v => v.Name).ToListAsync(), i => (i as WineVar)?.SortId);
|
||||
ControlUtils.RenewItemsSource(AttributesInput, await Context.WineAttributes.Where(a => IsCreating || a.IsActive).OrderBy(a => a.Name).ToListAsync(), i => (i as WineAttr)?.AttrId);
|
||||
@ -763,8 +777,9 @@ namespace Elwig.Windows {
|
||||
InitInputs();
|
||||
}
|
||||
|
||||
private void CancelCreatingButton_Click(object sender, RoutedEventArgs evt) {
|
||||
ControlUtils.RenewItemsSource(AttributesInput, Context.WineAttributes.OrderBy(a => a.Name).ToList(), i => (i as WineAttr)?.AttrId);
|
||||
private async void CancelCreatingButton_Click(object sender, RoutedEventArgs evt) {
|
||||
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) {
|
||||
// switch away from creating mode
|
||||
IsCreating = false;
|
||||
@ -785,8 +800,11 @@ namespace Elwig.Windows {
|
||||
}
|
||||
}
|
||||
|
||||
private void NewDeliveryButton_Click(object? sender, RoutedEventArgs? evt) {
|
||||
ControlUtils.RenewItemsSource(AttributesInput, Context.WineAttributes.Where(a => a.IsActive).OrderBy(a => a.Name).ToList(), i => (i as WineAttr)?.AttrId);
|
||||
private async void NewDeliveryButton_Click(object? sender, RoutedEventArgs? evt) {
|
||||
TodayOnlyInput.IsChecked = true;
|
||||
SearchInput.Text = "";
|
||||
ControlUtils.RenewItemsSource(AttributesInput, await Context.WineAttributes.Where(a => a.IsActive).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);
|
||||
IsCreating = true;
|
||||
DeliveryList.IsEnabled = false;
|
||||
DeliveryPartList.IsEnabled = false;
|
||||
@ -1131,10 +1149,11 @@ namespace Elwig.Windows {
|
||||
|
||||
private void EnableWeighingButtons() {
|
||||
WeighingManualButton.IsEnabled = true;
|
||||
WeighingAButton.IsEnabled = true;
|
||||
WeighingBButton.IsEnabled = true;
|
||||
WeighingCButton.IsEnabled = true;
|
||||
WeighingDButton.IsEnabled = true;
|
||||
var n = App.Scales.Count;
|
||||
WeighingAButton.IsEnabled = n > 0 && App.Scales[0].IsReady;
|
||||
WeighingBButton.IsEnabled = n > 1 && App.Scales[1].IsReady;
|
||||
WeighingCButton.IsEnabled = n > 2 && App.Scales[2].IsReady;
|
||||
WeighingDButton.IsEnabled = n > 3 && App.Scales[3].IsReady;
|
||||
}
|
||||
|
||||
private async Task UpdateLsNr() {
|
||||
@ -1245,8 +1264,10 @@ namespace Elwig.Windows {
|
||||
}
|
||||
|
||||
private void ModifiersInput_SelectionChanged(object sender, ItemSelectionChangedEventArgs evt) {
|
||||
if ((IsEditing || IsCreating) && App.Client.IsMatzen) {
|
||||
var mod = ModifiersInput.SelectedItems.Cast<Modifier>();
|
||||
if (!IsEditing && !IsCreating) return;
|
||||
var mod = ModifiersInput.SelectedItems.Cast<Modifier>();
|
||||
var source = ModifiersInput.ItemsSource.Cast<Modifier>();
|
||||
if (App.Client.IsMatzen) {
|
||||
var kl = mod.Where(m => m.Name.StartsWith("Klasse "));
|
||||
if (kl.Count() > 1) {
|
||||
foreach (var r in kl.Take(kl.Count() - 1)) ModifiersInput.SelectedItems.Remove(r);
|
||||
@ -1255,11 +1276,14 @@ namespace Elwig.Windows {
|
||||
}
|
||||
|
||||
private void LesewagenInput_Changed(object sender, RoutedEventArgs evt) {
|
||||
if ((IsEditing || IsCreating) && App.Client.IsMatzen) {
|
||||
var mod = ModifiersInput.SelectedItems.Cast<Modifier>();
|
||||
if (!IsEditing && !IsCreating) return;
|
||||
var mod = ModifiersInput.SelectedItems.Cast<Modifier>();
|
||||
var source = ModifiersInput.ItemsSource.Cast<Modifier>();
|
||||
var lw = LesewagenInput.IsChecked == true;
|
||||
if (App.Client.IsMatzen) {
|
||||
var kl = mod.Where(m => m.Name.StartsWith("Klasse ")).Select(m => m.ModId).LastOrDefault("A")[0];
|
||||
if (LesewagenInput.IsChecked == true) kl++; else kl--;
|
||||
var newKl = ModifiersInput.ItemsSource.Cast<Modifier>().Where(m => m.ModId == kl.ToString()).FirstOrDefault();
|
||||
if (lw) kl++; else kl--;
|
||||
var newKl = source.Where(m => m.ModId == kl.ToString()).FirstOrDefault();
|
||||
if (newKl != null) ModifiersInput.SelectedItems.Add(newKl);
|
||||
}
|
||||
CheckBox_Changed(sender, evt);
|
||||
|
Reference in New Issue
Block a user