Update model database schema
This commit is contained in:
@ -7,8 +7,9 @@ namespace Elwig.Helpers {
|
|||||||
public class AppDbContext : DbContext {
|
public class AppDbContext : DbContext {
|
||||||
|
|
||||||
public DbSet<Country> Countries { get; set; }
|
public DbSet<Country> Countries { get; set; }
|
||||||
|
public DbSet<Currency> Currencies { get; set; }
|
||||||
public DbSet<Member> Members { get; set; }
|
public DbSet<Member> Members { get; set; }
|
||||||
public DbSet<BillingAddress> BillingAddresses { get; set; }
|
public DbSet<BillingAddr> BillingAddresses { get; set; }
|
||||||
public DbSet<AT_Gem> Gemeinden { get; set; }
|
public DbSet<AT_Gem> Gemeinden { get; set; }
|
||||||
public DbSet<AT_Kg> Katastralgemeinden { get; set; }
|
public DbSet<AT_Kg> Katastralgemeinden { get; set; }
|
||||||
public DbSet<AT_Ort> Orte { get; set; }
|
public DbSet<AT_Ort> Orte { get; set; }
|
||||||
@ -17,12 +18,15 @@ namespace Elwig.Helpers {
|
|||||||
public DbSet<Branch> Branches { get; set; }
|
public DbSet<Branch> Branches { get; set; }
|
||||||
public DbSet<WbKg> WbKgs { get; set; }
|
public DbSet<WbKg> WbKgs { get; set; }
|
||||||
public DbSet<WbRd> WbRde { get; set; }
|
public DbSet<WbRd> WbRde { get; set; }
|
||||||
public DbSet<AreaCommitment> AreaCommitments { get; set; }
|
public DbSet<AreaCom> AreaCommitments { get; set; }
|
||||||
|
public DbSet<AreaComParcel> AreaCommitmentParcels { get; set; }
|
||||||
|
public DbSet<AreaComAttr> AreaCommitmentAttributes { get; set; }
|
||||||
public DbSet<Contract> Contracts { get; set; }
|
public DbSet<Contract> Contracts { get; set; }
|
||||||
public DbSet<WineAttr> WineAttributes { get; set; }
|
public DbSet<WineAttr> WineAttributes { get; set; }
|
||||||
public DbSet<WineCult> WineCultivations { get; set; }
|
public DbSet<WineCult> WineCultivations { get; set; }
|
||||||
public DbSet<WineQual> WineQualities { get; set; }
|
public DbSet<WineQual> WineQualities { get; set; }
|
||||||
public DbSet<WineVar> WineVarieties { get; set; }
|
public DbSet<WineVar> WineVarieties { get; set; }
|
||||||
|
public DbSet<Season> Seasons { get; set; }
|
||||||
|
|
||||||
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) {
|
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) {
|
||||||
optionsBuilder.UseSqlite($"Data Source=\"{App.Config.DatabaseFile}\"; Foreign Keys=True; Mode=ReadWrite; Cache=Default");
|
optionsBuilder.UseSqlite($"Data Source=\"{App.Config.DatabaseFile}\"; Foreign Keys=True; Mode=ReadWrite; Cache=Default");
|
||||||
|
@ -86,5 +86,13 @@ namespace Elwig.Helpers {
|
|||||||
UseShellExecute = true,
|
UseShellExecute = true,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static double KmwToOe(double kmw) {
|
||||||
|
return Math.Round(kmw * (4.54 + 0.022 * kmw), 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static double OeToKmw(double oe) {
|
||||||
|
return Math.Round((-4.54 + Math.Sqrt(4.54 * 4.54 - 4 * 0.022 * -oe)) / 2 * 0.022, 1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,49 +1,39 @@
|
|||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using System.Collections.Generic;
|
||||||
using System.ComponentModel.DataAnnotations.Schema;
|
using System.ComponentModel.DataAnnotations.Schema;
|
||||||
|
using System.Linq;
|
||||||
|
|
||||||
namespace Elwig.Models {
|
namespace Elwig.Models {
|
||||||
[Table("area_commitment"), PrimaryKey("VNr", "KgNr", "GstNr")]
|
[Table("area_commitment"), PrimaryKey("VNr")]
|
||||||
public class AreaCommitment {
|
public class AreaCom {
|
||||||
[Column("vnr")]
|
[Column("vnr")]
|
||||||
public int VNr { get; set; }
|
public int VNr { get; set; }
|
||||||
|
|
||||||
[Column("kgnr")]
|
|
||||||
public int KgNr { get; set; }
|
|
||||||
|
|
||||||
[Column("gstnr")]
|
|
||||||
public string? GstNr { get; set; }
|
|
||||||
|
|
||||||
[Column("rdnr")]
|
|
||||||
public int? RdNr { get; set; }
|
|
||||||
|
|
||||||
[Column("area")]
|
[Column("area")]
|
||||||
public int Area { get; set; }
|
public int Area { get; set; }
|
||||||
|
|
||||||
[Column("sortid")]
|
[Column("sortid")]
|
||||||
public string SortId { get; set; }
|
public string SortId { get; set; }
|
||||||
|
|
||||||
[Column("attrid")]
|
|
||||||
public string? AttrId { get; set; }
|
|
||||||
|
|
||||||
[Column("cultid")]
|
[Column("cultid")]
|
||||||
public string CultId { get; set; }
|
public string CultId { get; set; }
|
||||||
|
|
||||||
[ForeignKey("KgNr")]
|
|
||||||
public virtual WbKg Kg { get; private set; }
|
|
||||||
|
|
||||||
[ForeignKey("KgNr, RdNr")]
|
|
||||||
public virtual WbRd? Rd { get; private set; }
|
|
||||||
|
|
||||||
[ForeignKey("VNr")]
|
[ForeignKey("VNr")]
|
||||||
public virtual Contract Contract { get; private set; }
|
public virtual Contract Contract { get; private set; }
|
||||||
|
|
||||||
[ForeignKey("SortId")]
|
[ForeignKey("SortId")]
|
||||||
public virtual WineVar WineVar { get; private set; }
|
public virtual WineVar WineVar { get; private set; }
|
||||||
|
|
||||||
[ForeignKey("AttrId")]
|
|
||||||
public virtual WineAttr WineAttr { get; private set; }
|
|
||||||
|
|
||||||
[ForeignKey("CultId")]
|
[ForeignKey("CultId")]
|
||||||
public virtual WineCult WineCult { get; private set; }
|
public virtual WineCult WineCult { get; private set; }
|
||||||
|
|
||||||
|
[InverseProperty("AreaCom")]
|
||||||
|
public virtual ISet<AreaComParcel> Parcels { get; private set; }
|
||||||
|
|
||||||
|
[InverseProperty("AreaCom")]
|
||||||
|
public virtual ISet<AreaComAttr> AttributeEntries { get; private set; }
|
||||||
|
|
||||||
|
[NotMapped]
|
||||||
|
public IEnumerable<WineAttr> Attributes => AttributeEntries.Select(e => e.WineAttr);
|
||||||
}
|
}
|
||||||
}
|
}
|
19
Elwig/Models/AreaComAttr.cs
Normal file
19
Elwig/Models/AreaComAttr.cs
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using System.ComponentModel.DataAnnotations.Schema;
|
||||||
|
|
||||||
|
namespace Elwig.Models {
|
||||||
|
[Table("area_commitment_attribute"), PrimaryKey("VNr", "AttrId")]
|
||||||
|
public class AreaComAttr {
|
||||||
|
[Column("vnr")]
|
||||||
|
public int VNr { get; set; }
|
||||||
|
|
||||||
|
[Column("attrid")]
|
||||||
|
public string AttrId { get; set; }
|
||||||
|
|
||||||
|
[ForeignKey("VNr")]
|
||||||
|
public virtual AreaCom AreaCom { get; private set; }
|
||||||
|
|
||||||
|
[ForeignKey("AttrId")]
|
||||||
|
public virtual WineAttr WineAttr { get; private set; }
|
||||||
|
}
|
||||||
|
}
|
31
Elwig/Models/AreaComParcel.cs
Normal file
31
Elwig/Models/AreaComParcel.cs
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using System.ComponentModel.DataAnnotations.Schema;
|
||||||
|
|
||||||
|
namespace Elwig.Models {
|
||||||
|
[Table("area_commitment_parcel"), PrimaryKey("VNr", "KgNr", "GstNr")]
|
||||||
|
public class AreaComParcel {
|
||||||
|
[Column("vnr")]
|
||||||
|
public int VNr { get; set; }
|
||||||
|
|
||||||
|
[Column("kgnr")]
|
||||||
|
public int KgNr { get; set; }
|
||||||
|
|
||||||
|
[Column("gstnr")]
|
||||||
|
public string? GstNr { get; set; }
|
||||||
|
|
||||||
|
[Column("rdnr")]
|
||||||
|
public int? RdNr { get; set; }
|
||||||
|
|
||||||
|
[Column("area")]
|
||||||
|
public int? Area { get; set; }
|
||||||
|
|
||||||
|
[ForeignKey("KgNr")]
|
||||||
|
public virtual WbKg Kg { get; private set; }
|
||||||
|
|
||||||
|
[ForeignKey("KgNr, RdNr")]
|
||||||
|
public virtual WbRd? Rd { get; private set; }
|
||||||
|
|
||||||
|
[ForeignKey("VNr")]
|
||||||
|
public virtual AreaCom AreaCom { get; private set; }
|
||||||
|
}
|
||||||
|
}
|
@ -3,7 +3,7 @@ using System.ComponentModel.DataAnnotations.Schema;
|
|||||||
|
|
||||||
namespace Elwig.Models {
|
namespace Elwig.Models {
|
||||||
[Table("member_billing_address"), PrimaryKey("MgNr")]
|
[Table("member_billing_address"), PrimaryKey("MgNr")]
|
||||||
public class BillingAddress {
|
public class BillingAddr {
|
||||||
[Column("mgnr")]
|
[Column("mgnr")]
|
||||||
public int MgNr { get; set; }
|
public int MgNr { get; set; }
|
||||||
|
|
@ -1,7 +1,6 @@
|
|||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using System.Collections.Generic;
|
using System;
|
||||||
using System.ComponentModel.DataAnnotations.Schema;
|
using System.ComponentModel.DataAnnotations.Schema;
|
||||||
using System.Linq;
|
|
||||||
|
|
||||||
namespace Elwig.Models {
|
namespace Elwig.Models {
|
||||||
[Table("contract"), PrimaryKey("VNr")]
|
[Table("contract"), PrimaryKey("VNr")]
|
||||||
@ -12,19 +11,35 @@ namespace Elwig.Models {
|
|||||||
[Column("mgnr")]
|
[Column("mgnr")]
|
||||||
public int MgNr { get; set; }
|
public int MgNr { get; set; }
|
||||||
|
|
||||||
|
[Column("date")]
|
||||||
|
public string? DateString { get; set; }
|
||||||
|
|
||||||
|
[NotMapped]
|
||||||
|
public DateOnly? Date {
|
||||||
|
get {
|
||||||
|
return DateString != null ? DateOnly.ParseExact(DateString, "yyyy-MM-dd") : null;
|
||||||
|
}
|
||||||
|
set {
|
||||||
|
DateString = value?.ToString("yyyy-MM-dd");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
[Column("year_from")]
|
[Column("year_from")]
|
||||||
public int YearFrom { get; set; }
|
public int YearFrom { get; set; }
|
||||||
|
|
||||||
[Column("year_to")]
|
[Column("year_to")]
|
||||||
public int? YearTo { get; set; }
|
public int? YearTo { get; set; }
|
||||||
|
|
||||||
|
[Column("comment")]
|
||||||
|
public string? Comment { get; set; }
|
||||||
|
|
||||||
[ForeignKey("MgNr")]
|
[ForeignKey("MgNr")]
|
||||||
public virtual Member Member { get; private set; }
|
public virtual Member Member { get; private set; }
|
||||||
|
|
||||||
[InverseProperty("Contract")]
|
[InverseProperty("Contract")]
|
||||||
public virtual ISet<AreaCommitment> AreaCommitments { get; private set; }
|
public virtual AreaCom? AreaCom { get; private set; }
|
||||||
|
|
||||||
[NotMapped]
|
[NotMapped]
|
||||||
public int Area => AreaCommitments.Select(a => a.Area).Sum();
|
public int? Area => AreaCom?.Area;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
22
Elwig/Models/Currency.cs
Normal file
22
Elwig/Models/Currency.cs
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using System.ComponentModel.DataAnnotations.Schema;
|
||||||
|
|
||||||
|
namespace Elwig.Models {
|
||||||
|
[Table("currency"), PrimaryKey("Code")]
|
||||||
|
public class Currency {
|
||||||
|
[Column("code")]
|
||||||
|
public string Code { get; private set; }
|
||||||
|
|
||||||
|
[Column("name")]
|
||||||
|
public string Name { get; private set; }
|
||||||
|
|
||||||
|
[Column("symbol")]
|
||||||
|
public string? Symbol { get; private set; }
|
||||||
|
|
||||||
|
[Column("one_euro")]
|
||||||
|
public int? OneEuroValue { get; private set; }
|
||||||
|
|
||||||
|
[NotMapped]
|
||||||
|
public decimal? OneEuro => OneEuroValue / 1_000_000;
|
||||||
|
}
|
||||||
|
}
|
@ -38,10 +38,30 @@ namespace Elwig.Models {
|
|||||||
public string? Birthday { get; set; }
|
public string? Birthday { get; set; }
|
||||||
|
|
||||||
[Column("entry_date")]
|
[Column("entry_date")]
|
||||||
public string? EntryDate { get; set; }
|
public string? EntryDateString { get; set; }
|
||||||
|
|
||||||
|
[NotMapped]
|
||||||
|
public DateOnly? EntryDate {
|
||||||
|
get {
|
||||||
|
return EntryDateString != null ? DateOnly.ParseExact(EntryDateString, "yyyy-MM-dd") : null;
|
||||||
|
}
|
||||||
|
set {
|
||||||
|
EntryDateString = value?.ToString("yyyy-MM-dd");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
[Column("exit_date")]
|
[Column("exit_date")]
|
||||||
public string? ExitDate { get; set; }
|
public string? ExitDateString { get; set; }
|
||||||
|
|
||||||
|
[NotMapped]
|
||||||
|
public DateOnly? ExitDate {
|
||||||
|
get {
|
||||||
|
return ExitDateString != null ? DateOnly.ParseExact(ExitDateString, "yyyy-MM-dd") : null;
|
||||||
|
}
|
||||||
|
set {
|
||||||
|
ExitDateString = value?.ToString("yyyy-MM-dd");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
[Column("business_shares")]
|
[Column("business_shares")]
|
||||||
public int BusinessShares { get; set; }
|
public int BusinessShares { get; set; }
|
||||||
@ -125,7 +145,7 @@ namespace Elwig.Models {
|
|||||||
public virtual ISet<Contract> Contracts { get; private set; }
|
public virtual ISet<Contract> Contracts { get; private set; }
|
||||||
|
|
||||||
[InverseProperty("Member")]
|
[InverseProperty("Member")]
|
||||||
public virtual BillingAddress BillingAddress { get; private set; }
|
public virtual BillingAddr BillingAddress { get; private set; }
|
||||||
|
|
||||||
public int SearchScore(IEnumerable<string> keywords) {
|
public int SearchScore(IEnumerable<string> keywords) {
|
||||||
keywords = keywords.Where(s => s.Length >= 2 || (s.Length > 0 && s.All(c => char.IsDigit(c))));
|
keywords = keywords.Where(s => s.Length >= 2 || (s.Length > 0 && s.All(c => char.IsDigit(c))));
|
||||||
|
46
Elwig/Models/Season.cs
Normal file
46
Elwig/Models/Season.cs
Normal file
@ -0,0 +1,46 @@
|
|||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using System;
|
||||||
|
using System.ComponentModel.DataAnnotations.Schema;
|
||||||
|
|
||||||
|
namespace Elwig.Models {
|
||||||
|
[Table("season"), PrimaryKey("Year")]
|
||||||
|
public class Season {
|
||||||
|
[Column("year")]
|
||||||
|
public int Year { get; set; }
|
||||||
|
|
||||||
|
[Column("currency")]
|
||||||
|
public string CurrencyCode { get; set; }
|
||||||
|
|
||||||
|
[Column("precision")]
|
||||||
|
public int Precision { get; set; }
|
||||||
|
|
||||||
|
[Column("start_date")]
|
||||||
|
public string? StartDateString { get; set; }
|
||||||
|
|
||||||
|
[NotMapped]
|
||||||
|
public DateOnly? StartDate {
|
||||||
|
get {
|
||||||
|
return StartDateString != null ? DateOnly.ParseExact(StartDateString, "yyyy-MM-dd") : null;
|
||||||
|
}
|
||||||
|
set {
|
||||||
|
StartDateString = value?.ToString("yyyy-MM-dd");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[Column("end_date")]
|
||||||
|
public string? EndDateString { get; set; }
|
||||||
|
|
||||||
|
[NotMapped]
|
||||||
|
public DateOnly? EndDate {
|
||||||
|
get {
|
||||||
|
return EndDateString != null ? DateOnly.ParseExact(EndDateString, "yyyy-MM-dd") : null;
|
||||||
|
}
|
||||||
|
set {
|
||||||
|
EndDateString = value?.ToString("yyyy-MM-dd");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[ForeignKey("CurrencyCode")]
|
||||||
|
public virtual Currency Currency { get; private set; }
|
||||||
|
}
|
||||||
|
}
|
@ -1,4 +1,5 @@
|
|||||||
using Microsoft.EntityFrameworkCore;
|
using Elwig.Helpers;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
using System.ComponentModel.DataAnnotations.Schema;
|
using System.ComponentModel.DataAnnotations.Schema;
|
||||||
|
|
||||||
namespace Elwig.Models {
|
namespace Elwig.Models {
|
||||||
@ -10,13 +11,16 @@ namespace Elwig.Models {
|
|||||||
[Column("origin_level")]
|
[Column("origin_level")]
|
||||||
public int? OriginLevel { get; private set; }
|
public int? OriginLevel { get; private set; }
|
||||||
|
|
||||||
|
[Column("predicate")]
|
||||||
|
public bool IsPredicate { get; private set; }
|
||||||
|
|
||||||
|
[Column("min_kmw")]
|
||||||
|
public double? MinKmw { get; private set; }
|
||||||
|
|
||||||
|
[NotMapped]
|
||||||
|
public double? MinOe => MinKmw != null ? Utils.KmwToOe((double)MinKmw) : null;
|
||||||
|
|
||||||
[Column("name")]
|
[Column("name")]
|
||||||
public string Name { get; private set; }
|
public string Name { get; private set; }
|
||||||
|
|
||||||
[Column("from_kmw")]
|
|
||||||
public double? FromKmw { get; private set; }
|
|
||||||
|
|
||||||
[Column("to_kmw")]
|
|
||||||
public double? ToKmw { get; private set; }
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
<local:AdministrationWindow x:Class="Elwig.Windows.AreaCommAdminWindow"
|
<local:AdministrationWindow x:Class="Elwig.Windows.AreaComAdminWindow"
|
||||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
@ -5,18 +5,17 @@ using System.Windows;
|
|||||||
using System.Windows.Controls;
|
using System.Windows.Controls;
|
||||||
using Elwig.Helpers;
|
using Elwig.Helpers;
|
||||||
using Elwig.Models;
|
using Elwig.Models;
|
||||||
using System.Runtime.CompilerServices;
|
|
||||||
using System;
|
using System;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Microsoft.EntityFrameworkCore.ChangeTracking;
|
using Microsoft.EntityFrameworkCore.ChangeTracking;
|
||||||
|
|
||||||
namespace Elwig.Windows {
|
namespace Elwig.Windows {
|
||||||
public partial class AreaCommAdminWindow : AdministrationWindow {
|
public partial class AreaComAdminWindow : AdministrationWindow {
|
||||||
private readonly Member member;
|
private readonly Member member;
|
||||||
private bool IsEditing = false;
|
private bool IsEditing = false;
|
||||||
private bool IsCreating = false;
|
private bool IsCreating = false;
|
||||||
|
|
||||||
public AreaCommAdminWindow(Member member) {
|
public AreaComAdminWindow(Member member) {
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
this.member = member;
|
this.member = member;
|
||||||
Title = $"Flächenbindungen - {member.FamilyName} {member.GivenName} - Elwig";
|
Title = $"Flächenbindungen - {member.FamilyName} {member.GivenName} - Elwig";
|
||||||
@ -57,7 +56,7 @@ namespace Elwig.Windows {
|
|||||||
if (contracts.Count == 1)
|
if (contracts.Count == 1)
|
||||||
ContractList.SelectedIndex = 0;
|
ContractList.SelectedIndex = 0;
|
||||||
|
|
||||||
//TODO notwendig?
|
// TODO notwendig?
|
||||||
await RefreshAreaCommitmentList();
|
await RefreshAreaCommitmentList();
|
||||||
RefreshInputs();
|
RefreshInputs();
|
||||||
}
|
}
|
||||||
@ -70,10 +69,10 @@ namespace Elwig.Windows {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
List<AreaCommitment> commitments = await Context.AreaCommitments.Where(a => a.VNr == contract.VNr).ToListAsync();
|
List<AreaComParcel> parcels = (await Context.AreaCommitments.FindAsync(contract.VNr)).Parcels.ToList();
|
||||||
|
|
||||||
AreaCommitmentList.ItemsSource = commitments;
|
AreaCommitmentList.ItemsSource = parcels;
|
||||||
if (commitments.Count == 1)
|
if (parcels.Count == 1)
|
||||||
AreaCommitmentList.SelectedIndex = 0;
|
AreaCommitmentList.SelectedIndex = 0;
|
||||||
RefreshInputs();
|
RefreshInputs();
|
||||||
}
|
}
|
||||||
@ -81,7 +80,7 @@ namespace Elwig.Windows {
|
|||||||
private void RefreshInputs(bool validate = false) {
|
private void RefreshInputs(bool validate = false) {
|
||||||
ClearInputStates();
|
ClearInputStates();
|
||||||
Contract? c = (Contract)ContractList.SelectedItem;
|
Contract? c = (Contract)ContractList.SelectedItem;
|
||||||
AreaCommitment? a = (AreaCommitment)AreaCommitmentList.SelectedItem;
|
AreaComParcel? a = (AreaComParcel)AreaCommitmentList.SelectedItem;
|
||||||
|
|
||||||
if (c != null) {
|
if (c != null) {
|
||||||
DeleteContractButton.IsEnabled = true;
|
DeleteContractButton.IsEnabled = true;
|
||||||
@ -105,22 +104,23 @@ namespace Elwig.Windows {
|
|||||||
GC.Collect();
|
GC.Collect();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void FillInputs(AreaCommitment a) {
|
private void FillInputs(AreaComParcel a) {
|
||||||
ClearOriginalValues();
|
ClearOriginalValues();
|
||||||
|
|
||||||
VNrInput.Text = a.VNr.ToString();
|
VNrInput.Text = a.VNr.ToString();
|
||||||
MgNrInput.Text = a.Contract.MgNr.ToString();
|
MgNrInput.Text = a.AreaCom.Contract.MgNr.ToString();
|
||||||
YearFromInput.Text = a.Contract.YearFrom.ToString();
|
YearFromInput.Text = a.AreaCom.Contract.YearFrom.ToString();
|
||||||
YearToInput.Text = a.Contract.YearTo.ToString();
|
YearToInput.Text = a.AreaCom.Contract.YearTo.ToString();
|
||||||
|
|
||||||
KgInput.SelectedItem = a.Kg.Kg;
|
KgInput.SelectedItem = a.Kg.Kg;
|
||||||
RdInput.SelectedItem = a.Rd;
|
RdInput.SelectedItem = a.Rd;
|
||||||
GstNrInput.Text = a.GstNr;
|
GstNrInput.Text = a.GstNr;
|
||||||
AreaInput.Text = a.Area.ToString();
|
AreaInput.Text = a.Area.ToString();
|
||||||
|
|
||||||
SortInput.SelectedItem = a.WineVar;
|
SortInput.SelectedItem = a.AreaCom.WineVar;
|
||||||
AttrInput.SelectedItem = a.WineAttr;
|
// FIXME
|
||||||
CultInput.SelectedItem = a.WineCult;
|
//AttrInput.SelectedItem = a.WineAttr;
|
||||||
|
CultInput.SelectedItem = a.AreaCom.WineCult;
|
||||||
|
|
||||||
FillOriginalValues();
|
FillOriginalValues();
|
||||||
}
|
}
|
||||||
@ -155,12 +155,12 @@ namespace Elwig.Windows {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private async void DeleteAreaCommitmentButton_Click(object sender, RoutedEventArgs evt) {
|
private async void DeleteAreaCommitmentButton_Click(object sender, RoutedEventArgs evt) {
|
||||||
AreaCommitment a = (AreaCommitment)AreaCommitmentList.SelectedItem;
|
AreaComParcel a = (AreaComParcel)AreaCommitmentList.SelectedItem;
|
||||||
if (a == null) return;
|
if (a == null) return;
|
||||||
|
|
||||||
var r = MessageBox.Show(
|
var r = MessageBox.Show(
|
||||||
$"Soll die Flächenbindung {a.Kg.Kg.Name}{(a.Rd.Name == null ? "" : $", {a.Rd.Name}")}, {a.GstNr} wirklich unwiderruflich gelöscht werden?",
|
$"Soll die Parzelle {a.GstNr} ({a.Area} m²) wirklich unwiderruflich gelöscht werden?",
|
||||||
"Flächenbindung löschen", MessageBoxButton.YesNo, MessageBoxImage.Warning, MessageBoxResult.No);
|
"Parzelle löschen", MessageBoxButton.YesNo, MessageBoxImage.Warning, MessageBoxResult.No);
|
||||||
if (r == MessageBoxResult.Yes) {
|
if (r == MessageBoxResult.Yes) {
|
||||||
Context.Remove(a);
|
Context.Remove(a);
|
||||||
Context.SaveChanges();
|
Context.SaveChanges();
|
||||||
@ -186,7 +186,7 @@ namespace Elwig.Windows {
|
|||||||
if (c == null) return;
|
if (c == null) return;
|
||||||
|
|
||||||
var r = MessageBox.Show(
|
var r = MessageBox.Show(
|
||||||
$"Soll der Vertrag \"{c.VNr} und alle enthaltenen Flächenbindungen wirklich unwiderruflich gelöscht werden?",
|
$"Soll der Vertrag {c.VNr} und alle enthaltenen Parzellen wirklich unwiderruflich gelöscht werden?",
|
||||||
"Vertrag löschen", MessageBoxButton.YesNo, MessageBoxImage.Warning, MessageBoxResult.No);
|
"Vertrag löschen", MessageBoxButton.YesNo, MessageBoxImage.Warning, MessageBoxResult.No);
|
||||||
if (r == MessageBoxResult.Yes) {
|
if (r == MessageBoxResult.Yes) {
|
||||||
Context.Remove(c);
|
Context.Remove(c);
|
||||||
@ -226,17 +226,18 @@ namespace Elwig.Windows {
|
|||||||
return c;
|
return c;
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task<AreaCommitment> UpdateaAreaCommitment(AreaCommitment a) {
|
private async Task<AreaComParcel> UpdateaAreaComParcel(AreaComParcel a) {
|
||||||
a.VNr = int.Parse(VNrInput.Text);
|
a.VNr = int.Parse(VNrInput.Text);
|
||||||
a.KgNr = ((AT_Kg)KgInput.SelectedItem).KgNr;
|
a.KgNr = ((AT_Kg)KgInput.SelectedItem).KgNr;
|
||||||
a.RdNr = ((WbRd)RdInput.SelectedItem).RdNr;
|
a.RdNr = ((WbRd)RdInput.SelectedItem).RdNr;
|
||||||
a.GstNr = GstNrInput.Text;
|
a.GstNr = GstNrInput.Text;
|
||||||
a.Area = int.Parse(AreaInput.Text);
|
a.Area = int.Parse(AreaInput.Text);
|
||||||
a.SortId = ((WineVar)SortInput.SelectedItem).SortId;
|
a.AreaCom.SortId = ((WineVar)SortInput.SelectedItem).SortId;
|
||||||
a.AttrId = ((WineAttr)AttrInput.SelectedItem).AttrId;
|
// FIXME
|
||||||
a.CultId = ((WineCult)CultInput.SelectedItem).CultId;
|
//a.AttrId = ((WineAttr)AttrInput.SelectedItem).AttrId;
|
||||||
|
a.AreaCom.CultId = ((WineCult)CultInput.SelectedItem).CultId;
|
||||||
|
|
||||||
EntityEntry<AreaCommitment>? tr = null;
|
EntityEntry<AreaComParcel>? tr = null;
|
||||||
try {
|
try {
|
||||||
if (IsEditing) {
|
if (IsEditing) {
|
||||||
tr = Context.Update(a);
|
tr = Context.Update(a);
|
||||||
@ -257,7 +258,7 @@ namespace Elwig.Windows {
|
|||||||
|
|
||||||
private async void AreaCommitmentSaveButton_Click(object sender, RoutedEventArgs evt) {
|
private async void AreaCommitmentSaveButton_Click(object sender, RoutedEventArgs evt) {
|
||||||
Contract c = await UpdateContract((Contract)ContractList.SelectedItem);
|
Contract c = await UpdateContract((Contract)ContractList.SelectedItem);
|
||||||
AreaCommitment a = await UpdateaAreaCommitment(IsEditing ? (AreaCommitment)AreaCommitmentList.SelectedItem : Context.CreateProxy<AreaCommitment>());
|
AreaComParcel a = await UpdateaAreaComParcel(IsEditing ? (AreaComParcel)AreaCommitmentList.SelectedItem : Context.CreateProxy<AreaComParcel>());
|
||||||
|
|
||||||
IsEditing = false;
|
IsEditing = false;
|
||||||
IsCreating = false;
|
IsCreating = false;
|
||||||
@ -297,7 +298,7 @@ namespace Elwig.Windows {
|
|||||||
|
|
||||||
private async void ContractSaveButton_Click(object sender, RoutedEventArgs evt) {
|
private async void ContractSaveButton_Click(object sender, RoutedEventArgs evt) {
|
||||||
Contract c = await UpdateContract(Context.CreateProxy<Contract>());
|
Contract c = await UpdateContract(Context.CreateProxy<Contract>());
|
||||||
AreaCommitment a = await UpdateaAreaCommitment(Context.CreateProxy<AreaCommitment>());
|
AreaComParcel a = await UpdateaAreaComParcel(Context.CreateProxy<AreaComParcel>());
|
||||||
|
|
||||||
IsEditing = false;
|
IsEditing = false;
|
||||||
IsCreating = false;
|
IsCreating = false;
|
@ -189,7 +189,7 @@ namespace Elwig.Windows {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void AreaCommitmentButton_Click(object sender, RoutedEventArgs evt) {
|
private void AreaCommitmentButton_Click(object sender, RoutedEventArgs evt) {
|
||||||
var w = new AreaCommAdminWindow((Member)MemberList.SelectedItem);
|
var w = new AreaComAdminWindow((Member)MemberList.SelectedItem);
|
||||||
w.Show();
|
w.Show();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -281,8 +281,8 @@ namespace Elwig.Windows {
|
|||||||
|
|
||||||
// TODO Rechnungsadresse
|
// TODO Rechnungsadresse
|
||||||
|
|
||||||
m.EntryDate = (EntryDateInput.Text == "") ? null : string.Join("-", EntryDateInput.Text.Split(".").Reverse());
|
m.EntryDateString = (EntryDateInput.Text == "") ? null : string.Join("-", EntryDateInput.Text.Split(".").Reverse());
|
||||||
m.ExitDate = (ExitDateInput.Text == "") ? null : string.Join("-", ExitDateInput.Text.Split(".").Reverse());
|
m.ExitDateString = (ExitDateInput.Text == "") ? null : string.Join("-", ExitDateInput.Text.Split(".").Reverse());
|
||||||
m.BusinessShares = (BusinessSharesInput.Text == "") ? 0 : int.Parse(BusinessSharesInput.Text);
|
m.BusinessShares = (BusinessSharesInput.Text == "") ? 0 : int.Parse(BusinessSharesInput.Text);
|
||||||
m.AccountingNr = (AccountingNrInput.Text == "") ? null : AccountingNrInput.Text;
|
m.AccountingNr = (AccountingNrInput.Text == "") ? null : AccountingNrInput.Text;
|
||||||
m.IsActive = ActiveInput.IsChecked ?? false;
|
m.IsActive = ActiveInput.IsChecked ?? false;
|
||||||
@ -372,8 +372,8 @@ namespace Elwig.Windows {
|
|||||||
BillingOrtInput.SelectedItem = null;
|
BillingOrtInput.SelectedItem = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
EntryDateInput.Text = (m.EntryDate != null) ? string.Join(".", m.EntryDate.Split("-").Reverse()) : null;
|
EntryDateInput.Text = (m.EntryDateString != null) ? string.Join(".", m.EntryDateString.Split("-").Reverse()) : null;
|
||||||
ExitDateInput.Text = (m.ExitDate != null) ? string.Join(".", m.ExitDate.Split("-").Reverse()) : null;
|
ExitDateInput.Text = (m.ExitDateString != null) ? string.Join(".", m.ExitDateString.Split("-").Reverse()) : null;
|
||||||
BusinessSharesInput.Text = m.BusinessShares.ToString();
|
BusinessSharesInput.Text = m.BusinessShares.ToString();
|
||||||
AccountingNrInput.Text = m.AccountingNr;
|
AccountingNrInput.Text = m.AccountingNr;
|
||||||
BranchInput.SelectedItem = m.Branch;
|
BranchInput.SelectedItem = m.Branch;
|
||||||
|
Reference in New Issue
Block a user