DeliveryAdminWindow: Use last scale error as default manual weighing reason
This commit is contained in:
@ -9,19 +9,16 @@ namespace Elwig.Dialogs {
|
|||||||
public int Weight = 0;
|
public int Weight = 0;
|
||||||
public string? Reason = null;
|
public string? Reason = null;
|
||||||
|
|
||||||
public ManualWeighingDialog() {
|
public ManualWeighingDialog(string? reason = null) {
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
|
ReasonInput.Text = reason;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ConfirmButton_Click(object sender, RoutedEventArgs evt) {
|
private void ConfirmButton_Click(object sender, RoutedEventArgs evt) {
|
||||||
DialogResult = true;
|
DialogResult = true;
|
||||||
Weight = int.Parse(WeightInput.Text);
|
Weight = int.Parse(WeightInput.Text);
|
||||||
Reason = Regex.Replace(ReasonInput.Text, @"\s+", " ").Trim();
|
Reason = Regex.Replace(ReasonInput.Text, @"\s+", " ").Trim();
|
||||||
if (Reason == "") {
|
if (Reason == "") Reason = null;
|
||||||
Reason = null;
|
|
||||||
} else if (!Reason.EndsWith(".") || !Reason.EndsWith("!") || !Reason.EndsWith("?")) {
|
|
||||||
Reason += ".";
|
|
||||||
}
|
|
||||||
Close();
|
Close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -219,8 +219,8 @@ namespace Elwig.Helpers {
|
|||||||
.Sum();
|
.Sum();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static (int, string?)? ShowManualWeighingDialog() {
|
public static (int, string?)? ShowManualWeighingDialog(string? reason = null) {
|
||||||
var d = new ManualWeighingDialog();
|
var d = new ManualWeighingDialog(reason);
|
||||||
return d.ShowDialog() == true ? (d.Weight, d.Reason) : null;
|
return d.ShowDialog() == true ? (d.Weight, d.Reason) : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -413,7 +413,7 @@ namespace Elwig.Windows {
|
|||||||
UpdateButtons();
|
UpdateButtons();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void TextBox_TextChanged(object sender, RoutedEventArgs evt) {
|
protected void TextBox_TextChanged(object sender, RoutedEventArgs? evt) {
|
||||||
var input = (TextBox)sender;
|
var input = (TextBox)sender;
|
||||||
if (SenderIsRequired(input) && input.Text.Length == 0) {
|
if (SenderIsRequired(input) && input.Text.Length == 0) {
|
||||||
ValidateInput(input, false);
|
ValidateInput(input, false);
|
||||||
|
@ -25,6 +25,7 @@ namespace Elwig.Windows {
|
|||||||
private List<string> TextFilter = new();
|
private List<string> TextFilter = new();
|
||||||
private readonly RoutedCommand CtrlF = new();
|
private readonly RoutedCommand CtrlF = new();
|
||||||
|
|
||||||
|
private string? LastScaleError = null;
|
||||||
private string? ManualWeighingReason = null;
|
private string? ManualWeighingReason = null;
|
||||||
private string? ScaleId = null;
|
private string? ScaleId = null;
|
||||||
private string? WeighingId = null;
|
private string? WeighingId = null;
|
||||||
@ -147,6 +148,11 @@ namespace Elwig.Windows {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void InitialInputs() {
|
private void InitialInputs() {
|
||||||
|
LastScaleError = null;
|
||||||
|
WeighingId = null;
|
||||||
|
ScaleId = null;
|
||||||
|
ManualWeighingReason = null;
|
||||||
|
|
||||||
ClearOriginalValues();
|
ClearOriginalValues();
|
||||||
ClearDefaultValues();
|
ClearDefaultValues();
|
||||||
|
|
||||||
@ -651,12 +657,18 @@ namespace Elwig.Windows {
|
|||||||
ScaleId = null;
|
ScaleId = null;
|
||||||
WeighingId = null;
|
WeighingId = null;
|
||||||
}
|
}
|
||||||
ManualWeighingReason = null;
|
LastScaleError = null;
|
||||||
ManualWeighingInput.IsChecked = false;
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
LastScaleError = e.Message.Split(": ")[^1];
|
||||||
|
WeightInput.Text = "";
|
||||||
|
ScaleId = null;
|
||||||
|
WeighingId = null;
|
||||||
MessageBox.Show($"Beim Wiegen ist ein Fehler aufgetreten:\n\n{e.Message}", "Waagenfehler",
|
MessageBox.Show($"Beim Wiegen ist ein Fehler aufgetreten:\n\n{e.Message}", "Waagenfehler",
|
||||||
MessageBoxButton.OK, MessageBoxImage.Error);
|
MessageBoxButton.OK, MessageBoxImage.Error);
|
||||||
}
|
}
|
||||||
|
ManualWeighingReason = null;
|
||||||
|
ManualWeighingInput.IsChecked = false;
|
||||||
|
base.TextBox_TextChanged(WeightInput, null);
|
||||||
EnableWeighingButtons();
|
EnableWeighingButtons();
|
||||||
UpdateButtons();
|
UpdateButtons();
|
||||||
}
|
}
|
||||||
@ -885,7 +897,7 @@ namespace Elwig.Windows {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void WeighingManualButton_Click(object sender, RoutedEventArgs evt) {
|
private void WeighingManualButton_Click(object sender, RoutedEventArgs evt) {
|
||||||
var res = Utils.ShowManualWeighingDialog();
|
var res = Utils.ShowManualWeighingDialog(LastScaleError);
|
||||||
if (res == null) return;
|
if (res == null) return;
|
||||||
WeightInput.Text = $"{res?.Item1:N0}";
|
WeightInput.Text = $"{res?.Item1:N0}";
|
||||||
ManualWeighingInput.IsChecked = true;
|
ManualWeighingInput.IsChecked = true;
|
||||||
|
Reference in New Issue
Block a user