DeliveryAdminWindow: Small quality of life fixes
This commit is contained in:
@ -84,8 +84,8 @@ namespace Elwig {
|
||||
|
||||
var list = new List<IScale>();
|
||||
foreach (var s in Config.Scales) {
|
||||
try {
|
||||
var id = s[0];
|
||||
try {
|
||||
var type = s[1]?.ToLower();
|
||||
var model = s[2];
|
||||
var cnx = s[3];
|
||||
@ -99,6 +99,7 @@ namespace Elwig {
|
||||
throw new ArgumentException($"Invalid scale type: \"{type}\"");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
list.Add(new InvalidScale(id));
|
||||
MessageBox.Show($"Unable to create scale {s[0]}:\n\n{e.Message}", "Scale Error", MessageBoxButton.OK, MessageBoxImage.Error);
|
||||
}
|
||||
}
|
||||
|
@ -11,6 +11,9 @@ namespace Elwig.Helpers {
|
||||
|
||||
public bool IsMatzen => Client == Type.Matzen;
|
||||
public bool IsWinzerkeller => Client == Type.Winzerkeller;
|
||||
public bool IsWolkersdorf => Client == Type.Winzerkeller && App.ZwstId == "W";
|
||||
public bool IsHaugsdorf => Client == Type.Winzerkeller && App.ZwstId == "H";
|
||||
public bool IsSitzendorf => Client == Type.Winzerkeller && App.ZwstId == "S";
|
||||
|
||||
public string NameToken;
|
||||
public string NameShort;
|
||||
|
44
Elwig/Helpers/Weighing/InvalidScale.cs
Normal file
44
Elwig/Helpers/Weighing/InvalidScale.cs
Normal file
@ -0,0 +1,44 @@
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Elwig.Helpers.Weighing {
|
||||
public class InvalidScale : IScale {
|
||||
|
||||
public string Manufacturer => "NONE";
|
||||
public string Model => "NONE";
|
||||
public string ScaleId { get; private set; }
|
||||
public int InternalScaleNr => 0;
|
||||
public bool IsReady => false;
|
||||
public bool HasFillingClearance => false;
|
||||
public int? WeightLimit => null;
|
||||
public string? LogPath => null;
|
||||
|
||||
public InvalidScale(string id) {
|
||||
ScaleId = id;
|
||||
}
|
||||
|
||||
public void Dispose() {
|
||||
GC.SuppressFinalize(this);
|
||||
}
|
||||
|
||||
public Task<WeighingResult> Weigh() {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public Task<WeighingResult> GetCurrentWeight() {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public Task Empty() {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public Task GrantFillingClearance() {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public Task RevokeFillingClearance() {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
@ -32,6 +32,7 @@ namespace Elwig.Windows {
|
||||
LockContext = IsEditing;
|
||||
}
|
||||
}
|
||||
protected bool DoShowWarningWindows = true;
|
||||
protected bool IsClosing { get; private set; }
|
||||
|
||||
private TextBox[] TextBoxInputs;
|
||||
@ -363,7 +364,7 @@ namespace Elwig.Windows {
|
||||
}
|
||||
|
||||
protected bool InputLostFocus(TextBox input, ValidationResult res, string? msg = null) {
|
||||
if (!res.IsValid && !IsClosing && (IsEditing || IsCreating))
|
||||
if (DoShowWarningWindows && !res.IsValid && !IsClosing && (IsEditing || IsCreating))
|
||||
System.Windows.MessageBox.Show(res.ErrorContent.ToString(), msg ?? res.ErrorContent.ToString(), MessageBoxButton.OK, MessageBoxImage.Warning);
|
||||
return res.IsValid;
|
||||
}
|
||||
|
@ -160,10 +160,10 @@
|
||||
|
||||
<Label Content="Mitglied:" Margin="10,10,0,0" Grid.Column="0"/>
|
||||
<TextBox x:Name="MgNrInput" Width="48" Grid.Row="1" Grid.Column="1" Margin="0,10,0,0" HorizontalAlignment="Left" TextAlignment="Right"
|
||||
TextChanged="MgNrInput_TextChanged" LostFocus="MgNrInput_LostFocus"/>
|
||||
TextChanged="MgNrInput_TextChanged" LostFocus="MgNrInput_LostFocus" KeyUp="Input_KeyUp"/>
|
||||
<ComboBox x:Name="MemberInput" Grid.Column="1" Margin="53,10,10,10" IsEditable="True"
|
||||
ItemTemplate="{StaticResource MemberAdminNameTemplate}" TextSearch.TextPath="AdministrativeName"
|
||||
SelectionChanged="MemberInput_SelectionChanged"/>
|
||||
SelectionChanged="MemberInput_SelectionChanged" KeyUp="Input_KeyUp"/>
|
||||
|
||||
<Label Content="Wohnort:" Margin="10,38,0,0" Grid.Column="0"/>
|
||||
<TextBox x:Name="MemberAddressField" Grid.Column="1" Margin="0,40,10,10" FontSize="12" Height="22"
|
||||
@ -209,15 +209,15 @@
|
||||
|
||||
<Label Content="Sorte:" Margin="10,10,0,0" Grid.Column="0"/>
|
||||
<TextBox x:Name="SortIdInput" Width="36" Grid.Row="1" Grid.Column="1" Margin="0,10,0,0" HorizontalAlignment="Left"
|
||||
TextChanged="SortIdInput_TextChanged" LostFocus="SortIdInput_LostFocus"/>
|
||||
TextChanged="SortIdInput_TextChanged" LostFocus="SortIdInput_LostFocus" KeyUp="Input_KeyUp"/>
|
||||
<ComboBox x:Name="WineVarietyInput" Grid.Row="1" Grid.Column="1" Margin="41,10,10,10"
|
||||
ItemTemplate="{StaticResource WineVarietyTemplate}" TextSearch.TextPath="Name"
|
||||
SelectionChanged="WineVarietyInput_SelectionChanged"/>
|
||||
SelectionChanged="WineVarietyInput_SelectionChanged" KeyUp="Input_KeyUp"/>
|
||||
|
||||
<Label Content="Attribute:" Margin="10,40,0,0" Grid.Column="0"/>
|
||||
<xctk:CheckComboBox x:Name="AttributesInput" Grid.Row="1" Grid.Column="1" Margin="0,40,10,10"
|
||||
DisplayMemberPath="Name" Delimiter=", " AllItemsSelectedContent="Alle"
|
||||
ItemSelectionChanged="AttributesInput_SelectionChanged"/>
|
||||
ItemSelectionChanged="AttributesInput_SelectionChanged" KeyUp="Input_KeyUp"/>
|
||||
</Grid>
|
||||
</GroupBox>
|
||||
|
||||
@ -246,7 +246,7 @@
|
||||
SelectionChanged="WineQualityLevelInput_SelectionChanged"/>
|
||||
|
||||
<CheckBox x:Name="AbgewertetInput" Content="Abgewertet" IsEnabled="False"
|
||||
VerticalAlignment="Top" HorizontalAlignment="Left" Margin="0,75,10,10" Grid.Column="1"/>
|
||||
VerticalAlignment="Top" HorizontalAlignment="Left" Margin="10,75,10,10" Grid.Column="0" Grid.ColumnSpan="2"/>
|
||||
</Grid>
|
||||
</GroupBox>
|
||||
|
||||
|
@ -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) {
|
||||
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) {
|
||||
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