Add ManualWeighingDialog

This commit is contained in:
2023-08-01 16:34:22 +02:00
parent 704337aa1d
commit 75dfdb155b
6 changed files with 127 additions and 3 deletions

View File

@ -1,3 +1,4 @@
using Elwig.Dialogs;
using Elwig.Helpers;
using Elwig.Models;
using Microsoft.EntityFrameworkCore;
@ -22,6 +23,8 @@ namespace Elwig.Windows {
private List<string> TextFilter = new();
private readonly RoutedCommand CtrlF = new();
private string? ManualWeighingReason = null;
public DeliveryAdminWindow(bool receipt = false) {
InitializeComponent();
CtrlF.InputGestures.Add(new KeyGesture(Key.F, ModifierKeys.Control));
@ -216,7 +219,7 @@ namespace Elwig.Windows {
ControlUtils.SelectComboBoxItem(WineKgInput, k => (k as AT_Kg)?.KgNr, p?.KgNr);
ControlUtils.SelectComboBoxItem(WineRdInput, r => (r as WbRd)?.RdNr, p?.RdNr);
ControlUtils.SelectComboBoxItem(WineOriginInput, r => (r as WineOrigin)?.HkId, p?.HkId);
WeightInput.Text = p?.Weight.ToString() ?? "";
WeightInput.Text = (p != null) ? $"{p.Weight:N0}" : "";
ManualWeighingInput.IsChecked = p?.ManualWeighing ?? false;
GerebeltGewogenInput.IsChecked = p?.IsGerebelt ?? false;
ControlUtils.SelectCheckComboBoxItems(ModifiersInput, p?.Modifiers, i => (i as Modifier)?.ModId);
@ -453,6 +456,14 @@ namespace Elwig.Windows {
// TODO abwerten dialog
}
private void WeighingManualButton_Click(object sender, RoutedEventArgs evt) {
var res = Utils.ShowManualWeighingDialog();
if (res == null) return;
WeightInput.Text = $"{res?.Item1:N0}";
ManualWeighingInput.IsChecked = true;
ManualWeighingReason = res?.Item2;
}
private void EditDeliveryButton_Click(object sender, RoutedEventArgs evt) {
if (DeliveryPartList.SelectedItem == null)
return;
@ -795,5 +806,9 @@ namespace Elwig.Windows {
var defQual = Context.GetWineQualityLevel(double.Parse(GradationKmwInput.Text)).GetAwaiter().GetResult();
AbgewertetInput.IsChecked = !qual.IsPredicate && defQual != qual;
}
private void WeightInput_TextChanged(object sender, TextChangedEventArgs evt) {
InputTextChanged((TextBox)sender);
}
}
}