Adust AreaComAdminWindow to new db schema
This commit is contained in:
@ -11,17 +11,13 @@
|
||||
<DataTemplate x:Key="PostalDestTemplate">
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<TextBlock Text="{Binding Dest}"/>
|
||||
<TextBlock Text=" ("/>
|
||||
<TextBlock Text="{Binding Ort.Name}"/>
|
||||
<TextBlock Text=")"/>
|
||||
<TextBlock Text="{Binding Ort.Name, StringFormat='{} ({0})'}"/>
|
||||
</StackPanel>
|
||||
</DataTemplate>
|
||||
<DataTemplate x:Key="KgNrTemplate">
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<TextBlock Text="{Binding Name}"/>
|
||||
<TextBlock Text=" ("/>
|
||||
<TextBlock Text="{Binding KgNr}"/>
|
||||
<TextBlock Text=")"/>
|
||||
<TextBlock Text="{Binding KgNr, StringFormat='{} ({0:00000})'}"/>
|
||||
</StackPanel>
|
||||
</DataTemplate>
|
||||
<DataTemplate x:Key="MemberAdminNameTemplate">
|
||||
|
@ -58,19 +58,25 @@ namespace Elwig {
|
||||
|
||||
Dictionary<string, (string, string, int?, string?, string?, string?, string?, string?)> branches = new();
|
||||
using (var ctx = new AppDbContext()) {
|
||||
if (!ctx.Database.CanConnect()) {
|
||||
MessageBox.Show($"Invalid Database:\n\n{Config.DatabaseFile}", "Invalid Database", MessageBoxButton.OK, MessageBoxImage.Error);
|
||||
Shutdown();
|
||||
return;
|
||||
} else {
|
||||
branches = ctx.Branches.ToDictionary(b => b.Name.ToLower(), b => (b.ZwstId, b.Name, b.PostalDest?.AtPlz?.Plz, b.PostalDest?.AtPlz?.Dest, b.Address, b.PhoneNr, b.FaxNr, b.MobileNr));
|
||||
try {
|
||||
Client = new(ctx);
|
||||
} catch (Exception e) {
|
||||
MessageBox.Show($"Fehler beim Laden der Mandantendaten:\n\n{e.Message}", "Fehler");
|
||||
try {
|
||||
if (!ctx.Database.CanConnect()) {
|
||||
MessageBox.Show($"Invalid Database:\n\n{Config.DatabaseFile}", "Invalid Database", MessageBoxButton.OK, MessageBoxImage.Error);
|
||||
Shutdown();
|
||||
return;
|
||||
} else {
|
||||
branches = ctx.Branches.ToDictionary(b => b.Name.ToLower(), b => (b.ZwstId, b.Name, b.PostalDest?.AtPlz?.Plz, b.PostalDest?.AtPlz?.Dest, b.Address, b.PhoneNr, b.FaxNr, b.MobileNr));
|
||||
try {
|
||||
Client = new(ctx);
|
||||
} catch (Exception e) {
|
||||
MessageBox.Show($"Fehler beim Laden der Mandantendaten:\n\n{e.Message}", "Fehler", MessageBoxButton.OK, MessageBoxImage.Error);
|
||||
Shutdown();
|
||||
return;
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
MessageBox.Show($"Invalid Database:\n\n{e.Message}", "Invalid Database", MessageBoxButton.OK, MessageBoxImage.Error);
|
||||
Shutdown();
|
||||
return;
|
||||
}
|
||||
}
|
||||
Utils.RunBackground("HTML Initialization", () => Documents.Html.Init(PrintingReadyChanged));
|
||||
|
@ -28,11 +28,11 @@ namespace Elwig.Helpers {
|
||||
public DbSet<WineAttr> WineAttributes { get; private set; }
|
||||
public DbSet<WineCult> WineCultivations { get; private set; }
|
||||
public DbSet<Branch> Branches { get; private set; }
|
||||
public DbSet<AreaComType> AreaCommitmentTypes { get; private set; }
|
||||
public DbSet<Member> Members { get; private set; }
|
||||
public DbSet<BillingAddr> BillingAddresses { get; private set; }
|
||||
public DbSet<MemberTelNr> MemberTelephoneNrs { get; private set; }
|
||||
public DbSet<AreaCom> AreaCommitments { get; private set; }
|
||||
public DbSet<AreaComAttr> AreaCommitmentAttributes { get; private set; }
|
||||
public DbSet<Season> Seasons { get; private set; }
|
||||
public DbSet<Modifier> Modifiers { get; private set; }
|
||||
public DbSet<Delivery> Deliveries { get; private set; }
|
||||
@ -110,7 +110,7 @@ namespace Elwig.Helpers {
|
||||
public async Task<int> NextFbNr() {
|
||||
int c = await AreaCommitments.Select(ac => ac.FbNr).MinAsync();
|
||||
(await AreaCommitments.OrderBy(ac => ac.FbNr).Select(ac => ac.FbNr).ToListAsync())
|
||||
.ForEach(a => { if (a <= c + 100) c = a; });
|
||||
.ForEach(a => { if (a <= c + 1000) c = a; });
|
||||
return c + 1;
|
||||
}
|
||||
|
||||
|
@ -1,7 +1,5 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.Linq;
|
||||
|
||||
namespace Elwig.Models {
|
||||
[Table("area_commitment"), PrimaryKey("FbNr")]
|
||||
@ -12,8 +10,8 @@ namespace Elwig.Models {
|
||||
[Column("mgnr")]
|
||||
public int MgNr { get; set; }
|
||||
|
||||
[Column("sortid")]
|
||||
public string SortId { get; set; }
|
||||
[Column("vtrgid")]
|
||||
public string VtrgId { get; set; }
|
||||
|
||||
[Column("cultid")]
|
||||
public string CultId { get; set; }
|
||||
@ -42,8 +40,8 @@ namespace Elwig.Models {
|
||||
[ForeignKey("MgNr")]
|
||||
public virtual Member Member { get; private set; }
|
||||
|
||||
[ForeignKey("SortId")]
|
||||
public virtual WineVar WineVar { get; private set; }
|
||||
[ForeignKey("VtrgId")]
|
||||
public virtual AreaComType AreaComType { get; private set; }
|
||||
|
||||
[ForeignKey("CultId")]
|
||||
public virtual WineCult WineCult { get; private set; }
|
||||
@ -53,11 +51,5 @@ namespace Elwig.Models {
|
||||
|
||||
[ForeignKey("KgNr, RdNr")]
|
||||
public virtual WbRd? Rd { get; private set; }
|
||||
|
||||
[InverseProperty("AreaCom")]
|
||||
public virtual ISet<AreaComAttr> AttributeEntries { get; private set; }
|
||||
|
||||
[NotMapped]
|
||||
public IEnumerable<WineAttr> Attributes => AttributeEntries.Select(e => e.WineAttr);
|
||||
}
|
||||
}
|
||||
|
@ -1,19 +0,0 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
|
||||
namespace Elwig.Models {
|
||||
[Table("area_commitment_attribute"), PrimaryKey("FbNr", "AttrId")]
|
||||
public class AreaComAttr {
|
||||
[Column("fbnr")]
|
||||
public int FbNr { get; set; }
|
||||
|
||||
[Column("attrid")]
|
||||
public string AttrId { get; set; }
|
||||
|
||||
[ForeignKey("FbNr")]
|
||||
public virtual AreaCom AreaCom { get; private set; }
|
||||
|
||||
[ForeignKey("AttrId")]
|
||||
public virtual WineAttr WineAttr { get; private set; }
|
||||
}
|
||||
}
|
50
Elwig/Models/AreaComType.cs
Normal file
50
Elwig/Models/AreaComType.cs
Normal file
@ -0,0 +1,50 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
|
||||
namespace Elwig.Models {
|
||||
[Table("area_commitment_type"), PrimaryKey("VtrgId"), Index("SortId", "AttrId1", "AttrId2", "Discriminator")]
|
||||
public class AreaComType {
|
||||
[Column("vtrgid")]
|
||||
public string VtrgId { get; set; }
|
||||
|
||||
[Column("sortid")]
|
||||
public string SortId { get; set; }
|
||||
|
||||
[Column("attrid_1")]
|
||||
public string? AttrId1 { get; set; }
|
||||
|
||||
[Column("attrid_2")]
|
||||
public string? AttrId2 { get; set; }
|
||||
|
||||
[Column("disc")]
|
||||
public string? Discriminator { get; set; }
|
||||
|
||||
[Column("min_kg_per_ha")]
|
||||
public int? MinKgPerHa { get; set; }
|
||||
|
||||
[Column("max_kg_per_ha")]
|
||||
public int? MaxKgPerHa { get; set; }
|
||||
|
||||
[Column("penalty_amount")]
|
||||
public double? PenaltyAmoutValue { get; set; }
|
||||
|
||||
[NotMapped]
|
||||
public decimal? PenaltyAmount {
|
||||
get => PenaltyAmoutValue != null ? (decimal)PenaltyAmoutValue : null;
|
||||
set => PenaltyAmoutValue = value != null ? (double)value : null;
|
||||
}
|
||||
|
||||
[ForeignKey("SortId")]
|
||||
public virtual WineVar WineVar { get; private set; }
|
||||
|
||||
[ForeignKey("AttrId1")]
|
||||
public virtual WineAttr? WineAttr1 { get; private set; }
|
||||
|
||||
[ForeignKey("AttrId2")]
|
||||
public virtual WineAttr? WineAttr2 { get; private set; }
|
||||
|
||||
[NotMapped]
|
||||
public string DisplayName => WineVar.Name + (WineAttr1 != null ? $" {WineAttr1.Name}" : "") +
|
||||
(WineAttr2 != null ? $" {WineAttr2.Name}" : "") + (Discriminator != null ? $" ({Discriminator})" : "");
|
||||
}
|
||||
}
|
@ -110,6 +110,9 @@ namespace Elwig.Models {
|
||||
[Column("active")]
|
||||
public bool IsActive { get; set; }
|
||||
|
||||
[Column("deceased")]
|
||||
public bool IsDeceased { get; set; }
|
||||
|
||||
[Column("iban")]
|
||||
public string? Iban { get; set; }
|
||||
|
||||
|
@ -47,9 +47,8 @@
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="19"/>
|
||||
<RowDefinition Height="110"/>
|
||||
<RowDefinition Height="175"/>
|
||||
<RowDefinition Height="1*"/>
|
||||
<RowDefinition Height="*"/>
|
||||
<RowDefinition Height="*"/>
|
||||
</Grid.RowDefinitions>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*"/>
|
||||
@ -60,7 +59,7 @@
|
||||
<MenuItem Header="Flächenbindugen"/>
|
||||
</Menu>
|
||||
|
||||
<Grid Grid.RowSpan="3" Grid.Row="1" Grid.Column="0">
|
||||
<Grid Grid.RowSpan="2" Grid.Row="1" Grid.Column="0">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="1*"/>
|
||||
<ColumnDefinition Width="1*"/>
|
||||
@ -69,38 +68,44 @@
|
||||
|
||||
<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="0" Grid.Row="1"
|
||||
Margin="5,10,5,47" FontSize="14" Grid.ColumnSpan="3" Background="#e2e2e2">
|
||||
Margin="5,10,5,42" FontSize="14" Grid.ColumnSpan="3" Background="#e2e2e2">
|
||||
<DataGrid.Columns>
|
||||
<DataGridTextColumn Header="FbNr" Binding="{Binding FbNr}" Width="2*"/>
|
||||
<DataGridTextColumn Header="FbNr." Binding="{Binding FbNr}" Width="2*"/>
|
||||
<DataGridTextColumn Header="Katastralgemeinde" Binding="{Binding Kg.AtKg.Name}" Width="6*"/>
|
||||
<DataGridTextColumn Header="Ried" Binding="{Binding Rd.Name}" Width="4*"/>
|
||||
<DataGridTextColumn Header="Parzelle" Binding="{Binding GstNr}" Width="4*"/>
|
||||
<DataGridTextColumn Header="Fläche (m²)" Binding="{Binding Area}" Width="4*"/>
|
||||
<DataGridTextColumn Header="Fläche" Binding="{Binding Area, StringFormat='{}{0:N0} m²'}" Width="4*">
|
||||
<DataGridTextColumn.CellStyle>
|
||||
<Style>
|
||||
<Setter Property="TextBlock.TextAlignment" Value="Right"/>
|
||||
</Style>
|
||||
</DataGridTextColumn.CellStyle>
|
||||
</DataGridTextColumn>
|
||||
</DataGrid.Columns>
|
||||
</DataGrid>
|
||||
|
||||
<Button x:Name="NewAreaCommitmentButton" Content="Neu" Click="NewAreaCommitmentButton_Click"
|
||||
HorizontalAlignment="Stretch" VerticalAlignment="Bottom" Margin="5,10,5,10" Grid.Column="0"/>
|
||||
HorizontalAlignment="Stretch" VerticalAlignment="Bottom" Margin="5,5,2.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"/>
|
||||
HorizontalAlignment="Stretch" VerticalAlignment="Bottom" Margin="2.5,5,2.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"/>
|
||||
HorizontalAlignment="Stretch" VerticalAlignment="Bottom" Margin="2.5,5,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"/>
|
||||
HorizontalAlignment="Stretch" VerticalAlignment="Bottom" Margin="5,5,2.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"/>
|
||||
HorizontalAlignment="Stretch" VerticalAlignment="Bottom" Margin="2.5,5,2.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"/>
|
||||
HorizontalAlignment="Stretch" VerticalAlignment="Bottom" Margin="2.5,5,5,10" Grid.Column="2"/>
|
||||
</Grid>
|
||||
|
||||
<GroupBox Header="Vertrag" Grid.Column="2" Grid.Row="1" Grid.RowSpan="1" Margin="5,5,5,5">
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="60"/>
|
||||
<ColumnDefinition Width="70"/>
|
||||
<ColumnDefinition Width="80"/>
|
||||
<ColumnDefinition Width="*"/>
|
||||
<ColumnDefinition Width="50"/>
|
||||
<ColumnDefinition Width="100"/>
|
||||
<ColumnDefinition Width="*"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<Label Content="FbNr.:" Margin="10,10,0,0" Grid.Column="0"/>
|
||||
@ -108,67 +113,51 @@
|
||||
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"/>
|
||||
<TextBox x:Name="MgNrInput" IsEnabled="False"
|
||||
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"
|
||||
<TextBox x:Name="YearFromInput" Margin="0,10,0,0" Width="41" Grid.Column="3" TextAlignment="Right" HorizontalAlignment="Left"
|
||||
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"
|
||||
<TextBox x:Name="YearToInput" Margin="0,40,0,0" Width="41" Grid.Column="3" TextAlignment="Right" HorizontalAlignment="Left"
|
||||
TextChanged="IntegerInput_TextChanged"/>
|
||||
|
||||
<Label Content="Vertragsart:" Margin="10,70,0,0" Grid.Column="0" Grid.ColumnSpan="2"/>
|
||||
<ComboBox x:Name="AreaComTypeInput" DisplayMemberPath="DisplayName" TextSearch.TextPath="DisplayName"
|
||||
HorizontalAlignment="Stretch" Margin="0,70,10,0" Grid.Column="1" Grid.ColumnSpan="3"/>
|
||||
|
||||
<Label Content="Bewirt.-Art:" Margin="10,100,0,0" Grid.Column="0" Grid.ColumnSpan="2"/>
|
||||
<ComboBox x:Name="WineCultivationInput" DisplayMemberPath="Name" TextSearch.TextPath="Name"
|
||||
HorizontalAlignment="Stretch" Margin="0,100,10,0" Grid.Column="1" Grid.ColumnSpan="3"/>
|
||||
</Grid>
|
||||
</GroupBox>
|
||||
|
||||
<GroupBox Header="Lage" Grid.Column="2" 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,10">
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="80"/>
|
||||
<ColumnDefinition Width="*"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<Label Content="Gemeinde:" Margin="10,10,0,0" Grid.Column="0"/>
|
||||
<Label Content="KG:" Margin="10,10,0,0" Grid.Column="0"/>
|
||||
<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"/>
|
||||
HorizontalAlignment="Stretch" Margin="0,10,10,0" Grid.Column="1"
|
||||
SelectionChanged="KgInput_SelectionChanged"/>
|
||||
|
||||
<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"/>
|
||||
HorizontalAlignment="Stretch" Margin="0,40,10,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="200" Grid.Column="1" TextAlignment="Right" HorizontalAlignment="Left"
|
||||
<Label Content="Parzelle(n):" Margin="10,70,0,0" Grid.Column="0"/>
|
||||
<TextBox x:Name="GstNrInput" Margin="0,70,10,0" Grid.Column="1" HorizontalAlignment="Stretch"
|
||||
TextChanged="GstNrInput_TextChanged" LostFocus="GstNrInput_LostFocus"/>
|
||||
|
||||
<Label Content="Fläche (m²):" Margin="10,100,0,0" Grid.Column="0"/>
|
||||
<Label Content="Fläche:" 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="IntegerInput_TextChanged"/>
|
||||
</Grid>
|
||||
|
||||
</GroupBox>
|
||||
|
||||
<GroupBox Header="Eigenschaften" Grid.Column="2" Grid.Row="3" Grid.RowSpan="1" Margin="5,5,5,5">
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="80"/>
|
||||
<ColumnDefinition Width="*"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<Label Content="Sorte:" Margin="10,10,0,0" Grid.Column="0"/>
|
||||
<ComboBox x:Name="WineVarietyInput" ItemTemplate="{StaticResource WineVarietyTemplate}" TextSearch.TextPath="Name"
|
||||
Width="200" HorizontalAlignment="Left"
|
||||
Margin="0,10,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="WineCultivationInput" DisplayMemberPath="Name" TextSearch.TextPath="Name"
|
||||
Width="200" HorizontalAlignment="Left" Margin="0,70,10,0" Grid.Column="1"/>
|
||||
</Grid>
|
||||
</GroupBox>
|
||||
</Grid>
|
||||
</local:AdministrationWindow>
|
||||
|
@ -25,12 +25,12 @@ namespace Elwig.Windows {
|
||||
};
|
||||
RequiredInputs = new Control[] {
|
||||
FbNrInput, YearFromInput, KgInput,
|
||||
GstNrInput, AreaInput, WineVarietyInput, WineCultivationInput
|
||||
GstNrInput, AreaInput, AreaComTypeInput, WineCultivationInput
|
||||
};
|
||||
}
|
||||
|
||||
private async void Window_Loaded(object sender, RoutedEventArgs e) {
|
||||
await RenewContext();
|
||||
private void Window_Loaded(object sender, RoutedEventArgs e) {
|
||||
LockInputs();
|
||||
}
|
||||
|
||||
private async Task RefreshAreaCommitmentList() {
|
||||
@ -50,9 +50,7 @@ namespace Elwig.Windows {
|
||||
|
||||
private void RefreshInputs(bool validate = false) {
|
||||
ClearInputStates();
|
||||
AreaCom? a = (AreaCom)AreaCommitmentList.SelectedItem;
|
||||
|
||||
if (a != null) {
|
||||
if (AreaCommitmentList.SelectedItem is AreaCom a) {
|
||||
EditAreaCommitmentButton.IsEnabled = true;
|
||||
DeleteAreaCommitmentButton.IsEnabled = true;
|
||||
FillInputs(a);
|
||||
@ -60,11 +58,9 @@ namespace Elwig.Windows {
|
||||
EditAreaCommitmentButton.IsEnabled = false;
|
||||
DeleteAreaCommitmentButton.IsEnabled = false;
|
||||
ClearOriginalValues();
|
||||
ClearInputs();
|
||||
AttributesInput.UnSelectAll();
|
||||
MgNrInput.Text = "";
|
||||
ClearInputs(validate);
|
||||
ClearInputStates();
|
||||
}
|
||||
if (!validate) ClearInputStates();
|
||||
GC.Collect();
|
||||
}
|
||||
|
||||
@ -81,13 +77,7 @@ namespace Elwig.Windows {
|
||||
GstNrInput.Text = a.GstNr;
|
||||
AreaInput.Text = a.Area.ToString();
|
||||
|
||||
WineVarietyInput.SelectedItem = a.WineVar;
|
||||
|
||||
AttributesInput.UnSelectAll();
|
||||
foreach (var attr in a.Attributes) {
|
||||
AttributesInput.SelectedItems.Add(attr);
|
||||
}
|
||||
|
||||
AreaComTypeInput.SelectedItem = a.AreaComType;
|
||||
WineCultivationInput.SelectedItem = a.WineCult;
|
||||
|
||||
FillOriginalValues();
|
||||
@ -103,8 +93,7 @@ namespace Elwig.Windows {
|
||||
protected override async Task RenewContext() {
|
||||
await base.RenewContext();
|
||||
ControlUtils.RenewItemsSource(KgInput, await Context.WbKgs.Select(k => k.AtKg).OrderBy(k => k.Name).ToListAsync(), i => (i as AT_Kg)?.KgNr);
|
||||
ControlUtils.RenewItemsSource(WineVarietyInput, await Context.WineVarieties.OrderBy(v => v.Name).ToListAsync(), i => (i as WineVar)?.SortId);
|
||||
ControlUtils.RenewItemsSource(AttributesInput, await Context.WineAttributes.OrderBy(a => a.Name).ToListAsync(), i => (i as WineAttr)?.AttrId);
|
||||
ControlUtils.RenewItemsSource(AreaComTypeInput, await Context.AreaCommitmentTypes.OrderBy(v => v.VtrgId).ToListAsync(), i => (i as AreaComType)?.VtrgId);
|
||||
ControlUtils.RenewItemsSource(WineCultivationInput, await Context.WineCultivations.OrderBy(c => c.Name).ToListAsync(), i => (i as WineCult)?.CultId);
|
||||
await RefreshAreaCommitmentList();
|
||||
}
|
||||
@ -116,7 +105,6 @@ namespace Elwig.Windows {
|
||||
HideAreaCommitmentNewEditDeleteButtons();
|
||||
ShowAreaCommitmentSaveResetCancelButtons();
|
||||
UnlockInputs();
|
||||
AttributesInput.IsEnabled = true;
|
||||
InitInputs();
|
||||
}
|
||||
|
||||
@ -130,7 +118,6 @@ namespace Elwig.Windows {
|
||||
HideAreaCommitmentNewEditDeleteButtons();
|
||||
ShowAreaCommitmentSaveResetCancelButtons();
|
||||
UnlockInputs();
|
||||
AttributesInput.IsEnabled = true;
|
||||
}
|
||||
|
||||
private async void DeleteAreaCommitmentButton_Click(object sender, RoutedEventArgs evt) {
|
||||
@ -139,7 +126,7 @@ namespace Elwig.Windows {
|
||||
|
||||
var r = MessageBox.Show(
|
||||
$"Soll die Flächenbindung {a.GstNr} ({a.Area} m²) wirklich unwiderruflich gelöscht werden?",
|
||||
"Parzelle löschen", MessageBoxButton.YesNo, MessageBoxImage.Warning, MessageBoxResult.No);
|
||||
"Flächenbindung löschen", MessageBoxButton.YesNo, MessageBoxImage.Warning, MessageBoxResult.No);
|
||||
if (r == MessageBoxResult.Yes) {
|
||||
Context.Remove(a);
|
||||
Context.SaveChanges();
|
||||
@ -156,8 +143,8 @@ namespace Elwig.Windows {
|
||||
a.RdNr = RdInput.SelectedItem.GetType() == typeof(NullItem) ? null : ((WbRd)RdInput.SelectedItem).RdNr;
|
||||
a.GstNr = GstNrInput.Text;
|
||||
a.Area = int.Parse(AreaInput.Text);
|
||||
a.SortId = ((WineVar)WineVarietyInput.SelectedItem).SortId;
|
||||
a.CultId = ((WineCult)WineCultivationInput.SelectedItem).CultId;
|
||||
a.VtrgId = (AreaComTypeInput.SelectedItem as AreaComType)?.VtrgId;
|
||||
a.CultId = (WineCultivationInput.SelectedItem as WineCult)?.CultId;
|
||||
|
||||
EntityEntry<AreaCom>? tr = null;
|
||||
try {
|
||||
@ -168,23 +155,6 @@ namespace Elwig.Windows {
|
||||
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) {
|
||||
@ -211,7 +181,6 @@ namespace Elwig.Windows {
|
||||
HideAreaCommitmentSaveResetCancelButtons();
|
||||
ShowAreaCommitmentNewEditDeleteButtons();
|
||||
LockInputs();
|
||||
AttributesInput.IsEnabled = false;
|
||||
await RefreshAreaCommitmentList();
|
||||
AreaCommitmentList.SelectedItem = a;
|
||||
}
|
||||
@ -234,7 +203,6 @@ namespace Elwig.Windows {
|
||||
RefreshInputs();
|
||||
ClearInputStates();
|
||||
LockInputs();
|
||||
AttributesInput.IsEnabled = false;
|
||||
}
|
||||
|
||||
override protected void UpdateButtons() {
|
||||
@ -297,11 +265,13 @@ namespace Elwig.Windows {
|
||||
}
|
||||
|
||||
private async void KgInput_SelectionChanged(object sender, SelectionChangedEventArgs evt) {
|
||||
AT_Kg? curr_kg = (AT_Kg)KgInput.SelectedItem;
|
||||
if (curr_kg != null) {
|
||||
if (KgInput.SelectedItem is AT_Kg curr_kg) {
|
||||
var rdList = await Context.WbRde.Where(r => r.KgNr == curr_kg.KgNr).OrderBy(r => r.Name).Cast<object>().ToListAsync();
|
||||
rdList.Insert(0, new NullItem());
|
||||
ControlUtils.RenewItemsSource(RdInput, rdList, i => (i as WbRd)?.RdNr);
|
||||
} else {
|
||||
var rdList = new object[] { new NullItem() };
|
||||
ControlUtils.RenewItemsSource(RdInput, rdList, i => (i as WbRd)?.RdNr);
|
||||
}
|
||||
ComboBox_SelectionChanged(sender, evt);
|
||||
}
|
||||
|
Reference in New Issue
Block a user