DeliveryAdminWindow: Add DeliverySplittingDialog
All checks were successful
Test / Run tests (push) Successful in 2m10s
All checks were successful
Test / Run tests (push) Successful in 2m10s
This commit is contained in:
@ -1,56 +0,0 @@
|
||||
<Window x:Class="Elwig.Dialogs.AbwertenDialog"
|
||||
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"
|
||||
ResizeMode="NoResize" ShowInTaskbar="False" Topmost="True"
|
||||
WindowStartupLocation="CenterOwner"
|
||||
FocusManager.FocusedElement="{Binding ElementName=WeightInput}"
|
||||
Title="Teillieferung abwerten" Height="190" Width="400">
|
||||
<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="70"/>
|
||||
<ColumnDefinition/>
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<TextBlock Margin="10,10,10,10" Grid.ColumnSpan="2" TextWrapping="Wrap" TextAlignment="Center">
|
||||
Welche Menge der Teillieferung <Run x:Name="TextLsNr" FontWeight="Bold" Text="20201010A000/1"/><LineBreak/>
|
||||
von <Run x:Name="TextMember" FontWeight="Bold" Text="Max Mustermann"/><LineBreak/>
|
||||
mit <Run x:Name="TextWeight" FontWeight="Bold" Text="1 000 kg"/> soll abgewertet werden?
|
||||
</TextBlock>
|
||||
|
||||
<Label Content="Gewicht:" Margin="10,70,10,10"/>
|
||||
<Grid Grid.Column="1" Width="70" Height="25" Margin="0,70,10,10" HorizontalAlignment="Left" VerticalAlignment="Top">
|
||||
<TextBox x:Name="WeightInput" TextAlignment="Right" Padding="2,2,17,2"
|
||||
TextChanged="WeightInput_TextChanged"/>
|
||||
<Label Content="kg" Margin="0,4,3,0" HorizontalAlignment="Right" FontSize="10" Padding="2,4,2,4"/>
|
||||
</Grid>
|
||||
|
||||
<Button x:Name="ConfirmButton" Content="Bestätigen" Margin="10,10,115,10" Grid.Column="1" IsEnabled="False" IsDefault="True"
|
||||
Click="ConfirmButton_Click"/>
|
||||
<Button x:Name="CancelButton" Content="Abbrechen" Margin="10,10,10,10" Grid.Column="1" IsCancel="True"/>
|
||||
</Grid>
|
||||
</Window>
|
@ -1,33 +0,0 @@
|
||||
using Elwig.Helpers;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
|
||||
namespace Elwig.Dialogs {
|
||||
public partial class AbwertenDialog : Window {
|
||||
|
||||
public int Weight;
|
||||
|
||||
public AbwertenDialog(string lsnr, string name, int weight) {
|
||||
Weight = weight;
|
||||
InitializeComponent();
|
||||
TextLsNr.Text = lsnr;
|
||||
TextMember.Text = name;
|
||||
TextWeight.Text = $"{weight:N0}{Utils.UnitSeparator}kg";
|
||||
}
|
||||
|
||||
private void ConfirmButton_Click(object sender, RoutedEventArgs evt) {
|
||||
DialogResult = true;
|
||||
Weight = int.Parse(WeightInput.Text);
|
||||
Close();
|
||||
}
|
||||
|
||||
private void UpdateButtons() {
|
||||
ConfirmButton.IsEnabled = int.TryParse(WeightInput.Text, out var w) && w > 0 && w <= Weight;
|
||||
}
|
||||
|
||||
private void WeightInput_TextChanged(object sender, TextChangedEventArgs evt) {
|
||||
Validator.CheckInteger(WeightInput, true, 5);
|
||||
UpdateButtons();
|
||||
}
|
||||
}
|
||||
}
|
@ -57,8 +57,8 @@
|
||||
Checked="CheckBox_Changed" Unchecked="CheckBox_Changed"
|
||||
IsChecked="{Binding DeletePaymentData}"/>
|
||||
|
||||
<Button x:Name="ConfirmButton" Content="Bestätigen" Margin="10,10,115,10" Grid.Column="1" IsEnabled="False"
|
||||
<Button x:Name="ConfirmButton" Content="Bestätigen" Margin="10,10,115,10" IsEnabled="False"
|
||||
Click="ConfirmButton_Click"/>
|
||||
<Button x:Name="CancelButton" Content="Abbrechen" Margin="10,10,10,10" Grid.Column="1" IsCancel="True"/>
|
||||
<Button x:Name="CancelButton" Content="Abbrechen" Margin="10,10,10,10" IsCancel="True"/>
|
||||
</Grid>
|
||||
</Window>
|
||||
|
@ -1,57 +0,0 @@
|
||||
<Window x:Class="Elwig.Dialogs.DeliveryExtractionDialog"
|
||||
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"
|
||||
ResizeMode="NoResize" ShowInTaskbar="False" Topmost="True"
|
||||
WindowStartupLocation="CenterOwner"
|
||||
FocusManager.FocusedElement="{Binding ElementName=WeightInput}"
|
||||
Title="Teillieferung extrahieren" Height="210" Width="380">
|
||||
<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="200"/>
|
||||
<ColumnDefinition/>
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<TextBlock Margin="10,10,0,10" TextWrapping="Wrap">
|
||||
Was soll mit der Teillieferung <Run x:Name="TextLsNr" FontWeight="Bold" Text="20201010A000/1"/><LineBreak/>
|
||||
von <Run x:Name="TextMember" FontWeight="Bold" Text="Max Mustermann"/> geschehen?
|
||||
</TextBlock>
|
||||
<RadioButton x:Name="NewDeliveryButton" Content="Neue Lieferung erstellen"
|
||||
Margin="10,80,0,10" HorizontalAlignment="Left" VerticalAlignment="Top"
|
||||
Checked="Selection_Changed" Unchecked="Selection_Changed"/>
|
||||
<RadioButton x:Name="AddToDeliveryButton" Content="Zu Lieferung hinzufügen"
|
||||
Margin="10,100,0,10" HorizontalAlignment="Left" VerticalAlignment="Top"
|
||||
Checked="Selection_Changed" Unchecked="Selection_Changed"/>
|
||||
|
||||
<ListBox x:Name="DeliveryList" Grid.Column="1" Margin="10,10,10,45"
|
||||
SelectionChanged="DeliveryList_SelectionChanged"/>
|
||||
|
||||
<Button x:Name="ConfirmButton" Content="Bestätigen" Margin="10,10,115,10" Grid.ColumnSpan="2" IsEnabled="False" IsDefault="True"
|
||||
Click="ConfirmButton_Click"/>
|
||||
<Button x:Name="CancelButton" Content="Abbrechen" Margin="10,10,10,10" Grid.ColumnSpan="2" IsCancel="True"/>
|
||||
</Grid>
|
||||
</Window>
|
@ -1,37 +0,0 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Windows;
|
||||
|
||||
namespace Elwig.Dialogs {
|
||||
public partial class DeliveryExtractionDialog : Window {
|
||||
|
||||
public string? AddTo;
|
||||
|
||||
public DeliveryExtractionDialog(string lsnr, string name, bool single, IEnumerable<string> lsnrs) {
|
||||
InitializeComponent();
|
||||
TextLsNr.Text = lsnr;
|
||||
TextMember.Text = name;
|
||||
NewDeliveryButton.IsEnabled = !single;
|
||||
DeliveryList.IsEnabled = false;
|
||||
DeliveryList.ItemsSource = lsnrs;
|
||||
}
|
||||
|
||||
private void ConfirmButton_Click(object sender, RoutedEventArgs evt) {
|
||||
DialogResult = true;
|
||||
AddTo = NewDeliveryButton.IsChecked == true ? "new" : DeliveryList.SelectedItem as string;
|
||||
Close();
|
||||
}
|
||||
|
||||
private void UpdateButtons() {
|
||||
ConfirmButton.IsEnabled = NewDeliveryButton.IsChecked == true || (AddToDeliveryButton.IsChecked == true && DeliveryList.SelectedItem != null);
|
||||
DeliveryList.IsEnabled = AddToDeliveryButton.IsChecked == true;
|
||||
}
|
||||
|
||||
private void Selection_Changed(object sender, RoutedEventArgs evt) {
|
||||
UpdateButtons();
|
||||
}
|
||||
|
||||
private void DeliveryList_SelectionChanged(object sender, RoutedEventArgs evt) {
|
||||
UpdateButtons();
|
||||
}
|
||||
}
|
||||
}
|
104
Elwig/Dialogs/DeliverySplittingDialog.xaml
Normal file
104
Elwig/Dialogs/DeliverySplittingDialog.xaml
Normal file
@ -0,0 +1,104 @@
|
||||
<local:ContextWindow
|
||||
x:Class="Elwig.Dialogs.DeliverySplittingDialog"
|
||||
AutomationProperties.AutomationId="DeliverySplittingDialog"
|
||||
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:local="clr-namespace:Elwig.Windows"
|
||||
xmlns:ctrl="clr-namespace:Elwig.Controls"
|
||||
ResizeMode="NoResize" ShowInTaskbar="False" Topmost="True"
|
||||
WindowStartupLocation="CenterOwner"
|
||||
DataContext="{Binding RelativeSource={RelativeSource Self}}"
|
||||
Title="Lieferung abwerten oder aufteilen" Height="400" Width="600">
|
||||
<Window.Resources>
|
||||
<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>
|
||||
|
||||
<RadioButton x:Name="DepreciateModeInput" GroupName="ModeInput" Content="Abwerten" Margin="15,10,10,10" IsChecked="True"
|
||||
VerticalAlignment="Top" HorizontalAlignment="Left"
|
||||
Checked="ModeInput_Changed"/>
|
||||
<RadioButton x:Name="MemberModeInput" GroupName="ModeInput" Content="Auf Mitglied übertragen" Margin="15,30,10,10"
|
||||
VerticalAlignment="Top" HorizontalAlignment="Left"
|
||||
Checked="ModeInput_Changed"/>
|
||||
<RadioButton x:Name="DeliveryModeInput" GroupName="ModeInput" Content="Zu anderer Lieferung hinzufügen" Margin="15,50,10,10"
|
||||
VerticalAlignment="Top" HorizontalAlignment="Left"
|
||||
Checked="ModeInput_Changed"/>
|
||||
|
||||
<TextBox x:Name="MgNrInput" FontSize="14" Padding="2" Visibility="Hidden"
|
||||
Width="48" Margin="220,10,0,0" Height="25" TextAlignment="Right"
|
||||
TextChanged="MgNrInput_TextChanged"
|
||||
VerticalAlignment="Top" HorizontalAlignment="Left"/>
|
||||
<ComboBox x:Name="MemberInput" FontSize="14" Visibility="Hidden"
|
||||
Margin="273,10,40,10" IsEditable="True" Height="25"
|
||||
ItemTemplate="{StaticResource MemberAdminNameTemplate}" TextSearch.TextPath="AdministrativeName"
|
||||
SelectionChanged="MemberInput_SelectionChanged"
|
||||
VerticalAlignment="Top" HorizontalAlignment="Stretch"/>
|
||||
<Button x:Name="MemberReferenceButton" Height="25" Width="25" FontFamily="Segoe MDL2 Assets" Content="" Padding="0"
|
||||
Margin="10,10,10,10" VerticalAlignment="Top" HorizontalAlignment="Right" ToolTip="Zu Mitglied springen" FontSize="14" Visibility="Hidden"
|
||||
Click="MemberReferenceButton_Click"/>
|
||||
|
||||
<ComboBox x:Name="DeliveryInput" FontSize="14" Visibility="Hidden"
|
||||
Margin="220,10,10,10" Height="25"
|
||||
TextSearch.TextPath="LsNr"
|
||||
SelectionChanged="DeliveryInput_SelectionChanged"
|
||||
VerticalAlignment="Top" HorizontalAlignment="Stretch">
|
||||
<ComboBox.ItemTemplate>
|
||||
<DataTemplate>
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<TextBlock Text="{Binding LsNr}" Width="100"/>
|
||||
<TextBlock Text="{Binding Weight, StringFormat='{}{0:N0} kg'}" Width="80" TextAlignment="Right" Margin="0,0,10,0"/>
|
||||
<TextBlock Text="{Binding Member.AdministrativeName}"/>
|
||||
</StackPanel>
|
||||
</DataTemplate>
|
||||
</ComboBox.ItemTemplate>
|
||||
</ComboBox>
|
||||
|
||||
<TextBlock x:Name="InfoBlock" Margin="230,45,10,10" FontSize="14" TextAlignment="Right"
|
||||
VerticalAlignment="Top" HorizontalAlignment="Stretch"
|
||||
Text="Insgesamt 0 kg / 0 kg ausgewählt."/>
|
||||
|
||||
<ListBox x:Name="DeliveryPartList" Margin="10,75,10,40" ItemsSource="{Binding DeliveryParts, Mode=TwoWay}">
|
||||
<ListBox.ItemContainerStyle>
|
||||
<Style TargetType="{x:Type ListBoxItem}">
|
||||
<Setter Property="Focusable" Value="False"/>
|
||||
</Style>
|
||||
</ListBox.ItemContainerStyle>
|
||||
<ListBox.ItemTemplate>
|
||||
<DataTemplate>
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<TextBlock Text="{Binding Part.DPNr}" Width="20" TextAlignment="Right"
|
||||
VerticalAlignment="Center" Margin="0,0,5,0" FontSize="14"/>
|
||||
<TextBlock Text="{Binding Part.SortId}" Width="40" TextAlignment="Center"
|
||||
VerticalAlignment="Center" Margin="0,0,0,0" FontSize="14"/>
|
||||
<TextBlock Text="{Binding Part.Kmw, StringFormat='{}{0:N1}°'}" Width="40" TextAlignment="Right" Padding="0,0,10,0"
|
||||
VerticalAlignment="Center"/>
|
||||
<TextBlock Text="{Binding Part.QualId}" Width="30"
|
||||
VerticalAlignment="Center"/>
|
||||
<TextBlock Text="{Binding Part.Weight, StringFormat='{}{0:N0} kg'}" Width="70" TextAlignment="Right"
|
||||
VerticalAlignment="Center" Margin="0,0,10,0" FontSize="14"/>
|
||||
<TextBlock Text="{Binding Part.Attribute.Name}" Width="60"
|
||||
VerticalAlignment="Center"/>
|
||||
<TextBlock Text="{Binding Part.Cultivation.Name}" Width="50"
|
||||
VerticalAlignment="Center"/>
|
||||
<CheckBox IsChecked="{Binding SplitCompletely, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" Content="Vollständig" Tag="{Binding Part.DPNr}"
|
||||
VerticalAlignment="Center" Margin="20,0,5,0"
|
||||
Checked="SplitCompletelyInput_Changed" Unchecked="SplitCompletelyInput_Changed"/>
|
||||
<ctrl:UnitTextBox Text="{Binding SplitWeightString, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" Unit="kg" Width="70" Height="25" IsEnabled="{Binding SplitWeightEnabled}" Tag="{Binding Part.DPNr}"
|
||||
VerticalAlignment="Center" Margin="5,0,5,0" FontSize="14" Padding="2" Background="White"
|
||||
TextChanged="SplitWeightInput_TextChanged"/>
|
||||
</StackPanel>
|
||||
</DataTemplate>
|
||||
</ListBox.ItemTemplate>
|
||||
</ListBox>
|
||||
|
||||
<Button x:Name="ConfirmButton" Content="Bestätigen" Margin="10,10,115,10" IsEnabled="False"
|
||||
Click="ConfirmButton_Click"/>
|
||||
<Button x:Name="CancelButton" Content="Abbrechen" Margin="10,10,10,10" IsCancel="True"/>
|
||||
</Grid>
|
||||
</local:ContextWindow>
|
163
Elwig/Dialogs/DeliverySplittingDialog.xaml.cs
Normal file
163
Elwig/Dialogs/DeliverySplittingDialog.xaml.cs
Normal file
@ -0,0 +1,163 @@
|
||||
using Elwig.Helpers;
|
||||
using Elwig.Models.Entities;
|
||||
using Elwig.Windows;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Data;
|
||||
|
||||
namespace Elwig.Dialogs {
|
||||
public partial class DeliverySplittingDialog : ContextWindow {
|
||||
|
||||
public class Row {
|
||||
public DeliveryPart Part { get; set; }
|
||||
public bool SplitCompletely { get; set; }
|
||||
public string? SplitWeightString { get; set; }
|
||||
public int? SplitWeight {
|
||||
get => int.TryParse(SplitWeightString, out var v) ? v : null;
|
||||
set => SplitWeightString = $"{value}";
|
||||
}
|
||||
public bool SplitWeightEnabled { get; set; }
|
||||
}
|
||||
|
||||
private readonly Delivery _delivery;
|
||||
|
||||
public int? MgNr { get; set; }
|
||||
public string? LsNr { get; set; }
|
||||
public int[]? Weights => DeliveryParts.Select(r => r.SplitCompletely ? r.Part.Weight : r.SplitWeight ?? 0).ToArray();
|
||||
|
||||
public ObservableCollection<Row> DeliveryParts { get; set; }
|
||||
|
||||
public DeliverySplittingDialog(Delivery d) {
|
||||
_delivery = d;
|
||||
DeliveryParts = new(d.Parts.Select(p => new Row {
|
||||
Part = p,
|
||||
SplitCompletely = false,
|
||||
SplitWeight = null,
|
||||
SplitWeightEnabled = true,
|
||||
}).ToList());
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
protected override async Task OnRenewContext(AppDbContext ctx) {
|
||||
ControlUtils.RenewItemsSource(MemberInput, await ctx.Members
|
||||
.Where(m => m.IsActive)
|
||||
.OrderBy(m => m.Name)
|
||||
.ThenBy(m => m.GivenName)
|
||||
.ToListAsync());
|
||||
ControlUtils.RenewItemsSource(DeliveryInput, await ctx.Deliveries
|
||||
.Where(d => d.DateString == $"{_delivery.Date:yyyy-MM-dd}" && d.ZwstId == _delivery.ZwstId)
|
||||
.OrderBy(d => d.LsNr)
|
||||
.Include(d => d.Member)
|
||||
.Include(d => d.Parts)
|
||||
.ToListAsync());
|
||||
if (DeliveryInput.SelectedItem == null)
|
||||
ControlUtils.SelectItem(DeliveryInput, _delivery);
|
||||
CheckValidity();
|
||||
}
|
||||
|
||||
private void ConfirmButton_Click(object sender, RoutedEventArgs evt) {
|
||||
if (DepreciateModeInput.IsChecked == true) {
|
||||
MgNr = null;
|
||||
LsNr = null;
|
||||
} else if (MemberModeInput.IsChecked == true) {
|
||||
MgNr = ((Member)MemberInput.SelectedItem).MgNr;
|
||||
LsNr = null;
|
||||
} else if (DeliveryModeInput.IsChecked == true) {
|
||||
MgNr = null;
|
||||
LsNr = ((Delivery)DeliveryInput.SelectedItem).LsNr;
|
||||
}
|
||||
DialogResult = true;
|
||||
Close();
|
||||
}
|
||||
|
||||
private void ModeInput_Changed(object sender, RoutedEventArgs evt) {
|
||||
if (!IsLoaded) return;
|
||||
CheckValidity();
|
||||
if (DepreciateModeInput.IsChecked == true) {
|
||||
MgNrInput.Visibility = Visibility.Hidden;
|
||||
MemberInput.Visibility = Visibility.Hidden;
|
||||
MemberReferenceButton.Visibility = Visibility.Hidden;
|
||||
DeliveryInput.Visibility = Visibility.Hidden;
|
||||
} else if (MemberModeInput.IsChecked == true) {
|
||||
MgNrInput.Visibility = Visibility.Visible;
|
||||
MemberInput.Visibility = Visibility.Visible;
|
||||
MemberReferenceButton.Visibility = Visibility.Visible;
|
||||
DeliveryInput.Visibility = Visibility.Hidden;
|
||||
} else if (DeliveryModeInput.IsChecked == true) {
|
||||
MgNrInput.Visibility = Visibility.Hidden;
|
||||
MemberInput.Visibility = Visibility.Hidden;
|
||||
MemberReferenceButton.Visibility = Visibility.Hidden;
|
||||
DeliveryInput.Visibility = Visibility.Visible;
|
||||
}
|
||||
}
|
||||
|
||||
private void CheckValidity() {
|
||||
var weight = DeliveryParts.Sum(r => r.SplitCompletely ? r.Part.Weight : r.SplitWeight ?? 0);
|
||||
var total = DeliveryParts.Sum(r => r.Part.Weight);
|
||||
InfoBlock.Text = $"Insgesamt {weight:N0} kg / {total:N0} kg ausgewählt.";
|
||||
ConfirmButton.IsEnabled = DeliveryParts.Any(r => r.SplitCompletely || r.SplitWeight > 0) && (
|
||||
DepreciateModeInput.IsChecked == true ||
|
||||
(MemberModeInput.IsChecked == true && MemberInput.SelectedItem != null && !DeliveryParts.All(r => r.SplitCompletely)) ||
|
||||
(DeliveryModeInput.IsChecked == true && DeliveryInput.SelectedItem != null));
|
||||
}
|
||||
|
||||
private void MgNrInput_TextChanged(object sender, TextChangedEventArgs evt) {
|
||||
var res = Validator.CheckMgNr((TextBox)sender, true);
|
||||
var text = MgNrInput.Text;
|
||||
var caret = MgNrInput.CaretIndex;
|
||||
ControlUtils.SelectItemWithPk(MemberInput, res.IsValid ? int.Parse(MgNrInput.Text) : null);
|
||||
MgNrInput.Text = text;
|
||||
MgNrInput.CaretIndex = caret;
|
||||
}
|
||||
|
||||
private void MemberInput_SelectionChanged(object sender, SelectionChangedEventArgs evt) {
|
||||
var m = MemberInput.SelectedItem as Member;
|
||||
MgNrInput.Text = m?.MgNr.ToString();
|
||||
CheckValidity();
|
||||
}
|
||||
|
||||
private void MemberReferenceButton_Click(object sender, RoutedEventArgs evt) {
|
||||
if (MemberInput.SelectedItem is not Member m) return;
|
||||
App.FocusMember(m.MgNr);
|
||||
}
|
||||
|
||||
private void DeliveryInput_SelectionChanged(object sender, SelectionChangedEventArgs evt) {
|
||||
CheckValidity();
|
||||
}
|
||||
|
||||
private void SplitCompletelyInput_Changed(object sender, RoutedEventArgs evt) {
|
||||
var checkbox = (CheckBox)sender;
|
||||
var dpnr = int.Parse(checkbox.Tag.ToString()!);
|
||||
var row = DeliveryParts.First(d => d.Part.DPNr == dpnr);
|
||||
if (checkbox.IsChecked == true) {
|
||||
row.SplitWeightEnabled = false;
|
||||
row.SplitWeight = row.Part.Weight;
|
||||
} else if (checkbox.IsChecked == false) {
|
||||
row.SplitWeightEnabled = true;
|
||||
row.SplitWeight = null;
|
||||
}
|
||||
CollectionViewSource.GetDefaultView(DeliveryParts).Refresh();
|
||||
CheckValidity();
|
||||
}
|
||||
|
||||
private void SplitWeightInput_TextChanged(object sender, TextChangedEventArgs evt) {
|
||||
var textbox = (TextBox)sender;
|
||||
Validator.CheckInteger(textbox, false, 6);
|
||||
var dpnr = int.Parse(textbox.Tag.ToString()!);
|
||||
var row = DeliveryParts.First(d => d.Part.DPNr == dpnr);
|
||||
var w = int.TryParse(textbox.Text, out var v) ? v : (int?)null;
|
||||
if (w >= row.Part.Weight) {
|
||||
row.SplitCompletely = true;
|
||||
row.SplitWeightEnabled = false;
|
||||
row.SplitWeight = row.Part.Weight;
|
||||
CollectionViewSource.GetDefaultView(DeliveryParts).Refresh();
|
||||
}
|
||||
CheckValidity();
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user