[#15] DeliveryConfirmationsWindow: Replace with MailWindow
This commit is contained in:
@ -227,10 +227,6 @@ namespace Elwig {
|
|||||||
return FocusWindow<SeasonFinishWindow>(() => new());
|
return FocusWindow<SeasonFinishWindow>(() => new());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static DeliveryConfirmationsWindow FocusDeliveryConfirmations(int year) {
|
|
||||||
return FocusWindow<DeliveryConfirmationsWindow>(() => new(year), w => w.Year == year);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static OriginHierarchyWindow FocusOriginHierarchy() {
|
public static OriginHierarchyWindow FocusOriginHierarchy() {
|
||||||
return FocusWindow<OriginHierarchyWindow>(() => new());
|
return FocusWindow<OriginHierarchyWindow>(() => new());
|
||||||
}
|
}
|
||||||
@ -255,8 +251,8 @@ namespace Elwig {
|
|||||||
return w;
|
return w;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static MailWindow FocusMailWindow() {
|
public static MailWindow FocusMailWindow(int? year = null) {
|
||||||
return FocusWindow<MailWindow>(() => new());
|
return FocusWindow<MailWindow>(() => new(year));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,35 +0,0 @@
|
|||||||
<local:ContextWindow x:Class="Elwig.Dialogs.DeliveryConfirmationsWindow"
|
|
||||||
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"
|
|
||||||
Loaded="Window_Loaded"
|
|
||||||
Title="Anlieferungsbestätingungen - Elwig" Height="500" Width="800" MinHeight="400" MinWidth="600">
|
|
||||||
<Grid>
|
|
||||||
<GroupBox Header="Sortieren nach" Margin="10,10,10,10" Width="180" Height="80" VerticalAlignment="Top" HorizontalAlignment="Left">
|
|
||||||
<StackPanel Margin="5,5,0,5">
|
|
||||||
<RadioButton GroupName="Order" x:Name="OrderMgNrInput" Content="Mitgliedsnummer" IsChecked="True"/>
|
|
||||||
<RadioButton GroupName="Order" x:Name="OrderNameInput" Content="Name"/>
|
|
||||||
<RadioButton GroupName="Order" x:Name="OrderPlzInput" Content="PLZ, Ort, Name"/>
|
|
||||||
</StackPanel>
|
|
||||||
</GroupBox>
|
|
||||||
|
|
||||||
<CheckBox x:Name="AllMembersInput" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="10,100,10,10">
|
|
||||||
<TextBlock>Auch Mitglieder ohne<LineBreak/>Lieferungen miteinbeziehen</TextBlock>
|
|
||||||
</CheckBox>
|
|
||||||
|
|
||||||
<TextBox x:Name="TextElement" TextWrapping="Wrap" VerticalScrollBarVisibility="Visible" AcceptsReturn="True"
|
|
||||||
HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Margin="200,10,10,10" Height="Auto"/>
|
|
||||||
|
|
||||||
<ProgressBar x:Name="ProgressBar" Margin="10,0,0,74" Height="27" Width="180"
|
|
||||||
VerticalAlignment="Bottom" HorizontalAlignment="Left"/>
|
|
||||||
<Button x:Name="ShowButton" Content="Vorschau" FontSize="14" Width="180" Margin="10,10,10,42" Height="27" Tag="Print" IsEnabled="False"
|
|
||||||
Click="ShowButton_Click"
|
|
||||||
VerticalAlignment="Bottom" HorizontalAlignment="Left"/>
|
|
||||||
<Button x:Name="PrintButton" Content="Drucken" FontSize="14" Width="180" Margin="10,10,10,10" Height="27" Tag="Print" IsEnabled="False"
|
|
||||||
Click="PrintButton_Click"
|
|
||||||
VerticalAlignment="Bottom" HorizontalAlignment="Left"/>
|
|
||||||
</Grid>
|
|
||||||
</local:ContextWindow>
|
|
@ -1,109 +0,0 @@
|
|||||||
using Elwig.Documents;
|
|
||||||
using Elwig.Models.Dtos;
|
|
||||||
using Elwig.Models.Entities;
|
|
||||||
using Elwig.Windows;
|
|
||||||
using Microsoft.EntityFrameworkCore;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using System.Windows;
|
|
||||||
using System.Windows.Input;
|
|
||||||
|
|
||||||
namespace Elwig.Dialogs {
|
|
||||||
public partial class DeliveryConfirmationsWindow : ContextWindow {
|
|
||||||
|
|
||||||
public readonly int Year;
|
|
||||||
|
|
||||||
public DeliveryConfirmationsWindow(int year) {
|
|
||||||
InitializeComponent();
|
|
||||||
Year = year;
|
|
||||||
Title = $"Anlieferungsbestätigungen - Lese {Year} - Elwig";
|
|
||||||
TextElement.Text = App.Client.TextDeliveryConfirmation;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void Window_Loaded(object sender, RoutedEventArgs evt) {
|
|
||||||
ShowButton.IsEnabled = App.IsPrintingReady;
|
|
||||||
PrintButton.IsEnabled = App.IsPrintingReady;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override async Task OnRenewContext() { }
|
|
||||||
|
|
||||||
private async Task UpdateTextParameter() {
|
|
||||||
var text = TextElement.Text;
|
|
||||||
if (text.Length == 0) text = null;
|
|
||||||
if (text != App.Client.TextDeliveryConfirmation) {
|
|
||||||
App.Client.TextDeliveryConfirmation = text;
|
|
||||||
await App.Client.UpdateValues();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private async Task Generate(int mode) {
|
|
||||||
|
|
||||||
Mouse.OverrideCursor = Cursors.AppStarting;
|
|
||||||
await UpdateTextParameter();
|
|
||||||
|
|
||||||
IQueryable<Member> members;
|
|
||||||
if (AllMembersInput.IsChecked == true) {
|
|
||||||
members = Context.Members.Where(m => m.IsActive);
|
|
||||||
} else {
|
|
||||||
members = Context.Members.FromSqlRaw($"""
|
|
||||||
SELECT m.*
|
|
||||||
FROM member m
|
|
||||||
INNER JOIN delivery d ON d.mgnr = m.mgnr
|
|
||||||
WHERE d.year = {Year}
|
|
||||||
GROUP BY m.mgnr
|
|
||||||
""");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (OrderMgNrInput.IsChecked == true) {
|
|
||||||
members = members
|
|
||||||
.OrderBy(m => m.MgNr);
|
|
||||||
} else if (OrderNameInput.IsChecked == true) {
|
|
||||||
members = members
|
|
||||||
.OrderBy(m => m.FamilyName)
|
|
||||||
.ThenBy(m => m.GivenName)
|
|
||||||
.ThenBy(m => m.MgNr);
|
|
||||||
} else if (OrderPlzInput.IsChecked == true) {
|
|
||||||
members = members
|
|
||||||
.OrderBy(m => m.PostalDest.AtPlz.Plz)
|
|
||||||
.ThenBy(m => m.PostalDest.AtPlz.Ort.Name)
|
|
||||||
.ThenBy(m => m.FamilyName)
|
|
||||||
.ThenBy(m => m.GivenName)
|
|
||||||
.ThenBy(m => m.MgNr);
|
|
||||||
}
|
|
||||||
|
|
||||||
IEnumerable<Member> list = await members.ToListAsync();
|
|
||||||
var data = await DeliveryConfirmationDeliveryData.ForSeason(Context.DeliveryParts, Year);
|
|
||||||
using var doc = Document.Merge(list.Select(m =>
|
|
||||||
new DeliveryConfirmation(Context, Year, m, data.TryGetValue(m.MgNr, out var d) ? d : DeliveryConfirmationDeliveryData.CreateEmpty(Year, m)) {
|
|
||||||
//DoubleSided = true
|
|
||||||
}
|
|
||||||
));
|
|
||||||
//doc.DoubleSided = true;
|
|
||||||
await doc.Generate(new Progress<double>(v => {
|
|
||||||
ProgressBar.Value = v;
|
|
||||||
}));
|
|
||||||
Mouse.OverrideCursor = null;
|
|
||||||
|
|
||||||
if (mode < 2) {
|
|
||||||
doc.Show();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (App.Config.Debug) {
|
|
||||||
doc.Show();
|
|
||||||
} else {
|
|
||||||
await doc.Print();
|
|
||||||
}
|
|
||||||
Close();
|
|
||||||
}
|
|
||||||
|
|
||||||
private async void ShowButton_Click(object sender, RoutedEventArgs evt) {
|
|
||||||
await Generate(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
private async void PrintButton_Click(object sender, RoutedEventArgs evt) {
|
|
||||||
await Generate(2);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -52,7 +52,7 @@ namespace Elwig.Windows {
|
|||||||
CreditNote.Name,
|
CreditNote.Name,
|
||||||
];
|
];
|
||||||
|
|
||||||
protected Season? Season;
|
protected readonly int? Year;
|
||||||
public ObservableCollection<SelectedDoc> SelectedDocs = [];
|
public ObservableCollection<SelectedDoc> SelectedDocs = [];
|
||||||
public IEnumerable<Member> Recipients = [];
|
public IEnumerable<Member> Recipients = [];
|
||||||
|
|
||||||
@ -99,8 +99,11 @@ namespace Elwig.Windows {
|
|||||||
});
|
});
|
||||||
|
|
||||||
// powershell -Command "$(Get-WmiObject -Class Win32_Printer | Where-Object {$_.Default -eq $True}).Name"
|
// powershell -Command "$(Get-WmiObject -Class Win32_Printer | Where-Object {$_.Default -eq $True}).Name"
|
||||||
public MailWindow() {
|
public MailWindow(int? year = null) {
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
|
Year = year ?? Context.Seasons.OrderBy(s => s.Year).LastOrDefault()?.Year;
|
||||||
|
Title = $"Rundschreiben {Year} - Elwig";
|
||||||
|
|
||||||
AvaiableDocumentsList.ItemsSource = AvaiableDocuments;
|
AvaiableDocumentsList.ItemsSource = AvaiableDocuments;
|
||||||
SelectedDocumentsList.ItemsSource = SelectedDocs;
|
SelectedDocumentsList.ItemsSource = SelectedDocs;
|
||||||
|
|
||||||
@ -120,13 +123,13 @@ namespace Elwig.Windows {
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected override async Task OnRenewContext() {
|
protected override async Task OnRenewContext() {
|
||||||
Season = await Context.Seasons.OrderBy(s => s.Year).LastOrDefaultAsync();
|
var season = await Context.Seasons.FindAsync(Year);
|
||||||
var l = new List<string> {
|
var l = new List<string> {
|
||||||
MemberDataSheet.Name
|
MemberDataSheet.Name
|
||||||
};
|
};
|
||||||
if (Season != null) {
|
if (season != null) {
|
||||||
l.Add($"{DeliveryConfirmation.Name} {Season.Year}");
|
l.Add($"{DeliveryConfirmation.Name} {Year}");
|
||||||
l.AddRange(Season.PaymentVariants.Where(v => !v.TestVariant).OrderBy(v => v.AvNr).Select(v => $"{CreditNote.Name} – {v.Name}"));
|
l.AddRange(season.PaymentVariants.Where(v => !v.TestVariant).OrderBy(v => v.AvNr).Select(v => $"{CreditNote.Name} – {v.Name}"));
|
||||||
}
|
}
|
||||||
AvaiableDocumentsList.ItemsSource = l;
|
AvaiableDocumentsList.ItemsSource = l;
|
||||||
|
|
||||||
@ -221,10 +224,10 @@ namespace Elwig.Windows {
|
|||||||
if (idx == 0) {
|
if (idx == 0) {
|
||||||
SelectedDocs.Add(new(DocType.MemberDataSheet, s, null));
|
SelectedDocs.Add(new(DocType.MemberDataSheet, s, null));
|
||||||
} else if (idx == 1) {
|
} else if (idx == 1) {
|
||||||
SelectedDocs.Add(new(DocType.DeliveryConfirmation, s, (Season!.Year, DocumentNonDeliverersInput.IsChecked == true)));
|
SelectedDocs.Add(new(DocType.DeliveryConfirmation, s, ((int)Year!, DocumentNonDeliverersInput.IsChecked == true)));
|
||||||
} else if (idx >= 2) {
|
} else if (idx >= 2) {
|
||||||
var name = s.Split(" – ")[^1];
|
var name = s.Split(" – ")[^1];
|
||||||
var pv = Context.PaymentVariants.Single(v => v.Year == Season!.Year && v.Name == name)!;
|
var pv = Context.PaymentVariants.Single(v => v.Year == Year && v.Name == name)!;
|
||||||
SelectedDocs.Add(new(DocType.CreditNote, s, (pv.Year, pv.AvNr)));
|
SelectedDocs.Add(new(DocType.CreditNote, s, (pv.Year, pv.AvNr)));
|
||||||
}
|
}
|
||||||
SelectedDocumentsList.SelectedIndex = SelectedDocs.Count - 1;
|
SelectedDocumentsList.SelectedIndex = SelectedDocs.Count - 1;
|
||||||
@ -553,5 +556,13 @@ namespace Elwig.Windows {
|
|||||||
Process.Start("explorer.exe", d.FolderName);
|
Process.Start("explorer.exe", d.FolderName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void AddDeliveryConfirmation() {
|
||||||
|
AvaiableDocumentsList.SelectedIndex = 1;
|
||||||
|
if (AvaiableDocumentsList.SelectedItem is not string s)
|
||||||
|
return;
|
||||||
|
SelectedDocs.Add(new(DocType.DeliveryConfirmation, s, ((int)Year!, DocumentNonDeliverersInput.IsChecked == true)));
|
||||||
|
SelectedDocumentsList.SelectedIndex = SelectedDocs.Count - 1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -65,7 +65,8 @@ namespace Elwig.Windows {
|
|||||||
private void DeliveryConfirmationButton_Click(object sender, RoutedEventArgs evt) {
|
private void DeliveryConfirmationButton_Click(object sender, RoutedEventArgs evt) {
|
||||||
if (SeasonInput.Value is not int year)
|
if (SeasonInput.Value is not int year)
|
||||||
return;
|
return;
|
||||||
App.FocusDeliveryConfirmations(year);
|
var w = App.FocusMailWindow(year);
|
||||||
|
w.AddDeliveryConfirmation();
|
||||||
}
|
}
|
||||||
|
|
||||||
private async void OverUnderDeliveryButton_Click(object sender, RoutedEventArgs evt) {
|
private async void OverUnderDeliveryButton_Click(object sender, RoutedEventArgs evt) {
|
||||||
|
Reference in New Issue
Block a user