diff --git a/WGneu/Documents/Template.cs b/WGneu/Documents/Template.cs index abeca76..c8c34db 100644 --- a/WGneu/Documents/Template.cs +++ b/WGneu/Documents/Template.cs @@ -1,18 +1,34 @@ -using System; +using RazorLight; +using System; using System.Collections.Generic; using System.Diagnostics; using System.Linq; using System.Text; using System.Threading.Tasks; +using System.IO; +using WGneu.Models; namespace WGneu.Documents { class Template { - private static readonly string ROOT = @"C:\Users\Lorenz\Desktop\"; + private static readonly string ROOT = @"C:\Users\tom\Projects\wgneu\"; public static async void Test() { await Pdf.Convert(ROOT + "din-5008.html", ROOT + "test.pdf"); Pdf.Display("Test-Dokument", ROOT + "test.pdf"); } + + public static async void Generate(WgContext c) { + var engine = new RazorLightEngineBuilder() + .UseFileSystemProject(@"C:\Users\tom\source\repos\wgneu-cs\WGneu\Documents") + .UseMemoryCachingProvider() + .Build(); + + var model = new TestTemplateModel(c); + + string result = await engine.CompileRenderAsync("TestTemplate.cshtml", model); + + await File.WriteAllTextAsync(ROOT + "razor_test.html", result); + } } } diff --git a/WGneu/Documents/TestTemplate.cs b/WGneu/Documents/TestTemplate.cs deleted file mode 100644 index 2ac41f3..0000000 --- a/WGneu/Documents/TestTemplate.cs +++ /dev/null @@ -1,10 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace WGneu.Documents { - internal class TestTemplate { - } -} diff --git a/WGneu/Documents/TestTemplate.cshtml b/WGneu/Documents/TestTemplate.cshtml index c233872..c59b0a8 100644 --- a/WGneu/Documents/TestTemplate.cshtml +++ b/WGneu/Documents/TestTemplate.cshtml @@ -1,9 +1,249 @@ - +@using RazorLight +@inherits TemplatePage +@model IQueryable + + - Test Document + %SUBJECT% + + + + -

Test Document

+
+
+
+
+

Winzergenossenschaft Matzen

+
+ +
+
+
+
+
+
WG Matzen | Schloßstraße 6 | 2243 Matzen
+
E Österreichische Post AG Eco Brief
+
+
Maximilian Mustermann + Musterstraße 123 + 2222 Musterort + Österreich
+
+ +
+
+
Matzen, am 04.03.2023
+

%SUBJECT%

+

Sehr geehrtes Mitglied,

+ +

Ich bin ein langer Paragraph.

+

Ich bin ein langer Paragraph.

+

Ich bin ein langer Paragraph.

+

Ich bin ein langer Paragraph.

+

Ich bin ein langer Paragraph.

+

Ich bin ein langer Paragraph.

+

Ich bin ein langer Paragraph.

+

Ich bin ein langer Paragraph.

+

Ich bin ein langer Paragraph.

+

Ich bin ein langer Paragraph.

+

Ich bin ein langer Paragraph.

+

Ich bin ein langer Paragraph.

+

Ich bin ein langer Paragraph.

+

Ich bin ein langer Paragraph.

+

Ich bin ein langer Paragraph.

+

Ich bin ein langer Paragraph.

+

Ich bin ein langer Paragraph.

+

Ich bin ein langer Paragraph.

+

Ich bin ein langer Paragraph.

+

Ich bin ein langer Paragraph.

+

Ich bin ein langer Paragraph.

+

Ich bin ein langer Paragraph.

+

Ich bin ein langer Paragraph.

+

Ich bin ein langer Paragraph.

+

Ich bin ein langer Paragraph.

+ + @foreach (var country in Model.Countries) { +

Land:

+

@Raw(country.Name)

+

@country.Alpha2

+

@country.Alpha3

+ } + + + +

+ Mit freundlichen Grüßen
+ Ihre Winzergenossenschaft Matzen +

+
+
- \ No newline at end of file + diff --git a/WGneu/Documents/TestTemplateModel.cshtml.cs b/WGneu/Documents/TestTemplateModel.cshtml.cs new file mode 100644 index 0000000..a033d85 --- /dev/null +++ b/WGneu/Documents/TestTemplateModel.cshtml.cs @@ -0,0 +1,19 @@ +using Microsoft.AspNetCore.Mvc.RazorPages; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using WGneu.Models; + +namespace WGneu.Documents { + public class TestTemplateModel { + + public IQueryable Countries { get; set; } + + public TestTemplateModel(WgContext c) { + Countries = c.Countries; + } + + } +} diff --git a/WGneu/Models/AreaCommit.cs b/WGneu/Models/AreaCommit.cs new file mode 100644 index 0000000..d679180 --- /dev/null +++ b/WGneu/Models/AreaCommit.cs @@ -0,0 +1,51 @@ +using Microsoft.EntityFrameworkCore; +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations.Schema; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace WGneu.Models { + [Table("area_commitment"), PrimaryKey("Vnr", "KgNr", "GstNr")] + public class AreaCommit { + [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; } + + [Column("sortid")] + public String SortId { get; set; } + + [Column("attrid")] + public String? AttrId { get; set; } + + [Column("cultid")] + public String CultId { get; set; } + + [ForeignKey("Vnr")] + public virtual Contract Contract { get; set; } + + [ForeignKey("SortId")] + public virtual WineVar WineVar { get; set; } + + [ForeignKey("AttrId")] + public virtual WineAttr WineAttr { get; set; } + + [ForeignKey("CultId")] + public virtual WineCult WineCult { get; set; } + + [ForeignKey("KgNr, RdNr")] + public virtual WbRd WbRd { get; set; } + } +} diff --git a/WGneu/Models/Contract.cs b/WGneu/Models/Contract.cs new file mode 100644 index 0000000..6d04277 --- /dev/null +++ b/WGneu/Models/Contract.cs @@ -0,0 +1,27 @@ +using Microsoft.EntityFrameworkCore; +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations.Schema; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace WGneu.Models { + [Table("contract"), PrimaryKey("Vnr")] + public class Contract { + [Column("vnr")] + public int Vnr { get; set; } + + [Column("mgnr")] + public int MgNr { get; set; } + + [Column("year_from")] + public int YearFrom { get; set; } + + [Column("year_to")] + public int? YearTo { get; set; } + + [ForeignKey("MgNr")] + public virtual Member Member { get; set; } + } +} diff --git a/WGneu/Models/WbRd.cs b/WGneu/Models/WbRd.cs new file mode 100644 index 0000000..756cb10 --- /dev/null +++ b/WGneu/Models/WbRd.cs @@ -0,0 +1,24 @@ +using Microsoft.EntityFrameworkCore; +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations.Schema; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace WGneu.Models { + [Table("wb_rd"), PrimaryKey("KgNr", "RdNr")] + public class WbRd { + [Column("kgnr")] + public int KgNr { get; set; } + + [Column("rdnr")] + public int RdNr { get; set; } + + [Column("name")] + public String Name { get; set; } + + [ForeignKey("KgNr")] + public virtual WbKg WbKg { get; set; } + } +} diff --git a/WGneu/Models/WineAttr.cs b/WGneu/Models/WineAttr.cs new file mode 100644 index 0000000..10d7d7f --- /dev/null +++ b/WGneu/Models/WineAttr.cs @@ -0,0 +1,21 @@ +using Microsoft.EntityFrameworkCore; +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations.Schema; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace WGneu.Models { + [Table("wine_attribute"), PrimaryKey("AttrId")] + public class WineAttr { + [Column("attrid")] + public String AttrId { get; set; } + + [Column("name")] + public String Name { get; set; } + + [Column("kg_per_ha")] + public int KgPerHa { get; set; } + } +} diff --git a/WGneu/Models/WineCult.cs b/WGneu/Models/WineCult.cs new file mode 100644 index 0000000..4407211 --- /dev/null +++ b/WGneu/Models/WineCult.cs @@ -0,0 +1,18 @@ +using Microsoft.EntityFrameworkCore; +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations.Schema; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace WGneu.Models { + [Table("wine_cultivation"), PrimaryKey("CultId")] + public class WineCult { + [Column("cultid")] + public String CultId { get; set; } + + [Column("name")] + public String Name { get; set; } + } +} diff --git a/WGneu/Models/WineQual.cs b/WGneu/Models/WineQual.cs new file mode 100644 index 0000000..ee5f7f4 --- /dev/null +++ b/WGneu/Models/WineQual.cs @@ -0,0 +1,27 @@ +using Microsoft.EntityFrameworkCore; +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations.Schema; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace WGneu.Models { + [Table("wine_quality"), PrimaryKey("QualId")] + public class WineQual { + [Column("qualid")] + public String QualId { get; set; } + + [Column("origin_level")] + public int OriginLevel { get; set; } + + [Column("name")] + public String Name { get; set; } + + [Column("from_kmw")] + public double? FromKmw { get; set; } + + [Column("to_kmw")] + public double? ToKmw { get; set; } + } +} diff --git a/WGneu/Models/WineVar.cs b/WGneu/Models/WineVar.cs new file mode 100644 index 0000000..d82465f --- /dev/null +++ b/WGneu/Models/WineVar.cs @@ -0,0 +1,24 @@ +using Microsoft.EntityFrameworkCore; +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations.Schema; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace WGneu.Models { + [Table("wine_variety"), PrimaryKey("SortId")] + public class WineVar { + [Column("sortid")] + public String SortId { get; set; } + + [Column("type")] + public String Type { get; set; } + + [Column("name")] + public String Name { get; set; } + + [Column("comment")] + public String? Comment { get; set; } + } +} diff --git a/WGneu/WGneu.csproj b/WGneu/WGneu.csproj index 8a8806f..df79fa8 100644 --- a/WGneu/WGneu.csproj +++ b/WGneu/WGneu.csproj @@ -5,6 +5,7 @@ net6.0-windows enable true + true @@ -16,6 +17,7 @@ + diff --git a/WGneu/WgContext.cs b/WGneu/WgContext.cs index 7a06147..7a862dd 100644 --- a/WGneu/WgContext.cs +++ b/WGneu/WgContext.cs @@ -17,9 +17,18 @@ namespace WGneu { public DbSet PostalDestinations { get; set; } public DbSet Branches { get; set; } public DbSet WbKgs { get; set; } + public DbSet WbRde { get; set; } + public DbSet AreaCommitments { get; set; } + public DbSet Contracts { get; set; } + public DbSet WineAttributes { get; set; } + public DbSet WineCultivations { get; set; } + public DbSet WineQualities { get; set; } + public DbSet WineVarieties { get; set; } - protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) { - optionsBuilder.UseSqlite("Data Source=\"C:\\Users\\lorenz\\Desktop\\wgtest.sqlite3\"; foreign keys=true"); + + protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) + { + optionsBuilder.UseSqlite("Data Source=\"C:\\Users\\tom\\Projects\\wgneu\\wgtest.sqlite3\"; foreign keys=true"); optionsBuilder.UseLazyLoadingProxies(); } } diff --git a/WGneu/Windows/AreaCommitmentListWindow.xaml b/WGneu/Windows/AreaCommitmentListWindow.xaml new file mode 100644 index 0000000..c4dad34 --- /dev/null +++ b/WGneu/Windows/AreaCommitmentListWindow.xaml @@ -0,0 +1,21 @@ + + + + + + + + + + + + + diff --git a/WGneu/Windows/AreaCommitmentListWindow.xaml.cs b/WGneu/Windows/AreaCommitmentListWindow.xaml.cs new file mode 100644 index 0000000..4239b60 --- /dev/null +++ b/WGneu/Windows/AreaCommitmentListWindow.xaml.cs @@ -0,0 +1,42 @@ +using Microsoft.EntityFrameworkCore; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Data; +using System.Windows.Documents; +using System.Windows.Input; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using System.Windows.Shapes; +using WGneu.Models; + +namespace WGneu.Windows +{ + /// + /// Interaction logic for AreaCommitmentListWindow.xaml + /// + public partial class AreaCommitmentListWindow : Window { + private readonly WgContext Context = new(); + + public AreaCommitmentListWindow(Member member) { + InitializeComponent(); + } + + private void RefreshContractList() { + Context.Members.Load(); + List contracts = Context.Contracts.OrderBy(c => c.MgNr).ToList(); + + ContractList.ItemsSource = contracts; + if (contracts.Count == 1) + ContractList.SelectedIndex = 0; + } + + private void ContractList_SelectionChanged(object sender, SelectionChangedEventArgs e) { + RefreshContractList(); + } + } +} diff --git a/WGneu/Windows/DocumentViewerWindow.xaml b/WGneu/Windows/DocumentViewerWindow.xaml index bdf5ec0..fd64973 100644 --- a/WGneu/Windows/DocumentViewerWindow.xaml +++ b/WGneu/Windows/DocumentViewerWindow.xaml @@ -7,7 +7,7 @@ xmlns:local="clr-namespace:WGneu.Windows" mc:Ignorable="d" Title="PDF Ansicht" - MinHeight="600" MinWidth="420" Height="600" Width="420"> + MinHeight="600" MinWidth="420" Height="970" Width="670"> diff --git a/WGneu/Windows/MainWindow.xaml b/WGneu/Windows/MainWindow.xaml index 3ca7167..a831070 100644 --- a/WGneu/Windows/MainWindow.xaml +++ b/WGneu/Windows/MainWindow.xaml @@ -19,5 +19,6 @@