Update AreaComAdminWindow
This commit is contained in:
@ -60,6 +60,12 @@
|
||||
</StackPanel>
|
||||
</DataTemplate>
|
||||
|
||||
<DataTemplate x:Key="WineAttributeTemplate">
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<TextBlock Text="{Binding Name}" MinWidth="150" Margin="0,0,10,0"/>
|
||||
</StackPanel>
|
||||
</DataTemplate>
|
||||
|
||||
<ControlTemplate x:Key="WineQualityLevelTemplateSimple">
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<TextBlock Text="{Binding Name}"/>
|
||||
|
@ -15,5 +15,8 @@ namespace Elwig.Models {
|
||||
|
||||
[Column("active")]
|
||||
public bool IsActive { get; set; }
|
||||
public override string ToString() {
|
||||
return Name;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -5,7 +5,8 @@
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:local="clr-namespace:Elwig.Windows"
|
||||
mc:Ignorable="d"
|
||||
Title="Flächenbindugen - Elwig" Height="500" Width="950"
|
||||
xmlns:xctk="http://schemas.xceed.com/wpf/xaml/toolkit"
|
||||
Title="Flächenbindugen - Elwig" Height="480" Width="745"
|
||||
Loaded="Window_Loaded">
|
||||
<Window.Resources>
|
||||
<Style TargetType="Label">
|
||||
@ -30,6 +31,13 @@
|
||||
<Setter Property="HorizontalAlignment" Value="Stretch"/>
|
||||
<Setter Property="VerticalAlignment" Value="Top"/>
|
||||
</Style>
|
||||
<Style TargetType="xctk:CheckComboBox">
|
||||
<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"/>
|
||||
@ -39,78 +47,53 @@
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="19"/>
|
||||
<RowDefinition Height="120"/>
|
||||
<RowDefinition Height="190"/>
|
||||
<RowDefinition Height="110"/>
|
||||
<RowDefinition Height="175"/>
|
||||
<RowDefinition Height="1*"/>
|
||||
</Grid.RowDefinitions>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="620"/>
|
||||
<ColumnDefinition Width="415"/>
|
||||
<ColumnDefinition Width="1*"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<Menu Grid.ColumnSpan="3" BorderThickness="0,0,0,1" BorderBrush="LightGray" Background="White">
|
||||
<Menu Grid.ColumnSpan="2" BorderThickness="0,0,0,1" BorderBrush="LightGray" Background="White">
|
||||
<MenuItem Header="Flächenbindugen"/>
|
||||
</Menu>
|
||||
|
||||
<Grid Grid.RowSpan="4" Grid.Row="1">
|
||||
<Grid Grid.RowSpan="3" Grid.Row="1" Grid.Column="0">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="125"/>
|
||||
<ColumnDefinition Width="120"/>
|
||||
<ColumnDefinition Width="125"/>
|
||||
<ColumnDefinition Width="125"/>
|
||||
<ColumnDefinition Width="125"/>
|
||||
<ColumnDefinition Width="1*"/>
|
||||
<ColumnDefinition Width="1*"/>
|
||||
<ColumnDefinition Width="1*"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<DataGrid x:Name="ContractList" AutoGenerateColumns="False" HeadersVisibility="Column" IsReadOnly="True" GridLinesVisibility="None" SelectionMode="Single"
|
||||
CanUserDeleteRows="False" CanUserResizeRows="False" CanUserAddRows="False" SelectionChanged="ContractList_SelectionChanged" Grid.Column="0" Grid.Row="1"
|
||||
Margin="10,10,5,47" FontSize="14" Grid.ColumnSpan="2" Background="#e2e2e2">
|
||||
<DataGrid.Columns>
|
||||
<DataGridTextColumn Header="VNr." Binding="{Binding VNr}" Width="*"/>
|
||||
<DataGridTextColumn Header="Von" Binding="{Binding YearFrom}" Width="*"/>
|
||||
<DataGridTextColumn Header="Bis" Binding="{Binding YearTo}" Width="*"/>
|
||||
</DataGrid.Columns>
|
||||
</DataGrid>
|
||||
|
||||
|
||||
<Button x:Name="NewContractButton" Content="Neu" Click="NewContractButton_Click"
|
||||
HorizontalAlignment="Left" VerticalAlignment="Bottom" Margin="10,10,0,10" Width="110" Grid.Column="0"/>
|
||||
<Button x:Name="DeleteContractButton" Content="Löschen" Click="DeleteContractButton_Click" IsEnabled="False"
|
||||
HorizontalAlignment="Left" VerticalAlignment="Bottom" Margin="5,10,0,10" Width="110" Grid.Column="1"/>
|
||||
|
||||
<Button x:Name="ContractSaveButton" Content="Speichern" Click="ContractSaveButton_Click" IsEnabled="False" Visibility="Hidden"
|
||||
HorizontalAlignment="Left" VerticalAlignment="Bottom" Margin="10,10,0,10" Width="110" Grid.Column="0"/>
|
||||
<Button x:Name="ContractCancelButton" Content="Abbrechen" Click="ContractCancelButton_Click" IsEnabled="False" Visibility="Hidden" IsCancel="True"
|
||||
HorizontalAlignment="Left" VerticalAlignment="Bottom" Margin="5,10,0,10" Width="110" Grid.Column="1"/>
|
||||
|
||||
|
||||
|
||||
<Button x:Name="NewAreaCommitmentButton" Content="Neu" Click="NewAreaCommitmentButton_Click" IsEnabled="False"
|
||||
HorizontalAlignment="Left" VerticalAlignment="Bottom" Margin="5,10,0,10" Width="110" Grid.Column="2"/>
|
||||
<Button x:Name="EditAreaCommitmentButton" Content="Bearbeiten" Click="EditAreaCommitmentButton_Click" IsEnabled="False"
|
||||
HorizontalAlignment="Center" VerticalAlignment="Bottom" Margin="-5,10,0,10" Width="110" Grid.Column="3"/>
|
||||
<Button x:Name="DeleteAreaCommitmentButton" Content="Löschen" Click="DeleteAreaCommitmentButton_Click" IsEnabled="False"
|
||||
HorizontalAlignment="Right" VerticalAlignment="Bottom" Margin="0,10,10,10" Width="110" Grid.Column="4"/>
|
||||
|
||||
<Button x:Name="AreaCommitmentSaveButton" Content="Speichern" Click="AreaCommitmentSaveButton_Click" IsEnabled="False" Visibility="Hidden"
|
||||
HorizontalAlignment="Left" VerticalAlignment="Bottom" Margin="10,10,0,10" Width="110" Grid.Column="2"/>
|
||||
<Button x:Name="AreaCommitmentResetButton" Content="Zurücksetzen" Click="AreaCommitmentResetButton_Click" IsEnabled="False" Visibility="Hidden"
|
||||
HorizontalAlignment="Center" VerticalAlignment="Bottom" Margin="-5,10,0,10" Width="110" Grid.Column="3"/>
|
||||
<Button x:Name="AreaCommitmentCancelButton" Content="Abbrechen" Click="AreaCommitmentCancelButton_Click" IsEnabled="False" Visibility="Hidden" IsCancel="True"
|
||||
HorizontalAlignment="Right" VerticalAlignment="Bottom" Margin="0,10,10,10" Width="110" Grid.Column="4"/>
|
||||
|
||||
<DataGrid x:Name="AreaCommitmentList" AutoGenerateColumns="False" HeadersVisibility="Column" IsReadOnly="True" GridLinesVisibility="None" SelectionMode="Single"
|
||||
CanUserDeleteRows="False" CanUserResizeRows="False" CanUserAddRows="False" SelectionChanged="AreaCommitmentList_SelectionChanged" Grid.Column="2" Grid.Row="1"
|
||||
Margin="5,10,10,47" FontSize="14" Grid.ColumnSpan="3" Background="#e2e2e2">
|
||||
CanUserDeleteRows="False" CanUserResizeRows="False" CanUserAddRows="False" SelectionChanged="AreaCommitmentList_SelectionChanged" Grid.Column="0" Grid.Row="1"
|
||||
Margin="5,10,5,47" FontSize="14" Grid.ColumnSpan="3" Background="#e2e2e2">
|
||||
<DataGrid.Columns>
|
||||
<DataGridTextColumn Header="Katastralgemeinde" Binding="{Binding Kg.Kg.Name}" Width="5*"/>
|
||||
<DataGridTextColumn Header="FbNr" Binding="{Binding FbNr}" Width="2*"/>
|
||||
<DataGridTextColumn Header="Katastralgemeinde" Binding="{Binding Kg.AtKg.Name}" Width="5*"/>
|
||||
<DataGridTextColumn Header="Ried" Binding="{Binding Rd.Name}" Width="4*"/>
|
||||
<DataGridTextColumn Header="Parzelle" Binding="{Binding GstNr}" Width="4*"/>
|
||||
</DataGrid.Columns>
|
||||
</DataGrid>
|
||||
|
||||
<Button x:Name="NewAreaCommitmentButton" Content="Neu" Click="NewAreaCommitmentButton_Click"
|
||||
HorizontalAlignment="Stretch" VerticalAlignment="Bottom" Margin="5,10,5,10" Grid.Column="0"/>
|
||||
<Button x:Name="EditAreaCommitmentButton" Content="Bearbeiten" Click="EditAreaCommitmentButton_Click" IsEnabled="False"
|
||||
HorizontalAlignment="Stretch" VerticalAlignment="Bottom" Margin="5,10,5,10" Grid.Column="1"/>
|
||||
<Button x:Name="DeleteAreaCommitmentButton" Content="Löschen" Click="DeleteAreaCommitmentButton_Click" IsEnabled="False"
|
||||
HorizontalAlignment="Stretch" VerticalAlignment="Bottom" Margin="5,10,5,10" Grid.Column="2"/>
|
||||
|
||||
<Button x:Name="AreaCommitmentSaveButton" Content="Speichern" Click="AreaCommitmentSaveButton_Click" IsEnabled="False" Visibility="Hidden"
|
||||
HorizontalAlignment="Stretch" VerticalAlignment="Bottom" Margin="5,10,5,10" Grid.Column="0"/>
|
||||
<Button x:Name="AreaCommitmentResetButton" Content="Zurücksetzen" Click="AreaCommitmentResetButton_Click" IsEnabled="False" Visibility="Hidden"
|
||||
HorizontalAlignment="Stretch" VerticalAlignment="Bottom" Margin="5,10,5,10" Grid.Column="1"/>
|
||||
<Button x:Name="AreaCommitmentCancelButton" Content="Abbrechen" Click="AreaCommitmentCancelButton_Click" IsEnabled="False" Visibility="Hidden" IsCancel="True"
|
||||
HorizontalAlignment="Stretch" VerticalAlignment="Bottom" Margin="5,10,5,10" Grid.Column="2"/>
|
||||
</Grid>
|
||||
|
||||
<GroupBox Header="Vertrag" Grid.Column="1" Grid.Row="1" Grid.RowSpan="1" Margin="5,5,5,5">
|
||||
<GroupBox Header="Vertrag" Grid.Column="2" Grid.Row="1" Grid.RowSpan="1" Margin="5,5,5,5">
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="60"/>
|
||||
@ -119,24 +102,24 @@
|
||||
<ColumnDefinition Width="100"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<Label Content="VNr.:" Margin="10,10,0,0" Grid.Column="0"/>
|
||||
<TextBox x:Name="VNrInput" Margin="0,10,0,0" Width="48" Grid.Column="1" TextAlignment="Right" HorizontalAlignment="Left"
|
||||
TextChanged="VNrInput_TextChanged" LostFocus="VNrInput_LostFocus"/>
|
||||
|
||||
<Label Content="FbNr.:" Margin="10,10,0,0" Grid.Column="0"/>
|
||||
<TextBox x:Name="FbNrInput" Margin="0,10,0,0" Width="48" Grid.Column="1" TextAlignment="Right" HorizontalAlignment="Left"
|
||||
TextChanged="FbNrInput_TextChanged" LostFocus="FbNrInput_LostFocus"/>
|
||||
|
||||
<Label Content="MgNr.:" Margin="10,40,0,0" Grid.Column="0"/>
|
||||
<TextBox x:Name="MgNrInput" Margin="0,40,0,0" Width="48" Grid.Column="1" TextAlignment="Right" HorizontalAlignment="Left"/>
|
||||
|
||||
|
||||
<Label Content="Von:" Margin="10,10,0,0" Grid.Column="2"/>
|
||||
<TextBox x:Name="YearFromInput" Margin="0,10,0,0" Width="100" Grid.Column="3" TextAlignment="Right" HorizontalAlignment="Left"
|
||||
TextChanged="YearFromInput_TextChanged"/>
|
||||
|
||||
TextChanged="IntegerInput_TextChanged"/>
|
||||
|
||||
<Label Content="Bis:" Margin="10,40,0,0" Grid.Column="2"/>
|
||||
<TextBox x:Name="YearToInput" Margin="0,40,0,0" Width="100" Grid.Column="3" TextAlignment="Right" HorizontalAlignment="Left"
|
||||
TextChanged="YearToInput_TextChanged"/>
|
||||
TextChanged="IntegerInput_TextChanged"/>
|
||||
</Grid>
|
||||
</GroupBox>
|
||||
|
||||
<GroupBox Header="Lage" Grid.Column="1" Grid.Row="2" Grid.RowSpan="1" Margin="5,5,5,5">
|
||||
|
||||
<GroupBox Header="Lage" Grid.Column="2" Grid.Row="2" Grid.RowSpan="1" Margin="5,5,5,5">
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="80"/>
|
||||
@ -147,24 +130,24 @@
|
||||
<ComboBox x:Name="KgInput" ItemTemplate="{StaticResource KgNrTemplate}" TextSearch.TextPath="Name"
|
||||
Width="200" HorizontalAlignment="Left" SelectionChanged="KgInput_SelectionChanged"
|
||||
Margin="0,10,10,0" Grid.Column="1"/>
|
||||
|
||||
|
||||
<Label Content="Ried:" Margin="10,40,0,0" Grid.Column="0"/>
|
||||
<ComboBox x:Name="RdInput" DisplayMemberPath="Name" TextSearch.TextPath="Name"
|
||||
Width="200" HorizontalAlignment="Left"
|
||||
Margin="0,40,0,0" Grid.Column="1"/>
|
||||
|
||||
|
||||
<Label Content="Parzelle:" Margin="10,70,0,0" Grid.Column="0"/>
|
||||
<TextBox x:Name="GstNrInput" Margin="0,70,0,0" Width="100" Grid.Column="1" TextAlignment="Right" HorizontalAlignment="Left"
|
||||
TextChanged="GstNrInput_TextChanged" LostFocus="GstNrInput_LostFocus"/>
|
||||
|
||||
<Label Content="Fläche (m²):" Margin="10,100,0,0" Grid.Column="0"/>
|
||||
<TextBox x:Name="AreaInput" Margin="0,100,0,0" Width="100" Grid.Column="1" TextAlignment="Right" HorizontalAlignment="Left"
|
||||
TextChanged="AreaInput_TextChanged"/>
|
||||
TextChanged="IntegerInput_TextChanged"/>
|
||||
</Grid>
|
||||
|
||||
</GroupBox>
|
||||
|
||||
<GroupBox Header="Eigenschaften" Grid.Column="1" Grid.Row="3" Grid.RowSpan="1" Margin="5,5,5,5">
|
||||
<GroupBox Header="Eigenschaften" Grid.Column="2" Grid.Row="3" Grid.RowSpan="1" Margin="5,5,5,5">
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="80"/>
|
||||
@ -172,20 +155,18 @@
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<Label Content="Sorte:" Margin="10,10,0,0" Grid.Column="0"/>
|
||||
<ComboBox x:Name="SortInput" ItemTemplate="{StaticResource WineVarietyTemplate}" TextSearch.TextPath="Name"
|
||||
<ComboBox x:Name="WineVarietyInput" ItemTemplate="{StaticResource WineVarietyTemplate}" TextSearch.TextPath="Name"
|
||||
Width="200" HorizontalAlignment="Left"
|
||||
Margin="0,10,10,0" Grid.Column="1"/>
|
||||
|
||||
<Label Content="Attribut:" Margin="10,40,0,0" Grid.Column="0"/>
|
||||
<ComboBox x:Name="AttrInput" DisplayMemberPath="Name" TextSearch.TextPath="Name"
|
||||
Width="200" HorizontalAlignment="Left"
|
||||
Margin="0,40,10,0" Grid.Column="1"/>
|
||||
<Label Content="Attribute:" Margin="10,40,0,0" Grid.Column="0"/>
|
||||
<xctk:CheckComboBox x:Name="AttributesInput" Grid.Column="1" Margin="0,40,0,0" IsEnabled="False"
|
||||
ItemTemplate="{StaticResource WineAttributeTemplate}" Delimiter=", " AllItemsSelectedContent="Alle"
|
||||
Width="200" HorizontalAlignment="Left" ItemSelectionChanged="AttributesInput_SelectionChanged"/>
|
||||
|
||||
<Label Content="Bewirt. Art:" Margin="10,70,0,0" Grid.Column="0"/>
|
||||
<ComboBox x:Name="CultInput" DisplayMemberPath="Name" TextSearch.TextPath="Name"
|
||||
Width="200" HorizontalAlignment="Left"
|
||||
Margin="0,70,10,0" Grid.Column="1"/>
|
||||
|
||||
<ComboBox x:Name="WineCultivationInput" DisplayMemberPath="Name" TextSearch.TextPath="Name"
|
||||
Width="200" HorizontalAlignment="Left" Margin="0,70,10,0" Grid.Column="1"/>
|
||||
</Grid>
|
||||
</GroupBox>
|
||||
</Grid>
|
||||
|
@ -4,8 +4,11 @@ using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using Elwig.Helpers;
|
||||
using Elwig.Models;
|
||||
using System.Threading.Tasks;
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using System.Collections.Generic;
|
||||
using Microsoft.EntityFrameworkCore.ChangeTracking;
|
||||
using Xceed.Wpf.Toolkit.Primitives;
|
||||
|
||||
namespace Elwig.Windows {
|
||||
public partial class AreaComAdminWindow : AdministrationWindow {
|
||||
@ -16,34 +19,18 @@ namespace Elwig.Windows {
|
||||
Member = Context.Members.Find(mgnr) ?? throw new ArgumentException("MgNr argument has invalid value");
|
||||
Title = $"Flächenbindungen - {Member.AdministrativeName} - Elwig";
|
||||
ExemptInputs = new Control[] {
|
||||
MgNrInput, ContractList, AreaCommitmentList, NewContractButton, DeleteContractButton,
|
||||
ContractSaveButton, ContractCancelButton, NewAreaCommitmentButton,
|
||||
MgNrInput, AreaCommitmentList, NewAreaCommitmentButton,
|
||||
EditAreaCommitmentButton, DeleteAreaCommitmentButton, AreaCommitmentSaveButton,
|
||||
AreaCommitmentResetButton, AreaCommitmentCancelButton
|
||||
};
|
||||
RequiredInputs = new Control[] {
|
||||
VNrInput, YearFromInput, KgInput,
|
||||
GstNrInput, AreaInput, SortInput, CultInput
|
||||
FbNrInput, YearFromInput, KgInput,
|
||||
GstNrInput, AreaInput, WineVarietyInput, WineCultivationInput
|
||||
};
|
||||
}
|
||||
|
||||
private async void Window_Loaded(object sender, RoutedEventArgs e) {
|
||||
await RefreshContractList();
|
||||
KgInput.ItemsSource = Context.WbKgs.Select(k => k.AtKg).OrderBy(k => k.Name).ToList();
|
||||
SortInput.ItemsSource = Context.WineVarieties.OrderBy(s => s.Name).ToList();
|
||||
AttrInput.ItemsSource = Context.WineAttributes.OrderBy(a => a.Name).ToList();
|
||||
CultInput.ItemsSource = Context.WineCultivations.OrderBy(c => c.Name).ToList();
|
||||
}
|
||||
|
||||
protected override async Task RenewContext() {
|
||||
await base.RenewContext();
|
||||
}
|
||||
|
||||
private async Task RefreshContractList() {
|
||||
/*
|
||||
await Context.Contracts.LoadAsync();
|
||||
await RefreshContractListQuery();
|
||||
*/
|
||||
await RenewContext();
|
||||
}
|
||||
|
||||
private async Task RefreshAreaCommitmentList() {
|
||||
@ -51,51 +38,19 @@ namespace Elwig.Windows {
|
||||
await RefreshAreaCommitmentListQuery();
|
||||
}
|
||||
|
||||
private async Task RefreshContractListQuery() {
|
||||
/*
|
||||
List<Contract> contracts = await Context.Contracts.Where(c => c.MgNr == member.MgNr).ToListAsync();
|
||||
|
||||
ContractList.ItemsSource = contracts;
|
||||
if (contracts.Count == 1)
|
||||
ContractList.SelectedIndex = 0;
|
||||
|
||||
// TODO notwendig?
|
||||
await RefreshAreaCommitmentList();
|
||||
RefreshInputs();
|
||||
*/
|
||||
}
|
||||
|
||||
private async Task RefreshAreaCommitmentListQuery() {
|
||||
/*
|
||||
Contract? contract = (Contract)ContractList.SelectedItem;
|
||||
|
||||
if (contract == null) {
|
||||
AreaCommitmentList.ItemsSource = null;
|
||||
return;
|
||||
}
|
||||
List<AreaCom> areaComs = await Context.AreaCommitments.Where(a => a.MgNr == Member.MgNr).OrderBy(a => a.FbNr).ToListAsync();
|
||||
|
||||
List<AreaComParcel> parcels = (await Context.AreaCommitments.FindAsync(contract.VNr)).Parcels.ToList();
|
||||
|
||||
AreaCommitmentList.ItemsSource = parcels;
|
||||
if (parcels.Count == 1)
|
||||
Utils.RenewItemsSource(AreaCommitmentList, areaComs, i => (i as AreaCom)?.FbNr);
|
||||
if (areaComs.Count == 1)
|
||||
AreaCommitmentList.SelectedIndex = 0;
|
||||
|
||||
RefreshInputs();
|
||||
*/
|
||||
}
|
||||
|
||||
private void RefreshInputs(bool validate = false) {
|
||||
/*
|
||||
ClearInputStates();
|
||||
Contract? c = (Contract)ContractList.SelectedItem;
|
||||
AreaComParcel? a = (AreaComParcel)AreaCommitmentList.SelectedItem;
|
||||
|
||||
if (c != null) {
|
||||
DeleteContractButton.IsEnabled = true;
|
||||
NewAreaCommitmentButton.IsEnabled = true;
|
||||
} else {
|
||||
DeleteContractButton.IsEnabled = false;
|
||||
NewAreaCommitmentButton.IsEnabled = false;
|
||||
}
|
||||
AreaCom? a = (AreaCom)AreaCommitmentList.SelectedItem;
|
||||
|
||||
if (a != null) {
|
||||
EditAreaCommitmentButton.IsEnabled = true;
|
||||
@ -104,49 +59,64 @@ namespace Elwig.Windows {
|
||||
} else {
|
||||
EditAreaCommitmentButton.IsEnabled = false;
|
||||
DeleteAreaCommitmentButton.IsEnabled = false;
|
||||
ClearOriginalValues();
|
||||
ClearInputs();
|
||||
AttributesInput.UnSelectAll();
|
||||
MgNrInput.Text = "";
|
||||
}
|
||||
if (!validate) ClearInputStates();
|
||||
GC.Collect();
|
||||
*/
|
||||
}
|
||||
|
||||
/*
|
||||
private void FillInputs(AreaComParcel a) {
|
||||
private void FillInputs(AreaCom a) {
|
||||
ClearOriginalValues();
|
||||
|
||||
VNrInput.Text = a.VNr.ToString();
|
||||
MgNrInput.Text = a.AreaCom.Contract.MgNr.ToString();
|
||||
YearFromInput.Text = a.AreaCom.Contract.YearFrom.ToString();
|
||||
YearToInput.Text = a.AreaCom.Contract.YearTo.ToString();
|
||||
FbNrInput.Text = a.FbNr.ToString();
|
||||
MgNrInput.Text = a.MgNr.ToString();
|
||||
YearFromInput.Text = a.YearFrom.ToString();
|
||||
YearToInput.Text = a.YearTo.ToString();
|
||||
|
||||
KgInput.SelectedItem = a.Kg.Kg;
|
||||
KgInput.SelectedItem = a.Kg.AtKg;
|
||||
RdInput.SelectedItem = a.Rd;
|
||||
GstNrInput.Text = a.GstNr;
|
||||
AreaInput.Text = a.Area.ToString();
|
||||
|
||||
SortInput.SelectedItem = a.AreaCom.WineVar;
|
||||
// FIXME
|
||||
//AttrInput.SelectedItem = a.WineAttr;
|
||||
CultInput.SelectedItem = a.AreaCom.WineCult;
|
||||
WineVarietyInput.SelectedItem = a.WineVar;
|
||||
|
||||
AttributesInput.UnSelectAll();
|
||||
foreach (var attr in a.Attributes) {
|
||||
AttributesInput.SelectedItems.Add(attr);
|
||||
}
|
||||
|
||||
WineCultivationInput.SelectedItem = a.WineCult;
|
||||
|
||||
FillOriginalValues();
|
||||
}
|
||||
*/
|
||||
|
||||
private async void InitInputs() {
|
||||
FbNrInput.Text = (await Context.NextFbNr()).ToString();
|
||||
MgNrInput.Text = Member.MgNr.ToString();
|
||||
FillOriginalValues();
|
||||
ValidateRequiredInputs();
|
||||
}
|
||||
|
||||
protected override async Task RenewContext() {
|
||||
await base.RenewContext();
|
||||
Utils.RenewItemsSource(KgInput, await Context.WbKgs.Select(k => k.AtKg).OrderBy(k => k.Name).ToListAsync(), i => (i as AT_Kg)?.KgNr);
|
||||
Utils.RenewItemsSource(WineVarietyInput, await Context.WineVarieties.OrderBy(v => v.Name).ToListAsync(), i => (i as WineVar)?.SortId);
|
||||
Utils.RenewItemsSource(AttributesInput, await Context.WineAttributes.OrderBy(a => a.Name).ToListAsync(), i => (i as WineAttr)?.AttrId);
|
||||
Utils.RenewItemsSource(WineCultivationInput, await Context.WineCultivations.OrderBy(c => c.Name).ToListAsync(), i => (i as WineCult)?.CultId);
|
||||
await RefreshAreaCommitmentList();
|
||||
}
|
||||
|
||||
private void NewAreaCommitmentButton_Click(object sender, RoutedEventArgs evt) {
|
||||
IsCreating = true;
|
||||
AreaCommitmentList.IsEnabled = false;
|
||||
AreaCommitmentList.SelectedItem = null;
|
||||
ContractList.IsEnabled = false;
|
||||
HideAreaCommitmentNewEditDeleteButtons();
|
||||
ShowAreaCommitmentSaveResetCancelButtons();
|
||||
DisableContractNewDeleteButtons();
|
||||
UnlockInputs();
|
||||
VNrInput.IsReadOnly = true;
|
||||
YearFromInput.IsReadOnly = true;
|
||||
YearToInput.IsReadOnly = true;
|
||||
AttributesInput.IsEnabled = true;
|
||||
InitInputs();
|
||||
}
|
||||
|
||||
@ -156,111 +126,73 @@ namespace Elwig.Windows {
|
||||
|
||||
IsEditing = true;
|
||||
AreaCommitmentList.IsEnabled = false;
|
||||
ContractList.IsEnabled = false;
|
||||
|
||||
HideAreaCommitmentNewEditDeleteButtons();
|
||||
ShowAreaCommitmentSaveResetCancelButtons();
|
||||
DisableContractNewDeleteButtons();
|
||||
UnlockInputs();
|
||||
AttributesInput.IsEnabled = true;
|
||||
}
|
||||
|
||||
private async void DeleteAreaCommitmentButton_Click(object sender, RoutedEventArgs evt) {
|
||||
/*
|
||||
AreaComParcel a = (AreaComParcel)AreaCommitmentList.SelectedItem;
|
||||
AreaCom a = (AreaCom)AreaCommitmentList.SelectedItem;
|
||||
if (a == null) return;
|
||||
|
||||
var r = MessageBox.Show(
|
||||
$"Soll die Parzelle {a.GstNr} ({a.Area} m²) wirklich unwiderruflich gelöscht werden?",
|
||||
$"Soll die Flächenbindung {a.GstNr} ({a.Area} m²) wirklich unwiderruflich gelöscht werden?",
|
||||
"Parzelle löschen", MessageBoxButton.YesNo, MessageBoxImage.Warning, MessageBoxResult.No);
|
||||
if (r == MessageBoxResult.Yes) {
|
||||
Context.Remove(a);
|
||||
Context.SaveChanges();
|
||||
await RefreshAreaCommitmentList();
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
private void NewContractButton_Click(object sender, RoutedEventArgs evt) {
|
||||
IsCreating = true;
|
||||
ContractList.IsEnabled = false;
|
||||
ContractList.SelectedItem = null;
|
||||
AreaCommitmentList.IsEnabled = false;
|
||||
AreaCommitmentList.SelectedItem = null;
|
||||
HideContractNewDeleteButtons();
|
||||
ShowContractSaveCancelButtons();
|
||||
DisableAreaCommitmentNewEditDeleteButtons();
|
||||
UnlockInputs();
|
||||
InitInputs();
|
||||
}
|
||||
|
||||
private async void DeleteContractButton_Click(object sender, RoutedEventArgs evt) {
|
||||
/*
|
||||
Contract c = (Contract)ContractList.SelectedItem;
|
||||
if (c == null) return;
|
||||
|
||||
var r = MessageBox.Show(
|
||||
$"Soll der Vertrag {c.VNr} und alle enthaltenen Parzellen wirklich unwiderruflich gelöscht werden?",
|
||||
"Vertrag löschen", MessageBoxButton.YesNo, MessageBoxImage.Warning, MessageBoxResult.No);
|
||||
if (r == MessageBoxResult.Yes) {
|
||||
Context.Remove(c);
|
||||
Context.SaveChanges();
|
||||
await RefreshContractList();
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
/*
|
||||
private async Task<Contract> UpdateContract(Contract c) {
|
||||
int newVNr = int.Parse(VNrInput.Text);
|
||||
c.MgNr = int.Parse(MgNrInput.Text);
|
||||
c.YearFrom = int.Parse(YearFromInput.Text);
|
||||
c.YearTo = (YearToInput.Text == "") ? null : int.Parse(YearToInput.Text);
|
||||
|
||||
EntityEntry<Contract>? tr = null;
|
||||
try {
|
||||
if (IsEditing) {
|
||||
tr = Context.Update(c);
|
||||
} else if (IsCreating) {
|
||||
c.VNr = newVNr;
|
||||
tr = (await Context.AddAsync(c));
|
||||
}
|
||||
await Context.SaveChangesAsync();
|
||||
|
||||
if (newVNr != c.VNr) {
|
||||
await Context.Database.ExecuteSqlAsync($"UPDATE contract SET vnr = {newVNr} WHERE mgnr = {c.VNr}");
|
||||
await Context.Contracts.LoadAsync();
|
||||
c = await Context.Contracts.FindAsync(newVNr);
|
||||
}
|
||||
} catch (Exception exc) {
|
||||
if (tr != null) await tr.ReloadAsync();
|
||||
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, "Vertrag aktualisieren", MessageBoxButton.OK, MessageBoxImage.Error);
|
||||
}
|
||||
|
||||
return c;
|
||||
}
|
||||
|
||||
private async Task<AreaComParcel> UpdateaAreaComParcel(AreaComParcel a) {
|
||||
a.VNr = int.Parse(VNrInput.Text);
|
||||
private async Task<AreaCom> UpdateAreaCom(AreaCom a) {
|
||||
int newFbNr = int.Parse(FbNrInput.Text);
|
||||
a.MgNr = int.Parse(MgNrInput.Text);
|
||||
a.YearFrom = int.Parse(YearFromInput.Text);
|
||||
a.YearTo = (YearToInput.Text == "") ? null : int.Parse(YearToInput.Text);
|
||||
a.KgNr = ((AT_Kg)KgInput.SelectedItem).KgNr;
|
||||
a.RdNr = ((WbRd)RdInput.SelectedItem).RdNr;
|
||||
a.RdNr = RdInput.SelectedItem.GetType() == typeof(NullItem) ? null : ((WbRd)RdInput.SelectedItem).RdNr;
|
||||
a.GstNr = GstNrInput.Text;
|
||||
a.Area = int.Parse(AreaInput.Text);
|
||||
a.AreaCom.SortId = ((WineVar)SortInput.SelectedItem).SortId;
|
||||
// FIXME
|
||||
//a.AttrId = ((WineAttr)AttrInput.SelectedItem).AttrId;
|
||||
a.AreaCom.CultId = ((WineCult)CultInput.SelectedItem).CultId;
|
||||
a.SortId = ((WineVar)WineVarietyInput.SelectedItem).SortId;
|
||||
a.CultId = ((WineCult)WineCultivationInput.SelectedItem).CultId;
|
||||
|
||||
EntityEntry<AreaComParcel>? tr = null;
|
||||
EntityEntry<AreaCom>? tr = null;
|
||||
try {
|
||||
if (IsEditing) {
|
||||
tr = Context.Update(a);
|
||||
} else if (IsCreating) {
|
||||
a.FbNr = newFbNr;
|
||||
tr = (await Context.AddAsync(a));
|
||||
}
|
||||
|
||||
|
||||
foreach (WineAttr attr in a.Attributes) {
|
||||
if (!AttributesInput.SelectedItems.Contains(attr)) {
|
||||
var aca = a.AttributeEntries.FirstOrDefault(h => h.AttrId == attr.AttrId);
|
||||
Context.Remove(aca);
|
||||
}
|
||||
}
|
||||
|
||||
foreach (WineAttr attr in AttributesInput.SelectedItems) {
|
||||
if (!a.Attributes.Contains(attr)) {
|
||||
AreaComAttr aca = Context.CreateProxy<AreaComAttr>();
|
||||
aca.FbNr = a.FbNr;
|
||||
aca.AttrId = attr.AttrId;
|
||||
await Context.AddAsync(aca);
|
||||
}
|
||||
}
|
||||
|
||||
await Context.SaveChangesAsync();
|
||||
|
||||
if (newFbNr != a.FbNr) {
|
||||
await Context.Database.ExecuteSqlAsync($"UPDATE area_commitment SET fbnr = {newFbNr} WHERE fbnr = {a.FbNr}");
|
||||
await Context.Members.LoadAsync();
|
||||
a = await Context.AreaCommitments.FindAsync(newFbNr);
|
||||
}
|
||||
|
||||
} catch (Exception exc) {
|
||||
if (tr != null) await tr.ReloadAsync();
|
||||
var str = "Der Eintrag konnte nicht in der Datenbank aktualisiert werden!\n\n" + exc.Message;
|
||||
@ -270,26 +202,18 @@ namespace Elwig.Windows {
|
||||
|
||||
return a;
|
||||
}
|
||||
*/
|
||||
|
||||
private async void AreaCommitmentSaveButton_Click(object sender, RoutedEventArgs evt) {
|
||||
/*
|
||||
Contract c = await UpdateContract((Contract)ContractList.SelectedItem);
|
||||
AreaComParcel a = await UpdateaAreaComParcel(IsEditing ? (AreaComParcel)AreaCommitmentList.SelectedItem : Context.CreateProxy<AreaComParcel>());
|
||||
|
||||
AreaCom a = await UpdateAreaCom(IsEditing ? (AreaCom)AreaCommitmentList.SelectedItem : Context.CreateProxy<AreaCom>());
|
||||
IsEditing = false;
|
||||
IsCreating = false;
|
||||
AreaCommitmentList.IsEnabled = true;
|
||||
ContractList.IsEnabled = true;
|
||||
HideAreaCommitmentSaveResetCancelButtons();
|
||||
ShowAreaCommitmentNewEditDeleteButtons();
|
||||
EnableContractNewDeleteButtons();
|
||||
LockInputs();
|
||||
await RefreshContractList();
|
||||
AttributesInput.IsEnabled = false;
|
||||
await RefreshAreaCommitmentList();
|
||||
ContractList.SelectedItem = c;
|
||||
AreaCommitmentList.SelectedItem = a;
|
||||
*/
|
||||
}
|
||||
|
||||
private void AreaCommitmentResetButton_Click(object sender, RoutedEventArgs evt) {
|
||||
@ -305,73 +229,19 @@ namespace Elwig.Windows {
|
||||
IsEditing = false;
|
||||
IsCreating = false;
|
||||
AreaCommitmentList.IsEnabled = true;
|
||||
ContractList.IsEnabled = true;
|
||||
HideAreaCommitmentSaveResetCancelButtons();
|
||||
ShowAreaCommitmentNewEditDeleteButtons();
|
||||
EnableContractNewDeleteButtons();
|
||||
RefreshInputs();
|
||||
ClearInputStates();
|
||||
LockInputs();
|
||||
}
|
||||
|
||||
private async void ContractSaveButton_Click(object sender, RoutedEventArgs evt) {
|
||||
/*
|
||||
Contract c = await UpdateContract(Context.CreateProxy<Contract>());
|
||||
AreaComParcel a = await UpdateaAreaComParcel(Context.CreateProxy<AreaComParcel>());
|
||||
|
||||
IsEditing = false;
|
||||
IsCreating = false;
|
||||
AreaCommitmentList.IsEnabled = true;
|
||||
ContractList.IsEnabled = true;
|
||||
HideContractSaveCancelButtons();
|
||||
ShowContractNewDeleteButtons();
|
||||
EnableAreaCommitmentNewEditDeleteButtons();
|
||||
LockInputs();
|
||||
await RefreshContractList();
|
||||
await RefreshAreaCommitmentList();
|
||||
ContractList.SelectedItem = c;
|
||||
AreaCommitmentList.SelectedItem = a;
|
||||
*/
|
||||
}
|
||||
|
||||
private void ContractCancelButton_Click(object sender, RoutedEventArgs evt) {
|
||||
IsEditing = false;
|
||||
IsCreating = false;
|
||||
ContractList.IsEnabled = true;
|
||||
AreaCommitmentList.IsEnabled = true;
|
||||
HideContractSaveCancelButtons();
|
||||
ShowContractNewDeleteButtons();
|
||||
EnableAreaCommitmentNewEditDeleteButtons();
|
||||
RefreshInputs();
|
||||
ClearInputStates();
|
||||
LockInputs();
|
||||
AttributesInput.IsEnabled = false;
|
||||
}
|
||||
|
||||
override protected void UpdateButtons() {
|
||||
if (!IsEditing && !IsCreating) return;
|
||||
bool ch = HasChanged, v = IsValid;
|
||||
ContractSaveButton.IsEnabled = (v && ch);
|
||||
AreaCommitmentResetButton.IsEnabled = (ch);
|
||||
AreaCommitmentSaveButton.IsEnabled = (v && ch);
|
||||
}
|
||||
|
||||
private async void InitInputs() {
|
||||
/*
|
||||
VNrInput.Text = ContractList.SelectedItem == null ? (await Context.NextVNr()).ToString() : ((Contract)ContractList.SelectedItem).VNr.ToString();
|
||||
MgNrInput.Text = member.MgNr.ToString();
|
||||
FillOriginalValues();
|
||||
ValidateRequiredInputs();
|
||||
*/
|
||||
}
|
||||
|
||||
private void EnableContractNewDeleteButtons() {
|
||||
NewContractButton.IsEnabled = true;
|
||||
DeleteContractButton.IsEnabled = ContractList.SelectedItem != null;
|
||||
}
|
||||
|
||||
private void DisableContractNewDeleteButtons() {
|
||||
NewContractButton.IsEnabled = false;
|
||||
DeleteContractButton.IsEnabled = false;
|
||||
AreaCommitmentSaveButton.IsEnabled = (ch && v);
|
||||
}
|
||||
|
||||
private void DisableAreaCommitmentNewEditDeleteButtons() {
|
||||
@ -381,37 +251,11 @@ namespace Elwig.Windows {
|
||||
}
|
||||
|
||||
private void EnableAreaCommitmentNewEditDeleteButtons() {
|
||||
NewAreaCommitmentButton.IsEnabled = ContractList.SelectedItem != null;
|
||||
NewAreaCommitmentButton.IsEnabled = true;
|
||||
EditAreaCommitmentButton.IsEnabled = AreaCommitmentList.SelectedItem != null;
|
||||
DeleteAreaCommitmentButton.IsEnabled = AreaCommitmentList.SelectedItem != null;
|
||||
}
|
||||
|
||||
private void ShowContractSaveCancelButtons() {
|
||||
ContractSaveButton.IsEnabled = false;
|
||||
ContractCancelButton.IsEnabled = true;
|
||||
ContractSaveButton.Visibility = Visibility.Visible;
|
||||
ContractCancelButton.Visibility = Visibility.Visible;
|
||||
}
|
||||
|
||||
private void HideContractSaveCancelButtons() {
|
||||
ContractSaveButton.IsEnabled = false;
|
||||
ContractCancelButton.IsEnabled = false;
|
||||
ContractSaveButton.Visibility = Visibility.Hidden;
|
||||
ContractCancelButton.Visibility = Visibility.Hidden;
|
||||
}
|
||||
|
||||
private void ShowContractNewDeleteButtons() {
|
||||
EnableContractNewDeleteButtons();
|
||||
NewContractButton.Visibility = Visibility.Visible;
|
||||
DeleteContractButton.Visibility = Visibility.Visible;
|
||||
}
|
||||
|
||||
private void HideContractNewDeleteButtons() {
|
||||
DisableContractNewDeleteButtons();
|
||||
NewContractButton.Visibility = Visibility.Hidden;
|
||||
DeleteContractButton.Visibility = Visibility.Hidden;
|
||||
}
|
||||
|
||||
private void ShowAreaCommitmentSaveResetCancelButtons() {
|
||||
AreaCommitmentSaveButton.IsEnabled = false;
|
||||
AreaCommitmentResetButton.IsEnabled = false;
|
||||
@ -444,57 +288,40 @@ namespace Elwig.Windows {
|
||||
DeleteAreaCommitmentButton.Visibility = Visibility.Hidden;
|
||||
}
|
||||
|
||||
private async void ContractList_SelectionChanged(object sender, SelectionChangedEventArgs evt) {
|
||||
//await RefreshContractListQuery();
|
||||
await RefreshAreaCommitmentList();
|
||||
}
|
||||
|
||||
private void AreaCommitmentList_SelectionChanged(object sender, SelectionChangedEventArgs evt) {
|
||||
RefreshInputs();
|
||||
}
|
||||
|
||||
private void KgInput_SelectionChanged(object sender, SelectionChangedEventArgs evt) {
|
||||
private void AttributesInput_SelectionChanged(object sender, ItemSelectionChangedEventArgs evt) {
|
||||
|
||||
}
|
||||
|
||||
private async void KgInput_SelectionChanged(object sender, SelectionChangedEventArgs evt) {
|
||||
AT_Kg? curr_kg = (AT_Kg)KgInput.SelectedItem;
|
||||
if (curr_kg != null) {
|
||||
RdInput.ItemsSource = Context.WbRde.Where(r => r.KgNr == curr_kg.KgNr).OrderBy(r => r.Name).ToList();
|
||||
var rdList = await Context.WbRde.Where(r => r.KgNr == curr_kg.KgNr).OrderBy(r => r.Name).Cast<object>().ToListAsync();
|
||||
rdList.Insert(0, new NullItem());
|
||||
Utils.RenewItemsSource(RdInput, rdList, i => (i as WbRd)?.RdNr);
|
||||
}
|
||||
ComboBox_SelectionChanged(sender, evt);
|
||||
}
|
||||
|
||||
/*
|
||||
protected void InputTextChanged(TextBox input, Func<TextBox, bool, AppDbContext, Contract?, ValidationResult> checker) {
|
||||
InputTextChanged(input, checker(input, SenderIsRequired(input), Context, (Contract)ContractList.SelectedItem));
|
||||
protected void InputTextChanged(TextBox input, Func<TextBox, bool, AppDbContext, AreaCom?, ValidationResult> checker) {
|
||||
InputTextChanged(input, checker(input, SenderIsRequired(input), Context, (AreaCom)AreaCommitmentList.SelectedItem));
|
||||
}
|
||||
|
||||
protected void InputLostFocus(TextBox input, Func<TextBox, bool, AppDbContext, Contract?, ValidationResult> checker, string? msg = null) {
|
||||
InputLostFocus(input, checker(input, SenderIsRequired(input), Context, (Contract)ContractList.SelectedItem), msg);
|
||||
}
|
||||
*/
|
||||
|
||||
private void NumericInput_TextChanged(object sender, RoutedEventArgs evt) {
|
||||
InputTextChanged((TextBox)sender, Validator.CheckInteger);
|
||||
protected void InputLostFocus(TextBox input, Func<TextBox, bool, AppDbContext, AreaCom?, ValidationResult> checker, string? msg = null) {
|
||||
InputLostFocus(input, checker(input, SenderIsRequired(input), Context, (AreaCom)AreaCommitmentList.SelectedItem), msg);
|
||||
}
|
||||
|
||||
private void VNrInput_TextChanged(object sender, RoutedEventArgs evt) {
|
||||
/*
|
||||
InputTextChanged((TextBox)sender, Validator.CheckVNr);
|
||||
*/
|
||||
private void FbNrInput_TextChanged(object sender, RoutedEventArgs evt) {
|
||||
InputTextChanged((TextBox)sender, Validator.CheckFbNr);
|
||||
}
|
||||
|
||||
private void VNrInput_LostFocus(object sender, RoutedEventArgs evt) {
|
||||
/*
|
||||
InputLostFocus((TextBox)sender, Validator.CheckVNr);
|
||||
*/
|
||||
private void FbNrInput_LostFocus(object sender, RoutedEventArgs evt) {
|
||||
InputLostFocus((TextBox)sender, Validator.CheckFbNr);
|
||||
}
|
||||
|
||||
private void YearFromInput_TextChanged(object sender, RoutedEventArgs evt) {
|
||||
InputTextChanged((TextBox)sender, Validator.CheckInteger);
|
||||
}
|
||||
|
||||
private void YearToInput_TextChanged(object sender, RoutedEventArgs evt) {
|
||||
InputTextChanged((TextBox)sender, Validator.CheckInteger);
|
||||
}
|
||||
|
||||
|
||||
private void GstNrInput_TextChanged(object sender, RoutedEventArgs evt) {
|
||||
InputTextChanged((TextBox)sender, Validator.CheckGstNr);
|
||||
}
|
||||
@ -502,9 +329,5 @@ namespace Elwig.Windows {
|
||||
private void GstNrInput_LostFocus(object sender, RoutedEventArgs evt) {
|
||||
InputLostFocus((TextBox)sender, Validator.CheckGstNr);
|
||||
}
|
||||
|
||||
private void AreaInput_TextChanged(object sender, RoutedEventArgs evt) {
|
||||
InputTextChanged((TextBox)sender, Validator.CheckInteger);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user