Update DeliveryAdminWindow
This commit is contained in:
@ -1,63 +1,67 @@
|
||||
using Elwig.Models;
|
||||
|
||||
namespace Elwig.Helpers {
|
||||
public class ClientParameters {
|
||||
public class ClientParameters {
|
||||
|
||||
public string NameToken;
|
||||
public string NameShort;
|
||||
public string NameShortened;
|
||||
public string Name;
|
||||
public string NameSuffix;
|
||||
public string NameFull => $"{Name} {NameSuffix}";
|
||||
public enum Type { Matzen, GWK };
|
||||
|
||||
public PostalDest PostalDest {
|
||||
set {
|
||||
Plz = value.AtPlz.Plz;
|
||||
Ort = value.AtPlz.Ort.Name;
|
||||
}
|
||||
}
|
||||
public int Plz { get; private set; }
|
||||
public string Ort { get; private set; }
|
||||
public string Address;
|
||||
public string Sender1 => $"{NameShort} | {Address} | {Plz} {Ort}";
|
||||
public string Sender2;
|
||||
public string NameToken;
|
||||
public string NameShort;
|
||||
public string NameShortened;
|
||||
public string Name;
|
||||
public string NameSuffix;
|
||||
public string NameFull => $"{Name} {NameSuffix}";
|
||||
public Type? Client;
|
||||
|
||||
public string? Iban;
|
||||
public string? Bic;
|
||||
public string? UstId;
|
||||
public string? LfbisNr;
|
||||
public PostalDest PostalDest {
|
||||
set {
|
||||
Plz = value.AtPlz.Plz;
|
||||
Ort = value.AtPlz.Ort.Name;
|
||||
}
|
||||
}
|
||||
public int Plz { get; private set; }
|
||||
public string Ort { get; private set; }
|
||||
public string Address;
|
||||
public string Sender1 => $"{NameShort} | {Address} | {Plz} {Ort}";
|
||||
public string Sender2;
|
||||
|
||||
public string? PhoneNr;
|
||||
public string? FaxNr;
|
||||
public string? EmailAddress;
|
||||
public string? Website;
|
||||
public string? Iban;
|
||||
public string? Bic;
|
||||
public string? UstId;
|
||||
public string? LfbisNr;
|
||||
|
||||
public string? DeliveryNoteText;
|
||||
public string? PhoneNr;
|
||||
public string? FaxNr;
|
||||
public string? EmailAddress;
|
||||
public string? Website;
|
||||
|
||||
public ClientParameters() {
|
||||
NameToken = "WGM";
|
||||
NameShort = "WG Matzen";
|
||||
NameShortened = "Winzergenossenschaft f. Matzen u. Umgebung";
|
||||
Name = "Winzergenossenschaft für Matzen und Umgebung";
|
||||
NameSuffix = "reg. Gen.m.b.H.";
|
||||
Plz = 2243;
|
||||
Ort = "Matzen";
|
||||
Address = "Schloßstraße 6";
|
||||
PhoneNr = "+43 2289 2221";
|
||||
FaxNr = "+43 2289 2221";
|
||||
EmailAddress = "winzermatzen@aon.at";
|
||||
Website = "winzermatzen.at";
|
||||
LfbisNr = "0901768";
|
||||
UstId = "ATU16328105";
|
||||
Bic = "RLNWATWWGAE";
|
||||
Iban = "AT92 3209 2000 0240 0075";
|
||||
Sender2 = "E Österreichische Post AG Eco Brief";
|
||||
DeliveryNoteText = "Das Mitglied erklärt, dass die gelieferte Ware dem österreichischen Weingesetz entspricht und insbesondere die " +
|
||||
"Bestimmungen über die Mengenbeschränkungen sowie für die Erzeugung von Wein besonderer Leseart eingehalten wird. " +
|
||||
"Alle maßgeblichen Veränderungen obiger Angaben sind der Winzergenossenschaft unverzüglich zu melden. " +
|
||||
"Das Mitglied bestätigt weiters mit seiner Unterschrift, dass die gelieferten Trauben entsprechend der guten Herstellungspraxis erzeugt wurden, " +
|
||||
"insbesondere die Einhaltung der vom Hersteller vorgegebenen Wartefristen für Pflanzenschutzmittel. " +
|
||||
"Weiters wird bestätigt, dass die Datenschutzerklärung der Winzergenossenschaft für Matzen und Umgebung in der Übernahmestelle zur freien Entnahme aufliegt.";
|
||||
}
|
||||
}
|
||||
public string? DeliveryNoteText;
|
||||
|
||||
public ClientParameters() {
|
||||
NameToken = "WGM";
|
||||
NameShort = "WG Matzen";
|
||||
NameShortened = "Winzergenossenschaft f. Matzen u. Umgebung";
|
||||
Name = "Winzergenossenschaft für Matzen und Umgebung";
|
||||
NameSuffix = "reg. Gen.m.b.H.";
|
||||
Client = Type.Matzen;
|
||||
Plz = 2243;
|
||||
Ort = "Matzen";
|
||||
Address = "Schloßstraße 6";
|
||||
PhoneNr = "+43 2289 2221";
|
||||
FaxNr = "+43 2289 2221";
|
||||
EmailAddress = "winzermatzen@aon.at";
|
||||
Website = "winzermatzen.at";
|
||||
LfbisNr = "0901768";
|
||||
UstId = "ATU16328105";
|
||||
Bic = "RLNWATWWGAE";
|
||||
Iban = "AT92 3209 2000 0240 0075";
|
||||
Sender2 = "E Österreichische Post AG Eco Brief";
|
||||
DeliveryNoteText = "Das Mitglied erklärt, dass die gelieferte Ware dem österreichischen Weingesetz entspricht und insbesondere die " +
|
||||
"Bestimmungen über die Mengenbeschränkungen sowie für die Erzeugung von Wein besonderer Leseart eingehalten wird. " +
|
||||
"Alle maßgeblichen Veränderungen obiger Angaben sind der Winzergenossenschaft unverzüglich zu melden. " +
|
||||
"Das Mitglied bestätigt weiters mit seiner Unterschrift, dass die gelieferten Trauben entsprechend der guten Herstellungspraxis erzeugt wurden, " +
|
||||
"insbesondere die Einhaltung der vom Hersteller vorgegebenen Wartefristen für Pflanzenschutzmittel. " +
|
||||
"Weiters wird bestätigt, dass die Datenschutzerklärung der Winzergenossenschaft für Matzen und Umgebung in der Übernahmestelle zur freien Entnahme aufliegt.";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -161,16 +161,19 @@ namespace Elwig.Helpers.Weighing {
|
||||
var terminalNr = line[49..52].Trim();
|
||||
var crc16 = line[52..60].Trim();
|
||||
|
||||
if (Utils.CalcCrc16Modbus(record[..54]).ToString() != crc16) {
|
||||
if (Utils.CalcCrc16Modbus(record[..54]) != ushort.Parse(crc16)) {
|
||||
throw new IOException($"Invalid response from scale: Invalid CRC16 checksum ({crc16} != {Utils.CalcCrc16Modbus(record[..54]).ToString()})");
|
||||
} else if (unit != "kg") {
|
||||
throw new IOException($"Unsupported unit in weighing response: '{unit}'");
|
||||
}
|
||||
|
||||
identNr = identNr.Length > 0 && identNr != "0" ? identNr : null;
|
||||
var parsedDate = DateOnly.Parse(date);
|
||||
return new() {
|
||||
Weight = int.TryParse(netto, out int w) ? w : null,
|
||||
WeighingId = identNr.Length > 0 && identNr != "0" ? identNr : null,
|
||||
Date = DateOnly.Parse(date),
|
||||
Weight = int.Parse(netto),
|
||||
WeighingId = identNr,
|
||||
FullWeighingId = identNr != null ? $"{parsedDate:yyyy-MM-dd}/{identNr}" : null,
|
||||
Date = parsedDate,
|
||||
Time = TimeOnly.Parse(time),
|
||||
};
|
||||
}
|
||||
@ -195,10 +198,10 @@ namespace Elwig.Helpers.Weighing {
|
||||
p.DtrEnable = false;
|
||||
} else if (EmptyMode == Output.OUT1 || EmptyMode == Output.OUT2) {
|
||||
int output = EmptyMode == Output.OUT1 ? 1 : 2;
|
||||
await SendCommand($"OS{output:02i}");
|
||||
await SendCommand($"OS{output:00}");
|
||||
await ReceiveResponse();
|
||||
await Task.Delay(EmptyDelay);
|
||||
await SendCommand($"OC{output:02i}");
|
||||
await SendCommand($"OC{output:00}");
|
||||
await ReceiveResponse();
|
||||
}
|
||||
}
|
||||
@ -212,7 +215,7 @@ namespace Elwig.Helpers.Weighing {
|
||||
} else if (FillingClearanceMode == Output.OUT1 || FillingClearanceMode == Output.OUT2) {
|
||||
string cmd = status ? "OS" : "OC";
|
||||
int output = FillingClearanceMode == Output.OUT1 ? 1 : 2;
|
||||
await SendCommand($"{cmd}{output:02i}");
|
||||
await SendCommand($"{cmd}{output:00}");
|
||||
await ReceiveResponse();
|
||||
}
|
||||
}
|
||||
|
@ -15,6 +15,11 @@ namespace Elwig.Helpers.Weighing {
|
||||
/// </summary>
|
||||
public string? WeighingId = null;
|
||||
|
||||
/// <summary>
|
||||
/// Wheighing id (or IdentNr) provided by the scale optionally combined with the current date
|
||||
/// </summary>
|
||||
public string? FullWeighingId = null;
|
||||
|
||||
/// <summary>
|
||||
/// Date string provided by the scale
|
||||
/// </summary>
|
||||
|
@ -266,12 +266,16 @@
|
||||
Click="WeighingManualButton_Click"
|
||||
VerticalAlignment="Top" HorizontalAlignment="Right" Margin="10,10,10,10" Grid.Column="2"/>
|
||||
<Button x:Name="WeighingAButton" Content="Wiegen A" Width="120"
|
||||
Click="WeighingButton_Click"
|
||||
VerticalAlignment="Top" HorizontalAlignment="Right" Margin="10,42,10,10" Grid.Column="2"/>
|
||||
<Button x:Name="WeighingBButton" Content="Wiegen B" Width="120"
|
||||
Click="WeighingButton_Click"
|
||||
VerticalAlignment="Top" HorizontalAlignment="Right" Margin="10,74,10,10" Grid.Column="2"/>
|
||||
<Button x:Name="WeighingCButton" Content="Wiegen C" Width="120"
|
||||
Click="WeighingButton_Click"
|
||||
VerticalAlignment="Top" HorizontalAlignment="Right" Margin="10,106,10,10" Grid.Column="2"/>
|
||||
<Button x:Name="WeighingDButton" Content="Wiegen D" Width="120"
|
||||
Click="WeighingButton_Click"
|
||||
VerticalAlignment="Top" HorizontalAlignment="Right" Margin="10,138,10,10" Grid.Column="2"/>
|
||||
|
||||
</Grid>
|
||||
|
@ -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