Windows: Add SeasonFinishWindow
This commit is contained in:
78
Elwig/Windows/SeasonFinishWindow.xaml.cs
Normal file
78
Elwig/Windows/SeasonFinishWindow.xaml.cs
Normal 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();
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user