Add DeliveryAdminWindow

This commit is contained in:
2023-05-22 21:32:06 +02:00
parent 3bf7d65dea
commit dc236bab62
13 changed files with 534 additions and 35 deletions

View File

@ -0,0 +1,144 @@
<local:AdministrationWindow x:Class="Elwig.Windows.DeliveryAdminWindow"
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.Windows"
xmlns:xctk="http://schemas.xceed.com/wpf/xaml/toolkit"
Title="Lieferungsverwaltung - Elwig" Height="600" Width="1000" MinHeight="400" MinWidth="800"
Loaded="Window_Loaded">
<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="IsReadOnly" Value="True"/>
<Setter Property="Height" Value="25"/>
<Setter Property="TextWrapping" Value="NoWrap"/>
</Style>
<Style TargetType="ComboBox">
<Setter Property="IsEnabled" Value="False"/>
<Setter Property="Height" Value="25"/>
<Setter Property="FontSize" Value="14"/>
<Setter Property="HorizontalAlignment" Value="Stretch"/>
<Setter Property="VerticalAlignment" Value="Top"/>
</Style>
<Style TargetType="xctk:CheckComboBox">
<Setter Property="IsEnabled" Value="False"/>
<Setter Property="Height" Value="25"/>
<Setter Property="FontSize" Value="14"/>
<Setter Property="HorizontalAlignment" Value="Stretch"/>
<Setter Property="VerticalAlignment" Value="Top"/>
</Style>
<Style TargetType="Button">
<Setter Property="FontSize" Value="14"/>
<Setter Property="Padding" Value="9,3"/>
<Setter Property="Height" Value="27"/>
</Style>
</Window.Resources>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="19"/>
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="300"/>
<ColumnDefinition Width="1*"/>
<ColumnDefinition Width="1*"/>
</Grid.ColumnDefinitions>
<Menu Grid.ColumnSpan="3" BorderThickness="0,0,0,1" BorderBrush="LightGray" Background="White">
<MenuItem Header="Lieferung">
</MenuItem>
<MenuItem Header="Drucken">
<MenuItem Header="Lieferschein drucken"/>
</MenuItem>
<MenuItem Header="Werkzeuge">
<MenuItem Header="Alle Lieferscheine überprüfen"/>
</MenuItem>
</Menu>
<GroupBox Header="Mitglied" Grid.Column="1" Grid.Row="1" Margin="5,5,5,5">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="70"/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<Label Content="Mitglied:" Margin="10,10,0,0" Grid.Column="0"/>
<TextBox x:Name="MgNrInput" Width="48" Grid.Row="1" Grid.Column="1" Margin="0,10,0,0" HorizontalAlignment="Left" TextAlignment="Right"
IsReadOnly="False" IsEnabled="True"
TextChanged="MgNrInput_TextChanged" LostFocus="MgNrInput_LostFocus"/>
<ComboBox x:Name="MemberInput" Grid.Row="1" Grid.Column="1" Margin="53,10,10,10" IsEditable="True" IsEnabled="True"
ItemTemplate="{StaticResource MemberAdminNameTemplate}" TextSearch.TextPath="AdministrativeName"
SelectionChanged="MemberInput_SelectionChanged"/>
<Label Content="Wohnort:" Margin="10,38,0,0" Grid.Column="0"/>
<TextBox x:Name="MemberAddressField" Grid.Row="1" Grid.Column="1" Margin="0,40,10,10" FontSize="12" Height="22" IsReadOnly="True"/>
</Grid>
</GroupBox>
<GroupBox Header="Sorte" Grid.Column="2" Grid.Row="1" Margin="5,5,5,5">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="70"/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<Label Content="Sorte:" Margin="10,10,0,0" Grid.Column="0"/>
<TextBox x:Name="SortIdInput" Width="36" Grid.Row="1" Grid.Column="1" Margin="0,10,0,0" HorizontalAlignment="Left"
IsReadOnly="False" IsEnabled="True"
TextChanged="SortIdInput_TextChanged" LostFocus="SortIdInput_LostFocus"/>
<ComboBox x:Name="WineVarietyInput" Grid.Row="1" Grid.Column="1" Margin="41,10,10,10" IsEnabled="True"
ItemTemplate="{StaticResource WineVarietyTemplate}" TextSearch.TextPath="Name"
SelectionChanged="WineVarietyInput_SelectionChanged"/>
<Label Content="Attribute:" Margin="10,40,0,0" Grid.Column="0"/>
<xctk:CheckComboBox x:Name="AttributesInput" Grid.Row="1" Grid.Column="1" Margin="0,40,10,10" IsEnabled="True"
DisplayMemberPath="Name" Delimiter=", " AllItemsSelectedContent="Alle"
ItemSelectionChanged="AttributesInput_SelectionChanged"/>
</Grid>
</GroupBox>
<GroupBox Header="Gradation" Grid.Column="2" Grid.Row="2" Margin="5,5,5,5">
<Grid>
<TextBox x:Name="GradationOeInput" Width="80" Grid.Row="1" Grid.Column="1" Margin="10,10,10,10" HorizontalAlignment="Left"
IsReadOnly="False" IsEnabled="True"
TextAlignment="Right" Padding="2,2,25,2"
TextChanged="GradationOeInput_TextChanged" LostFocus="GradationOeInput_LostFocus"/>
<Label Content="°Oe" Margin="63,11,10,10"/>
<Label Content="=" Margin="94,10,10,10"/>
<TextBox x:Name="GradationKmwInput" Width="80" Grid.Row="1" Grid.Column="1" Margin="110,10,10,10" HorizontalAlignment="Left"
IsReadOnly="False" IsEnabled="True"
TextAlignment="Right" Padding="2,2,38,2"
TextChanged="GradationKmwInput_TextChanged" LostFocus="GradationKmwInput_LostFocus"/>
<Label Content="°KMW" Margin="150,11,10,10"/>
</Grid>
</GroupBox>
<GroupBox Header="Zu-/Abschläge" Grid.Column="2" Grid.Row="3" Margin="5,5,5,5">
<Grid>
<xctk:CheckComboBox x:Name="ModifiersInput" IsEnabled="True" Margin="10,10,10,10"
ItemTemplate="{StaticResource ModifierTemplate}" Delimiter=", " AllItemsSelectedContent="Alle"
ItemSelectionChanged="ModifiersInput_SelectionChanged"/>
</Grid>
</GroupBox>
<GroupBox Header="Herkunft" Grid.Column="2" Grid.Row="4" Margin="5,5,5,5">
<Grid>
<ComboBox x:Name="WineOriginInput" IsEnabled="True" Margin="10,10,10,10"
ItemTemplate="{StaticResource WineOriginTemplate}" SelectedValuePath="Name"/>
</Grid>
</GroupBox>
</Grid>
</local:AdministrationWindow>

View File

@ -0,0 +1,125 @@
using Elwig.Helpers;
using Elwig.Models;
using System.Linq;
using System.Windows;
using System.Windows.Controls;
using Xceed.Wpf.Toolkit.Primitives;
namespace Elwig.Windows {
public partial class DeliveryAdminWindow : AdministrationWindow {
private bool IsUpdatingGradation = false;
public DeliveryAdminWindow() {
InitializeComponent();
RequiredInputs = new Control[] {
MgNrInput, MemberInput,
SortIdInput, WineVarietyInput,
GradationOeInput, GradationKmwInput,
WineOriginInput
};
ExemptInputs = new Control[] {
MgNrInput, MemberInput,
MemberAddressField
};
}
private void Window_Loaded(object sender, RoutedEventArgs evt) {
MemberInput.ItemsSource = Context.Members.OrderBy(m => m.FamilyName).ThenBy(m => m.GivenName).ToList();
WineVarietyInput.ItemsSource = Context.WineVarieties.OrderBy(v => v.Name).ToList();
AttributesInput.ItemsSource = Context.WineAttributes.OrderBy(a => a.Name).ToList();
ModifiersInput.ItemsSource = Context.Modifiers.Where(m => m.Season.Year == 2022).OrderBy(m => m.Name).ToList();
WineOriginInput.ItemsSource = Context.WineOrigins.ToList().OrderByDescending(o => o.SortKey).ThenBy(o => o.HkId);
}
protected override void UpdateButtons() {
}
private void MgNrInput_TextChanged(object sender, TextChangedEventArgs evt) {
var valid = InputTextChanged((TextBox)sender, Validator.CheckMgNr);
MemberInput.SelectedItem = valid ? Context.Members.Find(int.Parse(MgNrInput.Text)) : null;
}
private void MgNrInput_LostFocus(object sender, RoutedEventArgs evt) {
var valid = InputLostFocus((TextBox)sender, Validator.CheckMgNr);
MemberInput.SelectedItem = valid ? Context.Members.Find(int.Parse(MgNrInput.Text)) : null;
}
private void MemberInput_SelectionChanged(object sender, SelectionChangedEventArgs evt) {
var m = MemberInput.SelectedItem as Member;
if (m != null) MgNrInput.Text = m.MgNr.ToString();
MemberAddressField.Text = m?.FullAddress;
}
private void UpdateWineVariety(bool valid) {
if (valid) {
var text = SortIdInput.Text;
WineVarietyInput.SelectedItem = Context.WineVarieties.Find(text[0..2]);
if (text.Length >= 3) {
AttributesInput.UnSelectAll();
AttributesInput.SelectedItems.Add(Context.WineAttributes.Find(text[2..]));
SortIdInput.Text = text[0..2];
}
} else {
WineVarietyInput.SelectedItem = null;
AttributesInput.UnSelectAll();
}
}
private void SortIdInput_TextChanged(object sender, TextChangedEventArgs evt) {
UpdateWineVariety(InputTextChanged((TextBox)sender, Validator.CheckSortId));
}
private void SortIdInput_LostFocus(object sender, RoutedEventArgs evt) {
UpdateWineVariety(InputLostFocus((TextBox)sender, Validator.CheckSortId));
}
private void WineVarietyInput_SelectionChanged(object sender, SelectionChangedEventArgs evt) {
var s = WineVarietyInput.SelectedItem as WineVar;
if (s != null) SortIdInput.Text = s.SortId;
}
private void UpdateGradationKmw() {
IsUpdatingGradation = true;
var caret = GradationKmwInput.CaretIndex;
GradationKmwInput.Text = $"{Utils.OeToKmw(double.Parse(GradationOeInput.Text)):#.0}";
GradationKmwInput.CaretIndex = caret;
IsUpdatingGradation = false;
}
private void UpdateGradationOe() {
IsUpdatingGradation = true;
var caret = GradationOeInput.CaretIndex;
GradationOeInput.Text = $"{Utils.KmwToOe(double.Parse(GradationKmwInput.Text)):#}";
GradationOeInput.CaretIndex = caret;
IsUpdatingGradation = false;
}
private void GradationOeInput_TextChanged(object sender, TextChangedEventArgs evt) {
var valid = InputTextChanged((TextBox)sender, Validator.CheckGradatoinOe);
if (valid && !IsUpdatingGradation) UpdateGradationKmw();
}
private void GradationOeInput_LostFocus(object sender, RoutedEventArgs evt) {
InputLostFocus((TextBox)sender, Validator.CheckGradatoinOe);
}
private void GradationKmwInput_TextChanged(object sender, TextChangedEventArgs evt) {
var valid = InputTextChanged((TextBox)sender, Validator.CheckGradationKmw);
if (valid && !IsUpdatingGradation) UpdateGradationOe();
}
private void GradationKmwInput_LostFocus(object sender, RoutedEventArgs evt) {
InputLostFocus((TextBox)sender, Validator.CheckGradationKmw);
}
private void AttributesInput_SelectionChanged(object sender, ItemSelectionChangedEventArgs evt) {
}
private void ModifiersInput_SelectionChanged(object sender, ItemSelectionChangedEventArgs evt) {
}
}
}

View File

@ -38,13 +38,17 @@
HorizontalAlignment="Left" Margin="0,70,0,0" VerticalAlignment="Top"/>
</Grid>
<Button x:Name="Button2" Content="Mitgliederverwaltung" Click="Button2_Click"
<Button x:Name="MemberAdminButton" Content="Mitgliederverwaltung" Click="MemberAdminButton_Click"
Margin="50,160,0,0" VerticalAlignment="Top" HorizontalAlignment="Left"/>
<Button x:Name="Button3" Content="Mitgliederliste" Click="Button3_Click"
<Button x:Name="MemberListButton" Content="Mitgliederliste" Click="MemberListButton_Click"
Margin="50,200,0,0" VerticalAlignment="Top" HorizontalAlignment="Left"/>
<Button x:Name="Button4" Content="PDF Erzeugen" Click="Button4_Click" Tag="Print"
<Button x:Name="DeliveryAdminButton" Content="Lieferungsverwaltung" Click="DeliveryAdminButton_Click"
Margin="50,240,0,0" VerticalAlignment="Top" HorizontalAlignment="Left"/>
<Button x:Name="TestWindowButton" Content="Test Fenster" Click="TestWindowButton_Click"
<Button x:Name="DeliveryListButton" Content="Lieferungungen" Click="DeliveryListButton_Click" IsEnabled="False"
Margin="50,280,0,0" VerticalAlignment="Top" HorizontalAlignment="Left"/>
<Button x:Name="PdfButton" Content="PDF Erzeugen" Click="PdfButton_Click" Tag="Print"
Margin="50,320,0,0" VerticalAlignment="Top" HorizontalAlignment="Left"/>
<Button x:Name="TestWindowButton" Content="Test Fenster" Click="TestWindowButton_Click"
Margin="50,360,0,0" VerticalAlignment="Top" HorizontalAlignment="Left"/>
</Grid>
</Window>

View File

@ -12,20 +12,29 @@ namespace Elwig.Windows {
}
private void Window_Loaded(object sender, RoutedEventArgs evt) {
Button4.IsEnabled = App.IsPrintingReady;
PdfButton.IsEnabled = App.IsPrintingReady;
}
private void Button2_Click(object sender, RoutedEventArgs evt) {
private void MemberAdminButton_Click(object sender, RoutedEventArgs evt) {
var w = new MemberAdminWindow();
w.Show();
}
private void Button3_Click(object sender, RoutedEventArgs evt) {
private void MemberListButton_Click(object sender, RoutedEventArgs evt) {
var w = new MemberListWindow();
w.Show();
}
private void Button4_Click(object sender, RoutedEventArgs evt) {
private void DeliveryAdminButton_Click(object sender, RoutedEventArgs evt) {
var w = new DeliveryAdminWindow();
w.Show();
}
private void DeliveryListButton_Click(object sender, RoutedEventArgs evt) {
// TODO
}
private void PdfButton_Click(object sender, RoutedEventArgs evt) {
Utils.RunBackground("PDF Generation", async () => {
using var ctx = new AppDbContext();
using var doc = new DeliveryNote(ctx.Deliveries.OrderBy(d => d.Parts.Count).ThenBy(d => d.Year).ThenBy(d => d.DId).Last());

View File

@ -153,7 +153,7 @@
<Label Content="PLZ/Ort:" Margin="10,160,0,0" Grid.Column="0"/>
<TextBox x:Name="PlzInput" Margin="0,160,0,0" Width="42" Grid.Column="1" HorizontalAlignment="Left"
TextChanged="PlzInput_TextChanged" LostFocus="PlzInput_LostFocus"/>
<ComboBox x:Name="OrtInput" ItemTemplate="{StaticResource PostalDestComboBoxTemplate}" TextSearch.TextPath="Ort.Name"
<ComboBox x:Name="OrtInput" ItemTemplate="{StaticResource PostalDestTemplate}" TextSearch.TextPath="Ort.Name"
SelectionChanged="ComboBox_SelectionChanged"
Margin="47,160,10,0" Grid.Column="1" Grid.ColumnSpan="3"/>
</Grid>
@ -241,7 +241,7 @@
<Label Content="PLZ/Ort:" Margin="10,70,0,0" Grid.Column="0"/>
<TextBox x:Name="BillingPlzInput" Margin="0,70,0,0" Width="42" Grid.Column="1" HorizontalAlignment="Left"
TextChanged="PlzInput_TextChanged" LostFocus="PlzInput_LostFocus"/>
<ComboBox x:Name="BillingOrtInput" ItemTemplate="{StaticResource PostalDestComboBoxTemplate}" TextSearch.TextPath="Ort.Name"
<ComboBox x:Name="BillingOrtInput" ItemTemplate="{StaticResource PostalDestTemplate}" TextSearch.TextPath="Ort.Name"
SelectionChanged="ComboBox_SelectionChanged"
Margin="47,70,10,0" Grid.Column="1"/>
</Grid>
@ -283,12 +283,12 @@
Grid.Column="2" HorizontalAlignment="Left" Margin="10,75,0,0" VerticalAlignment="Top" IsChecked="False"/>
<Label Content="StammZwst.:" Margin="10,130,0,0" Grid.Column="0"/>
<ComboBox x:Name="BranchInput" ItemTemplate="{StaticResource BranchTemplate}" TextSearch.TextPath="Name"
<ComboBox x:Name="BranchInput" DisplayMemberPath="Name" TextSearch.TextPath="Name"
SelectionChanged="ComboBox_SelectionChanged"
Margin="0,130,10,0" Grid.Column="1" Grid.ColumnSpan="2"/>
<Label Content="Stammgemeinde:" Margin="10,160,0,0" Grid.Column="0"/>
<ComboBox x:Name="DefaultKgInput" ItemTemplate="{StaticResource KgTemplate}" TextSearch.TextPath="Name"
<ComboBox x:Name="DefaultKgInput" DisplayMemberPath="Name" TextSearch.TextPath="Name"
SelectionChanged="ComboBox_SelectionChanged"
Margin="0,160,10,0" Grid.Column="1" Grid.ColumnSpan="2"/>

View File

@ -439,11 +439,11 @@ namespace Elwig.Windows {
}
private void MgNrInput_TextChanged(object sender, RoutedEventArgs evt) {
InputTextChanged((TextBox)sender, Validator.CheckMgNr);
InputTextChanged((TextBox)sender, Validator.CheckNewMgNr);
}
private void MgNrInput_LostFocus(object sender, RoutedEventArgs evt) {
InputLostFocus((TextBox)sender, Validator.CheckMgNr);
InputLostFocus((TextBox)sender, Validator.CheckNewMgNr);
}
private void PredecessorMgNrInput_TextChanged(object sender, RoutedEventArgs evt) {