DeliveryAdminWindow: Add button to correct tare
This commit is contained in:
@@ -4,6 +4,7 @@
|
|||||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||||
xmlns:local="clr-namespace:Elwig.Dialogs"
|
xmlns:local="clr-namespace:Elwig.Dialogs"
|
||||||
|
xmlns:ctrl="clr-namespace:Elwig.Controls"
|
||||||
ResizeMode="NoResize" ShowInTaskbar="False" Topmost="True"
|
ResizeMode="NoResize" ShowInTaskbar="False" Topmost="True"
|
||||||
WindowStartupLocation="CenterOwner"
|
WindowStartupLocation="CenterOwner"
|
||||||
FocusManager.FocusedElement="{Binding ElementName=WeightInput}"
|
FocusManager.FocusedElement="{Binding ElementName=WeightInput}"
|
||||||
@@ -37,11 +38,9 @@
|
|||||||
</Grid.ColumnDefinitions>
|
</Grid.ColumnDefinitions>
|
||||||
|
|
||||||
<Label Content="Gewicht:" Margin="10,20,10,10"/>
|
<Label Content="Gewicht:" Margin="10,20,10,10"/>
|
||||||
<Grid Grid.Column="1" Width="70" Height="25" Margin="0,20,10,10" HorizontalAlignment="Left" VerticalAlignment="Top">
|
<ctrl:UnitTextBox x:Name="WeightInput" Grid.Column="1" Width="62" Height="25" Unit="kg"
|
||||||
<TextBox x:Name="WeightInput" TextAlignment="Right" Padding="2,2,17,2"
|
Margin="0,20,10,10" HorizontalAlignment="Left" VerticalAlignment="Top" FontSize="14" Padding="2"
|
||||||
TextChanged="WeightInput_TextChanged"/>
|
TextChanged="WeightInput_TextChanged"/>
|
||||||
<Label Content="kg" Margin="0,4,3,0" HorizontalAlignment="Right" FontSize="10" Padding="2,4,2,4"/>
|
|
||||||
</Grid>
|
|
||||||
|
|
||||||
<Label Content="Grund:" Margin="10,50,10,10"/>
|
<Label Content="Grund:" Margin="10,50,10,10"/>
|
||||||
<TextBox x:Name="ReasonInput" Grid.Column="1" Margin="0,50,10,10"
|
<TextBox x:Name="ReasonInput" Grid.Column="1" Margin="0,50,10,10"
|
||||||
|
|||||||
@@ -6,8 +6,8 @@ using System.Windows.Controls;
|
|||||||
namespace Elwig.Dialogs {
|
namespace Elwig.Dialogs {
|
||||||
public partial class ManualWeighingDialog : Window {
|
public partial class ManualWeighingDialog : Window {
|
||||||
|
|
||||||
public int Weight = 0;
|
public int Weight { get; private set; }
|
||||||
public string? Reason = null;
|
public string? Reason { get; private set; }
|
||||||
|
|
||||||
public ManualWeighingDialog(string? reason = null) {
|
public ManualWeighingDialog(string? reason = null) {
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
|
|||||||
@@ -0,0 +1,55 @@
|
|||||||
|
<Window x:Class="Elwig.Dialogs.TareCorrectionDialog"
|
||||||
|
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||||
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
|
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||||
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||||
|
xmlns:local="clr-namespace:Elwig.Dialogs"
|
||||||
|
xmlns:ctrl="clr-namespace:Elwig.Controls"
|
||||||
|
ResizeMode="NoResize" ShowInTaskbar="False" Topmost="True"
|
||||||
|
WindowStartupLocation="CenterOwner"
|
||||||
|
FocusManager.FocusedElement="{Binding ElementName=TargetTareInput}"
|
||||||
|
Title="Tara korrigieren" Height="170" Width="300">
|
||||||
|
<Window.Resources>
|
||||||
|
<Style TargetType="Label">
|
||||||
|
<Setter Property="HorizontalAlignment" Value="Left"/>
|
||||||
|
<Setter Property="VerticalAlignment" Value="Top"/>
|
||||||
|
<Setter Property="Padding" Value="2,4,2,4"/>
|
||||||
|
<Setter Property="Height" Value="25"/>
|
||||||
|
</Style>
|
||||||
|
<Style TargetType="TextBox">
|
||||||
|
<Setter Property="HorizontalAlignment" Value="Stretch"/>
|
||||||
|
<Setter Property="VerticalAlignment" Value="Top"/>
|
||||||
|
<Setter Property="FontSize" Value="14"/>
|
||||||
|
<Setter Property="Padding" Value="2"/>
|
||||||
|
<Setter Property="Height" Value="25"/>
|
||||||
|
<Setter Property="TextWrapping" Value="NoWrap"/>
|
||||||
|
</Style>
|
||||||
|
<Style TargetType="Button">
|
||||||
|
<Setter Property="HorizontalAlignment" Value="Right"/>
|
||||||
|
<Setter Property="VerticalAlignment" Value="Bottom"/>
|
||||||
|
<Setter Property="Width" Value="100"/>
|
||||||
|
<Setter Property="Height" Value="25"/>
|
||||||
|
</Style>
|
||||||
|
</Window.Resources>
|
||||||
|
<Grid>
|
||||||
|
<Grid.ColumnDefinitions>
|
||||||
|
<ColumnDefinition Width="*"/>
|
||||||
|
<ColumnDefinition Width="70"/>
|
||||||
|
<ColumnDefinition Width="3*"/>
|
||||||
|
</Grid.ColumnDefinitions>
|
||||||
|
|
||||||
|
<Label Content="Ist-Tara:" Margin="10,20,0,10" Grid.Column="1"/>
|
||||||
|
<ctrl:UnitTextBox x:Name="ActualTareInput" Grid.Column="2" Width="56" Height="25" Unit="kg" IsReadOnly="True"
|
||||||
|
Margin="0,20,10,10" HorizontalAlignment="Left" VerticalAlignment="Top" FontSize="14" Padding="2"
|
||||||
|
TextChanged="TareInput_TextChanged"/>
|
||||||
|
|
||||||
|
<Label Content="Soll-Tara:" Margin="10,50,0,10" Grid.Column="1"/>
|
||||||
|
<ctrl:UnitTextBox x:Name="TargetTareInput" Grid.Column="2" Width="56" Height="25" Unit="kg"
|
||||||
|
Margin="0,50,10,10" HorizontalAlignment="Left" VerticalAlignment="Top" FontSize="14" Padding="2"
|
||||||
|
TextChanged="TareInput_TextChanged"/>
|
||||||
|
|
||||||
|
<Button x:Name="ConfirmButton" Content="Bestätigen" Margin="10,10,115,10" Grid.ColumnSpan="3" IsEnabled="False" IsDefault="True"
|
||||||
|
Click="ConfirmButton_Click"/>
|
||||||
|
<Button x:Name="CancelButton" Content="Abbrechen" Margin="10,10,10,10" Grid.ColumnSpan="3" IsCancel="True"/>
|
||||||
|
</Grid>
|
||||||
|
</Window>
|
||||||
@@ -0,0 +1,36 @@
|
|||||||
|
using Elwig.Helpers;
|
||||||
|
using System.Windows;
|
||||||
|
using System.Windows.Controls;
|
||||||
|
|
||||||
|
namespace Elwig.Dialogs {
|
||||||
|
public partial class TareCorrectionDialog : Window {
|
||||||
|
|
||||||
|
public int ActualTare { get; private set; }
|
||||||
|
public int TargetTare { get; private set; }
|
||||||
|
|
||||||
|
public TareCorrectionDialog(int actualTare, int? targetTare = null) {
|
||||||
|
InitializeComponent();
|
||||||
|
ActualTare = actualTare;
|
||||||
|
TargetTare = targetTare ?? actualTare;
|
||||||
|
ActualTareInput.Text = ActualTare.ToString();
|
||||||
|
TargetTareInput.Text = TargetTare.ToString();
|
||||||
|
TargetTareInput.SelectAll();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ConfirmButton_Click(object sender, RoutedEventArgs evt) {
|
||||||
|
DialogResult = true;
|
||||||
|
TargetTare = int.Parse(TargetTareInput.Text);
|
||||||
|
Close();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void UpdateButtons() {
|
||||||
|
ConfirmButton.IsEnabled = TargetTareInput.Text.Length > 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void TareInput_TextChanged(object sender, TextChangedEventArgs evt) {
|
||||||
|
if (sender is not TextBox b) return;
|
||||||
|
Validator.CheckInteger(b, true, 4);
|
||||||
|
UpdateButtons();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -196,9 +196,17 @@ namespace Elwig.Documents {
|
|||||||
.Add(Italic("Brutto:"))
|
.Add(Italic("Brutto:"))
|
||||||
.Add(Normal($" {info.Gross:N0} kg \u2013 "))
|
.Add(Normal($" {info.Gross:N0} kg \u2013 "))
|
||||||
.Add(Italic("Tara:"))
|
.Add(Italic("Tara:"))
|
||||||
.Add(Normal($" {info.Tare:N0} kg \u2013 "))
|
.Add(Normal($" {info.Tare:N0} kg "));
|
||||||
|
if (info.TareCorrection != null && info.TareCorrection != 0)
|
||||||
|
weighing.Add(Bold($"(Korr.: {Utils.GetSign(info.TareCorrection.Value)}{Math.Abs(info.TareCorrection.Value)} kg)")).Add(" ");
|
||||||
|
weighing
|
||||||
|
.Add(Normal("\u2013 "))
|
||||||
.Add(Italic("Netto:"))
|
.Add(Italic("Netto:"))
|
||||||
.Add(Normal($" {info.Net:N0} kg \u2013 "))
|
.Add(Normal($" {info.Net:N0} kg "));
|
||||||
|
if (info.TareCorrection != null && info.TareCorrection != 0)
|
||||||
|
weighing.Add(Normal($"({Utils.GetSign(-info.TareCorrection.Value)}{Math.Abs(info.TareCorrection.Value)} kg) "));
|
||||||
|
weighing
|
||||||
|
.Add(Normal("\u2013 "))
|
||||||
.Add(Italic(part.IsNetWeight ? "gerebelt gewogen" : "nicht gerebelt gewogen"));
|
.Add(Italic(part.IsNetWeight ? "gerebelt gewogen" : "nicht gerebelt gewogen"));
|
||||||
} else {
|
} else {
|
||||||
weighing.Add(" ")
|
weighing.Add(" ")
|
||||||
|
|||||||
@@ -303,6 +303,11 @@ namespace Elwig.Helpers {
|
|||||||
return d.ShowDialog() == true ? (d.Weight, d.Reason) : null;
|
return d.ShowDialog() == true ? (d.Weight, d.Reason) : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static int? ShowTareCorrectionDialog(int actualTare, int? targetTare = null) {
|
||||||
|
var d = new TareCorrectionDialog(actualTare, targetTare);
|
||||||
|
return d.ShowDialog() == true ? d.TargetTare - d.ActualTare : null;
|
||||||
|
}
|
||||||
|
|
||||||
public static (string?, int[])? ShowDeliverySplittingDialog(Delivery delivery) {
|
public static (string?, int[])? ShowDeliverySplittingDialog(Delivery delivery) {
|
||||||
var d = new DeliverySplittingDialog(delivery);
|
var d = new DeliverySplittingDialog(delivery);
|
||||||
return d.ShowDialog() == true ? (d.MgNr?.ToString() ?? d.LsNr, d.Weights ?? []) : null;
|
return d.ShowDialog() == true ? (d.MgNr?.ToString() ?? d.LsNr, d.Weights ?? []) : null;
|
||||||
|
|||||||
@@ -124,7 +124,7 @@ namespace Elwig.Models.Entities {
|
|||||||
[Column("weighing_data")]
|
[Column("weighing_data")]
|
||||||
public string? WeighingData { get; set; }
|
public string? WeighingData { get; set; }
|
||||||
[NotMapped]
|
[NotMapped]
|
||||||
public (string? ScaleId, string? Id, int? Gross, int? Tare, int? Net, DateOnly? Date, TimeOnly? Time) WeighingInfo {
|
public (string? ScaleId, string? Id, int? Gross, int? Tare, int? TareCorrection, int? Net, DateOnly? Date, TimeOnly? Time) WeighingInfo {
|
||||||
get {
|
get {
|
||||||
try {
|
try {
|
||||||
var obj = JsonNode.Parse(WeighingData!)!.AsObject();
|
var obj = JsonNode.Parse(WeighingData!)!.AsObject();
|
||||||
@@ -133,12 +133,13 @@ namespace Elwig.Models.Entities {
|
|||||||
obj["id"]?.AsValue().GetValue<string>(),
|
obj["id"]?.AsValue().GetValue<string>(),
|
||||||
obj["gross_weight"]?.AsValue().GetValue<int>(),
|
obj["gross_weight"]?.AsValue().GetValue<int>(),
|
||||||
obj["tare_weight"]?.AsValue().GetValue<int>(),
|
obj["tare_weight"]?.AsValue().GetValue<int>(),
|
||||||
|
obj["tare_correction"]?.AsValue().GetValue<int>(),
|
||||||
obj["net_weight"]?.AsValue().GetValue<int>(),
|
obj["net_weight"]?.AsValue().GetValue<int>(),
|
||||||
DateOnly.TryParseExact(obj["date"]?.AsValue().GetValue<string>(), "yyyy-MM-dd", out var d) ? d : null,
|
DateOnly.TryParseExact(obj["date"]?.AsValue().GetValue<string>(), "yyyy-MM-dd", out var d) ? d : null,
|
||||||
TimeOnly.TryParseExact(obj["time"]?.AsValue().GetValue<string>(), ["HH:mm:ss", "HH:mm"], out var t) ? t : null
|
TimeOnly.TryParseExact(obj["time"]?.AsValue().GetValue<string>(), ["HH:mm:ss", "HH:mm"], out var t) ? t : null
|
||||||
);
|
);
|
||||||
} catch {
|
} catch {
|
||||||
return (null, null, null, null, null, null, null);
|
return (null, null, null, null, null, null, null, null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -35,8 +35,13 @@ namespace Elwig.Services {
|
|||||||
|
|
||||||
vm.SortId = "";
|
vm.SortId = "";
|
||||||
vm.GradationKmwString = "";
|
vm.GradationKmwString = "";
|
||||||
vm.WeightString = "";
|
|
||||||
|
vm.Weight = null;
|
||||||
|
vm.ActualTare = 0;
|
||||||
|
vm.TargetTare = null;
|
||||||
|
vm.Tare = null;
|
||||||
vm.IsManualWeighing = false;
|
vm.IsManualWeighing = false;
|
||||||
|
|
||||||
vm.PartComment = "";
|
vm.PartComment = "";
|
||||||
vm.TemperatureString = "";
|
vm.TemperatureString = "";
|
||||||
vm.AcidString = "";
|
vm.AcidString = "";
|
||||||
@@ -51,7 +56,11 @@ namespace Elwig.Services {
|
|||||||
vm.WineKg = ControlUtils.GetItemFromSourceWithPk(vm.WineKgSource, p.KgNr) as AT_Kg;
|
vm.WineKg = ControlUtils.GetItemFromSourceWithPk(vm.WineKgSource, p.KgNr) as AT_Kg;
|
||||||
vm.WineRd = ControlUtils.GetItemFromSourceWithPk(vm.WineRdSource, p.KgNr, p.RdNr) as WbRd;
|
vm.WineRd = ControlUtils.GetItemFromSourceWithPk(vm.WineRdSource, p.KgNr, p.RdNr) as WbRd;
|
||||||
vm.WineOrigin = ControlUtils.GetItemFromSourceWithPk(vm.WineOriginSource, p.HkId) as WineOrigin;
|
vm.WineOrigin = ControlUtils.GetItemFromSourceWithPk(vm.WineOriginSource, p.HkId) as WineOrigin;
|
||||||
vm.WeightString = $"{p.Weight:N0}";
|
|
||||||
|
vm.Weight = p.Weight;
|
||||||
|
vm.ActualTare = p.WeighingInfo.Tare ?? 0;
|
||||||
|
vm.TargetTare = vm.ActualTare + p.WeighingInfo.TareCorrection;
|
||||||
|
vm.Tare = vm.ActualTare != 0 ? vm.TargetTare ?? vm.ActualTare : null;
|
||||||
vm.IsManualWeighing = p.IsManualWeighing;
|
vm.IsManualWeighing = p.IsManualWeighing;
|
||||||
vm.IsNetWeight = p.IsNetWeight;
|
vm.IsNetWeight = p.IsNetWeight;
|
||||||
|
|
||||||
|
|||||||
@@ -120,6 +120,14 @@ namespace Elwig.ViewModels {
|
|||||||
set => WeightString = $"{value:N0}";
|
set => WeightString = $"{value:N0}";
|
||||||
}
|
}
|
||||||
[ObservableProperty]
|
[ObservableProperty]
|
||||||
|
private string? _tareString = "-";
|
||||||
|
public int? Tare {
|
||||||
|
get => int.TryParse(TareString?.Replace(Utils.GroupSeparator, "").Replace(" kg", ""), out var w) ? w : null;
|
||||||
|
set => TareString = value == null ? "-" : $"{value:N0} kg{(TargetTare != null ? "*" : "")}";
|
||||||
|
}
|
||||||
|
public int ActualTare;
|
||||||
|
public int? TargetTare;
|
||||||
|
[ObservableProperty]
|
||||||
private bool _isManualWeighing;
|
private bool _isManualWeighing;
|
||||||
[ObservableProperty]
|
[ObservableProperty]
|
||||||
private bool? _isNetWeightValue = false;
|
private bool? _isNetWeightValue = false;
|
||||||
|
|||||||
@@ -398,7 +398,8 @@
|
|||||||
<Grid Grid.Row="1" Grid.Column="2">
|
<Grid Grid.Row="1" Grid.Column="2">
|
||||||
<Grid.RowDefinitions>
|
<Grid.RowDefinitions>
|
||||||
<RowDefinition Height="0.625*"/>
|
<RowDefinition Height="0.625*"/>
|
||||||
<RowDefinition Height="0.875*"/>
|
<RowDefinition Height="0.8125*"/>
|
||||||
|
<RowDefinition Height="0.0625*"/>
|
||||||
<RowDefinition Height="0.875*"/>
|
<RowDefinition Height="0.875*"/>
|
||||||
<RowDefinition Height="0.25*"/>
|
<RowDefinition Height="0.25*"/>
|
||||||
<RowDefinition Height="*"/>
|
<RowDefinition Height="*"/>
|
||||||
@@ -434,7 +435,7 @@
|
|||||||
</Grid>
|
</Grid>
|
||||||
</GroupBox>
|
</GroupBox>
|
||||||
|
|
||||||
<GroupBox Header="Lieferung" Grid.Column="0" Grid.Row="1" Grid.RowSpan="3" Margin="5,5,5,5">
|
<GroupBox Header="Lieferung" Grid.Column="0" Grid.Row="1" Grid.RowSpan="4" Margin="5,5,5,5">
|
||||||
<Grid>
|
<Grid>
|
||||||
<Grid.ColumnDefinitions>
|
<Grid.ColumnDefinitions>
|
||||||
<ColumnDefinition Width="100"/>
|
<ColumnDefinition Width="100"/>
|
||||||
@@ -553,7 +554,7 @@
|
|||||||
</Grid>
|
</Grid>
|
||||||
</GroupBox>
|
</GroupBox>
|
||||||
|
|
||||||
<GroupBox Header="Menge" Grid.Column="1" Grid.Row="2" Margin="5,5,5,5">
|
<GroupBox Header="Menge" Grid.Column="1" Grid.Row="2" Grid.RowSpan="2" Margin="5,5,5,5">
|
||||||
<Grid>
|
<Grid>
|
||||||
<Grid.ColumnDefinitions>
|
<Grid.ColumnDefinitions>
|
||||||
<ColumnDefinition Width="70"/>
|
<ColumnDefinition Width="70"/>
|
||||||
@@ -565,16 +566,23 @@
|
|||||||
TextChanged="WeightInput_TextChanged"
|
TextChanged="WeightInput_TextChanged"
|
||||||
Grid.Column="1" Width="70" Margin="0,10,10,10" HorizontalAlignment="Left" VerticalAlignment="Top"/>
|
Grid.Column="1" Width="70" Margin="0,10,10,10" HorizontalAlignment="Left" VerticalAlignment="Top"/>
|
||||||
|
|
||||||
|
<Label Content="Tara:" Margin="10,40,10,10"/>
|
||||||
|
<TextBlock x:Name="Tare" Text="{Binding TareString}" Width="40"
|
||||||
|
Grid.Column="1" Margin="30,44,10,10" TextAlignment="Center" HorizontalAlignment="Left" VerticalAlignment="Top"/>
|
||||||
|
|
||||||
<CheckBox x:Name="ManualWeighingInput" IsChecked="{Binding IsManualWeighing, Mode=TwoWay}"
|
<CheckBox x:Name="ManualWeighingInput" IsChecked="{Binding IsManualWeighing, Mode=TwoWay}"
|
||||||
Content="Handwiegung" IsEnabled="False"
|
Content="Handwiegung" IsEnabled="False"
|
||||||
VerticalAlignment="Top" HorizontalAlignment="Left" Margin="10,45,10,10" Grid.Column="0" Grid.ColumnSpan="2"
|
VerticalAlignment="Top" HorizontalAlignment="Left" Margin="10,75,10,10" Grid.Column="0" Grid.ColumnSpan="2"
|
||||||
Checked="CheckBox_Changed" Unchecked="CheckBox_Changed"/>
|
Checked="CheckBox_Changed" Unchecked="CheckBox_Changed"/>
|
||||||
|
|
||||||
<CheckBox x:Name="GerebeltGewogenInput" IsChecked="{Binding IsNetWeightValue, Mode=TwoWay}"
|
<CheckBox x:Name="GerebeltGewogenInput" IsChecked="{Binding IsNetWeightValue, Mode=TwoWay}"
|
||||||
Content="Gerebelt gewogen" IsThreeState="True"
|
Content="Gerebelt gewogen" IsThreeState="True"
|
||||||
VerticalAlignment="Top" HorizontalAlignment="Left" Margin="10,75,10,10" Grid.Column="0" Grid.ColumnSpan="2"
|
VerticalAlignment="Top" HorizontalAlignment="Left" Margin="10,100,10,10" Grid.Column="0" Grid.ColumnSpan="2"
|
||||||
Checked="GerebeltGewogenInput_Changed" Unchecked="GerebeltGewogenInput_Changed" Indeterminate="GerebeltGewogenInput_Changed"/>
|
Checked="GerebeltGewogenInput_Changed" Unchecked="GerebeltGewogenInput_Changed" Indeterminate="GerebeltGewogenInput_Changed"/>
|
||||||
|
|
||||||
|
<Button x:Name="CorrectTareButton" Content="Tara korrigieren" Width="120" Visibility="Hidden"
|
||||||
|
Click="CorrectTareButton_Click"
|
||||||
|
VerticalAlignment="Top" HorizontalAlignment="Right" Margin="10,10,10,10" Grid.Column="2"/>
|
||||||
<Button x:Name="WeighingAButton" Content="Wiegen A" Width="120"
|
<Button x:Name="WeighingAButton" Content="Wiegen A" Width="120"
|
||||||
Click="WeighingButton_Click"
|
Click="WeighingButton_Click"
|
||||||
VerticalAlignment="Top" HorizontalAlignment="Right" Margin="10,10,10,10" Grid.Column="2"/>
|
VerticalAlignment="Top" HorizontalAlignment="Right" Margin="10,10,10,10" Grid.Column="2"/>
|
||||||
@@ -593,7 +601,7 @@
|
|||||||
</Grid>
|
</Grid>
|
||||||
</GroupBox>
|
</GroupBox>
|
||||||
|
|
||||||
<GroupBox Header="Sonstiges" Grid.Column="1" Grid.Row="3" Grid.RowSpan="2" Margin="5,5,5,10">
|
<GroupBox Header="Sonstiges" Grid.Column="1" Grid.Row="4" Grid.RowSpan="2" Margin="5,5,5,10">
|
||||||
<Grid>
|
<Grid>
|
||||||
<Grid.ColumnDefinitions>
|
<Grid.ColumnDefinitions>
|
||||||
<ColumnDefinition Width="100"/>
|
<ColumnDefinition Width="100"/>
|
||||||
@@ -646,7 +654,7 @@
|
|||||||
</Grid>
|
</Grid>
|
||||||
</GroupBox>
|
</GroupBox>
|
||||||
|
|
||||||
<GroupBox Header="Herkunft" Grid.Column="0" Grid.Row="4" Margin="5,5,5,10">
|
<GroupBox Header="Herkunft" Grid.Column="0" Grid.Row="5" Margin="5,5,5,10">
|
||||||
<Grid>
|
<Grid>
|
||||||
<Grid.ColumnDefinitions>
|
<Grid.ColumnDefinitions>
|
||||||
<ColumnDefinition Width="100"/>
|
<ColumnDefinition Width="100"/>
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ using Microsoft.EntityFrameworkCore;
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using System.Text.Json.Nodes;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using System.Windows;
|
using System.Windows;
|
||||||
using System.Windows.Controls;
|
using System.Windows.Controls;
|
||||||
@@ -103,6 +104,7 @@ namespace Elwig.Windows {
|
|||||||
WeighingBButton.Visibility = Visibility.Hidden;
|
WeighingBButton.Visibility = Visibility.Hidden;
|
||||||
WeighingCButton.Visibility = Visibility.Hidden;
|
WeighingCButton.Visibility = Visibility.Hidden;
|
||||||
WeighingDButton.Visibility = Visibility.Hidden;
|
WeighingDButton.Visibility = Visibility.Hidden;
|
||||||
|
DisableWeighingButtons();
|
||||||
}
|
}
|
||||||
|
|
||||||
Menu_Statistics_WineQuality_ModeOe.IsChecked = false;
|
Menu_Statistics_WineQuality_ModeOe.IsChecked = false;
|
||||||
@@ -612,14 +614,34 @@ namespace Elwig.Windows {
|
|||||||
ClearOriginalValues();
|
ClearOriginalValues();
|
||||||
ClearDefaultValues();
|
ClearDefaultValues();
|
||||||
ViewModel.FillInputs(p);
|
ViewModel.FillInputs(p);
|
||||||
|
CorrectTareButton.Visibility = !ViewModel.IsReceipt && p.WeighingInfo.Tare != null && p.WeighingInfo.Tare != 0 ? Visibility.Visible : Visibility.Hidden;
|
||||||
FinishInputFilling();
|
FinishInputFilling();
|
||||||
}
|
}
|
||||||
|
|
||||||
new protected void ClearInputs(bool validate = false) {
|
new protected void ClearInputs(bool validate = false) {
|
||||||
ViewModel.ClearInputs();
|
ViewModel.ClearInputs();
|
||||||
|
CorrectTareButton.Visibility = Visibility.Hidden;
|
||||||
base.ClearInputs(validate);
|
base.ClearInputs(validate);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void CorrectTareButton_Click(object sender, RoutedEventArgs evt) {
|
||||||
|
var lastCorrection = (ViewModel.TargetTare ?? ViewModel.ActualTare) - ViewModel.ActualTare;
|
||||||
|
var correction = Utils.ShowTareCorrectionDialog(ViewModel.ActualTare, ViewModel.TargetTare);
|
||||||
|
if (correction == null) return;
|
||||||
|
ViewModel.Weight += lastCorrection - correction;
|
||||||
|
ViewModel.TargetTare = correction == 0 ? null : ViewModel.ActualTare + correction;
|
||||||
|
ViewModel.Tare = ViewModel.TargetTare ?? ViewModel.ActualTare;
|
||||||
|
if (ViewModel.WeighingData is string s) {
|
||||||
|
var obj = JsonNode.Parse(s)!.AsObject();
|
||||||
|
if (correction == 0) {
|
||||||
|
obj.Remove("tare_correction");
|
||||||
|
} else {
|
||||||
|
obj["tare_correction"] = correction;
|
||||||
|
}
|
||||||
|
ViewModel.WeighingData = obj.ToJsonString(Utils.JsonOpts);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void WeighingButton_Click(object sender, RoutedEventArgs evt) {
|
private void WeighingButton_Click(object sender, RoutedEventArgs evt) {
|
||||||
int index = Array.IndexOf(WeighingButtons, sender as Button);
|
int index = Array.IndexOf(WeighingButtons, sender as Button);
|
||||||
if (index >= 0) WeighingButton_Click(index);
|
if (index >= 0) WeighingButton_Click(index);
|
||||||
@@ -651,12 +673,18 @@ namespace Elwig.Windows {
|
|||||||
private void OnWeighingResult(IScale scale, WeighingResult res) {
|
private void OnWeighingResult(IScale scale, WeighingResult res) {
|
||||||
if ((res.NetWeight ?? 0) > 0 && res.FullWeighingId != null) {
|
if ((res.NetWeight ?? 0) > 0 && res.FullWeighingId != null) {
|
||||||
ViewModel.Weight = res.NetWeight;
|
ViewModel.Weight = res.NetWeight;
|
||||||
|
ViewModel.ActualTare = res.TareWeight ?? 0;
|
||||||
|
ViewModel.TargetTare = null;
|
||||||
|
ViewModel.Tare = ViewModel.ActualTare != 0 ? ViewModel.ActualTare : null;
|
||||||
ViewModel.ScaleTerminalId = scale.ScaleTerminalId;
|
ViewModel.ScaleTerminalId = scale.ScaleTerminalId;
|
||||||
ViewModel.WeighingData = res.ToJson().ToJsonString();
|
ViewModel.WeighingData = res.ToJson().ToJsonString();
|
||||||
ViewModel.ManualWeighingReason = null;
|
ViewModel.ManualWeighingReason = null;
|
||||||
ManualWeighingInput.IsChecked = false;
|
ManualWeighingInput.IsChecked = false;
|
||||||
} else {
|
} else {
|
||||||
ViewModel.Weight = null;
|
ViewModel.Weight = null;
|
||||||
|
ViewModel.ActualTare = 0;
|
||||||
|
ViewModel.TargetTare = null;
|
||||||
|
ViewModel.Tare = null;
|
||||||
ViewModel.ScaleTerminalId = null;
|
ViewModel.ScaleTerminalId = null;
|
||||||
ViewModel.WeighingData = null;
|
ViewModel.WeighingData = null;
|
||||||
}
|
}
|
||||||
@@ -971,6 +999,8 @@ namespace Elwig.Windows {
|
|||||||
DeliveryList.IsEnabled = false;
|
DeliveryList.IsEnabled = false;
|
||||||
DeliveryPartList.IsEnabled = false;
|
DeliveryPartList.IsEnabled = false;
|
||||||
|
|
||||||
|
if (!ViewModel.IsReceipt)
|
||||||
|
EnableWeighingButtons();
|
||||||
HideNewEditDeleteButtons();
|
HideNewEditDeleteButtons();
|
||||||
ShowSaveResetCancelButtons();
|
ShowSaveResetCancelButtons();
|
||||||
UnlockInputs();
|
UnlockInputs();
|
||||||
@@ -1034,6 +1064,8 @@ namespace Elwig.Windows {
|
|||||||
DeliveryList.IsEnabled = true;
|
DeliveryList.IsEnabled = true;
|
||||||
DeliveryPartList.IsEnabled = true;
|
DeliveryPartList.IsEnabled = true;
|
||||||
|
|
||||||
|
if (!ViewModel.IsReceipt)
|
||||||
|
DisableWeighingButtons();
|
||||||
HideSaveResetCancelButtons();
|
HideSaveResetCancelButtons();
|
||||||
ShowNewEditDeleteButtons();
|
ShowNewEditDeleteButtons();
|
||||||
LockInputs();
|
LockInputs();
|
||||||
@@ -1067,6 +1099,8 @@ namespace Elwig.Windows {
|
|||||||
DeliveryList.IsEnabled = true;
|
DeliveryList.IsEnabled = true;
|
||||||
DeliveryPartList.IsEnabled = true;
|
DeliveryPartList.IsEnabled = true;
|
||||||
|
|
||||||
|
if (!ViewModel.IsReceipt)
|
||||||
|
DisableWeighingButtons();
|
||||||
HideSaveResetCancelButtons();
|
HideSaveResetCancelButtons();
|
||||||
ShowNewEditDeleteButtons();
|
ShowNewEditDeleteButtons();
|
||||||
RefreshInputs();
|
RefreshInputs();
|
||||||
@@ -1171,6 +1205,7 @@ namespace Elwig.Windows {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void DisableWeighingButtons() {
|
private void DisableWeighingButtons() {
|
||||||
|
CorrectTareButton.IsEnabled = false;
|
||||||
WeighingManualButton.IsEnabled = false;
|
WeighingManualButton.IsEnabled = false;
|
||||||
WeighingAButton.IsEnabled = false;
|
WeighingAButton.IsEnabled = false;
|
||||||
WeighingBButton.IsEnabled = false;
|
WeighingBButton.IsEnabled = false;
|
||||||
@@ -1179,6 +1214,7 @@ namespace Elwig.Windows {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void EnableWeighingButtons() {
|
private void EnableWeighingButtons() {
|
||||||
|
CorrectTareButton.IsEnabled = true;
|
||||||
WeighingManualButton.IsEnabled = true;
|
WeighingManualButton.IsEnabled = true;
|
||||||
var n = App.CommandScales.Count;
|
var n = App.CommandScales.Count;
|
||||||
WeighingAButton.IsEnabled = n > 0 && App.CommandScales[0].IsReady;
|
WeighingAButton.IsEnabled = n > 0 && App.CommandScales[0].IsReady;
|
||||||
|
|||||||
Reference in New Issue
Block a user