Update DeliveryAdminWindow
This commit is contained in:
@ -24,6 +24,9 @@ namespace Elwig.Windows {
|
||||
private readonly RoutedCommand CtrlF = new();
|
||||
|
||||
private string? ManualWeighingReason = null;
|
||||
private string? ScaleId = null;
|
||||
private string? WeighingId = null;
|
||||
private Button[] WeighingButtons;
|
||||
|
||||
public DeliveryAdminWindow(bool receipt = false) {
|
||||
InitializeComponent();
|
||||
@ -42,6 +45,9 @@ namespace Elwig.Windows {
|
||||
DeliveryList, DeliveryPartList,
|
||||
MemberAddressField,
|
||||
};
|
||||
WeighingButtons = new Button[] {
|
||||
WeighingAButton, WeighingBButton, WeighingCButton, WeighingDButton,
|
||||
};
|
||||
IsReceipt = receipt;
|
||||
|
||||
Timer = new DispatcherTimer();
|
||||
@ -111,8 +117,13 @@ namespace Elwig.Windows {
|
||||
|
||||
private void InitialInputs() {
|
||||
HandPickedInput.IsChecked = null;
|
||||
// FIXME if Matzen
|
||||
GerebeltGewogenInput.IsChecked = true;
|
||||
if (App.Client.Client == ClientParameters.Type.Matzen) {
|
||||
GerebeltGewogenInput.IsChecked = true;
|
||||
GerebeltGewogenInput.IsEnabled = false;
|
||||
} else {
|
||||
GerebeltGewogenInput.IsChecked = false;
|
||||
GerebeltGewogenInput.IsEnabled = true;
|
||||
}
|
||||
ClearOriginalValues();
|
||||
ValidateRequiredInputs();
|
||||
}
|
||||
@ -311,7 +322,6 @@ namespace Elwig.Windows {
|
||||
d.Comment = (CommentInput.Text == "") ? null : CommentInput.Text;
|
||||
|
||||
p.SortId = (WineVarietyInput.SelectedItem as WineVar)?.SortId;
|
||||
p.Weight = int.Parse(WeightInput.Text.Replace("\u202f", ""));
|
||||
p.Kmw = double.Parse(GradationKmwInput.Text);
|
||||
p.QualId = (WineQualityLevelInput.SelectedItem as WineQualLevel)?.QualId;
|
||||
p.HkId = (WineOriginInput.SelectedItem as WineOrigin)?.HkId;
|
||||
@ -319,16 +329,18 @@ namespace Elwig.Windows {
|
||||
p.RdNr = (WineRdInput.SelectedItem as WbRd)?.RdNr;
|
||||
|
||||
p.IsGerebelt = GerebeltGewogenInput.IsChecked ?? false;
|
||||
p.ManualWeighing = ManualWeighingInput.IsChecked ?? false;
|
||||
p.IsHandPicked = HandPickedInput.IsChecked;
|
||||
p.IsLesewagen = LesewagenInput.IsChecked;
|
||||
p.Temperature = (TemperatureInput.Text == "") ? null : double.Parse(TemperatureInput.Text);
|
||||
p.Acid = (TemperatureInput.Text == "") ? null : double.Parse(AcidInput.Text);
|
||||
p.Acid = (AcidInput.Text == "") ? null : double.Parse(AcidInput.Text);
|
||||
p.Comment = (PartCommentInput.Text == "") ? null : PartCommentInput.Text;
|
||||
|
||||
// TODO weighing/scale id
|
||||
// p.ScaleId
|
||||
// p.WeighingId
|
||||
p.Weight = int.Parse(WeightInput.Text.Replace("\u202f", ""));
|
||||
p.ManualWeighing = ManualWeighingInput.IsChecked ?? false;
|
||||
p.ScaleId = ScaleId;
|
||||
p.WeighingId = WeighingId;
|
||||
if (ManualWeighingReason != null)
|
||||
p.Comment = (p.Comment != null ? $"{p.Comment} / " : "") + $"Begründung Handwiegung: {ManualWeighingReason}";
|
||||
|
||||
// TODO update KgNr when MgNr changes (if default is selected)
|
||||
|
||||
@ -401,6 +413,39 @@ namespace Elwig.Windows {
|
||||
return p;
|
||||
}
|
||||
|
||||
private void WeighingButton_Click(object sender, RoutedEventArgs evt) {
|
||||
int index = Array.IndexOf(WeighingButtons, sender as Button);
|
||||
if (index >= 0) WeighingButton_Click(index);
|
||||
}
|
||||
|
||||
private async void WeighingButton_Click(int index) {
|
||||
DisableWeighingButtons();
|
||||
FinishButton.IsEnabled = false;
|
||||
NewDeliveryPartButton.IsEnabled = false;
|
||||
CancelCreatingButton.IsEnabled = false;
|
||||
try {
|
||||
var s = App.Scales[index];
|
||||
var res = await s.Weigh();
|
||||
if ((res.Weight ?? 0) > 0 && res.FullWeighingId != null) {
|
||||
WeightInput.Text = $"{res.Weight:N0}";
|
||||
ScaleId = s.ScaleId;
|
||||
WeighingId = res.FullWeighingId;
|
||||
s.Empty();
|
||||
} else {
|
||||
WeightInput.Text = "";
|
||||
ScaleId = null;
|
||||
WeighingId = null;
|
||||
}
|
||||
ManualWeighingReason = null;
|
||||
ManualWeighingInput.IsChecked = false;
|
||||
} catch (Exception e) {
|
||||
MessageBox.Show($"Beim Wiegen ist ein Fehler aufgetreten:\n\n{e.Message}", "Waagenfehler",
|
||||
MessageBoxButton.OK, MessageBoxImage.Error);
|
||||
}
|
||||
EnableWeighingButtons();
|
||||
UpdateButtons();
|
||||
}
|
||||
|
||||
private async void SearchInput_TextChanged(object sender, RoutedEventArgs evt) {
|
||||
TextFilter = SearchInput.Text.ToLower().Split(" ").ToList().FindAll(e => e.Length > 0);
|
||||
await RefreshDeliveryListQuery(true);
|
||||
@ -500,11 +545,7 @@ namespace Elwig.Windows {
|
||||
IsEditing = false;
|
||||
DeliveryList.IsEnabled = true;
|
||||
DeliveryPartList.IsEnabled = true;
|
||||
WeighingManualButton.IsEnabled = false;
|
||||
WeighingAButton.IsEnabled = false;
|
||||
WeighingBButton.IsEnabled = false;
|
||||
WeighingCButton.IsEnabled = false;
|
||||
WeighingDButton.IsEnabled = false;
|
||||
DisableWeighingButtons();
|
||||
HideFinishNewPartDeliveryCancelButtons();
|
||||
ShowNewEditDeleteButtons();
|
||||
RefreshInputs();
|
||||
@ -522,11 +563,7 @@ namespace Elwig.Windows {
|
||||
IsCreating = true;
|
||||
DeliveryList.IsEnabled = false;
|
||||
DeliveryPartList.IsEnabled = false;
|
||||
WeighingManualButton.IsEnabled = true;
|
||||
WeighingAButton.IsEnabled = true;
|
||||
WeighingBButton.IsEnabled = true;
|
||||
WeighingCButton.IsEnabled = true;
|
||||
WeighingDButton.IsEnabled = true;
|
||||
EnableWeighingButtons();
|
||||
DeliveryList.SelectedItem = null;
|
||||
HideNewEditDeleteButtons();
|
||||
ShowFinishNewPartDeliveryCancelButtons();
|
||||
@ -545,6 +582,8 @@ namespace Elwig.Windows {
|
||||
WeightInput.Text = $"{res?.Item1:N0}";
|
||||
ManualWeighingInput.IsChecked = true;
|
||||
ManualWeighingReason = res?.Item2;
|
||||
ScaleId = null;
|
||||
WeighingId = null;
|
||||
}
|
||||
|
||||
private void EditDeliveryButton_Click(object sender, RoutedEventArgs evt) {
|
||||
@ -733,6 +772,22 @@ namespace Elwig.Windows {
|
||||
BranchInput.IsEnabled = false;
|
||||
}
|
||||
|
||||
private void DisableWeighingButtons() {
|
||||
WeighingManualButton.IsEnabled = false;
|
||||
WeighingAButton.IsEnabled = false;
|
||||
WeighingBButton.IsEnabled = false;
|
||||
WeighingCButton.IsEnabled = false;
|
||||
WeighingDButton.IsEnabled = false;
|
||||
}
|
||||
|
||||
private void EnableWeighingButtons() {
|
||||
WeighingManualButton.IsEnabled = true;
|
||||
WeighingAButton.IsEnabled = true;
|
||||
WeighingBButton.IsEnabled = true;
|
||||
WeighingCButton.IsEnabled = true;
|
||||
WeighingDButton.IsEnabled = true;
|
||||
}
|
||||
|
||||
private async Task UpdateLsNr() {
|
||||
if (DateInput.Text == "" || BranchInput.SelectedItem == null) {
|
||||
LsNrInput.Text = "";
|
||||
|
Reference in New Issue
Block a user