Compare commits
46 Commits
85e4ccd215
...
v0.1.0
Author | SHA1 | Date | |
---|---|---|---|
c933fa3423 | |||
0958728418 | |||
cb8d405dcf | |||
6f4e3474b8 | |||
545622a2ab | |||
3a0736a73f | |||
048a7e0f13 | |||
cad475fc20 | |||
8b0f1e35c8 | |||
67dbf62eb7 | |||
9b59208373 | |||
146560c796 | |||
286e3515d4 | |||
c1d3a9042d | |||
e656bde54d | |||
33d763d968 | |||
56a0eb794e | |||
effc9f9230 | |||
4817a2aedc | |||
b67628c566 | |||
5aa8e45652 | |||
1f377483a5 | |||
9b84452b86 | |||
75e6c1bd5d | |||
a96a05d3de | |||
3f09e62c74 | |||
a98bc3ae4a | |||
93d4365d36 | |||
33e10d00bf | |||
7c2bf711c7 | |||
ff7fe34d5b | |||
973f49fabc | |||
8899e8bd32 | |||
6dda9e09cf | |||
c0a6f16374 | |||
ba71618463 | |||
6261217e7c | |||
5dd56d9666 | |||
83a82c17c6 | |||
03cf88a058 | |||
4bb0acb4a2 | |||
04db3fe0c5 | |||
28bb8f2d3f | |||
5074f945cf | |||
3a12837706 | |||
cfa1f1eeea |
@@ -11,17 +11,13 @@
|
|||||||
<DataTemplate x:Key="PostalDestTemplate">
|
<DataTemplate x:Key="PostalDestTemplate">
|
||||||
<StackPanel Orientation="Horizontal">
|
<StackPanel Orientation="Horizontal">
|
||||||
<TextBlock Text="{Binding Dest}"/>
|
<TextBlock Text="{Binding Dest}"/>
|
||||||
<TextBlock Text=" ("/>
|
<TextBlock Text="{Binding Ort.Name, StringFormat='{} ({0})'}"/>
|
||||||
<TextBlock Text="{Binding Ort.Name}"/>
|
|
||||||
<TextBlock Text=")"/>
|
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
</DataTemplate>
|
</DataTemplate>
|
||||||
<DataTemplate x:Key="KgNrTemplate">
|
<DataTemplate x:Key="KgNrTemplate">
|
||||||
<StackPanel Orientation="Horizontal">
|
<StackPanel Orientation="Horizontal">
|
||||||
<TextBlock Text="{Binding Name}"/>
|
<TextBlock Text="{Binding Name}"/>
|
||||||
<TextBlock Text=" ("/>
|
<TextBlock Text="{Binding KgNr, StringFormat='{} ({0:00000})'}"/>
|
||||||
<TextBlock Text="{Binding KgNr}"/>
|
|
||||||
<TextBlock Text=")"/>
|
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
</DataTemplate>
|
</DataTemplate>
|
||||||
<DataTemplate x:Key="MemberAdminNameTemplate">
|
<DataTemplate x:Key="MemberAdminNameTemplate">
|
||||||
|
@@ -29,7 +29,7 @@ namespace Elwig {
|
|||||||
public static string? BranchFaxNr { get; private set; }
|
public static string? BranchFaxNr { get; private set; }
|
||||||
public static string? BranchMobileNr { get; private set; }
|
public static string? BranchMobileNr { get; private set; }
|
||||||
public static IList<IScale> Scales { get; private set; }
|
public static IList<IScale> Scales { get; private set; }
|
||||||
public static ClientParameters Client { get; private set; }
|
public static ClientParameters Client { get; private set; }
|
||||||
|
|
||||||
public static bool IsPrintingReady => Documents.Html.IsReady && Documents.Pdf.IsReady;
|
public static bool IsPrintingReady => Documents.Html.IsReady && Documents.Pdf.IsReady;
|
||||||
public static Dispatcher MainDispatcher { get; private set; }
|
public static Dispatcher MainDispatcher { get; private set; }
|
||||||
@@ -58,19 +58,25 @@ namespace Elwig {
|
|||||||
|
|
||||||
Dictionary<string, (string, string, int?, string?, string?, string?, string?, string?)> branches = new();
|
Dictionary<string, (string, string, int?, string?, string?, string?, string?, string?)> branches = new();
|
||||||
using (var ctx = new AppDbContext()) {
|
using (var ctx = new AppDbContext()) {
|
||||||
if (!ctx.Database.CanConnect()) {
|
try {
|
||||||
MessageBox.Show($"Invalid Database:\n\n{Config.DatabaseFile}", "Invalid Database", MessageBoxButton.OK, MessageBoxImage.Error);
|
if (!ctx.Database.CanConnect()) {
|
||||||
Shutdown();
|
MessageBox.Show($"Invalid Database:\n\n{Config.DatabaseFile}", "Invalid Database", MessageBoxButton.OK, MessageBoxImage.Error);
|
||||||
return;
|
|
||||||
} else {
|
|
||||||
branches = ctx.Branches.ToDictionary(b => b.Name.ToLower(), b => (b.ZwstId, b.Name, b.PostalDest?.AtPlz?.Plz, b.PostalDest?.AtPlz?.Dest, b.Address, b.PhoneNr, b.FaxNr, b.MobileNr));
|
|
||||||
try {
|
|
||||||
Client = new(ctx);
|
|
||||||
} catch (Exception e) {
|
|
||||||
MessageBox.Show($"Fehler beim Laden der Mandantendaten:\n\n{e.Message}", "Fehler");
|
|
||||||
Shutdown();
|
Shutdown();
|
||||||
return;
|
return;
|
||||||
|
} else {
|
||||||
|
branches = ctx.Branches.ToDictionary(b => b.Name.ToLower(), b => (b.ZwstId, b.Name, b.PostalDest?.AtPlz?.Plz, b.PostalDest?.AtPlz?.Dest, b.Address, b.PhoneNr, b.FaxNr, b.MobileNr));
|
||||||
|
try {
|
||||||
|
Client = new(ctx);
|
||||||
|
} catch (Exception e) {
|
||||||
|
MessageBox.Show($"Fehler beim Laden der Mandantendaten:\n\n{e.Message}", "Fehler", MessageBoxButton.OK, MessageBoxImage.Error);
|
||||||
|
Shutdown();
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
MessageBox.Show($"Invalid Database:\n\n{e.Message}", "Invalid Database", MessageBoxButton.OK, MessageBoxImage.Error);
|
||||||
|
Shutdown();
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Utils.RunBackground("HTML Initialization", () => Documents.Html.Init(PrintingReadyChanged));
|
Utils.RunBackground("HTML Initialization", () => Documents.Html.Init(PrintingReadyChanged));
|
||||||
|
59
Elwig/Dialogs/AbwertenDialog.xaml
Normal file
59
Elwig/Dialogs/AbwertenDialog.xaml
Normal file
@@ -0,0 +1,59 @@
|
|||||||
|
<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"
|
||||||
|
mc:Ignorable="d"
|
||||||
|
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>
|
33
Elwig/Dialogs/AbwertenDialog.xaml.cs
Normal file
33
Elwig/Dialogs/AbwertenDialog.xaml.cs
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
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}\u202fkg";
|
||||||
|
}
|
||||||
|
|
||||||
|
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();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
60
Elwig/Dialogs/DeliveryExtractionDialog.xaml
Normal file
60
Elwig/Dialogs/DeliveryExtractionDialog.xaml
Normal file
@@ -0,0 +1,60 @@
|
|||||||
|
<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"
|
||||||
|
mc:Ignorable="d"
|
||||||
|
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>
|
37
Elwig/Dialogs/DeliveryExtractionDialog.xaml.cs
Normal file
37
Elwig/Dialogs/DeliveryExtractionDialog.xaml.cs
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
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();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
53
Elwig/Dialogs/LinearPriceIncreaseDialog.xaml
Normal file
53
Elwig/Dialogs/LinearPriceIncreaseDialog.xaml
Normal file
@@ -0,0 +1,53 @@
|
|||||||
|
<Window x:Class="Elwig.Dialogs.LinearPriceIncreaseDialog"
|
||||||
|
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"
|
||||||
|
mc:Ignorable="d"
|
||||||
|
ResizeMode="NoResize"
|
||||||
|
ShowInTaskbar="False"
|
||||||
|
Topmost="True"
|
||||||
|
WindowStartupLocation="CenterOwner"
|
||||||
|
FocusManager.FocusedElement="{Binding ElementName=PriceInput}"
|
||||||
|
Title="Linear wachsen" Height="140" Width="270">
|
||||||
|
<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="55"/>
|
||||||
|
<ColumnDefinition/>
|
||||||
|
</Grid.ColumnDefinitions>
|
||||||
|
|
||||||
|
<Label Content="Preis:" Margin="10,20,10,10"/>
|
||||||
|
<Grid Grid.Column="1" Width="145" Height="25" Margin="0,20,0,0" HorizontalAlignment="Left" VerticalAlignment="Top">
|
||||||
|
<TextBox x:Name="PriceInput" TextAlignment="Right" Padding="2,2,30,2"
|
||||||
|
TextChanged="PriceInput_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="17,0,133,10" IsEnabled="False" IsDefault="True"
|
||||||
|
Click="ConfirmButton_Click" Grid.ColumnSpan="2" HorizontalAlignment="Stretch"/>
|
||||||
|
<Button x:Name="CancelButton" Content="Abbrechen" Margin="0,0,20,10" Grid.Column="1" IsCancel="True"/>
|
||||||
|
</Grid>
|
||||||
|
</Window>
|
30
Elwig/Dialogs/LinearPriceIncreaseDialog.xaml.cs
Normal file
30
Elwig/Dialogs/LinearPriceIncreaseDialog.xaml.cs
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
using Elwig.Helpers;
|
||||||
|
using System.Text.RegularExpressions;
|
||||||
|
using System.Windows;
|
||||||
|
using System.Windows.Controls;
|
||||||
|
|
||||||
|
namespace Elwig.Dialogs {
|
||||||
|
public partial class LinearPriceIncreaseDialog : Window {
|
||||||
|
|
||||||
|
public double Price = 0.0;
|
||||||
|
|
||||||
|
public LinearPriceIncreaseDialog() {
|
||||||
|
InitializeComponent();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ConfirmButton_Click(object sender, RoutedEventArgs evt) {
|
||||||
|
DialogResult = true;
|
||||||
|
Price = double.Parse(PriceInput.Text.Replace("\u202f", ""));
|
||||||
|
Close();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void UpdateButtons(ValidationResult res) {
|
||||||
|
ConfirmButton.IsEnabled = res.IsValid;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void PriceInput_TextChanged(object sender, TextChangedEventArgs evt) {
|
||||||
|
var res = Validator.CheckDecimal(PriceInput, true, 2, 8);
|
||||||
|
UpdateButtons(res);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@@ -15,7 +15,7 @@ namespace Elwig.Dialogs {
|
|||||||
|
|
||||||
private void ConfirmButton_Click(object sender, RoutedEventArgs evt) {
|
private void ConfirmButton_Click(object sender, RoutedEventArgs evt) {
|
||||||
DialogResult = true;
|
DialogResult = true;
|
||||||
Weight = int.Parse(WeightInput.Text.Replace("\u202f", ""));
|
Weight = int.Parse(WeightInput.Text);
|
||||||
Reason = Regex.Replace(ReasonInput.Text, @"\s+", "").Trim();
|
Reason = Regex.Replace(ReasonInput.Text, @"\s+", "").Trim();
|
||||||
if (Reason == "") {
|
if (Reason == "") {
|
||||||
Reason = null;
|
Reason = null;
|
||||||
|
@@ -5,13 +5,33 @@
|
|||||||
|
|
||||||
<div class="date">@Model.Location, am @($"{Model.Date:dd.MM.yyyy}")</div>
|
<div class="date">@Model.Location, am @($"{Model.Date:dd.MM.yyyy}")</div>
|
||||||
<h1>@Model.Title</h1>
|
<h1>@Model.Title</h1>
|
||||||
@if (Model.Delivery.Parts.Count > 2) {
|
@{
|
||||||
<p>Siehe nächste Seite.</p>
|
bool displayStats = true; // Model.Delivery.Year == Model.CurrentNextSeason
|
||||||
if (Model.Delivery.Year == Model.CurrentNextSeason) {
|
|
||||||
<p>Gesamtlieferung usw.</p>
|
|
||||||
}
|
|
||||||
<hr class="page-break"/>
|
|
||||||
}
|
}
|
||||||
|
<script>
|
||||||
|
document.addEventListener("DOMContentLoaded", () => {
|
||||||
|
const hidden = document.getElementsByClassName("hidden")[0];
|
||||||
|
const bottom = hidden.offsetTop + hidden.offsetHeight;
|
||||||
|
const cm = bottom * 2.54 / 96 * window.devicePixelRatio;
|
||||||
|
|
||||||
|
if (cm > 25.75) {
|
||||||
|
// force page break
|
||||||
|
const table = document.getElementsByClassName("delivery")[0];
|
||||||
|
|
||||||
|
const hr = document.createElement("hr");
|
||||||
|
hr.classList.add("page-break");
|
||||||
|
table.before(hr);
|
||||||
|
|
||||||
|
const stats = document.getElementById("delivery-stats");
|
||||||
|
stats.getElementsByTagName("table")[0].classList.add("expanded");
|
||||||
|
hr.before(stats);
|
||||||
|
|
||||||
|
const p = document.createElement("p");
|
||||||
|
p.innerText = "Siehe nächste Seite."
|
||||||
|
stats.before(p);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
</script>
|
||||||
<table class="delivery">
|
<table class="delivery">
|
||||||
<colgroup>
|
<colgroup>
|
||||||
<col style="width: 1cm;"/>
|
<col style="width: 1cm;"/>
|
||||||
@@ -54,12 +74,12 @@
|
|||||||
@if (part.Modifiers.Count() > 0) {
|
@if (part.Modifiers.Count() > 0) {
|
||||||
var first = true;
|
var first = true;
|
||||||
foreach (var mod in part.Modifiers) {
|
foreach (var mod in part.Modifiers) {
|
||||||
<tr class="tight @(first ? "first" : "")"><td></td><td>@Raw(first ? "<i>Zu-/Abschläge:</i>" : "")</td><td colspan="3">@mod.Name</td><td style="white-space: pre;">@mod.ValueStr</td></tr>
|
<tr class="tight @(first ? "first" : "")"><td></td><td>@Raw(first ? "<i>Zu-/Abschläge:</i>" : "")</td><td colspan="3"><b>@mod.Name</b></td><td style="white-space: pre;">@mod.ValueStr</td></tr>
|
||||||
first = false;
|
first = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
<tr><td></td><td colspan="5">
|
<tr><td></td><td colspan="5">
|
||||||
@(part.ManualWeighing ? "Handwiegung" : $"Waage: {part.ScaleId ?? "?"}, ID: {part.WeighingId ?? "?"}") (@(part.IsGerebelt ? "gerebelt gewogen" : "nicht gerebelt gewogen"))
|
@Raw(part.ManualWeighing ? "<i>Handwiegung</i>" : $"<i>Waage:</i> {part.ScaleId ?? "?"}, <i>ID:</i> {part.WeighingId ?? "?"}") (@(part.IsGerebelt ? "gerebelt gewogen" : "nicht gerebelt gewogen"))
|
||||||
</td></tr>
|
</td></tr>
|
||||||
@if (part.Comment != null) {
|
@if (part.Comment != null) {
|
||||||
<tr><td></td><td colspan="5"><i>Anmerkung:</i> @part.Comment</td></tr>
|
<tr><td></td><td colspan="5"><i>Anmerkung:</i> @part.Comment</td></tr>
|
||||||
@@ -81,11 +101,59 @@
|
|||||||
@if (Model.Delivery.Comment != null) {
|
@if (Model.Delivery.Comment != null) {
|
||||||
<p class="comment">Amerkung zur Lieferung: @Model.Delivery.Comment</p>
|
<p class="comment">Amerkung zur Lieferung: @Model.Delivery.Comment</p>
|
||||||
}
|
}
|
||||||
@if (Model.Delivery.Parts.Count <= 2 && Model.Delivery.Year == Model.CurrentNextSeason) {
|
@if (displayStats) {
|
||||||
<p>Gesamtlieferung usw.</p>
|
<div id="delivery-stats">
|
||||||
|
<table class="delivery-stats">
|
||||||
|
<colgroup>
|
||||||
|
<col style="width: 100%;"/>
|
||||||
|
<col style="width: 2cm;"/>
|
||||||
|
<col style="width: 2cm;"/>
|
||||||
|
<col style="width: 2cm;"/>
|
||||||
|
<col style="width: 2cm;"/>
|
||||||
|
<col style="width: 2cm;"/>
|
||||||
|
<col style="width: 2cm;"/>
|
||||||
|
</colgroup>
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th><b>Gesamtlieferung</b> [kg]</th>
|
||||||
|
<th>Lieferpflicht</th>
|
||||||
|
<th>Lieferrecht</th>
|
||||||
|
<th>Unterliefert</th>
|
||||||
|
<th>Noch zu liefern</th>
|
||||||
|
<th>Überliefert</th>
|
||||||
|
<th>Geliefert</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
@{
|
||||||
|
string FormatRow(int obligation, int right, int sum) {
|
||||||
|
return $"<td>{obligation:N0}</td>" +
|
||||||
|
$"<td>{right:N0}</td>" +
|
||||||
|
$"<td>{(sum < obligation ? $"{obligation - sum:N0}" : "-")}</td>" +
|
||||||
|
$"<td>{(sum >= obligation && sum <= right ? $"{right - sum:N0}" : "-")}</td>" +
|
||||||
|
$"<td>{(sum > right ? $"{sum - right:N0}" : "-")}</td>" +
|
||||||
|
$"<td>{sum:N0}</td>";
|
||||||
|
}
|
||||||
|
var sortids = Model.Delivery.Parts.Select(p => p.SortId).ToList();
|
||||||
|
}
|
||||||
|
<tr>
|
||||||
|
<th>Geschäftsanteile</th>
|
||||||
|
@Raw(FormatRow(Model.Member.DeliveryObligation, Model.Member.DeliveryRight, Model.Member.Deliveries.Where(d => d.Year == Model.Delivery.Year).Sum(d => d.Weight)))
|
||||||
|
</tr>
|
||||||
|
@foreach (var (id, name, right, obligation, sum) in Model.MemberBuckets.OrderBy(b => b.Item1)) {
|
||||||
|
if (right > 0 && obligation > 0) {
|
||||||
|
<tr class="@(sortids.Contains(id[..2]) ? "" : "optional")">
|
||||||
|
<th>@name</th>
|
||||||
|
@Raw(FormatRow(obligation, right, sum))
|
||||||
|
</tr>
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
}
|
}
|
||||||
@for (int i = 0; i < 2; i++) {
|
@for (int i = 0; i < 2; i++) {
|
||||||
<div class="@(i == 0 ? "bottom" : "hidden")">
|
<div class="@(i == 0 ? "hidden" : "bottom")">
|
||||||
@if (Model.Text != null) {
|
@if (Model.Text != null) {
|
||||||
<p class="comment">@Model.Text</p>
|
<p class="comment">@Model.Text</p>
|
||||||
}
|
}
|
||||||
|
@@ -1,12 +1,15 @@
|
|||||||
|
using Elwig.Helpers;
|
||||||
using Elwig.Models;
|
using Elwig.Models;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
namespace Elwig.Documents {
|
namespace Elwig.Documents {
|
||||||
public class DeliveryNote : BusinessDocument {
|
public class DeliveryNote : BusinessDocument {
|
||||||
|
|
||||||
public Delivery Delivery;
|
public Delivery Delivery;
|
||||||
public string? Text;
|
public string? Text;
|
||||||
|
public IEnumerable<(string, string, int, int, int)> MemberBuckets;
|
||||||
|
|
||||||
public DeliveryNote(Delivery d) : base($"Traubenübernahmeschein Nr. {d.LsNr}", d.Member) {
|
public DeliveryNote(Delivery d, AppDbContext ctx) : base($"Traubenübernahmeschein Nr. {d.LsNr}", d.Member) {
|
||||||
Delivery = d;
|
Delivery = d;
|
||||||
Aside = Aside.Replace("</table>", "") +
|
Aside = Aside.Replace("</table>", "") +
|
||||||
$"<thead><tr><th colspan='2'>Lieferung</th></tr></thead><tbody>" +
|
$"<thead><tr><th colspan='2'>Lieferung</th></tr></thead><tbody>" +
|
||||||
@@ -14,8 +17,9 @@ namespace Elwig.Documents {
|
|||||||
$"<tr><th>Datum/Zeit</th><td>{d.Date:dd.MM.yyyy} / {d.Time:HH:mm}</td></tr>" +
|
$"<tr><th>Datum/Zeit</th><td>{d.Date:dd.MM.yyyy} / {d.Time:HH:mm}</td></tr>" +
|
||||||
$"<tr><th>Zweigstelle</th><td>{d.Branch.Name}</td></tr>" +
|
$"<tr><th>Zweigstelle</th><td>{d.Branch.Name}</td></tr>" +
|
||||||
$"</tbody></table>";
|
$"</tbody></table>";
|
||||||
Text = App.Client.DeliveryNoteText;
|
Text = App.Client.TextDeliveryNote;
|
||||||
DocumentId = d.LsNr;
|
DocumentId = d.LsNr;
|
||||||
|
MemberBuckets = ctx.GetMemberBuckets(d.Member, d.Year).GetAwaiter().GetResult();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -206,7 +206,7 @@ table {
|
|||||||
}
|
}
|
||||||
|
|
||||||
table.delivery {
|
table.delivery {
|
||||||
margin-bottom: 1cm;
|
margin-bottom: 5mm;
|
||||||
}
|
}
|
||||||
|
|
||||||
table.delivery th {
|
table.delivery th {
|
||||||
@@ -249,6 +249,48 @@ table.delivery tr.sum td {
|
|||||||
padding-top: 1mm;
|
padding-top: 1mm;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
table.delivery-stats {
|
||||||
|
font-size: 8pt;
|
||||||
|
}
|
||||||
|
|
||||||
|
table.delivery-stats.expanded th,
|
||||||
|
table.delivery-stats.expanded td {
|
||||||
|
padding: 0.25mm 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
table.delivery-stats:not(.expanded) th,
|
||||||
|
table.delivery-stats:not(.expanded) td {
|
||||||
|
padding: 0.125mm 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
table.delivery-stats:not(.expanded) tr.optional {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
table.delivery-stats thead th {
|
||||||
|
font-weight: normal;
|
||||||
|
font-style: italic;
|
||||||
|
text-align: right;
|
||||||
|
}
|
||||||
|
|
||||||
|
table.delivery-stats thead th:first-child {
|
||||||
|
text-align: left;
|
||||||
|
}
|
||||||
|
|
||||||
|
table.delivery-stats.expanded tbody {
|
||||||
|
font-size: 10pt;
|
||||||
|
}
|
||||||
|
|
||||||
|
table.delivery-stats td {
|
||||||
|
text-align: right;
|
||||||
|
}
|
||||||
|
|
||||||
|
table.delivery-stats tbody th {
|
||||||
|
font-weight: normal;
|
||||||
|
font-style: italic;
|
||||||
|
text-align: left;
|
||||||
|
}
|
||||||
|
|
||||||
.hidden {
|
.hidden {
|
||||||
visibility: hidden;
|
visibility: hidden;
|
||||||
}
|
}
|
||||||
|
@@ -7,7 +7,7 @@
|
|||||||
<UseWPF>true</UseWPF>
|
<UseWPF>true</UseWPF>
|
||||||
<PreserveCompilationContext>true</PreserveCompilationContext>
|
<PreserveCompilationContext>true</PreserveCompilationContext>
|
||||||
<ApplicationIcon>elwig.ico</ApplicationIcon>
|
<ApplicationIcon>elwig.ico</ApplicationIcon>
|
||||||
<Version>0.0.1</Version>
|
<Version>0.1.0</Version>
|
||||||
<SatelliteResourceLanguages>de-AT</SatelliteResourceLanguages>
|
<SatelliteResourceLanguages>de-AT</SatelliteResourceLanguages>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
@@ -16,15 +16,16 @@
|
|||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Extended.Wpf.Toolkit" Version="4.5.0" />
|
<PackageReference Include="Extended.Wpf.Toolkit" Version="4.5.1" />
|
||||||
<PackageReference Include="ini-parser" Version="2.5.2" />
|
<PackageReference Include="ini-parser" Version="2.5.2" />
|
||||||
<PackageReference Include="Microsoft.AspNetCore.Razor.Language" Version="6.0.16" />
|
<PackageReference Include="Microsoft.AspNetCore.Razor.Language" Version="6.0.21" />
|
||||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Proxies" Version="7.0.5" />
|
<PackageReference Include="Microsoft.EntityFrameworkCore.Proxies" Version="7.0.10" />
|
||||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="7.0.5" />
|
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="7.0.10" />
|
||||||
<PackageReference Include="Microsoft.Web.WebView2" Version="1.0.1774.30" />
|
<PackageReference Include="Microsoft.Web.WebView2" Version="1.0.1938.49" />
|
||||||
<PackageReference Include="PdfSharp" Version="1.50.5147" />
|
<PackageReference Include="PdfSharp" Version="1.50.5147" />
|
||||||
<PackageReference Include="PuppeteerSharp" Version="10.0.0" />
|
<PackageReference Include="PuppeteerSharp" Version="11.0.2" />
|
||||||
<PackageReference Include="RazorLight" Version="2.3.1" />
|
<PackageReference Include="RazorLight" Version="2.3.1" />
|
||||||
|
<PackageReference Include="ScottPlot.WPF" Version="4.1.67" />
|
||||||
<PackageReference Include="System.IO.Ports" Version="7.0.0" />
|
<PackageReference Include="System.IO.Ports" Version="7.0.0" />
|
||||||
<PackageReference Include="System.Text.Encoding.CodePages" Version="7.0.0" />
|
<PackageReference Include="System.Text.Encoding.CodePages" Version="7.0.0" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
@@ -6,6 +6,9 @@ using System.IO;
|
|||||||
using System;
|
using System;
|
||||||
using System.Windows;
|
using System.Windows;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
|
using Microsoft.Data.Sqlite;
|
||||||
|
using System.Text.RegularExpressions;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
namespace Elwig.Helpers {
|
namespace Elwig.Helpers {
|
||||||
public class AppDbContext : DbContext {
|
public class AppDbContext : DbContext {
|
||||||
@@ -28,17 +31,18 @@ namespace Elwig.Helpers {
|
|||||||
public DbSet<WineAttr> WineAttributes { get; private set; }
|
public DbSet<WineAttr> WineAttributes { get; private set; }
|
||||||
public DbSet<WineCult> WineCultivations { get; private set; }
|
public DbSet<WineCult> WineCultivations { get; private set; }
|
||||||
public DbSet<Branch> Branches { get; private set; }
|
public DbSet<Branch> Branches { get; private set; }
|
||||||
|
public DbSet<AreaComType> AreaCommitmentTypes { get; private set; }
|
||||||
public DbSet<Member> Members { get; private set; }
|
public DbSet<Member> Members { get; private set; }
|
||||||
public DbSet<BillingAddr> BillingAddresses { get; private set; }
|
public DbSet<BillingAddr> BillingAddresses { get; private set; }
|
||||||
public DbSet<MemberTelNr> MemberTelephoneNrs { get; private set; }
|
public DbSet<MemberTelNr> MemberTelephoneNrs { get; private set; }
|
||||||
public DbSet<AreaCom> AreaCommitments { get; private set; }
|
public DbSet<AreaCom> AreaCommitments { get; private set; }
|
||||||
public DbSet<AreaComAttr> AreaCommitmentAttributes { get; private set; }
|
|
||||||
public DbSet<Season> Seasons { get; private set; }
|
public DbSet<Season> Seasons { get; private set; }
|
||||||
public DbSet<Modifier> Modifiers { get; private set; }
|
public DbSet<Modifier> Modifiers { get; private set; }
|
||||||
public DbSet<Delivery> Deliveries { get; private set; }
|
public DbSet<Delivery> Deliveries { get; private set; }
|
||||||
public DbSet<DeliveryPart> DeliveryParts { get; private set; }
|
public DbSet<DeliveryPart> DeliveryParts { get; private set; }
|
||||||
public DbSet<DeliveryPartAttr> DeliveryPartAttributes { get; private set; }
|
public DbSet<DeliveryPartAttr> DeliveryPartAttributes { get; private set; }
|
||||||
public DbSet<DeliveryPartModifier> DeliveryPartModifiers { get; private set; }
|
public DbSet<DeliveryPartModifier> DeliveryPartModifiers { get; private set; }
|
||||||
|
public DbSet<PaymentVar> PaymentVariants { get; private set; }
|
||||||
|
|
||||||
private readonly StreamWriter? LogFile = null;
|
private readonly StreamWriter? LogFile = null;
|
||||||
public static DateTime LastWriteTime => File.GetLastWriteTime(App.Config.DatabaseFile);
|
public static DateTime LastWriteTime => File.GetLastWriteTime(App.Config.DatabaseFile);
|
||||||
@@ -60,7 +64,20 @@ namespace Elwig.Helpers {
|
|||||||
}
|
}
|
||||||
SavedLastWriteTime = LastWriteTime;
|
SavedLastWriteTime = LastWriteTime;
|
||||||
SavedChanges += OnSavedChanges;
|
SavedChanges += OnSavedChanges;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static SqliteConnection Connect() {
|
||||||
|
var cnx = new SqliteConnection(ConnectionString);
|
||||||
|
cnx.CreateFunction<string, string?, bool?>("REGEXP", (pattern, value) => value == null ? null : Regex.Match(value, pattern).Success, true);
|
||||||
|
cnx.Open();
|
||||||
|
return cnx;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static async Task<SqliteConnection> ConnectAsync() {
|
||||||
|
var cnx = new SqliteConnection(ConnectionString);
|
||||||
|
cnx.CreateFunction<string, string?, bool?>("REGEXP", (pattern, value) => value == null ? null : Regex.Match(value, pattern).Success, true);
|
||||||
|
await cnx.OpenAsync();
|
||||||
|
return cnx;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) {
|
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) {
|
||||||
@@ -103,14 +120,14 @@ namespace Elwig.Helpers {
|
|||||||
public async Task<int> NextMgNr() {
|
public async Task<int> NextMgNr() {
|
||||||
int c = await Members.Select(m => m.MgNr).MinAsync();
|
int c = await Members.Select(m => m.MgNr).MinAsync();
|
||||||
(await Members.OrderBy(m => m.MgNr).Select(m => m.MgNr).ToListAsync())
|
(await Members.OrderBy(m => m.MgNr).Select(m => m.MgNr).ToListAsync())
|
||||||
.ForEach(a => { if (a <= c + 100) c = a; });
|
.ForEach(a => { if (a <= c + 1000) c = a; });
|
||||||
return c + 1;
|
return c + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<int> NextFbNr() {
|
public async Task<int> NextFbNr() {
|
||||||
int c = await AreaCommitments.Select(ac => ac.FbNr).MinAsync();
|
int c = await AreaCommitments.Select(ac => ac.FbNr).MinAsync();
|
||||||
(await AreaCommitments.OrderBy(ac => ac.FbNr).Select(ac => ac.FbNr).ToListAsync())
|
(await AreaCommitments.OrderBy(ac => ac.FbNr).Select(ac => ac.FbNr).ToListAsync())
|
||||||
.ForEach(a => { if (a <= c + 100) c = a; });
|
.ForEach(a => { if (a <= c + 1000) c = a; });
|
||||||
return c + 1;
|
return c + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -118,21 +135,21 @@ namespace Elwig.Helpers {
|
|||||||
var dateStr = date.ToString("yyyy-MM-dd");
|
var dateStr = date.ToString("yyyy-MM-dd");
|
||||||
int c = 0;
|
int c = 0;
|
||||||
(await Deliveries.Where(d => d.DateString == dateStr).Select(d => d.LNr).ToListAsync())
|
(await Deliveries.Where(d => d.DateString == dateStr).Select(d => d.LNr).ToListAsync())
|
||||||
.ForEach(a => { if (a <= c + 10) c = a; });
|
.ForEach(a => { if (a <= c + 100) c = a; });
|
||||||
return c + 1;
|
return c + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<int> NextDId(int year) {
|
public async Task<int> NextDId(int year) {
|
||||||
int c = 0;
|
int c = 0;
|
||||||
(await Deliveries.Where(d => d.Year == year).Select(d => d.DId).ToListAsync())
|
(await Deliveries.Where(d => d.Year == year).Select(d => d.DId).ToListAsync())
|
||||||
.ForEach(a => { if (a <= c + 10) c = a; });
|
.ForEach(a => { if (a <= c + 100) c = a; });
|
||||||
return c + 1;
|
return c + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<int> NextDPNr(int year, int did) {
|
public async Task<int> NextDPNr(int year, int did) {
|
||||||
int c = 0;
|
int c = 0;
|
||||||
(await DeliveryParts.Where(p => p.Year == year && p.DId == did).Select(d => d.DPNr).ToListAsync())
|
(await DeliveryParts.Where(p => p.Year == year && p.DId == did).Select(d => d.DPNr).ToListAsync())
|
||||||
.ForEach(a => { if (a <= c + 10) c = a; });
|
.ForEach(a => { if (a <= c + 100) c = a; });
|
||||||
return c + 1;
|
return c + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -142,5 +159,71 @@ namespace Elwig.Helpers {
|
|||||||
.OrderBy(q => q.MinKmw)
|
.OrderBy(q => q.MinKmw)
|
||||||
.LastOrDefaultAsync();
|
.LastOrDefaultAsync();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public async Task UpdateDeliveryPartAttributes(DeliveryPart part, IEnumerable<WineAttr> attributes) {
|
||||||
|
foreach (var a in WineAttributes) {
|
||||||
|
var attr = part.PartAttributes.Where(pa => pa.AttrId == a.AttrId).FirstOrDefault();
|
||||||
|
if (attributes.Contains(a)) {
|
||||||
|
DeliveryPartAttr dpa = attr ?? this.CreateProxy<DeliveryPartAttr>();
|
||||||
|
dpa.Year = part.Year;
|
||||||
|
dpa.DId = part.DId;
|
||||||
|
dpa.DPNr = part.DPNr;
|
||||||
|
dpa.AttrId = a.AttrId;
|
||||||
|
if (attr == null) {
|
||||||
|
await AddAsync(dpa);
|
||||||
|
} else {
|
||||||
|
Update(dpa);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (attr != null) {
|
||||||
|
Remove(attr);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task UpdateDeliveryPartModifiers(DeliveryPart part, IEnumerable<Modifier> modifiers) {
|
||||||
|
foreach (var m in Modifiers.Where(m => m.Year == part.Year)) {
|
||||||
|
var mod = part.PartModifiers.Where(pa => pa.ModId == m.ModId).FirstOrDefault();
|
||||||
|
if (modifiers.Contains(m)) {
|
||||||
|
DeliveryPartModifier dpm = mod ?? this.CreateProxy<DeliveryPartModifier>();
|
||||||
|
dpm.Year = part.Year;
|
||||||
|
dpm.DId = part.DId;
|
||||||
|
dpm.DPNr = part.DPNr;
|
||||||
|
dpm.ModId = m.ModId;
|
||||||
|
if (mod == null) {
|
||||||
|
await AddAsync(dpm);
|
||||||
|
} else {
|
||||||
|
Update(dpm);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (mod != null) {
|
||||||
|
Remove(mod);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<IEnumerable<(string, string, int, int, int)>> GetMemberBuckets(Member m, int year) {
|
||||||
|
using var cnx = await ConnectAsync();
|
||||||
|
var (rights, obligations) = await Billing.Billing.GetMemberRightsObligations(m.MgNr, year, cnx);
|
||||||
|
var buckets = await Billing.Billing.GetMemberBucketWeights(m.MgNr, year, cnx);
|
||||||
|
|
||||||
|
var list = new List<(string, string, int, int, int)>();
|
||||||
|
foreach (var id in rights.Keys.Union(obligations.Keys).Union(buckets.Keys)) {
|
||||||
|
var s = await WineVarieties.FindAsync(id[..2]);
|
||||||
|
var attrIds = id[2..];
|
||||||
|
var a = await WineAttributes.Where(a => attrIds.Contains(a.AttrId)).ToListAsync();
|
||||||
|
var name = (s?.Name ?? "") + (a.Count > 0 ? $" ({string.Join(" / ", a.Select(a => a.Name))})" : "");
|
||||||
|
list.Add((
|
||||||
|
id, name,
|
||||||
|
rights.TryGetValue(id, out var v1) ? v1 : 0,
|
||||||
|
obligations.TryGetValue(id, out var v2) ? v2 : 0,
|
||||||
|
buckets.TryGetValue(id, out var v3) ? v3 : 0
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
|
return list;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
130
Elwig/Helpers/Billing/Billing.cs
Normal file
130
Elwig/Helpers/Billing/Billing.cs
Normal file
@@ -0,0 +1,130 @@
|
|||||||
|
using Microsoft.Data.Sqlite;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace Elwig.Helpers.Billing {
|
||||||
|
public class Billing {
|
||||||
|
|
||||||
|
private readonly int Year;
|
||||||
|
private readonly int AvNr;
|
||||||
|
private readonly AppDbContext Context;
|
||||||
|
private readonly Dictionary<string, string> Attributes;
|
||||||
|
private readonly Dictionary<string, (decimal?, decimal?)> Modifiers;
|
||||||
|
private readonly Dictionary<string, (string, string?, string?, string?, int?, int?, decimal?)> AreaComTypes;
|
||||||
|
|
||||||
|
public Billing(int year, int avnr) {
|
||||||
|
Year = year;
|
||||||
|
AvNr = avnr;
|
||||||
|
Context = new AppDbContext();
|
||||||
|
Attributes = Context.WineAttributes.ToDictionary(a => a.AttrId, a => a.Name);
|
||||||
|
Modifiers = Context.Modifiers.Where(m => m.Year == Year).ToDictionary(m => m.ModId, m => (m.Abs, m.Rel));
|
||||||
|
AreaComTypes = Context.AreaCommitmentTypes.ToDictionary(v => v.VtrgId, v => (v.SortId, v.AttrId1, v.AttrId2, v.Discriminator, v.MinKgPerHa, v.MaxKgPerHa, v.PenaltyAmount));
|
||||||
|
}
|
||||||
|
|
||||||
|
protected async Task DeleteInDb() {
|
||||||
|
using var cnx = await AppDbContext.ConnectAsync();
|
||||||
|
using (var cmd = cnx.CreateCommand()) {
|
||||||
|
cmd.CommandText = $"DELETE FROM payment_delivery_part WHERE (year, avnr) = ({Year}, {AvNr})";
|
||||||
|
await cmd.ExecuteNonQueryAsync();
|
||||||
|
}
|
||||||
|
using (var cmd = cnx.CreateCommand()) {
|
||||||
|
cmd.CommandText = $"DELETE FROM payment_member WHERE (year, avnr) = ({Year}, {AvNr})";
|
||||||
|
await cmd.ExecuteNonQueryAsync();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task Calculate() {
|
||||||
|
await DeleteInDb();
|
||||||
|
var tasks = new List<Task>();
|
||||||
|
foreach (var mgnr in Context.Members.Select(m => m.MgNr)) {
|
||||||
|
tasks.Add(Task.Run(() => CalculateMember(mgnr)));
|
||||||
|
}
|
||||||
|
await Task.WhenAll(tasks);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static async Task<(Dictionary<string, int>, Dictionary<string, int>)> GetMemberRightsObligations(int mgnr, int year, SqliteConnection cnx) {
|
||||||
|
var rights = new Dictionary<string, int>();
|
||||||
|
var obligations = new Dictionary<string, int>();
|
||||||
|
|
||||||
|
using var cmd = cnx.CreateCommand();
|
||||||
|
cmd.CommandText = $"""
|
||||||
|
SELECT t.vtrgid,
|
||||||
|
SUM(COALESCE(area * min_kg_per_ha, 0)) / 10000 AS min_kg,
|
||||||
|
SUM(COALESCE(area * max_kg_per_ha, 0)) / 10000 AS max_kg
|
||||||
|
FROM area_commitment c
|
||||||
|
JOIN area_commitment_type t ON t.vtrgid = c.vtrgid
|
||||||
|
WHERE mgnr = {mgnr} AND (year_from IS NULL OR year_from <= {year}) AND (year_to IS NULL OR year_to >= {year})
|
||||||
|
GROUP BY t.vtrgid
|
||||||
|
ORDER BY LENGTH(t.vtrgid) DESC, t.vtrgid
|
||||||
|
""";
|
||||||
|
|
||||||
|
var reader = await cmd.ExecuteReaderAsync();
|
||||||
|
while (await reader.ReadAsync()) {
|
||||||
|
var vtrgid = reader.GetString(0);
|
||||||
|
obligations[vtrgid] = reader.GetInt32(1);
|
||||||
|
rights[vtrgid] = reader.GetInt32(2);
|
||||||
|
}
|
||||||
|
|
||||||
|
return (rights, obligations);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static async Task<Dictionary<string, int>> GetMemberBucketWeights(int mgnr, int year, SqliteConnection cnx) {
|
||||||
|
var buckets = new Dictionary<string, int>();
|
||||||
|
|
||||||
|
using var cmd = cnx.CreateCommand();
|
||||||
|
cmd.CommandText = $"""
|
||||||
|
SELECT bucket, weight
|
||||||
|
FROM v_bucket
|
||||||
|
WHERE (year, mgnr) = ({year}, {mgnr})
|
||||||
|
""";
|
||||||
|
|
||||||
|
var reader = await cmd.ExecuteReaderAsync();
|
||||||
|
while (await reader.ReadAsync()) {
|
||||||
|
var bucket = reader.GetString(0);
|
||||||
|
buckets[bucket] = reader.GetInt32(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
return buckets;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected async Task CalculateMember(int mgnr) {
|
||||||
|
using var cnx = await AppDbContext.ConnectAsync();
|
||||||
|
var (rights, obligations) = await GetMemberRightsObligations(mgnr, Year, cnx);
|
||||||
|
|
||||||
|
var deliveries = new List<(int, int, string, int, double, string, string[], string[])>();
|
||||||
|
using (var cmd = cnx.CreateCommand()) {
|
||||||
|
cmd.CommandText = $"""
|
||||||
|
SELECT did, dpnr, sortid, weight, kmw, qualid, attributes, modifiers
|
||||||
|
FROM v_delivery
|
||||||
|
WHERE (year, mgnr) = ({Year}, {mgnr})
|
||||||
|
ORDER BY kmw DESC, weight DESC, did, dpnr
|
||||||
|
""";
|
||||||
|
var reader = await cmd.ExecuteReaderAsync();
|
||||||
|
while (await reader.ReadAsync()) {
|
||||||
|
deliveries.Add((
|
||||||
|
reader.GetInt32(0), reader.GetInt32(1), reader.GetString(2), reader.GetInt32(3),
|
||||||
|
reader.GetDouble(4), reader.GetString(5), reader.GetString(6).Split(","), reader.GetString(7).Split(",")
|
||||||
|
));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach (var (did, dpnr, sortid, weight, kmw, qualid, attributes, modifiers) in deliveries) {
|
||||||
|
if (qualid == "WEI" || qualid == "RSW" || qualid == "LDW") {
|
||||||
|
// Nicht mindestens Qualitätswein (QUW)
|
||||||
|
using var cmd = cnx.CreateCommand();
|
||||||
|
// TODO
|
||||||
|
cmd.CommandText = $"""
|
||||||
|
INSERT INTO payment_delivery_part (year, did, dpnr, avnr, mod_abs, mod_rel, )
|
||||||
|
VALUES ({Year}, {did}, {dpnr}, {AvNr}, )
|
||||||
|
""";
|
||||||
|
await cmd.ExecuteNonQueryAsync();
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@@ -1,15 +1,19 @@
|
|||||||
using Elwig.Models;
|
using Elwig.Models;
|
||||||
|
using Microsoft.Data.Sqlite;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace Elwig.Helpers {
|
namespace Elwig.Helpers {
|
||||||
public class ClientParameters {
|
public class ClientParameters {
|
||||||
|
|
||||||
public enum Type { Matzen, GWK };
|
public enum Type { Matzen, GWK };
|
||||||
|
|
||||||
|
public bool IsMatzen => Client == Type.Matzen;
|
||||||
|
public bool IsGWK => Client == Type.GWK;
|
||||||
|
|
||||||
public string NameToken;
|
public string NameToken;
|
||||||
public string NameShort;
|
public string NameShort;
|
||||||
public string NameShortened;
|
|
||||||
public string Name;
|
public string Name;
|
||||||
public string? NameSuffix;
|
public string? NameSuffix;
|
||||||
public string NameType;
|
public string NameType;
|
||||||
@@ -22,8 +26,8 @@ namespace Elwig.Helpers {
|
|||||||
Ort = value.AtPlz.Ort.Name;
|
Ort = value.AtPlz.Ort.Name;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public int Plz { get; private set; }
|
public int Plz;
|
||||||
public string Ort { get; private set; }
|
public string Ort;
|
||||||
public string Address;
|
public string Address;
|
||||||
public string Sender1 => $"{NameShort} | {Address} | {Plz} {Ort}";
|
public string Sender1 => $"{NameShort} | {Address} | {Plz} {Ort}";
|
||||||
public string Sender2;
|
public string Sender2;
|
||||||
@@ -40,8 +44,11 @@ namespace Elwig.Helpers {
|
|||||||
|
|
||||||
public int DeliveryObligation;
|
public int DeliveryObligation;
|
||||||
public int DeliveryRight;
|
public int DeliveryRight;
|
||||||
|
public decimal VatNormal;
|
||||||
|
public decimal VatReduced;
|
||||||
|
public decimal VatFlatRate;
|
||||||
|
|
||||||
public string? DeliveryNoteText;
|
public string? TextDeliveryNote;
|
||||||
|
|
||||||
public ClientParameters(AppDbContext ctx) : this(ctx.ClientParameters.ToDictionary(e => e.Param, e => e.Value)) { }
|
public ClientParameters(AppDbContext ctx) : this(ctx.ClientParameters.ToDictionary(e => e.Param, e => e.Value)) { }
|
||||||
|
|
||||||
@@ -50,7 +57,6 @@ namespace Elwig.Helpers {
|
|||||||
NameToken = parameters["CLIENT_NAME_TOKEN"] ?? throw new KeyNotFoundException();
|
NameToken = parameters["CLIENT_NAME_TOKEN"] ?? throw new KeyNotFoundException();
|
||||||
NameShort = parameters["CLIENT_NAME_SHORT"] ?? throw new KeyNotFoundException();
|
NameShort = parameters["CLIENT_NAME_SHORT"] ?? throw new KeyNotFoundException();
|
||||||
Name = parameters["CLIENT_NAME"] ?? throw new KeyNotFoundException();
|
Name = parameters["CLIENT_NAME"] ?? throw new KeyNotFoundException();
|
||||||
NameShortened = parameters["CLIENT_NAME_SHORTENED"] ?? Name;
|
|
||||||
NameSuffix = parameters.GetValueOrDefault("CLIENT_NAME_SUFFIX");
|
NameSuffix = parameters.GetValueOrDefault("CLIENT_NAME_SUFFIX");
|
||||||
NameType = parameters["CLIENT_NAME_TYPE"] ?? throw new KeyNotFoundException();
|
NameType = parameters["CLIENT_NAME_TYPE"] ?? throw new KeyNotFoundException();
|
||||||
switch (Name) {
|
switch (Name) {
|
||||||
@@ -69,15 +75,65 @@ namespace Elwig.Helpers {
|
|||||||
UstIdNr = parameters.GetValueOrDefault("CLIENT_USTIDNR");
|
UstIdNr = parameters.GetValueOrDefault("CLIENT_USTIDNR");
|
||||||
Bic = parameters.GetValueOrDefault("CLIENT_BIC");
|
Bic = parameters.GetValueOrDefault("CLIENT_BIC");
|
||||||
Iban = parameters.GetValueOrDefault("CLIENT_IBAN");
|
Iban = parameters.GetValueOrDefault("CLIENT_IBAN");
|
||||||
Sender2 = parameters.GetValueOrDefault("DOCUMENT_SENDER") ?? "";
|
|
||||||
|
|
||||||
DeliveryObligation = int.Parse(parameters["DELIVERY_OBLIGATION"] ?? "");
|
DeliveryObligation = int.Parse(parameters["DELIVERY_OBLIGATION"] ?? "");
|
||||||
DeliveryRight = int.Parse(parameters["DELIVERY_RIGHT"] ?? "");
|
DeliveryRight = int.Parse(parameters["DELIVERY_RIGHT"] ?? "");
|
||||||
|
VatNormal = decimal.Parse((parameters["VAT_NORMAL"] ?? "").Replace(".", ","));
|
||||||
|
VatReduced = decimal.Parse((parameters["VAT_REDUCED"] ?? "").Replace(".", ","));
|
||||||
|
VatFlatRate = decimal.Parse((parameters["VAT_FLATRATE"] ?? "").Replace(".", ","));
|
||||||
|
|
||||||
DeliveryNoteText = parameters.GetValueOrDefault("DELIVERY_NOTE_TEXT");
|
Sender2 = parameters.GetValueOrDefault("DOCUMENT_SENDER") ?? "";
|
||||||
|
TextDeliveryNote = parameters.GetValueOrDefault("TEXT_DELIVERYNOTE");
|
||||||
} catch {
|
} catch {
|
||||||
throw new KeyNotFoundException();
|
throw new KeyNotFoundException();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private IEnumerable<(string, string?)> GetParamValues() {
|
||||||
|
return new (string, string?)[] {
|
||||||
|
("CLIENT_NAME_TOKEN", NameToken),
|
||||||
|
("CLIENT_NAME_SHORT", NameShort),
|
||||||
|
("CLIENT_NAME", Name),
|
||||||
|
("CLIENT_NAME_SUFFIX", NameSuffix),
|
||||||
|
("CLIENT_NAME_TYPE", NameType),
|
||||||
|
("CLIENT_PLZ", Plz.ToString()),
|
||||||
|
("CLIENT_ORT", Ort),
|
||||||
|
("CLIENT_ADDRESS", Address),
|
||||||
|
("CLIENT_PHONE", PhoneNr),
|
||||||
|
("CLIENT_FAX", FaxNr),
|
||||||
|
("CLIENT_EMAIL", EmailAddress),
|
||||||
|
("CLIENT_WEBSITE", Website),
|
||||||
|
("CLIENT_LFBISNR", LfbisNr),
|
||||||
|
("CLIENT_USTIDNR", UstIdNr),
|
||||||
|
("CLIENT_BIC", Bic),
|
||||||
|
("CLIENT_IBAN", Iban),
|
||||||
|
("DELIVERY_OBLIGATION", DeliveryObligation.ToString()),
|
||||||
|
("DELIVERY_RIGHT", DeliveryRight.ToString()),
|
||||||
|
("VAT_NORMAL", VatNormal.ToString().Replace(",", ".")),
|
||||||
|
("VAT_REDUCED", VatReduced.ToString().Replace(",", ".")),
|
||||||
|
("VAT_FLATRATE", VatFlatRate.ToString().Replace(",", ".")),
|
||||||
|
("DOCUMENT_SENDER", Sender2),
|
||||||
|
("TEXT_DELIVERYNOTE", TextDeliveryNote),
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task UpdateValues() {
|
||||||
|
using var cnx = await AppDbContext.ConnectAsync();
|
||||||
|
using var cmd = cnx.CreateCommand();
|
||||||
|
var pv = GetParamValues();
|
||||||
|
cmd.CommandText = "INSERT INTO client_parameter (param, value) VALUES " +
|
||||||
|
string.Join(", ", pv.Select((pv, i) => $"(@p{i}, " + (pv.Item2 != null ? $"@v{i}" : "NULL") + ")")) +
|
||||||
|
" ON CONFLICT DO UPDATE SET value = excluded.value";
|
||||||
|
|
||||||
|
int i = 0;
|
||||||
|
foreach (var (p, v) in pv) {
|
||||||
|
cmd.Parameters.Add(new SqliteParameter($"@p{i}", p));
|
||||||
|
if (v != null)
|
||||||
|
cmd.Parameters.Add(new SqliteParameter($"@v{i}", v));
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
|
||||||
|
await cmd.ExecuteNonQueryAsync();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -25,6 +25,10 @@ namespace Elwig.Helpers {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void SetInputNotDefault(Control input) {
|
||||||
|
SetControlBrush(input, Brushes.Gold);
|
||||||
|
}
|
||||||
|
|
||||||
public static void SetInputChanged(Control input) {
|
public static void SetInputChanged(Control input) {
|
||||||
SetControlBrush(input, Brushes.Orange);
|
SetControlBrush(input, Brushes.Orange);
|
||||||
}
|
}
|
||||||
@@ -102,6 +106,7 @@ namespace Elwig.Helpers {
|
|||||||
var selectedIds = selector.SelectedItems.Cast<object>().Select(i => getId(i)).ToList();
|
var selectedIds = selector.SelectedItems.Cast<object>().Select(i => getId(i)).ToList();
|
||||||
selector.ItemsSource = source;
|
selector.ItemsSource = source;
|
||||||
if (source != null) {
|
if (source != null) {
|
||||||
|
selector.SelectedItems.Clear();
|
||||||
foreach (var i in source.Cast<object>().Where(i => selectedIds.Contains(getId(i))))
|
foreach (var i in source.Cast<object>().Where(i => selectedIds.Contains(getId(i))))
|
||||||
selector.SelectedItems.Add(i);
|
selector.SelectedItems.Add(i);
|
||||||
}
|
}
|
||||||
@@ -198,5 +203,21 @@ namespace Elwig.Helpers {
|
|||||||
public static void SelectCheckComboBoxItems(Xceed.Wpf.Toolkit.CheckComboBox ccb, IEnumerable<object>? items, Func<object?, object?> getId) {
|
public static void SelectCheckComboBoxItems(Xceed.Wpf.Toolkit.CheckComboBox ccb, IEnumerable<object>? items, Func<object?, object?> getId) {
|
||||||
SelectCheckComboBoxItems(ccb, getId, items?.Select(i => getId(i)));
|
SelectCheckComboBoxItems(ccb, getId, items?.Select(i => getId(i)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static object? GetInputValue(Control input) {
|
||||||
|
if (input is TextBox tb) {
|
||||||
|
return tb.Text;
|
||||||
|
} else if (input is ComboBox sb) {
|
||||||
|
return sb.SelectedItem;
|
||||||
|
} else if (input is Xceed.Wpf.Toolkit.CheckComboBox ccb) {
|
||||||
|
return ccb.SelectedItems.Cast<object>().ToArray();
|
||||||
|
} else if (input is CheckBox cb) {
|
||||||
|
return cb.IsChecked?.ToString();
|
||||||
|
} else if (input is RadioButton rb) {
|
||||||
|
return rb.IsChecked?.ToString();
|
||||||
|
} else {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
4
Elwig/Helpers/Export/Bki.cs
Normal file
4
Elwig/Helpers/Export/Bki.cs
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
namespace Elwig.Helpers.Export {
|
||||||
|
public class Bki {
|
||||||
|
}
|
||||||
|
}
|
4
Elwig/Helpers/Export/Csv.cs
Normal file
4
Elwig/Helpers/Export/Csv.cs
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
namespace Elwig.Helpers.Export {
|
||||||
|
public class Csv {
|
||||||
|
}
|
||||||
|
}
|
15
Elwig/Helpers/Export/Ebics.cs
Normal file
15
Elwig/Helpers/Export/Ebics.cs
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
using Elwig.Models;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace Elwig.Helpers.Export {
|
||||||
|
public class Ebics : IBankingProvider {
|
||||||
|
|
||||||
|
public string FileExtension => "xml";
|
||||||
|
|
||||||
|
public Task Export(string filename, int avnr, IEnumerable<Member> members) {
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
15
Elwig/Helpers/Export/Elba.cs
Normal file
15
Elwig/Helpers/Export/Elba.cs
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
using Elwig.Models;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace Elwig.Helpers.Export {
|
||||||
|
public class Elba : IBankingProvider {
|
||||||
|
|
||||||
|
public string FileExtension => "elba";
|
||||||
|
|
||||||
|
public Task Export(string filename, int avnr, IEnumerable<Member> members) {
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
24
Elwig/Helpers/Export/IBankingProvider.cs
Normal file
24
Elwig/Helpers/Export/IBankingProvider.cs
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
using Elwig.Models;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace Elwig.Helpers.Export {
|
||||||
|
/// <summary>
|
||||||
|
/// Interface for exporting banking data
|
||||||
|
/// </summary>
|
||||||
|
public interface IBankingProvider {
|
||||||
|
/// <summary>
|
||||||
|
/// The default file extension of the exported files to be used (whithout a preceding ".")
|
||||||
|
/// </summary>
|
||||||
|
string FileExtension { get; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Export the member payment data of the given payment variant to the given file.
|
||||||
|
/// (The amount of the last payed variant is deducted from the calculated amount.)
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="filename">The file to export the data to</param>
|
||||||
|
/// <param name="avnr">The number of the payment variant to export</param>
|
||||||
|
/// <param name="members">The members whose data to include in the export</param>
|
||||||
|
Task Export(string filename, int avnr, IEnumerable<Member> members);
|
||||||
|
}
|
||||||
|
}
|
@@ -187,22 +187,30 @@ namespace Elwig.Helpers {
|
|||||||
if (!searchKeywords.Any())
|
if (!searchKeywords.Any())
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
words = words.Select(w => w?.ToLower());
|
return words
|
||||||
int i = 0;
|
.Select(w => {
|
||||||
foreach (string? c in words) {
|
w = w?.ToLower();
|
||||||
if (c == null) continue;
|
var p = w?.ToLower()?.Split(" ");
|
||||||
var parts = c.Split(" ");
|
if (w == null || p == null)
|
||||||
if (searchKeywords.Any(f => c == f)) {
|
return 0;
|
||||||
i += 100;
|
|
||||||
} else if (searchKeywords.Any(f => parts.Any(a => a == f))) {
|
var t1 = searchKeywords.Where(f => w == f).Select(f => f.Length).OrderDescending().FirstOrDefault(0);
|
||||||
i += 90;
|
var t2 = searchKeywords.Where(f => p.Any(a => a == f)).Select(f => f.Length).OrderDescending().FirstOrDefault(0);
|
||||||
} else if (searchKeywords.Any(f => parts.Any(a => a.StartsWith(f)))) {
|
var t3 = searchKeywords.Where(f => p.Any(a => a.StartsWith(f))).Select(f => f.Length).OrderDescending().FirstOrDefault(0);
|
||||||
i += 50;
|
var t4 = searchKeywords.Where(f => w.Contains(f)).Select(f => f.Length).OrderDescending().FirstOrDefault(0);
|
||||||
} else if (searchKeywords.Any(f => f != null && c.Contains(f))) {
|
if (t1 > 0) {
|
||||||
i += 1;
|
return 4 + t1;
|
||||||
}
|
} else if (t2 > 0) {
|
||||||
}
|
return 3 + t2;
|
||||||
return i;
|
} else if (t3 > 0) {
|
||||||
|
return 2 + t3;
|
||||||
|
} else if (t4 > 0) {
|
||||||
|
return 1 + t4;
|
||||||
|
} else {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.Sum();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static (int, string?)? ShowManualWeighingDialog() {
|
public static (int, string?)? ShowManualWeighingDialog() {
|
||||||
@@ -210,6 +218,21 @@ namespace Elwig.Helpers {
|
|||||||
return d.ShowDialog() == true ? (d.Weight, d.Reason) : null;
|
return d.ShowDialog() == true ? (d.Weight, d.Reason) : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static int? ShowAbwertenDialog(string lsnr, string name, int weight) {
|
||||||
|
var d = new AbwertenDialog(lsnr, name, weight);
|
||||||
|
return d.ShowDialog() == true ? d.Weight : null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static double? ShowLinearPriceIncreaseDialog() {
|
||||||
|
var d = new LinearPriceIncreaseDialog();
|
||||||
|
return d.ShowDialog() == true ? d.Price : null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static string? ShowDeliveryExtractionDialog(string lsnr, string name, bool single, IEnumerable<string> lsnrs) {
|
||||||
|
var d = new DeliveryExtractionDialog(lsnr, name, single, lsnrs);
|
||||||
|
return d.ShowDialog() == true ? d.AddTo : null;
|
||||||
|
}
|
||||||
|
|
||||||
public static Footer GenerateFooter(string lineBreak, string seperator) {
|
public static Footer GenerateFooter(string lineBreak, string seperator) {
|
||||||
return new Footer(lineBreak, seperator);
|
return new Footer(lineBreak, seperator);
|
||||||
}
|
}
|
||||||
@@ -265,5 +288,9 @@ namespace Elwig.Helpers {
|
|||||||
),
|
),
|
||||||
sum => sum.Kmw
|
sum => sum.Kmw
|
||||||
);
|
);
|
||||||
|
|
||||||
|
public static string GenerateLsNr(Delivery d) => GenerateLsNr(d.Date, d.ZwstId, d.LNr);
|
||||||
|
|
||||||
|
public static string GenerateLsNr(DateOnly date, string zwstid, int lnr) => $"{date:yyyyMMdd}{zwstid}{lnr:000}";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -1,7 +1,5 @@
|
|||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.ComponentModel.DataAnnotations.Schema;
|
using System.ComponentModel.DataAnnotations.Schema;
|
||||||
using System.Linq;
|
|
||||||
|
|
||||||
namespace Elwig.Models {
|
namespace Elwig.Models {
|
||||||
[Table("area_commitment"), PrimaryKey("FbNr")]
|
[Table("area_commitment"), PrimaryKey("FbNr")]
|
||||||
@@ -12,8 +10,8 @@ namespace Elwig.Models {
|
|||||||
[Column("mgnr")]
|
[Column("mgnr")]
|
||||||
public int MgNr { get; set; }
|
public int MgNr { get; set; }
|
||||||
|
|
||||||
[Column("sortid")]
|
[Column("vtrgid")]
|
||||||
public string SortId { get; set; }
|
public string VtrgId { get; set; }
|
||||||
|
|
||||||
[Column("cultid")]
|
[Column("cultid")]
|
||||||
public string CultId { get; set; }
|
public string CultId { get; set; }
|
||||||
@@ -42,8 +40,8 @@ namespace Elwig.Models {
|
|||||||
[ForeignKey("MgNr")]
|
[ForeignKey("MgNr")]
|
||||||
public virtual Member Member { get; private set; }
|
public virtual Member Member { get; private set; }
|
||||||
|
|
||||||
[ForeignKey("SortId")]
|
[ForeignKey("VtrgId")]
|
||||||
public virtual WineVar WineVar { get; private set; }
|
public virtual AreaComType AreaComType { get; private set; }
|
||||||
|
|
||||||
[ForeignKey("CultId")]
|
[ForeignKey("CultId")]
|
||||||
public virtual WineCult WineCult { get; private set; }
|
public virtual WineCult WineCult { get; private set; }
|
||||||
@@ -53,11 +51,5 @@ namespace Elwig.Models {
|
|||||||
|
|
||||||
[ForeignKey("KgNr, RdNr")]
|
[ForeignKey("KgNr, RdNr")]
|
||||||
public virtual WbRd? Rd { get; private set; }
|
public virtual WbRd? Rd { get; private set; }
|
||||||
|
|
||||||
[InverseProperty("AreaCom")]
|
|
||||||
public virtual ISet<AreaComAttr> AttributeEntries { get; private set; }
|
|
||||||
|
|
||||||
[NotMapped]
|
|
||||||
public IEnumerable<WineAttr> Attributes => AttributeEntries.Select(e => e.WineAttr);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -1,19 +0,0 @@
|
|||||||
using Microsoft.EntityFrameworkCore;
|
|
||||||
using System.ComponentModel.DataAnnotations.Schema;
|
|
||||||
|
|
||||||
namespace Elwig.Models {
|
|
||||||
[Table("area_commitment_attribute"), PrimaryKey("FbNr", "AttrId")]
|
|
||||||
public class AreaComAttr {
|
|
||||||
[Column("fbnr")]
|
|
||||||
public int FbNr { get; set; }
|
|
||||||
|
|
||||||
[Column("attrid")]
|
|
||||||
public string AttrId { get; set; }
|
|
||||||
|
|
||||||
[ForeignKey("FbNr")]
|
|
||||||
public virtual AreaCom AreaCom { get; private set; }
|
|
||||||
|
|
||||||
[ForeignKey("AttrId")]
|
|
||||||
public virtual WineAttr WineAttr { get; private set; }
|
|
||||||
}
|
|
||||||
}
|
|
51
Elwig/Models/AreaComType.cs
Normal file
51
Elwig/Models/AreaComType.cs
Normal file
@@ -0,0 +1,51 @@
|
|||||||
|
using Elwig.Helpers;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using System.ComponentModel.DataAnnotations.Schema;
|
||||||
|
|
||||||
|
namespace Elwig.Models {
|
||||||
|
[Table("area_commitment_type"), PrimaryKey("VtrgId"), Index("SortId", "AttrId1", "AttrId2", "Discriminator")]
|
||||||
|
public class AreaComType {
|
||||||
|
[Column("vtrgid")]
|
||||||
|
public string VtrgId { get; set; }
|
||||||
|
|
||||||
|
[Column("sortid")]
|
||||||
|
public string SortId { get; set; }
|
||||||
|
|
||||||
|
[Column("attrid_1")]
|
||||||
|
public string? AttrId1 { get; set; }
|
||||||
|
|
||||||
|
[Column("attrid_2")]
|
||||||
|
public string? AttrId2 { get; set; }
|
||||||
|
|
||||||
|
[Column("disc")]
|
||||||
|
public string? Discriminator { get; set; }
|
||||||
|
|
||||||
|
[Column("min_kg_per_ha")]
|
||||||
|
public int? MinKgPerHa { get; set; }
|
||||||
|
|
||||||
|
[Column("max_kg_per_ha")]
|
||||||
|
public int? MaxKgPerHa { get; set; }
|
||||||
|
|
||||||
|
[Column("penalty_amount")]
|
||||||
|
public long? PenaltyAmoutValue { get; set; }
|
||||||
|
|
||||||
|
[NotMapped]
|
||||||
|
public decimal? PenaltyAmount {
|
||||||
|
get => PenaltyAmoutValue != null ? Utils.DecFromDb(PenaltyAmoutValue.Value, 4) : null;
|
||||||
|
set => PenaltyAmoutValue = value != null ? Utils.DecToDb(value.Value, 4) : null;
|
||||||
|
}
|
||||||
|
|
||||||
|
[ForeignKey("SortId")]
|
||||||
|
public virtual WineVar WineVar { get; private set; }
|
||||||
|
|
||||||
|
[ForeignKey("AttrId1")]
|
||||||
|
public virtual WineAttr? WineAttr1 { get; private set; }
|
||||||
|
|
||||||
|
[ForeignKey("AttrId2")]
|
||||||
|
public virtual WineAttr? WineAttr2 { get; private set; }
|
||||||
|
|
||||||
|
[NotMapped]
|
||||||
|
public string DisplayName => WineVar.Name + (WineAttr1 != null ? $" {WineAttr1.Name}" : "") +
|
||||||
|
(WineAttr2 != null ? $" {WineAttr2.Name}" : "") + (Discriminator != null ? $" ({Discriminator})" : "");
|
||||||
|
}
|
||||||
|
}
|
@@ -18,6 +18,6 @@ namespace Elwig.Models {
|
|||||||
public long? OneEuroValue { get; private set; }
|
public long? OneEuroValue { get; private set; }
|
||||||
|
|
||||||
[NotMapped]
|
[NotMapped]
|
||||||
public decimal? OneEuro => OneEuroValue != null ? Utils.DecFromDb((long)OneEuroValue, 6) : null;
|
public decimal? OneEuro => OneEuroValue != null ? Utils.DecFromDb(OneEuroValue.Value, 6) : null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
123
Elwig/Models/Graph.cs
Normal file
123
Elwig/Models/Graph.cs
Normal file
@@ -0,0 +1,123 @@
|
|||||||
|
using Newtonsoft.Json.Linq;
|
||||||
|
using ScottPlot;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Diagnostics.Contracts;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using System.Windows.Markup;
|
||||||
|
|
||||||
|
namespace Elwig.Models {
|
||||||
|
public class Graph : ICloneable {
|
||||||
|
|
||||||
|
public string Type { get; set; }
|
||||||
|
public int Num { get; set; }
|
||||||
|
private int MinX { get; set; }
|
||||||
|
private int MaxX { get; set; }
|
||||||
|
public string Contracts { get; set; }
|
||||||
|
public double[] DataX { get; set; }
|
||||||
|
public double[] DataY { get; set; }
|
||||||
|
|
||||||
|
public Graph(int num, int minX, int maxX) {
|
||||||
|
Type = "oe";
|
||||||
|
Num = num;
|
||||||
|
Contracts = "";
|
||||||
|
MinX = minX;
|
||||||
|
MaxX = maxX;
|
||||||
|
|
||||||
|
DataX = DataGen.Range(MinX, MaxX + 1);
|
||||||
|
DataY = DataGen.Zeros(MaxX - MinX + 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Graph(string type, int num, JToken graphData, string contracts, int minX, int maxX) {
|
||||||
|
Type = type;
|
||||||
|
Num = num;
|
||||||
|
Contracts = contracts;
|
||||||
|
MinX = minX;
|
||||||
|
MaxX = maxX;
|
||||||
|
|
||||||
|
DataX = DataGen.Range(MinX, MaxX + 1);
|
||||||
|
DataY = DataGen.Zeros(MaxX - MinX + 1);
|
||||||
|
ParseGraphData(graphData);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Graph(string type, int num, int minX, int maxX, string contracts, double[] dataX, double[] dataY) {
|
||||||
|
Type = type;
|
||||||
|
Num = num;
|
||||||
|
MinX = minX;
|
||||||
|
MaxX = maxX;
|
||||||
|
Contracts = contracts;
|
||||||
|
DataX = dataX;
|
||||||
|
DataY = dataY;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ParseGraphData(JToken graphData) {
|
||||||
|
var GraphPoints = graphData.Children().OfType<JProperty>().ToDictionary(p => int.Parse(p.Name[..^2]), p => (double)p.Value);
|
||||||
|
|
||||||
|
if (GraphPoints.Keys.Count < 1) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var minKey = GraphPoints.Keys.Order().First();
|
||||||
|
var maxKey = GraphPoints.Keys.OrderDescending().First();
|
||||||
|
|
||||||
|
if (!GraphPoints.ContainsKey(MinX)) {
|
||||||
|
GraphPoints.Add(MinX, GraphPoints.GetValueOrDefault(minKey));
|
||||||
|
}
|
||||||
|
if (!GraphPoints.ContainsKey(MaxX)) {
|
||||||
|
GraphPoints.Add(MaxX, GraphPoints.GetValueOrDefault(maxKey));
|
||||||
|
}
|
||||||
|
|
||||||
|
var keys = GraphPoints.Keys.Order().ToArray();
|
||||||
|
|
||||||
|
for (int i = 0; i < keys.Length; i++) {
|
||||||
|
double point1Value = GraphPoints[keys[i]];
|
||||||
|
if (i + 1 < keys.Length) {
|
||||||
|
double point2Value = GraphPoints[keys[i + 1]];
|
||||||
|
if (point1Value == point2Value) {
|
||||||
|
for (int j = keys[i] - MinX; j < keys[i + 1] - MinX; j++) {
|
||||||
|
DataY[j] = point1Value;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
int steps = Math.Abs(keys[i + 1] - keys[i]);
|
||||||
|
double step = (point2Value - point1Value) / steps;
|
||||||
|
|
||||||
|
DataY[keys[i] - MinX] = point1Value;
|
||||||
|
DataY[keys[i + 1] - MinX] = point2Value;
|
||||||
|
|
||||||
|
for (int j = keys[i] - MinX; j < keys[i + 1] - MinX - 1; j++) {
|
||||||
|
DataY[j + 1] = Math.Round(DataY[j] + step, 4); // TODO richtig runden
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
for (int j = keys[i] - MinX; j < DataX.Length; j++) {
|
||||||
|
DataY[j] = point1Value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public JObject ToJson() {
|
||||||
|
JObject graph = new();
|
||||||
|
|
||||||
|
if (DataY[0] != DataY[1]) {
|
||||||
|
graph.Add(new JProperty(DataX[0] + Type.ToLower(), Math.Round(DataY[0], 4)));
|
||||||
|
}
|
||||||
|
for (int i = 1; i < DataX.Length - 1; i++) {
|
||||||
|
if (Math.Round(DataY[i] - DataY[i - 1], 4) != Math.Round(DataY[i + 1] - DataY[i], 4)) {
|
||||||
|
graph.Add(new JProperty(DataX[i] + Type.ToLower(), Math.Round(DataY[i], 4)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (DataY[^1] != DataY[^2]) {
|
||||||
|
graph.Add(new JProperty(DataX[^1] + Type.ToLower(), Math.Round(DataY[^1], 4)));
|
||||||
|
}
|
||||||
|
return graph;
|
||||||
|
}
|
||||||
|
|
||||||
|
public object Clone() {
|
||||||
|
return new Graph(Type, Num, MinX, MaxX, Contracts, (double[])DataX.Clone(), (double[])DataY.Clone());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@@ -110,6 +110,9 @@ namespace Elwig.Models {
|
|||||||
[Column("active")]
|
[Column("active")]
|
||||||
public bool IsActive { get; set; }
|
public bool IsActive { get; set; }
|
||||||
|
|
||||||
|
[Column("deceased")]
|
||||||
|
public bool IsDeceased { get; set; }
|
||||||
|
|
||||||
[Column("iban")]
|
[Column("iban")]
|
||||||
public string? Iban { get; set; }
|
public string? Iban { get; set; }
|
||||||
|
|
||||||
@@ -173,6 +176,9 @@ namespace Elwig.Models {
|
|||||||
|
|
||||||
public string FullAddress => $"{Address}, {PostalDest.AtPlz.Plz} {PostalDest.AtPlz.Ort.Name}";
|
public string FullAddress => $"{Address}, {PostalDest.AtPlz.Plz} {PostalDest.AtPlz.Ort.Name}";
|
||||||
|
|
||||||
|
public int DeliveryRight => BusinessShares * App.Client.DeliveryRight;
|
||||||
|
public int DeliveryObligation => BusinessShares * App.Client.DeliveryObligation;
|
||||||
|
|
||||||
public int SearchScore(IEnumerable<string> keywords) {
|
public int SearchScore(IEnumerable<string> keywords) {
|
||||||
return Utils.GetSearchScore(new string?[] {
|
return Utils.GetSearchScore(new string?[] {
|
||||||
MgNr.ToString(),
|
MgNr.ToString(),
|
||||||
|
@@ -2,6 +2,7 @@ using Elwig.Helpers;
|
|||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using System;
|
using System;
|
||||||
using System.ComponentModel.DataAnnotations.Schema;
|
using System.ComponentModel.DataAnnotations.Schema;
|
||||||
|
using System.Linq;
|
||||||
|
|
||||||
namespace Elwig.Models {
|
namespace Elwig.Models {
|
||||||
[Table("modifier"), PrimaryKey("Year", "ModId")]
|
[Table("modifier"), PrimaryKey("Year", "ModId")]
|
||||||
@@ -23,16 +24,18 @@ namespace Elwig.Models {
|
|||||||
|
|
||||||
[NotMapped]
|
[NotMapped]
|
||||||
public decimal? Abs {
|
public decimal? Abs {
|
||||||
get {
|
get => AbsValue != null ? Season.DecFromDb(AbsValue.Value) : null;
|
||||||
return AbsValue != null ? Season.DecFromDb((long)AbsValue) : null;
|
set => AbsValue = value != null ? Season.DecToDb(value.Value) : null;
|
||||||
}
|
|
||||||
set {
|
|
||||||
AbsValue = value != null ? Season.DecToDb((decimal)value) : null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[Column("rel")]
|
[Column("rel")]
|
||||||
public double? Rel { get; set; }
|
public double? RelValue { get; set; }
|
||||||
|
|
||||||
|
[NotMapped]
|
||||||
|
public decimal? Rel {
|
||||||
|
get => (decimal?)RelValue;
|
||||||
|
set => RelValue = (double?)value;
|
||||||
|
}
|
||||||
|
|
||||||
[Column("standard")]
|
[Column("standard")]
|
||||||
public bool IsStandard { get; set; }
|
public bool IsStandard { get; set; }
|
||||||
@@ -44,8 +47,8 @@ namespace Elwig.Models {
|
|||||||
public virtual Season Season { get; private set; }
|
public virtual Season Season { get; private set; }
|
||||||
|
|
||||||
public string ValueStr =>
|
public string ValueStr =>
|
||||||
(Abs != null) ? $"{Utils.GetSign(Abs.Value)}{Math.Abs(Abs.Value)}\u00a0{Season.Currency.Symbol}/kg" :
|
(Abs != null) ? $"{Utils.GetSign(Abs.Value)}{Math.Abs(Abs.Value).ToString("0." + string.Concat(Enumerable.Repeat('0', Season.Precision)))}\u00a0{Season.Currency.Symbol}/kg" :
|
||||||
(Rel != null) ? $"{Utils.GetSign(Rel.Value)}{(Math.Abs(Rel.Value) < 0.1 ? "\u2007" : "")}{Math.Abs(Rel.Value):0.00##\u00a0%}" :
|
(Rel != null) ? $"{Utils.GetSign(Rel.Value)}{(Math.Abs(Rel.Value) < 0.1m ? "\u2007" : "")}{Math.Abs(Rel.Value):0.00##\u00a0%}" :
|
||||||
"";
|
"";
|
||||||
|
|
||||||
public override string ToString() {
|
public override string ToString() {
|
||||||
|
69
Elwig/Models/PaymentVar.cs
Normal file
69
Elwig/Models/PaymentVar.cs
Normal file
@@ -0,0 +1,69 @@
|
|||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using System;
|
||||||
|
using System.ComponentModel.DataAnnotations.Schema;
|
||||||
|
|
||||||
|
namespace Elwig.Models {
|
||||||
|
[Table("payment_variant"), PrimaryKey("Year", "AvNr")]
|
||||||
|
public class PaymentVar {
|
||||||
|
[Column("year")]
|
||||||
|
public int Year { get; set; }
|
||||||
|
|
||||||
|
[Column("avnr")]
|
||||||
|
public int AvNr { get; set; }
|
||||||
|
|
||||||
|
[Column("name")]
|
||||||
|
public string Name { get; set; }
|
||||||
|
|
||||||
|
[Column("date")]
|
||||||
|
public string DateString { get; set; }
|
||||||
|
|
||||||
|
[NotMapped]
|
||||||
|
public DateOnly Date {
|
||||||
|
get {
|
||||||
|
return DateOnly.ParseExact(DateString, "yyyy-MM-dd");
|
||||||
|
}
|
||||||
|
set {
|
||||||
|
DateString = value.ToString("yyyy-MM-dd");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[Column("test_variant")]
|
||||||
|
public bool TestVariant { get; set; }
|
||||||
|
|
||||||
|
[Column("calc_time")]
|
||||||
|
public int? CalcTime { get; set; }
|
||||||
|
|
||||||
|
[Column("bucket_1_name")]
|
||||||
|
public string? Bucket1Name { get; set; }
|
||||||
|
|
||||||
|
[Column("bucket_2_name")]
|
||||||
|
public string? Bucket2Name { get; set; }
|
||||||
|
|
||||||
|
[Column("bucket_3_name")]
|
||||||
|
public string? Bucket3Name { get; set; }
|
||||||
|
|
||||||
|
[Column("bucket_4_name")]
|
||||||
|
public string? Bucket4Name { get; set; }
|
||||||
|
|
||||||
|
[Column("bucket_5_name")]
|
||||||
|
public string? Bucket5Name { get; set; }
|
||||||
|
|
||||||
|
[Column("bucket_6_name")]
|
||||||
|
public string? Bucket6Name { get; set; }
|
||||||
|
|
||||||
|
[Column("bucket_7_name")]
|
||||||
|
public string? Bucket7Name { get; set; }
|
||||||
|
|
||||||
|
[Column("bucket_8_name")]
|
||||||
|
public string? Bucket8Name { get; set; }
|
||||||
|
|
||||||
|
[Column("bucket_9_name")]
|
||||||
|
public string? Bucket9Name { get; set; }
|
||||||
|
|
||||||
|
[Column("comment")]
|
||||||
|
public string? Comment { get; set; }
|
||||||
|
|
||||||
|
[Column("data")]
|
||||||
|
public string Data { get; set; }
|
||||||
|
}
|
||||||
|
}
|
@@ -43,6 +43,7 @@ namespace Elwig.Windows {
|
|||||||
private RadioButton[] RadioButtonInputs;
|
private RadioButton[] RadioButtonInputs;
|
||||||
private readonly Dictionary<Control, bool> Valid;
|
private readonly Dictionary<Control, bool> Valid;
|
||||||
private readonly Dictionary<Control, object?> OriginalValues;
|
private readonly Dictionary<Control, object?> OriginalValues;
|
||||||
|
private readonly Dictionary<Control, object?> DefaultValues;
|
||||||
|
|
||||||
public AdministrationWindow() : base() {
|
public AdministrationWindow() : base() {
|
||||||
IsEditing = false;
|
IsEditing = false;
|
||||||
@@ -58,6 +59,7 @@ namespace Elwig.Windows {
|
|||||||
RadioButtonInputs = Array.Empty<RadioButton>();
|
RadioButtonInputs = Array.Empty<RadioButton>();
|
||||||
Valid = new();
|
Valid = new();
|
||||||
OriginalValues = new();
|
OriginalValues = new();
|
||||||
|
DefaultValues = new();
|
||||||
Closing += OnClosing;
|
Closing += OnClosing;
|
||||||
Loaded += OnLoaded;
|
Loaded += OnLoaded;
|
||||||
}
|
}
|
||||||
@@ -101,6 +103,12 @@ namespace Elwig.Windows {
|
|||||||
return (sender is Control c) && RequiredInputs.Contains(c);
|
return (sender is Control c) && RequiredInputs.Contains(c);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected void FinishInputFilling() {
|
||||||
|
FillOriginalValues();
|
||||||
|
ValidateDefaultValues();
|
||||||
|
ValidateRequiredInputs();
|
||||||
|
}
|
||||||
|
|
||||||
protected void ClearInputStates() {
|
protected void ClearInputStates() {
|
||||||
foreach (var tb in TextBoxInputs)
|
foreach (var tb in TextBoxInputs)
|
||||||
ControlUtils.ClearInputState(tb);
|
ControlUtils.ClearInputState(tb);
|
||||||
@@ -121,15 +129,28 @@ namespace Elwig.Windows {
|
|||||||
Valid[input] = false;
|
Valid[input] = false;
|
||||||
} else if (input is ComboBox cb && cb.SelectedItem == null && cb.ItemsSource != null) {
|
} else if (input is ComboBox cb && cb.SelectedItem == null && cb.ItemsSource != null) {
|
||||||
ControlUtils.SetInputInvalid(input);
|
ControlUtils.SetInputInvalid(input);
|
||||||
|
} else if (input is CheckComboBox ccb && ccb.SelectedItem == null && ccb.ItemsSource != null) {
|
||||||
|
ControlUtils.SetInputInvalid(input);
|
||||||
|
} else if (input is CheckBox ckb && ckb.IsChecked != true) {
|
||||||
|
ControlUtils.SetInputInvalid(input);
|
||||||
|
Valid[input] = false;
|
||||||
|
} else if (input is RadioButton rb && rb.IsChecked != true) {
|
||||||
|
ControlUtils.SetInputInvalid(input);
|
||||||
|
Valid[input] = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void LockInputs() {
|
protected void ValidateDefaultValues() {
|
||||||
foreach (var tb in TextBoxInputs) {
|
foreach (var input in DefaultValues.Keys) {
|
||||||
tb.IsReadOnly = true;
|
if (InputIsNotDefault(input))
|
||||||
tb.Focusable = false;
|
ControlUtils.SetInputNotDefault(input);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void LockInputs() {
|
||||||
|
foreach (var tb in TextBoxInputs)
|
||||||
|
tb.IsReadOnly = true;
|
||||||
foreach (var cb in ComboBoxInputs)
|
foreach (var cb in ComboBoxInputs)
|
||||||
cb.IsEnabled = false;
|
cb.IsEnabled = false;
|
||||||
foreach (var ccb in CheckComboBoxInputs)
|
foreach (var ccb in CheckComboBoxInputs)
|
||||||
@@ -141,10 +162,8 @@ namespace Elwig.Windows {
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected void UnlockInputs() {
|
protected void UnlockInputs() {
|
||||||
foreach (var tb in TextBoxInputs) {
|
foreach (var tb in TextBoxInputs)
|
||||||
tb.IsReadOnly = false;
|
tb.IsReadOnly = false;
|
||||||
tb.Focusable = true;
|
|
||||||
}
|
|
||||||
foreach (var cb in ComboBoxInputs)
|
foreach (var cb in ComboBoxInputs)
|
||||||
cb.IsEnabled = true;
|
cb.IsEnabled = true;
|
||||||
foreach (var ccb in CheckComboBoxInputs)
|
foreach (var ccb in CheckComboBoxInputs)
|
||||||
@@ -159,6 +178,10 @@ namespace Elwig.Windows {
|
|||||||
OriginalValues.Clear();
|
OriginalValues.Clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected void ClearDefaultValues() {
|
||||||
|
DefaultValues.Clear();
|
||||||
|
}
|
||||||
|
|
||||||
protected void FillOriginalValues() {
|
protected void FillOriginalValues() {
|
||||||
foreach (var tb in TextBoxInputs)
|
foreach (var tb in TextBoxInputs)
|
||||||
OriginalValues[tb] = tb.Text;
|
OriginalValues[tb] = tb.Text;
|
||||||
@@ -167,17 +190,49 @@ namespace Elwig.Windows {
|
|||||||
foreach (var ccb in CheckComboBoxInputs)
|
foreach (var ccb in CheckComboBoxInputs)
|
||||||
OriginalValues[ccb] = ccb.SelectedItems.Cast<object>().ToArray();
|
OriginalValues[ccb] = ccb.SelectedItems.Cast<object>().ToArray();
|
||||||
foreach (var cb in CheckBoxInputs)
|
foreach (var cb in CheckBoxInputs)
|
||||||
OriginalValues[cb] = (cb.IsChecked ?? false) ? bool.TrueString : null;
|
OriginalValues[cb] = cb.IsChecked?.ToString();
|
||||||
foreach (var rb in RadioButtonInputs)
|
foreach (var rb in RadioButtonInputs)
|
||||||
OriginalValues[rb] = (rb.IsChecked ?? false) ? bool.TrueString : null;
|
OriginalValues[rb] = rb.IsChecked?.ToString();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void SetOriginalValue(Control input, object? value) {
|
protected void SetOriginalValue(Control input, object? value) {
|
||||||
OriginalValues[input] = value;
|
OriginalValues[input] = value is bool b ? b.ToString() : value;
|
||||||
|
if (InputHasChanged(input)) {
|
||||||
|
ControlUtils.SetInputChanged(input);
|
||||||
|
} else {
|
||||||
|
ControlUtils.ClearInputState(input);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void SetOriginalValue(Control input) {
|
||||||
|
SetOriginalValue(input, ControlUtils.GetInputValue(input));
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void UnsetOriginalValue(Control input) {
|
protected void UnsetOriginalValue(Control input) {
|
||||||
OriginalValues.Remove(input);
|
OriginalValues.Remove(input);
|
||||||
|
ControlUtils.ClearInputState(input);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void SetDefaultValue(Control input, object? value) {
|
||||||
|
DefaultValues[input] = value is bool b ? b.ToString() : value;
|
||||||
|
if (!InputHasChanged(input)) {
|
||||||
|
if (InputIsNotDefault(input)) {
|
||||||
|
ControlUtils.SetInputNotDefault(input);
|
||||||
|
} else {
|
||||||
|
ControlUtils.ClearInputState(input);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void SetDefaultValue(Control input) {
|
||||||
|
SetDefaultValue(input, ControlUtils.GetInputValue(input));
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void UnsetDefaultValue(Control input) {
|
||||||
|
DefaultValues.Remove(input);
|
||||||
|
if (!InputHasChanged(input)) {
|
||||||
|
ControlUtils.ClearInputState(input);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void ClearInputs(bool validate = true) {
|
protected void ClearInputs(bool validate = true) {
|
||||||
@@ -210,9 +265,27 @@ namespace Elwig.Windows {
|
|||||||
} else if (input is CheckComboBox ccb) {
|
} else if (input is CheckComboBox ccb) {
|
||||||
return !ccb.SelectedItems.Cast<object>().ToArray().SequenceEqual(((object[]?)OriginalValues[ccb]) ?? Array.Empty<object>());
|
return !ccb.SelectedItems.Cast<object>().ToArray().SequenceEqual(((object[]?)OriginalValues[ccb]) ?? Array.Empty<object>());
|
||||||
} else if (input is CheckBox cb) {
|
} else if (input is CheckBox cb) {
|
||||||
return (OriginalValues[cb] != null) != (cb.IsChecked ?? false);
|
return (string?)OriginalValues[cb] != cb.IsChecked?.ToString();
|
||||||
} else if (input is RadioButton rb) {
|
} else if (input is RadioButton rb) {
|
||||||
return (OriginalValues[rb] != null) != (rb.IsChecked ?? false);
|
return (string?)OriginalValues[rb] != rb.IsChecked?.ToString();
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected bool InputIsNotDefault(Control input) {
|
||||||
|
if (!DefaultValues.ContainsKey(input)) {
|
||||||
|
return false;
|
||||||
|
} else if (input is TextBox tb) {
|
||||||
|
return DefaultValues[tb]?.ToString() != tb.Text;
|
||||||
|
} else if (input is ComboBox sb) {
|
||||||
|
return DefaultValues[sb] != sb.SelectedItem;
|
||||||
|
} else if (input is CheckComboBox ccb) {
|
||||||
|
return !ccb.SelectedItems.Cast<object>().ToArray().SequenceEqual(((object[]?)DefaultValues[ccb]) ?? Array.Empty<object>());
|
||||||
|
} else if (input is CheckBox cb) {
|
||||||
|
return (string?)DefaultValues[cb] != cb.IsChecked?.ToString();
|
||||||
|
} else if (input is RadioButton rb) {
|
||||||
|
return (string?)DefaultValues[rb] != rb.IsChecked?.ToString();
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -269,6 +342,8 @@ namespace Elwig.Windows {
|
|||||||
if (res.IsValid) {
|
if (res.IsValid) {
|
||||||
if (InputHasChanged(input)) {
|
if (InputHasChanged(input)) {
|
||||||
ControlUtils.SetInputChanged(input);
|
ControlUtils.SetInputChanged(input);
|
||||||
|
} else if (InputIsNotDefault(input)) {
|
||||||
|
ControlUtils.SetInputNotDefault(input);
|
||||||
} else {
|
} else {
|
||||||
ControlUtils.ClearInputState(input);
|
ControlUtils.ClearInputState(input);
|
||||||
}
|
}
|
||||||
@@ -288,7 +363,7 @@ namespace Elwig.Windows {
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected bool InputLostFocus(TextBox input, ValidationResult res, string? msg = null) {
|
protected bool InputLostFocus(TextBox input, ValidationResult res, string? msg = null) {
|
||||||
if (!res.IsValid && !IsClosing)
|
if (!res.IsValid && !IsClosing && (IsEditing || IsCreating))
|
||||||
System.Windows.MessageBox.Show(res.ErrorContent.ToString(), msg ?? res.ErrorContent.ToString(), MessageBoxButton.OK, MessageBoxImage.Warning);
|
System.Windows.MessageBox.Show(res.ErrorContent.ToString(), msg ?? res.ErrorContent.ToString(), MessageBoxButton.OK, MessageBoxImage.Warning);
|
||||||
return res.IsValid;
|
return res.IsValid;
|
||||||
}
|
}
|
||||||
@@ -299,6 +374,8 @@ namespace Elwig.Windows {
|
|||||||
ControlUtils.SetInputInvalid(input);
|
ControlUtils.SetInputInvalid(input);
|
||||||
} else if (InputHasChanged(input)) {
|
} else if (InputHasChanged(input)) {
|
||||||
ControlUtils.SetInputChanged(input);
|
ControlUtils.SetInputChanged(input);
|
||||||
|
} else if (InputIsNotDefault(input)) {
|
||||||
|
ControlUtils.SetInputNotDefault(input);
|
||||||
} else {
|
} else {
|
||||||
ControlUtils.ClearInputState(input);
|
ControlUtils.ClearInputState(input);
|
||||||
}
|
}
|
||||||
@@ -311,6 +388,8 @@ namespace Elwig.Windows {
|
|||||||
ControlUtils.SetInputInvalid(input);
|
ControlUtils.SetInputInvalid(input);
|
||||||
} else if (InputHasChanged(input)) {
|
} else if (InputHasChanged(input)) {
|
||||||
ControlUtils.SetInputChanged(input);
|
ControlUtils.SetInputChanged(input);
|
||||||
|
} else if (InputIsNotDefault(input)) {
|
||||||
|
ControlUtils.SetInputNotDefault(input);
|
||||||
} else {
|
} else {
|
||||||
ControlUtils.ClearInputState(input);
|
ControlUtils.ClearInputState(input);
|
||||||
}
|
}
|
||||||
@@ -326,6 +405,8 @@ namespace Elwig.Windows {
|
|||||||
ValidateInput(input, true);
|
ValidateInput(input, true);
|
||||||
if (InputHasChanged(input)) {
|
if (InputHasChanged(input)) {
|
||||||
ControlUtils.SetInputChanged(input);
|
ControlUtils.SetInputChanged(input);
|
||||||
|
} else if (InputIsNotDefault(input)) {
|
||||||
|
ControlUtils.SetInputNotDefault(input);
|
||||||
} else {
|
} else {
|
||||||
ControlUtils.ClearInputState(input);
|
ControlUtils.ClearInputState(input);
|
||||||
}
|
}
|
||||||
@@ -344,6 +425,8 @@ namespace Elwig.Windows {
|
|||||||
ValidateInput(input, true);
|
ValidateInput(input, true);
|
||||||
if (InputHasChanged(input)) {
|
if (InputHasChanged(input)) {
|
||||||
ControlUtils.SetInputChanged(input);
|
ControlUtils.SetInputChanged(input);
|
||||||
|
} else if (InputIsNotDefault(input)) {
|
||||||
|
ControlUtils.SetInputNotDefault(input);
|
||||||
} else {
|
} else {
|
||||||
ControlUtils.ClearInputState(input);
|
ControlUtils.ClearInputState(input);
|
||||||
}
|
}
|
||||||
@@ -381,20 +464,22 @@ namespace Elwig.Windows {
|
|||||||
protected void PlzInput_TextChanged(object sender, RoutedEventArgs evt) {
|
protected void PlzInput_TextChanged(object sender, RoutedEventArgs evt) {
|
||||||
var plz = (TextBox)sender;
|
var plz = (TextBox)sender;
|
||||||
InputTextChanged(plz, Validator.CheckPlz);
|
InputTextChanged(plz, Validator.CheckPlz);
|
||||||
UpdatePlz(plz, GetPlzOrtInput(plz));
|
if ("PLZ".Equals(plz.Tag))
|
||||||
|
UpdatePlz(plz, GetPlzOrtInput(plz));
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void PlzInput_LostFocus(object sender, RoutedEventArgs evt) {
|
protected void PlzInput_LostFocus(object sender, RoutedEventArgs evt) {
|
||||||
var plz = (TextBox)sender;
|
var plz = (TextBox)sender;
|
||||||
InputLostFocus(plz, Validator.CheckPlz);
|
InputLostFocus(plz, Validator.CheckPlz);
|
||||||
UpdatePlz(plz, GetPlzOrtInput(plz));
|
if ("PLZ".Equals(plz.Tag))
|
||||||
|
UpdatePlz(plz, GetPlzOrtInput(plz));
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void EmailInput_TextChanged(object sender, RoutedEventArgs evt) {
|
protected void EmailAddressInput_TextChanged(object sender, RoutedEventArgs evt) {
|
||||||
InputTextChanged((TextBox)sender, Validator.CheckEmailAddress);
|
InputTextChanged((TextBox)sender, Validator.CheckEmailAddress);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void EmailInput_LostFocus(object sender, RoutedEventArgs evt) {
|
protected void EmailAddressInput_LostFocus(object sender, RoutedEventArgs evt) {
|
||||||
InputLostFocus((TextBox)sender, Validator.CheckEmailAddress);
|
InputLostFocus((TextBox)sender, Validator.CheckEmailAddress);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -47,9 +47,8 @@
|
|||||||
<Grid>
|
<Grid>
|
||||||
<Grid.RowDefinitions>
|
<Grid.RowDefinitions>
|
||||||
<RowDefinition Height="19"/>
|
<RowDefinition Height="19"/>
|
||||||
<RowDefinition Height="110"/>
|
<RowDefinition Height="*"/>
|
||||||
<RowDefinition Height="175"/>
|
<RowDefinition Height="*"/>
|
||||||
<RowDefinition Height="1*"/>
|
|
||||||
</Grid.RowDefinitions>
|
</Grid.RowDefinitions>
|
||||||
<Grid.ColumnDefinitions>
|
<Grid.ColumnDefinitions>
|
||||||
<ColumnDefinition Width="*"/>
|
<ColumnDefinition Width="*"/>
|
||||||
@@ -60,7 +59,7 @@
|
|||||||
<MenuItem Header="Flächenbindugen"/>
|
<MenuItem Header="Flächenbindugen"/>
|
||||||
</Menu>
|
</Menu>
|
||||||
|
|
||||||
<Grid Grid.RowSpan="3" Grid.Row="1" Grid.Column="0">
|
<Grid Grid.RowSpan="2" Grid.Row="1" Grid.Column="0">
|
||||||
<Grid.ColumnDefinitions>
|
<Grid.ColumnDefinitions>
|
||||||
<ColumnDefinition Width="1*"/>
|
<ColumnDefinition Width="1*"/>
|
||||||
<ColumnDefinition Width="1*"/>
|
<ColumnDefinition Width="1*"/>
|
||||||
@@ -69,38 +68,44 @@
|
|||||||
|
|
||||||
<DataGrid x:Name="AreaCommitmentList" AutoGenerateColumns="False" HeadersVisibility="Column" IsReadOnly="True" GridLinesVisibility="None" SelectionMode="Single"
|
<DataGrid x:Name="AreaCommitmentList" AutoGenerateColumns="False" HeadersVisibility="Column" IsReadOnly="True" GridLinesVisibility="None" SelectionMode="Single"
|
||||||
CanUserDeleteRows="False" CanUserResizeRows="False" CanUserAddRows="False" SelectionChanged="AreaCommitmentList_SelectionChanged" Grid.Column="0" Grid.Row="1"
|
CanUserDeleteRows="False" CanUserResizeRows="False" CanUserAddRows="False" SelectionChanged="AreaCommitmentList_SelectionChanged" Grid.Column="0" Grid.Row="1"
|
||||||
Margin="5,10,5,47" FontSize="14" Grid.ColumnSpan="3" Background="#e2e2e2">
|
Margin="5,10,5,42" FontSize="14" Grid.ColumnSpan="3" Background="#e2e2e2">
|
||||||
<DataGrid.Columns>
|
<DataGrid.Columns>
|
||||||
<DataGridTextColumn Header="FbNr" Binding="{Binding FbNr}" Width="2*"/>
|
<DataGridTextColumn Header="FbNr." Binding="{Binding FbNr}" Width="2*"/>
|
||||||
<DataGridTextColumn Header="Katastralgemeinde" Binding="{Binding Kg.AtKg.Name}" Width="6*"/>
|
<DataGridTextColumn Header="Katastralgemeinde" Binding="{Binding Kg.AtKg.Name}" Width="6*"/>
|
||||||
<DataGridTextColumn Header="Ried" Binding="{Binding Rd.Name}" Width="4*"/>
|
<DataGridTextColumn Header="Ried" Binding="{Binding Rd.Name}" Width="4*"/>
|
||||||
<DataGridTextColumn Header="Parzelle" Binding="{Binding GstNr}" Width="4*"/>
|
<DataGridTextColumn Header="Parzelle" Binding="{Binding GstNr}" Width="4*"/>
|
||||||
<DataGridTextColumn Header="Fläche (m²)" Binding="{Binding Area}" Width="4*"/>
|
<DataGridTextColumn Header="Fläche" Binding="{Binding Area, StringFormat='{}{0:N0} m²'}" Width="4*">
|
||||||
|
<DataGridTextColumn.CellStyle>
|
||||||
|
<Style>
|
||||||
|
<Setter Property="TextBlock.TextAlignment" Value="Right"/>
|
||||||
|
</Style>
|
||||||
|
</DataGridTextColumn.CellStyle>
|
||||||
|
</DataGridTextColumn>
|
||||||
</DataGrid.Columns>
|
</DataGrid.Columns>
|
||||||
</DataGrid>
|
</DataGrid>
|
||||||
|
|
||||||
<Button x:Name="NewAreaCommitmentButton" Content="Neu" Click="NewAreaCommitmentButton_Click"
|
<Button x:Name="NewAreaCommitmentButton" Content="Neu" Click="NewAreaCommitmentButton_Click"
|
||||||
HorizontalAlignment="Stretch" VerticalAlignment="Bottom" Margin="5,10,5,10" Grid.Column="0"/>
|
HorizontalAlignment="Stretch" VerticalAlignment="Bottom" Margin="5,5,2.5,10" Grid.Column="0"/>
|
||||||
<Button x:Name="EditAreaCommitmentButton" Content="Bearbeiten" Click="EditAreaCommitmentButton_Click" IsEnabled="False"
|
<Button x:Name="EditAreaCommitmentButton" Content="Bearbeiten" Click="EditAreaCommitmentButton_Click" IsEnabled="False"
|
||||||
HorizontalAlignment="Stretch" VerticalAlignment="Bottom" Margin="5,10,5,10" Grid.Column="1"/>
|
HorizontalAlignment="Stretch" VerticalAlignment="Bottom" Margin="2.5,5,2.5,10" Grid.Column="1"/>
|
||||||
<Button x:Name="DeleteAreaCommitmentButton" Content="Löschen" Click="DeleteAreaCommitmentButton_Click" IsEnabled="False"
|
<Button x:Name="DeleteAreaCommitmentButton" Content="Löschen" Click="DeleteAreaCommitmentButton_Click" IsEnabled="False"
|
||||||
HorizontalAlignment="Stretch" VerticalAlignment="Bottom" Margin="5,10,5,10" Grid.Column="2"/>
|
HorizontalAlignment="Stretch" VerticalAlignment="Bottom" Margin="2.5,5,5,10" Grid.Column="2"/>
|
||||||
|
|
||||||
<Button x:Name="AreaCommitmentSaveButton" Content="Speichern" Click="AreaCommitmentSaveButton_Click" IsEnabled="False" Visibility="Hidden"
|
<Button x:Name="AreaCommitmentSaveButton" Content="Speichern" Click="AreaCommitmentSaveButton_Click" IsEnabled="False" Visibility="Hidden"
|
||||||
HorizontalAlignment="Stretch" VerticalAlignment="Bottom" Margin="5,10,5,10" Grid.Column="0"/>
|
HorizontalAlignment="Stretch" VerticalAlignment="Bottom" Margin="5,5,2.5,10" Grid.Column="0"/>
|
||||||
<Button x:Name="AreaCommitmentResetButton" Content="Zurücksetzen" Click="AreaCommitmentResetButton_Click" IsEnabled="False" Visibility="Hidden"
|
<Button x:Name="AreaCommitmentResetButton" Content="Zurücksetzen" Click="AreaCommitmentResetButton_Click" IsEnabled="False" Visibility="Hidden"
|
||||||
HorizontalAlignment="Stretch" VerticalAlignment="Bottom" Margin="5,10,5,10" Grid.Column="1"/>
|
HorizontalAlignment="Stretch" VerticalAlignment="Bottom" Margin="2.5,5,2.5,10" Grid.Column="1"/>
|
||||||
<Button x:Name="AreaCommitmentCancelButton" Content="Abbrechen" Click="AreaCommitmentCancelButton_Click" IsEnabled="False" Visibility="Hidden" IsCancel="True"
|
<Button x:Name="AreaCommitmentCancelButton" Content="Abbrechen" Click="AreaCommitmentCancelButton_Click" IsEnabled="False" Visibility="Hidden" IsCancel="True"
|
||||||
HorizontalAlignment="Stretch" VerticalAlignment="Bottom" Margin="5,10,5,10" Grid.Column="2"/>
|
HorizontalAlignment="Stretch" VerticalAlignment="Bottom" Margin="2.5,5,5,10" Grid.Column="2"/>
|
||||||
</Grid>
|
</Grid>
|
||||||
|
|
||||||
<GroupBox Header="Vertrag" Grid.Column="2" Grid.Row="1" Grid.RowSpan="1" Margin="5,5,5,5">
|
<GroupBox Header="Vertrag" Grid.Column="2" Grid.Row="1" Grid.RowSpan="1" Margin="5,5,5,5">
|
||||||
<Grid>
|
<Grid>
|
||||||
<Grid.ColumnDefinitions>
|
<Grid.ColumnDefinitions>
|
||||||
<ColumnDefinition Width="60"/>
|
<ColumnDefinition Width="80"/>
|
||||||
<ColumnDefinition Width="70"/>
|
<ColumnDefinition Width="*"/>
|
||||||
<ColumnDefinition Width="50"/>
|
<ColumnDefinition Width="50"/>
|
||||||
<ColumnDefinition Width="100"/>
|
<ColumnDefinition Width="*"/>
|
||||||
</Grid.ColumnDefinitions>
|
</Grid.ColumnDefinitions>
|
||||||
|
|
||||||
<Label Content="FbNr.:" Margin="10,10,0,0" Grid.Column="0"/>
|
<Label Content="FbNr.:" Margin="10,10,0,0" Grid.Column="0"/>
|
||||||
@@ -108,67 +113,51 @@
|
|||||||
TextChanged="FbNrInput_TextChanged" LostFocus="FbNrInput_LostFocus"/>
|
TextChanged="FbNrInput_TextChanged" LostFocus="FbNrInput_LostFocus"/>
|
||||||
|
|
||||||
<Label Content="MgNr.:" Margin="10,40,0,0" Grid.Column="0"/>
|
<Label Content="MgNr.:" Margin="10,40,0,0" Grid.Column="0"/>
|
||||||
<TextBox x:Name="MgNrInput" Margin="0,40,0,0" Width="48" Grid.Column="1" TextAlignment="Right" HorizontalAlignment="Left"/>
|
<TextBox x:Name="MgNrInput" IsEnabled="False"
|
||||||
|
Margin="0,40,0,0" Width="48" Grid.Column="1" TextAlignment="Right" HorizontalAlignment="Left"/>
|
||||||
|
|
||||||
<Label Content="Von:" Margin="10,10,0,0" Grid.Column="2"/>
|
<Label Content="Von:" Margin="10,10,0,0" Grid.Column="2"/>
|
||||||
<TextBox x:Name="YearFromInput" Margin="0,10,0,0" Width="100" Grid.Column="3" TextAlignment="Right" HorizontalAlignment="Left"
|
<TextBox x:Name="YearFromInput" Margin="0,10,0,0" Width="41" Grid.Column="3" TextAlignment="Right" HorizontalAlignment="Left"
|
||||||
TextChanged="IntegerInput_TextChanged"/>
|
TextChanged="IntegerInput_TextChanged"/>
|
||||||
|
|
||||||
<Label Content="Bis:" Margin="10,40,0,0" Grid.Column="2"/>
|
<Label Content="Bis:" Margin="10,40,0,0" Grid.Column="2"/>
|
||||||
<TextBox x:Name="YearToInput" Margin="0,40,0,0" Width="100" Grid.Column="3" TextAlignment="Right" HorizontalAlignment="Left"
|
<TextBox x:Name="YearToInput" Margin="0,40,0,0" Width="41" Grid.Column="3" TextAlignment="Right" HorizontalAlignment="Left"
|
||||||
TextChanged="IntegerInput_TextChanged"/>
|
TextChanged="IntegerInput_TextChanged"/>
|
||||||
|
|
||||||
|
<Label Content="Vertragsart:" Margin="10,70,0,0" Grid.Column="0" Grid.ColumnSpan="2"/>
|
||||||
|
<ComboBox x:Name="AreaComTypeInput" DisplayMemberPath="DisplayName" TextSearch.TextPath="DisplayName"
|
||||||
|
HorizontalAlignment="Stretch" Margin="0,70,10,0" Grid.Column="1" Grid.ColumnSpan="3"/>
|
||||||
|
|
||||||
|
<Label Content="Bewirt.-Art:" Margin="10,100,0,0" Grid.Column="0" Grid.ColumnSpan="2"/>
|
||||||
|
<ComboBox x:Name="WineCultivationInput" DisplayMemberPath="Name" TextSearch.TextPath="Name"
|
||||||
|
HorizontalAlignment="Stretch" Margin="0,100,10,0" Grid.Column="1" Grid.ColumnSpan="3"/>
|
||||||
</Grid>
|
</Grid>
|
||||||
</GroupBox>
|
</GroupBox>
|
||||||
|
|
||||||
<GroupBox Header="Lage" Grid.Column="2" Grid.Row="2" Grid.RowSpan="1" Margin="5,5,5,5">
|
<GroupBox Header="Lage" Grid.Column="2" Grid.Row="2" Grid.RowSpan="1" Margin="5,5,5,10">
|
||||||
<Grid>
|
<Grid>
|
||||||
<Grid.ColumnDefinitions>
|
<Grid.ColumnDefinitions>
|
||||||
<ColumnDefinition Width="80"/>
|
<ColumnDefinition Width="80"/>
|
||||||
<ColumnDefinition Width="*"/>
|
<ColumnDefinition Width="*"/>
|
||||||
</Grid.ColumnDefinitions>
|
</Grid.ColumnDefinitions>
|
||||||
|
|
||||||
<Label Content="Gemeinde:" Margin="10,10,0,0" Grid.Column="0"/>
|
<Label Content="KG:" Margin="10,10,0,0" Grid.Column="0"/>
|
||||||
<ComboBox x:Name="KgInput" ItemTemplate="{StaticResource KgNrTemplate}" TextSearch.TextPath="Name"
|
<ComboBox x:Name="KgInput" ItemTemplate="{StaticResource KgNrTemplate}" TextSearch.TextPath="Name"
|
||||||
Width="200" HorizontalAlignment="Left" SelectionChanged="KgInput_SelectionChanged"
|
HorizontalAlignment="Stretch" Margin="0,10,10,0" Grid.Column="1"
|
||||||
Margin="0,10,10,0" Grid.Column="1"/>
|
SelectionChanged="KgInput_SelectionChanged"/>
|
||||||
|
|
||||||
<Label Content="Ried:" Margin="10,40,0,0" Grid.Column="0"/>
|
<Label Content="Ried:" Margin="10,40,0,0" Grid.Column="0"/>
|
||||||
<ComboBox x:Name="RdInput" DisplayMemberPath="Name" TextSearch.TextPath="Name"
|
<ComboBox x:Name="RdInput" DisplayMemberPath="Name" TextSearch.TextPath="Name"
|
||||||
Width="200" HorizontalAlignment="Left"
|
HorizontalAlignment="Stretch" Margin="0,40,10,0" Grid.Column="1"/>
|
||||||
Margin="0,40,0,0" Grid.Column="1"/>
|
|
||||||
|
|
||||||
<Label Content="Parzelle:" Margin="10,70,0,0" Grid.Column="0"/>
|
<Label Content="Parzelle(n):" Margin="10,70,0,0" Grid.Column="0"/>
|
||||||
<TextBox x:Name="GstNrInput" Margin="0,70,0,0" Width="200" Grid.Column="1" TextAlignment="Right" HorizontalAlignment="Left"
|
<TextBox x:Name="GstNrInput" Margin="0,70,10,0" Grid.Column="1" HorizontalAlignment="Stretch"
|
||||||
TextChanged="GstNrInput_TextChanged" LostFocus="GstNrInput_LostFocus"/>
|
TextChanged="GstNrInput_TextChanged" LostFocus="GstNrInput_LostFocus"/>
|
||||||
|
|
||||||
<Label Content="Fläche (m²):" Margin="10,100,0,0" Grid.Column="0"/>
|
<Label Content="Fläche:" Margin="10,100,0,0" Grid.Column="0"/>
|
||||||
<TextBox x:Name="AreaInput" Margin="0,100,0,0" Width="100" Grid.Column="1" TextAlignment="Right" HorizontalAlignment="Left"
|
<TextBox x:Name="AreaInput" Margin="0,100,0,0" Width="100" Grid.Column="1" TextAlignment="Right" HorizontalAlignment="Left"
|
||||||
TextChanged="IntegerInput_TextChanged"/>
|
TextChanged="IntegerInput_TextChanged"/>
|
||||||
</Grid>
|
</Grid>
|
||||||
|
|
||||||
</GroupBox>
|
|
||||||
|
|
||||||
<GroupBox Header="Eigenschaften" Grid.Column="2" Grid.Row="3" Grid.RowSpan="1" Margin="5,5,5,5">
|
|
||||||
<Grid>
|
|
||||||
<Grid.ColumnDefinitions>
|
|
||||||
<ColumnDefinition Width="80"/>
|
|
||||||
<ColumnDefinition Width="*"/>
|
|
||||||
</Grid.ColumnDefinitions>
|
|
||||||
|
|
||||||
<Label Content="Sorte:" Margin="10,10,0,0" Grid.Column="0"/>
|
|
||||||
<ComboBox x:Name="WineVarietyInput" ItemTemplate="{StaticResource WineVarietyTemplate}" TextSearch.TextPath="Name"
|
|
||||||
Width="200" HorizontalAlignment="Left"
|
|
||||||
Margin="0,10,10,0" Grid.Column="1"/>
|
|
||||||
|
|
||||||
<Label Content="Attribute:" Margin="10,40,0,0" Grid.Column="0"/>
|
|
||||||
<xctk:CheckComboBox x:Name="AttributesInput" Grid.Column="1" Margin="0,40,0,0" IsEnabled="False"
|
|
||||||
ItemTemplate="{StaticResource WineAttributeTemplate}" Delimiter=", " AllItemsSelectedContent="Alle"
|
|
||||||
Width="200" HorizontalAlignment="Left" ItemSelectionChanged="AttributesInput_SelectionChanged"/>
|
|
||||||
|
|
||||||
<Label Content="Bewirt. Art:" Margin="10,70,0,0" Grid.Column="0"/>
|
|
||||||
<ComboBox x:Name="WineCultivationInput" DisplayMemberPath="Name" TextSearch.TextPath="Name"
|
|
||||||
Width="200" HorizontalAlignment="Left" Margin="0,70,10,0" Grid.Column="1"/>
|
|
||||||
</Grid>
|
|
||||||
</GroupBox>
|
</GroupBox>
|
||||||
</Grid>
|
</Grid>
|
||||||
</local:AdministrationWindow>
|
</local:AdministrationWindow>
|
||||||
|
@@ -25,12 +25,12 @@ namespace Elwig.Windows {
|
|||||||
};
|
};
|
||||||
RequiredInputs = new Control[] {
|
RequiredInputs = new Control[] {
|
||||||
FbNrInput, YearFromInput, KgInput,
|
FbNrInput, YearFromInput, KgInput,
|
||||||
GstNrInput, AreaInput, WineVarietyInput, WineCultivationInput
|
GstNrInput, AreaInput, AreaComTypeInput, WineCultivationInput
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
private async void Window_Loaded(object sender, RoutedEventArgs e) {
|
private void Window_Loaded(object sender, RoutedEventArgs e) {
|
||||||
await RenewContext();
|
LockInputs();
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task RefreshAreaCommitmentList() {
|
private async Task RefreshAreaCommitmentList() {
|
||||||
@@ -50,9 +50,7 @@ namespace Elwig.Windows {
|
|||||||
|
|
||||||
private void RefreshInputs(bool validate = false) {
|
private void RefreshInputs(bool validate = false) {
|
||||||
ClearInputStates();
|
ClearInputStates();
|
||||||
AreaCom? a = (AreaCom)AreaCommitmentList.SelectedItem;
|
if (AreaCommitmentList.SelectedItem is AreaCom a) {
|
||||||
|
|
||||||
if (a != null) {
|
|
||||||
EditAreaCommitmentButton.IsEnabled = true;
|
EditAreaCommitmentButton.IsEnabled = true;
|
||||||
DeleteAreaCommitmentButton.IsEnabled = true;
|
DeleteAreaCommitmentButton.IsEnabled = true;
|
||||||
FillInputs(a);
|
FillInputs(a);
|
||||||
@@ -60,16 +58,16 @@ namespace Elwig.Windows {
|
|||||||
EditAreaCommitmentButton.IsEnabled = false;
|
EditAreaCommitmentButton.IsEnabled = false;
|
||||||
DeleteAreaCommitmentButton.IsEnabled = false;
|
DeleteAreaCommitmentButton.IsEnabled = false;
|
||||||
ClearOriginalValues();
|
ClearOriginalValues();
|
||||||
ClearInputs();
|
ClearDefaultValues();
|
||||||
AttributesInput.UnSelectAll();
|
ClearInputs(validate);
|
||||||
MgNrInput.Text = "";
|
ClearInputStates();
|
||||||
}
|
}
|
||||||
if (!validate) ClearInputStates();
|
|
||||||
GC.Collect();
|
GC.Collect();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void FillInputs(AreaCom a) {
|
private void FillInputs(AreaCom a) {
|
||||||
ClearOriginalValues();
|
ClearOriginalValues();
|
||||||
|
ClearDefaultValues();
|
||||||
|
|
||||||
FbNrInput.Text = a.FbNr.ToString();
|
FbNrInput.Text = a.FbNr.ToString();
|
||||||
MgNrInput.Text = a.MgNr.ToString();
|
MgNrInput.Text = a.MgNr.ToString();
|
||||||
@@ -81,30 +79,27 @@ namespace Elwig.Windows {
|
|||||||
GstNrInput.Text = a.GstNr;
|
GstNrInput.Text = a.GstNr;
|
||||||
AreaInput.Text = a.Area.ToString();
|
AreaInput.Text = a.Area.ToString();
|
||||||
|
|
||||||
WineVarietyInput.SelectedItem = a.WineVar;
|
AreaComTypeInput.SelectedItem = a.AreaComType;
|
||||||
|
|
||||||
AttributesInput.UnSelectAll();
|
|
||||||
foreach (var attr in a.Attributes) {
|
|
||||||
AttributesInput.SelectedItems.Add(attr);
|
|
||||||
}
|
|
||||||
|
|
||||||
WineCultivationInput.SelectedItem = a.WineCult;
|
WineCultivationInput.SelectedItem = a.WineCult;
|
||||||
|
|
||||||
FillOriginalValues();
|
FinishInputFilling();
|
||||||
}
|
}
|
||||||
|
|
||||||
private async void InitInputs() {
|
private async void InitInputs() {
|
||||||
|
ClearOriginalValues();
|
||||||
|
ClearDefaultValues();
|
||||||
|
|
||||||
FbNrInput.Text = (await Context.NextFbNr()).ToString();
|
FbNrInput.Text = (await Context.NextFbNr()).ToString();
|
||||||
MgNrInput.Text = Member.MgNr.ToString();
|
MgNrInput.Text = Member.MgNr.ToString();
|
||||||
FillOriginalValues();
|
|
||||||
|
SetDefaultValue(FbNrInput);
|
||||||
ValidateRequiredInputs();
|
ValidateRequiredInputs();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override async Task RenewContext() {
|
protected override async Task RenewContext() {
|
||||||
await base.RenewContext();
|
await base.RenewContext();
|
||||||
ControlUtils.RenewItemsSource(KgInput, await Context.WbKgs.Select(k => k.AtKg).OrderBy(k => k.Name).ToListAsync(), i => (i as AT_Kg)?.KgNr);
|
ControlUtils.RenewItemsSource(KgInput, await Context.WbKgs.Select(k => k.AtKg).OrderBy(k => k.Name).ToListAsync(), i => (i as AT_Kg)?.KgNr);
|
||||||
ControlUtils.RenewItemsSource(WineVarietyInput, await Context.WineVarieties.OrderBy(v => v.Name).ToListAsync(), i => (i as WineVar)?.SortId);
|
ControlUtils.RenewItemsSource(AreaComTypeInput, await Context.AreaCommitmentTypes.OrderBy(v => v.VtrgId).ToListAsync(), i => (i as AreaComType)?.VtrgId);
|
||||||
ControlUtils.RenewItemsSource(AttributesInput, await Context.WineAttributes.OrderBy(a => a.Name).ToListAsync(), i => (i as WineAttr)?.AttrId);
|
|
||||||
ControlUtils.RenewItemsSource(WineCultivationInput, await Context.WineCultivations.OrderBy(c => c.Name).ToListAsync(), i => (i as WineCult)?.CultId);
|
ControlUtils.RenewItemsSource(WineCultivationInput, await Context.WineCultivations.OrderBy(c => c.Name).ToListAsync(), i => (i as WineCult)?.CultId);
|
||||||
await RefreshAreaCommitmentList();
|
await RefreshAreaCommitmentList();
|
||||||
}
|
}
|
||||||
@@ -116,7 +111,6 @@ namespace Elwig.Windows {
|
|||||||
HideAreaCommitmentNewEditDeleteButtons();
|
HideAreaCommitmentNewEditDeleteButtons();
|
||||||
ShowAreaCommitmentSaveResetCancelButtons();
|
ShowAreaCommitmentSaveResetCancelButtons();
|
||||||
UnlockInputs();
|
UnlockInputs();
|
||||||
AttributesInput.IsEnabled = true;
|
|
||||||
InitInputs();
|
InitInputs();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -130,7 +124,6 @@ namespace Elwig.Windows {
|
|||||||
HideAreaCommitmentNewEditDeleteButtons();
|
HideAreaCommitmentNewEditDeleteButtons();
|
||||||
ShowAreaCommitmentSaveResetCancelButtons();
|
ShowAreaCommitmentSaveResetCancelButtons();
|
||||||
UnlockInputs();
|
UnlockInputs();
|
||||||
AttributesInput.IsEnabled = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private async void DeleteAreaCommitmentButton_Click(object sender, RoutedEventArgs evt) {
|
private async void DeleteAreaCommitmentButton_Click(object sender, RoutedEventArgs evt) {
|
||||||
@@ -139,7 +132,7 @@ namespace Elwig.Windows {
|
|||||||
|
|
||||||
var r = MessageBox.Show(
|
var r = MessageBox.Show(
|
||||||
$"Soll die Flächenbindung {a.GstNr} ({a.Area} m²) wirklich unwiderruflich gelöscht werden?",
|
$"Soll die Flächenbindung {a.GstNr} ({a.Area} m²) wirklich unwiderruflich gelöscht werden?",
|
||||||
"Parzelle löschen", MessageBoxButton.YesNo, MessageBoxImage.Warning, MessageBoxResult.No);
|
"Flächenbindung löschen", MessageBoxButton.YesNo, MessageBoxImage.Warning, MessageBoxResult.No);
|
||||||
if (r == MessageBoxResult.Yes) {
|
if (r == MessageBoxResult.Yes) {
|
||||||
Context.Remove(a);
|
Context.Remove(a);
|
||||||
Context.SaveChanges();
|
Context.SaveChanges();
|
||||||
@@ -156,8 +149,8 @@ namespace Elwig.Windows {
|
|||||||
a.RdNr = RdInput.SelectedItem.GetType() == typeof(NullItem) ? null : ((WbRd)RdInput.SelectedItem).RdNr;
|
a.RdNr = RdInput.SelectedItem.GetType() == typeof(NullItem) ? null : ((WbRd)RdInput.SelectedItem).RdNr;
|
||||||
a.GstNr = GstNrInput.Text;
|
a.GstNr = GstNrInput.Text;
|
||||||
a.Area = int.Parse(AreaInput.Text);
|
a.Area = int.Parse(AreaInput.Text);
|
||||||
a.SortId = ((WineVar)WineVarietyInput.SelectedItem).SortId;
|
a.VtrgId = (AreaComTypeInput.SelectedItem as AreaComType)?.VtrgId;
|
||||||
a.CultId = ((WineCult)WineCultivationInput.SelectedItem).CultId;
|
a.CultId = (WineCultivationInput.SelectedItem as WineCult)?.CultId;
|
||||||
|
|
||||||
EntityEntry<AreaCom>? tr = null;
|
EntityEntry<AreaCom>? tr = null;
|
||||||
try {
|
try {
|
||||||
@@ -166,35 +159,25 @@ namespace Elwig.Windows {
|
|||||||
} else if (IsCreating) {
|
} else if (IsCreating) {
|
||||||
a.FbNr = newFbNr;
|
a.FbNr = newFbNr;
|
||||||
tr = (await Context.AddAsync(a));
|
tr = (await Context.AddAsync(a));
|
||||||
}
|
} else {
|
||||||
|
throw new Exception();
|
||||||
|
|
||||||
foreach (WineAttr attr in a.Attributes) {
|
|
||||||
if (!AttributesInput.SelectedItems.Contains(attr)) {
|
|
||||||
var aca = a.AttributeEntries.FirstOrDefault(h => h.AttrId == attr.AttrId);
|
|
||||||
Context.Remove(aca);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach (WineAttr attr in AttributesInput.SelectedItems) {
|
|
||||||
if (!a.Attributes.Contains(attr)) {
|
|
||||||
AreaComAttr aca = Context.CreateProxy<AreaComAttr>();
|
|
||||||
aca.FbNr = a.FbNr;
|
|
||||||
aca.AttrId = attr.AttrId;
|
|
||||||
await Context.AddAsync(aca);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
await Context.SaveChangesAsync();
|
await Context.SaveChangesAsync();
|
||||||
|
|
||||||
if (newFbNr != a.FbNr) {
|
if (newFbNr != a.FbNr) {
|
||||||
await Context.Database.ExecuteSqlAsync($"UPDATE area_commitment SET fbnr = {newFbNr} WHERE fbnr = {a.FbNr}");
|
await Context.Database.ExecuteSqlAsync($"UPDATE area_commitment SET fbnr = {newFbNr} WHERE fbnr = {a.FbNr}");
|
||||||
await Context.Members.LoadAsync();
|
tr.State = EntityState.Detached;
|
||||||
|
await Context.SaveChangesAsync();
|
||||||
|
await tr.ReloadAsync();
|
||||||
a = await Context.AreaCommitments.FindAsync(newFbNr);
|
a = await Context.AreaCommitments.FindAsync(newFbNr);
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (Exception exc) {
|
} catch (Exception exc) {
|
||||||
if (tr != null) await tr.ReloadAsync();
|
if (tr != null) {
|
||||||
|
tr.State = EntityState.Detached;
|
||||||
|
await tr.ReloadAsync();
|
||||||
|
}
|
||||||
var str = "Der Eintrag konnte nicht in der Datenbank aktualisiert werden!\n\n" + exc.Message;
|
var str = "Der Eintrag konnte nicht in der Datenbank aktualisiert werden!\n\n" + exc.Message;
|
||||||
if (exc.InnerException != null) str += "\n\n" + exc.InnerException.Message;
|
if (exc.InnerException != null) str += "\n\n" + exc.InnerException.Message;
|
||||||
MessageBox.Show(str, "Flächenbindung aktualisieren", MessageBoxButton.OK, MessageBoxImage.Error);
|
MessageBox.Show(str, "Flächenbindung aktualisieren", MessageBoxButton.OK, MessageBoxImage.Error);
|
||||||
@@ -211,7 +194,6 @@ namespace Elwig.Windows {
|
|||||||
HideAreaCommitmentSaveResetCancelButtons();
|
HideAreaCommitmentSaveResetCancelButtons();
|
||||||
ShowAreaCommitmentNewEditDeleteButtons();
|
ShowAreaCommitmentNewEditDeleteButtons();
|
||||||
LockInputs();
|
LockInputs();
|
||||||
AttributesInput.IsEnabled = false;
|
|
||||||
await RefreshAreaCommitmentList();
|
await RefreshAreaCommitmentList();
|
||||||
AreaCommitmentList.SelectedItem = a;
|
AreaCommitmentList.SelectedItem = a;
|
||||||
}
|
}
|
||||||
@@ -234,7 +216,6 @@ namespace Elwig.Windows {
|
|||||||
RefreshInputs();
|
RefreshInputs();
|
||||||
ClearInputStates();
|
ClearInputStates();
|
||||||
LockInputs();
|
LockInputs();
|
||||||
AttributesInput.IsEnabled = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override protected void UpdateButtons() {
|
override protected void UpdateButtons() {
|
||||||
@@ -297,11 +278,13 @@ namespace Elwig.Windows {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private async void KgInput_SelectionChanged(object sender, SelectionChangedEventArgs evt) {
|
private async void KgInput_SelectionChanged(object sender, SelectionChangedEventArgs evt) {
|
||||||
AT_Kg? curr_kg = (AT_Kg)KgInput.SelectedItem;
|
if (KgInput.SelectedItem is AT_Kg curr_kg) {
|
||||||
if (curr_kg != null) {
|
|
||||||
var rdList = await Context.WbRde.Where(r => r.KgNr == curr_kg.KgNr).OrderBy(r => r.Name).Cast<object>().ToListAsync();
|
var rdList = await Context.WbRde.Where(r => r.KgNr == curr_kg.KgNr).OrderBy(r => r.Name).Cast<object>().ToListAsync();
|
||||||
rdList.Insert(0, new NullItem());
|
rdList.Insert(0, new NullItem());
|
||||||
ControlUtils.RenewItemsSource(RdInput, rdList, i => (i as WbRd)?.RdNr);
|
ControlUtils.RenewItemsSource(RdInput, rdList, i => (i as WbRd)?.RdNr);
|
||||||
|
} else {
|
||||||
|
var rdList = new object[] { new NullItem() };
|
||||||
|
ControlUtils.RenewItemsSource(RdInput, rdList, i => (i as WbRd)?.RdNr);
|
||||||
}
|
}
|
||||||
ComboBox_SelectionChanged(sender, evt);
|
ComboBox_SelectionChanged(sender, evt);
|
||||||
}
|
}
|
||||||
|
235
Elwig/Windows/BaseDataWindow.xaml
Normal file
235
Elwig/Windows/BaseDataWindow.xaml
Normal file
@@ -0,0 +1,235 @@
|
|||||||
|
<local:AdministrationWindow x:Class="Elwig.Windows.BaseDataWindow"
|
||||||
|
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"
|
||||||
|
mc:Ignorable="d"
|
||||||
|
Title="Stammdaten - Elwig" Height="500" MinHeight="400" Width="800" 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="Height" Value="25"/>
|
||||||
|
<Setter Property="TextWrapping" Value="NoWrap"/>
|
||||||
|
</Style>
|
||||||
|
<Style TargetType="ComboBox">
|
||||||
|
<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>
|
||||||
|
<TabControl Margin="10,10,10,42">
|
||||||
|
<TabItem Header="Mandant">
|
||||||
|
<Grid>
|
||||||
|
<Grid.ColumnDefinitions>
|
||||||
|
<ColumnDefinition Width="130"/>
|
||||||
|
<ColumnDefinition Width="*"/>
|
||||||
|
<ColumnDefinition Width="90"/>
|
||||||
|
<ColumnDefinition Width="*"/>
|
||||||
|
</Grid.ColumnDefinitions>
|
||||||
|
|
||||||
|
<Label Content="Vollständiger Name:"
|
||||||
|
VerticalAlignment="Top" HorizontalAlignment="Left" Grid.Column="0" Margin="10,10,0,10"/>
|
||||||
|
<TextBox x:Name="ClientNameFull" IsEnabled="False"
|
||||||
|
VerticalAlignment="Top" HorizontalAlignment="Stretch" Grid.Column="1" Grid.ColumnSpan="3" Margin="0,10,10,10"/>
|
||||||
|
|
||||||
|
<Label Content="Name:"
|
||||||
|
VerticalAlignment="Top" HorizontalAlignment="Left" Grid.Column="0" Margin="10,40,0,10"/>
|
||||||
|
<TextBox x:Name="ClientNameInput"
|
||||||
|
TextChanged="ClientNames_TextChanged"
|
||||||
|
VerticalAlignment="Top" HorizontalAlignment="Stretch" Grid.Column="1" Grid.ColumnSpan="3" Margin="0,40,10,10"/>
|
||||||
|
|
||||||
|
<Label Content="Namenszusatz:"
|
||||||
|
VerticalAlignment="Top" HorizontalAlignment="Left" Grid.Column="0" Margin="10,70,0,10"/>
|
||||||
|
<TextBox x:Name="ClientNameSuffixInput"
|
||||||
|
TextChanged="ClientNames_TextChanged"
|
||||||
|
VerticalAlignment="Top" HorizontalAlignment="Stretch" Grid.Column="1" Grid.ColumnSpan="3" Margin="0,70,10,10"/>
|
||||||
|
|
||||||
|
<Label Content="Gesellschaftsform:"
|
||||||
|
VerticalAlignment="Top" HorizontalAlignment="Left" Grid.Column="0" Margin="10,100,0,10"/>
|
||||||
|
<TextBox x:Name="ClientNameTypeInput"
|
||||||
|
TextChanged="ClientNames_TextChanged"
|
||||||
|
VerticalAlignment="Top" HorizontalAlignment="Stretch" Grid.Column="1" Margin="0,100,10,10"/>
|
||||||
|
|
||||||
|
<Label Content="Kürzel/Kurzform:"
|
||||||
|
VerticalAlignment="Top" HorizontalAlignment="Left" Grid.Column="0" Margin="10,130,0,10"/>
|
||||||
|
<TextBox x:Name="ClientNameTokenInput"
|
||||||
|
TextChanged="TextBox_TextChanged"
|
||||||
|
VerticalAlignment="Top" HorizontalAlignment="Left" Grid.Column="1" Margin="0,130,10,10" Width="70"/>
|
||||||
|
<TextBox x:Name="ClientNameShortInput"
|
||||||
|
TextChanged="TextBox_TextChanged"
|
||||||
|
VerticalAlignment="Top" HorizontalAlignment="Stretch" Grid.Column="1" Margin="75,130,10,10"/>
|
||||||
|
|
||||||
|
<Label Content="Adresse:"
|
||||||
|
VerticalAlignment="Top" HorizontalAlignment="Left" Grid.Column="0" Margin="10,160,0,10"/>
|
||||||
|
<TextBox x:Name="ClientAddressInput"
|
||||||
|
TextChanged="TextBox_TextChanged"
|
||||||
|
VerticalAlignment="Top" HorizontalAlignment="Stretch" Grid.Column="1" Margin="0,160,10,10"/>
|
||||||
|
|
||||||
|
<Label Content="PLZ/Ort:"
|
||||||
|
VerticalAlignment="Top" HorizontalAlignment="Left" Grid.Column="0" Margin="10,190,0,10"/>
|
||||||
|
<TextBox x:Name="ClientPlzInput"
|
||||||
|
Margin="0,190,0,0" Width="42" Grid.Column="1" HorizontalAlignment="Left"
|
||||||
|
TextChanged="PlzInput_TextChanged" LostFocus="PlzInput_LostFocus"/>
|
||||||
|
<TextBox x:Name="ClientOrtInput" Margin="47,190,10,0" Grid.Column="1"
|
||||||
|
TextChanged="TextBox_TextChanged"/>
|
||||||
|
|
||||||
|
<Label Content="IBAN:" Margin="10,220,0,0" Grid.Column="0"/>
|
||||||
|
<TextBox x:Name="ClientIbanInput" Margin="0,220,10,0" Grid.Column="1"
|
||||||
|
TextChanged="IbanInput_TextChanged" LostFocus="IbanInput_LostFocus"/>
|
||||||
|
|
||||||
|
<Label Content="BIC:" Margin="10,250,0,0" Grid.Column="0"/>
|
||||||
|
<TextBox x:Name="ClientBicInput" Margin="0,250,10,0" Grid.Column="1"
|
||||||
|
TextChanged="BicInput_TextChanged" LostFocus="BicInput_LostFocus"/>
|
||||||
|
|
||||||
|
<Label Content="UID:"
|
||||||
|
VerticalAlignment="Top" HorizontalAlignment="Left" Grid.Column="2" Margin="10,100,0,10"/>
|
||||||
|
<TextBox x:Name="ClientUstIdNrInput"
|
||||||
|
VerticalAlignment="Top" HorizontalAlignment="Left" Grid.Column="3" Margin="0,100,10,10" Width="96"
|
||||||
|
TextChanged="UstIdNrInput_TextChanged" LostFocus="UstIdNrInput_LostFocus"/>
|
||||||
|
|
||||||
|
<Label Content="Betriebs-Nr.:"
|
||||||
|
VerticalAlignment="Top" HorizontalAlignment="Left" Grid.Column="2" Margin="10,130,0,10"/>
|
||||||
|
<TextBox x:Name="ClientLfbisNrInput"
|
||||||
|
VerticalAlignment="Top" HorizontalAlignment="Left" Grid.Column="3" Margin="0,130,10,10" Width="64"
|
||||||
|
TextChanged="LfbisNrInput_TextChanged" LostFocus="LfbisNrInput_LostFocus"/>
|
||||||
|
|
||||||
|
<Label Content="Telefon-Nr.:"
|
||||||
|
VerticalAlignment="Top" HorizontalAlignment="Left" Grid.Column="2" Margin="10,160,0,10"/>
|
||||||
|
<TextBox x:Name="ClientPhoneNrInput" Margin="0,160,10,10" Grid.Column="3"
|
||||||
|
TextChanged="PhoneNrInput_TextChanged" LostFocus="PhoneNrInput_LostFocus"/>
|
||||||
|
|
||||||
|
<Label Content="Fax-Nr.:"
|
||||||
|
VerticalAlignment="Top" HorizontalAlignment="Left" Grid.Column="2" Margin="10,190,0,10"/>
|
||||||
|
<TextBox x:Name="ClientFaxNrInput" Margin="0,190,10,10" Grid.Column="3"
|
||||||
|
TextChanged="PhoneNrInput_TextChanged" LostFocus="PhoneNrInput_LostFocus"/>
|
||||||
|
|
||||||
|
<Label Content="E-Mail-Adr.:"
|
||||||
|
VerticalAlignment="Top" HorizontalAlignment="Left" Grid.Column="2" Margin="10,220,0,10"/>
|
||||||
|
<TextBox x:Name="ClientEmailAddressInput" Margin="0,220,10,0" Grid.Column="3"
|
||||||
|
TextChanged="EmailAddressInput_TextChanged" LostFocus="EmailAddressInput_LostFocus"/>
|
||||||
|
|
||||||
|
<Label Content="Website:"
|
||||||
|
VerticalAlignment="Top" HorizontalAlignment="Left" Grid.Column="2" Margin="10,250,0,10"/>
|
||||||
|
<TextBox x:Name="ClientWebsiteInput" Margin="0,250,10,0" Grid.Column="3"
|
||||||
|
TextChanged="TextBox_TextChanged"/>
|
||||||
|
</Grid>
|
||||||
|
</TabItem>
|
||||||
|
<TabItem Header="Zweigstellen">
|
||||||
|
|
||||||
|
</TabItem>
|
||||||
|
<TabItem Header="Sortenattribute">
|
||||||
|
|
||||||
|
</TabItem>
|
||||||
|
<TabItem Header="Bewirtschaftungsarten">
|
||||||
|
|
||||||
|
</TabItem>
|
||||||
|
<TabItem Header="Flächenbindungsverträge">
|
||||||
|
|
||||||
|
</TabItem>
|
||||||
|
|
||||||
|
<TabItem Header="Saisons">
|
||||||
|
<Grid>
|
||||||
|
<ListBox x:Name="SeasonList" HorizontalAlignment="Left" VerticalAlignment="Stretch" Width="150" Margin="10,10,10,10"
|
||||||
|
SelectionChanged="SeasonList_SelectionChanged">
|
||||||
|
<ListBox.ItemTemplate>
|
||||||
|
<DataTemplate>
|
||||||
|
<StackPanel Orientation="Horizontal">
|
||||||
|
<TextBlock Text="{Binding Year}" Width="40"/>
|
||||||
|
<TextBlock Text="{Binding Currency.Name}" Width="60"/>
|
||||||
|
<TextBlock Text="{Binding Precision}" Width="10"/>
|
||||||
|
</StackPanel>
|
||||||
|
</DataTemplate>
|
||||||
|
</ListBox.ItemTemplate>
|
||||||
|
</ListBox>
|
||||||
|
|
||||||
|
<GroupBox Header="Zu-/Abschläge" Margin="170,150,10,10" VerticalAlignment="Stretch" HorizontalAlignment="Stretch">
|
||||||
|
<Grid>
|
||||||
|
<Grid.ColumnDefinitions>
|
||||||
|
<ColumnDefinition Width="400"/>
|
||||||
|
<ColumnDefinition Width="70"/>
|
||||||
|
<ColumnDefinition Width="*"/>
|
||||||
|
</Grid.ColumnDefinitions>
|
||||||
|
<ListBox x:Name="SeasonModifierList" SelectionChanged="SeasonModifierList_SelectionChanged"
|
||||||
|
HorizontalAlignment="Left" VerticalAlignment="Stretch" Width="350" Margin="10,10,10,10">
|
||||||
|
<ListBox.ItemTemplate>
|
||||||
|
<DataTemplate>
|
||||||
|
<StackPanel Orientation="Horizontal">
|
||||||
|
<TextBlock Text="{Binding ModId}" Width="30"/>
|
||||||
|
<TextBlock Text="{Binding Name}" Width="200" Margin="0,0,10,0"/>
|
||||||
|
<TextBlock Text="{Binding ValueStr}"/>
|
||||||
|
</StackPanel>
|
||||||
|
</DataTemplate>
|
||||||
|
</ListBox.ItemTemplate>
|
||||||
|
</ListBox>
|
||||||
|
<Button x:Name="SeasonModifierUpButton" Content="" FontFamily="Segoe MDL2 Assets" FontSize="10" Padding="0,0,0,0" IsEnabled="False"
|
||||||
|
Click="SeasonModifierUpButton_Click"
|
||||||
|
VerticalAlignment="Center" HorizontalAlignment="Left" Width="25" Height="25" Margin="365,0,0,90"/>
|
||||||
|
<Button x:Name="SeasonModifierDownButton" Content="" FontFamily="Segoe MDL2 Assets" FontSize="10" Padding="0,2,0,0" IsEnabled="False"
|
||||||
|
Click="SeasonModifierDownButton_Click"
|
||||||
|
VerticalAlignment="Center" HorizontalAlignment="Left" Width="25" Height="25" Margin="365,0,0,30"/>
|
||||||
|
<Button x:Name="SeasonModifierAddButton" Content="" FontFamily="Segoe MDL2 Assets" FontSize="11" Padding="0,1.5,0,0" IsEnabled="False"
|
||||||
|
Click="SeasonModifierAddButton_Click"
|
||||||
|
VerticalAlignment="Center" HorizontalAlignment="Left" Width="25" Height="25" Margin="365,30,0,0"/>
|
||||||
|
<Button x:Name="SeasonModifierDeleteButton" Content="" FontFamily="Segoe MDL2 Assets" FontSize="11" Padding="0,1.5,0,0" IsEnabled="False"
|
||||||
|
Click="SeasonModifierDeleteButton_Click"
|
||||||
|
VerticalAlignment="Center" HorizontalAlignment="Left" Width="25" Height="25" Margin="365,90,0,0"/>
|
||||||
|
|
||||||
|
<Label Content="ID:" Grid.Column="1" Margin="10,10,10,10"/>
|
||||||
|
<TextBox x:Name="SeasonModifierIdInput" Grid.Column="2" Margin="0,10,10,10" Width="50" HorizontalAlignment="Left"
|
||||||
|
TextChanged="SeasonModifierIdInput_TextChanged"/>
|
||||||
|
|
||||||
|
<Label Content="Name:" Grid.Column="1" Margin="10,40,10,10"/>
|
||||||
|
<TextBox x:Name="SeasonModifierNameInput" Grid.Column="2" Margin="0,40,10,10"
|
||||||
|
TextChanged="SeasonModifierNameInput_TextChanged"/>
|
||||||
|
|
||||||
|
<Label Content="Relativ:" Grid.Column="1" Margin="10,70,10,10"/>
|
||||||
|
<TextBox x:Name="SeasonModifierRelInput" Grid.Column="2" Margin="0,70,10,10"
|
||||||
|
TextChanged="SeasonModifierRelInput_TextChanged"/>
|
||||||
|
|
||||||
|
<Label Content="Absolut:" Grid.Column="1" Margin="10,100,10,10"/>
|
||||||
|
<TextBox x:Name="SeasonModifierAbsInput" Grid.Column="2" Margin="0,100,10,10"
|
||||||
|
TextChanged="SeasonModifierAbsInput_TextChanged"/>
|
||||||
|
</Grid>
|
||||||
|
</GroupBox>
|
||||||
|
</Grid>
|
||||||
|
</TabItem>
|
||||||
|
<TabItem Header="Parameter">
|
||||||
|
|
||||||
|
</TabItem>
|
||||||
|
<TabItem Header="Textelemente">
|
||||||
|
|
||||||
|
</TabItem>
|
||||||
|
</TabControl>
|
||||||
|
|
||||||
|
<Button x:Name="EditButton" Content="Bearbeiten"
|
||||||
|
HorizontalAlignment="Center" VerticalAlignment="Bottom" Margin="0,0,0,10" Width="120"
|
||||||
|
Click="EditButton_Click"/>
|
||||||
|
<Button x:Name="SaveButton" Content="Speichern" IsEnabled="False"
|
||||||
|
HorizontalAlignment="Center" VerticalAlignment="Bottom" Margin="0,0,250,10" Width="120"
|
||||||
|
Click="SaveButton_Click"/>
|
||||||
|
<Button x:Name="ResetButton" Content="Zurücksetzen" IsEnabled="False" Visibility="Hidden"
|
||||||
|
HorizontalAlignment="Center" VerticalAlignment="Bottom" Margin="0,0,0,10" Width="120"
|
||||||
|
Click="ResetButton_Click"/>
|
||||||
|
<Button x:Name="CancelButton" Content="Abbrechen" IsEnabled="False" IsCancel="True"
|
||||||
|
HorizontalAlignment="Center" VerticalAlignment="Bottom" Margin="250,0,0,10" Width="120"
|
||||||
|
Click="CancelButton_Click"/>
|
||||||
|
</Grid>
|
||||||
|
</local:AdministrationWindow>
|
343
Elwig/Windows/BaseDataWindow.xaml.cs
Normal file
343
Elwig/Windows/BaseDataWindow.xaml.cs
Normal file
@@ -0,0 +1,343 @@
|
|||||||
|
using Elwig.Helpers;
|
||||||
|
using Elwig.Models;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Collections.ObjectModel;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using System.Windows;
|
||||||
|
using System.Windows.Controls;
|
||||||
|
using System.Windows.Data;
|
||||||
|
|
||||||
|
namespace Elwig.Windows {
|
||||||
|
public partial class BaseDataWindow : AdministrationWindow {
|
||||||
|
|
||||||
|
private Dictionary<string, string?>? Modifiers = null;
|
||||||
|
private Dictionary<Modifier, string>? ModifierIds = null;
|
||||||
|
private ObservableCollection<Modifier>? ModifierList = null;
|
||||||
|
private bool ModifiersChanged = false;
|
||||||
|
private bool ModifierUpdate = false;
|
||||||
|
|
||||||
|
public BaseDataWindow() {
|
||||||
|
InitializeComponent();
|
||||||
|
RequiredInputs = new Control[] {
|
||||||
|
ClientNameInput, ClientNameTypeInput, ClientNameTokenInput, ClientNameShortInput,
|
||||||
|
ClientAddressInput, ClientPlzInput, ClientOrtInput,
|
||||||
|
};
|
||||||
|
ExemptInputs = new Control[] {
|
||||||
|
ClientNameFull,
|
||||||
|
SeasonModifierIdInput, SeasonModifierNameInput, SeasonModifierRelInput, SeasonModifierAbsInput,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
new protected void LockInputs() {
|
||||||
|
base.LockInputs();
|
||||||
|
SeasonModifierIdInput.IsReadOnly = true;
|
||||||
|
SeasonModifierNameInput.IsReadOnly = true;
|
||||||
|
SeasonModifierRelInput.IsReadOnly = true;
|
||||||
|
SeasonModifierAbsInput.IsReadOnly = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
new protected void UnlockInputs() {
|
||||||
|
base.UnlockInputs();
|
||||||
|
SeasonModifierIdInput.IsReadOnly = false;
|
||||||
|
SeasonModifierNameInput.IsReadOnly = false;
|
||||||
|
SeasonModifierRelInput.IsReadOnly = false;
|
||||||
|
SeasonModifierAbsInput.IsReadOnly = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void Window_Loaded(object sender, RoutedEventArgs evt) {
|
||||||
|
LockInputs();
|
||||||
|
FillInputs(App.Client);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override async Task RenewContext() {
|
||||||
|
await base.RenewContext();
|
||||||
|
ControlUtils.RenewItemsSource(SeasonList, await Context.Seasons.OrderByDescending(s => s.Year).ToListAsync(), s => (s as Season)?.Year, null, ControlUtils.RenewSourceDefault.First);
|
||||||
|
var year = (SeasonList.SelectedItem as Season)?.Year;
|
||||||
|
ControlUtils.RenewItemsSource(SeasonModifierList, await Context.Modifiers.Where(m => m.Year == year).OrderBy(m => m.Ordering).ToListAsync(), m => (m as Modifier)?.ModId);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void UpdateButtons() {
|
||||||
|
if (!IsEditing && !IsCreating) return;
|
||||||
|
bool ch = ModifiersChanged || HasChanged, v = IsValid;
|
||||||
|
CancelButton.IsEnabled = true;
|
||||||
|
ResetButton.IsEnabled = ch;
|
||||||
|
SaveButton.IsEnabled = ch && v;
|
||||||
|
SeasonModifierUpButton.IsEnabled = SeasonModifierList.SelectedIndex >= 1;
|
||||||
|
SeasonModifierDownButton.IsEnabled = SeasonModifierList.SelectedIndex != -1 && SeasonModifierList.SelectedIndex < (ModifierList?.Count - 1 ?? 0);
|
||||||
|
SeasonModifierAddButton.IsEnabled = true;
|
||||||
|
SeasonModifierDeleteButton.IsEnabled = SeasonModifierList.SelectedIndex != -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ModifiersInitEditing() {
|
||||||
|
var year = (SeasonList.SelectedItem as Season)?.Year;
|
||||||
|
Context.ChangeTracker.Clear();
|
||||||
|
ModifierList = new(Context.Modifiers.Where(m => m.Year == year).OrderBy(m => m.Ordering).ToList());
|
||||||
|
Modifiers = ModifierList.ToDictionary(m => m.ModId, m => m.ModId);
|
||||||
|
ModifierIds = ModifierList.ToDictionary(m => m, m => m.ModId);
|
||||||
|
ControlUtils.RenewItemsSource(SeasonModifierList, ModifierList, m => (m as Modifier)?.ModId);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ModifiersFinishEditing() {
|
||||||
|
var year = (SeasonList.SelectedItem as Season)?.Year;
|
||||||
|
ControlUtils.RenewItemsSource(SeasonModifierList, Context.Modifiers.Where(m => m.Year == year).OrderBy(m => m.Ordering).ToList(), m => (m as Modifier)?.ModId);
|
||||||
|
ModifierList = null;
|
||||||
|
Modifiers = null;
|
||||||
|
ModifierIds = null;
|
||||||
|
ModifiersChanged = false;
|
||||||
|
|
||||||
|
SeasonModifierUpButton.IsEnabled = false;
|
||||||
|
SeasonModifierDownButton.IsEnabled = false;
|
||||||
|
SeasonModifierAddButton.IsEnabled = false;
|
||||||
|
SeasonModifierDeleteButton.IsEnabled = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task ModifiersSave() {
|
||||||
|
if (!ModifiersChanged || ModifierList == null || Modifiers == null || ModifierIds == null) return;
|
||||||
|
int i = 0;
|
||||||
|
foreach (var mod in ModifierList) mod.Ordering = ++i;
|
||||||
|
|
||||||
|
var year = (SeasonList.SelectedItem as Season)?.Year;
|
||||||
|
foreach (var (modid, _) in Modifiers.Where(m => m.Value == null)) {
|
||||||
|
Context.Remove(Context.Modifiers.Find(new object?[] { year, modid }));
|
||||||
|
}
|
||||||
|
foreach (var (mod, old) in ModifierIds) {
|
||||||
|
mod.ModId = old;
|
||||||
|
}
|
||||||
|
foreach (var (old, modid) in Modifiers.Where(m => m.Value != null)) {
|
||||||
|
Context.Update(Context.Modifiers.Find(new object?[] { year, old }));
|
||||||
|
}
|
||||||
|
await Context.SaveChangesAsync();
|
||||||
|
|
||||||
|
foreach (var (old, modid) in Modifiers.Where(m => m.Value != null)) {
|
||||||
|
await Context.Database.ExecuteSqlAsync($"UPDATE modifier SET modid = {modid} WHERE (year, modid) = ({year}, {old})");
|
||||||
|
}
|
||||||
|
await Context.SaveChangesAsync();
|
||||||
|
|
||||||
|
foreach (var mod in ModifierList.Where(m => !ModifierIds.ContainsKey(m))) {
|
||||||
|
await Context.AddAsync(mod);
|
||||||
|
}
|
||||||
|
await Context.SaveChangesAsync();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void EditButton_Click(object sender, RoutedEventArgs evt) {
|
||||||
|
IsEditing = true;
|
||||||
|
EditButton.Visibility = Visibility.Hidden;
|
||||||
|
ResetButton.Visibility = Visibility.Visible;
|
||||||
|
|
||||||
|
ModifiersInitEditing();
|
||||||
|
UnlockInputs();
|
||||||
|
UpdateButtons();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void CancelButton_Click(object sender, RoutedEventArgs evt) {
|
||||||
|
IsEditing = false;
|
||||||
|
IsCreating = false;
|
||||||
|
EditButton.Visibility = Visibility.Visible;
|
||||||
|
ResetButton.Visibility = Visibility.Hidden;
|
||||||
|
CancelButton.IsEnabled = false;
|
||||||
|
SaveButton.IsEnabled = false;
|
||||||
|
ResetButton.IsEnabled = false;
|
||||||
|
ModifiersFinishEditing();
|
||||||
|
|
||||||
|
ClearInputStates();
|
||||||
|
FillInputs(App.Client);
|
||||||
|
LockInputs();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ResetButton_Click(object sender, RoutedEventArgs evt) {
|
||||||
|
ModifiersChanged = false;
|
||||||
|
ModifiersInitEditing();
|
||||||
|
ClearInputStates();
|
||||||
|
FillInputs(App.Client);
|
||||||
|
UpdateButtons();
|
||||||
|
}
|
||||||
|
|
||||||
|
private async void SaveButton_Click(object sender, RoutedEventArgs evt) {
|
||||||
|
try {
|
||||||
|
await UpdateClientParameters(App.Client);
|
||||||
|
await ModifiersSave();
|
||||||
|
} catch (Exception exc) {
|
||||||
|
var str = "Der Eintrag konnte nicht in der Datenbank aktualisiert werden!\n\n" + exc.Message;
|
||||||
|
if (exc.InnerException != null) str += "\n\n" + exc.InnerException.Message;
|
||||||
|
MessageBox.Show(str, "Stammdaten aktualisieren", MessageBoxButton.OK, MessageBoxImage.Error);
|
||||||
|
}
|
||||||
|
|
||||||
|
IsEditing = false;
|
||||||
|
IsCreating = false;
|
||||||
|
EditButton.Visibility = Visibility.Visible;
|
||||||
|
ResetButton.Visibility = Visibility.Hidden;
|
||||||
|
CancelButton.IsEnabled = false;
|
||||||
|
SaveButton.IsEnabled = false;
|
||||||
|
ResetButton.IsEnabled = false;
|
||||||
|
ModifiersFinishEditing();
|
||||||
|
|
||||||
|
ClearInputStates();
|
||||||
|
FillInputs(App.Client);
|
||||||
|
LockInputs();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void FillInputs(ClientParameters p) {
|
||||||
|
ClearOriginalValues();
|
||||||
|
ClearDefaultValues();
|
||||||
|
|
||||||
|
ClientNameInput.Text = p.Name;
|
||||||
|
ClientNameSuffixInput.Text = p.NameSuffix;
|
||||||
|
ClientNameTypeInput.Text = p.NameType;
|
||||||
|
ClientNameTokenInput.Text = p.NameToken;
|
||||||
|
ClientNameShortInput.Text = p.NameShort;
|
||||||
|
ClientAddressInput.Text = p.Address;
|
||||||
|
ClientPlzInput.Text = p.Plz.ToString();
|
||||||
|
ClientOrtInput.Text = p.Ort;
|
||||||
|
ClientIbanInput.Text = p.Iban;
|
||||||
|
ClientBicInput.Text = p.Bic;
|
||||||
|
ClientUstIdNrInput.Text = p.UstIdNr;
|
||||||
|
ClientLfbisNrInput.Text = p.LfbisNr;
|
||||||
|
ClientPhoneNrInput.Text = p.PhoneNr;
|
||||||
|
ClientFaxNrInput.Text = p.FaxNr;
|
||||||
|
ClientEmailAddressInput.Text = p.EmailAddress;
|
||||||
|
ClientWebsiteInput.Text = p.Website;
|
||||||
|
|
||||||
|
FinishInputFilling();
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task UpdateClientParameters(ClientParameters p) {
|
||||||
|
p.Name = ClientNameInput.Text;
|
||||||
|
p.NameSuffix = ClientNameSuffixInput.Text.Length > 0 ? ClientNameSuffixInput.Text : null;
|
||||||
|
p.NameType = ClientNameTypeInput.Text;
|
||||||
|
p.NameToken = ClientNameTokenInput.Text;
|
||||||
|
p.NameShort = ClientNameShortInput.Text;
|
||||||
|
p.Address = ClientAddressInput.Text;
|
||||||
|
p.Plz = int.Parse(ClientPlzInput.Text);
|
||||||
|
p.Ort = ClientOrtInput.Text;
|
||||||
|
p.Iban = ClientIbanInput.Text.Length > 0 ? ClientIbanInput.Text.Replace(" ", "") : null;
|
||||||
|
p.Bic = ClientBicInput.Text.Length > 0 ? ClientBicInput.Text : null;
|
||||||
|
p.UstIdNr = ClientUstIdNrInput.Text.Length > 0 ? ClientUstIdNrInput.Text : null;
|
||||||
|
p.LfbisNr = ClientLfbisNrInput.Text.Length > 0 ? ClientLfbisNrInput.Text : null;
|
||||||
|
p.PhoneNr = ClientPhoneNrInput.Text.Length > 0 ? ClientPhoneNrInput.Text : null;
|
||||||
|
p.FaxNr = ClientFaxNrInput.Text.Length > 0 ? ClientFaxNrInput.Text : null;
|
||||||
|
p.EmailAddress = ClientEmailAddressInput.Text.Length > 0 ? ClientEmailAddressInput.Text : null;
|
||||||
|
p.Website = ClientWebsiteInput.Text.Length > 0 ? ClientWebsiteInput.Text : null;
|
||||||
|
|
||||||
|
await p.UpdateValues();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void SeasonModifierUpButton_Click(object sender, RoutedEventArgs evt) {
|
||||||
|
if (ModifierList == null) return;
|
||||||
|
ModifiersChanged = true;
|
||||||
|
var idx = SeasonModifierList.SelectedIndex;
|
||||||
|
var item = ModifierList[idx];
|
||||||
|
ModifierList.RemoveAt(idx);
|
||||||
|
idx--;
|
||||||
|
ModifierList.Insert(idx, item);
|
||||||
|
SeasonModifierList.SelectedIndex = idx;
|
||||||
|
UpdateButtons();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void SeasonModifierDownButton_Click(object sender, RoutedEventArgs evt) {
|
||||||
|
if (ModifierList == null) return;
|
||||||
|
ModifiersChanged = true;
|
||||||
|
var idx = SeasonModifierList.SelectedIndex;
|
||||||
|
var item = ModifierList[idx];
|
||||||
|
ModifierList.RemoveAt(idx);
|
||||||
|
idx++;
|
||||||
|
ModifierList.Insert(idx, item);
|
||||||
|
SeasonModifierList.SelectedIndex = idx;
|
||||||
|
UpdateButtons();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void SeasonModifierAddButton_Click(object sender, RoutedEventArgs evt) {
|
||||||
|
if (ModifierList == null || SeasonList.SelectedItem is not Season s) return;
|
||||||
|
ModifiersChanged = true;
|
||||||
|
var idx = (SeasonModifierList.SelectedIndex != -1) ? SeasonModifierList.SelectedIndex + 1 : ModifierList.Count;
|
||||||
|
var item = Context.CreateProxy<Modifier>();
|
||||||
|
item.Year = s.Year;
|
||||||
|
ModifierList.Insert(idx, item);
|
||||||
|
SeasonModifierList.SelectedIndex = idx;
|
||||||
|
UpdateButtons();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void SeasonModifierDeleteButton_Click(object sender, RoutedEventArgs evt) {
|
||||||
|
if (ModifierList == null || Modifiers == null) return;
|
||||||
|
ModifiersChanged = true;
|
||||||
|
var idx = SeasonModifierList.SelectedIndex;
|
||||||
|
var item = ModifierList[idx];
|
||||||
|
Modifiers[item.ModId] = null;
|
||||||
|
ModifierList.RemoveAt(idx);
|
||||||
|
SeasonModifierList.SelectedIndex = idx < ModifierList.Count ? idx : idx - 1;
|
||||||
|
UpdateButtons();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private void ClientNames_TextChanged(object sender, TextChangedEventArgs evt) {
|
||||||
|
var suffix = ClientNameSuffixInput.Text.Length > 0 ? ClientNameSuffixInput.Text : null;
|
||||||
|
ClientNameFull.Text = $"{ClientNameInput.Text}{(suffix != null ? $", {suffix}," : "")} {ClientNameTypeInput.Text}";
|
||||||
|
TextBox_TextChanged(sender, evt);
|
||||||
|
}
|
||||||
|
|
||||||
|
private async void SeasonList_SelectionChanged(object sender, SelectionChangedEventArgs evt) {
|
||||||
|
var year = (SeasonList.SelectedItem as Season)?.Year;
|
||||||
|
SeasonModifierList.ItemsSource = await Context.Modifiers.Where(m => m.Year == year).OrderBy(m => m.Ordering).ToListAsync();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void SeasonModifierList_SelectionChanged(object sender, SelectionChangedEventArgs evt) {
|
||||||
|
UpdateButtons();
|
||||||
|
ModifierUpdate = true;
|
||||||
|
if (SeasonModifierList.SelectedItem is not Modifier mod) {
|
||||||
|
SeasonModifierIdInput.Text = "";
|
||||||
|
SeasonModifierNameInput.Text = "";
|
||||||
|
SeasonModifierRelInput.Text = "";
|
||||||
|
SeasonModifierAbsInput.Text = "";
|
||||||
|
} else {
|
||||||
|
SeasonModifierIdInput.Text = mod.ModId;
|
||||||
|
SeasonModifierNameInput.Text = mod.Name;
|
||||||
|
SeasonModifierRelInput.Text = (mod.Rel * 100)?.ToString();
|
||||||
|
SeasonModifierAbsInput.Text = mod.Abs?.ToString();
|
||||||
|
}
|
||||||
|
ModifierUpdate = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void SeasonModifierIdInput_TextChanged(object sender, TextChangedEventArgs evt) {
|
||||||
|
if ((!IsEditing && !IsCreating) || SeasonModifierList.SelectedItem is not Modifier mod || Modifiers == null || ModifierIds == null) return;
|
||||||
|
ModifiersChanged = ModifiersChanged || (SeasonModifierIdInput.Text ?? "") != ((SeasonModifierList.SelectedItem as Modifier)?.ModId ?? "");
|
||||||
|
if (ModifierUpdate) return;
|
||||||
|
var old = ModifierIds.GetValueOrDefault(mod);
|
||||||
|
var id = SeasonModifierIdInput.Text ?? "";
|
||||||
|
if (old != null) Modifiers[old] = id;
|
||||||
|
mod.ModId = id;
|
||||||
|
CollectionViewSource.GetDefaultView(ModifierList).Refresh();
|
||||||
|
UpdateButtons();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void SeasonModifierNameInput_TextChanged(object sender, TextChangedEventArgs evt) {
|
||||||
|
if ((!IsEditing && !IsCreating) || SeasonModifierList.SelectedItem is not Modifier mod) return;
|
||||||
|
ModifiersChanged = ModifiersChanged || (SeasonModifierNameInput.Text ?? "") != ((SeasonModifierList.SelectedItem as Modifier)?.Name ?? "");
|
||||||
|
if (ModifierUpdate) return;
|
||||||
|
mod.Name = SeasonModifierNameInput.Text ?? "";
|
||||||
|
CollectionViewSource.GetDefaultView(ModifierList).Refresh();
|
||||||
|
UpdateButtons();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void SeasonModifierRelInput_TextChanged(object sender, TextChangedEventArgs evt) {
|
||||||
|
if ((!IsEditing && !IsCreating) || SeasonModifierList.SelectedItem is not Modifier mod) return;
|
||||||
|
ModifiersChanged = ModifiersChanged || (SeasonModifierRelInput.Text ?? "") != ((SeasonModifierList.SelectedItem as Modifier)?.Rel?.ToString() ?? "");
|
||||||
|
if (ModifierUpdate) return;
|
||||||
|
mod.Rel = decimal.TryParse(SeasonModifierRelInput.Text, out var v) ? v / 100 : null;
|
||||||
|
if (mod.Rel != null) SeasonModifierAbsInput.Text = "";
|
||||||
|
CollectionViewSource.GetDefaultView(ModifierList).Refresh();
|
||||||
|
UpdateButtons();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void SeasonModifierAbsInput_TextChanged(object sender, TextChangedEventArgs evt) {
|
||||||
|
if ((!IsEditing && !IsCreating) || SeasonModifierList.SelectedItem is not Modifier mod) return;
|
||||||
|
ModifiersChanged = ModifiersChanged || (SeasonModifierAbsInput.Text ?? "") != ((SeasonModifierList.SelectedItem as Modifier)?.Abs?.ToString() ?? "");
|
||||||
|
if (ModifierUpdate) return;
|
||||||
|
mod.Abs = decimal.TryParse(SeasonModifierAbsInput.Text, out var v) ? v : null;
|
||||||
|
if (mod.Abs != null) SeasonModifierRelInput.Text = "";
|
||||||
|
CollectionViewSource.GetDefaultView(ModifierList).Refresh();
|
||||||
|
UpdateButtons();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
188
Elwig/Windows/ChartWindow.xaml
Normal file
188
Elwig/Windows/ChartWindow.xaml
Normal file
@@ -0,0 +1,188 @@
|
|||||||
|
<local:AdministrationWindow x:Class="Elwig.Windows.ChartWindow"
|
||||||
|
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"
|
||||||
|
xmlns:ScottPlot="clr-namespace:ScottPlot;assembly=ScottPlot.WPF"
|
||||||
|
mc:Ignorable="d"
|
||||||
|
Title="Auszahlung - Elwig" Height="700" Width="1500"
|
||||||
|
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="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="*"/>
|
||||||
|
</Grid.RowDefinitions>
|
||||||
|
<Grid.ColumnDefinitions>
|
||||||
|
<ColumnDefinition Width="330"/>
|
||||||
|
<ColumnDefinition Width="1*"/>
|
||||||
|
<ColumnDefinition Width="200"/>
|
||||||
|
</Grid.ColumnDefinitions>
|
||||||
|
|
||||||
|
<Grid Grid.Row="1" Margin="5,0,0,0">
|
||||||
|
<Grid.RowDefinitions>
|
||||||
|
<RowDefinition Height="*"/>
|
||||||
|
<RowDefinition Height="42"/>
|
||||||
|
</Grid.RowDefinitions>
|
||||||
|
<Grid.ColumnDefinitions>
|
||||||
|
<ColumnDefinition Width="*"/>
|
||||||
|
<ColumnDefinition Width="*"/>
|
||||||
|
<ColumnDefinition Width="*"/>
|
||||||
|
</Grid.ColumnDefinitions>
|
||||||
|
|
||||||
|
<DataGrid x:Name="GraphList" AutoGenerateColumns="False" HeadersVisibility="Column" IsReadOnly="True" GridLinesVisibility="None" SelectionMode="Single"
|
||||||
|
CanUserDeleteRows="False" CanUserResizeRows="False" CanUserAddRows="False"
|
||||||
|
SelectionChanged="GraphList_SelectionChanged"
|
||||||
|
Margin="5,15,5,0" Grid.Row="0" FontSize="14" Grid.ColumnSpan="3">
|
||||||
|
<DataGrid.Columns>
|
||||||
|
<DataGridTextColumn Header="Nr." Binding="{Binding Num}" Width="40">
|
||||||
|
<DataGridTextColumn.ElementStyle>
|
||||||
|
<Style>
|
||||||
|
<Setter Property="TextBlock.TextWrapping" Value="Wrap" />
|
||||||
|
</Style>
|
||||||
|
</DataGridTextColumn.ElementStyle>
|
||||||
|
</DataGridTextColumn>
|
||||||
|
<DataGridTextColumn Header="Typ" Binding="{Binding Type}" Width="40"/>
|
||||||
|
<DataGridTextColumn Header="Angewandte Verträge" Binding="{Binding Contracts}" Width="4*"/>
|
||||||
|
</DataGrid.Columns>
|
||||||
|
</DataGrid>
|
||||||
|
|
||||||
|
<Button x:Name="NewButton" Content="Neu"
|
||||||
|
HorizontalAlignment="Stretch" VerticalAlignment="Bottom" Margin="5,5,2.5,10" Grid.Column="0" Grid.Row="2"
|
||||||
|
Click="NewButton_Click"/>
|
||||||
|
<Button x:Name="EditButton" Content="Bearbeiten" IsEnabled="False"
|
||||||
|
HorizontalAlignment="Stretch" VerticalAlignment="Bottom" Margin="2.5,5,2.5,10" Grid.Column="1" Grid.Row="2"
|
||||||
|
Click="EditButton_Click"/>
|
||||||
|
<Button x:Name="DeleteButton" Content="Löschen" IsEnabled="False"
|
||||||
|
HorizontalAlignment="Stretch" VerticalAlignment="Bottom" Margin="2.5,5,5,10" Grid.Column="2" Grid.Row="2"
|
||||||
|
Click="DeleteButton_Click"/>
|
||||||
|
|
||||||
|
<Button x:Name="SaveButton" Content="Speichern" IsEnabled="False" Visibility="Hidden"
|
||||||
|
HorizontalAlignment="Stretch" VerticalAlignment="Bottom" Margin="5,5,2.5,10" Grid.Column="0" Grid.Row="2"
|
||||||
|
Click="SaveButton_Click"/>
|
||||||
|
<Button x:Name="ResetButton" Content="Zurücksetzen" IsEnabled="False" Visibility="Hidden"
|
||||||
|
HorizontalAlignment="Stretch" VerticalAlignment="Bottom" Margin="2.5,5,2.5,10" Grid.Column="1" Grid.Row="2"
|
||||||
|
Click="ResetButton_Click"/>
|
||||||
|
<Button x:Name="CancelButton" Content="Abbrechen" IsEnabled="False" Visibility="Hidden" IsCancel="True"
|
||||||
|
HorizontalAlignment="Stretch" VerticalAlignment="Bottom" Margin="2.5,5,5,10" Grid.Column="2" Grid.Row="2"
|
||||||
|
Click="CancelButton_Click"/>
|
||||||
|
</Grid>
|
||||||
|
|
||||||
|
<Grid Grid.Row="1" Grid.Column="1">
|
||||||
|
<ScottPlot:WpfPlot x:Name="OechslePricePlot" MouseMove="OechslePricePlot_MouseMove" MouseDown="OechslePricePlot_MouseDown" IsEnabled="False"/>
|
||||||
|
</Grid>
|
||||||
|
|
||||||
|
<Grid Grid.Row="1" Grid.Column="2" Margin="0,0,5,0">
|
||||||
|
<Grid.RowDefinitions>
|
||||||
|
<RowDefinition Height="120"/>
|
||||||
|
<RowDefinition Height="120"/>
|
||||||
|
<RowDefinition Height="210"/>
|
||||||
|
<RowDefinition Height="110"/>
|
||||||
|
<RowDefinition Height="42"/>
|
||||||
|
</Grid.RowDefinitions>
|
||||||
|
|
||||||
|
<GroupBox Header="Graph" Grid.Row="0" Margin="0,5,5,5">
|
||||||
|
<Grid>
|
||||||
|
<Grid.ColumnDefinitions>
|
||||||
|
<ColumnDefinition Width="85"/>
|
||||||
|
<ColumnDefinition Width="*"/>
|
||||||
|
</Grid.ColumnDefinitions>
|
||||||
|
|
||||||
|
<Label Content="Nummer:" Margin="10,10,0,0" Grid.Column="0"/>
|
||||||
|
<TextBox x:Name="GraphNumberInput" Grid.Column="1" HorizontalAlignment="Left" Margin="0,10,0,0" Text="" Width="90" TextChanged="GraphNumberInput_TextChanged" LostFocus="GraphNumberInput_LostFocus"/>
|
||||||
|
|
||||||
|
<Label Content="Typ:" Margin="10,45,0,0" Grid.Column="0"/>
|
||||||
|
<RadioButton x:Name="OechsleGraphType_Input" GroupName="GraphType" Grid.Column="1" Margin="0,45,0,0">Oechsle</RadioButton>
|
||||||
|
<RadioButton x:Name="KmwGraphType_Input" GroupName="GraphType" Grid.Column="1" Margin="0,60,0,0">KMW</RadioButton>
|
||||||
|
</Grid>
|
||||||
|
</GroupBox>
|
||||||
|
|
||||||
|
<GroupBox Header="Datenpunkt" Grid.Row="1" Margin="0,5,5,5">
|
||||||
|
<Grid>
|
||||||
|
<Grid.ColumnDefinitions>
|
||||||
|
<ColumnDefinition Width="85"/>
|
||||||
|
<ColumnDefinition Width="*"/>
|
||||||
|
</Grid.ColumnDefinitions>
|
||||||
|
|
||||||
|
<Label Content="Oechsle:" Margin="10,10,0,0" Grid.Column="0"/>
|
||||||
|
<TextBox x:Name="OechsleInput" Grid.Column="1" HorizontalAlignment="Left" Margin="0,10,0,0" Text="" Width="90" TextChanged="OechsleInput_TextChanged" LostFocus="OechsleInput_LostFocus"/>
|
||||||
|
|
||||||
|
<Label Content="Preis pro kg:" Margin="10,40,0,0" Grid.Column="0"/>
|
||||||
|
<TextBox x:Name="PriceInput" Grid.Column="1" HorizontalAlignment="Left" Margin="0,40,0,0" Text="" Width="90" TextChanged="PriceInput_TextChanged" LostFocus="PriceInput_LostFocus"/>
|
||||||
|
|
||||||
|
</Grid>
|
||||||
|
</GroupBox>
|
||||||
|
|
||||||
|
<GroupBox Header="Aktionen" Grid.Row="2" Margin="0,5,5,5">
|
||||||
|
<Grid>
|
||||||
|
<Grid.ColumnDefinitions>
|
||||||
|
<ColumnDefinition Width="*"/>
|
||||||
|
</Grid.ColumnDefinitions>
|
||||||
|
|
||||||
|
<Button x:Name="LeftFlatButton" Content="Links flach" Click="LeftFlatButton_Click" IsEnabled="False"
|
||||||
|
HorizontalAlignment="Stretch" VerticalAlignment="Top" Margin="10,10,10,10"/>
|
||||||
|
|
||||||
|
<Button x:Name="RightFlatButton" Content="Rechts flach" Click="RightFlatButton_Click" IsEnabled="False"
|
||||||
|
HorizontalAlignment="Stretch" VerticalAlignment="Top" Margin="10,50,10,10"/>
|
||||||
|
|
||||||
|
<Button x:Name="InterpolateButton" Content="Interpolieren" Click="InterpolateButton_Click" IsEnabled="False"
|
||||||
|
HorizontalAlignment="Stretch" VerticalAlignment="Top" Margin="10,90,10,10"/>
|
||||||
|
|
||||||
|
<Button x:Name="LinearIncreaseButton" Content="Linear wachsen" Click="LinearIncreaseButton_Click" IsEnabled="False"
|
||||||
|
HorizontalAlignment="Stretch" VerticalAlignment="Top" Margin="10,130,10,10"/>
|
||||||
|
</Grid>
|
||||||
|
</GroupBox>
|
||||||
|
|
||||||
|
<GroupBox Header="Optionen" Grid.Row="3" Margin="0,5,5,5">
|
||||||
|
<Grid>
|
||||||
|
<Grid.ColumnDefinitions>
|
||||||
|
<ColumnDefinition Width="*"/>
|
||||||
|
</Grid.ColumnDefinitions>
|
||||||
|
|
||||||
|
<CheckBox x:Name="FreeZoomInput" Content="Freier Zoom" IsEnabled="False"
|
||||||
|
Checked="FreeZoomInput_Changed" Unchecked="FreeZoomInput_Changed"
|
||||||
|
HorizontalAlignment="Left" Margin="10,10,10,0" VerticalAlignment="Top"/>
|
||||||
|
|
||||||
|
<CheckBox x:Name="GradationLinesInput" Content="Gradationslinien anzeigen" IsEnabled="False"
|
||||||
|
Checked="GradationLinesInput_Changed" Unchecked="GradationLinesInput_Changed"
|
||||||
|
HorizontalAlignment="Left" Margin="10,30,10,0" VerticalAlignment="Top" IsChecked="True"/>
|
||||||
|
|
||||||
|
<CheckBox x:Name="TooltipInput" Content="Tooltips anzeigen" IsEnabled="False"
|
||||||
|
HorizontalAlignment="Left" Margin="10,50,10,0" VerticalAlignment="Top" IsChecked="True"/>
|
||||||
|
</Grid>
|
||||||
|
</GroupBox>
|
||||||
|
</Grid>
|
||||||
|
</Grid>
|
||||||
|
</local:AdministrationWindow>
|
750
Elwig/Windows/ChartWindow.xaml.cs
Normal file
750
Elwig/Windows/ChartWindow.xaml.cs
Normal file
@@ -0,0 +1,750 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel;
|
||||||
|
using System.Diagnostics;
|
||||||
|
using System.Diagnostics.Contracts;
|
||||||
|
using System.Drawing;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using System.Windows;
|
||||||
|
using System.Windows.Controls;
|
||||||
|
using System.Windows.Data;
|
||||||
|
using System.Windows.Documents;
|
||||||
|
using System.Windows.Input;
|
||||||
|
using Elwig.Helpers;
|
||||||
|
using Elwig.Models;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using Microsoft.EntityFrameworkCore.ChangeTracking;
|
||||||
|
using Newtonsoft.Json.Linq;
|
||||||
|
using ScottPlot;
|
||||||
|
using ScottPlot.Plottable;
|
||||||
|
|
||||||
|
namespace Elwig.Windows {
|
||||||
|
public partial class ChartWindow : AdministrationWindow {
|
||||||
|
|
||||||
|
private readonly int Year = 2021;
|
||||||
|
private readonly int AvNr = 2;
|
||||||
|
|
||||||
|
private ScatterPlot OechslePricePlotScatter;
|
||||||
|
private MarkerPlot HighlightedPoint;
|
||||||
|
private MarkerPlot PrimaryMarkedPoint;
|
||||||
|
private MarkerPlot SecondaryMarkedPoint;
|
||||||
|
private Tooltip Tooltip;
|
||||||
|
|
||||||
|
private int LastHighlightedIndex = -1;
|
||||||
|
private int HighlightedIndex = -1;
|
||||||
|
private int PrimaryMarkedPointIndex = -1;
|
||||||
|
private int SecondaryMarkedPointIndex = -1;
|
||||||
|
private bool HoverChanged = false;
|
||||||
|
private bool HoverActive = false;
|
||||||
|
|
||||||
|
private const int MinOechsle = 50;
|
||||||
|
private const int MaxOechsle = 140;
|
||||||
|
|
||||||
|
private Graph? Graph;
|
||||||
|
|
||||||
|
public ChartWindow() {
|
||||||
|
InitializeComponent();
|
||||||
|
|
||||||
|
ExemptInputs = new Control[] {
|
||||||
|
GraphList, OechsleInput, PriceInput, FreeZoomInput, GradationLinesInput, TooltipInput
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
private void Window_Loaded(object sender, RoutedEventArgs evt) {
|
||||||
|
LockInputs();
|
||||||
|
OechslePricePlot.IsEnabled = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task RefreshGraphList() {
|
||||||
|
await Context.PaymentVariants.LoadAsync();
|
||||||
|
await RefreshGraphListQuery();
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task RefreshGraphListQuery(bool updateSort = false) {
|
||||||
|
List<PaymentVar> paymentVars = await Context.PaymentVariants.Where(p => p.Year == Year && p.AvNr == AvNr).ToListAsync();
|
||||||
|
|
||||||
|
if (paymentVars.Count != 1) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
PaymentVar paymentVar = paymentVars[0];
|
||||||
|
var data = JToken.Parse(paymentVar.Data);
|
||||||
|
|
||||||
|
var auszahlungsSorten = data["AuszahlungSorten"];
|
||||||
|
if (auszahlungsSorten == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var Graphs = auszahlungsSorten["Kurven"];
|
||||||
|
|
||||||
|
if (Graphs == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
List<Graph> GraphsList = new();
|
||||||
|
|
||||||
|
int i = 1;
|
||||||
|
foreach (var graph in Graphs) {
|
||||||
|
GraphsList.Add(new Graph("Oe", i, graph, ParseContracts(auszahlungsSorten, i - 1), 50, 140));
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
|
||||||
|
ControlUtils.RenewItemsSource(GraphList, GraphsList, g => (g as Graph)?.Num);
|
||||||
|
if (GraphsList.Count == 1) {
|
||||||
|
GraphList.SelectedIndex = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
RefreshInputs();
|
||||||
|
}
|
||||||
|
|
||||||
|
private String ParseContracts(JToken auszahlungsSorten, int num) {
|
||||||
|
List<string> contracts = new();
|
||||||
|
|
||||||
|
foreach (var sorte in auszahlungsSorten.Children().OfType<JToken>()) {
|
||||||
|
if (((JProperty)sorte).Name == "Kurven") {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
foreach (var attribut in sorte.Values().OfType<JToken>()) {
|
||||||
|
foreach (var bindung in attribut.Values().OfType<JProperty>()) {
|
||||||
|
if ((int)(bindung).Value == num) {
|
||||||
|
contracts.Add($"{((JProperty)sorte).Name}/{((JProperty)attribut).Name}/{bindung.Name}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return string.Join("\n", contracts.ToArray());
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task<bool> RemoveGraph(int num) {
|
||||||
|
List<PaymentVar> paymentVars = await Context.PaymentVariants.Where(p => p.Year == Year && p.AvNr == AvNr).ToListAsync();
|
||||||
|
|
||||||
|
if (paymentVars.Count != 1) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
PaymentVar paymentVar = paymentVars[0];
|
||||||
|
var data = JToken.Parse(paymentVar.Data);
|
||||||
|
|
||||||
|
var auszahlungsSorten = data["AuszahlungSorten"];
|
||||||
|
if (auszahlungsSorten == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
var Graphs = auszahlungsSorten["Kurven"];
|
||||||
|
|
||||||
|
if (Graphs == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
int i = 1;
|
||||||
|
foreach (var graph in Graphs) {
|
||||||
|
if (i == num) {
|
||||||
|
graph.Remove();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach (var sorte in auszahlungsSorten.Children().OfType<JToken>()) {
|
||||||
|
if (((JProperty)sorte).Name == "Kurven") {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
foreach (var attribut in sorte.Values().OfType<JToken>()) {
|
||||||
|
List<JProperty> itemsToRemove = new();
|
||||||
|
foreach (var bindung in attribut.Values().OfType<JProperty>()) {
|
||||||
|
if ((int)bindung.Value == num - 1) {
|
||||||
|
itemsToRemove.Add(bindung);
|
||||||
|
} else if ((int)bindung.Value > num - 1) {
|
||||||
|
bindung.Value = (int)bindung.Value - 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
itemsToRemove.ForEach(i => i.Remove());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
EntityEntry<PaymentVar>? tr = null;
|
||||||
|
try {
|
||||||
|
paymentVar.Data = data.ToString();
|
||||||
|
tr = Context.Update(paymentVar);
|
||||||
|
|
||||||
|
await Context.SaveChangesAsync();
|
||||||
|
} catch (Exception exc) {
|
||||||
|
if (tr != null) await tr.ReloadAsync();
|
||||||
|
var str = "Der Eintrag konnte nicht in der Datenbank gelöscht werden!\n\n" + exc.Message;
|
||||||
|
if (exc.InnerException != null) str += "\n\n" + exc.InnerException.Message;
|
||||||
|
MessageBox.Show(str, "Graph löschen", MessageBoxButton.OK, MessageBoxImage.Error);
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void RefreshInputs(bool validate = false) {
|
||||||
|
ResetPlot();
|
||||||
|
ClearInputStates();
|
||||||
|
if (GraphList.SelectedItem is Graph g) {
|
||||||
|
EditButton.IsEnabled = true;
|
||||||
|
DeleteButton.IsEnabled = true;
|
||||||
|
EnableOptionButtons();
|
||||||
|
FillInputs(g);
|
||||||
|
} else {
|
||||||
|
EditButton.IsEnabled = false;
|
||||||
|
DeleteButton.IsEnabled = false;
|
||||||
|
DisableOptionButtons();
|
||||||
|
ClearOriginalValues();
|
||||||
|
ClearInputs(validate);
|
||||||
|
ClearInputStates();
|
||||||
|
}
|
||||||
|
GC.Collect();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void FillInputs(Graph g) {
|
||||||
|
ClearOriginalValues();
|
||||||
|
|
||||||
|
Graph = (Graph)g.Clone();
|
||||||
|
|
||||||
|
GraphNumberInput.Text = Graph.Num.ToString();
|
||||||
|
if (Graph.Type == "oe") {
|
||||||
|
OechsleGraphType_Input.IsChecked = true;
|
||||||
|
} else if (Graph.Type == "kmw") {
|
||||||
|
KmwGraphType_Input.IsChecked = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
InitPlot();
|
||||||
|
OechslePricePlot.IsEnabled = true;
|
||||||
|
|
||||||
|
FinishInputFilling();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void InitInputs() {
|
||||||
|
GraphNumberInput.Text = (GraphList.Items.Count + 1).ToString();
|
||||||
|
OechsleGraphType_Input.IsChecked = true;
|
||||||
|
FinishInputFilling();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override async Task RenewContext() {
|
||||||
|
await base.RenewContext();
|
||||||
|
await RefreshGraphList();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void InitPlot() {
|
||||||
|
OechslePricePlotScatter = OechslePricePlot.Plot.AddScatter(Graph.DataX, Graph.DataY);
|
||||||
|
|
||||||
|
OechslePricePlotScatter.LineColor = Color.Blue;
|
||||||
|
OechslePricePlotScatter.MarkerColor = Color.Blue;
|
||||||
|
OechslePricePlotScatter.MarkerSize = 9;
|
||||||
|
|
||||||
|
//OechslePricePlot.Plot.XAxis.ManualTickSpacing(1);
|
||||||
|
OechslePricePlot.Plot.YAxis.ManualTickSpacing(0.1);
|
||||||
|
OechslePricePlot.Plot.SetAxisLimits(MinOechsle - 1, MaxOechsle + 1, -0.1, 2);
|
||||||
|
|
||||||
|
OechslePricePlot.Plot.Layout(padding: 0);
|
||||||
|
OechslePricePlot.Plot.XAxis2.Layout(padding: 0);
|
||||||
|
OechslePricePlot.Plot.YAxis.Layout(padding: 0);
|
||||||
|
OechslePricePlot.Plot.YAxis2.Layout(padding: 0);
|
||||||
|
|
||||||
|
HighlightedPoint = OechslePricePlot.Plot.AddPoint(0, 0);
|
||||||
|
HighlightedPoint.Color = Color.Red;
|
||||||
|
HighlightedPoint.MarkerSize = 10;
|
||||||
|
HighlightedPoint.MarkerShape = MarkerShape.openCircle;
|
||||||
|
HighlightedPoint.IsVisible = false;
|
||||||
|
|
||||||
|
PrimaryMarkedPoint = OechslePricePlot.Plot.AddPoint(0, 0);
|
||||||
|
PrimaryMarkedPoint.Color = Color.Red;
|
||||||
|
PrimaryMarkedPoint.MarkerSize = 6;
|
||||||
|
PrimaryMarkedPoint.MarkerShape = MarkerShape.filledCircle;
|
||||||
|
PrimaryMarkedPoint.IsVisible = false;
|
||||||
|
|
||||||
|
SecondaryMarkedPoint = OechslePricePlot.Plot.AddPoint(0, 0);
|
||||||
|
SecondaryMarkedPoint.Color = Color.Red;
|
||||||
|
SecondaryMarkedPoint.MarkerSize = 6;
|
||||||
|
SecondaryMarkedPoint.MarkerShape = MarkerShape.filledCircle;
|
||||||
|
SecondaryMarkedPoint.IsVisible = false;
|
||||||
|
|
||||||
|
OechslePricePlot.Refresh();
|
||||||
|
|
||||||
|
RefreshFreeZoom();
|
||||||
|
RefreshGradationLines();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ResetPlot() {
|
||||||
|
Graph = null;
|
||||||
|
PrimaryMarkedPointIndex = -1;
|
||||||
|
OechslePricePlot.Plot.Remove(OechslePricePlotScatter);
|
||||||
|
OechslePricePlot.Plot.Clear();
|
||||||
|
OechslePricePlot.Reset();
|
||||||
|
OechslePricePlot.Refresh();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ChangeMarker(MarkerPlot point, bool visible, double x = 0, double y = 0) {
|
||||||
|
point.X = x;
|
||||||
|
point.Y = y;
|
||||||
|
point.IsVisible = visible;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void FlattenGraph(int begin, int end, double value) {
|
||||||
|
for (int i = begin; i <= end; i++) {
|
||||||
|
Graph.DataY[i] = value;
|
||||||
|
}
|
||||||
|
OechslePricePlot.Render();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void LinearIncreaseGraph(int begin, int end, double inc) {
|
||||||
|
for (int i = begin; i < end; i++) {
|
||||||
|
Graph.DataY[i + 1] = Graph.DataY[i] + inc;
|
||||||
|
}
|
||||||
|
OechslePricePlot.Render();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void EnableActionButtons() {
|
||||||
|
LeftFlatButton.IsEnabled = true;
|
||||||
|
RightFlatButton.IsEnabled = true;
|
||||||
|
LinearIncreaseButton.IsEnabled = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void DisableActionButtons() {
|
||||||
|
LeftFlatButton.IsEnabled = false;
|
||||||
|
RightFlatButton.IsEnabled = false;
|
||||||
|
InterpolateButton.IsEnabled = false;
|
||||||
|
LinearIncreaseButton.IsEnabled = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void FreeZoomInput_Changed(object sender, RoutedEventArgs evt) {
|
||||||
|
RefreshFreeZoom();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void RefreshFreeZoom() {
|
||||||
|
if (FreeZoomInput.IsChecked == true) {
|
||||||
|
UnlockZoom();
|
||||||
|
} else {
|
||||||
|
LockZoom();
|
||||||
|
}
|
||||||
|
OechslePricePlot.Refresh();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void LockZoom() {
|
||||||
|
OechslePricePlot.Plot.XAxis.SetBoundary(MinOechsle - 1, MaxOechsle + 1);
|
||||||
|
OechslePricePlot.Plot.YAxis.SetBoundary(-0.1, 2);
|
||||||
|
OechslePricePlot.Plot.XAxis.SetZoomOutLimit(MaxOechsle - MinOechsle + 2);
|
||||||
|
OechslePricePlot.Plot.YAxis.SetZoomOutLimit(2.1);
|
||||||
|
OechslePricePlot.Plot.SetAxisLimits(MinOechsle - 1, MaxOechsle + 1, -0.1, 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void UnlockZoom() {
|
||||||
|
OechslePricePlot.Plot.XAxis.SetBoundary();
|
||||||
|
OechslePricePlot.Plot.YAxis.SetBoundary();
|
||||||
|
OechslePricePlot.Plot.XAxis.SetZoomOutLimit((MaxOechsle - MinOechsle) * 1.5);
|
||||||
|
OechslePricePlot.Plot.YAxis.SetZoomOutLimit(3.5);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void EnableOptionButtons() {
|
||||||
|
FreeZoomInput.IsEnabled = true;
|
||||||
|
GradationLinesInput.IsEnabled = true;
|
||||||
|
TooltipInput.IsEnabled = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void DisableOptionButtons() {
|
||||||
|
FreeZoomInput.IsEnabled = false;
|
||||||
|
GradationLinesInput.IsEnabled = false;
|
||||||
|
TooltipInput.IsEnabled = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void GradationLinesInput_Changed(object sender, RoutedEventArgs evt) {
|
||||||
|
RefreshGradationLines();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void RefreshGradationLines() {
|
||||||
|
if (GradationLinesInput.IsChecked == true) {
|
||||||
|
ShowGradationLines();
|
||||||
|
ShowLegend();
|
||||||
|
} else {
|
||||||
|
HideGradationLines();
|
||||||
|
HideLegend();
|
||||||
|
}
|
||||||
|
OechslePricePlot.Refresh();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ShowGradationLines() {
|
||||||
|
OechslePricePlot.Plot.AddVerticalLine(68, Color.Red, 2, label: "68 Oechsle (LDW)");
|
||||||
|
OechslePricePlot.Plot.AddVerticalLine(73, Color.Orange, 2, label: "73 Oechsle (QUW)");
|
||||||
|
OechslePricePlot.Plot.AddVerticalLine(84, Color.Green, 2, label: "84 Oechsle (KAB)");
|
||||||
|
}
|
||||||
|
|
||||||
|
private void HideGradationLines() {
|
||||||
|
OechslePricePlot.Plot.Clear(typeof(VLine));
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ShowLegend() {
|
||||||
|
OechslePricePlot.Plot.Legend(true, Alignment.UpperRight);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void HideLegend() {
|
||||||
|
OechslePricePlot.Plot.Legend(false, Alignment.UpperRight);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OechsleInput_TextChanged(object sender, RoutedEventArgs evt) {
|
||||||
|
IntegerInput_TextChanged(sender, evt);
|
||||||
|
|
||||||
|
bool success = int.TryParse(OechsleInput.Text, out int oechsle);
|
||||||
|
|
||||||
|
SecondaryMarkedPointIndex = -1;
|
||||||
|
ChangeMarker(SecondaryMarkedPoint, false);
|
||||||
|
|
||||||
|
if (success) {
|
||||||
|
if (oechsle >= MinOechsle && oechsle <= MaxOechsle) {
|
||||||
|
PrimaryMarkedPointIndex = oechsle - MinOechsle;
|
||||||
|
ChangeMarker(PrimaryMarkedPoint, true, Graph.DataX[PrimaryMarkedPointIndex], Graph.DataY[PrimaryMarkedPointIndex]);
|
||||||
|
|
||||||
|
PriceInput.Text = Graph.DataY[PrimaryMarkedPointIndex].ToString();
|
||||||
|
|
||||||
|
EnableActionButtons();
|
||||||
|
OechslePricePlot.Render();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
PrimaryMarkedPointIndex = -1;
|
||||||
|
ChangeMarker(PrimaryMarkedPoint, false);
|
||||||
|
DisableActionButtons();
|
||||||
|
PriceInput.Text = "";
|
||||||
|
OechslePricePlot.Render();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void PriceInput_TextChanged(object sender, RoutedEventArgs evt) {
|
||||||
|
if (PrimaryMarkedPointIndex != -1) {
|
||||||
|
bool success = Double.TryParse(PriceInput.Text, out double price);
|
||||||
|
|
||||||
|
if (success) {
|
||||||
|
Graph.DataY[PrimaryMarkedPointIndex] = price;
|
||||||
|
PrimaryMarkedPoint.Y = price;
|
||||||
|
SaveButton.IsEnabled = true;
|
||||||
|
ResetButton.IsEnabled = true;
|
||||||
|
OechslePricePlot.Refresh();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void LeftFlatButton_Click(object sender, RoutedEventArgs evt) {
|
||||||
|
if (PrimaryMarkedPointIndex == -1) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
FlattenGraph(0, PrimaryMarkedPointIndex, Graph.DataY[PrimaryMarkedPointIndex]);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void RightFlatButton_Click(object sender, RoutedEventArgs evt) {
|
||||||
|
if (PrimaryMarkedPointIndex == -1) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
FlattenGraph(PrimaryMarkedPointIndex, Graph.DataY.Length - 1, Graph.DataY[PrimaryMarkedPointIndex]);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void InterpolateButton_Click(object sender, RoutedEventArgs evt) {
|
||||||
|
int steps = Math.Abs(PrimaryMarkedPointIndex - SecondaryMarkedPointIndex);
|
||||||
|
if (PrimaryMarkedPointIndex == -1 || SecondaryMarkedPointIndex == -1 || steps < 2) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
var (lowIndex, highIndex) = PrimaryMarkedPointIndex < SecondaryMarkedPointIndex ? (PrimaryMarkedPointIndex, SecondaryMarkedPointIndex): (SecondaryMarkedPointIndex, PrimaryMarkedPointIndex);
|
||||||
|
|
||||||
|
double step = (Graph.DataY[highIndex] - Graph.DataY[lowIndex]) / steps;
|
||||||
|
|
||||||
|
for (int i = lowIndex; i < highIndex - 1; i++) {
|
||||||
|
Graph.DataY[i + 1] = Math.Round(Graph.DataY[i] + step, 4); // TODO richtig runden
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void LinearIncreaseButton_Click(object sender, RoutedEventArgs e) {
|
||||||
|
if (PrimaryMarkedPointIndex == -1) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
double? priceIncrease = Utils.ShowLinearPriceIncreaseDialog();
|
||||||
|
if (priceIncrease == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
LinearIncreaseGraph(PrimaryMarkedPointIndex, Graph.DataY.Length - 1, priceIncrease.Value);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OechslePricePlot_MouseDown(object sender, MouseEventArgs e) {
|
||||||
|
if (!IsCreating && GraphList.SelectedItem == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (HoverActive) {
|
||||||
|
if ((IsEditing || IsCreating) && Keyboard.IsKeyDown(Key.LeftCtrl)) {
|
||||||
|
if (PrimaryMarkedPointIndex == -1) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
SecondaryMarkedPointIndex = HighlightedIndex;
|
||||||
|
ChangeMarker(SecondaryMarkedPoint, true, Graph.DataX[SecondaryMarkedPointIndex], Graph.DataY[SecondaryMarkedPointIndex]);
|
||||||
|
|
||||||
|
InterpolateButton.IsEnabled = true;
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
PrimaryMarkedPointIndex = HighlightedIndex;
|
||||||
|
ChangeMarker(PrimaryMarkedPoint, true, Graph.DataX[PrimaryMarkedPointIndex], Graph.DataY[PrimaryMarkedPointIndex]);
|
||||||
|
|
||||||
|
OechsleInput.Text = Graph.DataX[HighlightedIndex].ToString();
|
||||||
|
PriceInput.Text = Graph.DataY[HighlightedIndex].ToString();
|
||||||
|
|
||||||
|
if (IsEditing || IsCreating) {
|
||||||
|
EnableActionButtons();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
PrimaryMarkedPointIndex = -1;
|
||||||
|
SecondaryMarkedPointIndex = -1;
|
||||||
|
ChangeMarker(PrimaryMarkedPoint, false);
|
||||||
|
ChangeMarker(SecondaryMarkedPoint, false);
|
||||||
|
|
||||||
|
OechsleInput.Text = "";
|
||||||
|
PriceInput.Text = "";
|
||||||
|
|
||||||
|
DisableActionButtons();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OechslePricePlot_MouseMove(object sender, MouseEventArgs e) {
|
||||||
|
if (!IsCreating && GraphList.SelectedItem == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
(double mouseCoordX, double mouseCoordY) = OechslePricePlot.GetMouseCoordinates();
|
||||||
|
double xyRatio = OechslePricePlot.Plot.XAxis.Dims.PxPerUnit / OechslePricePlot.Plot.YAxis.Dims.PxPerUnit;
|
||||||
|
(double pointX, double pointY, int pointIndex) = OechslePricePlotScatter.GetPointNearest(mouseCoordX, mouseCoordY, xyRatio);
|
||||||
|
|
||||||
|
(double mousePixelX, double mousePixelY) = OechslePricePlot.GetMousePixel();
|
||||||
|
(double pointPixelX, double pointPixelY) = OechslePricePlot.Plot.GetPixel(pointX, pointY);
|
||||||
|
|
||||||
|
HighlightedIndex = LastHighlightedIndex;
|
||||||
|
|
||||||
|
if (Math.Abs(mousePixelX - pointPixelX) < 3 && Math.Abs(mousePixelY - pointPixelY) < 3) {
|
||||||
|
ChangeMarker(HighlightedPoint, true, pointX, pointY);
|
||||||
|
HighlightedPoint.IsVisible = true;
|
||||||
|
HoverChanged = true ^ HoverActive;
|
||||||
|
HoverActive = true;
|
||||||
|
} else {
|
||||||
|
ChangeMarker(HighlightedPoint, false);
|
||||||
|
HoverChanged= false ^ HoverActive;
|
||||||
|
HoverActive= false;
|
||||||
|
OechslePricePlot.Plot.Remove(Tooltip);
|
||||||
|
OechslePricePlot.Render();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (LastHighlightedIndex != HighlightedIndex || HoverChanged) {
|
||||||
|
OechslePricePlot.Plot.Remove(Tooltip);
|
||||||
|
if (TooltipInput.IsChecked == true) {
|
||||||
|
Tooltip = OechslePricePlot.Plot.AddTooltip($"Oechsle: {pointX:N2}, Preis: {Math.Round(pointY, 4)})", pointX, pointY);
|
||||||
|
}
|
||||||
|
LastHighlightedIndex = pointIndex;
|
||||||
|
HoverChanged = false;
|
||||||
|
OechslePricePlot.Render();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override protected void UpdateButtons() {
|
||||||
|
if (!IsEditing && !IsCreating) return;
|
||||||
|
bool ch = HasChanged, v = IsValid;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void DisableNewEditDeleteButtons() {
|
||||||
|
NewButton.IsEnabled = false;
|
||||||
|
EditButton.IsEnabled = false;
|
||||||
|
DeleteButton.IsEnabled = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void EnableNewEditDeleteButtons() {
|
||||||
|
NewButton.IsEnabled = true;
|
||||||
|
EditButton.IsEnabled = GraphList.SelectedItem != null;
|
||||||
|
DeleteButton.IsEnabled = GraphList.SelectedItem != null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ShowSaveResetCancelButtons() {
|
||||||
|
SaveButton.IsEnabled = false;
|
||||||
|
ResetButton.IsEnabled = false;
|
||||||
|
CancelButton.IsEnabled = true;
|
||||||
|
SaveButton.Visibility = Visibility.Visible;
|
||||||
|
ResetButton.Visibility = Visibility.Visible;
|
||||||
|
CancelButton.Visibility = Visibility.Visible;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void HideSaveResetCancelButtons() {
|
||||||
|
SaveButton.IsEnabled = false;
|
||||||
|
ResetButton.IsEnabled = false;
|
||||||
|
CancelButton.IsEnabled = false;
|
||||||
|
SaveButton.Visibility = Visibility.Hidden;
|
||||||
|
ResetButton.Visibility = Visibility.Hidden;
|
||||||
|
CancelButton.Visibility = Visibility.Hidden;
|
||||||
|
}
|
||||||
|
private void ShowNewEditDeleteButtons() {
|
||||||
|
EnableNewEditDeleteButtons();
|
||||||
|
NewButton.Visibility = Visibility.Visible;
|
||||||
|
EditButton.Visibility = Visibility.Visible;
|
||||||
|
DeleteButton.Visibility = Visibility.Visible;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void HideNewEditDeleteButtons() {
|
||||||
|
DisableNewEditDeleteButtons();
|
||||||
|
NewButton.Visibility = Visibility.Hidden;
|
||||||
|
EditButton.Visibility = Visibility.Hidden;
|
||||||
|
DeleteButton.Visibility = Visibility.Hidden;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void NewButton_Click(object sender, RoutedEventArgs e) {
|
||||||
|
IsCreating = true;
|
||||||
|
GraphList.IsEnabled = false;
|
||||||
|
GraphList.SelectedItem = null;
|
||||||
|
HideNewEditDeleteButtons();
|
||||||
|
ShowSaveResetCancelButtons();
|
||||||
|
UnlockInputs();
|
||||||
|
PriceInput.IsReadOnly = false;
|
||||||
|
OechsleInput.IsReadOnly = false;
|
||||||
|
InitInputs();
|
||||||
|
FillInputs(new Graph(GraphList.Items.Count + 1, MinOechsle, MaxOechsle));
|
||||||
|
EnableOptionButtons();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void EditButton_Click(object sender, RoutedEventArgs e) {
|
||||||
|
if (GraphList.SelectedItem == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
IsEditing = true;
|
||||||
|
GraphList.IsEnabled = false;
|
||||||
|
|
||||||
|
HideNewEditDeleteButtons();
|
||||||
|
ShowSaveResetCancelButtons();
|
||||||
|
UnlockInputs();
|
||||||
|
PriceInput.IsReadOnly = false;
|
||||||
|
OechsleInput.IsReadOnly = false;
|
||||||
|
if (PrimaryMarkedPointIndex != -1) EnableActionButtons();
|
||||||
|
}
|
||||||
|
|
||||||
|
private async void DeleteButton_Click(object sender, RoutedEventArgs e) {
|
||||||
|
Graph g = (Graph)GraphList.SelectedItem;
|
||||||
|
if (g == null) return;
|
||||||
|
|
||||||
|
var r = MessageBox.Show(
|
||||||
|
$"Soll der Graph {g.Num} (verwendet in folgenden Verträgen: {g.Contracts}) wirklich unwiderruflich gelöscht werden?",
|
||||||
|
"Graph löschen", MessageBoxButton.YesNo, MessageBoxImage.Warning, MessageBoxResult.No);
|
||||||
|
if (r == MessageBoxResult.Yes) {
|
||||||
|
bool success = await RemoveGraph(g.Num);
|
||||||
|
if (!success) {
|
||||||
|
MessageBox.Show("Der Graph konnte nicht gelöscht werden", "Graph löschen", MessageBoxButton.OK, MessageBoxImage.Error);
|
||||||
|
}
|
||||||
|
await RefreshGraphList();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private async void SaveButton_Click(object sender, RoutedEventArgs e) {
|
||||||
|
int? index = await UpdateGraph(Graph);
|
||||||
|
if (index == null) {
|
||||||
|
MessageBox.Show("Der Graph konnte nicht gespeichert werden", "Graph speichern", MessageBoxButton.OK, MessageBoxImage.Error);
|
||||||
|
}
|
||||||
|
IsEditing = false;
|
||||||
|
IsCreating = false;
|
||||||
|
GraphList.IsEnabled = true;
|
||||||
|
HideSaveResetCancelButtons();
|
||||||
|
ShowNewEditDeleteButtons();
|
||||||
|
LockInputs();
|
||||||
|
PriceInput.IsReadOnly = true;
|
||||||
|
OechsleInput.IsReadOnly = true;
|
||||||
|
await RefreshGraphList();
|
||||||
|
GraphList.SelectedIndex = index.Value;
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task<int?> UpdateGraph(Graph g) {
|
||||||
|
List<PaymentVar> paymentVars = await Context.PaymentVariants.Where(p => p.Year == Year && p.AvNr == AvNr).ToListAsync();
|
||||||
|
|
||||||
|
if (paymentVars.Count != 1) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
PaymentVar paymentVar = paymentVars[0];
|
||||||
|
var data = JToken.Parse(paymentVar.Data);
|
||||||
|
|
||||||
|
var auszahlungsSorten = data["AuszahlungSorten"];
|
||||||
|
if (auszahlungsSorten == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
var Graphs = auszahlungsSorten["Kurven"];
|
||||||
|
|
||||||
|
if (Graphs == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (IsEditing) {
|
||||||
|
((JArray)Graphs)[g.Num - 1] = g.ToJson();
|
||||||
|
} else if(IsCreating) {
|
||||||
|
((JArray)Graphs).Add(g.ToJson());
|
||||||
|
} else {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
EntityEntry<PaymentVar>? tr = null;
|
||||||
|
try {
|
||||||
|
paymentVar.Data = data.ToString();
|
||||||
|
tr = Context.Update(paymentVar);
|
||||||
|
|
||||||
|
await Context.SaveChangesAsync();
|
||||||
|
} catch (Exception exc) {
|
||||||
|
if (tr != null) await tr.ReloadAsync();
|
||||||
|
var str = "Der Eintrag konnte nicht in der Datenbank gelöscht werden!\n\n" + exc.Message;
|
||||||
|
if (exc.InnerException != null) str += "\n\n" + exc.InnerException.Message;
|
||||||
|
MessageBox.Show(str, "Graph löschen", MessageBoxButton.OK, MessageBoxImage.Error);
|
||||||
|
}
|
||||||
|
|
||||||
|
return g.Num - 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ResetButton_Click(object sender, RoutedEventArgs e) {
|
||||||
|
if (IsEditing) {
|
||||||
|
RefreshInputs();
|
||||||
|
} else if (IsCreating) {
|
||||||
|
InitInputs();
|
||||||
|
}
|
||||||
|
UpdateButtons();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void CancelButton_Click(object sender, RoutedEventArgs e) {
|
||||||
|
IsEditing = false;
|
||||||
|
IsCreating = false;
|
||||||
|
GraphList.IsEnabled = true;
|
||||||
|
HideSaveResetCancelButtons();
|
||||||
|
ShowNewEditDeleteButtons();
|
||||||
|
DisableActionButtons();
|
||||||
|
RefreshInputs();
|
||||||
|
PriceInput.Text = "";
|
||||||
|
OechsleInput.Text = "";
|
||||||
|
ClearInputStates();
|
||||||
|
LockInputs();
|
||||||
|
PriceInput.IsReadOnly = true;
|
||||||
|
OechsleInput.IsReadOnly = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void GraphList_SelectionChanged(object sender, System.Windows.Controls.SelectionChangedEventArgs e) {
|
||||||
|
RefreshInputs();
|
||||||
|
|
||||||
|
//var x = OechslePricePlot.Plot.GetPlottables().OfType<ScatterPlot>();
|
||||||
|
//MessageBox.Show($"SelectionChanged\nLength: {x.ToList().Count}, Ys: {string.Join(", ", ((ScatterPlot)x.First()).Ys)}");
|
||||||
|
}
|
||||||
|
|
||||||
|
private void PriceInput_LostFocus(object sender, RoutedEventArgs e) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OechsleInput_LostFocus(object sender, RoutedEventArgs e) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private void GraphNumberInput_TextChanged(object sender, TextChangedEventArgs e) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private void GraphNumberInput_LostFocus(object sender, RoutedEventArgs e) {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@@ -1,12 +0,0 @@
|
|||||||
<local:AdministrationWindow x:Class="Elwig.Windows.ClientParamWindow"
|
|
||||||
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"
|
|
||||||
mc:Ignorable="d"
|
|
||||||
Title="ClientParamWindow" Height="450" Width="800">
|
|
||||||
<Grid>
|
|
||||||
|
|
||||||
</Grid>
|
|
||||||
</local:AdministrationWindow>
|
|
@@ -1,18 +0,0 @@
|
|||||||
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace Elwig.Windows {
|
|
||||||
public partial class ClientParamWindow : AdministrationWindow {
|
|
||||||
public ClientParamWindow() {
|
|
||||||
InitializeComponent();
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override void UpdateButtons() {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override async Task RenewContext() {
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@@ -64,6 +64,10 @@
|
|||||||
<MenuItem x:Name="Menu_Print_PrintDeliveryNote" Header="Lieferschein drucken" IsEnabled="False"
|
<MenuItem x:Name="Menu_Print_PrintDeliveryNote" Header="Lieferschein drucken" IsEnabled="False"
|
||||||
Click="Menu_Print_PrintDeliveryNote_Click"/>
|
Click="Menu_Print_PrintDeliveryNote_Click"/>
|
||||||
</MenuItem>
|
</MenuItem>
|
||||||
|
<MenuItem Header="Exportieren">
|
||||||
|
<MenuItem x:Name="Menu_Export_Bki" Header="Traubentransportscheinliste (BKI)"
|
||||||
|
Click="Menu_Export_Bki_Click"/>
|
||||||
|
</MenuItem>
|
||||||
<MenuItem Header="Werkzeuge">
|
<MenuItem Header="Werkzeuge">
|
||||||
<MenuItem Header="Alle Lieferscheine überprüfen"/>
|
<MenuItem Header="Alle Lieferscheine überprüfen"/>
|
||||||
</MenuItem>
|
</MenuItem>
|
||||||
@@ -192,7 +196,8 @@
|
|||||||
DisplayMemberPath="Name" TextSearch.TextPath="Name"/>
|
DisplayMemberPath="Name" TextSearch.TextPath="Name"/>
|
||||||
|
|
||||||
<Label Content="Anmerkung:" Margin="10,100,0,10"/>
|
<Label Content="Anmerkung:" Margin="10,100,0,10"/>
|
||||||
<TextBox x:Name="CommentInput" Grid.Column="1" Margin="0,100,10,10"/>
|
<TextBox x:Name="CommentInput" Grid.Column="1" Margin="0,100,10,10"
|
||||||
|
TextChanged="TextBox_TextChanged"/>
|
||||||
</Grid>
|
</Grid>
|
||||||
</GroupBox>
|
</GroupBox>
|
||||||
|
|
||||||
@@ -261,10 +266,12 @@
|
|||||||
</Grid>
|
</Grid>
|
||||||
|
|
||||||
<CheckBox x:Name="ManualWeighingInput" Content="Handwiegung" IsEnabled="False"
|
<CheckBox x:Name="ManualWeighingInput" 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,45,10,10" Grid.Column="0" Grid.ColumnSpan="2"
|
||||||
|
Checked="CheckBox_Changed" Unchecked="CheckBox_Changed"/>
|
||||||
|
|
||||||
<CheckBox x:Name="GerebeltGewogenInput" Content="Gerebelt gewogen"
|
<CheckBox x:Name="GerebeltGewogenInput" Content="Gerebelt gewogen"
|
||||||
VerticalAlignment="Top" HorizontalAlignment="Left" Margin="10,75,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"/>
|
||||||
|
|
||||||
<Button x:Name="WeighingManualButton" Content="Handwiegung" Width="120"
|
<Button x:Name="WeighingManualButton" Content="Handwiegung" Width="120"
|
||||||
Click="WeighingManualButton_Click"
|
Click="WeighingManualButton_Click"
|
||||||
@@ -299,24 +306,29 @@
|
|||||||
ItemSelectionChanged="ModifiersInput_SelectionChanged"/>
|
ItemSelectionChanged="ModifiersInput_SelectionChanged"/>
|
||||||
|
|
||||||
<Label Content="Anmerkung:" Margin="10,40,0,10"/>
|
<Label Content="Anmerkung:" Margin="10,40,0,10"/>
|
||||||
<TextBox x:Name="PartCommentInput" Grid.Column="1" Margin="0,40,10,10" Grid.ColumnSpan="2"/>
|
<TextBox x:Name="PartCommentInput" Grid.Column="1" Margin="0,40,10,10" Grid.ColumnSpan="2"
|
||||||
|
TextChanged="TextBox_TextChanged"/>
|
||||||
|
|
||||||
<Label Content="Temperatur:" Margin="10,70,0,10"/>
|
<Label Content="Temperatur:" Margin="10,70,0,10"/>
|
||||||
<Grid Grid.Column="1" Height="25" Margin="0,70,10,10" VerticalAlignment="Top">
|
<Grid Grid.Column="1" Height="25" Margin="0,70,10,10" VerticalAlignment="Top">
|
||||||
<TextBox x:Name="TemperatureInput" TextAlignment="Right" Padding="2,2,16,2"/>
|
<TextBox x:Name="TemperatureInput" TextAlignment="Right" Padding="2,2,16,2"
|
||||||
|
TextChanged="TemperatureAcidInput_TextChanged" LostFocus="TemperatureAcidInput_LostFocus"/>
|
||||||
<Label Content="°C" Margin="0,4,3,0" HorizontalAlignment="Right" FontSize="10"/>
|
<Label Content="°C" Margin="0,4,3,0" HorizontalAlignment="Right" FontSize="10"/>
|
||||||
</Grid>
|
</Grid>
|
||||||
|
|
||||||
<Label Content="Säure:" Margin="10,100,0,10"/>
|
<Label Content="Säure:" Margin="10,100,0,10"/>
|
||||||
<Grid Grid.Column="1" Height="25" Margin="0,100,10,10" VerticalAlignment="Top">
|
<Grid Grid.Column="1" Height="25" Margin="0,100,10,10" VerticalAlignment="Top">
|
||||||
<TextBox x:Name="AcidInput" TextAlignment="Right" Padding="2,2,19,2"/>
|
<TextBox x:Name="AcidInput" TextAlignment="Right" Padding="2,2,19,2"
|
||||||
|
TextChanged="TemperatureAcidInput_TextChanged" LostFocus="TemperatureAcidInput_LostFocus"/>
|
||||||
<Label Content="g/l" Margin="0,4,3,0" HorizontalAlignment="Right" FontSize="10"/>
|
<Label Content="g/l" Margin="0,4,3,0" HorizontalAlignment="Right" FontSize="10"/>
|
||||||
</Grid>
|
</Grid>
|
||||||
|
|
||||||
<CheckBox x:Name="LesewagenInput" Content="Lesewagen" Margin="10,75,0,0" Grid.Column="2"
|
<CheckBox x:Name="LesewagenInput" Content="Lesewagen" Margin="10,75,0,0" Grid.Column="2"
|
||||||
VerticalAlignment="Top" HorizontalAlignment="Left"/>
|
VerticalAlignment="Top" HorizontalAlignment="Left"
|
||||||
|
Checked="LesewagenInput_Changed" Unchecked="LesewagenInput_Changed"/>
|
||||||
<CheckBox x:Name="HandPickedInput" Content="Handlese" Margin="10,105,0,0" Grid.Column="2" IsThreeState="True"
|
<CheckBox x:Name="HandPickedInput" Content="Handlese" Margin="10,105,0,0" Grid.Column="2" IsThreeState="True"
|
||||||
VerticalAlignment="Top" HorizontalAlignment="Left"/>
|
VerticalAlignment="Top" HorizontalAlignment="Left"
|
||||||
|
Checked="CheckBox_Changed" Unchecked="CheckBox_Changed"/>
|
||||||
</Grid>
|
</Grid>
|
||||||
</GroupBox>
|
</GroupBox>
|
||||||
|
|
||||||
@@ -341,7 +353,7 @@
|
|||||||
</ListBox.ItemTemplate>
|
</ListBox.ItemTemplate>
|
||||||
</ListBox>
|
</ListBox>
|
||||||
|
|
||||||
<Button x:Name="ExtractDeliveryPartButton" Content="Herausheben" IsEnabled="False"
|
<Button x:Name="ExtractDeliveryPartButton" Content="Extrahieren" IsEnabled="False"
|
||||||
ToolTip="Ausgewählte Teillieferung aus aktueller Lieferung entfernen und entweder anderer oder neuer Lieferung zuordnen"
|
ToolTip="Ausgewählte Teillieferung aus aktueller Lieferung entfernen und entweder anderer oder neuer Lieferung zuordnen"
|
||||||
HorizontalAlignment="Stretch" VerticalAlignment="Bottom" Margin="5,10,2.5,5" Grid.Column="0" Grid.Row="2"
|
HorizontalAlignment="Stretch" VerticalAlignment="Bottom" Margin="5,10,2.5,5" Grid.Column="0" Grid.Row="2"
|
||||||
Click="ExtractDeliveryPartButton_Click"/>
|
Click="ExtractDeliveryPartButton_Click"/>
|
||||||
|
@@ -26,7 +26,7 @@ namespace Elwig.Windows {
|
|||||||
private string? ManualWeighingReason = null;
|
private string? ManualWeighingReason = null;
|
||||||
private string? ScaleId = null;
|
private string? ScaleId = null;
|
||||||
private string? WeighingId = null;
|
private string? WeighingId = null;
|
||||||
private Button[] WeighingButtons;
|
private readonly Button[] WeighingButtons;
|
||||||
|
|
||||||
public DeliveryAdminWindow(bool receipt = false) {
|
public DeliveryAdminWindow(bool receipt = false) {
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
@@ -67,6 +67,10 @@ namespace Elwig.Windows {
|
|||||||
if (n < 3) WeighingCButton.Visibility = Visibility.Hidden;
|
if (n < 3) WeighingCButton.Visibility = Visibility.Hidden;
|
||||||
if (n < 4) WeighingDButton.Visibility = Visibility.Hidden;
|
if (n < 4) WeighingDButton.Visibility = Visibility.Hidden;
|
||||||
if (n == 1) WeighingAButton.Content = "Wiegen";
|
if (n == 1) WeighingAButton.Content = "Wiegen";
|
||||||
|
if (n > 1) WeighingAButton.Content = $"Wiegen {App.Scales[0].ScaleId}";
|
||||||
|
if (n >= 2) WeighingBButton.Content = $"Wiegen {App.Scales[1].ScaleId}";
|
||||||
|
if (n >= 3) WeighingCButton.Content = $"Wiegen {App.Scales[2].ScaleId}";
|
||||||
|
if (n >= 4) WeighingDButton.Content = $"Wiegen {App.Scales[3].ScaleId}";
|
||||||
} else {
|
} else {
|
||||||
WeighingManualButton.Visibility = Visibility.Hidden;
|
WeighingManualButton.Visibility = Visibility.Hidden;
|
||||||
WeighingAButton.Visibility = Visibility.Hidden;
|
WeighingAButton.Visibility = Visibility.Hidden;
|
||||||
@@ -98,18 +102,22 @@ namespace Elwig.Windows {
|
|||||||
|
|
||||||
private async void Menu_Print_ShowDeliveryNote_Click(object sender, RoutedEventArgs evt) {
|
private async void Menu_Print_ShowDeliveryNote_Click(object sender, RoutedEventArgs evt) {
|
||||||
if (DeliveryList.SelectedItem is not Delivery d) return;
|
if (DeliveryList.SelectedItem is not Delivery d) return;
|
||||||
using var doc = new DeliveryNote(d);
|
using var doc = new DeliveryNote(d, Context);
|
||||||
await doc.Generate();
|
await doc.Generate();
|
||||||
doc.Show();
|
doc.Show();
|
||||||
}
|
}
|
||||||
|
|
||||||
private async void Menu_Print_PrintDeliveryNote_Click(object sender, RoutedEventArgs evt) {
|
private async void Menu_Print_PrintDeliveryNote_Click(object sender, RoutedEventArgs evt) {
|
||||||
if (DeliveryList.SelectedItem is not Delivery d) return;
|
if (DeliveryList.SelectedItem is not Delivery d) return;
|
||||||
using var doc = new DeliveryNote(d);
|
using var doc = new DeliveryNote(d, Context);
|
||||||
await doc.Generate();
|
await doc.Generate();
|
||||||
await doc.Print();
|
await doc.Print();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void Menu_Export_Bki_Click(object sender, RoutedEventArgs evt) {
|
||||||
|
// TODO export Traubentransportscheinliste
|
||||||
|
}
|
||||||
|
|
||||||
private void OnSecondPassed(object? sender, EventArgs? evt) {
|
private void OnSecondPassed(object? sender, EventArgs? evt) {
|
||||||
if (IsReceipt && IsCreating) {
|
if (IsReceipt && IsCreating) {
|
||||||
var now = DateTime.Now;
|
var now = DateTime.Now;
|
||||||
@@ -119,15 +127,21 @@ namespace Elwig.Windows {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void InitialInputs() {
|
private void InitialInputs() {
|
||||||
|
ClearOriginalValues();
|
||||||
|
ClearDefaultValues();
|
||||||
|
|
||||||
HandPickedInput.IsChecked = null;
|
HandPickedInput.IsChecked = null;
|
||||||
if (App.Client.Client == ClientParameters.Type.Matzen) {
|
if (App.Client.IsMatzen) {
|
||||||
GerebeltGewogenInput.IsChecked = true;
|
GerebeltGewogenInput.IsChecked = true;
|
||||||
GerebeltGewogenInput.IsEnabled = false;
|
GerebeltGewogenInput.IsEnabled = false;
|
||||||
|
SetDefaultValue(GerebeltGewogenInput);
|
||||||
} else {
|
} else {
|
||||||
GerebeltGewogenInput.IsChecked = false;
|
GerebeltGewogenInput.IsChecked = false;
|
||||||
GerebeltGewogenInput.IsEnabled = true;
|
GerebeltGewogenInput.IsEnabled = true;
|
||||||
|
UnsetDefaultValue(GerebeltGewogenInput);
|
||||||
}
|
}
|
||||||
ClearOriginalValues();
|
|
||||||
|
SetDefaultValue(HandPickedInput);
|
||||||
ValidateRequiredInputs();
|
ValidateRequiredInputs();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -252,6 +266,8 @@ namespace Elwig.Windows {
|
|||||||
filter.RemoveAt(i--);
|
filter.RemoveAt(i--);
|
||||||
} else if (e.Length > 2 && e.StartsWith("\"") && e.EndsWith("\"")) {
|
} else if (e.Length > 2 && e.StartsWith("\"") && e.EndsWith("\"")) {
|
||||||
filter[i] = e[1..^1];
|
filter[i] = e[1..^1];
|
||||||
|
} else if (e.Length <= 2) {
|
||||||
|
filter.RemoveAt(i--);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -272,7 +288,7 @@ namespace Elwig.Windows {
|
|||||||
|
|
||||||
List<Delivery> deliveries = await deliveryQuery.OrderByDescending(d => d.DateString).ThenByDescending(d => d.TimeString).ToListAsync();
|
List<Delivery> deliveries = await deliveryQuery.OrderByDescending(d => d.DateString).ThenByDescending(d => d.TimeString).ToListAsync();
|
||||||
if (filter.Count > 0 && deliveries.Count > 0) {
|
if (filter.Count > 0 && deliveries.Count > 0) {
|
||||||
var dict = deliveries
|
var dict = deliveries.AsParallel()
|
||||||
.ToDictionary(d => d, d => d.SearchScore(TextFilter))
|
.ToDictionary(d => d, d => d.SearchScore(TextFilter))
|
||||||
.OrderByDescending(a => a.Value)
|
.OrderByDescending(a => a.Value)
|
||||||
.ThenBy(a => a.Key.DateTime);
|
.ThenBy(a => a.Key.DateTime);
|
||||||
@@ -372,7 +388,7 @@ namespace Elwig.Windows {
|
|||||||
ControlUtils.RenewItemsSource(MemberInput, await Context.Members.OrderBy(m => m.FamilyName).ThenBy(m => m.GivenName).ToListAsync(), i => (i as Member)?.MgNr);
|
ControlUtils.RenewItemsSource(MemberInput, await Context.Members.OrderBy(m => m.FamilyName).ThenBy(m => m.GivenName).ToListAsync(), i => (i as Member)?.MgNr);
|
||||||
ControlUtils.RenewItemsSource(BranchInput, await Context.Branches.OrderBy(b => b.Name).ToListAsync(), i => (i as Branch)?.ZwstId);
|
ControlUtils.RenewItemsSource(BranchInput, await Context.Branches.OrderBy(b => b.Name).ToListAsync(), i => (i as Branch)?.ZwstId);
|
||||||
ControlUtils.RenewItemsSource(WineVarietyInput, await Context.WineVarieties.OrderBy(v => v.Name).ToListAsync(), i => (i as WineVar)?.SortId);
|
ControlUtils.RenewItemsSource(WineVarietyInput, await Context.WineVarieties.OrderBy(v => v.Name).ToListAsync(), i => (i as WineVar)?.SortId);
|
||||||
ControlUtils.RenewItemsSource(AttributesInput, await Context.WineAttributes.OrderBy(a => a.Name).ToListAsync(), i => (i as WineAttr)?.AttrId);
|
ControlUtils.RenewItemsSource(AttributesInput, await Context.WineAttributes.Where(a => IsCreating || a.IsActive).OrderBy(a => a.Name).ToListAsync(), i => (i as WineAttr)?.AttrId);
|
||||||
ControlUtils.RenewItemsSource(WineQualityLevelInput, await Context.WineQualityLevels.ToListAsync(), i => (i as WineQualLevel)?.QualId);
|
ControlUtils.RenewItemsSource(WineQualityLevelInput, await Context.WineQualityLevels.ToListAsync(), i => (i as WineQualLevel)?.QualId);
|
||||||
ControlUtils.RenewItemsSource(ModifiersInput, await Context.Modifiers.Where(m => m.Year == y).OrderBy(m => m.Ordering).ToListAsync(), i => (i as Modifier)?.ModId);
|
ControlUtils.RenewItemsSource(ModifiersInput, await Context.Modifiers.Where(m => m.Year == y).OrderBy(m => m.Ordering).ToListAsync(), i => (i as Modifier)?.ModId);
|
||||||
ControlUtils.RenewItemsSource(WineOriginInput, (await Context.WineOrigins.ToListAsync()).OrderByDescending(o => o.SortKey).ThenBy(o => o.HkId), i => (i as WineOrigin)?.HkId);
|
ControlUtils.RenewItemsSource(WineOriginInput, (await Context.WineOrigins.ToListAsync()).OrderByDescending(o => o.SortKey).ThenBy(o => o.HkId), i => (i as WineOrigin)?.HkId);
|
||||||
@@ -380,8 +396,9 @@ namespace Elwig.Windows {
|
|||||||
kgList.Insert(0, new NullItem());
|
kgList.Insert(0, new NullItem());
|
||||||
ControlUtils.RenewItemsSource(WineKgInput, kgList, i => (i as AT_Kg)?.KgNr);
|
ControlUtils.RenewItemsSource(WineKgInput, kgList, i => (i as AT_Kg)?.KgNr);
|
||||||
UpdateRdInput();
|
UpdateRdInput();
|
||||||
|
|
||||||
if (IsCreating) await UpdateLsNr();
|
if (IsCreating) await UpdateLsNr();
|
||||||
|
|
||||||
|
await RefreshDeliveryParts();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void FocusSearchInput(object sender, RoutedEventArgs evt) {
|
private void FocusSearchInput(object sender, RoutedEventArgs evt) {
|
||||||
@@ -391,12 +408,12 @@ namespace Elwig.Windows {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void RefreshDeliveryParts() {
|
private async Task RefreshDeliveryParts() {
|
||||||
if (DeliveryList.SelectedItem is Delivery d) {
|
if (DeliveryList.SelectedItem is Delivery d) {
|
||||||
ControlUtils.RenewItemsSource(ModifiersInput, Context.Modifiers.Where(m => m.Year == d.Year).OrderBy(m => m.Ordering).ToList(), i => (i as Modifier)?.ModId);
|
ControlUtils.RenewItemsSource(ModifiersInput, await Context.Modifiers.Where(m => m.Year == d.Year).OrderBy(m => m.Ordering).ToListAsync(), i => (i as Modifier)?.ModId);
|
||||||
ControlUtils.RenewItemsSource(DeliveryPartList, d.Parts.OrderBy(p => p.DPNr).ToList(), i => ((i as DeliveryPart)?.Year, (i as DeliveryPart)?.DId, (i as DeliveryPart)?.DPNr), DeliveryPartList_SelectionChanged, ControlUtils.RenewSourceDefault.First);
|
ControlUtils.RenewItemsSource(DeliveryPartList, d.Parts.OrderBy(p => p.DPNr).ToList(), i => ((i as DeliveryPart)?.Year, (i as DeliveryPart)?.DId, (i as DeliveryPart)?.DPNr), DeliveryPartList_SelectionChanged, ControlUtils.RenewSourceDefault.First);
|
||||||
} else {
|
} else {
|
||||||
ControlUtils.RenewItemsSource(ModifiersInput, Context.Modifiers.Where(m => m.Year == Utils.CurrentLastSeason).OrderBy(m => m.Ordering).ToList(), i => (i as Modifier)?.ModId);
|
ControlUtils.RenewItemsSource(ModifiersInput, await Context.Modifiers.Where(m => m.Year == Utils.CurrentLastSeason).OrderBy(m => m.Ordering).ToListAsync(), i => (i as Modifier)?.ModId);
|
||||||
DeliveryPartList.ItemsSource = null;
|
DeliveryPartList.ItemsSource = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -409,6 +426,7 @@ namespace Elwig.Windows {
|
|||||||
FillInputs(d);
|
FillInputs(d);
|
||||||
} else {
|
} else {
|
||||||
ClearOriginalValues();
|
ClearOriginalValues();
|
||||||
|
ClearDefaultValues();
|
||||||
ClearInputs(validate);
|
ClearInputs(validate);
|
||||||
ClearInputStates();
|
ClearInputStates();
|
||||||
}
|
}
|
||||||
@@ -417,6 +435,7 @@ namespace Elwig.Windows {
|
|||||||
|
|
||||||
private void FillInputs(Delivery d) {
|
private void FillInputs(Delivery d) {
|
||||||
ClearOriginalValues();
|
ClearOriginalValues();
|
||||||
|
ClearDefaultValues();
|
||||||
|
|
||||||
MgNrInput.Text = d.MgNr.ToString();
|
MgNrInput.Text = d.MgNr.ToString();
|
||||||
ControlUtils.SelectComboBoxItem(BranchInput, i => (i as Branch)?.ZwstId, d.ZwstId);
|
ControlUtils.SelectComboBoxItem(BranchInput, i => (i as Branch)?.ZwstId, d.ZwstId);
|
||||||
@@ -433,12 +452,13 @@ namespace Elwig.Windows {
|
|||||||
TemperatureInput.Text = "";
|
TemperatureInput.Text = "";
|
||||||
AcidInput.Text = "";
|
AcidInput.Text = "";
|
||||||
|
|
||||||
FillOriginalValues();
|
FinishInputFilling();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void FillInputs(DeliveryPart p) {
|
private void FillInputs(DeliveryPart p) {
|
||||||
ClearOriginalValues();
|
|
||||||
FillInputs(p.Delivery);
|
FillInputs(p.Delivery);
|
||||||
|
ClearOriginalValues();
|
||||||
|
ClearDefaultValues();
|
||||||
|
|
||||||
SortIdInput.Text = p?.SortId ?? "";
|
SortIdInput.Text = p?.SortId ?? "";
|
||||||
ControlUtils.SelectCheckComboBoxItems(AttributesInput, p?.Attributes, i => (i as WineAttr)?.AttrId);
|
ControlUtils.SelectCheckComboBoxItems(AttributesInput, p?.Attributes, i => (i as WineAttr)?.AttrId);
|
||||||
@@ -457,12 +477,17 @@ namespace Elwig.Windows {
|
|||||||
LesewagenInput.IsChecked = p?.IsLesewagen ?? false;
|
LesewagenInput.IsChecked = p?.IsLesewagen ?? false;
|
||||||
HandPickedInput.IsChecked = p?.IsHandPicked;
|
HandPickedInput.IsChecked = p?.IsHandPicked;
|
||||||
|
|
||||||
FillOriginalValues();
|
ScaleId = p?.ScaleId;
|
||||||
|
WeighingId = p?.WeighingId;
|
||||||
|
|
||||||
|
FinishInputFilling();
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task<DeliveryPart> UpdateDeliveryPart(Delivery? d, DeliveryPart? p) {
|
private async Task<DeliveryPart> UpdateDeliveryPart(Delivery? d, DeliveryPart? p) {
|
||||||
int year, did, dpnr;
|
int year, did, dpnr;
|
||||||
bool deliveryNew = (d == null), partNew = (p == null);
|
bool deliveryNew = (d == null), partNew = (p == null);
|
||||||
|
var originalMgNr = d?.MgNr;
|
||||||
|
var originalMemberKgNr = d?.Member?.DefaultKgNr;
|
||||||
if (d == null) {
|
if (d == null) {
|
||||||
d = Context.CreateProxy<Delivery>();
|
d = Context.CreateProxy<Delivery>();
|
||||||
year = Utils.CurrentNextSeason;
|
year = Utils.CurrentNextSeason;
|
||||||
@@ -518,8 +543,6 @@ namespace Elwig.Windows {
|
|||||||
if (ManualWeighingReason != null)
|
if (ManualWeighingReason != null)
|
||||||
p.Comment = (p.Comment != null ? $"{p.Comment} / " : "") + $"Begründung Handwiegung: {ManualWeighingReason}";
|
p.Comment = (p.Comment != null ? $"{p.Comment} / " : "") + $"Begründung Handwiegung: {ManualWeighingReason}";
|
||||||
|
|
||||||
// TODO update KgNr when MgNr changes (if default is selected)
|
|
||||||
|
|
||||||
EntityEntry<Delivery>? dEntry = null;
|
EntityEntry<Delivery>? dEntry = null;
|
||||||
EntityEntry<DeliveryPart>? pEntry = null;
|
EntityEntry<DeliveryPart>? pEntry = null;
|
||||||
try {
|
try {
|
||||||
@@ -531,55 +554,27 @@ namespace Elwig.Windows {
|
|||||||
pEntry = partNew ? await Context.AddAsync(p) : Context.Update(p);
|
pEntry = partNew ? await Context.AddAsync(p) : Context.Update(p);
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (var a in AttributesInput.ItemsSource.Cast<WineAttr>()) {
|
await Context.UpdateDeliveryPartAttributes(p, AttributesInput.SelectedItems.Cast<WineAttr>());
|
||||||
var attr = p.PartAttributes.Where(pa => pa.AttrId == a.AttrId).FirstOrDefault();
|
await Context.UpdateDeliveryPartModifiers(p, ModifiersInput.SelectedItems.Cast<Modifier>());
|
||||||
if (AttributesInput.SelectedItems.Contains(a)) {
|
|
||||||
DeliveryPartAttr dpa = attr ?? Context.CreateProxy<DeliveryPartAttr>();
|
|
||||||
dpa.Year = year;
|
|
||||||
dpa.DId = did;
|
|
||||||
dpa.DPNr = dpnr;
|
|
||||||
dpa.AttrId = a.AttrId;
|
|
||||||
if (attr == null) {
|
|
||||||
await Context.AddAsync(dpa);
|
|
||||||
} else {
|
|
||||||
Context.Update(dpa);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (attr != null) {
|
|
||||||
Context.Remove(attr);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach (var m in ModifiersInput.ItemsSource.Cast<Modifier>()) {
|
if (originalMgNr != null && originalMgNr.Value != d.MgNr) {
|
||||||
var mod = p.PartModifiers.Where(pa => pa.ModId == m.ModId).FirstOrDefault();
|
// update origin (KgNr), if default is selected
|
||||||
if (ModifiersInput.SelectedItems.Contains(m)) {
|
var newKgNr = (await Context.Members.FindAsync(d.MgNr))?.DefaultKgNr;
|
||||||
DeliveryPartModifier dpm = mod ?? Context.CreateProxy<DeliveryPartModifier>();
|
foreach (var part in d.Parts.Where(part => part.DPNr != dpnr && part.KgNr == originalMemberKgNr)) {
|
||||||
dpm.Year = year;
|
part.KgNr = newKgNr;
|
||||||
dpm.DId = did;
|
Context.Update(part);
|
||||||
dpm.DPNr = dpnr;
|
|
||||||
dpm.ModId = m.ModId;
|
|
||||||
if (mod == null) {
|
|
||||||
await Context.AddAsync(dpm);
|
|
||||||
} else {
|
|
||||||
Context.Update(dpm);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (mod != null) {
|
|
||||||
Context.Remove(mod);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
await Context.SaveChangesAsync();
|
await Context.SaveChangesAsync();
|
||||||
} catch (Exception exc) {
|
} catch (Exception exc) {
|
||||||
if (dEntry != null) {
|
if (dEntry != null) {
|
||||||
|
dEntry.State = EntityState.Detached;
|
||||||
await dEntry.ReloadAsync();
|
await dEntry.ReloadAsync();
|
||||||
if (deliveryNew) dEntry.State = EntityState.Detached;
|
|
||||||
}
|
}
|
||||||
if (pEntry != null) {
|
if (pEntry != null) {
|
||||||
|
pEntry.State = EntityState.Detached;
|
||||||
await pEntry.ReloadAsync();
|
await pEntry.ReloadAsync();
|
||||||
if (partNew) pEntry.State = EntityState.Detached;
|
|
||||||
}
|
}
|
||||||
var str = "Der Eintrag konnte nicht in der Datenbank aktualisiert werden!\n\n" + exc.Message;
|
var str = "Der Eintrag konnte nicht in der Datenbank aktualisiert werden!\n\n" + exc.Message;
|
||||||
if (exc.InnerException != null) str += "\n\n" + exc.InnerException.Message;
|
if (exc.InnerException != null) str += "\n\n" + exc.InnerException.Message;
|
||||||
@@ -655,8 +650,8 @@ namespace Elwig.Windows {
|
|||||||
await RefreshDeliveryListQuery();
|
await RefreshDeliveryListQuery();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void DeliveryList_SelectionChanged(object sender, SelectionChangedEventArgs evt) {
|
private async void DeliveryList_SelectionChanged(object sender, SelectionChangedEventArgs evt) {
|
||||||
RefreshDeliveryParts();
|
await RefreshDeliveryParts();
|
||||||
if (DeliveryList.SelectedItem != null) {
|
if (DeliveryList.SelectedItem != null) {
|
||||||
DeleteDeliveryButton.IsEnabled = true;
|
DeleteDeliveryButton.IsEnabled = true;
|
||||||
Menu_Print_ShowDeliveryNote.IsEnabled = !IsEditing && !IsCreating;
|
Menu_Print_ShowDeliveryNote.IsEnabled = !IsEditing && !IsCreating;
|
||||||
@@ -670,8 +665,8 @@ namespace Elwig.Windows {
|
|||||||
|
|
||||||
private void DeliveryPartList_SelectionChanged(object? sender, SelectionChangedEventArgs? evt) {
|
private void DeliveryPartList_SelectionChanged(object? sender, SelectionChangedEventArgs? evt) {
|
||||||
RefreshInputs();
|
RefreshInputs();
|
||||||
if (DeliveryPartList.SelectedItem != null) {
|
if (DeliveryPartList.SelectedItem is DeliveryPart p) {
|
||||||
AbwertenButton.IsEnabled = true;
|
AbwertenButton.IsEnabled = p.QualId != "WEI";
|
||||||
EditDeliveryButton.IsEnabled = true;
|
EditDeliveryButton.IsEnabled = true;
|
||||||
ExtractDeliveryPartButton.IsEnabled = !IsCreating;
|
ExtractDeliveryPartButton.IsEnabled = !IsCreating;
|
||||||
DeleteDeliveryPartButton.IsEnabled = DeliveryList.SelectedItem is Delivery { Parts.Count: > 1 } && !IsCreating;
|
DeleteDeliveryPartButton.IsEnabled = DeliveryList.SelectedItem is Delivery { Parts.Count: > 1 } && !IsCreating;
|
||||||
@@ -698,10 +693,10 @@ namespace Elwig.Windows {
|
|||||||
if (m != null) MgNrInput.Text = m.MgNr.ToString();
|
if (m != null) MgNrInput.Text = m.MgNr.ToString();
|
||||||
MemberAddressField.Text = m?.FullAddress;
|
MemberAddressField.Text = m?.FullAddress;
|
||||||
if (m == null) {
|
if (m == null) {
|
||||||
UnsetOriginalValue(WineKgInput);
|
UnsetDefaultValue(WineKgInput);
|
||||||
WineKgInput.SelectedIndex = 0;
|
WineKgInput.SelectedIndex = 0;
|
||||||
} else {
|
} else {
|
||||||
SetOriginalValue(WineKgInput, m.DefaultKg);
|
SetDefaultValue(WineKgInput, m.DefaultKg);
|
||||||
WineKgInput.SelectedItem = m.DefaultKg;
|
WineKgInput.SelectedItem = m.DefaultKg;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -710,7 +705,7 @@ namespace Elwig.Windows {
|
|||||||
DeliveryPartList.IsEnabled = false;
|
DeliveryPartList.IsEnabled = false;
|
||||||
var p = await UpdateDeliveryPart(DeliveryList.SelectedItem as Delivery, DeliveryPartList.SelectedItem as DeliveryPart);
|
var p = await UpdateDeliveryPart(DeliveryList.SelectedItem as Delivery, DeliveryPartList.SelectedItem as DeliveryPart);
|
||||||
await RefreshDeliveryList();
|
await RefreshDeliveryList();
|
||||||
RefreshDeliveryParts();
|
await RefreshDeliveryParts();
|
||||||
DeliveryList.SelectedItem = p?.Delivery;
|
DeliveryList.SelectedItem = p?.Delivery;
|
||||||
DeliveryPartList.SelectedItem = null;
|
DeliveryPartList.SelectedItem = null;
|
||||||
InitialInputs();
|
InitialInputs();
|
||||||
@@ -720,9 +715,9 @@ namespace Elwig.Windows {
|
|||||||
DeliveryPartList.IsEnabled = false;
|
DeliveryPartList.IsEnabled = false;
|
||||||
var p = await UpdateDeliveryPart(DeliveryList.SelectedItem as Delivery, DeliveryPartList.SelectedItem as DeliveryPart);
|
var p = await UpdateDeliveryPart(DeliveryList.SelectedItem as Delivery, DeliveryPartList.SelectedItem as DeliveryPart);
|
||||||
await RefreshDeliveryList();
|
await RefreshDeliveryList();
|
||||||
RefreshDeliveryParts();
|
await RefreshDeliveryParts();
|
||||||
if (p?.Delivery != null) {
|
if (p?.Delivery != null) {
|
||||||
using var doc = new DeliveryNote(p.Delivery);
|
using var doc = new DeliveryNote(p.Delivery, Context);
|
||||||
await doc.Generate();
|
await doc.Generate();
|
||||||
doc.Show();
|
doc.Show();
|
||||||
//await doc.Print(2);
|
//await doc.Print(2);
|
||||||
@@ -732,6 +727,7 @@ namespace Elwig.Windows {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void CancelCreatingButton_Click(object sender, RoutedEventArgs evt) {
|
private void CancelCreatingButton_Click(object sender, RoutedEventArgs evt) {
|
||||||
|
ControlUtils.RenewItemsSource(AttributesInput, Context.WineAttributes.OrderBy(a => a.Name).ToList(), i => (i as WineAttr)?.AttrId);
|
||||||
if (DeliveryList.SelectedItem is not Delivery d) {
|
if (DeliveryList.SelectedItem is not Delivery d) {
|
||||||
// switch away from creating mode
|
// switch away from creating mode
|
||||||
IsCreating = false;
|
IsCreating = false;
|
||||||
@@ -753,20 +749,68 @@ namespace Elwig.Windows {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void NewDeliveryButton_Click(object? sender, RoutedEventArgs? evt) {
|
private void NewDeliveryButton_Click(object? sender, RoutedEventArgs? evt) {
|
||||||
|
ControlUtils.RenewItemsSource(AttributesInput, Context.WineAttributes.Where(a => a.IsActive).OrderBy(a => a.Name).ToList(), i => (i as WineAttr)?.AttrId);
|
||||||
IsCreating = true;
|
IsCreating = true;
|
||||||
DeliveryList.IsEnabled = false;
|
DeliveryList.IsEnabled = false;
|
||||||
DeliveryPartList.IsEnabled = false;
|
DeliveryPartList.IsEnabled = false;
|
||||||
EnableWeighingButtons();
|
EnableWeighingButtons();
|
||||||
DeliveryList.SelectedItem = null;
|
DeliveryList.SelectedItem = null;
|
||||||
HideNewEditDeleteButtons();
|
HideNewEditDeleteButtons();
|
||||||
ShowFinishNewPartDeliveryCancelButtons();
|
|
||||||
UnlockInputs();
|
UnlockInputs();
|
||||||
InitInputs();
|
InitInputs();
|
||||||
|
ShowFinishNewPartDeliveryCancelButtons();
|
||||||
LockSearchInputs();
|
LockSearchInputs();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void AbwertenButton_Click(object sender, RoutedEventArgs evt) {
|
private async void AbwertenButton_Click(object sender, RoutedEventArgs evt) {
|
||||||
// TODO abwerten dialog
|
if (DeliveryPartList.SelectedItem is not DeliveryPart p) return;
|
||||||
|
var res = Utils.ShowAbwertenDialog($"{p.Delivery.LsNr}/{p.DPNr}", p.Delivery.Member.AdministrativeName, p.Weight);
|
||||||
|
EntityEntry<DeliveryPart>? entry1 = null, entry2 = null;
|
||||||
|
try {
|
||||||
|
if (res == null || res <= 0)
|
||||||
|
return;
|
||||||
|
ClearOriginalValues();
|
||||||
|
if (res >= p.Weight) {
|
||||||
|
ControlUtils.SelectComboBoxItem(WineQualityLevelInput, q => (q as WineQualLevel)?.QualId, "WEI");
|
||||||
|
ControlUtils.SelectComboBoxItem(WineOriginInput, o => (o as WineOrigin)?.HkId, "OEST");
|
||||||
|
p.QualId = "WEI";
|
||||||
|
p.HkId = "OEST";
|
||||||
|
entry1 = Context.Update(p);
|
||||||
|
} else {
|
||||||
|
var w = p.Weight - res.Value;
|
||||||
|
WeightInput.Text = $"{w:N0}";
|
||||||
|
p.Weight = w;
|
||||||
|
entry1 = Context.Update(p);
|
||||||
|
|
||||||
|
var d = p.Delivery;
|
||||||
|
var p2 = Context.CreateProxy<DeliveryPart>();
|
||||||
|
var values = Context.Entry(p).CurrentValues;
|
||||||
|
Context.Entry(p2).CurrentValues.SetValues(values);
|
||||||
|
p2.DPNr = await Context.NextDPNr(d.Year, d.DId);
|
||||||
|
p2.Weight = res.Value;
|
||||||
|
p2.QualId = "WEI";
|
||||||
|
p2.HkId = "OEST";
|
||||||
|
entry2 = await Context.AddAsync(p2);
|
||||||
|
|
||||||
|
await Context.UpdateDeliveryPartAttributes(p2, p.Attributes);
|
||||||
|
await Context.UpdateDeliveryPartModifiers(p2, p.Modifiers);
|
||||||
|
}
|
||||||
|
await Context.SaveChangesAsync();
|
||||||
|
await RefreshDeliveryParts();
|
||||||
|
FinishInputFilling();
|
||||||
|
} catch (Exception exc) {
|
||||||
|
if (entry1 != null) {
|
||||||
|
entry1.State = EntityState.Detached;
|
||||||
|
await entry1.ReloadAsync();
|
||||||
|
}
|
||||||
|
if (entry2 != null) {
|
||||||
|
entry2.State = EntityState.Detached;
|
||||||
|
await entry2.ReloadAsync();
|
||||||
|
}
|
||||||
|
var str = "Der Eintrag konnte nicht in der Datenbank aktualisiert werden!\n\n" + exc.Message;
|
||||||
|
if (exc.InnerException != null) str += "\n\n" + exc.InnerException.Message;
|
||||||
|
MessageBox.Show(str, "Lieferung aktualisieren", MessageBoxButton.OK, MessageBoxImage.Error);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void WeighingManualButton_Click(object sender, RoutedEventArgs evt) {
|
private void WeighingManualButton_Click(object sender, RoutedEventArgs evt) {
|
||||||
@@ -808,7 +852,7 @@ namespace Elwig.Windows {
|
|||||||
Context.Remove(d);
|
Context.Remove(d);
|
||||||
await Context.SaveChangesAsync();
|
await Context.SaveChangesAsync();
|
||||||
await RefreshDeliveryList();
|
await RefreshDeliveryList();
|
||||||
RefreshDeliveryParts();
|
await RefreshDeliveryParts();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -824,12 +868,12 @@ namespace Elwig.Windows {
|
|||||||
ShowNewEditDeleteButtons();
|
ShowNewEditDeleteButtons();
|
||||||
LockInputs();
|
LockInputs();
|
||||||
UnlockSearchInputs();
|
UnlockSearchInputs();
|
||||||
FillOriginalValues();
|
FinishInputFilling();
|
||||||
await RefreshDeliveryList();
|
await RefreshDeliveryList();
|
||||||
RefreshDeliveryParts();
|
await RefreshDeliveryParts();
|
||||||
RefreshInputs();
|
RefreshInputs();
|
||||||
|
|
||||||
AbwertenButton.IsEnabled = true;
|
AbwertenButton.IsEnabled = p.QualId != "WEI";
|
||||||
ExtractDeliveryPartButton.IsEnabled = DeliveryPartList.SelectedItem != null && !IsCreating;
|
ExtractDeliveryPartButton.IsEnabled = DeliveryPartList.SelectedItem != null && !IsCreating;
|
||||||
DeleteDeliveryPartButton.IsEnabled = DeliveryList.SelectedItem is Delivery { Parts.Count: > 1 } && !IsCreating;
|
DeleteDeliveryPartButton.IsEnabled = DeliveryList.SelectedItem is Delivery { Parts.Count: > 1 } && !IsCreating;
|
||||||
}
|
}
|
||||||
@@ -853,17 +897,78 @@ namespace Elwig.Windows {
|
|||||||
HideSaveResetCancelButtons();
|
HideSaveResetCancelButtons();
|
||||||
ShowNewEditDeleteButtons();
|
ShowNewEditDeleteButtons();
|
||||||
RefreshInputs();
|
RefreshInputs();
|
||||||
ClearInputStates();
|
|
||||||
LockInputs();
|
LockInputs();
|
||||||
UnlockSearchInputs();
|
UnlockSearchInputs();
|
||||||
|
|
||||||
AbwertenButton.IsEnabled = DeliveryPartList.SelectedItem != null;
|
AbwertenButton.IsEnabled = DeliveryPartList.SelectedItem is DeliveryPart p && p.QualId != "WEI";
|
||||||
ExtractDeliveryPartButton.IsEnabled = DeliveryPartList.SelectedItem != null && !IsCreating;
|
ExtractDeliveryPartButton.IsEnabled = DeliveryPartList.SelectedItem != null && !IsCreating;
|
||||||
DeleteDeliveryPartButton.IsEnabled = DeliveryList.SelectedItem is Delivery { Parts.Count: > 1 } && !IsCreating;
|
DeleteDeliveryPartButton.IsEnabled = DeliveryList.SelectedItem is Delivery { Parts.Count: > 1 } && !IsCreating;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ExtractDeliveryPartButton_Click(object sender, RoutedEventArgs evt) {
|
private async void ExtractDeliveryPartButton_Click(object sender, RoutedEventArgs evt) {
|
||||||
// TODO extract delivery part
|
if (DeliveryPartList.SelectedItem is not DeliveryPart p)
|
||||||
|
return;
|
||||||
|
|
||||||
|
var delivery = p.Delivery;
|
||||||
|
var day = delivery.Date;
|
||||||
|
var count = delivery.Parts.Count;
|
||||||
|
|
||||||
|
if (delivery.Time <= new TimeOnly(3, 0))
|
||||||
|
day = day.AddDays(-1);
|
||||||
|
var lsnrs = await Context.Deliveries
|
||||||
|
.Where(d => d.ZwstId == delivery.ZwstId)
|
||||||
|
.Where(d => (d.DateString == day.ToString("yyyy-MM-dd") && d.TimeString.CompareTo("03:00:00") > 0) ||
|
||||||
|
(d.DateString == day.AddDays(1).ToString("yyyy-MM-dd") && d.TimeString.CompareTo("03:00:00") <= 0))
|
||||||
|
.Where(d => d.LsNr != delivery.LsNr)
|
||||||
|
.OrderBy(d => d.LsNr)
|
||||||
|
.Select(d => d.LsNr)
|
||||||
|
.ToListAsync();
|
||||||
|
|
||||||
|
var res = Utils.ShowDeliveryExtractionDialog($"{delivery.LsNr}/{p.DPNr}", delivery.Member.AdministrativeName, count == 1, lsnrs);
|
||||||
|
EntityEntry<Delivery>? entry = null;
|
||||||
|
try {
|
||||||
|
Delivery? d = null;
|
||||||
|
if (res == null) {
|
||||||
|
return;
|
||||||
|
} else if (res == "new") {
|
||||||
|
d = Context.CreateProxy<Delivery>();
|
||||||
|
d.Date = delivery.Date;
|
||||||
|
d.Time = delivery.Time;
|
||||||
|
d.Year = p.Year;
|
||||||
|
d.DId = await Context.NextDId(d.Year);
|
||||||
|
d.LNr = await Context.NextLNr(d.Date);
|
||||||
|
d.ZwstId = delivery.ZwstId;
|
||||||
|
d.MgNr = delivery.MgNr;
|
||||||
|
d.Comment = delivery.Comment;
|
||||||
|
d.LsNr = Utils.GenerateLsNr(d);
|
||||||
|
entry = await Context.AddAsync(d);
|
||||||
|
await Context.SaveChangesAsync();
|
||||||
|
} else {
|
||||||
|
d = await Context.Deliveries.Where(d => d.LsNr == res).FirstOrDefaultAsync();
|
||||||
|
}
|
||||||
|
if (d == null) return;
|
||||||
|
|
||||||
|
await Context.Database.ExecuteSqlAsync($"UPDATE delivery_part SET year = {d.Year}, did = {d.DId}, dpnr = {await Context.NextDPNr(d.Year, d.DId)} WHERE (year, did, dpnr) = ({p.Year}, {p.DId}, {p.DPNr})");
|
||||||
|
Context.Entry(p).State = EntityState.Detached;
|
||||||
|
if (count == 1) {
|
||||||
|
await Context.Database.ExecuteSqlAsync($"DELETE FROM delivery WHERE (year, did) = ({delivery.Year}, {delivery.DId})");
|
||||||
|
Context.Entry(delivery).State = EntityState.Detached;
|
||||||
|
}
|
||||||
|
await Context.SaveChangesAsync();
|
||||||
|
await Context.Entry(p).ReloadAsync();
|
||||||
|
await Context.Entry(delivery).ReloadAsync();
|
||||||
|
|
||||||
|
await RefreshDeliveryList();
|
||||||
|
DeliveryList.SelectedItem = d;
|
||||||
|
} catch (Exception exc) {
|
||||||
|
if (entry != null) {
|
||||||
|
entry.State = EntityState.Detached;
|
||||||
|
await entry.ReloadAsync();
|
||||||
|
}
|
||||||
|
var str = "Der Eintrag konnte nicht in der Datenbank aktualisiert werden!\n\n" + exc.Message;
|
||||||
|
if (exc.InnerException != null) str += "\n\n" + exc.InnerException.Message;
|
||||||
|
MessageBox.Show(str, "Lieferung aktualisieren", MessageBoxButton.OK, MessageBoxImage.Error);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private async void DeleteDeliveryPartButton_Click(object sender, RoutedEventArgs evt) {
|
private async void DeleteDeliveryPartButton_Click(object sender, RoutedEventArgs evt) {
|
||||||
@@ -876,7 +981,7 @@ namespace Elwig.Windows {
|
|||||||
if (r == MessageBoxResult.Yes) {
|
if (r == MessageBoxResult.Yes) {
|
||||||
Context.Remove(p);
|
Context.Remove(p);
|
||||||
await Context.SaveChangesAsync();
|
await Context.SaveChangesAsync();
|
||||||
RefreshDeliveryParts();
|
await RefreshDeliveryParts();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -900,7 +1005,7 @@ namespace Elwig.Windows {
|
|||||||
|
|
||||||
private void ShowNewEditDeleteButtons() {
|
private void ShowNewEditDeleteButtons() {
|
||||||
NewDeliveryButton.IsEnabled = IsReceipt;
|
NewDeliveryButton.IsEnabled = IsReceipt;
|
||||||
AbwertenButton.IsEnabled = DeliveryPartList.SelectedItem != null;
|
AbwertenButton.IsEnabled = DeliveryPartList.SelectedItem is DeliveryPart p && p.QualId == "WEI";
|
||||||
EditDeliveryButton.IsEnabled = DeliveryPartList.SelectedItem != null;
|
EditDeliveryButton.IsEnabled = DeliveryPartList.SelectedItem != null;
|
||||||
DeleteDeliveryButton.IsEnabled = DeliveryList.SelectedItem != null;
|
DeleteDeliveryButton.IsEnabled = DeliveryList.SelectedItem != null;
|
||||||
NewDeliveryButton.Visibility = IsReceipt ? Visibility.Visible : Visibility.Hidden;
|
NewDeliveryButton.Visibility = IsReceipt ? Visibility.Visible : Visibility.Hidden;
|
||||||
@@ -990,7 +1095,7 @@ namespace Elwig.Windows {
|
|||||||
var branch = (Branch)BranchInput.SelectedItem;
|
var branch = (Branch)BranchInput.SelectedItem;
|
||||||
var date = DateOnly.ParseExact(DateInput.Text, "dd.MM.yyyy");
|
var date = DateOnly.ParseExact(DateInput.Text, "dd.MM.yyyy");
|
||||||
var lnr = await Context.NextLNr(date);
|
var lnr = await Context.NextLNr(date);
|
||||||
LsNrInput.Text = $"{date:yyyyMMdd}{branch.ZwstId}{lnr:000}";
|
LsNrInput.Text = Utils.GenerateLsNr(date, branch.ZwstId, lnr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1028,14 +1133,14 @@ namespace Elwig.Windows {
|
|||||||
|
|
||||||
private void UpdateWineQualityLevels() {
|
private void UpdateWineQualityLevels() {
|
||||||
if (!GetInputValid(GradationKmwInput)) {
|
if (!GetInputValid(GradationKmwInput)) {
|
||||||
UnsetOriginalValue(WineQualityLevelInput);
|
UnsetDefaultValue(WineQualityLevelInput);
|
||||||
WineQualityLevelInput.ItemsSource = Context.WineQualityLevels.Where(q => q.QualId == "WEI").ToList();
|
WineQualityLevelInput.ItemsSource = Context.WineQualityLevels.Where(q => q.QualId == "WEI").ToList();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var kmw = double.Parse(GradationKmwInput.Text);
|
var kmw = double.Parse(GradationKmwInput.Text);
|
||||||
WineQualityLevelInput.ItemsSource = Context.WineQualityLevels.Where(q => q.MinKmw == null || q.MinKmw <= kmw).ToList();
|
WineQualityLevelInput.ItemsSource = Context.WineQualityLevels.Where(q => q.MinKmw == null || q.MinKmw <= kmw).ToList();
|
||||||
var qual = Context.GetWineQualityLevel(kmw).GetAwaiter().GetResult();
|
var qual = Context.GetWineQualityLevel(kmw).GetAwaiter().GetResult();
|
||||||
SetOriginalValue(WineQualityLevelInput, qual);
|
SetDefaultValue(WineQualityLevelInput, qual);
|
||||||
if (WineQualityLevelInput.SelectedItem == null || (WineQualityLevelInput.SelectedItem is WineQualLevel selected && !selected.IsPredicate)) {
|
if (WineQualityLevelInput.SelectedItem == null || (WineQualityLevelInput.SelectedItem is WineQualLevel selected && !selected.IsPredicate)) {
|
||||||
WineQualityLevelInput.SelectedItem = qual;
|
WineQualityLevelInput.SelectedItem = qual;
|
||||||
}
|
}
|
||||||
@@ -1091,7 +1196,24 @@ namespace Elwig.Windows {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void ModifiersInput_SelectionChanged(object sender, ItemSelectionChangedEventArgs evt) {
|
private void ModifiersInput_SelectionChanged(object sender, ItemSelectionChangedEventArgs evt) {
|
||||||
|
if ((IsEditing || IsCreating) && App.Client.IsMatzen) {
|
||||||
|
var mod = ModifiersInput.SelectedItems.Cast<Modifier>();
|
||||||
|
var kl = mod.Where(m => m.Name.StartsWith("Klasse "));
|
||||||
|
if (kl.Count() > 1) {
|
||||||
|
foreach (var r in kl.Take(kl.Count() - 1)) ModifiersInput.SelectedItems.Remove(r);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void LesewagenInput_Changed(object sender, RoutedEventArgs evt) {
|
||||||
|
if ((IsEditing || IsCreating) && App.Client.IsMatzen) {
|
||||||
|
var mod = ModifiersInput.SelectedItems.Cast<Modifier>();
|
||||||
|
var kl = mod.Where(m => m.Name.StartsWith("Klasse ")).Select(m => m.ModId).LastOrDefault("A")[0];
|
||||||
|
if (LesewagenInput.IsChecked == true) kl++; else kl--;
|
||||||
|
var newKl = ModifiersInput.ItemsSource.Cast<Modifier>().Where(m => m.ModId == kl.ToString()).FirstOrDefault();
|
||||||
|
if (newKl != null) ModifiersInput.SelectedItems.Add(newKl);
|
||||||
|
}
|
||||||
|
CheckBox_Changed(sender, evt);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void UpdateWineOrigin() {
|
private void UpdateWineOrigin() {
|
||||||
@@ -1099,11 +1221,13 @@ namespace Elwig.Windows {
|
|||||||
var kg = (WineKgInput.SelectedItem as AT_Kg)?.WbKg;
|
var kg = (WineKgInput.SelectedItem as AT_Kg)?.WbKg;
|
||||||
if (qual == null || kg == null) {
|
if (qual == null || kg == null) {
|
||||||
WineOriginInput.IsEnabled = (IsEditing || IsCreating);
|
WineOriginInput.IsEnabled = (IsEditing || IsCreating);
|
||||||
|
UnsetDefaultValue(WineOriginInput);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
WineOriginInput.IsEnabled = false;
|
WineOriginInput.IsEnabled = false;
|
||||||
var o = kg.Origin;
|
var o = kg.Origin;
|
||||||
while (o != null && o.Level > qual.OriginLevel) o = o.Parent;
|
while (o != null && o.Level > qual.OriginLevel) o = o.Parent;
|
||||||
|
SetDefaultValue(WineOriginInput, o);
|
||||||
WineOriginInput.SelectedItem = o;
|
WineOriginInput.SelectedItem = o;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1145,5 +1269,18 @@ namespace Elwig.Windows {
|
|||||||
private void WeightInput_TextChanged(object sender, TextChangedEventArgs evt) {
|
private void WeightInput_TextChanged(object sender, TextChangedEventArgs evt) {
|
||||||
InputTextChanged((TextBox)sender);
|
InputTextChanged((TextBox)sender);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void TemperatureAcidInput_TextChanged(object sender, TextChangedEventArgs evt) {
|
||||||
|
InputTextChanged((TextBox)sender, Validator.CheckDecimal((TextBox)sender, false, 2, 1));
|
||||||
|
}
|
||||||
|
|
||||||
|
private void TemperatureAcidInput_LostFocus(object sender, RoutedEventArgs evt) {
|
||||||
|
if (sender is not TextBox tb) return;
|
||||||
|
if (tb.Text.Length > 0) {
|
||||||
|
if (!tb.Text.Contains(',')) tb.Text += ",0";
|
||||||
|
if (tb.Text.EndsWith(",")) tb.Text += "0";
|
||||||
|
}
|
||||||
|
InputLostFocus(tb, Validator.CheckDecimal(tb, false, 2, 1));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -49,11 +49,15 @@
|
|||||||
<Button x:Name="DeliveryListButton" Content="Lieferungungen" Click="DeliveryListButton_Click" IsEnabled="False"
|
<Button x:Name="DeliveryListButton" Content="Lieferungungen" Click="DeliveryListButton_Click" IsEnabled="False"
|
||||||
Margin="50,320,0,0" VerticalAlignment="Top" HorizontalAlignment="Left"/>
|
Margin="50,320,0,0" VerticalAlignment="Top" HorizontalAlignment="Left"/>
|
||||||
|
|
||||||
<Button x:Name="PdfButton" Content="PDF Erzeugen" Click="PdfButton_Click" Tag="Print"
|
<Button x:Name="BaseDataButton" Content="Stammdaten" Click="BaseDataButton_Click"
|
||||||
Margin="260,160,0,0" VerticalAlignment="Top" HorizontalAlignment="Left"/>
|
Margin="260,160,0,0" VerticalAlignment="Top" HorizontalAlignment="Left"/>
|
||||||
<Button x:Name="TestWindowButton" Content="Test Fenster" Click="TestWindowButton_Click"
|
<Button x:Name="PdfButton" Content="PDF Erzeugen" Click="PdfButton_Click" Tag="Print"
|
||||||
Margin="260,200,0,0" VerticalAlignment="Top" HorizontalAlignment="Left"/>
|
Margin="260,200,0,0" VerticalAlignment="Top" HorizontalAlignment="Left"/>
|
||||||
<Button x:Name="QueryWindowButton" Content="Datenbankabfragen" Click="QueryWindowButton_Click"
|
<Button x:Name="TestWindowButton" Content="Test Fenster" Click="TestWindowButton_Click"
|
||||||
Margin="260,240,0,0" VerticalAlignment="Top" HorizontalAlignment="Left"/>
|
Margin="260,240,0,0" VerticalAlignment="Top" HorizontalAlignment="Left"/>
|
||||||
|
<Button x:Name="QueryWindowButton" Content="Datenbankabfragen" Click="QueryWindowButton_Click"
|
||||||
|
Margin="260,280,0,0" VerticalAlignment="Top" HorizontalAlignment="Left"/>
|
||||||
|
<Button x:Name="PaymentWindowButton" Content="Auszahlung" Click="PaymentWindowButton_Click"
|
||||||
|
Margin="260,320,0,0" VerticalAlignment="Top" HorizontalAlignment="Left"/>
|
||||||
</Grid>
|
</Grid>
|
||||||
</Window>
|
</Window>
|
||||||
|
@@ -41,7 +41,7 @@ namespace Elwig.Windows {
|
|||||||
private void PdfButton_Click(object sender, RoutedEventArgs evt) {
|
private void PdfButton_Click(object sender, RoutedEventArgs evt) {
|
||||||
Utils.RunBackground("PDF Generation", async () => {
|
Utils.RunBackground("PDF Generation", async () => {
|
||||||
using var ctx = new AppDbContext();
|
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());
|
using var doc = new DeliveryNote(ctx.Deliveries.OrderBy(d => d.Parts.Count).ThenBy(d => d.Year).ThenBy(d => d.DId).Last(), ctx);
|
||||||
await doc.Generate();
|
await doc.Generate();
|
||||||
doc.Show();
|
doc.Show();
|
||||||
});
|
});
|
||||||
@@ -56,5 +56,15 @@ namespace Elwig.Windows {
|
|||||||
var w = new QueryWindow();
|
var w = new QueryWindow();
|
||||||
w.Show();
|
w.Show();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void BaseDataButton_Click(object sender, RoutedEventArgs evt) {
|
||||||
|
var w = new BaseDataWindow();
|
||||||
|
w.Show();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void PaymentWindowButton_Click(object sender, RoutedEventArgs e) {
|
||||||
|
var w = new ChartWindow();
|
||||||
|
w.Show();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -155,6 +155,10 @@
|
|||||||
<Label Content="Alter:" Margin="85,100,0,0" Grid.Column="1" Grid.ColumnSpan="3"/>
|
<Label Content="Alter:" Margin="85,100,0,0" Grid.Column="1" Grid.ColumnSpan="3"/>
|
||||||
<TextBlock x:Name="Age" Text="-" Margin="119,104,0,0" Grid.Column="1" Grid.ColumnSpan="3" TextWrapping="NoWrap" VerticalAlignment="Top"/>
|
<TextBlock x:Name="Age" Text="-" Margin="119,104,0,0" Grid.Column="1" Grid.ColumnSpan="3" TextWrapping="NoWrap" VerticalAlignment="Top"/>
|
||||||
|
|
||||||
|
<CheckBox x:Name="DeceasedInput" Content="Verstorben" IsEnabled="False"
|
||||||
|
Checked="CheckBox_Changed" Unchecked="CheckBox_Changed"
|
||||||
|
Grid.Column="3" HorizontalAlignment="Left" Margin="0,105,0,0" VerticalAlignment="Top" IsChecked="False"/>
|
||||||
|
|
||||||
<Label Content="Adresse:" Margin="10,130,0,0"/>
|
<Label Content="Adresse:" Margin="10,130,0,0"/>
|
||||||
<TextBox x:Name="AddressInput" Margin="0,130,10,0" Grid.Column="1" Grid.ColumnSpan="3"
|
<TextBox x:Name="AddressInput" Margin="0,130,10,0" Grid.Column="1" Grid.ColumnSpan="3"
|
||||||
TextChanged="TextBox_TextChanged"/>
|
TextChanged="TextBox_TextChanged"/>
|
||||||
@@ -175,8 +179,8 @@
|
|||||||
</Grid.ColumnDefinitions>
|
</Grid.ColumnDefinitions>
|
||||||
|
|
||||||
<Label Content="E-Mail-Adresse:" Margin="10,10,0,0" Grid.Column="0"/>
|
<Label Content="E-Mail-Adresse:" Margin="10,10,0,0" Grid.Column="0"/>
|
||||||
<TextBox x:Name="EmailInput" Margin="0,10,10,0" Grid.Column="1" Grid.ColumnSpan="2"
|
<TextBox x:Name="EmailAddressInput" Margin="0,10,10,0" Grid.Column="1" Grid.ColumnSpan="2"
|
||||||
TextChanged="EmailInput_TextChanged" LostFocus="EmailInput_LostFocus"/>
|
TextChanged="EmailAddressInput_TextChanged" LostFocus="EmailAddressInput_LostFocus"/>
|
||||||
|
|
||||||
<ComboBox x:Name="PhoneNr1TypeInput" DisplayMemberPath="Value" Margin="6,40,5,0" FontSize="12" Padding="6,4,4,4"/>
|
<ComboBox x:Name="PhoneNr1TypeInput" DisplayMemberPath="Value" Margin="6,40,5,0" FontSize="12" Padding="6,4,4,4"/>
|
||||||
<TextBox x:Name="PhoneNr1Input" Margin="0,40,5,0" Grid.Column="1"
|
<TextBox x:Name="PhoneNr1Input" Margin="0,40,5,0" Grid.Column="1"
|
||||||
@@ -258,10 +262,10 @@
|
|||||||
</Grid.ColumnDefinitions>
|
</Grid.ColumnDefinitions>
|
||||||
|
|
||||||
<Label Content="UID:" Margin="10,10,0,0" Grid.Column="0"/>
|
<Label Content="UID:" Margin="10,10,0,0" Grid.Column="0"/>
|
||||||
<TextBox x:Name="UstIdNrInput" Margin="0,10,10,0" Grid.Column="1" Width="120" HorizontalAlignment="Left"
|
<TextBox x:Name="UstIdNrInput" Margin="0,10,10,0" Grid.Column="1" Width="96" HorizontalAlignment="Left"
|
||||||
TextChanged="UstIdNrInput_TextChanged" LostFocus="UstIdNrInput_LostFocus"/>
|
TextChanged="UstIdNrInput_TextChanged" LostFocus="UstIdNrInput_LostFocus"/>
|
||||||
|
|
||||||
<Label Content="BetriebsNr.:" Margin="10,40,0,0" Grid.Column="0"/>
|
<Label Content="Betriebs-Nr.:" Margin="10,40,0,0" Grid.Column="0"/>
|
||||||
<TextBox x:Name="LfbisNrInput" Margin="0,40,10,0" Grid.Column="1" Width="64" HorizontalAlignment="Left" TextAlignment="Right"
|
<TextBox x:Name="LfbisNrInput" Margin="0,40,10,0" Grid.Column="1" Width="64" HorizontalAlignment="Left" TextAlignment="Right"
|
||||||
TextChanged="LfbisNrInput_TextChanged" LostFocus="LfbisNrInput_LostFocus"/>
|
TextChanged="LfbisNrInput_TextChanged" LostFocus="LfbisNrInput_LostFocus"/>
|
||||||
|
|
||||||
@@ -328,7 +332,7 @@
|
|||||||
Checked="CheckBox_Changed" Unchecked="CheckBox_Changed"
|
Checked="CheckBox_Changed" Unchecked="CheckBox_Changed"
|
||||||
Grid.Column="2" HorizontalAlignment="Left" Margin="10,75,0,0" VerticalAlignment="Top" IsChecked="False"/>
|
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"/>
|
<Label Content="Stamm-Zwst.:" Margin="10,130,0,0" Grid.Column="0"/>
|
||||||
<ComboBox x:Name="BranchInput" DisplayMemberPath="Name" TextSearch.TextPath="Name"
|
<ComboBox x:Name="BranchInput" DisplayMemberPath="Name" TextSearch.TextPath="Name"
|
||||||
Margin="0,130,10,0" Grid.Column="1" Grid.ColumnSpan="2"/>
|
Margin="0,130,10,0" Grid.Column="1" Grid.ColumnSpan="2"/>
|
||||||
|
|
||||||
|
@@ -72,7 +72,7 @@ namespace Elwig.Windows {
|
|||||||
List<Member> members = await memberQuery.ToListAsync();
|
List<Member> members = await memberQuery.ToListAsync();
|
||||||
|
|
||||||
if (TextFilter.Count > 0) {
|
if (TextFilter.Count > 0) {
|
||||||
var dict = members
|
var dict = members.AsParallel()
|
||||||
.ToDictionary(m => m, m => m.SearchScore(TextFilter))
|
.ToDictionary(m => m, m => m.SearchScore(TextFilter))
|
||||||
.OrderByDescending(a => a.Value)
|
.OrderByDescending(a => a.Value)
|
||||||
.ThenBy(a => a.Key.FamilyName)
|
.ThenBy(a => a.Key.FamilyName)
|
||||||
@@ -106,6 +106,7 @@ namespace Elwig.Windows {
|
|||||||
AreaCommitmentButton.IsEnabled = false;
|
AreaCommitmentButton.IsEnabled = false;
|
||||||
DeliveryButton.IsEnabled = false;
|
DeliveryButton.IsEnabled = false;
|
||||||
ClearOriginalValues();
|
ClearOriginalValues();
|
||||||
|
ClearDefaultValues();
|
||||||
ClearInputs(validate);
|
ClearInputs(validate);
|
||||||
ClearInputStates();
|
ClearInputStates();
|
||||||
}
|
}
|
||||||
@@ -113,13 +114,19 @@ namespace Elwig.Windows {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private async void InitInputs() {
|
private async void InitInputs() {
|
||||||
|
ClearOriginalValues();
|
||||||
|
ClearDefaultValues();
|
||||||
|
|
||||||
MgNrInput.Text = (await Context.NextMgNr()).ToString();
|
MgNrInput.Text = (await Context.NextMgNr()).ToString();
|
||||||
EntryDateInput.Text = DateTime.Now.ToString("dd.MM.yyyy");
|
EntryDateInput.Text = DateTime.Now.ToString("dd.MM.yyyy");
|
||||||
if (Context.Branches.Count() == 1)
|
if (Context.Branches.Count() == 1)
|
||||||
BranchInput.SelectedItem = Context.Branches.First();
|
BranchInput.SelectedItem = Context.Branches.First();
|
||||||
ActiveInput.IsChecked = true;
|
ActiveInput.IsChecked = true;
|
||||||
ContactPostalInput.IsChecked = true;
|
ContactPostalInput.IsChecked = true;
|
||||||
FillOriginalValues();
|
|
||||||
|
SetDefaultValue(MgNrInput);
|
||||||
|
SetDefaultValue(EntryDateInput);
|
||||||
|
SetDefaultValue(ActiveInput);
|
||||||
ValidateRequiredInputs();
|
ValidateRequiredInputs();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -213,7 +220,7 @@ namespace Elwig.Windows {
|
|||||||
LockInputs();
|
LockInputs();
|
||||||
UpdatePhoneNrInputVisibility();
|
UpdatePhoneNrInputVisibility();
|
||||||
UnlockSearchInputs();
|
UnlockSearchInputs();
|
||||||
FillOriginalValues();
|
FinishInputFilling();
|
||||||
await RefreshMemberList();
|
await RefreshMemberList();
|
||||||
RefreshInputs();
|
RefreshInputs();
|
||||||
SearchInput.Text = "";
|
SearchInput.Text = "";
|
||||||
@@ -237,7 +244,6 @@ namespace Elwig.Windows {
|
|||||||
HideSaveResetCancelButtons();
|
HideSaveResetCancelButtons();
|
||||||
ShowNewEditDeleteButtons();
|
ShowNewEditDeleteButtons();
|
||||||
RefreshInputs();
|
RefreshInputs();
|
||||||
ClearInputStates();
|
|
||||||
LockInputs();
|
LockInputs();
|
||||||
UpdatePhoneNrInputVisibility();
|
UpdatePhoneNrInputVisibility();
|
||||||
UnlockSearchInputs();
|
UnlockSearchInputs();
|
||||||
@@ -337,11 +343,12 @@ namespace Elwig.Windows {
|
|||||||
m.FamilyName = FamilyNameInput.Text;
|
m.FamilyName = FamilyNameInput.Text;
|
||||||
m.Suffix = (SuffixInput.Text == "") ? null : SuffixInput.Text;
|
m.Suffix = (SuffixInput.Text == "") ? null : SuffixInput.Text;
|
||||||
m.Birthday = (BirthdayInput.Text == "") ? null : string.Join("-", BirthdayInput.Text.Split(".").Reverse());
|
m.Birthday = (BirthdayInput.Text == "") ? null : string.Join("-", BirthdayInput.Text.Split(".").Reverse());
|
||||||
|
m.IsDeceased = DeceasedInput.IsChecked ?? false;
|
||||||
m.CountryNum = 40; // Austria AT AUT
|
m.CountryNum = 40; // Austria AT AUT
|
||||||
m.PostalDestId = ((AT_PlzDest)OrtInput.SelectedItem).Id;
|
m.PostalDestId = ((AT_PlzDest)OrtInput.SelectedItem).Id;
|
||||||
m.Address = AddressInput.Text;
|
m.Address = AddressInput.Text;
|
||||||
|
|
||||||
m.Email = (EmailInput.Text == "") ? null : EmailInput.Text;
|
m.Email = (EmailAddressInput.Text == "") ? null : EmailAddressInput.Text;
|
||||||
|
|
||||||
m.Iban = (IbanInput.Text == "") ? null : IbanInput.Text.Replace(" ", "");
|
m.Iban = (IbanInput.Text == "") ? null : IbanInput.Text.Replace(" ", "");
|
||||||
m.Bic = (BicInput.Text == "") ? null : BicInput.Text;
|
m.Bic = (BicInput.Text == "") ? null : BicInput.Text;
|
||||||
@@ -370,6 +377,8 @@ namespace Elwig.Windows {
|
|||||||
} else if (IsCreating) {
|
} else if (IsCreating) {
|
||||||
m.MgNr = newMgNr;
|
m.MgNr = newMgNr;
|
||||||
tr = (await Context.AddAsync(m));
|
tr = (await Context.AddAsync(m));
|
||||||
|
} else {
|
||||||
|
throw new Exception();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (BillingOrtInput.SelectedItem == null) {
|
if (BillingOrtInput.SelectedItem == null) {
|
||||||
@@ -418,13 +427,15 @@ namespace Elwig.Windows {
|
|||||||
|
|
||||||
if (newMgNr != m.MgNr) {
|
if (newMgNr != m.MgNr) {
|
||||||
await Context.Database.ExecuteSqlAsync($"UPDATE member SET mgnr = {newMgNr} WHERE mgnr = {m.MgNr}");
|
await Context.Database.ExecuteSqlAsync($"UPDATE member SET mgnr = {newMgNr} WHERE mgnr = {m.MgNr}");
|
||||||
await Context.Members.LoadAsync();
|
tr.State = EntityState.Detached;
|
||||||
|
await Context.SaveChangesAsync();
|
||||||
|
await tr.ReloadAsync();
|
||||||
m = await Context.Members.FindAsync(newMgNr);
|
m = await Context.Members.FindAsync(newMgNr);
|
||||||
}
|
}
|
||||||
} catch (Exception exc) {
|
} catch (Exception exc) {
|
||||||
if (tr != null) {
|
if (tr != null) {
|
||||||
|
tr.State = EntityState.Detached;
|
||||||
await tr.ReloadAsync();
|
await tr.ReloadAsync();
|
||||||
if (memberNew) tr.State = EntityState.Detached;
|
|
||||||
}
|
}
|
||||||
var str = "Der Eintrag konnte nicht in der Datenbank aktualisiert werden!\n\n" + exc.Message;
|
var str = "Der Eintrag konnte nicht in der Datenbank aktualisiert werden!\n\n" + exc.Message;
|
||||||
if (exc.InnerException != null) str += "\n\n" + exc.InnerException.Message;
|
if (exc.InnerException != null) str += "\n\n" + exc.InnerException.Message;
|
||||||
@@ -436,6 +447,7 @@ namespace Elwig.Windows {
|
|||||||
|
|
||||||
private void FillInputs(Member m) {
|
private void FillInputs(Member m) {
|
||||||
ClearOriginalValues();
|
ClearOriginalValues();
|
||||||
|
ClearDefaultValues();
|
||||||
|
|
||||||
MgNrInput.Text = m.MgNr.ToString();
|
MgNrInput.Text = m.MgNr.ToString();
|
||||||
PredecessorMgNrInput.Text = m.PredecessorMgNr.ToString();
|
PredecessorMgNrInput.Text = m.PredecessorMgNr.ToString();
|
||||||
@@ -451,6 +463,7 @@ namespace Elwig.Windows {
|
|||||||
} else {
|
} else {
|
||||||
Age.Text = "-";
|
Age.Text = "-";
|
||||||
}
|
}
|
||||||
|
DeceasedInput.IsChecked = m.IsDeceased;
|
||||||
AddressInput.Text = m.Address;
|
AddressInput.Text = m.Address;
|
||||||
AT_PlzDest? p = m.PostalDest.AtPlz;
|
AT_PlzDest? p = m.PostalDest.AtPlz;
|
||||||
if (p != null) {
|
if (p != null) {
|
||||||
@@ -461,7 +474,7 @@ namespace Elwig.Windows {
|
|||||||
OrtInput.SelectedItem = null;
|
OrtInput.SelectedItem = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
EmailInput.Text = m.Email;
|
EmailAddressInput.Text = m.Email;
|
||||||
var phoneNrs = m.TelephoneNumbers.OrderBy(p => p.Nr).ToList();
|
var phoneNrs = m.TelephoneNumbers.OrderBy(p => p.Nr).ToList();
|
||||||
for (int i = 0; i < PhoneNrInputs.Length; i++) {
|
for (int i = 0; i < PhoneNrInputs.Length; i++) {
|
||||||
if (i < phoneNrs.Count) {
|
if (i < phoneNrs.Count) {
|
||||||
@@ -513,7 +526,7 @@ namespace Elwig.Windows {
|
|||||||
|
|
||||||
Menu_Member_SendEmail.IsEnabled = m.Email != null;
|
Menu_Member_SendEmail.IsEnabled = m.Email != null;
|
||||||
|
|
||||||
FillOriginalValues();
|
FinishInputFilling();
|
||||||
}
|
}
|
||||||
|
|
||||||
new protected void ClearInputs(bool validate = false) {
|
new protected void ClearInputs(bool validate = false) {
|
||||||
|
@@ -1,9 +1,8 @@
|
|||||||
using Elwig.Helpers;
|
using Elwig.Helpers;
|
||||||
using Microsoft.Data.Sqlite;
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Data.Common;
|
using System.Data.Common;
|
||||||
using System.Text.RegularExpressions;
|
using System.Threading.Tasks;
|
||||||
using System.Windows;
|
using System.Windows;
|
||||||
using System.Windows.Controls;
|
using System.Windows.Controls;
|
||||||
using System.Windows.Data;
|
using System.Windows.Data;
|
||||||
@@ -14,26 +13,24 @@ namespace Elwig.Windows {
|
|||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void QueryButton_Click(object sender, RoutedEventArgs evt) {
|
private async void QueryButton_Click(object sender, RoutedEventArgs evt) {
|
||||||
try {
|
try {
|
||||||
ExecuteQuery(QueryInput.Text);
|
await ExecuteQuery(QueryInput.Text);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
MessageBox.Show(e.Message, "Fehler beim Ausführen", MessageBoxButton.OK, MessageBoxImage.Error);
|
MessageBox.Show(e.Message, "Fehler beim Ausführen", MessageBoxButton.OK, MessageBoxImage.Error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ExecuteQuery(string sqlQuery) {
|
private async Task ExecuteQuery(string sqlQuery) {
|
||||||
var rows = new List<object[]>();
|
var rows = new List<object[]>();
|
||||||
IList<DbColumn> header;
|
IList<DbColumn> header;
|
||||||
|
|
||||||
using (var cnx = new SqliteConnection(AppDbContext.ConnectionString)) {
|
using (var cnx = await AppDbContext.ConnectAsync()) {
|
||||||
cnx.CreateFunction<string, string?, bool?>("REGEXP", (pattern, value) => value == null ? null : Regex.Match(value, pattern).Success, true);
|
|
||||||
cnx.Open();
|
|
||||||
var cmd = cnx.CreateCommand();
|
var cmd = cnx.CreateCommand();
|
||||||
cmd.CommandText = sqlQuery;
|
cmd.CommandText = sqlQuery;
|
||||||
using var reader = cmd.ExecuteReader();
|
using var reader = await cmd.ExecuteReaderAsync();
|
||||||
header = reader.GetColumnSchema();
|
header = await reader.GetColumnSchemaAsync();
|
||||||
while (reader.Read()) {
|
while (await reader.ReadAsync()) {
|
||||||
var values = new object[reader.FieldCount];
|
var values = new object[reader.FieldCount];
|
||||||
reader.GetValues(values);
|
reader.GetValues(values);
|
||||||
rows.Add(values);
|
rows.Add(values);
|
||||||
|
@@ -16,5 +16,7 @@
|
|||||||
<Button x:Name="WeighingButton1" Click="WeighingButton1_Click" Height="30" Content="Aktuelles Gewicht" Width="110" Margin="515,246,0,0" HorizontalAlignment="Left" VerticalAlignment="Top"/>
|
<Button x:Name="WeighingButton1" Click="WeighingButton1_Click" Height="30" Content="Aktuelles Gewicht" Width="110" Margin="515,246,0,0" HorizontalAlignment="Left" VerticalAlignment="Top"/>
|
||||||
<Button x:Name="WeighingButton2" Click="WeighingButton2_Click" Height="30" Content="Wiegen" Width="110" Margin="515,285,0,0" HorizontalAlignment="Left" VerticalAlignment="Top"/>
|
<Button x:Name="WeighingButton2" Click="WeighingButton2_Click" Height="30" Content="Wiegen" Width="110" Margin="515,285,0,0" HorizontalAlignment="Left" VerticalAlignment="Top"/>
|
||||||
<TextBlock x:Name="Output" Height="20" Width="200" Margin="470,329,0,0" HorizontalAlignment="Left" VerticalAlignment="Top"/>
|
<TextBlock x:Name="Output" Height="20" Width="200" Margin="470,329,0,0" HorizontalAlignment="Left" VerticalAlignment="Top"/>
|
||||||
|
<Button x:Name="ChartButton" Content="Chart" Click="ChartButton_Click"
|
||||||
|
Margin="50,240,0,0" VerticalAlignment="Top" HorizontalAlignment="Left"/>
|
||||||
</Grid>
|
</Grid>
|
||||||
</Window>
|
</Window>
|
||||||
|
@@ -34,5 +34,10 @@ namespace Elwig.Windows {
|
|||||||
MessageBoxButton.OK, MessageBoxImage.Error);
|
MessageBoxButton.OK, MessageBoxImage.Error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void ChartButton_Click(object sender, RoutedEventArgs evt) {
|
||||||
|
var w = new ChartWindow();
|
||||||
|
w.Show();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user