Windows: Add SeasonFinishWindow

This commit is contained in:
2023-10-15 00:38:54 +02:00
parent 56578a0a9d
commit 5657a8f90a
4 changed files with 135 additions and 10 deletions

View File

@ -8,6 +8,8 @@
Loaded="Window_Loaded">
<Window.Resources>
<Style TargetType="Button">
<Setter Property="VerticalAlignment" Value="Top"/>
<Setter Property="HorizontalAlignment" Value="Left"/>
<Setter Property="FontSize" Value="14"/>
<Setter Property="Padding" Value="9,3"/>
<Setter Property="Height" Value="32"/>
@ -39,19 +41,19 @@
</Grid>
<Button x:Name="MemberAdminButton" Content="Mitglieder" Click="MemberAdminButton_Click"
Margin="50,160,0,0" VerticalAlignment="Top" HorizontalAlignment="Left"/>
Margin="50,160,0,0"/>
<Button x:Name="ReceiptButton" Content="Übernahme" Click="ReceiptButton_Click"
Margin="50,200,0,0" VerticalAlignment="Top" HorizontalAlignment="Left"/>
Margin="50,200,0,0"/>
<Button x:Name="DeliveryAdminButton" Content="Lieferungen" Click="DeliveryAdminButton_Click"
Margin="50,240,0,0" VerticalAlignment="Top" HorizontalAlignment="Left"/>
<Button x:Name="PaymentWindowButton" Content="Auszahlung" Click="PaymentWindowButton_Click"
Margin="50,280,0,0" VerticalAlignment="Top" HorizontalAlignment="Left"/>
Margin="50,240,0,0"/>
<Button x:Name="SeasonFinishButton" Content="Leseabschluss" Click="SeasonFinishButton_Click"
Margin="50,280,0,0"/>
<Button x:Name="BaseDataButton" Content="Stammdaten" Click="BaseDataButton_Click"
Margin="50,320,0,0" VerticalAlignment="Top" HorizontalAlignment="Left"/>
Margin="50,320,0,0"/>
<Button x:Name="TestWindowButton" Content="Test Fenster" Click="TestWindowButton_Click"
Margin="260,280,0,0" VerticalAlignment="Top" HorizontalAlignment="Left"/>
Margin="260,280,0,0"/>
<Button x:Name="QueryWindowButton" Content="Datenbankabfragen" Click="QueryWindowButton_Click"
Margin="260,320,0,0" VerticalAlignment="Top" HorizontalAlignment="Left"/>
Margin="260,320,0,0"/>
</Grid>
</Window>

View File

@ -52,8 +52,8 @@ namespace Elwig.Windows {
w.Show();
}
private void PaymentWindowButton_Click(object sender, RoutedEventArgs e) {
var w = new ChartWindow();
private void SeasonFinishButton_Click(object sender, RoutedEventArgs e) {
var w = new SeasonFinishWindow();
w.Show();
}
}

View File

@ -0,0 +1,45 @@
<local:ContextWindow x:Class="Elwig.Windows.SeasonFinishWindow"
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"
mc:Ignorable="d"
Loaded="Window_Loaded"
Title="Leseabschluss - Elwig" Height="450" Width="800">
<Window.Resources>
<Style TargetType="Button">
<Setter Property="VerticalAlignment" Value="Top"/>
<Setter Property="HorizontalAlignment" Value="Left"/>
<Setter Property="FontSize" Value="14"/>
<Setter Property="Padding" Value="9,3"/>
<Setter Property="Height" Value="32"/>
<Setter Property="Width" Value="200"/>
</Style>
</Window.Resources>
<Grid>
<Label Content="Saison:" Margin="50,40,0,0" VerticalAlignment="Top" HorizontalAlignment="Left" Padding="2,4,2,4" Height="25"/>
<xctk:IntegerUpDown Name="SeasonInput" Height="25" Width="56" FontSize="14" Minimum="1000" Maximum="9999"
Margin="110,40,0,0" VerticalAlignment="Top" HorizontalAlignment="Left"
ValueChanged="SeasonInput_ValueChanged"/>
<Button x:Name="CalculateBinsButton"
Click="CalculateBinsButton_Click"
Margin="50,80,0,0" FontSize="12" Height="40">
<TextBlock TextAlignment="Center">Lieferungen auf Flächen-<LineBreak/>bindungen aufteilen</TextBlock>
</Button>
<Button x:Name="DeliveryConfirmationButton" Content="Anlieferungsbestätigungen"
Click="DeliveryConfirmationButton_Click"
Margin="50,130,0,0"/>
<Button x:Name="OverUnderDeliveryButton" Content="Über-/Unterlieferungen"
Click="OverUnderDeliveryButton_Click"
Margin="50,172,0,0"/>
<Button x:Name="PaymentButton" Content="Auszahlung"
Click="PaymentButton_Click"
Margin="50,214,0,0"/>
</Grid>
</local:ContextWindow>

View File

@ -0,0 +1,78 @@
using Elwig.Documents;
using Elwig.Helpers;
using Elwig.Helpers.Billing;
using Microsoft.EntityFrameworkCore;
using System.Linq;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Input;
namespace Elwig.Windows {
public partial class SeasonFinishWindow : ContextWindow {
public SeasonFinishWindow() {
InitializeComponent();
}
private void Window_Loaded(object sender, RoutedEventArgs evt) {
SeasonInput.Value = Utils.CurrentLastSeason;
}
protected override async Task OnRenewContext() {
}
private async void SeasonInput_ValueChanged(object sender, RoutedEventArgs evt) {
var s = await Context.Seasons.FindAsync(SeasonInput.Value);
var valid = (s != null);
CalculateBinsButton.IsEnabled = valid;
DeliveryConfirmationButton.IsEnabled = valid;
OverUnderDeliveryButton.IsEnabled = valid;
}
private async void CalculateBinsButton_Click(object sender, RoutedEventArgs evt) {
if (SeasonInput.Value is not int year)
return;
Mouse.OverrideCursor = Cursors.AppStarting;
var b = new Billing(year);
await b.FinishSeason();
await b.CalculateBins();
Mouse.OverrideCursor = null;
}
private async void DeliveryConfirmationButton_Click(object sender, RoutedEventArgs evt) {
if (SeasonInput.Value is not int year)
return;
var res = MessageBox.Show(
$"Sollen wirklich alle Bestätigungen gedruckt werden?", "Ausdruck Bestätigen",
MessageBoxButton.YesNo, MessageBoxImage.Warning, MessageBoxResult.No);
if (res != MessageBoxResult.Yes)
return;
Mouse.OverrideCursor = Cursors.AppStarting;
using var doc = await Document.Merge(Context.Members.FromSqlRaw($"""
SELECT m.*
FROM member m
JOIN delivery d ON d.mgnr = m.mgnr
WHERE m.active AND d.year = {year}
GROUP BY m.mgnr
ORDER BY m.mgnr
""")
.ToList()
.Select(m => new DeliveryConfirmation(Context, year, m)));
await doc.Generate();
Mouse.OverrideCursor = null;
if (App.Config.Debug) {
doc.Show();
} else {
await doc.Print();
}
}
private void OverUnderDeliveryButton_Click(object sender, RoutedEventArgs evt) {
}
private void PaymentButton_Click(object sender, RoutedEventArgs evt) {
var w = new ChartWindow();
w.Show();
}
}
}