Daten können hinzugefügt
This commit is contained in:
@@ -22,9 +22,7 @@
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<None Update="kanSan.db">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</None>
|
||||
<ProjectReference Include="..\KanSan.Base\KanSan.Base.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
@@ -6,9 +6,23 @@
|
||||
<SubType>Designer</SubType>
|
||||
</ApplicationDefinition>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Update="UI\Baustelle\WindowBaustelleEdit.xaml.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Update="UI\Kunde\UCKundeEdit.xaml.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Page Update="MainWindow.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
</Page>
|
||||
<Page Update="UI\Baustelle\WindowBaustelleEdit.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
</Page>
|
||||
<Page Update="UI\Kunde\UCKundeEdit.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
</Page>
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
@@ -1,23 +0,0 @@
|
||||
using System;
|
||||
|
||||
namespace KanSan.Klassen
|
||||
{
|
||||
public class Baustelle
|
||||
{
|
||||
public Guid ID { get; set; }
|
||||
public Kunde Kunde { get; set; }
|
||||
public string Ort { get; set; }
|
||||
public string Strasse { get; set; }
|
||||
public string Projektnummer { get; set; }
|
||||
|
||||
public Baustelle(Kunde kunde)
|
||||
{
|
||||
Kunde = kunde;
|
||||
}
|
||||
|
||||
public Baustelle()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,31 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace KanSan.Klassen
|
||||
{
|
||||
public class Kunde
|
||||
{
|
||||
public Guid ID { get; set; }
|
||||
public string Vorname { get; set; }
|
||||
public string Nachname { get; set; }
|
||||
public string Strasse { get; set; }
|
||||
public string PLZ { get; set; }
|
||||
public string Ort { get; set; }
|
||||
|
||||
public List<Baustelle> Baustellen { get; set; } = new List<Baustelle>();
|
||||
|
||||
public void NeueBaustelle(KanSanContext ksc,string ort, string strasse, string projektnummer)
|
||||
{
|
||||
Baustelle baustelle = new Baustelle(this)
|
||||
{
|
||||
Ort = ort,
|
||||
ID = Guid.NewGuid(),
|
||||
Projektnummer = projektnummer,
|
||||
Strasse = strasse
|
||||
};
|
||||
//Baustellen.Add(baustelle);
|
||||
ksc.Add(baustelle);
|
||||
ksc.SaveChanges();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,42 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
|
||||
namespace KanSan.Klassen
|
||||
{
|
||||
public class Leistungsverzeichnis
|
||||
{
|
||||
public Guid ID { get; set; }
|
||||
public string Beschreibung { get; set; }
|
||||
public List<LeistungsverzeichnisPosition> Positionen { get; set; }
|
||||
public Leistungsverzeichnis(string beschreibung)
|
||||
{
|
||||
ID = Guid.NewGuid();
|
||||
Beschreibung = beschreibung;
|
||||
}
|
||||
|
||||
public void AddLeistungsverzeichnisPosition(string Positionnummer,string PositionsBeschreibung,string PositionEinheit, decimal PositionEinheitpreis)
|
||||
{
|
||||
if (Positionen == null) Positionen = new List<LeistungsverzeichnisPosition>();
|
||||
LeistungsverzeichnisPosition pos = new LeistungsverzeichnisPosition();
|
||||
pos.ID = Guid.NewGuid();
|
||||
pos.ref_leistungsverzeichnis = this;
|
||||
pos.Position = Positionnummer;
|
||||
pos.PositionBeschreibung = PositionsBeschreibung;
|
||||
pos.PositionEinheit = PositionEinheit;
|
||||
pos.PositionEinheitspreis = PositionEinheitpreis;
|
||||
|
||||
Positionen.Add(pos);
|
||||
}
|
||||
}
|
||||
|
||||
public class LeistungsverzeichnisPosition
|
||||
{
|
||||
public Guid ID { get; set; }
|
||||
public Leistungsverzeichnis ref_leistungsverzeichnis { get; set; }
|
||||
public string Position { get; set; }
|
||||
public string PositionBeschreibung { get; set; }
|
||||
public string PositionEinheit { get; set; }
|
||||
public decimal PositionEinheitspreis { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
namespace KanSan.Klassen
|
||||
{
|
||||
public class LeistungsverzeichnisBaustelle
|
||||
{
|
||||
public int LeistungsverzeichnisBaustelleID { get; set; }
|
||||
public Baustelle Baustelle { get; set; }
|
||||
public Leistungsverzeichnis Leistungsverzeichniss { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -8,9 +8,6 @@
|
||||
mc:Ignorable="d"
|
||||
Title="MainWindow" Height="450" Width="800">
|
||||
<Grid>
|
||||
|
||||
<syncfusion:GridControl HorizontalAlignment="Left" Height="100" Margin="252,147,0,0" VerticalAlignment="Top" Width="469"/>
|
||||
<Button Content="Button" HorizontalAlignment="Left" Height="30" Margin="153,217,0,0" VerticalAlignment="Top" Width="31" Click="Button_Click"/>
|
||||
|
||||
<ContentControl Name="ContentController" Content="ContentControl" HorizontalAlignment="Left" Height="402" Margin="226,22,0,0" VerticalAlignment="Top" Width="564"/>
|
||||
</Grid>
|
||||
</Window>
|
||||
|
||||
@@ -13,7 +13,8 @@ using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
using System.Windows.Navigation;
|
||||
using System.Windows.Shapes;
|
||||
using KanSan.Klassen;
|
||||
using KanSan.Base;
|
||||
using KanSan.Base.Models;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace KanSan
|
||||
@@ -26,97 +27,14 @@ namespace KanSan
|
||||
public MainWindow()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
public static void InsertOrUpdateGraph(KanSanContext context, Kunde kunde)
|
||||
{
|
||||
var existingKunde = context.Kunden
|
||||
.Include(b => b.Baustellen)
|
||||
.FirstOrDefault(b => b.ID == kunde.ID);
|
||||
|
||||
if (existingKunde == null)
|
||||
context.Add(kunde);
|
||||
else
|
||||
{
|
||||
context.Entry(existingKunde).CurrentValues.SetValues(kunde);
|
||||
foreach(var baustelle in kunde.Baustellen)
|
||||
{
|
||||
var existingBaustelle = existingKunde.Baustellen
|
||||
.FirstOrDefault(p => p.ID == baustelle.ID);
|
||||
if(existingBaustelle == null)
|
||||
{
|
||||
existingKunde.Baustellen.Add(baustelle);
|
||||
}
|
||||
else
|
||||
{
|
||||
context.Entry(existingBaustelle).CurrentValues.SetValues(baustelle);
|
||||
}
|
||||
}
|
||||
}
|
||||
context.SaveChanges();
|
||||
}
|
||||
|
||||
private void Button_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
using (KanSanContext ksc = new KanSanContext())
|
||||
{
|
||||
var kunden = ksc.Kunden.First();
|
||||
kunden.NeueBaustelle(ksc,"Oldenburg", "Strasse33", "20-850-012");
|
||||
/*
|
||||
Baustelle baustelle = new Baustelle(kunden);
|
||||
baustelle.ID = Guid.NewGuid();
|
||||
baustelle.Ort = "Oldenburg";
|
||||
baustelle.Projektnummer = "20-850-006";
|
||||
baustelle.Strasse = "Ammerländer";
|
||||
ksc.Add(baustelle);
|
||||
*/
|
||||
//NeueBaustelle("Oldenburg", "Ammerländer", "20-850-006");
|
||||
|
||||
|
||||
//InsertOrUpdateGraph(ksc, kunden);
|
||||
}
|
||||
|
||||
/*InitialKundenDatabase();
|
||||
InitialLeistungsverzeichnis();
|
||||
*/
|
||||
}
|
||||
private void InitialKundenDatabase()
|
||||
{
|
||||
Kunde kunde = new Kunde()
|
||||
{
|
||||
Vorname = "Fa.",
|
||||
Nachname = "OOWV",
|
||||
Ort = "Brake",
|
||||
PLZ = "268741",
|
||||
Strasse = "Donnerschweerstraße 74"
|
||||
};
|
||||
UnitOfWork unitOfWork = new UnitOfWork(new KanSanContext());
|
||||
var d = unitOfWork.KundenRepository.Get().First();
|
||||
|
||||
//kunde.NeueBaustelle("Oldenburg", "Kaspersweg", "20-850-003");
|
||||
using (KanSanContext ksc = new KanSanContext())
|
||||
{
|
||||
ksc.Kunden.Add(kunde);
|
||||
ksc.SaveChanges();
|
||||
}
|
||||
UI.UCKundeEdit uCKundeEdit = new UI.UCKundeEdit(d);
|
||||
ContentController.Content = uCKundeEdit;
|
||||
}
|
||||
private void InitialLeistungsverzeichnis()
|
||||
{
|
||||
using (KanSanContext ksc = new KanSanContext())
|
||||
{
|
||||
|
||||
Leistungsverzeichnis leistungsverzeichnis = new Leistungsverzeichnis("JunkerMevesGenerell");
|
||||
leistungsverzeichnis.AddLeistungsverzeichnisPosition("0.01", "Kurzliner", "Stk", 0);
|
||||
leistungsverzeichnis.AddLeistungsverzeichnisPosition("0.02", "Mat KL", "m", 0);
|
||||
leistungsverzeichnis.AddLeistungsverzeichnisPosition("0.03", "Stutzen Hut", "Stk", 0);
|
||||
leistungsverzeichnis.AddLeistungsverzeichnisPosition("0.04", "Stutzen andere", "Stk", 0);
|
||||
leistungsverzeichnis.AddLeistungsverzeichnisPosition("0.05", "VA-Manschette", "Stk", 0);
|
||||
leistungsverzeichnis.AddLeistungsverzeichnisPosition("0.06", "Öffnen", "Stk", 0);
|
||||
leistungsverzeichnis.AddLeistungsverzeichnisPosition("0.07", "Fräsen", "h", 0);
|
||||
leistungsverzeichnis.AddLeistungsverzeichnisPosition("0.08", "Hindernisse", "Stk", 0);
|
||||
leistungsverzeichnis.AddLeistungsverzeichnisPosition("0.09", "Anrauhen", "Stk", 0);
|
||||
|
||||
ksc.Leistungsverzeichnisses.Add(leistungsverzeichnis);
|
||||
ksc.SaveChanges();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,166 +0,0 @@
|
||||
// <auto-generated />
|
||||
using System;
|
||||
using KanSan;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
||||
|
||||
namespace KanSan.Migrations
|
||||
{
|
||||
[DbContext(typeof(KanSanContext))]
|
||||
[Migration("20200216122731_InitialCommit")]
|
||||
partial class InitialCommit
|
||||
{
|
||||
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||
{
|
||||
#pragma warning disable 612, 618
|
||||
modelBuilder
|
||||
.HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn)
|
||||
.HasAnnotation("ProductVersion", "3.1.1")
|
||||
.HasAnnotation("Relational:MaxIdentifierLength", 63);
|
||||
|
||||
modelBuilder.Entity("KanSan.Klassen.Baustelle", b =>
|
||||
{
|
||||
b.Property<Guid>("ID")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.Property<Guid?>("KundeID")
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.Property<string>("Ort")
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<string>("Projektnummer")
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<string>("Strasse")
|
||||
.HasColumnType("text");
|
||||
|
||||
b.HasKey("ID");
|
||||
|
||||
b.HasIndex("KundeID");
|
||||
|
||||
b.ToTable("Baustellen");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("KanSan.Klassen.Kunde", b =>
|
||||
{
|
||||
b.Property<Guid>("ID")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.Property<string>("Nachname")
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<string>("Ort")
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<string>("PLZ")
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<string>("Strasse")
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<string>("Vorname")
|
||||
.HasColumnType("text");
|
||||
|
||||
b.HasKey("ID");
|
||||
|
||||
b.ToTable("Kunden");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("KanSan.Klassen.Leistungsverzeichnis", b =>
|
||||
{
|
||||
b.Property<Guid>("ID")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.Property<string>("Beschreibung")
|
||||
.HasColumnType("text");
|
||||
|
||||
b.HasKey("ID");
|
||||
|
||||
b.ToTable("Leistungsverzeichnisses");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("KanSan.Klassen.LeistungsverzeichnisBaustelle", b =>
|
||||
{
|
||||
b.Property<int>("LeistungsverzeichnisBaustelleID")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer")
|
||||
.HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);
|
||||
|
||||
b.Property<Guid?>("BaustelleID")
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.Property<Guid?>("LeistungsverzeichnissID")
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.HasKey("LeistungsverzeichnisBaustelleID");
|
||||
|
||||
b.HasIndex("BaustelleID");
|
||||
|
||||
b.HasIndex("LeistungsverzeichnissID");
|
||||
|
||||
b.ToTable("LeistungsverzeichnisBaustelle");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("KanSan.Klassen.LeistungsverzeichnisPosition", b =>
|
||||
{
|
||||
b.Property<Guid>("ID")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.Property<string>("Position")
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<string>("PositionBeschreibung")
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<string>("PositionEinheit")
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<decimal>("PositionEinheitspreis")
|
||||
.HasColumnType("numeric");
|
||||
|
||||
b.Property<Guid?>("ref_leistungsverzeichnisID")
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.HasKey("ID");
|
||||
|
||||
b.HasIndex("ref_leistungsverzeichnisID");
|
||||
|
||||
b.ToTable("LeistungsverzeichnisPosition");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("KanSan.Klassen.Baustelle", b =>
|
||||
{
|
||||
b.HasOne("KanSan.Klassen.Kunde", null)
|
||||
.WithMany("Baustellen")
|
||||
.HasForeignKey("KundeID");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("KanSan.Klassen.LeistungsverzeichnisBaustelle", b =>
|
||||
{
|
||||
b.HasOne("KanSan.Klassen.Baustelle", "Baustelle")
|
||||
.WithMany()
|
||||
.HasForeignKey("BaustelleID");
|
||||
|
||||
b.HasOne("KanSan.Klassen.Leistungsverzeichnis", "Leistungsverzeichniss")
|
||||
.WithMany()
|
||||
.HasForeignKey("LeistungsverzeichnissID");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("KanSan.Klassen.LeistungsverzeichnisPosition", b =>
|
||||
{
|
||||
b.HasOne("KanSan.Klassen.Leistungsverzeichnis", "ref_leistungsverzeichnis")
|
||||
.WithMany("Positionen")
|
||||
.HasForeignKey("ref_leistungsverzeichnisID");
|
||||
});
|
||||
#pragma warning restore 612, 618
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,147 +0,0 @@
|
||||
using System;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
||||
|
||||
namespace KanSan.Migrations
|
||||
{
|
||||
public partial class InitialCommit : Migration
|
||||
{
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Kunden",
|
||||
columns: table => new
|
||||
{
|
||||
ID = table.Column<Guid>(nullable: false),
|
||||
Vorname = table.Column<string>(nullable: true),
|
||||
Nachname = table.Column<string>(nullable: true),
|
||||
Strasse = table.Column<string>(nullable: true),
|
||||
PLZ = table.Column<string>(nullable: true),
|
||||
Ort = table.Column<string>(nullable: true)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Kunden", x => x.ID);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Leistungsverzeichnisses",
|
||||
columns: table => new
|
||||
{
|
||||
ID = table.Column<Guid>(nullable: false),
|
||||
Beschreibung = table.Column<string>(nullable: true)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Leistungsverzeichnisses", x => x.ID);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Baustellen",
|
||||
columns: table => new
|
||||
{
|
||||
ID = table.Column<Guid>(nullable: false),
|
||||
Ort = table.Column<string>(nullable: true),
|
||||
Strasse = table.Column<string>(nullable: true),
|
||||
Projektnummer = table.Column<string>(nullable: true),
|
||||
KundeID = table.Column<Guid>(nullable: true)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Baustellen", x => x.ID);
|
||||
table.ForeignKey(
|
||||
name: "FK_Baustellen_Kunden_KundeID",
|
||||
column: x => x.KundeID,
|
||||
principalTable: "Kunden",
|
||||
principalColumn: "ID",
|
||||
onDelete: ReferentialAction.Restrict);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "LeistungsverzeichnisPosition",
|
||||
columns: table => new
|
||||
{
|
||||
ID = table.Column<Guid>(nullable: false),
|
||||
ref_leistungsverzeichnisID = table.Column<Guid>(nullable: true),
|
||||
Position = table.Column<string>(nullable: true),
|
||||
PositionBeschreibung = table.Column<string>(nullable: true),
|
||||
PositionEinheit = table.Column<string>(nullable: true),
|
||||
PositionEinheitspreis = table.Column<decimal>(nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_LeistungsverzeichnisPosition", x => x.ID);
|
||||
table.ForeignKey(
|
||||
name: "FK_LeistungsverzeichnisPosition_Leistungsverzeichnisses_ref_le~",
|
||||
column: x => x.ref_leistungsverzeichnisID,
|
||||
principalTable: "Leistungsverzeichnisses",
|
||||
principalColumn: "ID",
|
||||
onDelete: ReferentialAction.Restrict);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "LeistungsverzeichnisBaustelle",
|
||||
columns: table => new
|
||||
{
|
||||
LeistungsverzeichnisBaustelleID = table.Column<int>(nullable: false)
|
||||
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
||||
BaustelleID = table.Column<Guid>(nullable: true),
|
||||
LeistungsverzeichnissID = table.Column<Guid>(nullable: true)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_LeistungsverzeichnisBaustelle", x => x.LeistungsverzeichnisBaustelleID);
|
||||
table.ForeignKey(
|
||||
name: "FK_LeistungsverzeichnisBaustelle_Baustellen_BaustelleID",
|
||||
column: x => x.BaustelleID,
|
||||
principalTable: "Baustellen",
|
||||
principalColumn: "ID",
|
||||
onDelete: ReferentialAction.Restrict);
|
||||
table.ForeignKey(
|
||||
name: "FK_LeistungsverzeichnisBaustelle_Leistungsverzeichnisses_Leist~",
|
||||
column: x => x.LeistungsverzeichnissID,
|
||||
principalTable: "Leistungsverzeichnisses",
|
||||
principalColumn: "ID",
|
||||
onDelete: ReferentialAction.Restrict);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Baustellen_KundeID",
|
||||
table: "Baustellen",
|
||||
column: "KundeID");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_LeistungsverzeichnisBaustelle_BaustelleID",
|
||||
table: "LeistungsverzeichnisBaustelle",
|
||||
column: "BaustelleID");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_LeistungsverzeichnisBaustelle_LeistungsverzeichnissID",
|
||||
table: "LeistungsverzeichnisBaustelle",
|
||||
column: "LeistungsverzeichnissID");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_LeistungsverzeichnisPosition_ref_leistungsverzeichnisID",
|
||||
table: "LeistungsverzeichnisPosition",
|
||||
column: "ref_leistungsverzeichnisID");
|
||||
}
|
||||
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropTable(
|
||||
name: "LeistungsverzeichnisBaustelle");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "LeistungsverzeichnisPosition");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "Baustellen");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "Leistungsverzeichnisses");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "Kunden");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,164 +0,0 @@
|
||||
// <auto-generated />
|
||||
using System;
|
||||
using KanSan;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
||||
|
||||
namespace KanSan.Migrations
|
||||
{
|
||||
[DbContext(typeof(KanSanContext))]
|
||||
partial class KanSanContextModelSnapshot : ModelSnapshot
|
||||
{
|
||||
protected override void BuildModel(ModelBuilder modelBuilder)
|
||||
{
|
||||
#pragma warning disable 612, 618
|
||||
modelBuilder
|
||||
.HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn)
|
||||
.HasAnnotation("ProductVersion", "3.1.1")
|
||||
.HasAnnotation("Relational:MaxIdentifierLength", 63);
|
||||
|
||||
modelBuilder.Entity("KanSan.Klassen.Baustelle", b =>
|
||||
{
|
||||
b.Property<Guid>("ID")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.Property<Guid?>("KundeID")
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.Property<string>("Ort")
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<string>("Projektnummer")
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<string>("Strasse")
|
||||
.HasColumnType("text");
|
||||
|
||||
b.HasKey("ID");
|
||||
|
||||
b.HasIndex("KundeID");
|
||||
|
||||
b.ToTable("Baustellen");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("KanSan.Klassen.Kunde", b =>
|
||||
{
|
||||
b.Property<Guid>("ID")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.Property<string>("Nachname")
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<string>("Ort")
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<string>("PLZ")
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<string>("Strasse")
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<string>("Vorname")
|
||||
.HasColumnType("text");
|
||||
|
||||
b.HasKey("ID");
|
||||
|
||||
b.ToTable("Kunden");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("KanSan.Klassen.Leistungsverzeichnis", b =>
|
||||
{
|
||||
b.Property<Guid>("ID")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.Property<string>("Beschreibung")
|
||||
.HasColumnType("text");
|
||||
|
||||
b.HasKey("ID");
|
||||
|
||||
b.ToTable("Leistungsverzeichnisses");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("KanSan.Klassen.LeistungsverzeichnisBaustelle", b =>
|
||||
{
|
||||
b.Property<int>("LeistungsverzeichnisBaustelleID")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer")
|
||||
.HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);
|
||||
|
||||
b.Property<Guid?>("BaustelleID")
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.Property<Guid?>("LeistungsverzeichnissID")
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.HasKey("LeistungsverzeichnisBaustelleID");
|
||||
|
||||
b.HasIndex("BaustelleID");
|
||||
|
||||
b.HasIndex("LeistungsverzeichnissID");
|
||||
|
||||
b.ToTable("LeistungsverzeichnisBaustelle");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("KanSan.Klassen.LeistungsverzeichnisPosition", b =>
|
||||
{
|
||||
b.Property<Guid>("ID")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.Property<string>("Position")
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<string>("PositionBeschreibung")
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<string>("PositionEinheit")
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<decimal>("PositionEinheitspreis")
|
||||
.HasColumnType("numeric");
|
||||
|
||||
b.Property<Guid?>("ref_leistungsverzeichnisID")
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.HasKey("ID");
|
||||
|
||||
b.HasIndex("ref_leistungsverzeichnisID");
|
||||
|
||||
b.ToTable("LeistungsverzeichnisPosition");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("KanSan.Klassen.Baustelle", b =>
|
||||
{
|
||||
b.HasOne("KanSan.Klassen.Kunde", null)
|
||||
.WithMany("Baustellen")
|
||||
.HasForeignKey("KundeID");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("KanSan.Klassen.LeistungsverzeichnisBaustelle", b =>
|
||||
{
|
||||
b.HasOne("KanSan.Klassen.Baustelle", "Baustelle")
|
||||
.WithMany()
|
||||
.HasForeignKey("BaustelleID");
|
||||
|
||||
b.HasOne("KanSan.Klassen.Leistungsverzeichnis", "Leistungsverzeichniss")
|
||||
.WithMany()
|
||||
.HasForeignKey("LeistungsverzeichnissID");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("KanSan.Klassen.LeistungsverzeichnisPosition", b =>
|
||||
{
|
||||
b.HasOne("KanSan.Klassen.Leistungsverzeichnis", "ref_leistungsverzeichnis")
|
||||
.WithMany("Positionen")
|
||||
.HasForeignKey("ref_leistungsverzeichnisID");
|
||||
});
|
||||
#pragma warning restore 612, 618
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,36 +0,0 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using KanSan.Klassen;
|
||||
|
||||
namespace KanSan
|
||||
{
|
||||
public class KanSanContext : DbContext
|
||||
{
|
||||
|
||||
public DbSet<Kunde> Kunden { get; set; }
|
||||
public DbSet<Leistungsverzeichnis> Leistungsverzeichnisses { get; set; }
|
||||
public DbSet<LeistungsverzeichnisBaustelle> LeistungsverzeichnisBaustelle { get; set; }
|
||||
public DbSet<LeistungsverzeichnisPosition> LeistungsverzeichnisPosition { get; set; }
|
||||
public DbSet<Baustelle> Baustellen { get; set; }
|
||||
|
||||
protected override void OnConfiguring(DbContextOptionsBuilder options)
|
||||
{
|
||||
//options.UseSqlite("Data Source=kanSan.db");
|
||||
options.UseNpgsql("Host=localhost;Database=kanSan;Username=kansan;Password=kansan");
|
||||
}
|
||||
|
||||
/*
|
||||
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
||||
{
|
||||
modelBuilder.Entity<LeistungsverzeichnisBaustelle>(eb =>
|
||||
{
|
||||
eb.HasNoKey();
|
||||
});
|
||||
}
|
||||
*/
|
||||
}
|
||||
}
|
||||
25
KanSan/UI/Baustelle/WindowBaustelleEdit.xaml
Normal file
25
KanSan/UI/Baustelle/WindowBaustelleEdit.xaml
Normal file
@@ -0,0 +1,25 @@
|
||||
<Window x:Class="KanSan.UI.WindowBaustelleEdit"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:local="clr-namespace:KanSan.UI"
|
||||
mc:Ignorable="d"
|
||||
Title="FRMBaustelle" Height="450" Width="800" Closed="Window_Closed">
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition />
|
||||
<RowDefinition />
|
||||
<RowDefinition />
|
||||
</Grid.RowDefinitions>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="80" />
|
||||
<ColumnDefinition />
|
||||
</Grid.ColumnDefinitions>
|
||||
<Label>Ort</Label>
|
||||
<Label Grid.Row="1">Strasse</Label>
|
||||
|
||||
<TextBox Grid.Column="1" Name="Ort" Text="{Binding Ort}"/>
|
||||
<TextBox Grid.Column="1" Name="Strasse" Grid.Row="1" Text="{Binding Strasse}" />
|
||||
</Grid>
|
||||
</Window>
|
||||
62
KanSan/UI/Baustelle/WindowBaustelleEdit.xaml.cs
Normal file
62
KanSan/UI/Baustelle/WindowBaustelleEdit.xaml.cs
Normal file
@@ -0,0 +1,62 @@
|
||||
using KanSan.Base;
|
||||
using KanSan.Base.Models;
|
||||
using KanSan.ViewModel;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
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;
|
||||
|
||||
namespace KanSan.UI
|
||||
{
|
||||
/// <summary>
|
||||
/// Interaktionslogik für FRMBaustelle.xaml
|
||||
/// </summary>
|
||||
public partial class WindowBaustelleEdit : Window
|
||||
{
|
||||
private UnitOfWork unitOfWork = new UnitOfWork(new KanSanContext());
|
||||
private Baustelle bs = null;
|
||||
|
||||
|
||||
public WindowBaustelleEdit(Baustelle baustelle)
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
if (baustelle == null) throw new ArgumentNullException("baustelle");
|
||||
|
||||
bs = baustelle;
|
||||
|
||||
BaustelleViewModel model = new BaustelleViewModel(bs);
|
||||
|
||||
|
||||
model.PropertyChanged += Model_PropertyChanged;
|
||||
|
||||
this.DataContext = model;
|
||||
}
|
||||
|
||||
private void Model_PropertyChanged(object sender, PropertyChangedEventArgs e)
|
||||
{
|
||||
BaustelleViewModel baustelleViewModel = (BaustelleViewModel)sender;
|
||||
bs.Ort = baustelleViewModel.Ort;
|
||||
bs.Projektnummer = baustelleViewModel.Projektnummer;
|
||||
bs.Strasse = baustelleViewModel.Strasse;
|
||||
|
||||
unitOfWork.BaustellenRepository.Update(bs);
|
||||
//Debugger.Break();
|
||||
}
|
||||
|
||||
private void Window_Closed(object sender, EventArgs e)
|
||||
{
|
||||
unitOfWork.Commit();
|
||||
}
|
||||
}
|
||||
}
|
||||
34
KanSan/UI/Kunde/UCKundeEdit.xaml
Normal file
34
KanSan/UI/Kunde/UCKundeEdit.xaml
Normal file
@@ -0,0 +1,34 @@
|
||||
<UserControl x:Class="KanSan.UI.UCKundeEdit"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:local="clr-namespace:KanSan.UI"
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="450" d:DesignWidth="800">
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition />
|
||||
<RowDefinition />
|
||||
<RowDefinition />
|
||||
<RowDefinition />
|
||||
<RowDefinition />
|
||||
</Grid.RowDefinitions>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition />
|
||||
<ColumnDefinition />
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<Label Grid.Column="0" Grid.Row="0">Vorname</Label>
|
||||
<Label Grid.Column="0" Grid.Row="1">Nachname</Label>
|
||||
<Label Grid.Column="0" Grid.Row="2">Strasse</Label>
|
||||
<Label Grid.Column="0" Grid.Row="3">Plz</Label>
|
||||
<Label Grid.Column="0" Grid.Row="4">Ort</Label>
|
||||
|
||||
<TextBox Grid.Column="1" Grid.Row="0" Text="{Binding Vorname}" />
|
||||
<TextBox Grid.Column="1" Grid.Row="1" Text="{Binding Nachname}" />
|
||||
<TextBox Grid.Column="1" Grid.Row="2" Text="{Binding Strasse}" />
|
||||
<TextBox Grid.Column="1" Grid.Row="3" Text="{Binding PLZ}" />
|
||||
<TextBox Grid.Column="1" Grid.Row="4" Text="{Binding Ort}" />
|
||||
</Grid>
|
||||
</UserControl>
|
||||
44
KanSan/UI/Kunde/UCKundeEdit.xaml.cs
Normal file
44
KanSan/UI/Kunde/UCKundeEdit.xaml.cs
Normal file
@@ -0,0 +1,44 @@
|
||||
using KanSan.Base;
|
||||
using KanSan.Base.Models;
|
||||
using KanSan.ViewModel;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
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.Navigation;
|
||||
using System.Windows.Shapes;
|
||||
|
||||
namespace KanSan.UI
|
||||
{
|
||||
/// <summary>
|
||||
/// Interaktionslogik für UCKundeEdit.xaml
|
||||
/// </summary>
|
||||
public partial class UCKundeEdit : UserControl
|
||||
{
|
||||
private Kunde kunde = null;
|
||||
private UnitOfWork unitOfWork = null;
|
||||
public UCKundeEdit(Kunde kunde)
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
this.kunde = kunde;
|
||||
|
||||
unitOfWork = new UnitOfWork(new KanSanContext());
|
||||
|
||||
KundeViewModel kundeViewModel = new KundeViewModel(kunde);
|
||||
kundeViewModel.PropertyChanged += KundeViewModel_PropertyChanged;
|
||||
this.DataContext = kundeViewModel;
|
||||
}
|
||||
|
||||
private void KundeViewModel_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
68
KanSan/ViewModel/BaustelleViewModel.cs
Normal file
68
KanSan/ViewModel/BaustelleViewModel.cs
Normal file
@@ -0,0 +1,68 @@
|
||||
using KanSan.Base.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Text;
|
||||
|
||||
namespace KanSan.ViewModel
|
||||
{
|
||||
class BaustelleViewModel : PropertyChangedClass,INotifyPropertyChanged
|
||||
{
|
||||
private Baustelle _baustelle;
|
||||
|
||||
|
||||
private string ort;
|
||||
private string strasse;
|
||||
private string projektnummer;
|
||||
public string Ort
|
||||
{
|
||||
get
|
||||
{
|
||||
return ort;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (ort == value) return;
|
||||
ort = value;
|
||||
OnPropertyChanged();
|
||||
}
|
||||
}
|
||||
public string Strasse
|
||||
{
|
||||
get
|
||||
{
|
||||
return strasse;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (strasse == value) return;
|
||||
strasse = value;
|
||||
OnPropertyChanged();
|
||||
}
|
||||
}
|
||||
public string Projektnummer
|
||||
{
|
||||
get
|
||||
{
|
||||
return projektnummer;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (projektnummer == value) return;
|
||||
projektnummer = value;
|
||||
OnPropertyChanged();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
public BaustelleViewModel(Baustelle baustelle)
|
||||
{
|
||||
_baustelle = baustelle;
|
||||
ort = _baustelle.Ort;
|
||||
strasse = _baustelle.Strasse;
|
||||
projektnummer = _baustelle.Projektnummer;
|
||||
}
|
||||
}
|
||||
}
|
||||
96
KanSan/ViewModel/KundeViewModel.cs
Normal file
96
KanSan/ViewModel/KundeViewModel.cs
Normal file
@@ -0,0 +1,96 @@
|
||||
using KanSan.Base.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Text;
|
||||
|
||||
namespace KanSan.ViewModel
|
||||
{
|
||||
class KundeViewModel : PropertyChangedClass, INotifyPropertyChanged
|
||||
{
|
||||
private Kunde _kunde;
|
||||
private string vorname;
|
||||
private string nachname;
|
||||
private string strasse;
|
||||
private string plz;
|
||||
private string ort;
|
||||
|
||||
#region getters
|
||||
public string Vorname
|
||||
{
|
||||
get
|
||||
{
|
||||
return vorname;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (vorname == value) return;
|
||||
vorname = value;
|
||||
OnPropertyChanged();
|
||||
}
|
||||
}
|
||||
public string Nachname
|
||||
{
|
||||
get
|
||||
{
|
||||
return nachname;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (nachname == value) return;
|
||||
nachname = value;
|
||||
OnPropertyChanged();
|
||||
}
|
||||
}
|
||||
public string Strasse
|
||||
{
|
||||
get
|
||||
{
|
||||
return strasse;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (strasse == value) return;
|
||||
strasse = value;
|
||||
OnPropertyChanged();
|
||||
}
|
||||
}
|
||||
public string PLZ
|
||||
{
|
||||
get
|
||||
{
|
||||
return plz;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (plz == value) return;
|
||||
plz = value;
|
||||
OnPropertyChanged();
|
||||
}
|
||||
}
|
||||
public string Ort
|
||||
{
|
||||
get
|
||||
{
|
||||
return ort;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (ort == value) return;
|
||||
ort = value;
|
||||
OnPropertyChanged();
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
public KundeViewModel(Kunde kunde)
|
||||
{
|
||||
_kunde = kunde;
|
||||
vorname = _kunde.Vorname;
|
||||
nachname = _kunde.Nachname;
|
||||
strasse = _kunde.Strasse;
|
||||
plz = _kunde.PLZ;
|
||||
ort = _kunde.Ort;
|
||||
}
|
||||
}
|
||||
}
|
||||
18
KanSan/ViewModel/PropertyChangedClass.cs
Normal file
18
KanSan/ViewModel/PropertyChangedClass.cs
Normal file
@@ -0,0 +1,18 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Text;
|
||||
|
||||
namespace KanSan.ViewModel
|
||||
{
|
||||
class PropertyChangedClass
|
||||
{
|
||||
public event PropertyChangedEventHandler PropertyChanged;
|
||||
protected internal void OnPropertyChanged([CallerMemberName] string propertyname = null)
|
||||
{
|
||||
if (PropertyChanged != null)
|
||||
PropertyChanged(this, new PropertyChangedEventArgs(propertyname));
|
||||
}
|
||||
}
|
||||
}
|
||||
BIN
KanSan/kanSan.db
BIN
KanSan/kanSan.db
Binary file not shown.
Reference in New Issue
Block a user