Add Windows/
This commit is contained in:
38
WGneu/Windows/BankDetailsWindow.xaml
Normal file
38
WGneu/Windows/BankDetailsWindow.xaml
Normal file
@ -0,0 +1,38 @@
|
||||
<Window x:Class="WGneu.Windows.BankDetailsWindow"
|
||||
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:WGneu.Windows"
|
||||
mc:Ignorable="d"
|
||||
Title="Bankverbindung" Height="295" Width="440" ResizeMode="NoResize" MinWidth="440" MinHeight="295">
|
||||
<Grid>
|
||||
<GroupBox Header="IBAN" Margin="10,10,10,0" Height="60" VerticalAlignment="Top">
|
||||
<Grid>
|
||||
<TextBox x:Name="Iban" HorizontalAlignment="Left" Margin="105,0,-0.6,0" TextWrapping="NoWrap" Width="280" VerticalAlignment="Center" TextChanged="Iban_TextChanged" LostFocus="Iban_LostFocus"/>
|
||||
<TextBlock HorizontalAlignment="Left" Margin="5,0,0,0" TextWrapping="Wrap" VerticalAlignment="Center" Width="90"><Run Language="de-de" Text="IBAN:"/></TextBlock>
|
||||
</Grid>
|
||||
</GroupBox>
|
||||
<GroupBox Header="Bank/Kontonummer" Margin="10,80,10,0" Height="135" VerticalAlignment="Top">
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="1*"/>
|
||||
<RowDefinition Height="1*"/>
|
||||
<RowDefinition Height="1*"/>
|
||||
</Grid.RowDefinitions>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="100"/>
|
||||
<ColumnDefinition Width="1*"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<ComboBox HorizontalAlignment="Left" VerticalAlignment="Center" Width="280" Height="22" Margin="5,-0.3,0,0" Grid.Column="2"/>
|
||||
<TextBox x:Name="BankCode" HorizontalAlignment="Left" TextWrapping="Wrap" VerticalAlignment="Center" Width="80" TextChanged="BankCode_TextChanged" Height="18" Grid.Column="2" Grid.Row="1" Margin="5,0,0,0"/>
|
||||
<TextBox x:Name="AccountNumber" HorizontalAlignment="Left" TextWrapping="Wrap" VerticalAlignment="Center" Width="280" Height="18" Grid.Column="1" Grid.Row="2" Margin="5,0,0,0" TextChanged="AccountNumber_TextChanged"/>
|
||||
<TextBlock HorizontalAlignment="Left" TextWrapping="Wrap" Text="Land:" VerticalAlignment="Center" Height="16" Width="90" Margin="5,0,0,0"/>
|
||||
<TextBlock HorizontalAlignment="Left" TextWrapping="Wrap" Text="Bank:" VerticalAlignment="Center" Height="16" Width="90" Grid.Row="1" Margin="5,0,0,0" Grid.RowSpan="1"/>
|
||||
<TextBlock HorizontalAlignment="Left" TextWrapping="Wrap" Text="Kontonummer:" VerticalAlignment="Center" Grid.Row="2" Margin="5,0,0,0"/>
|
||||
<ComboBox Margin="92,0,0,0" VerticalAlignment="Center" Height="22" HorizontalAlignment="Left" Width="193" Grid.Column="2" Grid.Row="1"/>
|
||||
</Grid>
|
||||
</GroupBox>
|
||||
<Button Content="Übernehmen" HorizontalAlignment="Right" Margin="0,0,20,10" VerticalAlignment="Bottom" Padding="5,1,5,1"/>
|
||||
</Grid>
|
||||
</Window>
|
173
WGneu/Windows/BankDetailsWindow.xaml.cs
Normal file
173
WGneu/Windows/BankDetailsWindow.xaml.cs
Normal file
@ -0,0 +1,173 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Documents;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
using System.Windows.Shapes;
|
||||
using WGneu.Models;
|
||||
|
||||
|
||||
namespace WGneu.Windows
|
||||
{
|
||||
/// <summary>
|
||||
/// Interaktionslogik für BankDetailsWindow.xaml
|
||||
/// </summary>
|
||||
public partial class BankDetailsWindow : Window
|
||||
{
|
||||
public BankDetailsWindow()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
private void Iban_TextChanged(object sender, TextChangedEventArgs e)
|
||||
{
|
||||
string iban = "";
|
||||
int pos = Iban.CaretIndex;
|
||||
for (int i = 0, v = 0; i < Iban.Text.Length && v < 34; i++)
|
||||
{
|
||||
char ch = Iban.Text[i];
|
||||
if (Char.IsLetterOrDigit(ch) && Char.IsAscii(ch))
|
||||
{
|
||||
if (v != 0 && v % 4 == 0)
|
||||
iban += ' ';
|
||||
v++;
|
||||
iban += Char.ToUpper(ch);
|
||||
}
|
||||
if (i == Iban.CaretIndex - 1)
|
||||
pos = iban.Length;
|
||||
if (iban.StartsWith("AT") && v >= 20)
|
||||
break;
|
||||
}
|
||||
Iban.Text = iban;
|
||||
Iban.CaretIndex = pos;
|
||||
|
||||
if (Iban.IsFocused)
|
||||
GenerateBankDetails();
|
||||
}
|
||||
|
||||
private void Iban_LostFocus(object sender, EventArgs e)
|
||||
{
|
||||
// TODO vaildate checksum
|
||||
}
|
||||
|
||||
private void BankCode_TextChanged(object sender, TextChangedEventArgs e)
|
||||
{
|
||||
string cc = "AT";
|
||||
string code = "";
|
||||
int pos = BankCode.CaretIndex;
|
||||
|
||||
if (cc == "AT")
|
||||
{
|
||||
|
||||
for (int i = 0, v = 0; i < BankCode.Text.Length && v < 5; i++)
|
||||
{
|
||||
char ch = BankCode.Text[i];
|
||||
if (Char.IsDigit(ch))
|
||||
{
|
||||
v++;
|
||||
code += ch;
|
||||
}
|
||||
if (i == BankCode.CaretIndex - 1)
|
||||
pos = code.Length;
|
||||
}
|
||||
}
|
||||
|
||||
BankCode.Text = code;
|
||||
BankCode.CaretIndex = pos;
|
||||
|
||||
if (BankCode.IsFocused)
|
||||
GenerateIban();
|
||||
}
|
||||
|
||||
private void AccountNumber_TextChanged(object sender, TextChangedEventArgs e)
|
||||
{
|
||||
string cc = "AT";
|
||||
string num = "";
|
||||
int pos = AccountNumber.CaretIndex;
|
||||
|
||||
if (cc == "AT")
|
||||
{
|
||||
for (int i = 0, v = 0; i < AccountNumber.Text.Length && v < 11; i++)
|
||||
{
|
||||
char ch = AccountNumber.Text[i];
|
||||
if (Char.IsLetterOrDigit(ch) && Char.IsAscii(ch))
|
||||
{
|
||||
v++;
|
||||
num += ch;
|
||||
}
|
||||
if (i == AccountNumber.CaretIndex - 1)
|
||||
pos = num.Length;
|
||||
}
|
||||
}
|
||||
|
||||
AccountNumber.Text = num;
|
||||
AccountNumber.CaretIndex = pos;
|
||||
|
||||
if (AccountNumber.IsFocused)
|
||||
GenerateIban();
|
||||
}
|
||||
|
||||
private void GenerateIban()
|
||||
{
|
||||
string cc = "AT";
|
||||
string iban = cc + "00";
|
||||
|
||||
if (cc == "AT")
|
||||
{
|
||||
iban += BankCode.Text.PadLeft(5, '0') + AccountNumber.Text.PadLeft(11, '0');
|
||||
}
|
||||
|
||||
// TODO calculate checksum
|
||||
|
||||
Iban.Text = iban;
|
||||
Iban.CaretIndex = iban.Length;
|
||||
}
|
||||
|
||||
private void GenerateBankDetails()
|
||||
{
|
||||
BankCode.Text = "";
|
||||
AccountNumber.Text = "";
|
||||
|
||||
string iban = Iban.Text.Replace(" ", "");
|
||||
if (iban.Length <= 2)
|
||||
return;
|
||||
|
||||
string cc = iban.Substring(0, 2);
|
||||
if (cc == "AT")
|
||||
{
|
||||
if (iban.Length > 4)
|
||||
{
|
||||
string bankCodeStr = iban.Substring(4, Math.Min(5, iban.Length - 4));
|
||||
if (bankCodeStr.All(Char.IsDigit))
|
||||
{
|
||||
int bankCode = int.Parse(bankCodeStr);
|
||||
BankCode.Text = bankCode.ToString();
|
||||
}
|
||||
if (iban.Length > 9)
|
||||
{
|
||||
string accNumStr = iban.Substring(9, Math.Min(11, iban.Length - 9));
|
||||
if (accNumStr.All(Char.IsDigit))
|
||||
{
|
||||
int accNum = int.Parse(accNumStr);
|
||||
AccountNumber.Text = (accNum != 0) ? accNum.ToString() : "";
|
||||
}
|
||||
else
|
||||
{
|
||||
AccountNumber.Text = accNumStr;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
BankCode.CaretIndex = BankCode.Text.Length;
|
||||
AccountNumber.CaretIndex = AccountNumber.Text.Length;
|
||||
}
|
||||
}
|
||||
}
|
23
WGneu/Windows/MainWindow.xaml
Normal file
23
WGneu/Windows/MainWindow.xaml
Normal file
@ -0,0 +1,23 @@
|
||||
<Window x:Class="WGneu.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:WGneu.Windows"
|
||||
mc:Ignorable="d"
|
||||
Title="MainWindow" Height="450" Width="800" ResizeMode="CanResize" SizeToContent="Manual"
|
||||
Loaded="Window_Loaded">
|
||||
<Window.Resources>
|
||||
<CollectionViewSource x:Key="countryViewSource"/>
|
||||
<DataTemplate x:Key="asdf">
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<TextBlock Text="{Binding Name}"/>
|
||||
</StackPanel>
|
||||
</DataTemplate>
|
||||
</Window.Resources>
|
||||
<Grid>
|
||||
<Button x:Name="Button1" Content="Bankverbindung" VerticalAlignment="Top" Click="Button1_Click" Margin="454,109,159,0"/>
|
||||
<ComboBox HorizontalAlignment="Left" Margin="175,149,0,0" VerticalAlignment="Top" Width="120" ItemsSource="{Binding Source={StaticResource countryViewSource}}" ItemTemplate="{StaticResource asdf}" SelectionChanged="ComboBox_SelectionChanged" IsEditable="True"/>
|
||||
<Button x:Name="Button2" Content="Mitglieder" Margin="472,182,178,0" VerticalAlignment="Top" Click="Button2_Click"/>
|
||||
</Grid>
|
||||
</Window>
|
70
WGneu/Windows/MainWindow.xaml.cs
Normal file
70
WGneu/Windows/MainWindow.xaml.cs
Normal file
@ -0,0 +1,70 @@
|
||||
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 System.Windows.Controls;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Documents;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
using System.Windows.Navigation;
|
||||
using System.Windows.Shapes;
|
||||
using WGneu.Models;
|
||||
|
||||
|
||||
namespace WGneu.Windows
|
||||
{
|
||||
/// <summary>
|
||||
/// Interaction logic for MainWindow.xaml
|
||||
/// </summary>
|
||||
public partial class MainWindow : Window
|
||||
{
|
||||
private readonly WgContext _context = new WgContext();
|
||||
private CollectionViewSource countryViewSource;
|
||||
public MainWindow()
|
||||
{
|
||||
InitializeComponent();
|
||||
countryViewSource = (CollectionViewSource) FindResource("countryViewSource");
|
||||
}
|
||||
|
||||
private void Window_Loaded(object sender, RoutedEventArgs e)
|
||||
{
|
||||
_context.Countries.Load();
|
||||
countryViewSource.Source = _context.Countries.Local.ToObservableCollection();
|
||||
}
|
||||
|
||||
protected override void OnClosing(CancelEventArgs e)
|
||||
{
|
||||
_context.Dispose();
|
||||
base.OnClosing(e);
|
||||
}
|
||||
|
||||
private void Button1_Click(object sender, EventArgs e)
|
||||
{
|
||||
BankDetailsWindow w = new BankDetailsWindow();
|
||||
w.Show();
|
||||
}
|
||||
|
||||
private void Button2_Click(object sender, EventArgs e)
|
||||
{
|
||||
MemberListWindow w = new MemberListWindow();
|
||||
w.Show();
|
||||
}
|
||||
|
||||
private void Button_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
private void ComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
30
WGneu/Windows/MemberAddWindow.xaml
Normal file
30
WGneu/Windows/MemberAddWindow.xaml
Normal file
@ -0,0 +1,30 @@
|
||||
<Window x:Class="WGneu.Windows.MemberAddWindow"
|
||||
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:WGneu.Windows"
|
||||
mc:Ignorable="d"
|
||||
Title="Mitglied anlegen" Height="450" Width="800"
|
||||
Loaded="Window_Loaded">
|
||||
<Grid>
|
||||
<Label Content="MNR:" HorizontalAlignment="Left" Margin="392,137,0,0" VerticalAlignment="Top"/>
|
||||
<TextBox x:Name="MgNr" HorizontalAlignment="Left" Margin="475,141,0,0" TextWrapping="Wrap" Text="TextBox" VerticalAlignment="Top" Width="120"/>
|
||||
<Label Content="Vorname:" HorizontalAlignment="Left" Margin="392,160,0,0" VerticalAlignment="Top"/>
|
||||
<TextBox x:Name="GivenName" HorizontalAlignment="Left" Margin="475,164,0,0" TextWrapping="Wrap" Text="TextBox" VerticalAlignment="Top" Width="120"/>
|
||||
<Label Content="Nachname:" HorizontalAlignment="Left" Margin="392,182,0,0" VerticalAlignment="Top"/>
|
||||
<TextBox x:Name="FamilyName" HorizontalAlignment="Left" Margin="475,187,0,0" TextWrapping="Wrap" Text="TextBox" VerticalAlignment="Top" Width="120"/>
|
||||
<Label Content="Zweigstelle:" HorizontalAlignment="Left" Margin="392,206,0,0" VerticalAlignment="Top"/>
|
||||
<TextBox x:Name="Zweigstelle" HorizontalAlignment="Left" Margin="475,210,0,0" TextWrapping="Wrap" Text="TextBox" VerticalAlignment="Top" Width="120"/>
|
||||
<Label Content="Country:" HorizontalAlignment="Left" Margin="392,229,0,0" VerticalAlignment="Top"/>
|
||||
<TextBox x:Name="Country" HorizontalAlignment="Left" Margin="475,233,0,0" TextWrapping="Wrap" Text="TextBox" VerticalAlignment="Top" Width="120"/>
|
||||
<Label Content="PostalDest:" HorizontalAlignment="Left" Margin="392,252,0,0" VerticalAlignment="Top"/>
|
||||
<TextBox x:Name="PostalDest" HorizontalAlignment="Left" Margin="475,256,0,0" TextWrapping="Wrap" Text="TextBox" VerticalAlignment="Top" Width="120"/>
|
||||
<Label Content="Address:" HorizontalAlignment="Left" Margin="392,275,0,0" VerticalAlignment="Top"/>
|
||||
<TextBox x:Name="Address" HorizontalAlignment="Left" Margin="475,279,0,0" TextWrapping="Wrap" Text="TextBox" VerticalAlignment="Top" Width="120"/>
|
||||
<Label Content="DefaultKgnr:" HorizontalAlignment="Left" Margin="392,298,0,0" VerticalAlignment="Top"/>
|
||||
<TextBox x:Name="DefaultKgnr" HorizontalAlignment="Left" Margin="475,302,0,0" TextWrapping="Wrap" Text="TextBox" VerticalAlignment="Top" Width="120"/>
|
||||
<Button x:Name="Save_Button" Content="Save" HorizontalAlignment="Left" Margin="682,199,0,0" VerticalAlignment="Top" Click="Save_Button_Click"/>
|
||||
<Label x:Name="SaveError" Content="" HorizontalAlignment="Left" Height="32" Margin="639,233,0,0" VerticalAlignment="Top" Width="115"/>
|
||||
</Grid>
|
||||
</Window>
|
81
WGneu/Windows/MemberAddWindow.xaml.cs
Normal file
81
WGneu/Windows/MemberAddWindow.xaml.cs
Normal file
@ -0,0 +1,81 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Documents;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
using System.Windows.Shapes;
|
||||
using WGneu.Models;
|
||||
|
||||
|
||||
namespace WGneu.Windows
|
||||
{
|
||||
/// <summary>
|
||||
/// Interaction logic for MemberAddWindow.xaml
|
||||
/// </summary>
|
||||
public partial class MemberAddWindow : Window
|
||||
{
|
||||
private WgContext _context;
|
||||
private readonly Member member = new Member();
|
||||
public event EventHandler Event;
|
||||
|
||||
public MemberAddWindow(WgContext context)
|
||||
{
|
||||
this._context = context;
|
||||
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
private void Window_Loaded(object sender, RoutedEventArgs e)
|
||||
{
|
||||
MgNr.Text = member.MgNr.ToString();
|
||||
GivenName.Text = member.GivenName;
|
||||
FamilyName.Text = member.FamilyName;
|
||||
Zweigstelle.Text = member.Zweigstelle;
|
||||
Country.Text = member.Country.Alpha2;
|
||||
// PostalDest.Text= member.PostalDest;
|
||||
Address.Text = member.Address;
|
||||
DefaultKgnr.Text = member.DefaultKg.ToString();
|
||||
}
|
||||
|
||||
private void Save_Button_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
member.MgNr = Int32.Parse(MgNr.Text);
|
||||
member.GivenName = GivenName.Text;
|
||||
member.FamilyName = FamilyName.Text;
|
||||
member.Zweigstelle = Zweigstelle.Text;
|
||||
member.Country.Alpha2 = Country.Text;
|
||||
// member.PostalDest = PostalDest.Text;
|
||||
member.Address= Address.Text;
|
||||
member.DefaultKg.KgNr = Int32.Parse(DefaultKgnr.Text);
|
||||
|
||||
_context.Add(member);
|
||||
|
||||
try
|
||||
{
|
||||
_context.SaveChanges();
|
||||
}
|
||||
catch
|
||||
{
|
||||
SaveError.Content = "There was an Error!";
|
||||
return;
|
||||
}
|
||||
this.Call_Event();
|
||||
this.Close();
|
||||
}
|
||||
|
||||
private void Call_Event()
|
||||
{
|
||||
if (this.Event != null)
|
||||
{
|
||||
this.Event(this, EventArgs.Empty);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
29
WGneu/Windows/MemberEditWindow.xaml
Normal file
29
WGneu/Windows/MemberEditWindow.xaml
Normal file
@ -0,0 +1,29 @@
|
||||
<Window x:Class="WGneu.Windows.MemberEditWindow"
|
||||
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:WGneu.Windows"
|
||||
mc:Ignorable="d"
|
||||
Title="MemberEditWindow" Height="450" Width="800"
|
||||
Loaded="Window_Loaded">
|
||||
<Grid>
|
||||
<Label Content="MNR:" HorizontalAlignment="Left" Margin="392,137,0,0" VerticalAlignment="Top"/>
|
||||
<TextBox x:Name="MgNr" HorizontalAlignment="Left" Margin="475,141,0,0" TextWrapping="Wrap" Text="TextBox" VerticalAlignment="Top" Width="120"/>
|
||||
<Label Content="Vorname:" HorizontalAlignment="Left" Margin="392,160,0,0" VerticalAlignment="Top"/>
|
||||
<TextBox x:Name="GivenName" HorizontalAlignment="Left" Margin="475,164,0,0" TextWrapping="Wrap" Text="TextBox" VerticalAlignment="Top" Width="120"/>
|
||||
<Label Content="Nachname:" HorizontalAlignment="Left" Margin="392,182,0,0" VerticalAlignment="Top"/>
|
||||
<TextBox x:Name="FamilyName" HorizontalAlignment="Left" Margin="475,187,0,0" TextWrapping="Wrap" Text="TextBox" VerticalAlignment="Top" Width="120"/>
|
||||
<Label Content="Zweigstelle:" HorizontalAlignment="Left" Margin="392,206,0,0" VerticalAlignment="Top"/>
|
||||
<TextBox x:Name="Zweigstelle" HorizontalAlignment="Left" Margin="475,210,0,0" TextWrapping="Wrap" Text="TextBox" VerticalAlignment="Top" Width="120"/>
|
||||
<Label Content="Country:" HorizontalAlignment="Left" Margin="392,229,0,0" VerticalAlignment="Top"/>
|
||||
<TextBox x:Name="Country" HorizontalAlignment="Left" Margin="475,233,0,0" TextWrapping="Wrap" Text="TextBox" VerticalAlignment="Top" Width="120"/>
|
||||
<Label Content="PostalDest:" HorizontalAlignment="Left" Margin="392,252,0,0" VerticalAlignment="Top"/>
|
||||
<TextBox x:Name="PostalDest" HorizontalAlignment="Left" Margin="475,256,0,0" TextWrapping="Wrap" Text="TextBox" VerticalAlignment="Top" Width="120"/>
|
||||
<Label Content="Address:" HorizontalAlignment="Left" Margin="392,275,0,0" VerticalAlignment="Top"/>
|
||||
<TextBox x:Name="Address" HorizontalAlignment="Left" Margin="475,279,0,0" TextWrapping="Wrap" Text="TextBox" VerticalAlignment="Top" Width="120"/>
|
||||
<Label Content="DefaultKgnr:" HorizontalAlignment="Left" Margin="392,298,0,0" VerticalAlignment="Top"/>
|
||||
<TextBox x:Name="DefaultKgnr" HorizontalAlignment="Left" Margin="475,302,0,0" TextWrapping="Wrap" Text="TextBox" VerticalAlignment="Top" Width="120"/>
|
||||
<Button x:Name="Save_Button" Content="Save" HorizontalAlignment="Left" Margin="662,194,0,0" VerticalAlignment="Top" Click="Save_Button_Click"/>
|
||||
</Grid>
|
||||
</Window>
|
74
WGneu/Windows/MemberEditWindow.xaml.cs
Normal file
74
WGneu/Windows/MemberEditWindow.xaml.cs
Normal file
@ -0,0 +1,74 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Documents;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
using System.Windows.Shapes;
|
||||
using WGneu.Models;
|
||||
|
||||
|
||||
namespace WGneu.Windows
|
||||
{
|
||||
/// <summary>
|
||||
/// Interaction logic for MemberEditWindow.xaml
|
||||
/// </summary>
|
||||
public partial class MemberEditWindow : Window
|
||||
{
|
||||
private WgContext _context;
|
||||
private readonly Member member;
|
||||
public event EventHandler Event;
|
||||
|
||||
public MemberEditWindow(Member member, WgContext context)
|
||||
{
|
||||
this._context= context;
|
||||
this.member = member;
|
||||
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
private void Window_Loaded(object sender, RoutedEventArgs e)
|
||||
{
|
||||
MgNr.Text = member.MgNr.ToString();
|
||||
GivenName.Text = member.GivenName;
|
||||
FamilyName.Text = member.FamilyName;
|
||||
Zweigstelle.Text = member.Zweigstelle;
|
||||
// Country.Text = member.Country;
|
||||
// PostalDest.Text = member.PostalDest;
|
||||
Address.Text = member.Address;
|
||||
// DefaultKgnr.Text = member.DefaultKgnr.ToString();
|
||||
}
|
||||
|
||||
private void Save_Button_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
member.MgNr = Int32.Parse(MgNr.Text);
|
||||
member.GivenName = GivenName.Text;
|
||||
member.FamilyName = FamilyName.Text;
|
||||
member.Zweigstelle = Zweigstelle.Text;
|
||||
// member.Country = Country.Text;
|
||||
// member.PostalDest = PostalDest.Text;
|
||||
member.Address = Address.Text;
|
||||
// member.DefaultKgnr = Int32.Parse(DefaultKgnr.Text);
|
||||
|
||||
_context.Update(member);
|
||||
_context.SaveChanges();
|
||||
this.Call_Event();
|
||||
this.Close();
|
||||
}
|
||||
|
||||
private void Call_Event()
|
||||
{
|
||||
if (this.Event != null)
|
||||
{
|
||||
this.Event(this, EventArgs.Empty);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
29
WGneu/Windows/MemberListWindow.xaml
Normal file
29
WGneu/Windows/MemberListWindow.xaml
Normal file
@ -0,0 +1,29 @@
|
||||
<Window x:Class="WGneu.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:WGneu.Windows"
|
||||
xmlns:ui="http://schemas.modernwpf.com/2019"
|
||||
ui:WindowHelper.UseModernWindowStyle="True"
|
||||
mc:Ignorable="d"
|
||||
Title="Mitglieder" Height="500" Width="800" MinHeight="500" MinWidth="800"
|
||||
Loaded="Window_Loaded">
|
||||
<Grid>
|
||||
<DataGrid x:Name="MemberList" AutoGenerateColumns="False" CanUserAddRows="False"
|
||||
SelectionChanged="MemberList_SelectionChanged" VerticalAlignment="Top" Margin="10,10,540,0" FontSize="14" HeadersVisibility="Column" IsReadOnly="True">
|
||||
<DataGrid.Columns>
|
||||
<DataGridTextColumn Header="Nr." Binding="{Binding MgNr}" Width="50"/>
|
||||
<DataGridTextColumn Header="Nachname" Binding="{Binding FamilyName}" Width="100"/>
|
||||
<DataGridTextColumn Header="Vorname" Binding="{Binding GivenName}" Width="*"/>
|
||||
</DataGrid.Columns>
|
||||
</DataGrid>
|
||||
<TextBox x:Name="MgNr" HorizontalAlignment="Left" Margin="351,26,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="183" IsReadOnly="True" FontSize="14"/>
|
||||
<TextBox x:Name="GivenName" HorizontalAlignment="Left" Margin="351,67,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="183" IsReadOnly="True"/>
|
||||
<TextBox x:Name="FamilyName" HorizontalAlignment="Left" Margin="351,129,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="183" IsReadOnly="True"/>
|
||||
<Button x:Name="Edit_Member" Content="Mitglied bearbeiten" HorizontalAlignment="Left" VerticalAlignment="Bottom" Margin="130,407,0,20" Click="Edit_Member_Button_Click" IsEnabled="False" FontSize="14" Padding="3,3,3,3"/>
|
||||
<Button x:Name="Add_Member" Content="Mitglied erstellen" HorizontalAlignment="Left" VerticalAlignment="Bottom" Margin="10,407,0,20" Click="Add_Member_Button_Click" FontSize="14" Padding="3,3,3,3"/>
|
||||
<TextBox x:Name="Plz" HorizontalAlignment="Left" Margin="351,191,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="120" TextChanged="Plz_TextChanged"/>
|
||||
<ComboBox x:Name="Ort" HorizontalAlignment="Left" Margin="498,189,0,0" VerticalAlignment="Top" Width="200" ItemTemplate="{StaticResource PostalDestComboBoxTemplate}"/>
|
||||
</Grid>
|
||||
</Window>
|
110
WGneu/Windows/MemberListWindow.xaml.cs
Normal file
110
WGneu/Windows/MemberListWindow.xaml.cs
Normal file
@ -0,0 +1,110 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Documents;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
using System.Windows.Shapes;
|
||||
using WGneu.Models;
|
||||
|
||||
|
||||
namespace WGneu.Windows
|
||||
{
|
||||
/// <summary>
|
||||
/// Interaktionslogik für Window1.xaml
|
||||
/// </summary>
|
||||
public partial class MemberListWindow : Window
|
||||
{
|
||||
private readonly WgContext _context = new WgContext();
|
||||
|
||||
public MemberListWindow()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
private void Window_Loaded(object sender, RoutedEventArgs e)
|
||||
{
|
||||
Refresh_Member_Data();
|
||||
}
|
||||
|
||||
protected override void OnClosing(CancelEventArgs e)
|
||||
{
|
||||
_context.Dispose();
|
||||
base.OnClosing(e);
|
||||
}
|
||||
|
||||
private void MemberList_SelectionChanged(object sender, SelectionChangedEventArgs e)
|
||||
{
|
||||
Member m = (Member) MemberList.SelectedItem;
|
||||
MgNr.Text = m.MgNr.ToString();
|
||||
GivenName.Text = m.GivenName;
|
||||
FamilyName.Text = m.FamilyName;
|
||||
|
||||
AT_Plz? p = m.PostalDest.Plz(_context);
|
||||
if (p != null)
|
||||
{
|
||||
Plz.Text = p.Plz.ToString();
|
||||
|
||||
var o = p.Orte(_context);
|
||||
Ort.ItemsSource = o;
|
||||
Ort.SelectedItem = p;
|
||||
}
|
||||
else
|
||||
{
|
||||
Ort.ItemsSource = null;
|
||||
Ort.SelectedItem = null;
|
||||
}
|
||||
|
||||
|
||||
Edit_Member.IsEnabled = true;
|
||||
}
|
||||
|
||||
private void Plz_TextChanged(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (Plz.Text.Length == 4 && Plz.Text.All(char.IsDigit))
|
||||
{
|
||||
int plz = int.Parse(Plz.Text);
|
||||
var o = _context.Postleitzahlen.Where(p => p.Plz == plz).ToHashSet();
|
||||
Ort.ItemsSource = o;
|
||||
Ort.SelectedItem = null;
|
||||
}
|
||||
}
|
||||
|
||||
private void Edit_Member_Button_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
Member m = (Member)MemberList.SelectedItem;
|
||||
|
||||
if (m == null) return;
|
||||
|
||||
MemberEditWindow w = new MemberEditWindow(m, _context);
|
||||
w.Event += new EventHandler(Refresh_Member_Data_Event);
|
||||
w.Show();
|
||||
}
|
||||
|
||||
private void Add_Member_Button_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
MemberAddWindow w = new MemberAddWindow(_context);
|
||||
w.Event += new EventHandler(Refresh_Member_Data_Event);
|
||||
w.Show();
|
||||
}
|
||||
|
||||
private void Refresh_Member_Data()
|
||||
{
|
||||
_context.Members.Load();
|
||||
MemberList.ItemsSource = _context.Members.ToList();
|
||||
}
|
||||
|
||||
private void Refresh_Member_Data_Event(object sender, EventArgs e)
|
||||
{
|
||||
Refresh_Member_Data();
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user