DeliveryAdminWindow: Add button to correct tare
This commit is contained in:
@@ -398,7 +398,8 @@
|
||||
<Grid Grid.Row="1" Grid.Column="2">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="0.625*"/>
|
||||
<RowDefinition Height="0.875*"/>
|
||||
<RowDefinition Height="0.8125*"/>
|
||||
<RowDefinition Height="0.0625*"/>
|
||||
<RowDefinition Height="0.875*"/>
|
||||
<RowDefinition Height="0.25*"/>
|
||||
<RowDefinition Height="*"/>
|
||||
@@ -434,7 +435,7 @@
|
||||
</Grid>
|
||||
</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.ColumnDefinitions>
|
||||
<ColumnDefinition Width="100"/>
|
||||
@@ -553,7 +554,7 @@
|
||||
</Grid>
|
||||
</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.ColumnDefinitions>
|
||||
<ColumnDefinition Width="70"/>
|
||||
@@ -565,16 +566,23 @@
|
||||
TextChanged="WeightInput_TextChanged"
|
||||
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}"
|
||||
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"/>
|
||||
|
||||
<CheckBox x:Name="GerebeltGewogenInput" IsChecked="{Binding IsNetWeightValue, Mode=TwoWay}"
|
||||
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"/>
|
||||
|
||||
<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"
|
||||
Click="WeighingButton_Click"
|
||||
VerticalAlignment="Top" HorizontalAlignment="Right" Margin="10,10,10,10" Grid.Column="2"/>
|
||||
@@ -593,7 +601,7 @@
|
||||
</Grid>
|
||||
</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.ColumnDefinitions>
|
||||
<ColumnDefinition Width="100"/>
|
||||
@@ -646,7 +654,7 @@
|
||||
</Grid>
|
||||
</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.ColumnDefinitions>
|
||||
<ColumnDefinition Width="100"/>
|
||||
|
||||
@@ -9,6 +9,7 @@ using Microsoft.EntityFrameworkCore;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text.Json.Nodes;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
@@ -103,6 +104,7 @@ namespace Elwig.Windows {
|
||||
WeighingBButton.Visibility = Visibility.Hidden;
|
||||
WeighingCButton.Visibility = Visibility.Hidden;
|
||||
WeighingDButton.Visibility = Visibility.Hidden;
|
||||
DisableWeighingButtons();
|
||||
}
|
||||
|
||||
Menu_Statistics_WineQuality_ModeOe.IsChecked = false;
|
||||
@@ -612,14 +614,34 @@ namespace Elwig.Windows {
|
||||
ClearOriginalValues();
|
||||
ClearDefaultValues();
|
||||
ViewModel.FillInputs(p);
|
||||
CorrectTareButton.Visibility = !ViewModel.IsReceipt && p.WeighingInfo.Tare != null && p.WeighingInfo.Tare != 0 ? Visibility.Visible : Visibility.Hidden;
|
||||
FinishInputFilling();
|
||||
}
|
||||
|
||||
new protected void ClearInputs(bool validate = false) {
|
||||
ViewModel.ClearInputs();
|
||||
CorrectTareButton.Visibility = Visibility.Hidden;
|
||||
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) {
|
||||
int index = Array.IndexOf(WeighingButtons, sender as Button);
|
||||
if (index >= 0) WeighingButton_Click(index);
|
||||
@@ -651,12 +673,18 @@ namespace Elwig.Windows {
|
||||
private void OnWeighingResult(IScale scale, WeighingResult res) {
|
||||
if ((res.NetWeight ?? 0) > 0 && res.FullWeighingId != null) {
|
||||
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.WeighingData = res.ToJson().ToJsonString();
|
||||
ViewModel.ManualWeighingReason = null;
|
||||
ManualWeighingInput.IsChecked = false;
|
||||
} else {
|
||||
ViewModel.Weight = null;
|
||||
ViewModel.ActualTare = 0;
|
||||
ViewModel.TargetTare = null;
|
||||
ViewModel.Tare = null;
|
||||
ViewModel.ScaleTerminalId = null;
|
||||
ViewModel.WeighingData = null;
|
||||
}
|
||||
@@ -971,6 +999,8 @@ namespace Elwig.Windows {
|
||||
DeliveryList.IsEnabled = false;
|
||||
DeliveryPartList.IsEnabled = false;
|
||||
|
||||
if (!ViewModel.IsReceipt)
|
||||
EnableWeighingButtons();
|
||||
HideNewEditDeleteButtons();
|
||||
ShowSaveResetCancelButtons();
|
||||
UnlockInputs();
|
||||
@@ -1034,6 +1064,8 @@ namespace Elwig.Windows {
|
||||
DeliveryList.IsEnabled = true;
|
||||
DeliveryPartList.IsEnabled = true;
|
||||
|
||||
if (!ViewModel.IsReceipt)
|
||||
DisableWeighingButtons();
|
||||
HideSaveResetCancelButtons();
|
||||
ShowNewEditDeleteButtons();
|
||||
LockInputs();
|
||||
@@ -1067,6 +1099,8 @@ namespace Elwig.Windows {
|
||||
DeliveryList.IsEnabled = true;
|
||||
DeliveryPartList.IsEnabled = true;
|
||||
|
||||
if (!ViewModel.IsReceipt)
|
||||
DisableWeighingButtons();
|
||||
HideSaveResetCancelButtons();
|
||||
ShowNewEditDeleteButtons();
|
||||
RefreshInputs();
|
||||
@@ -1171,6 +1205,7 @@ namespace Elwig.Windows {
|
||||
}
|
||||
|
||||
private void DisableWeighingButtons() {
|
||||
CorrectTareButton.IsEnabled = false;
|
||||
WeighingManualButton.IsEnabled = false;
|
||||
WeighingAButton.IsEnabled = false;
|
||||
WeighingBButton.IsEnabled = false;
|
||||
@@ -1179,6 +1214,7 @@ namespace Elwig.Windows {
|
||||
}
|
||||
|
||||
private void EnableWeighingButtons() {
|
||||
CorrectTareButton.IsEnabled = true;
|
||||
WeighingManualButton.IsEnabled = true;
|
||||
var n = App.CommandScales.Count;
|
||||
WeighingAButton.IsEnabled = n > 0 && App.CommandScales[0].IsReady;
|
||||
|
||||
Reference in New Issue
Block a user