Rename solution directory to Elwig
This commit is contained in:
21
Elwig/Windows/ContractListWindow.xaml
Normal file
21
Elwig/Windows/ContractListWindow.xaml
Normal file
@ -0,0 +1,21 @@
|
||||
<Window x:Class="Elwig.Windows.ContractListWindow"
|
||||
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="Flächenbindungen" Height="450" Width="800">
|
||||
<Grid>
|
||||
<DataGrid x:Name="ContractList" AutoGenerateColumns="False" HeadersVisibility="Column" IsReadOnly="True" GridLinesVisibility="None" SelectionMode="Single"
|
||||
CanUserDeleteRows="False" CanUserResizeRows="False" CanUserAddRows="False" SelectionChanged="ContractList_SelectionChanged">
|
||||
<DataGrid.Columns>
|
||||
<DataGridTextColumn Header="Vnr." Binding="{Binding Vnr}" Width="50"/>
|
||||
<DataGridTextColumn Header="MgNr." Binding="{Binding MgNr}" Width="50"/>
|
||||
<DataGridTextColumn Header="From" Binding="{Binding YearFrom}" Width="50"/>
|
||||
<DataGridTextColumn Header="To" Binding="{Binding YearTo}" Width="*"/>
|
||||
</DataGrid.Columns>
|
||||
</DataGrid>
|
||||
|
||||
</Grid>
|
||||
</Window>
|
30
Elwig/Windows/ContractListWindow.xaml.cs
Normal file
30
Elwig/Windows/ContractListWindow.xaml.cs
Normal file
@ -0,0 +1,30 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using Elwig.Helpers;
|
||||
using Elwig.Models;
|
||||
|
||||
namespace Elwig.Windows {
|
||||
public partial class ContractListWindow : Window {
|
||||
private readonly AppDbContext Context = new();
|
||||
|
||||
public ContractListWindow(Member member) {
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
private void RefreshContractList() {
|
||||
Context.Members.Load();
|
||||
List<Contract> contracts = Context.Contracts.OrderBy(c => c.MgNr).ToList();
|
||||
|
||||
ContractList.ItemsSource = contracts;
|
||||
if (contracts.Count == 1)
|
||||
ContractList.SelectedIndex = 0;
|
||||
}
|
||||
|
||||
private void ContractList_SelectionChanged(object sender, SelectionChangedEventArgs evt) {
|
||||
RefreshContractList();
|
||||
}
|
||||
}
|
||||
}
|
12
Elwig/Windows/DeliveryReceptionWindow.xaml
Normal file
12
Elwig/Windows/DeliveryReceptionWindow.xaml
Normal file
@ -0,0 +1,12 @@
|
||||
<Window x:Class="Elwig.Windows.DeliveryReceptionWindow"
|
||||
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="Übernahme" Height="450" Width="800">
|
||||
<Grid>
|
||||
|
||||
</Grid>
|
||||
</Window>
|
9
Elwig/Windows/DeliveryReceptionWindow.xaml.cs
Normal file
9
Elwig/Windows/DeliveryReceptionWindow.xaml.cs
Normal file
@ -0,0 +1,9 @@
|
||||
using System.Windows;
|
||||
|
||||
namespace Elwig.Windows {
|
||||
public partial class DeliveryReceptionWindow : Window {
|
||||
public DeliveryReceptionWindow() {
|
||||
InitializeComponent();
|
||||
}
|
||||
}
|
||||
}
|
15
Elwig/Windows/DocumentViewerWindow.xaml
Normal file
15
Elwig/Windows/DocumentViewerWindow.xaml
Normal file
@ -0,0 +1,15 @@
|
||||
<Window x:Class="Elwig.Windows.DocumentViewerWindow"
|
||||
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:wv2="clr-namespace:Microsoft.Web.WebView2.Wpf;assembly=Microsoft.Web.WebView2.Wpf"
|
||||
xmlns:local="clr-namespace:Elwig.Windows"
|
||||
mc:Ignorable="d"
|
||||
Closed="OnClosed"
|
||||
Title="PDF Ansicht"
|
||||
MinHeight="600" MinWidth="420" Height="750" Width="525">
|
||||
<Grid>
|
||||
<wv2:WebView2 Name="WebView"/>
|
||||
</Grid>
|
||||
</Window>
|
25
Elwig/Windows/DocumentViewerWindow.xaml.cs
Normal file
25
Elwig/Windows/DocumentViewerWindow.xaml.cs
Normal file
@ -0,0 +1,25 @@
|
||||
using System;
|
||||
using System.Windows;
|
||||
using Elwig.Helpers;
|
||||
|
||||
namespace Elwig.Windows {
|
||||
public partial class DocumentViewerWindow : Window {
|
||||
|
||||
private TempFile? PdfFile = null;
|
||||
|
||||
public DocumentViewerWindow(string title, string path) {
|
||||
InitializeComponent();
|
||||
Title = Title + " - " + title;
|
||||
WebView.Source = new($"file://{path}#view=FitH");
|
||||
}
|
||||
|
||||
public DocumentViewerWindow(string title, TempFile file) : this(title, file.FilePath) {
|
||||
PdfFile = file;
|
||||
}
|
||||
|
||||
public void OnClosed(object sender, EventArgs evt) {
|
||||
PdfFile?.Dispose();
|
||||
PdfFile = null;
|
||||
}
|
||||
}
|
||||
}
|
14
Elwig/Windows/MainWindow.xaml
Normal file
14
Elwig/Windows/MainWindow.xaml
Normal file
@ -0,0 +1,14 @@
|
||||
<Window x:Class="Elwig.Windows.MainWindow"
|
||||
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="Elwig" Height="450" Width="800" ResizeMode="CanResize" SizeToContent="Manual"
|
||||
Loaded="Window_Loaded">
|
||||
<Grid>
|
||||
<Button x:Name="Button2" Content="Mitglieder" Margin="472,182,178,0" VerticalAlignment="Top" Click="Button2_Click"/>
|
||||
<Button x:Name="Button4" Content="Generate" Margin="425,300,225,0" VerticalAlignment="Top" Click="Button4_Click" Tag="Print"/>
|
||||
</Grid>
|
||||
</Window>
|
44
Elwig/Windows/MainWindow.xaml.cs
Normal file
44
Elwig/Windows/MainWindow.xaml.cs
Normal file
@ -0,0 +1,44 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using System.Runtime.Intrinsics.X86;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using Elwig.Documents;
|
||||
using Elwig.Helpers;
|
||||
|
||||
namespace Elwig.Windows {
|
||||
public partial class MainWindow : Window {
|
||||
private readonly AppDbContext Context = new();
|
||||
|
||||
public MainWindow() {
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
private void Window_Loaded(object sender, RoutedEventArgs evt) {
|
||||
Context.Countries.Load();
|
||||
Button4.IsEnabled = App.IsPrintingReady;
|
||||
}
|
||||
|
||||
protected override void OnClosing(CancelEventArgs evt) {
|
||||
Context.Dispose();
|
||||
base.OnClosing(evt);
|
||||
}
|
||||
|
||||
private void Button2_Click(object sender, RoutedEventArgs evt) {
|
||||
var w = new MemberListWindow();
|
||||
w.Show();
|
||||
}
|
||||
|
||||
private void Button4_Click(object sender, RoutedEventArgs evt) {
|
||||
Utils.RunBackground("PDF Generation", async () => {
|
||||
using var letter = new BusinessLetter("Test Dokument", Context.Members.First());
|
||||
await letter.Generate();
|
||||
letter.Show();
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
308
Elwig/Windows/MemberListWindow.xaml
Normal file
308
Elwig/Windows/MemberListWindow.xaml
Normal file
@ -0,0 +1,308 @@
|
||||
<Window x:Class="Elwig.Windows.MemberListWindow"
|
||||
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"
|
||||
Title="Mitglieder verwalten - Elwig" Height="600" Width="1200" MinHeight="600" MinWidth="1000"
|
||||
Loaded="Window_Loaded">
|
||||
<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="IsReadOnly" Value="True"/>
|
||||
<Setter Property="Height" Value="25"/>
|
||||
<Setter Property="TextWrapping" Value="NoWrap"/>
|
||||
</Style>
|
||||
<Style TargetType="ComboBox">
|
||||
<Setter Property="IsEnabled" Value="False"/>
|
||||
<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.RowDefinitions>
|
||||
<RowDefinition Height="19"/>
|
||||
<RowDefinition Height="0.8*"/>
|
||||
<RowDefinition Height="1*"/>
|
||||
<RowDefinition Height="1.3*"/>
|
||||
<RowDefinition Height="0.9*"/>
|
||||
</Grid.RowDefinitions>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="370"/>
|
||||
<ColumnDefinition Width="1*"/>
|
||||
<ColumnDefinition Width="1*"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<Menu Grid.ColumnSpan="3" BorderThickness="0,0,0,1" BorderBrush="LightGray" Background="White">
|
||||
<MenuItem Header="Mitglied">
|
||||
<MenuItem x:Name="Menu_Member_SendEmail" Header="E-Mail senden" IsEnabled="False"
|
||||
Click="Menu_Member_SendEmail_Click"/>
|
||||
</MenuItem>
|
||||
<MenuItem Header="Drucken">
|
||||
<MenuItem Header="Stammdatenblatt drucken"/>
|
||||
<MenuItem Header="Mitgliederliste drucken"/>
|
||||
</MenuItem>
|
||||
<MenuItem Header="Rundschreiben">
|
||||
<MenuItem Header="Runschreiben ausschicken"/>
|
||||
<MenuItem Header="Alle Stammdatenblätter ausschicken"/>
|
||||
</MenuItem>
|
||||
<MenuItem Header="Werkzeuge">
|
||||
<MenuItem Header="Alle Mitglieder überprüfen"/>
|
||||
</MenuItem>
|
||||
</Menu>
|
||||
|
||||
<Grid Grid.RowSpan="4" Grid.Row="1">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="125"/>
|
||||
<ColumnDefinition Width="120"/>
|
||||
<ColumnDefinition Width="125"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<TextBox x:Name="SearchInput" Grid.ColumnSpan="3" Margin="10,7,145,0" IsReadOnly="False"
|
||||
TextChanged="SearchInput_TextChanged"/>
|
||||
<CheckBox x:Name="ActiveMemberInput" Content="Nur aktive anzeigen"
|
||||
Checked="ActiveMemberInput_Changed" Unchecked="ActiveMemberInput_Changed"
|
||||
HorizontalAlignment="Right" Margin="0,12,10,0" VerticalAlignment="Top" Grid.Column="1" Grid.ColumnSpan="2"/>
|
||||
<DataGrid x:Name="MemberList" AutoGenerateColumns="False" HeadersVisibility="Column" IsReadOnly="True" GridLinesVisibility="None" SelectionMode="Single"
|
||||
CanUserDeleteRows="False" CanUserResizeRows="False" CanUserAddRows="False"
|
||||
SelectionChanged="MemberList_SelectionChanged"
|
||||
Margin="10,39,10,47" FontSize="14" Grid.ColumnSpan="3">
|
||||
<DataGrid.Columns>
|
||||
<DataGridTextColumn Header="MgNr." Binding="{Binding MgNr}" Width="70"/>
|
||||
<DataGridTextColumn Header="Nachname" Binding="{Binding FamilyName}" Width="4*"/>
|
||||
<DataGridTextColumn Header="Vorname" Binding="{Binding GivenName}" Width="3*"/>
|
||||
</DataGrid.Columns>
|
||||
</DataGrid>
|
||||
|
||||
<Button x:Name="NewMemberButton" Content="Neu" Click="NewMemberButton_Click"
|
||||
HorizontalAlignment="Left" VerticalAlignment="Bottom" Margin="10,10,0,10" Width="110" Grid.Column="0"/>
|
||||
<Button x:Name="EditMemberButton" Content="Bearbeiten" Click="EditMemberButton_Click" IsEnabled="False"
|
||||
HorizontalAlignment="Center" VerticalAlignment="Bottom" Margin="0,10,0,10" Width="110" Grid.Column="1"/>
|
||||
<Button x:Name="DeleteMemberButton" Content="Löschen" Click="DeleteMemberButton_Click" IsEnabled="False"
|
||||
HorizontalAlignment="Right" VerticalAlignment="Bottom" Margin="0,10,10,10" Width="110" Grid.Column="2"/>
|
||||
|
||||
<Button x:Name="SaveButton" Content="Speichern" Click="SaveButton_Click" IsEnabled="False" Visibility="Hidden"
|
||||
HorizontalAlignment="Left" VerticalAlignment="Bottom" Margin="10,10,0,10" Width="110" Grid.Column="0"/>
|
||||
<Button x:Name="ResetButton" Content="Zurücksetzen" Click="ResetButton_Click" IsEnabled="False" Visibility="Hidden"
|
||||
HorizontalAlignment="Center" VerticalAlignment="Bottom" Margin="0,10,0,10" Width="110" Grid.Column="1"/>
|
||||
<Button x:Name="CancelButton" Content="Abbrechen" Click="CancelButton_Click" IsEnabled="False" Visibility="Hidden" IsCancel="True"
|
||||
HorizontalAlignment="Right" VerticalAlignment="Bottom" Margin="0,10,10,10" Width="110" Grid.Column="2"/>
|
||||
</Grid>
|
||||
|
||||
<GroupBox Header="Persönliche Daten" Grid.Column="1" Grid.Row="1" Grid.RowSpan="2" Margin="5,5,5,5">
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="80"/>
|
||||
<ColumnDefinition Width="3*"/>
|
||||
<ColumnDefinition Width="50"/>
|
||||
<ColumnDefinition Width="2*"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<Label Content="MgNr.:" Margin="10,10,0,0" Grid.Column="0"/>
|
||||
<TextBox x:Name="MgNrInput" Margin="0,10,0,0" Width="48" Grid.Column="1" TextAlignment="Right" HorizontalAlignment="Left"
|
||||
TextChanged="MgNrInput_TextChanged" LostFocus="MgNrInput_LostFocus"/>
|
||||
|
||||
<Label Content="Vorg.:" Margin="10,10,0,0" Grid.Column="2"/>
|
||||
<TextBox x:Name="PredecessorMgNrInput" Margin="0,10,10,0" Width="48" Grid.Column="3" TextAlignment="Right" HorizontalAlignment="Left"
|
||||
TextChanged="PredecessorMgNrInput_TextChanged" LostFocus="PredecessorMgNrInput_LostFocus"/>
|
||||
|
||||
<Label Content="Vorname:" Margin="10,40,0,0" Grid.Column="0"/>
|
||||
<TextBox x:Name="GivenNameInput" Margin="0,40,0,0" Grid.Column="1"
|
||||
TextChanged="TextBox_TextChanged"/>
|
||||
|
||||
<Label Content="Präfix:" Margin="10,40,0,0" Grid.Column="2"/>
|
||||
<TextBox x:Name="PrefixInput" Margin="0,40,10,0" Grid.Column="3"
|
||||
TextChanged="TextBox_TextChanged"/>
|
||||
|
||||
<Label Content="Nachname:" Margin="10,70,0,0" Grid.Column="0"/>
|
||||
<TextBox x:Name="FamilyNameInput" Margin="0,70,0,0" Grid.Column="1"
|
||||
TextChanged="TextBox_TextChanged"/>
|
||||
|
||||
<Label Content="Suffix:" Margin="10,70,0,0" Grid.Column="2"/>
|
||||
<TextBox x:Name="SuffixInput" Margin="0,70,10,0" Grid.Column="3"
|
||||
TextChanged="TextBox_TextChanged"/>
|
||||
|
||||
<Label Content="Geburtstag:" Margin="10,100,0,0" Grid.Column="0"/>
|
||||
<TextBox x:Name="BirthdayInput" Margin="0,100,0,0" Grid.Column="1" Width="78" TextAlignment="Right" HorizontalAlignment="Left"
|
||||
TextChanged="BirthdayInput_TextChanged"/>
|
||||
|
||||
<Label Content="Adresse:" Margin="10,130,0,0"/>
|
||||
<TextBox x:Name="AddressInput" Margin="0,130,10,0" Grid.Column="1" Grid.ColumnSpan="3"
|
||||
TextChanged="TextBox_TextChanged"/>
|
||||
|
||||
<Label Content="PLZ/Ort:" Margin="10,160,0,0" Grid.Column="0"/>
|
||||
<TextBox x:Name="PlzInput" Margin="0,160,0,0" Width="42" Grid.Column="1" HorizontalAlignment="Left"
|
||||
TextChanged="PlzInput_TextChanged" LostFocus="PlzInput_LostFocus"/>
|
||||
<ComboBox x:Name="OrtInput" ItemTemplate="{StaticResource PostalDestComboBoxTemplate}" TextSearch.TextPath="Ort.Name"
|
||||
SelectionChanged="ComboBox_SelectionChanged"
|
||||
Margin="47,160,10,0" Grid.Column="1" Grid.ColumnSpan="3"/>
|
||||
</Grid>
|
||||
</GroupBox>
|
||||
<GroupBox Header="Kontaktdaten" Grid.Column="1" Grid.Row="3" Margin="5,5,5,5">
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="115"/>
|
||||
<ColumnDefinition/>
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<Label Content="E-Mail-Adresse:" Margin="10,10,0,0" Grid.Column="0"/>
|
||||
<TextBox x:Name="EmailInput" Margin="0,10,10,0" Grid.Column="1"
|
||||
TextChanged="EmailInput_TextChanged" LostFocus="EmailInput_LostFocus"/>
|
||||
|
||||
<Label Content="Tel.-Nr. (Festnetz):" Margin="10,40,0,0" Grid.Column="0"/>
|
||||
<TextBox x:Name="PhoneLandlineInput" Margin="0,40,10,0" Grid.Column="1"
|
||||
TextChanged="PhoneNrInput_TextChanged" LostFocus="PhoneNrInput_LostFocus"/>
|
||||
|
||||
<Label Content="Tel.-Nr. (mobil):" Margin="10,70,0,0" Grid.Column="0"/>
|
||||
<TextBox x:Name="PhoneMobile1Input" Margin="0,70,10,0" Grid.Column="1"
|
||||
TextChanged="PhoneNrInput_TextChanged" LostFocus="PhoneNrInput_LostFocus"/>
|
||||
|
||||
<Label Content="Tel.-Nr. (mobil):" Margin="10,100,0,0" Grid.Column="0"/>
|
||||
<TextBox x:Name="PhoneMobile2Input" Margin="0,100,10,0" Grid.Column="1"
|
||||
TextChanged="PhoneNrInput_TextChanged" LostFocus="PhoneNrInput_LostFocus"/>
|
||||
</Grid>
|
||||
</GroupBox>
|
||||
<GroupBox Header="Bankverbindung" Grid.Column="1" Grid.Row="4" Margin="5,5,5,10">
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="65"/>
|
||||
<ColumnDefinition/>
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<Label Content="IBAN:" Margin="10,10,0,0" Grid.Column="0"/>
|
||||
<TextBox x:Name="IbanInput" Margin="0,10,10,0" Grid.Column="1"
|
||||
TextChanged="IbanInput_TextChanged" LostFocus="IbanInput_LostFocus"/>
|
||||
|
||||
<Label Content="BIC:" Margin="10,40,0,0" Grid.Column="0"/>
|
||||
<TextBox x:Name="BicInput" Margin="0,40,10,0" Grid.Column="1"
|
||||
TextChanged="BicInput_TextChanged" LostFocus="BicInput_LostFocus"/>
|
||||
</Grid>
|
||||
</GroupBox>
|
||||
<GroupBox Header="Betrieb" Grid.Column="2" Grid.Row="1" Grid.RowSpan="1" Margin="5,5,5,5">
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="90"/>
|
||||
<ColumnDefinition Width="150"/>
|
||||
<ColumnDefinition/>
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<Label Content="UID:" Margin="10,10,0,0" Grid.Column="0"/>
|
||||
<TextBox x:Name="UstIdInput" Margin="0,10,10,0" Grid.Column="1" Width="120" HorizontalAlignment="Left"
|
||||
TextChanged="UstIdInput_TextChanged" LostFocus="UstIdInput_LostFocus"/>
|
||||
|
||||
<Label Content="BetriebsNr.:" Margin="10,40,0,0" Grid.Column="0"/>
|
||||
<TextBox x:Name="LfbisNrInput" Margin="0,40,10,0" Grid.Column="1" Width="64" HorizontalAlignment="Left" TextAlignment="Right"
|
||||
TextChanged="LfbisNrInput_TextChanged" LostFocus="LfbisNrInput_LostFocus"/>
|
||||
|
||||
<CheckBox x:Name="BuchführendInput" Content="Buchführend" IsEnabled="False"
|
||||
Checked="CheckBox_Changed" Unchecked="CheckBox_Changed"
|
||||
Grid.Column="2" HorizontalAlignment="Left" Margin="10,15,0,0" VerticalAlignment="Top" IsChecked="False"/>
|
||||
</Grid>
|
||||
</GroupBox>
|
||||
<GroupBox Header="Rechnungsadresse (optional)" Grid.Column="2" Grid.Row="2" Grid.RowSpan="1" Margin="5,5,5,5">
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="65"/>
|
||||
<ColumnDefinition/>
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<Label Content="Name:" Margin="10,10,0,0" Grid.Column="0"/>
|
||||
<TextBox x:Name="BillingName" Margin="0,10,10,10" Grid.Column="1" Grid.ColumnSpan="2"
|
||||
TextChanged="TextBox_TextChanged"/>
|
||||
|
||||
<Label Content="Adresse:" Margin="10,40,0,0" Grid.Column="0"/>
|
||||
<TextBox x:Name="BillingAddressInput" Margin="0,40,10,0" Grid.Column="1"
|
||||
TextChanged="TextBox_TextChanged"/>
|
||||
|
||||
<Label Content="PLZ/Ort:" Margin="10,70,0,0" Grid.Column="0"/>
|
||||
<TextBox x:Name="BillingPlzInput" Margin="0,70,0,0" Width="42" Grid.Column="1" HorizontalAlignment="Left"
|
||||
TextChanged="BillingPlzInput_TextChanged" LostFocus="BillingPlzInput_LostFocus"/>
|
||||
<ComboBox x:Name="BillingOrtInput" ItemTemplate="{StaticResource PostalDestComboBoxTemplate}" TextSearch.TextPath="Ort.Name"
|
||||
SelectionChanged="ComboBox_SelectionChanged"
|
||||
Margin="47,70,10,0" Grid.Column="1"/>
|
||||
</Grid>
|
||||
</GroupBox>
|
||||
<GroupBox Header="Genossenschaft" Grid.Column="2" Grid.Row="3" Grid.RowSpan="2" Margin="5,5,5,10">
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="120"/>
|
||||
<ColumnDefinition Width="120"/>
|
||||
<ColumnDefinition/>
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<Label Content="Eintritt:" Margin="10,10,0,0" Grid.Column="0"/>
|
||||
<TextBox x:Name="EntryDateInput" Margin="0,10,10,0" Width="78" Grid.Column="1" HorizontalAlignment="Left" TextAlignment="Right"
|
||||
TextChanged="DateInput_TextChanged"/>
|
||||
|
||||
<Label Content="Austritt:" Margin="10,40,0,0" Grid.Column="0"/>
|
||||
<TextBox x:Name="ExitDateInput" Margin="0,40,10,0" Width="78" Grid.Column="1" HorizontalAlignment="Left" TextAlignment="Right"
|
||||
TextChanged="DateInput_TextChanged"/>
|
||||
|
||||
<Label Content="Geschäftsanteile:" Margin="10,70,0,0" Grid.Column="0"/>
|
||||
<TextBox x:Name="BusinessSharesInput" Margin="0,70,10,0" Width="48" Grid.Column="1" HorizontalAlignment="Left" TextAlignment="Right"
|
||||
TextChanged="NumericInput_TextChanged"/>
|
||||
|
||||
<Label Content="BH-Konto:" Margin="10,100,0,0" Grid.Column="0"/>
|
||||
<TextBox x:Name="AccountingNrInput" Margin="0,100,10,0" Grid.Column="1"
|
||||
TextChanged="TextBox_TextChanged"/>
|
||||
|
||||
<CheckBox x:Name="ActiveInput" Content="Aktiv" IsEnabled="False"
|
||||
Checked="CheckBox_Changed" Unchecked="CheckBox_Changed"
|
||||
Grid.Column="2" HorizontalAlignment="Left" Margin="10,15,0,0" VerticalAlignment="Top" IsChecked="False"/>
|
||||
|
||||
<CheckBox x:Name="VollLieferantInput" Content="Volllieferant" IsEnabled="False"
|
||||
Checked="CheckBox_Changed" Unchecked="CheckBox_Changed"
|
||||
Grid.Column="2" HorizontalAlignment="Left" Margin="10,45,0,0" VerticalAlignment="Top" IsChecked="False"/>
|
||||
|
||||
<CheckBox x:Name="FunkionärInput" Content="Funktionär" IsEnabled="False"
|
||||
Checked="CheckBox_Changed" Unchecked="CheckBox_Changed"
|
||||
Grid.Column="2" HorizontalAlignment="Left" Margin="10,75,0,0" VerticalAlignment="Top" IsChecked="False"/>
|
||||
|
||||
<Label Content="StammZwst.:" Margin="10,130,0,0" Grid.Column="0"/>
|
||||
<ComboBox x:Name="BranchInput" ItemTemplate="{StaticResource BranchTemplate}" TextSearch.TextPath="Name"
|
||||
SelectionChanged="ComboBox_SelectionChanged"
|
||||
Margin="0,130,10,0" Grid.Column="1" Grid.ColumnSpan="2"/>
|
||||
|
||||
<Label Content="Stammgemeinde:" Margin="10,160,0,0" Grid.Column="0"/>
|
||||
<ComboBox x:Name="DefaultKgInput" ItemTemplate="{StaticResource KgTemplate}" TextSearch.TextPath="Name"
|
||||
SelectionChanged="ComboBox_SelectionChanged"
|
||||
Margin="0,160,10,0" Grid.Column="1" Grid.ColumnSpan="2"/>
|
||||
|
||||
<Label Content="Anmerkung:" Margin="10,190,0,0" Grid.Column="0"/>
|
||||
<TextBox x:Name="CommentInput" Margin="0,190,10,0" Grid.Column="1" Grid.ColumnSpan="2"
|
||||
TextChanged="TextBox_TextChanged"/>
|
||||
|
||||
<Label Content="Kontaktart:" Margin="10,220,0,0" Grid.Column="0"/>
|
||||
<RadioButton x:Name="ContactPostInput" GroupName="DefaultContact" Content="Post" IsEnabled="False"
|
||||
Checked="RadioButton_Changed" Unchecked="RadioButton_Changed"
|
||||
HorizontalAlignment="Left" Margin="0,225,0,0" VerticalAlignment="Top" Grid.Column="1" Grid.ColumnSpan="2"/>
|
||||
<RadioButton x:Name="ContactEmailInput" GroupName="DefaultContact" Content="E-Mail" IsEnabled="False"
|
||||
Checked="RadioButton_Changed" Unchecked="RadioButton_Changed"
|
||||
HorizontalAlignment="Left" Margin="60,225,0,0" VerticalAlignment="Top" Grid.Column="1" Grid.ColumnSpan="2"/>
|
||||
|
||||
<Label Content="Gebundene Fläche:" Margin="10,250,0,0" Grid.Column="0"/>
|
||||
<TextBlock x:Name="AreaCommitment" Text="- m²"
|
||||
Grid.Column="1" HorizontalAlignment="Stretch" Margin="5,252,5,0" TextWrapping="NoWrap" VerticalAlignment="Top" FontSize="14" TextAlignment="Right"/>
|
||||
|
||||
<Button x:Name="ContractButton" Content="Flächenbindungen" Click="ContractButton_Click"
|
||||
HorizontalAlignment="Right" Margin="10,10,10,10" VerticalAlignment="Bottom" Grid.ColumnSpan="3"/>
|
||||
</Grid>
|
||||
</GroupBox>
|
||||
</Grid>
|
||||
</Window>
|
674
Elwig/Windows/MemberListWindow.xaml.cs
Normal file
674
Elwig/Windows/MemberListWindow.xaml.cs
Normal file
@ -0,0 +1,674 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using ModernWpf.Controls;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Input;
|
||||
using Elwig.Helpers;
|
||||
using Elwig.Models;
|
||||
|
||||
|
||||
namespace Elwig.Windows {
|
||||
public partial class MemberListWindow : Window {
|
||||
private bool IsEditing = false;
|
||||
private bool IsCreating = false;
|
||||
private List<string> TextFilter = new();
|
||||
private readonly Control[] ExemptInputs;
|
||||
private IEnumerable<TextBox> TextBoxInputs = Array.Empty<TextBox>();
|
||||
private IEnumerable<ComboBox> ComboBoxInputs = Array.Empty<ComboBox>();
|
||||
private IEnumerable<CheckBox> CheckBoxInputs = Array.Empty<CheckBox>();
|
||||
private IEnumerable<RadioButton> RadioButtonInputs = Array.Empty<RadioButton>();
|
||||
private readonly Dictionary<Control, bool> Valid = new();
|
||||
private readonly Dictionary<Control, object?> OriginalValues = new();
|
||||
private readonly RoutedCommand CtrlF = new();
|
||||
private readonly AppDbContext Context = new();
|
||||
|
||||
public MemberListWindow() {
|
||||
InitializeComponent();
|
||||
CtrlF.InputGestures.Add(new KeyGesture(Key.F, ModifierKeys.Control));
|
||||
CommandBindings.Add(new CommandBinding(CtrlF, FocusSearchInput));
|
||||
ExemptInputs = new Control[] {
|
||||
SearchInput, ActiveMemberInput, MemberList,
|
||||
NewMemberButton, EditMemberButton, DeleteMemberButton,
|
||||
ResetButton, SaveButton, CancelButton
|
||||
};
|
||||
}
|
||||
|
||||
private void Window_Loaded(object sender, RoutedEventArgs evt) {
|
||||
ActiveMemberInput.IsChecked = true;
|
||||
BranchInput.ItemsSource = Context.Branches.OrderBy(b => b.Name).ToList();
|
||||
DefaultKgInput.ItemsSource = Context.WbKgs.Select(k => k.Kg).OrderBy(k => k.Name).ToList();
|
||||
TextBoxInputs = Utils.FindVisualChilds<TextBox>(this, ExemptInputs).ToList();
|
||||
ComboBoxInputs = Utils.FindVisualChilds<ComboBox>(this, ExemptInputs).ToList();
|
||||
CheckBoxInputs = Utils.FindVisualChilds<CheckBox>(this, ExemptInputs).ToList();
|
||||
RadioButtonInputs = Utils.FindVisualChilds<RadioButton>(this, ExemptInputs).ToList();
|
||||
foreach (var tb in TextBoxInputs)
|
||||
Valid[tb] = true;
|
||||
}
|
||||
|
||||
protected override void OnClosing(CancelEventArgs evt) {
|
||||
Context.Dispose();
|
||||
base.OnClosing(evt);
|
||||
}
|
||||
|
||||
private int CountMatchesInMember(Member m) {
|
||||
if (TextFilter.Count == 0) return 0;
|
||||
string?[] check = new string?[] { m.MgNr.ToString(), m.FamilyName.ToLower(), m.GivenName.ToLower(), m.DefaultKg?.Name?.ToLower() };
|
||||
int i = 0;
|
||||
foreach (string? c in check) {
|
||||
if (c == null) continue;
|
||||
if (TextFilter.Any(f => c == f))
|
||||
i += 10;
|
||||
else if (TextFilter.Any(f => c.Contains(f)))
|
||||
i += 1;
|
||||
}
|
||||
return i;
|
||||
}
|
||||
|
||||
private void RefreshMemberList() {
|
||||
Context.Members.Load();
|
||||
IQueryable<Member> memberQuery = Context.Members;
|
||||
if (ActiveMemberInput.IsChecked == true)
|
||||
memberQuery = memberQuery.Where(m => m.IsActive);
|
||||
|
||||
List<Member> members = memberQuery.ToList();
|
||||
members = members.OrderBy(m => m.FamilyName + " " + m.GivenName).ToList();
|
||||
|
||||
if (TextFilter.Count > 0) {
|
||||
members = members
|
||||
.ToDictionary(m => m, m => CountMatchesInMember(m))
|
||||
.OrderByDescending(a => a.Value)
|
||||
.Where(a => a.Value > 0)
|
||||
.Select(a => a.Key)
|
||||
.ToList();
|
||||
}
|
||||
MemberList.ItemsSource = members;
|
||||
if (members.Count == 1)
|
||||
MemberList.SelectedIndex = 0;
|
||||
|
||||
RefreshInputs();
|
||||
}
|
||||
|
||||
private void ClearInputStates() {
|
||||
foreach (var tb in TextBoxInputs)
|
||||
Utils.ClearInputState(tb);
|
||||
foreach (var cb in ComboBoxInputs)
|
||||
Utils.ClearInputState(cb);
|
||||
foreach (var cb in CheckBoxInputs)
|
||||
Utils.ClearInputState(cb);
|
||||
foreach (var rb in RadioButtonInputs)
|
||||
Utils.ClearInputState(rb);
|
||||
}
|
||||
|
||||
private void RefreshInputs(bool validate = false) {
|
||||
ClearInputStates();
|
||||
Member m = (Member)MemberList.SelectedItem;
|
||||
if (m != null) {
|
||||
EditMemberButton.IsEnabled = true;
|
||||
DeleteMemberButton.IsEnabled = true;
|
||||
FillInputs(m);
|
||||
} else {
|
||||
EditMemberButton.IsEnabled = false;
|
||||
DeleteMemberButton.IsEnabled = false;
|
||||
ClearInputs();
|
||||
}
|
||||
if (!validate) ClearInputStates();
|
||||
GC.Collect();
|
||||
}
|
||||
|
||||
private void InitInputs() {
|
||||
MgNrInput.Text = Utils.NextMgNr(Context).ToString();
|
||||
EntryDateInput.Text = DateTime.Now.ToString("dd.MM.yyyy");
|
||||
if (Context.Branches.Count() == 1)
|
||||
BranchInput.SelectedItem = Context.Branches.First();
|
||||
ActiveInput.IsChecked = true;
|
||||
ContactPostInput.IsChecked = true;
|
||||
FillOriginalValues();
|
||||
}
|
||||
|
||||
private void MemberList_SelectionChanged(object sender, RoutedEventArgs evt) {
|
||||
RefreshInputs();
|
||||
}
|
||||
|
||||
private void ActiveMemberInput_Changed(object sender, RoutedEventArgs evt) {
|
||||
RefreshMemberList();
|
||||
}
|
||||
|
||||
private void NewMemberButton_Click(object sender, RoutedEventArgs evt) {
|
||||
IsCreating = true;
|
||||
MemberList.IsEnabled = false;
|
||||
MemberList.SelectedItem = null;
|
||||
HideNewEditDeleteButtons();
|
||||
ShowSaveResetCancelButtons();
|
||||
UnlockInputs();
|
||||
InitInputs();
|
||||
LockSearchInputs();
|
||||
}
|
||||
|
||||
private void EditMemberButton_Click(object sender, RoutedEventArgs evt) {
|
||||
if (MemberList.SelectedItem == null)
|
||||
return;
|
||||
|
||||
IsEditing = true;
|
||||
MemberList.IsEnabled = false;
|
||||
|
||||
HideNewEditDeleteButtons();
|
||||
ShowSaveResetCancelButtons();
|
||||
UnlockInputs();
|
||||
LockSearchInputs();
|
||||
}
|
||||
|
||||
private void DeleteMemberButton_Click(object sender, RoutedEventArgs evt) {
|
||||
Member m = (Member)MemberList.SelectedItem;
|
||||
if (m == null) return;
|
||||
|
||||
var r = MessageBox.Show(
|
||||
$"Soll das Mitglied \"{m.FamilyName} {m.GivenName}\" (MgNr. {m.MgNr}) wirklich unwiderruflich gelöscht werden?",
|
||||
"Mitglied löschen", MessageBoxButton.YesNo, MessageBoxImage.Warning, MessageBoxResult.No);
|
||||
if (r == MessageBoxResult.Yes) {
|
||||
Context.Remove(m);
|
||||
Context.SaveChanges();
|
||||
RefreshMemberList();
|
||||
}
|
||||
}
|
||||
|
||||
private void SaveButton_Click(object sender, RoutedEventArgs evt) {
|
||||
Member? m = new();
|
||||
if (IsEditing)
|
||||
m = (Member)MemberList.SelectedItem;
|
||||
else if (IsCreating)
|
||||
m = new();
|
||||
|
||||
int newMgNr = int.Parse(MgNrInput.Text);
|
||||
m.PredecessorMgNr = (PredecessorMgNrInput.Text == "") ? null : int.Parse(PredecessorMgNrInput.Text);
|
||||
m.Prefix = (PrefixInput.Text == "") ? null : PrefixInput.Text;
|
||||
m.GivenName = GivenNameInput.Text;
|
||||
m.FamilyName = FamilyNameInput.Text;
|
||||
m.Suffix = (SuffixInput.Text == "") ? null : SuffixInput.Text;
|
||||
m.Birthday = (BirthdayInput.Text == "") ? null : string.Join("-", BirthdayInput.Text.Split(".").Reverse());
|
||||
m.CountryCode = "AT";
|
||||
m.PostalDestId = ((AT_PlzDest)OrtInput.SelectedItem).Id;
|
||||
m.Address = AddressInput.Text;
|
||||
|
||||
m.Email = (EmailInput.Text == "") ? null : EmailInput.Text;
|
||||
m.PhoneLandline = (PhoneLandlineInput.Text == "") ? null : PhoneLandlineInput.Text.Replace(" ", "");
|
||||
m.PhoneMobile1 = (PhoneMobile1Input.Text == "") ? null : PhoneMobile1Input.Text.Replace(" ", "");
|
||||
m.PhoneMobile2 = (PhoneMobile2Input.Text == "") ? null : PhoneMobile2Input.Text.Replace(" ", "");
|
||||
|
||||
m.Iban = (IbanInput.Text == "") ? null : IbanInput.Text.Replace(" ", "");
|
||||
m.Bic = (BicInput.Text == "") ? null : BicInput.Text;
|
||||
|
||||
m.UstId = (UstIdInput.Text == "") ? null : UstIdInput.Text;
|
||||
m.LfbisNr = (LfbisNrInput.Text == "") ? null : LfbisNrInput.Text;
|
||||
m.IsBuchführend = BuchführendInput.IsChecked ?? false;
|
||||
|
||||
// TODO Rechnungsadresse
|
||||
|
||||
m.EntryDate = (EntryDateInput.Text == "") ? null : string.Join("-", EntryDateInput.Text.Split(".").Reverse());
|
||||
m.ExitDate = (ExitDateInput.Text == "") ? null : string.Join("-", ExitDateInput.Text.Split(".").Reverse());
|
||||
m.BusinessShares = (BusinessSharesInput.Text == "") ? 0 : int.Parse(BusinessSharesInput.Text);
|
||||
m.AccountingNr = (AccountingNrInput.Text == "") ? null : AccountingNrInput.Text;
|
||||
m.IsActive = ActiveInput.IsChecked ?? false;
|
||||
m.IsVollLieferant = VollLieferantInput.IsChecked ?? false;
|
||||
m.IsFunktionär = FunkionärInput.IsChecked ?? false;
|
||||
m.ZwstId = ((Branch)BranchInput.SelectedItem).ZwstId;
|
||||
m.DefaultKgNr = ((AT_Kg)DefaultKgInput.SelectedItem).KgNr;
|
||||
m.Comment = (CommentInput.Text == "") ? null : CommentInput.Text;
|
||||
m.DefaultContact = "post";
|
||||
if (ContactPostInput.IsChecked ?? false) m.DefaultContact = "post";
|
||||
if (ContactEmailInput.IsChecked ?? false) m.DefaultContact = "email";
|
||||
|
||||
try {
|
||||
if (IsEditing)
|
||||
Context.Update(m);
|
||||
else if (IsCreating)
|
||||
Context.Add(m);
|
||||
Context.SaveChanges();
|
||||
|
||||
if (newMgNr != m.MgNr)
|
||||
Context.Database.ExecuteSql($"UPDATE member SET mgnr = {newMgNr} WHERE mgnr = {m.MgNr}");
|
||||
} catch (Exception exc) {
|
||||
var str = "Der Eintrag konnte nicht in der Datenbank aktualisiert werden!\n\n" + exc.Message;
|
||||
if (exc.InnerException != null) str += "\n\n" + exc.InnerException.Message;
|
||||
MessageBox.Show(str, "Mitglied aktualisieren", MessageBoxButton.OK, MessageBoxImage.Error);
|
||||
}
|
||||
|
||||
IsEditing = false;
|
||||
IsCreating = false;
|
||||
MemberList.IsEnabled = true;
|
||||
HideSaveResetCancelButtons();
|
||||
ShowNewEditDeleteButtons();
|
||||
LockInputs();
|
||||
UnlockSearchInputs();
|
||||
RefreshMemberList();
|
||||
}
|
||||
|
||||
private void ResetButton_Click(object sender, RoutedEventArgs evt) {
|
||||
if (IsEditing) {
|
||||
RefreshInputs();
|
||||
} else if (IsCreating) {
|
||||
InitInputs();
|
||||
}
|
||||
UpdateButtons();
|
||||
}
|
||||
|
||||
private void CancelButton_Click(object sender, RoutedEventArgs evt) {
|
||||
IsEditing = false;
|
||||
IsCreating = false;
|
||||
MemberList.IsEnabled = true;
|
||||
HideSaveResetCancelButtons();
|
||||
ShowNewEditDeleteButtons();
|
||||
RefreshInputs();
|
||||
ClearInputStates();
|
||||
LockInputs();
|
||||
UnlockSearchInputs();
|
||||
}
|
||||
|
||||
private void ContractButton_Click(object sender, RoutedEventArgs evt) {
|
||||
var w = new ContractListWindow((Member)MemberList.SelectedItem);
|
||||
w.Show();
|
||||
}
|
||||
|
||||
private void SearchInput_TextChanged(object sender, RoutedEventArgs evt) {
|
||||
TextFilter = SearchInput.Text.ToLower().Split(" ").ToList().FindAll(s => s != "");
|
||||
RefreshMemberList();
|
||||
}
|
||||
|
||||
private void Menu_Member_SendEmail_Click(object sender, RoutedEventArgs evt) {
|
||||
Utils.MailTo(((Member)MemberList.SelectedItem).Email);
|
||||
}
|
||||
|
||||
private void FocusSearchInput(object sender, RoutedEventArgs evt) {
|
||||
if (!IsEditing && !IsCreating) {
|
||||
SearchInput.Focus();
|
||||
SearchInput.SelectAll();
|
||||
}
|
||||
}
|
||||
|
||||
private void ShowSaveResetCancelButtons() {
|
||||
SaveButton.IsEnabled = false;
|
||||
ResetButton.IsEnabled = false;
|
||||
CancelButton.IsEnabled = true;
|
||||
SaveButton.Visibility = Visibility.Visible;
|
||||
ResetButton.Visibility = Visibility.Visible;
|
||||
CancelButton.Visibility = Visibility.Visible;
|
||||
}
|
||||
|
||||
private void HideSaveResetCancelButtons() {
|
||||
SaveButton.IsEnabled = false;
|
||||
ResetButton.IsEnabled = false;
|
||||
CancelButton.IsEnabled = false;
|
||||
SaveButton.Visibility = Visibility.Hidden;
|
||||
ResetButton.Visibility = Visibility.Hidden;
|
||||
CancelButton.Visibility = Visibility.Hidden;
|
||||
}
|
||||
|
||||
private void ShowNewEditDeleteButtons() {
|
||||
NewMemberButton.IsEnabled = true;
|
||||
EditMemberButton.IsEnabled = MemberList.SelectedItem != null;
|
||||
DeleteMemberButton.IsEnabled = MemberList.SelectedItem != null;
|
||||
NewMemberButton.Visibility = Visibility.Visible;
|
||||
EditMemberButton.Visibility = Visibility.Visible;
|
||||
DeleteMemberButton.Visibility = Visibility.Visible;
|
||||
}
|
||||
|
||||
private void HideNewEditDeleteButtons() {
|
||||
NewMemberButton.IsEnabled = false;
|
||||
EditMemberButton.IsEnabled = false;
|
||||
DeleteMemberButton.IsEnabled = false;
|
||||
NewMemberButton.Visibility = Visibility.Hidden;
|
||||
EditMemberButton.Visibility = Visibility.Hidden;
|
||||
DeleteMemberButton.Visibility = Visibility.Hidden;
|
||||
}
|
||||
|
||||
private void LockInputs() {
|
||||
foreach (var tb in TextBoxInputs)
|
||||
tb.IsReadOnly = true;
|
||||
foreach (var cb in ComboBoxInputs)
|
||||
cb.IsEnabled = false;
|
||||
foreach (var cb in CheckBoxInputs)
|
||||
cb.IsEnabled = false;
|
||||
foreach (var rb in RadioButtonInputs)
|
||||
rb.IsEnabled = false;
|
||||
}
|
||||
|
||||
private void UnlockInputs() {
|
||||
foreach (var tb in TextBoxInputs)
|
||||
tb.IsReadOnly = false;
|
||||
foreach (var cb in ComboBoxInputs)
|
||||
cb.IsEnabled = true;
|
||||
foreach (var cb in CheckBoxInputs)
|
||||
cb.IsEnabled = true;
|
||||
foreach (var rb in RadioButtonInputs)
|
||||
rb.IsEnabled = true;
|
||||
}
|
||||
|
||||
private void LockSearchInputs() {
|
||||
SearchInput.IsEnabled = false;
|
||||
ActiveMemberInput.IsEnabled = false;
|
||||
}
|
||||
|
||||
private void UnlockSearchInputs() {
|
||||
SearchInput.IsEnabled = true;
|
||||
ActiveMemberInput.IsEnabled = true;
|
||||
}
|
||||
|
||||
private void FillInputs(Member m) {
|
||||
OriginalValues.Clear();
|
||||
|
||||
MgNrInput.Text = m.MgNr.ToString();
|
||||
PredecessorMgNrInput.Text = m.PredecessorMgNr.ToString();
|
||||
PrefixInput.Text = m.Prefix;
|
||||
GivenNameInput.Text = m.GivenName;
|
||||
FamilyNameInput.Text = m.FamilyName;
|
||||
SuffixInput.Text = m.Suffix;
|
||||
BirthdayInput.Text = (m.Birthday != null) ? string.Join(".", m.Birthday.Split("-").Reverse()) : null;
|
||||
AddressInput.Text = m.Address;
|
||||
AT_PlzDest? p = m.PostalDest.AtPlz;
|
||||
if (p != null) {
|
||||
PlzInput.Text = p.Plz.ToString();
|
||||
OrtInput.ItemsSource = p.AtPlz.Orte;
|
||||
OrtInput.SelectedItem = p;
|
||||
} else {
|
||||
PlzInput.Text = null;
|
||||
OrtInput.ItemsSource = null;
|
||||
OrtInput.SelectedItem = null;
|
||||
}
|
||||
|
||||
EmailInput.Text = m.Email;
|
||||
PhoneLandlineInput.Text = m.PhoneLandline;
|
||||
PhoneMobile1Input.Text = m.PhoneMobile1;
|
||||
PhoneMobile2Input.Text = m.PhoneMobile2;
|
||||
|
||||
IbanInput.Text = m.Iban;
|
||||
BicInput.Text = m.Bic;
|
||||
|
||||
UstIdInput.Text = m.UstId;
|
||||
LfbisNrInput.Text = m.LfbisNr;
|
||||
BuchführendInput.IsChecked = m.IsBuchführend;
|
||||
|
||||
// TODO Rechnungsadresse
|
||||
|
||||
EntryDateInput.Text = (m.EntryDate != null) ? string.Join(".", m.EntryDate.Split("-").Reverse()) : null;
|
||||
ExitDateInput.Text = (m.ExitDate != null) ? string.Join(".", m.ExitDate.Split("-").Reverse()) : null;
|
||||
BusinessSharesInput.Text = m.BusinessShares.ToString();
|
||||
AccountingNrInput.Text = m.AccountingNr;
|
||||
BranchInput.SelectedItem = m.Branch;
|
||||
DefaultKgInput.SelectedItem = m.DefaultKg;
|
||||
CommentInput.Text = m.Comment;
|
||||
ActiveInput.IsChecked = m.IsActive;
|
||||
VollLieferantInput.IsChecked = m.IsVollLieferant;
|
||||
FunkionärInput.IsChecked = m.IsFunktionär;
|
||||
switch (m.DefaultContact) {
|
||||
case "post": ContactPostInput.IsChecked = true; break;
|
||||
case "email": ContactEmailInput.IsChecked = true; break;
|
||||
}
|
||||
|
||||
AreaCommitment.Text = $"{m.Contracts.Select(c => c.Area).Sum():N0} m²";
|
||||
|
||||
Menu_Member_SendEmail.IsEnabled = m.Email != null;
|
||||
|
||||
FillOriginalValues();
|
||||
}
|
||||
|
||||
private void FillOriginalValues() {
|
||||
foreach (var tb in TextBoxInputs)
|
||||
OriginalValues[tb] = tb.Text;
|
||||
foreach (var cb in ComboBoxInputs)
|
||||
OriginalValues[cb] = cb.SelectedItem;
|
||||
foreach (var cb in CheckBoxInputs)
|
||||
OriginalValues[cb] = (cb.IsChecked ?? false) ? bool.TrueString : null;
|
||||
foreach (var rb in RadioButtonInputs)
|
||||
OriginalValues[rb] = (rb.IsChecked ?? false) ? bool.TrueString : null;
|
||||
}
|
||||
|
||||
private void ClearInputs() {
|
||||
Menu_Member_SendEmail.IsEnabled = false;
|
||||
AreaCommitment.Text = "- m²";
|
||||
OriginalValues.Clear();
|
||||
foreach (var tb in TextBoxInputs) {
|
||||
tb.Text = " ";
|
||||
tb.Text = "";
|
||||
}
|
||||
foreach (var cb in ComboBoxInputs) {
|
||||
cb.SelectedItem = null;
|
||||
if (cb.ItemsSource != null)
|
||||
Utils.SetInputInvalid(cb);
|
||||
}
|
||||
foreach (var cb in CheckBoxInputs)
|
||||
cb.IsChecked = false;
|
||||
foreach (var rb in RadioButtonInputs)
|
||||
rb.IsChecked = false;
|
||||
}
|
||||
|
||||
private bool IsValid() {
|
||||
return Valid.All(kv => kv.Value) && ComboBoxInputs.All(cb => cb.ItemsSource == null || cb.SelectedItem != null);
|
||||
}
|
||||
|
||||
private void UpdateButtons() {
|
||||
if (!IsEditing && !IsCreating) return;
|
||||
bool ch = HasChanged(), v = IsValid();
|
||||
ResetButton.IsEnabled = (ch);
|
||||
SaveButton.IsEnabled = (v && ch);
|
||||
}
|
||||
|
||||
private bool InputHasChanged(Control input) {
|
||||
if (!OriginalValues.ContainsKey(input)) {
|
||||
return false;
|
||||
} else if (input is TextBox tb) {
|
||||
return OriginalValues[tb]?.ToString() != tb.Text;
|
||||
} else if (input is ComboBox sb) {
|
||||
return OriginalValues[sb] != sb.SelectedItem;
|
||||
} else if (input is CheckBox cb) {
|
||||
return (OriginalValues[cb] != null) != (cb.IsChecked ?? false);
|
||||
} else if (input is RadioButton rb) {
|
||||
return (OriginalValues[rb] != null) != (rb.IsChecked ?? false);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private bool HasChanged() {
|
||||
return !IsValid() ||
|
||||
TextBoxInputs.Any(InputHasChanged) ||
|
||||
ComboBoxInputs.Any(InputHasChanged) ||
|
||||
CheckBoxInputs.Any(InputHasChanged) ||
|
||||
RadioButtonInputs.Any(InputHasChanged);
|
||||
}
|
||||
|
||||
private void UpdatePlz(TextBox plzInput, ComboBox ortInput, bool optional) {
|
||||
if (plzInput.Text.Length == 4) {
|
||||
int plz = int.Parse(plzInput.Text);
|
||||
ortInput.ItemsSource = Context.Postleitzahlen.Where(p => p.Plz == plz).ToHashSet();
|
||||
} else {
|
||||
ortInput.ItemsSource = null;
|
||||
}
|
||||
ortInput.SelectedItem = null;
|
||||
if (ortInput.ItemsSource != null) {
|
||||
Utils.SetInputInvalid(ortInput);
|
||||
} else {
|
||||
Utils.ClearInputState(ortInput);
|
||||
}
|
||||
Valid[plzInput] = optional || (ortInput.ItemsSource != null);
|
||||
UpdateButtons();
|
||||
}
|
||||
|
||||
private void InputTextChanged(TextBox input, bool optional, Func<TextBox, bool, ValidationResult> checker) {
|
||||
InputTextChanged(input, optional, (tb, opt, ctx) => checker(tb, opt));
|
||||
}
|
||||
|
||||
private void InputTextChanged(TextBox input, bool optional, Func<TextBox, bool, AppDbContext, ValidationResult> checker) {
|
||||
InputTextChanged(input, optional, (tb, opt, ctx, m) => checker(tb, opt, ctx));
|
||||
}
|
||||
|
||||
private void InputTextChanged(TextBox input, bool optional, Func<TextBox, bool, AppDbContext, Member, ValidationResult> checker) {
|
||||
var res = checker(input, optional, Context, (Member)MemberList.SelectedItem);
|
||||
Valid[input] = res.IsValid;
|
||||
if (res.IsValid) {
|
||||
if (InputHasChanged(input)) {
|
||||
Utils.SetInputChanged(input);
|
||||
} else {
|
||||
Utils.ClearInputState(input);
|
||||
}
|
||||
} else {
|
||||
Utils.SetInputInvalid(input);
|
||||
}
|
||||
UpdateButtons();
|
||||
}
|
||||
|
||||
private void InputLostFocus(TextBox input, bool optional, Func<TextBox, bool, ValidationResult> checker, string? msg = null) {
|
||||
InputLostFocus(input, optional, (tb, optional, ctx) => checker(tb, optional), msg);
|
||||
}
|
||||
|
||||
private void InputLostFocus(TextBox input, bool optional, Func<TextBox, bool, AppDbContext, ValidationResult> checker, string? msg = null) {
|
||||
InputLostFocus(input, optional, (tb, optional, ctx, m) => checker(tb, optional, ctx), msg);
|
||||
}
|
||||
|
||||
private void InputLostFocus(TextBox input, bool optional, Func<TextBox, bool, AppDbContext, Member?, ValidationResult> checker, string? msg = null) {
|
||||
var res = checker(input, optional, Context, (Member)MemberList.SelectedItem);
|
||||
if (!res.IsValid)
|
||||
MessageBox.Show(res.ErrorContent.ToString(), msg ?? res.ErrorContent.ToString(), MessageBoxButton.OK, MessageBoxImage.Warning);
|
||||
}
|
||||
|
||||
private void CheckBox_Changed(object sender, RoutedEventArgs evt) {
|
||||
var input = (CheckBox)sender;
|
||||
if (InputHasChanged(input)) {
|
||||
Utils.SetInputChanged(input);
|
||||
} else {
|
||||
Utils.ClearInputState(input);
|
||||
}
|
||||
UpdateButtons();
|
||||
}
|
||||
|
||||
private void RadioButton_Changed(object sender, RoutedEventArgs evt) {
|
||||
var input = (RadioButton)sender;
|
||||
if (InputHasChanged(input)) {
|
||||
Utils.SetInputChanged(input);
|
||||
} else {
|
||||
Utils.ClearInputState(input);
|
||||
}
|
||||
UpdateButtons();
|
||||
}
|
||||
|
||||
private void TextBox_TextChanged(object sender, RoutedEventArgs evt) {
|
||||
var input = (TextBox)sender;
|
||||
if (InputHasChanged(input)) {
|
||||
Utils.SetInputChanged(input);
|
||||
} else {
|
||||
Utils.ClearInputState(input);
|
||||
}
|
||||
UpdateButtons();
|
||||
}
|
||||
|
||||
private void ComboBox_SelectionChanged(object sender, RoutedEventArgs evt) {
|
||||
var input = (ComboBox)sender;
|
||||
if (input.ItemsSource != null && input.SelectedItem == null) {
|
||||
Utils.SetInputInvalid(input);
|
||||
} else if (InputHasChanged(input)) {
|
||||
Utils.SetInputChanged(input);
|
||||
} else {
|
||||
Utils.ClearInputState(input);
|
||||
}
|
||||
UpdateButtons();
|
||||
}
|
||||
|
||||
private void NumericInput_TextChanged(object sender, RoutedEventArgs evt) {
|
||||
InputTextChanged((TextBox)sender, false, Validator.CheckNumeric);
|
||||
}
|
||||
|
||||
private void MgNrInput_TextChanged(object sender, RoutedEventArgs evt) {
|
||||
InputTextChanged((TextBox)sender, false, Validator.CheckMgNr);
|
||||
}
|
||||
|
||||
private void MgNrInput_LostFocus(object sender, RoutedEventArgs evt) {
|
||||
InputLostFocus((TextBox)sender, false, Validator.CheckMgNr);
|
||||
}
|
||||
|
||||
private void PredecessorMgNrInput_TextChanged(object sender, RoutedEventArgs evt) {
|
||||
InputTextChanged((TextBox)sender, true, Validator.CheckPredecessorMgNr);
|
||||
}
|
||||
|
||||
private void PredecessorMgNrInput_LostFocus(object sender, RoutedEventArgs evt) {
|
||||
InputLostFocus((TextBox)sender, true, Validator.CheckPredecessorMgNr);
|
||||
}
|
||||
|
||||
private void BirthdayInput_TextChanged(object sender, RoutedEventArgs evt) {
|
||||
InputTextChanged((TextBox)sender, true, Validator.CheckPartialDate);
|
||||
}
|
||||
|
||||
private void PlzInput_TextChanged(object sender, RoutedEventArgs evt) {
|
||||
InputTextChanged((TextBox)sender, false, Validator.CheckPlz);
|
||||
UpdatePlz((TextBox)sender, OrtInput, false);
|
||||
}
|
||||
|
||||
private void PlzInput_LostFocus(object sender, RoutedEventArgs evt) {
|
||||
InputLostFocus((TextBox)sender, true, Validator.CheckPlz);
|
||||
UpdatePlz((TextBox)sender, OrtInput, false);
|
||||
}
|
||||
|
||||
private void PhoneNrInput_TextChanged(object sender, RoutedEventArgs evt) {
|
||||
InputTextChanged((TextBox)sender, true, Validator.CheckPhoneNumber);
|
||||
}
|
||||
|
||||
private void PhoneNrInput_LostFocus(object sender, RoutedEventArgs evt) {
|
||||
InputLostFocus((TextBox)sender, true, Validator.CheckPhoneNumber);
|
||||
}
|
||||
|
||||
private void EmailInput_TextChanged(object sender, RoutedEventArgs evt) {
|
||||
InputTextChanged((TextBox)sender, true, Validator.CheckEmailAddress);
|
||||
}
|
||||
|
||||
private void EmailInput_LostFocus(object sender, RoutedEventArgs evt) {
|
||||
InputLostFocus((TextBox)sender, true, Validator.CheckEmailAddress);
|
||||
}
|
||||
|
||||
private void IbanInput_TextChanged(object sender, RoutedEventArgs evt) {
|
||||
InputTextChanged((TextBox)sender, true, Validator.CheckIban);
|
||||
}
|
||||
|
||||
private void IbanInput_LostFocus(object sender, RoutedEventArgs evt) {
|
||||
InputLostFocus((TextBox)sender, true, Validator.CheckIban);
|
||||
}
|
||||
|
||||
private void BicInput_TextChanged(object sender, RoutedEventArgs evt) {
|
||||
InputTextChanged((TextBox)sender, true, Validator.CheckBic);
|
||||
}
|
||||
|
||||
private void BicInput_LostFocus(object sender, RoutedEventArgs evt) {
|
||||
InputLostFocus((TextBox)sender, true, Validator.CheckBic);
|
||||
}
|
||||
|
||||
private void UstIdInput_TextChanged(object sender, RoutedEventArgs evt) {
|
||||
InputTextChanged((TextBox)sender, true, Validator.CheckUstId);
|
||||
}
|
||||
|
||||
private void UstIdInput_LostFocus(object sender, RoutedEventArgs evt) {
|
||||
InputLostFocus((TextBox)sender, true, Validator.CheckUstId);
|
||||
}
|
||||
|
||||
private void LfbisNrInput_TextChanged(object sender, RoutedEventArgs evt) {
|
||||
InputTextChanged((TextBox)sender, true, Validator.CheckLfbisNr);
|
||||
}
|
||||
|
||||
private void LfbisNrInput_LostFocus(object sender, RoutedEventArgs evt) {
|
||||
InputLostFocus((TextBox)sender, true, Validator.CheckLfbisNr);
|
||||
}
|
||||
|
||||
private void BillingPlzInput_TextChanged(object sender, RoutedEventArgs evt) {
|
||||
InputTextChanged((TextBox)sender, true, Validator.CheckPlz);
|
||||
UpdatePlz((TextBox)sender, BillingOrtInput, true);
|
||||
}
|
||||
|
||||
private void BillingPlzInput_LostFocus(object sender, RoutedEventArgs evt) {
|
||||
InputLostFocus((TextBox)sender, true, Validator.CheckPlz);
|
||||
UpdatePlz((TextBox)sender, BillingOrtInput, true);
|
||||
}
|
||||
|
||||
private void DateInput_TextChanged(object sender, RoutedEventArgs evt) {
|
||||
InputTextChanged((TextBox)sender, true, Validator.CheckDate);
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user