[#45] MemberAdminWindow: Add dialog for area commitment cancellation/transfer
Some checks failed
Test / Run tests (push) Failing after 52s
Some checks failed
Test / Run tests (push) Failing after 52s
This commit is contained in:
74
Elwig/Dialogs/AreaComDialog.xaml
Normal file
74
Elwig/Dialogs/AreaComDialog.xaml
Normal file
@ -0,0 +1,74 @@
|
|||||||
|
<Window x:Class="Elwig.Dialogs.AreaComDialog"
|
||||||
|
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.Dialogs"
|
||||||
|
xmlns:ctrl="clr-namespace:Elwig.Controls"
|
||||||
|
ResizeMode="NoResize" ShowInTaskbar="False" Topmost="True"
|
||||||
|
WindowStartupLocation="CenterOwner"
|
||||||
|
DataContext="{Binding RelativeSource={RelativeSource Self}}"
|
||||||
|
Title="Flächenbindungen übertragen" Height="230" Width="450">
|
||||||
|
<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="Button">
|
||||||
|
<Setter Property="HorizontalAlignment" Value="Right"/>
|
||||||
|
<Setter Property="VerticalAlignment" Value="Bottom"/>
|
||||||
|
<Setter Property="Width" Value="100"/>
|
||||||
|
<Setter Property="Height" Value="25"/>
|
||||||
|
</Style>
|
||||||
|
</Window.Resources>
|
||||||
|
<Grid>
|
||||||
|
<TextBlock x:Name="QuestionBlock1" TextAlignment="Center" Margin="0,10,0,0"
|
||||||
|
HorizontalAlignment="Center" VerticalAlignment="Top">
|
||||||
|
Sollen die aktiven Flächenbindungen des angegebenen Vorgängers<LineBreak/>
|
||||||
|
übernommen werden? (<Run Text="{Binding AreaComNum}"/> FB, <Run Text="{Binding Area}"/> m²)
|
||||||
|
</TextBlock>
|
||||||
|
<TextBlock x:Name="QuestionBlock2" TextAlignment="Center" Margin="0,10,0,0" Visibility="Hidden"
|
||||||
|
HorizontalAlignment="Center" VerticalAlignment="Top">
|
||||||
|
Sollen die aktiven Flächenbindungen gekündigt werden? (<Run Text="{Binding AreaComNum}"/> FB, <Run Text="{Binding Area}"/> m²)
|
||||||
|
</TextBlock>
|
||||||
|
|
||||||
|
<Label x:Name="SeasonLabel" Content="Saison:" Margin="0,50,100,0"
|
||||||
|
HorizontalAlignment="Center" VerticalAlignment="Top"/>
|
||||||
|
<ctrl:IntegerUpDown x:Name="SeasonInput" Width="56" Height="25" Margin="0,50,0,0" FontSize="14"
|
||||||
|
Minimum="1900" Maximum="9999"
|
||||||
|
HorizontalAlignment="Center" VerticalAlignment="Top"
|
||||||
|
TextChanged="SeasonInput_TextChanged"/>
|
||||||
|
|
||||||
|
<TextBlock x:Name="DescBlock1" Margin="0,85,0,0" TextAlignment="Center"
|
||||||
|
HorizontalAlignment="Center" VerticalAlignment="Top">
|
||||||
|
Die Flächenbindungen beim <Bold>Vorgänger</Bold> sind bis inkl. Saison <Bold><Run x:Name="CancelSeason1"/></Bold> gültig,<LineBreak/>
|
||||||
|
und werden beim <Bold>Nachfolger</Bold> ab inkl. Saison <Bold><Run x:Name="TransferSeason"/></Bold> übernommen.
|
||||||
|
</TextBlock>
|
||||||
|
<TextBlock x:Name="DescBlock2" Margin="0,70,0,0" TextAlignment="Center" Visibility="Hidden"
|
||||||
|
HorizontalAlignment="Center" VerticalAlignment="Top">
|
||||||
|
Die Flächenbindungen sind bis inklusive Saison <Bold><Run x:Name="CancelSeason2"/></Bold> gültig.
|
||||||
|
</TextBlock>
|
||||||
|
|
||||||
|
<TextBlock x:Name="InfoBlock" Margin="0,0,0,75" TextAlignment="Center"
|
||||||
|
HorizontalAlignment="Center" VerticalAlignment="Bottom">
|
||||||
|
Falls die Flächenbindungen später an ein neues Mitglied<LineBreak/>
|
||||||
|
übertragen werden sollen bitte <Italic>Nein</Italic> auswählen!
|
||||||
|
</TextBlock>
|
||||||
|
<TextBlock Text="Die Änderungen werden erst beim Speichern übernommen!"
|
||||||
|
HorizontalAlignment="Center" VerticalAlignment="Bottom" Margin="0,0,0,50"/>
|
||||||
|
|
||||||
|
<Button x:Name="ConfirmButton" Content="Ja" Margin="10,10,115,10" Grid.Column="1"
|
||||||
|
Click="ConfirmButton_Click"/>
|
||||||
|
<Button x:Name="CancelButton" Content="Nein" Margin="10,10,10,10" Grid.Column="1" IsCancel="True"/>
|
||||||
|
</Grid>
|
||||||
|
</Window>
|
52
Elwig/Dialogs/AreaComDialog.xaml.cs
Normal file
52
Elwig/Dialogs/AreaComDialog.xaml.cs
Normal file
@ -0,0 +1,52 @@
|
|||||||
|
using Elwig.Helpers;
|
||||||
|
using System.Windows;
|
||||||
|
using System.Windows.Controls;
|
||||||
|
|
||||||
|
namespace Elwig.Dialogs {
|
||||||
|
public partial class AreaComDialog : Window {
|
||||||
|
|
||||||
|
public int CancelSeason { get; set; }
|
||||||
|
public int SuccessorSeason => CancelSeason + 1;
|
||||||
|
|
||||||
|
public string AreaComNum { get; set; }
|
||||||
|
public string Area { get; set; }
|
||||||
|
|
||||||
|
public AreaComDialog(string name, int areaComNum, int area) {
|
||||||
|
CancelSeason = Utils.FollowingSeason - 1;
|
||||||
|
AreaComNum = $"{areaComNum:N0}";
|
||||||
|
Area = $"{area:N0}";
|
||||||
|
InitializeComponent();
|
||||||
|
SeasonInput.Text = $"{CancelSeason}";
|
||||||
|
Title = $"Aktive Flächenbindungen kündigen - {name}";
|
||||||
|
QuestionBlock1.Visibility = Visibility.Hidden;
|
||||||
|
QuestionBlock2.Visibility = Visibility.Visible;
|
||||||
|
DescBlock1.Visibility = Visibility.Hidden;
|
||||||
|
DescBlock2.Visibility = Visibility.Visible;
|
||||||
|
Height = 240;
|
||||||
|
SeasonInput.Margin = new(0, 40, 0, 0);
|
||||||
|
SeasonLabel.Margin = new(0, 40, 100, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
public AreaComDialog(string name, string successorName, int areaComNum, int area) {
|
||||||
|
CancelSeason = Utils.FollowingSeason - 1;
|
||||||
|
AreaComNum = $"{areaComNum:N0}";
|
||||||
|
Area = $"{area:N0}";
|
||||||
|
InitializeComponent();
|
||||||
|
SeasonInput.Text = $"{CancelSeason}";
|
||||||
|
Title = $"Aktive Flächenbindungen übertragen - {name} - {successorName}";
|
||||||
|
InfoBlock.Visibility = Visibility.Hidden;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void SeasonInput_TextChanged(object sender, TextChangedEventArgs evt) {
|
||||||
|
CancelSeason = (int)SeasonInput.Value!;
|
||||||
|
CancelSeason1.Text = $"{CancelSeason}";
|
||||||
|
CancelSeason2.Text = $"{CancelSeason}";
|
||||||
|
TransferSeason.Text = $"{SuccessorSeason}";
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ConfirmButton_Click(object sender, RoutedEventArgs evt) {
|
||||||
|
DialogResult = true;
|
||||||
|
Close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -1134,7 +1134,7 @@ namespace Elwig.Windows {
|
|||||||
var valid = InputLostFocus((TextBox)sender, Validator.CheckPredecessorMgNr);
|
var valid = InputLostFocus((TextBox)sender, Validator.CheckPredecessorMgNr);
|
||||||
if (valid && PredecessorMgNrInput.Text != "" && (IsEditing || IsCreating)) {
|
if (valid && PredecessorMgNrInput.Text != "" && (IsEditing || IsCreating)) {
|
||||||
var mgnr = int.Parse(PredecessorMgNrInput.Text);
|
var mgnr = int.Parse(PredecessorMgNrInput.Text);
|
||||||
if (MemberList.SelectedItem is Member m && m.MgNr == mgnr)
|
if (MemberList.SelectedItem is not Member m || m.MgNr == mgnr)
|
||||||
return;
|
return;
|
||||||
using var ctx = new AppDbContext();
|
using var ctx = new AppDbContext();
|
||||||
var areaComs = await ctx.AreaCommitments
|
var areaComs = await ctx.AreaCommitments
|
||||||
@ -1142,13 +1142,12 @@ namespace Elwig.Windows {
|
|||||||
.ToListAsync();
|
.ToListAsync();
|
||||||
if (areaComs.Count == 0)
|
if (areaComs.Count == 0)
|
||||||
return;
|
return;
|
||||||
var res = MessageBox.Show("Sollen die aktiven Flächenbindungen des angegebenen\n" +
|
|
||||||
$"Vorgängers übernommen werden? ({areaComs.Sum(c => c.Area)} m²)\n\n" +
|
var oldMember = (await ctx.Members.FindAsync(mgnr))!;
|
||||||
"Die Änderungen werden erst beim Speichern übernommen!",
|
var d = new AreaComDialog(oldMember.AdministrativeName, m.AdministrativeName, areaComs.Count, areaComs.Sum(c => c.Area));
|
||||||
"Aktive Flächenbindungen übernehmen", MessageBoxButton.YesNo, MessageBoxImage.Question, MessageBoxResult.No);
|
if (d.ShowDialog() != true)
|
||||||
if (res != MessageBoxResult.Yes)
|
|
||||||
return;
|
return;
|
||||||
TransferPredecessorAreaComs = Utils.FollowingSeason;
|
TransferPredecessorAreaComs = d.SuccessorSeason;
|
||||||
SetOriginalValue(PredecessorMgNrInput, -1); // hack to allow user to save
|
SetOriginalValue(PredecessorMgNrInput, -1); // hack to allow user to save
|
||||||
UpdateButtons();
|
UpdateButtons();
|
||||||
}
|
}
|
||||||
@ -1190,18 +1189,18 @@ namespace Elwig.Windows {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private async void ActiveInput_Changed(object sender, RoutedEventArgs evt) {
|
private async void ActiveInput_Changed(object sender, RoutedEventArgs evt) {
|
||||||
|
if (MemberList.SelectedItem is not Member m)
|
||||||
|
return;
|
||||||
if ((IsEditing || IsCreating) && ActiveInput.IsChecked == false && int.TryParse(MgNrInput.Text, out var mgnr)) {
|
if ((IsEditing || IsCreating) && ActiveInput.IsChecked == false && int.TryParse(MgNrInput.Text, out var mgnr)) {
|
||||||
using var ctx = new AppDbContext();
|
using var ctx = new AppDbContext();
|
||||||
var areaComs = await ctx.AreaCommitments
|
var areaComs = await ctx.AreaCommitments
|
||||||
.Where(c => c.MgNr == mgnr && (c.YearTo == null || c.YearTo >= Utils.FollowingSeason))
|
.Where(c => c.MgNr == mgnr && (c.YearTo == null || c.YearTo >= Utils.FollowingSeason))
|
||||||
.ToListAsync();
|
.ToListAsync();
|
||||||
if (areaComs.Count >= 0) {
|
if (areaComs.Count > 0) {
|
||||||
var res = MessageBox.Show($"Sollen die aktiven Flächenbindungen gekündigt werden? ({areaComs.Sum(c => c.Area)} m²)\n" +
|
var d = new AreaComDialog(m.AdministrativeName, areaComs.Count, areaComs.Sum(c => c.Area));
|
||||||
"Falls die Flächenbindungen später an ein neues Mitglied\n" +
|
if (d.ShowDialog() == true) {
|
||||||
"übertragen werden sollen bitte \"Nein\" auswählen!\n\n" +
|
CancelAreaComs = d.CancelSeason;
|
||||||
"Die Änderungen werden erst beim Speichern übernommen!",
|
}
|
||||||
"Flächenbindungen kündigen", MessageBoxButton.YesNo, MessageBoxImage.Question, MessageBoxResult.No);
|
|
||||||
CancelAreaComs = res == MessageBoxResult.Yes ? Utils.FollowingSeason - 1 : null;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
CheckBox_Changed(sender, evt);
|
CheckBox_Changed(sender, evt);
|
||||||
|
Reference in New Issue
Block a user