Add PaymentVariantsWindow
This commit is contained in:
		@@ -1,4 +1,5 @@
 | 
			
		||||
<local:AdministrationWindow x:Class="Elwig.Windows.ChartWindow"
 | 
			
		||||
<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"
 | 
			
		||||
 
 | 
			
		||||
@@ -18,8 +18,8 @@ using ScottPlot.Plottable;
 | 
			
		||||
namespace Elwig.Windows {
 | 
			
		||||
    public partial class ChartWindow : AdministrationWindow {
 | 
			
		||||
 | 
			
		||||
        private readonly int Year = 2021;
 | 
			
		||||
        private readonly int AvNr = 2;
 | 
			
		||||
        public readonly int Year;
 | 
			
		||||
        public readonly int AvNr;
 | 
			
		||||
 | 
			
		||||
        private ScatterPlot OechslePricePlotScatter;
 | 
			
		||||
        private MarkerPlot HighlightedPoint;
 | 
			
		||||
@@ -39,9 +39,12 @@ namespace Elwig.Windows {
 | 
			
		||||
 | 
			
		||||
        private Graph? Graph;
 | 
			
		||||
 | 
			
		||||
        public ChartWindow() {
 | 
			
		||||
        public ChartWindow(int year, int avnr) {
 | 
			
		||||
            InitializeComponent();
 | 
			
		||||
 | 
			
		||||
            Year = year;
 | 
			
		||||
            AvNr = avnr;
 | 
			
		||||
            var v = Context.PaymentVariants.Find(year, avnr);
 | 
			
		||||
            Title = $"{v?.Name} - Lese {year} - Elwig";
 | 
			
		||||
            ExemptInputs = new Control[] {
 | 
			
		||||
                GraphList, OechsleInput, PriceInput, FreeZoomInput, GradationLinesInput, TooltipInput
 | 
			
		||||
            };
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										99
									
								
								Elwig/Windows/PaymentVariantsWindow.xaml
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										99
									
								
								Elwig/Windows/PaymentVariantsWindow.xaml
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,99 @@
 | 
			
		||||
<local:ContextWindow
 | 
			
		||||
        x:Class="Elwig.Windows.PaymentVariantsWindow"
 | 
			
		||||
        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="Auszahlungsvarianten - Elwig" Height="450" Width="800" MinHeight="400" MinWidth="700">
 | 
			
		||||
    <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>
 | 
			
		||||
        <Grid.ColumnDefinitions>
 | 
			
		||||
            <ColumnDefinition Width="320"/>
 | 
			
		||||
            <ColumnDefinition Width="100"/>
 | 
			
		||||
            <ColumnDefinition Width="*"/>
 | 
			
		||||
        </Grid.ColumnDefinitions>
 | 
			
		||||
        <Grid.RowDefinitions>
 | 
			
		||||
            <RowDefinition Height="200"/>
 | 
			
		||||
            <RowDefinition Height="*"/>
 | 
			
		||||
        </Grid.RowDefinitions>
 | 
			
		||||
 | 
			
		||||
        <ListBox x:Name="PaymentVariantList" Margin="10,10,35,10" Grid.RowSpan="2" SelectionChanged="PaymentVariantList_SelectionChanged">
 | 
			
		||||
            <ListBox.ItemTemplate>
 | 
			
		||||
                <DataTemplate>
 | 
			
		||||
                    <StackPanel Orientation="Horizontal">
 | 
			
		||||
                        <TextBlock Text="{Binding Name}" Width="200"/>
 | 
			
		||||
                        <TextBlock Text="{Binding Date}" Width="60"/>
 | 
			
		||||
                    </StackPanel>
 | 
			
		||||
                </DataTemplate>
 | 
			
		||||
            </ListBox.ItemTemplate>
 | 
			
		||||
        </ListBox>
 | 
			
		||||
        <Button x:Name="AddButton" Content="" FontFamily="Segoe MDL2 Assets" FontSize="11" Padding="0,1.5,0,0"
 | 
			
		||||
                Click="AddButton_Click"
 | 
			
		||||
                VerticalAlignment="Center" HorizontalAlignment="Right" Width="25" Height="25" Margin="5,0,5,60" Grid.RowSpan="2"/>
 | 
			
		||||
        <Button x:Name="CopyButton" Content="" FontFamily="Segoe MDL2 Assets" FontSize="12" Padding="0,0,0,0" IsEnabled="False"
 | 
			
		||||
                Click="CopyButton_Click"
 | 
			
		||||
                VerticalAlignment="Center" HorizontalAlignment="Right" Width="25" Height="25" Margin="5,0,5,0" Grid.RowSpan="2"/>
 | 
			
		||||
        <Button x:Name="DeleteButton" Content="" FontFamily="Segoe MDL2 Assets" FontSize="11" Padding="0,1.5,0,0" IsEnabled="False"
 | 
			
		||||
                Click="DeleteButton_Click"
 | 
			
		||||
                VerticalAlignment="Center" HorizontalAlignment="Right" Width="25" Height="25" Margin="5,60,5,0" Grid.RowSpan="2"/>
 | 
			
		||||
 | 
			
		||||
        <Label Content="Name:" Margin="10,10,0,0" Grid.Column="1"/>
 | 
			
		||||
        <TextBox x:Name="NameInput" Width="200" Grid.Column="2" HorizontalAlignment="Left" Margin="0,10,0,0"/>
 | 
			
		||||
 | 
			
		||||
        <Label Content="Beschreibung:" Margin="10,40,0,0" Grid.Column="1"/>
 | 
			
		||||
        <TextBox x:Name="CommentInput" Grid.Column="2" HorizontalAlignment="Stretch" Margin="0,40,10,0"/>
 | 
			
		||||
 | 
			
		||||
        <Label Content="Erstellt am:" Margin="10,70,0,0" Grid.Column="1"/>
 | 
			
		||||
        <TextBox x:Name="DateInput" Grid.Column="2" Width="77" HorizontalAlignment="Left" Margin="0,70,10,0"/>
 | 
			
		||||
 | 
			
		||||
        <Label Content="Überwiesen am:" Margin="10,100,0,0" Grid.Column="1"/>
 | 
			
		||||
        <TextBox x:Name="TransferDateInput" Grid.Column="2" Width="77" HorizontalAlignment="Left" Margin="0,100,10,0"/>
 | 
			
		||||
        <Button x:Name="CalculateButton" Content="Berechnen" Grid.Column="1" Grid.ColumnSpan="2"
 | 
			
		||||
                Click="CalculateButton_Click"
 | 
			
		||||
                VerticalAlignment="Bottom" HorizontalAlignment="Right" Width="100" Margin="10,10,115,10"/>
 | 
			
		||||
        <Button x:Name="EditButton" Content="Bearbeiten" Grid.Column="1" Grid.ColumnSpan="2"
 | 
			
		||||
                Click="EditButton_Click"
 | 
			
		||||
                VerticalAlignment="Bottom" HorizontalAlignment="Right" Width="100" Margin="10,10,10,10"/>
 | 
			
		||||
 | 
			
		||||
        <GroupBox Header="Abschluss" Grid.Row="1" Grid.Column="1" Grid.ColumnSpan="2" Margin="10,0,10,10">
 | 
			
		||||
            <Grid>
 | 
			
		||||
                <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>
 | 
			
		||||
        </GroupBox>
 | 
			
		||||
    </Grid>
 | 
			
		||||
</local:ContextWindow>
 | 
			
		||||
							
								
								
									
										126
									
								
								Elwig/Windows/PaymentVariantsWindow.xaml.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										126
									
								
								Elwig/Windows/PaymentVariantsWindow.xaml.cs
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,126 @@
 | 
			
		||||
using Elwig.Documents;
 | 
			
		||||
using Elwig.Helpers;
 | 
			
		||||
using Elwig.Models.Dtos;
 | 
			
		||||
using Elwig.Models.Entities;
 | 
			
		||||
using Microsoft.EntityFrameworkCore;
 | 
			
		||||
using System.Collections.Generic;
 | 
			
		||||
using System;
 | 
			
		||||
using System.Linq;
 | 
			
		||||
using System.Threading.Tasks;
 | 
			
		||||
using System.Windows;
 | 
			
		||||
using System.Windows.Controls;
 | 
			
		||||
using System.Windows.Input;
 | 
			
		||||
 | 
			
		||||
namespace Elwig.Windows {
 | 
			
		||||
    public partial class PaymentVariantsWindow : ContextWindow {
 | 
			
		||||
 | 
			
		||||
        public readonly int Year;
 | 
			
		||||
 | 
			
		||||
        public PaymentVariantsWindow(int year) {
 | 
			
		||||
            InitializeComponent();
 | 
			
		||||
            Year = year;
 | 
			
		||||
            Title = $"Auszahlungsvarianten - Lese {Year} - Elwig";
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        protected override async Task OnRenewContext() {
 | 
			
		||||
            ControlUtils.RenewItemsSource(PaymentVariantList, await Context.PaymentVariants.Where(v => v.Year == Year).OrderBy(v => v.AvNr).ToListAsync(), v => (v as PaymentVar)?.AvNr);
 | 
			
		||||
            Update();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        private void Update() {
 | 
			
		||||
            if (PaymentVariantList.SelectedItem is PaymentVar v) {
 | 
			
		||||
                var locked = v.TransferDate != null || !v.TestVariant;
 | 
			
		||||
                DeleteButton.IsEnabled = !locked;
 | 
			
		||||
                CalculateButton.IsEnabled = !locked;
 | 
			
		||||
                CopyButton.IsEnabled = true;
 | 
			
		||||
                EditButton.IsEnabled = true;
 | 
			
		||||
                ShowButton.IsEnabled = true;
 | 
			
		||||
                PrintButton.IsEnabled = true;
 | 
			
		||||
 | 
			
		||||
                NameInput.Text = v.Name;
 | 
			
		||||
                CommentInput.Text = v.Comment;
 | 
			
		||||
            } else {
 | 
			
		||||
                EditButton.IsEnabled = false;
 | 
			
		||||
                CopyButton.IsEnabled = false;
 | 
			
		||||
                CalculateButton.IsEnabled = false;
 | 
			
		||||
                DeleteButton.IsEnabled = false;
 | 
			
		||||
                ShowButton.IsEnabled = false;
 | 
			
		||||
                PrintButton.IsEnabled = false;
 | 
			
		||||
 | 
			
		||||
                NameInput.Text = "";
 | 
			
		||||
                CommentInput.Text = "";
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        private void PaymentVariantList_SelectionChanged(object sender, SelectionChangedEventArgs evt) {
 | 
			
		||||
            Update();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        private void AddButton_Click(object sender, RoutedEventArgs evt) {
 | 
			
		||||
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        private void CopyButton_Click(object sender, RoutedEventArgs evt) {
 | 
			
		||||
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        private void DeleteButton_Click(object sender, RoutedEventArgs evt) {
 | 
			
		||||
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        private void CalculateButton_Click(object sender, RoutedEventArgs evt) {
 | 
			
		||||
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        private void EditButton_Click(object sender, RoutedEventArgs evt) {
 | 
			
		||||
            if (PaymentVariantList.SelectedItem is not PaymentVar v)
 | 
			
		||||
                return;
 | 
			
		||||
            App.FocusChartWindow(v.Year, v.AvNr);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        private async void ShowButton_Click(object sender, RoutedEventArgs evt) {
 | 
			
		||||
            await Generate(1);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        private async void PrintButton_Click(object sender, RoutedEventArgs evt) {
 | 
			
		||||
            await Generate(2);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        private async Task Generate(int mode) {
 | 
			
		||||
            if (PaymentVariantList.SelectedItem is not PaymentVar v)
 | 
			
		||||
                return;
 | 
			
		||||
 | 
			
		||||
            Mouse.OverrideCursor = Cursors.AppStarting;
 | 
			
		||||
 | 
			
		||||
            var 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
 | 
			
		||||
                """);
 | 
			
		||||
            members = members.OrderBy(m => m.MgNr);
 | 
			
		||||
 | 
			
		||||
            IEnumerable<Member> list = await members.ToListAsync();
 | 
			
		||||
            var data = await CreditNoteData.ForPaymentVariant(Context.CreditNoteRows, v.Year, v.AvNr);
 | 
			
		||||
            var payments = await Context.MemberPayments.Where(p => p.Year == v.Year && p.AvNr == v.AvNr).ToDictionaryAsync(c => c.MgNr);
 | 
			
		||||
            using var doc = Document.Merge(list.Select(m =>
 | 
			
		||||
                new CreditNote(Context, payments[m.MgNr], data[m.MgNr])
 | 
			
		||||
            ));
 | 
			
		||||
            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();
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -31,6 +31,7 @@ namespace Elwig.Windows {
 | 
			
		||||
            CalculateBucketsButton.IsEnabled = valid && last;
 | 
			
		||||
            DeliveryConfirmationButton.IsEnabled = valid;
 | 
			
		||||
            OverUnderDeliveryButton.IsEnabled = valid;
 | 
			
		||||
            PaymentButton.IsEnabled = valid;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        private async void CalculateBucketsButton_Click(object sender, RoutedEventArgs evt) {
 | 
			
		||||
@@ -82,8 +83,9 @@ namespace Elwig.Windows {
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        private void PaymentButton_Click(object sender, RoutedEventArgs evt) {
 | 
			
		||||
            var w = new ChartWindow();
 | 
			
		||||
            w.Show();
 | 
			
		||||
            if (SeasonInput.Value is not int year)
 | 
			
		||||
                return;
 | 
			
		||||
            App.FocusPaymentVariantsWindow(year);
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -5,7 +5,7 @@
 | 
			
		||||
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
 | 
			
		||||
        xmlns:local="clr-namespace:Elwig.Windows"
 | 
			
		||||
        xmlns:xctk="http://schemas.xceed.com/wpf/xaml/toolkit"
 | 
			
		||||
        Title="Test Fenster - Elwig" MinHeight="400" MinWidth="325" Height="450" Width="800" ResizeMode="CanResize" Loaded="Window_Loaded">
 | 
			
		||||
        Title="Test Fenster - Elwig" MinHeight="400" MinWidth="325" Height="450" Width="800" ResizeMode="CanResize">
 | 
			
		||||
    <Grid>
 | 
			
		||||
        <xctk:CheckComboBox x:Name="MyComboBox" HorizontalAlignment="Left" Margin="216,186,0,0" VerticalAlignment="Top" Delimiter=", "
 | 
			
		||||
                            SelectedValue="{Binding SelectedValue}"
 | 
			
		||||
@@ -16,14 +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="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"/>
 | 
			
		||||
        <Button x:Name="ChartButton" Content="Chart" Click="ChartButton_Click"
 | 
			
		||||
                Margin="50,240,0,0" VerticalAlignment="Top" HorizontalAlignment="Left"/>
 | 
			
		||||
        <Button x:Name="ZipButton" Content="ZIP-File" Click="ZipButton_Click"
 | 
			
		||||
                Margin="50,270,0,0" VerticalAlignment="Top" HorizontalAlignment="Left"/>
 | 
			
		||||
 | 
			
		||||
        <Button x:Name="PdfDeliveryButton" Content="Lieferschein Erzeugen" Click="PdfDeliveryButton_Click" Tag="Print" IsEnabled="False"
 | 
			
		||||
                Margin="260,190,0,0" VerticalAlignment="Top" HorizontalAlignment="Left"/>
 | 
			
		||||
        <Button x:Name="PdfCreditButton" Content="Gutschrift Erzeugen" Click="PdfCreditButton_Click" Tag="Print" IsEnabled="False"
 | 
			
		||||
                Margin="260,160,0,0" VerticalAlignment="Top" HorizontalAlignment="Left"/>
 | 
			
		||||
    </Grid>
 | 
			
		||||
</Window>
 | 
			
		||||
 
 | 
			
		||||
@@ -21,11 +21,6 @@ namespace Elwig.Windows {
 | 
			
		||||
            MyListBox.ItemsSource = new string[] { "Test 1", "Test 2", "Test 3", "Test 4" };
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        private void Window_Loaded(object sender, RoutedEventArgs evt) {
 | 
			
		||||
            PdfDeliveryButton.IsEnabled = App.IsPrintingReady;
 | 
			
		||||
            PdfCreditButton.IsEnabled = App.IsPrintingReady;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        private void OnItemSelectionChanged(object sender, ItemSelectionChangedEventArgs e) {
 | 
			
		||||
            MyText.Text = string.Join(", ", MyComboBox.SelectedItems.Cast<string>());
 | 
			
		||||
        }
 | 
			
		||||
@@ -50,33 +45,10 @@ namespace Elwig.Windows {
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        private void ChartButton_Click(object sender, RoutedEventArgs evt) {
 | 
			
		||||
            var w = new ChartWindow();
 | 
			
		||||
            w.Show();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        private async void ZipButton_Click(object sender, RoutedEventArgs evt) {
 | 
			
		||||
            using var ctx = new AppDbContext();
 | 
			
		||||
            using var ods = new OdsFile(@"C:\Users\Lorenz\Desktop\test.ods");
 | 
			
		||||
            await ods.AddTable(await DeliveryConfirmationData.ForMember(ctx.DeliveryParts, 2023, ctx.Members.Find(2948)));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        private async void PdfDeliveryButton_Click(object sender, RoutedEventArgs evt) {
 | 
			
		||||
            Mouse.OverrideCursor = Cursors.AppStarting;
 | 
			
		||||
            using var ctx = new AppDbContext();
 | 
			
		||||
            using var doc = new DeliveryNote(await ctx.Deliveries.OrderBy(d => d.Parts.Count).ThenBy(d => d.Year).ThenBy(d => d.DId).LastAsync(), ctx);
 | 
			
		||||
            await doc.Generate();
 | 
			
		||||
            doc.Show();
 | 
			
		||||
            Mouse.OverrideCursor = null;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        private async void PdfCreditButton_Click(object sender, RoutedEventArgs evt) {
 | 
			
		||||
            Mouse.OverrideCursor = Cursors.AppStarting;
 | 
			
		||||
            using var ctx = new AppDbContext();
 | 
			
		||||
            using var doc = new CreditNote(await ctx.Credits.FirstAsync(), ctx);
 | 
			
		||||
            await doc.Generate();
 | 
			
		||||
            doc.Show();
 | 
			
		||||
            Mouse.OverrideCursor = null;
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user