Dialogs: Add DeliveryConfirmationsDialog

This commit is contained in:
2023-10-17 00:59:32 +02:00
parent 62d6707d10
commit 450f5d8109
3 changed files with 137 additions and 27 deletions

View File

@ -1,8 +1,6 @@
using Elwig.Documents;
using Elwig.Dialogs;
using Elwig.Helpers;
using Elwig.Helpers.Billing;
using Microsoft.EntityFrameworkCore;
using System.Linq;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Input;
@ -46,32 +44,11 @@ namespace Elwig.Windows {
CalculateBinsButton.IsEnabled = true;
}
private async void DeliveryConfirmationButton_Click(object sender, RoutedEventArgs evt) {
private 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();
}
var d = new DeliveryConfirmationsDialog(year);
d.Show();
}
private void OverUnderDeliveryButton_Click(object sender, RoutedEventArgs evt) {