Initial commit
This commit is contained in:
commit
d69e92c437
289
.gitignore
vendored
Normal file
289
.gitignore
vendored
Normal file
@ -0,0 +1,289 @@
|
|||||||
|
## Ignore Visual Studio temporary files, build results, and
|
||||||
|
## files generated by popular Visual Studio add-ons.
|
||||||
|
##
|
||||||
|
## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore
|
||||||
|
|
||||||
|
# User-specific files
|
||||||
|
*.suo
|
||||||
|
*.user
|
||||||
|
*.userosscache
|
||||||
|
*.sln.docstates
|
||||||
|
|
||||||
|
# User-specific files (MonoDevelop/Xamarin Studio)
|
||||||
|
*.userprefs
|
||||||
|
|
||||||
|
# Build results
|
||||||
|
[Dd]ebug/
|
||||||
|
[Dd]ebugPublic/
|
||||||
|
[Rr]elease/
|
||||||
|
x64/
|
||||||
|
x86/
|
||||||
|
bld/
|
||||||
|
[Bb]in/
|
||||||
|
[Oo]bj/
|
||||||
|
[Ll]og/
|
||||||
|
|
||||||
|
# Visual Studio 2015 cache/options directory
|
||||||
|
.vs/
|
||||||
|
# Uncomment if you have tasks that create the project's static files in wwwroot
|
||||||
|
#wwwroot/
|
||||||
|
|
||||||
|
# MSTest test Results
|
||||||
|
[Tt]est[Rr]esult*/
|
||||||
|
[Bb]uild[Ll]og.*
|
||||||
|
|
||||||
|
# NUNIT
|
||||||
|
*.VisualState.xml
|
||||||
|
TestResult.xml
|
||||||
|
|
||||||
|
# Build Results of an ATL Project
|
||||||
|
[Dd]ebugPS/
|
||||||
|
[Rr]eleasePS/
|
||||||
|
dlldata.c
|
||||||
|
|
||||||
|
# .NET Core
|
||||||
|
project.lock.json
|
||||||
|
project.fragment.lock.json
|
||||||
|
artifacts/
|
||||||
|
**/Properties/launchSettings.json
|
||||||
|
|
||||||
|
# VS Code
|
||||||
|
.vscode/
|
||||||
|
|
||||||
|
*_i.c
|
||||||
|
*_p.c
|
||||||
|
*_i.h
|
||||||
|
*.ilk
|
||||||
|
*.meta
|
||||||
|
*.obj
|
||||||
|
*.pch
|
||||||
|
*.pdb
|
||||||
|
*.pgc
|
||||||
|
*.pgd
|
||||||
|
*.rsp
|
||||||
|
*.sbr
|
||||||
|
*.tlb
|
||||||
|
*.tli
|
||||||
|
*.tlh
|
||||||
|
*.tmp
|
||||||
|
*.tmp_proj
|
||||||
|
*.log
|
||||||
|
*.vspscc
|
||||||
|
*.vssscc
|
||||||
|
.builds
|
||||||
|
*.pidb
|
||||||
|
*.svclog
|
||||||
|
*.scc
|
||||||
|
|
||||||
|
# Chutzpah Test files
|
||||||
|
_Chutzpah*
|
||||||
|
|
||||||
|
# Visual C++ cache files
|
||||||
|
ipch/
|
||||||
|
*.aps
|
||||||
|
*.ncb
|
||||||
|
*.opendb
|
||||||
|
*.opensdf
|
||||||
|
*.sdf
|
||||||
|
*.cachefile
|
||||||
|
*.VC.db
|
||||||
|
*.VC.VC.opendb
|
||||||
|
|
||||||
|
# Visual Studio profiler
|
||||||
|
*.psess
|
||||||
|
*.vsp
|
||||||
|
*.vspx
|
||||||
|
*.sap
|
||||||
|
|
||||||
|
# TFS 2012 Local Workspace
|
||||||
|
$tf/
|
||||||
|
|
||||||
|
# Guidance Automation Toolkit
|
||||||
|
*.gpState
|
||||||
|
|
||||||
|
# ReSharper is a .NET coding add-in
|
||||||
|
_ReSharper*/
|
||||||
|
*.[Rr]e[Ss]harper
|
||||||
|
*.DotSettings.user
|
||||||
|
|
||||||
|
# JustCode is a .NET coding add-in
|
||||||
|
.JustCode
|
||||||
|
|
||||||
|
# TeamCity is a build add-in
|
||||||
|
_TeamCity*
|
||||||
|
|
||||||
|
# DotCover is a Code Coverage Tool
|
||||||
|
*.dotCover
|
||||||
|
|
||||||
|
# Visual Studio code coverage results
|
||||||
|
*.coverage
|
||||||
|
*.coveragexml
|
||||||
|
|
||||||
|
# NCrunch
|
||||||
|
_NCrunch_*
|
||||||
|
.*crunch*.local.xml
|
||||||
|
nCrunchTemp_*
|
||||||
|
|
||||||
|
# MightyMoose
|
||||||
|
*.mm.*
|
||||||
|
AutoTest.Net/
|
||||||
|
|
||||||
|
# Web workbench (sass)
|
||||||
|
.sass-cache/
|
||||||
|
|
||||||
|
# Installshield output folder
|
||||||
|
[Ee]xpress/
|
||||||
|
|
||||||
|
# DocProject is a documentation generator add-in
|
||||||
|
DocProject/buildhelp/
|
||||||
|
DocProject/Help/*.HxT
|
||||||
|
DocProject/Help/*.HxC
|
||||||
|
DocProject/Help/*.hhc
|
||||||
|
DocProject/Help/*.hhk
|
||||||
|
DocProject/Help/*.hhp
|
||||||
|
DocProject/Help/Html2
|
||||||
|
DocProject/Help/html
|
||||||
|
|
||||||
|
# Click-Once directory
|
||||||
|
publish/
|
||||||
|
|
||||||
|
# Publish Web Output
|
||||||
|
*.[Pp]ublish.xml
|
||||||
|
*.azurePubxml
|
||||||
|
# TODO: Comment the next line if you want to checkin your web deploy settings
|
||||||
|
# but database connection strings (with potential passwords) will be unencrypted
|
||||||
|
*.pubxml
|
||||||
|
*.publishproj
|
||||||
|
|
||||||
|
# Microsoft Azure Web App publish settings. Comment the next line if you want to
|
||||||
|
# checkin your Azure Web App publish settings, but sensitive information contained
|
||||||
|
# in these scripts will be unencrypted
|
||||||
|
PublishScripts/
|
||||||
|
|
||||||
|
# NuGet Packages
|
||||||
|
*.nupkg
|
||||||
|
# The packages folder can be ignored because of Package Restore
|
||||||
|
**/packages/*
|
||||||
|
# except build/, which is used as an MSBuild target.
|
||||||
|
!**/packages/build/
|
||||||
|
# Uncomment if necessary however generally it will be regenerated when needed
|
||||||
|
#!**/packages/repositories.config
|
||||||
|
# NuGet v3's project.json files produces more ignorable files
|
||||||
|
*.nuget.props
|
||||||
|
*.nuget.targets
|
||||||
|
|
||||||
|
# Microsoft Azure Build Output
|
||||||
|
csx/
|
||||||
|
*.build.csdef
|
||||||
|
|
||||||
|
# Microsoft Azure Emulator
|
||||||
|
ecf/
|
||||||
|
rcf/
|
||||||
|
|
||||||
|
# Windows Store app package directories and files
|
||||||
|
AppPackages/
|
||||||
|
BundleArtifacts/
|
||||||
|
Package.StoreAssociation.xml
|
||||||
|
_pkginfo.txt
|
||||||
|
|
||||||
|
# Visual Studio cache files
|
||||||
|
# files ending in .cache can be ignored
|
||||||
|
*.[Cc]ache
|
||||||
|
# but keep track of directories ending in .cache
|
||||||
|
!*.[Cc]ache/
|
||||||
|
|
||||||
|
# Others
|
||||||
|
ClientBin/
|
||||||
|
~$*
|
||||||
|
*~
|
||||||
|
*.dbmdl
|
||||||
|
*.dbproj.schemaview
|
||||||
|
*.jfm
|
||||||
|
*.pfx
|
||||||
|
*.publishsettings
|
||||||
|
orleans.codegen.cs
|
||||||
|
|
||||||
|
# Since there are multiple workflows, uncomment next line to ignore bower_components
|
||||||
|
# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
|
||||||
|
#bower_components/
|
||||||
|
|
||||||
|
# RIA/Silverlight projects
|
||||||
|
Generated_Code/
|
||||||
|
|
||||||
|
# Backup & report files from converting an old project file
|
||||||
|
# to a newer Visual Studio version. Backup files are not needed,
|
||||||
|
# because we have git ;-)
|
||||||
|
_UpgradeReport_Files/
|
||||||
|
Backup*/
|
||||||
|
UpgradeLog*.XML
|
||||||
|
UpgradeLog*.htm
|
||||||
|
|
||||||
|
# SQL Server files
|
||||||
|
*.mdf
|
||||||
|
*.ldf
|
||||||
|
|
||||||
|
# Business Intelligence projects
|
||||||
|
*.rdl.data
|
||||||
|
*.bim.layout
|
||||||
|
*.bim_*.settings
|
||||||
|
|
||||||
|
# Microsoft Fakes
|
||||||
|
FakesAssemblies/
|
||||||
|
|
||||||
|
# GhostDoc plugin setting file
|
||||||
|
*.GhostDoc.xml
|
||||||
|
|
||||||
|
# Node.js Tools for Visual Studio
|
||||||
|
.ntvs_analysis.dat
|
||||||
|
node_modules/
|
||||||
|
|
||||||
|
# Typescript v1 declaration files
|
||||||
|
typings/
|
||||||
|
|
||||||
|
# Visual Studio 6 build log
|
||||||
|
*.plg
|
||||||
|
|
||||||
|
# Visual Studio 6 workspace options file
|
||||||
|
*.opt
|
||||||
|
|
||||||
|
# Visual Studio 6 auto-generated workspace file (contains which files were open etc.)
|
||||||
|
*.vbw
|
||||||
|
|
||||||
|
# Visual Studio LightSwitch build output
|
||||||
|
**/*.HTMLClient/GeneratedArtifacts
|
||||||
|
**/*.DesktopClient/GeneratedArtifacts
|
||||||
|
**/*.DesktopClient/ModelManifest.xml
|
||||||
|
**/*.Server/GeneratedArtifacts
|
||||||
|
**/*.Server/ModelManifest.xml
|
||||||
|
_Pvt_Extensions
|
||||||
|
|
||||||
|
# Paket dependency manager
|
||||||
|
.paket/paket.exe
|
||||||
|
paket-files/
|
||||||
|
|
||||||
|
# FAKE - F# Make
|
||||||
|
.fake/
|
||||||
|
|
||||||
|
# JetBrains Rider
|
||||||
|
.idea/
|
||||||
|
*.sln.iml
|
||||||
|
|
||||||
|
# CodeRush
|
||||||
|
.cr/
|
||||||
|
|
||||||
|
# Python Tools for Visual Studio (PTVS)
|
||||||
|
__pycache__/
|
||||||
|
*.pyc
|
||||||
|
|
||||||
|
# Cake - Uncomment if you are using it
|
||||||
|
# tools/**
|
||||||
|
# !tools/packages.config
|
||||||
|
|
||||||
|
# Telerik's JustMock configuration file
|
||||||
|
*.jmconfig
|
||||||
|
|
||||||
|
# BizTalk build output
|
||||||
|
*.btp.cs
|
||||||
|
*.btm.cs
|
||||||
|
*.odx.cs
|
||||||
|
*.xsd.cs
|
25
FahrzeugProjekt.sln
Normal file
25
FahrzeugProjekt.sln
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
|
||||||
|
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||||
|
# Visual Studio Version 17
|
||||||
|
VisualStudioVersion = 17.14.36301.6 d17.14
|
||||||
|
MinimumVisualStudioVersion = 10.0.40219.1
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FahrzeugProjekt", "FahrzeugProjekt\FahrzeugProjekt.csproj", "{5070F3B7-2648-42A1-9F3C-016857AAD14D}"
|
||||||
|
EndProject
|
||||||
|
Global
|
||||||
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
|
Debug|Any CPU = Debug|Any CPU
|
||||||
|
Release|Any CPU = Release|Any CPU
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||||
|
{5070F3B7-2648-42A1-9F3C-016857AAD14D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{5070F3B7-2648-42A1-9F3C-016857AAD14D}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{5070F3B7-2648-42A1-9F3C-016857AAD14D}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{5070F3B7-2648-42A1-9F3C-016857AAD14D}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
|
HideSolutionNode = FALSE
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||||
|
SolutionGuid = {9F149AC2-9184-48A3-9A22-2F168C53A802}
|
||||||
|
EndGlobalSection
|
||||||
|
EndGlobal
|
8
FahrzeugProjekt/App.xaml
Normal file
8
FahrzeugProjekt/App.xaml
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
<Application x:Class="FahrzeugProjekt.App"
|
||||||
|
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||||
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
|
xmlns:local="clr-namespace:FahrzeugProjekt">
|
||||||
|
<Application.Resources>
|
||||||
|
|
||||||
|
</Application.Resources>
|
||||||
|
</Application>
|
45
FahrzeugProjekt/App.xaml.cs
Normal file
45
FahrzeugProjekt/App.xaml.cs
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
|
using Microsoft.Extensions.Configuration;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using System.IO;
|
||||||
|
using System.Windows;
|
||||||
|
|
||||||
|
namespace FahrzeugProjekt
|
||||||
|
{
|
||||||
|
public partial class App : Application
|
||||||
|
{
|
||||||
|
public static IServiceProvider ServiceProvider { get; private set; }
|
||||||
|
|
||||||
|
protected override void OnStartup(StartupEventArgs e)
|
||||||
|
{
|
||||||
|
base.OnStartup(e);
|
||||||
|
|
||||||
|
// Configuration laden
|
||||||
|
var builder = new ConfigurationBuilder()
|
||||||
|
.SetBasePath(Directory.GetCurrentDirectory())
|
||||||
|
.AddJsonFile("appsettings.json", optional: false, reloadOnChange: true);
|
||||||
|
IConfiguration configuration = builder.Build();
|
||||||
|
|
||||||
|
string connectionString = configuration.GetConnectionString("FahrzeugProjektConnection");
|
||||||
|
|
||||||
|
// Services konfigurieren
|
||||||
|
var services = new ServiceCollection();
|
||||||
|
|
||||||
|
// DbContext registrieren
|
||||||
|
services.AddDbContext<FahrzeugProjektKontext>(options =>
|
||||||
|
options.UseSqlServer(connectionString));
|
||||||
|
|
||||||
|
// Alle Fenster registrieren
|
||||||
|
services.AddTransient<MainWindow>();
|
||||||
|
services.AddTransient<FahrzeugEintragenWindow>();
|
||||||
|
services.AddTransient<FahrzeugeAnzeigenWindow>();
|
||||||
|
|
||||||
|
// Service Provider erstellen
|
||||||
|
ServiceProvider = services.BuildServiceProvider();
|
||||||
|
|
||||||
|
// MainWindow manuell erstellen und anzeigen
|
||||||
|
var hauptFenster = ServiceProvider.GetRequiredService<MainWindow>();
|
||||||
|
hauptFenster.Show();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
23
FahrzeugProjekt/Arbeiter.cs
Normal file
23
FahrzeugProjekt/Arbeiter.cs
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
using System.ComponentModel.DataAnnotations.Schema;
|
||||||
|
|
||||||
|
namespace FahrzeugProjekt
|
||||||
|
{
|
||||||
|
public class Arbeiter
|
||||||
|
{
|
||||||
|
[Column("ArbeiterID")]
|
||||||
|
public int ArbeiterID { get; set; }
|
||||||
|
|
||||||
|
[Column("Vorname")]
|
||||||
|
public string Vorname { get; set; }
|
||||||
|
|
||||||
|
[Column("Nachname")]
|
||||||
|
public string Nachname { get; set; }
|
||||||
|
|
||||||
|
[Column("Email")]
|
||||||
|
public string Email { get; set; }
|
||||||
|
|
||||||
|
[Column("Passwort")]
|
||||||
|
public string Passwort { get; set; }
|
||||||
|
}
|
||||||
|
}
|
10
FahrzeugProjekt/AssemblyInfo.cs
Normal file
10
FahrzeugProjekt/AssemblyInfo.cs
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
using System.Windows;
|
||||||
|
|
||||||
|
[assembly: ThemeInfo(
|
||||||
|
ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located
|
||||||
|
//(used if a resource is not found in the page,
|
||||||
|
// or application resource dictionaries)
|
||||||
|
ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located
|
||||||
|
//(used if a resource is not found in the page,
|
||||||
|
// app, or any theme specific resource dictionaries)
|
||||||
|
)]
|
36
FahrzeugProjekt/Fahrzeug.cs
Normal file
36
FahrzeugProjekt/Fahrzeug.cs
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
using System.ComponentModel.DataAnnotations.Schema;
|
||||||
|
|
||||||
|
namespace FahrzeugProjekt
|
||||||
|
{
|
||||||
|
[Table("Fahrzeuge")]
|
||||||
|
public class Fahrzeug
|
||||||
|
{
|
||||||
|
[Column("FahrzeugID")]
|
||||||
|
public int FahrzeugID { get; set; }
|
||||||
|
|
||||||
|
[Column("ModellID")]
|
||||||
|
public int ModellID { get; set; }
|
||||||
|
|
||||||
|
public Modell Modell { get; set; }
|
||||||
|
|
||||||
|
[Column("Getriebe")]
|
||||||
|
public string Getriebe { get; set; }
|
||||||
|
|
||||||
|
[Column("Kraftstoff")]
|
||||||
|
public string Kraftstoff { get; set; }
|
||||||
|
|
||||||
|
[Column("Baujahr")]
|
||||||
|
public int Baujahr { get; set; }
|
||||||
|
|
||||||
|
[Column("Farbe")]
|
||||||
|
public string Farbe { get; set; }
|
||||||
|
|
||||||
|
[Column("Kilometerstand")]
|
||||||
|
public int Kilometerstand { get; set; }
|
||||||
|
|
||||||
|
[Column("Beschreibung")]
|
||||||
|
public string Beschreibung { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
95
FahrzeugProjekt/FahrzeugAnzeigenWindow.xaml
Normal file
95
FahrzeugProjekt/FahrzeugAnzeigenWindow.xaml
Normal file
@ -0,0 +1,95 @@
|
|||||||
|
<Window x:Class="FahrzeugProjekt.FahrzeugeAnzeigenWindow"
|
||||||
|
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:FahrzeugProjekt"
|
||||||
|
mc:Ignorable="d"
|
||||||
|
Title="Fahrzeuge Anzeigen" Height="700" Width="900"
|
||||||
|
WindowStartupLocation="CenterScreen">
|
||||||
|
|
||||||
|
<Grid Margin="15">
|
||||||
|
<Grid.RowDefinitions>
|
||||||
|
<RowDefinition Height="Auto"/>
|
||||||
|
<RowDefinition Height="Auto"/>
|
||||||
|
<RowDefinition Height="*"/>
|
||||||
|
<RowDefinition Height="Auto"/>
|
||||||
|
</Grid.RowDefinitions>
|
||||||
|
|
||||||
|
<!-- Titel -->
|
||||||
|
<TextBlock Grid.Row="0" Text="Alle Fahrzeuge"
|
||||||
|
FontSize="20" FontWeight="Bold"
|
||||||
|
HorizontalAlignment="Center" Margin="0,0,0,20"/>
|
||||||
|
|
||||||
|
<!-- Filters -->
|
||||||
|
<GroupBox Grid.Row="1" Header="Filter" Margin="0,0,0,15">
|
||||||
|
<Grid Margin="10">
|
||||||
|
<Grid.RowDefinitions>
|
||||||
|
<RowDefinition Height="Auto"/>
|
||||||
|
<RowDefinition Height="Auto"/>
|
||||||
|
</Grid.RowDefinitions>
|
||||||
|
|
||||||
|
<!-- Filters -->
|
||||||
|
<StackPanel Grid.Row="0" Orientation="Horizontal" Margin="0,0,0,10">
|
||||||
|
<Label Content="Marke:" VerticalAlignment="Center" Width="60"/>
|
||||||
|
<ComboBox Name="cmbFilterMarke" Width="130" Height="25" Margin="5,0,15,0"/>
|
||||||
|
|
||||||
|
<Label Content="Modell:" VerticalAlignment="Center" Width="60"/>
|
||||||
|
<ComboBox Name="cmbFilterModell" Width="130" Height="25" Margin="5,0,15,0"/>
|
||||||
|
|
||||||
|
<Label Content="Kraftstoff:" VerticalAlignment="Center" Width="70"/>
|
||||||
|
<ComboBox Name="cmbFilterKraftstoff" Width="100" Height="25" Margin="5,0,15,0"/>
|
||||||
|
|
||||||
|
<Label Content="Getriebe:" VerticalAlignment="Center" Width="60"/>
|
||||||
|
<ComboBox Name="cmbFilterGetriebe" Width="130" Height="25" Margin="5,0,15,0"/>
|
||||||
|
</StackPanel>
|
||||||
|
|
||||||
|
<!-- Action knöpfe -->
|
||||||
|
<StackPanel Grid.Row="1" Orientation="Horizontal" HorizontalAlignment="Right">
|
||||||
|
<Button Name="kofAktuali" Content="Filter Anwenden"
|
||||||
|
Width="120" Height="25" Margin="5,0"
|
||||||
|
Click="Aktualisieren"/>
|
||||||
|
<Button Name="FilZurücksetze" Content="Filter Zurücksetzen"
|
||||||
|
Width="130" Height="25" Margin="5,0"
|
||||||
|
Click="Zurücksetzen"/>
|
||||||
|
</StackPanel>
|
||||||
|
</Grid>
|
||||||
|
</GroupBox>
|
||||||
|
|
||||||
|
<!-- Fahrzeuge Liste -->
|
||||||
|
<DataGrid Grid.Row="2" Name="dgFahrzeuge"
|
||||||
|
AutoGenerateColumns="False"
|
||||||
|
IsReadOnly="True"
|
||||||
|
CanUserResizeColumns="True"
|
||||||
|
CanUserSortColumns="False"
|
||||||
|
GridLinesVisibility="Horizontal"
|
||||||
|
AlternatingRowBackground="LightGray">
|
||||||
|
<DataGrid.Columns>
|
||||||
|
<DataGridTextColumn Header="ID" Binding="{Binding FahrzeugID}" Width="50"/>
|
||||||
|
<DataGridTextColumn Header="Marke" Binding="{Binding Modell.Marke.Markenname}" Width="100"/>
|
||||||
|
<DataGridTextColumn Header="Modell" Binding="{Binding Modell.Modellname}" Width="120"/>
|
||||||
|
<DataGridTextColumn Header="Getriebe" Binding="{Binding Getriebe}" Width="100"/>
|
||||||
|
<DataGridTextColumn Header="Kraftstoff" Binding="{Binding Kraftstoff}" Width="100"/>
|
||||||
|
<DataGridTextColumn Header="Baujahr" Binding="{Binding Baujahr}" Width="80"/>
|
||||||
|
<DataGridTextColumn Header="Farbe" Binding="{Binding Farbe}" Width="80"/>
|
||||||
|
<DataGridTextColumn Header="Kilometer" Binding="{Binding Kilometerstand}" Width="100"/>
|
||||||
|
<DataGridTextColumn Header="Beschreibung" Binding="{Binding Beschreibung}" Width="*"/>
|
||||||
|
</DataGrid.Columns>
|
||||||
|
</DataGrid>
|
||||||
|
|
||||||
|
<!-- Schließen knopf -->
|
||||||
|
<!-- PDF -->
|
||||||
|
<StackPanel Grid.Row="3" Orientation="Horizontal"
|
||||||
|
HorizontalAlignment="Center" Margin="0,15,0,0">
|
||||||
|
<Label Content="Fahrzeug ID:" VerticalAlignment="Center" Margin="0,0,5,0"/>
|
||||||
|
<TextBox Name="txtFahrzeugID" Width="80" Height="25" Margin="0,0,10,0"/>
|
||||||
|
<Button Name="PDFErstellen" Content="PDF Erstellen"
|
||||||
|
Width="100" Height="25" Margin="0,0,20,0"
|
||||||
|
Click="Erstellen"/>
|
||||||
|
<Button Name="kpfsch" Content="Schließen"
|
||||||
|
Width="120" Height="35"
|
||||||
|
Click="Schließ"/>
|
||||||
|
</StackPanel>
|
||||||
|
|
||||||
|
</Grid>
|
||||||
|
</Window>
|
215
FahrzeugProjekt/FahrzeugAnzeigenWindow.xaml.cs
Normal file
215
FahrzeugProjekt/FahrzeugAnzeigenWindow.xaml.cs
Normal file
@ -0,0 +1,215 @@
|
|||||||
|
using System.IO;
|
||||||
|
using System.Windows;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using Microsoft.Win32;
|
||||||
|
using PdfSharp.Drawing;
|
||||||
|
using PdfSharp.Fonts;
|
||||||
|
using PdfSharp.Pdf;
|
||||||
|
|
||||||
|
namespace FahrzeugProjekt
|
||||||
|
{
|
||||||
|
public partial class FahrzeugeAnzeigenWindow : Window
|
||||||
|
{
|
||||||
|
private FahrzeugProjektKontext Kontext;
|
||||||
|
private List<Fahrzeug> alleFahrzeuge;
|
||||||
|
public MainWindow main { get; set; }
|
||||||
|
|
||||||
|
public FahrzeugeAnzeigenWindow(FahrzeugProjektKontext dbKontext)
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
this.WindowState = WindowState.Maximized;
|
||||||
|
Kontext = dbKontext;
|
||||||
|
|
||||||
|
// font resolver
|
||||||
|
GlobalFontSettings.FontResolver = new SimpleFontResolver();
|
||||||
|
|
||||||
|
|
||||||
|
this.Loaded += (sender, e) =>
|
||||||
|
{
|
||||||
|
FahrzeugeDatenLaden();
|
||||||
|
Vorbereitung();
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
private void FahrzeugeDatenLaden()
|
||||||
|
{
|
||||||
|
alleFahrzeuge = Kontext.Fahrzeuge
|
||||||
|
.Include(f => f.Modell)
|
||||||
|
.ThenInclude(m => m.Marke)
|
||||||
|
.ToList();
|
||||||
|
|
||||||
|
dgFahrzeuge.ItemsSource = alleFahrzeuge;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void Vorbereitung()
|
||||||
|
{
|
||||||
|
// Marken für Filter laden
|
||||||
|
List<Marke> markenFürFilter = new List<Marke> { new Marke { MarkeID = -1, Markenname = "Alle Marken" } };
|
||||||
|
List<Marke> alleMarken = Kontext.Marken.ToList();
|
||||||
|
markenFürFilter.AddRange(alleMarken);
|
||||||
|
cmbFilterMarke.ItemsSource = markenFürFilter;
|
||||||
|
cmbFilterMarke.DisplayMemberPath = "Markenname";
|
||||||
|
cmbFilterMarke.SelectedIndex = 0;
|
||||||
|
|
||||||
|
// Alle Modelle für Filter laden
|
||||||
|
List<Modell> modelleFürFilter = new List<Modell> { new Modell { ModellID = -1, Modellname = "Alle Modelle" } };
|
||||||
|
List<Modell> alleModelle = Kontext.Modelle.ToList();
|
||||||
|
modelleFürFilter.AddRange(alleModelle);
|
||||||
|
cmbFilterModell.ItemsSource = modelleFürFilter;
|
||||||
|
cmbFilterModell.DisplayMemberPath = "Modellname";
|
||||||
|
cmbFilterModell.SelectedIndex = 0;
|
||||||
|
|
||||||
|
// Kraftstoffe für Filter
|
||||||
|
List<string> kraftstoffListe = new List<string> { "Alle", "Benzin", "Diesel", "Elektro", "Hybrid" };
|
||||||
|
cmbFilterKraftstoff.ItemsSource = kraftstoffListe;
|
||||||
|
cmbFilterKraftstoff.SelectedIndex = 0;
|
||||||
|
|
||||||
|
// Getriebe für Filter
|
||||||
|
List<string> getriebeListe = new List<string> { "Alle", "Manuell", "Automatik", "Halbautomatik" };
|
||||||
|
cmbFilterGetriebe.ItemsSource = getriebeListe;
|
||||||
|
cmbFilterGetriebe.SelectedIndex = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void Erstellen(object sender, RoutedEventArgs e)
|
||||||
|
{
|
||||||
|
int fahrzeugID = int.Parse(txtFahrzeugID.Text);
|
||||||
|
|
||||||
|
Fahrzeug fahrzeug = alleFahrzeuge.FirstOrDefault(f => f.FahrzeugID == fahrzeugID);
|
||||||
|
|
||||||
|
SaveFileDialog saveDialog = new SaveFileDialog
|
||||||
|
{
|
||||||
|
FileName = $"{fahrzeug.FahrzeugID}.pdf"
|
||||||
|
};
|
||||||
|
|
||||||
|
if (saveDialog.ShowDialog() == true)
|
||||||
|
{
|
||||||
|
CreateVehiclePDF(fahrzeug, saveDialog.FileName);
|
||||||
|
MessageBox.Show("PDF erfolgreich erstellt!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void CreateVehiclePDF(Fahrzeug fahrzeug, string filePath)
|
||||||
|
{
|
||||||
|
// PDF erstellen
|
||||||
|
PdfDocument document = new PdfDocument();
|
||||||
|
PdfPage page = document.AddPage();
|
||||||
|
XGraphics gfx = XGraphics.FromPdfPage(page);
|
||||||
|
XFont font = new XFont("Arial", 12);
|
||||||
|
XFont titleFont = new XFont("Arial", 16);
|
||||||
|
|
||||||
|
// start pos
|
||||||
|
double yPos = 50;
|
||||||
|
double lineHeight = 25;
|
||||||
|
|
||||||
|
// Title
|
||||||
|
gfx.DrawString("Fahrzeug Information", titleFont, XBrushes.Black, 50, yPos);
|
||||||
|
yPos += lineHeight * 2;
|
||||||
|
|
||||||
|
// Vehicle details
|
||||||
|
gfx.DrawString($"Fahrzeug ID: {fahrzeug.FahrzeugID}", font, XBrushes.Black, 50, yPos);
|
||||||
|
yPos += lineHeight;
|
||||||
|
|
||||||
|
gfx.DrawString($"Marke: {fahrzeug.Modell?.Marke?.Markenname ?? "N/A"}", font, XBrushes.Black, 50, yPos);
|
||||||
|
yPos += lineHeight;
|
||||||
|
|
||||||
|
gfx.DrawString($"Modell: {fahrzeug.Modell?.Modellname ?? "N/A"}", font, XBrushes.Black, 50, yPos);
|
||||||
|
yPos += lineHeight;
|
||||||
|
|
||||||
|
gfx.DrawString($"Baujahr: {fahrzeug.Baujahr}", font, XBrushes.Black, 50, yPos);
|
||||||
|
yPos += lineHeight;
|
||||||
|
|
||||||
|
gfx.DrawString($"Kraftstoff: {fahrzeug.Kraftstoff ?? "N/A"}", font, XBrushes.Black, 50, yPos);
|
||||||
|
yPos += lineHeight;
|
||||||
|
|
||||||
|
gfx.DrawString($"Getriebe: {fahrzeug.Getriebe ?? "N/A"}", font, XBrushes.Black, 50, yPos);
|
||||||
|
yPos += lineHeight;
|
||||||
|
|
||||||
|
gfx.DrawString($"Kilometerstand: {fahrzeug.Kilometerstand} km", font, XBrushes.Black, 50, yPos);
|
||||||
|
|
||||||
|
// Save
|
||||||
|
document.Save(filePath);
|
||||||
|
document.Close();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void Aktualisieren(object sender, RoutedEventArgs e)
|
||||||
|
{
|
||||||
|
List<Fahrzeug> ergebnisse = alleFahrzeuge.ToList();
|
||||||
|
|
||||||
|
// Marken Filter
|
||||||
|
Marke ausgewählteMarke = cmbFilterMarke.SelectedItem as Marke;
|
||||||
|
if (ausgewählteMarke.MarkeID != -1)
|
||||||
|
{
|
||||||
|
ergebnisse = ergebnisse
|
||||||
|
.Where(f => f.Modell.MarkeID == ausgewählteMarke.MarkeID)
|
||||||
|
.ToList();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Modell Filter
|
||||||
|
Modell ausgewähltesModell = cmbFilterModell.SelectedItem as Modell;
|
||||||
|
if (ausgewähltesModell.ModellID != -1)
|
||||||
|
{
|
||||||
|
ergebnisse = ergebnisse
|
||||||
|
.Where(f => f.ModellID == ausgewähltesModell.ModellID)
|
||||||
|
.ToList();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Kraftstoff Filter
|
||||||
|
if (cmbFilterKraftstoff.SelectedItem.ToString() != "Alle")
|
||||||
|
{
|
||||||
|
string ausgewählterKraftstoff = cmbFilterKraftstoff.SelectedItem.ToString();
|
||||||
|
ergebnisse = ergebnisse
|
||||||
|
.Where(f => f.Kraftstoff == ausgewählterKraftstoff)
|
||||||
|
.ToList();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Getriebe Filter
|
||||||
|
if (cmbFilterGetriebe.SelectedItem.ToString() != "Alle")
|
||||||
|
{
|
||||||
|
string ausgewähltesGetriebe = cmbFilterGetriebe.SelectedItem.ToString();
|
||||||
|
ergebnisse = ergebnisse
|
||||||
|
.Where(f => f.Getriebe == ausgewähltesGetriebe)
|
||||||
|
.ToList();
|
||||||
|
}
|
||||||
|
|
||||||
|
dgFahrzeuge.ItemsSource = ergebnisse;
|
||||||
|
this.Title = $"Fahrzeuge Anzeigen ({ergebnisse.Count} von {alleFahrzeuge.Count})";
|
||||||
|
}
|
||||||
|
|
||||||
|
private void Zurücksetzen(object sender, RoutedEventArgs e)
|
||||||
|
{
|
||||||
|
cmbFilterMarke.SelectedIndex = 0;
|
||||||
|
cmbFilterModell.SelectedIndex = 0;
|
||||||
|
cmbFilterKraftstoff.SelectedIndex = 0;
|
||||||
|
cmbFilterGetriebe.SelectedIndex = 0;
|
||||||
|
|
||||||
|
dgFahrzeuge.ItemsSource = alleFahrzeuge;
|
||||||
|
this.Title = "Fahrzeuge Anzeigen";
|
||||||
|
}
|
||||||
|
|
||||||
|
private void Schließ(object sender, RoutedEventArgs e)
|
||||||
|
{
|
||||||
|
this.Close();
|
||||||
|
main.Show();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Font resolver
|
||||||
|
public class SimpleFontResolver : IFontResolver
|
||||||
|
{
|
||||||
|
public FontResolverInfo ResolveTypeface(string familyName, bool isBold, bool isItalic)
|
||||||
|
{
|
||||||
|
return new FontResolverInfo("Arial");
|
||||||
|
}
|
||||||
|
|
||||||
|
public byte[] GetFont(string faceName)
|
||||||
|
{
|
||||||
|
string windowsFontsPath = Path.Combine(
|
||||||
|
Environment.GetFolderPath(Environment.SpecialFolder.Windows), "Fonts");
|
||||||
|
string fontPath = Path.Combine(windowsFontsPath, "arial.ttf");
|
||||||
|
|
||||||
|
return File.ReadAllBytes(fontPath);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
68
FahrzeugProjekt/FahrzeugEintragenWindow.xaml
Normal file
68
FahrzeugProjekt/FahrzeugEintragenWindow.xaml
Normal file
@ -0,0 +1,68 @@
|
|||||||
|
<Window x:Class="FahrzeugProjekt.FahrzeugEintragenWindow"
|
||||||
|
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:FahrzeugProjekt"
|
||||||
|
mc:Ignorable="d"
|
||||||
|
Title="Neues Fahrzeug Eintragen" Height="600" Width="500"
|
||||||
|
WindowStartupLocation="CenterScreen">
|
||||||
|
<Grid Margin="20">
|
||||||
|
<Grid.RowDefinitions>
|
||||||
|
<RowDefinition Height="Auto"/>
|
||||||
|
<RowDefinition Height="*"/>
|
||||||
|
<RowDefinition Height="Auto"/>
|
||||||
|
</Grid.RowDefinitions>
|
||||||
|
<!-- Titel -->
|
||||||
|
<TextBlock Grid.Row="0" Text="Neues Fahrzeug Hinzufügen"
|
||||||
|
FontSize="20" FontWeight="Bold"
|
||||||
|
HorizontalAlignment="Center" Margin="0,0,0,20"/>
|
||||||
|
<!-- Eingabeformular -->
|
||||||
|
<ScrollViewer Grid.Row="1" VerticalScrollBarVisibility="Auto">
|
||||||
|
<StackPanel>
|
||||||
|
<!-- Modell auswählen -->
|
||||||
|
<Label Content="Modell:" FontWeight="Bold"/>
|
||||||
|
<ComboBox Name="cmbModell" Margin="0,0,0,10" Height="25"/>
|
||||||
|
<!-- Getriebe -->
|
||||||
|
<Label Content="Getriebe:" FontWeight="Bold"/>
|
||||||
|
<ComboBox Name="cmbGetriebe" Margin="0,0,0,10" Height="25">
|
||||||
|
<ComboBoxItem Content="Manuell"/>
|
||||||
|
<ComboBoxItem Content="Automatik"/>
|
||||||
|
<ComboBoxItem Content="Halbautomatik"/>
|
||||||
|
</ComboBox>
|
||||||
|
<!-- Kraftstoff -->
|
||||||
|
<Label Content="Kraftstoff:" FontWeight="Bold"/>
|
||||||
|
<ComboBox Name="cmbKraftstoff" Margin="0,0,0,10" Height="25">
|
||||||
|
<ComboBoxItem Content="Benzin"/>
|
||||||
|
<ComboBoxItem Content="Diesel"/>
|
||||||
|
<ComboBoxItem Content="Elektro"/>
|
||||||
|
<ComboBoxItem Content="Hybrid"/>
|
||||||
|
</ComboBox>
|
||||||
|
<!-- Baujahr -->
|
||||||
|
<Label Content="Baujahr:" FontWeight="Bold"/>
|
||||||
|
<TextBox Name="txtBaujahr" Margin="0,0,0,10" Height="25"/>
|
||||||
|
<!-- Farbe -->
|
||||||
|
<Label Content="Farbe:" FontWeight="Bold"/>
|
||||||
|
<TextBox Name="txtFarbe" Margin="0,0,0,10" Height="25"/>
|
||||||
|
<!-- Kilometerstand -->
|
||||||
|
<Label Content="Kilometerstand:" FontWeight="Bold"/>
|
||||||
|
<TextBox Name="txtKilometer" Margin="0,0,0,10" Height="25"/>
|
||||||
|
<!-- Beschreibung -->
|
||||||
|
<Label Content="Beschreibung:" FontWeight="Bold"/>
|
||||||
|
<TextBox Name="txtBeschreibung" Margin="0,0,0,20" Height="80"
|
||||||
|
TextWrapping="Wrap" AcceptsReturn="True"
|
||||||
|
VerticalScrollBarVisibility="Auto"/>
|
||||||
|
</StackPanel>
|
||||||
|
</ScrollViewer>
|
||||||
|
<!-- Buttons -->
|
||||||
|
<StackPanel Grid.Row="2" Orientation="Horizontal"
|
||||||
|
HorizontalAlignment="Center" Margin="0,20,0,0">
|
||||||
|
<Button Name="kpfSpeichern" Content="Speichern"
|
||||||
|
Width="100" Height="35" Margin="10,0"
|
||||||
|
Click="Speichern"/>
|
||||||
|
<Button Name="KpfAbbrechen" Content="Abbrechen"
|
||||||
|
Width="100" Height="35" Margin="10,0"
|
||||||
|
Click="Abbrechen"/>
|
||||||
|
</StackPanel>
|
||||||
|
</Grid>
|
||||||
|
</Window>
|
119
FahrzeugProjekt/FahrzeugEintragenWindow.xaml.cs
Normal file
119
FahrzeugProjekt/FahrzeugEintragenWindow.xaml.cs
Normal file
@ -0,0 +1,119 @@
|
|||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using System.Windows;
|
||||||
|
using System.Windows.Controls;
|
||||||
|
namespace FahrzeugProjekt
|
||||||
|
{
|
||||||
|
public partial class FahrzeugEintragenWindow : Window
|
||||||
|
{
|
||||||
|
private FahrzeugProjektKontext Kontext;
|
||||||
|
bool idk;
|
||||||
|
public MainWindow main { get; set; }
|
||||||
|
|
||||||
|
public FahrzeugEintragenWindow(FahrzeugProjektKontext dbKontext)
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
Kontext = dbKontext;
|
||||||
|
DatenLaden();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void DatenLaden()
|
||||||
|
{
|
||||||
|
List<Modell> alleModelle = Kontext.Modelle.ToList();
|
||||||
|
cmbModell.ItemsSource = alleModelle;
|
||||||
|
cmbModell.DisplayMemberPath = "Modellname";
|
||||||
|
}
|
||||||
|
|
||||||
|
private void Speichern(object sender, RoutedEventArgs e)
|
||||||
|
{
|
||||||
|
idk = EingabenValidieren();
|
||||||
|
if (idk == false)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Modell ausgewähltesModell = cmbModell.SelectedItem as Modell;
|
||||||
|
Fahrzeug neuesFahrzeug = new Fahrzeug
|
||||||
|
{
|
||||||
|
ModellID = ausgewähltesModell.ModellID,
|
||||||
|
Getriebe = ((ComboBoxItem)cmbGetriebe.SelectedItem).Content.ToString(),
|
||||||
|
Kraftstoff = ((ComboBoxItem)cmbKraftstoff.SelectedItem).Content.ToString(),
|
||||||
|
Baujahr = int.Parse(txtBaujahr.Text),
|
||||||
|
Farbe = txtFarbe.Text.Trim(),
|
||||||
|
Kilometerstand = int.Parse(txtKilometer.Text),
|
||||||
|
Beschreibung = txtBeschreibung.Text.Trim()
|
||||||
|
};
|
||||||
|
|
||||||
|
Kontext.Fahrzeuge.Add(neuesFahrzeug);
|
||||||
|
Kontext.SaveChanges();
|
||||||
|
|
||||||
|
MessageBox.Show("Fahrzeug erfolgreich gespeichert!");
|
||||||
|
this.Close();
|
||||||
|
main.Show();
|
||||||
|
}
|
||||||
|
|
||||||
|
private bool EingabenValidieren()
|
||||||
|
{
|
||||||
|
if (cmbModell.SelectedItem == null)
|
||||||
|
{
|
||||||
|
MessageBox.Show("Bitte wählen Sie ein Modell aus!");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (cmbGetriebe.SelectedItem == null)
|
||||||
|
{
|
||||||
|
MessageBox.Show("Bitte wählen Sie ein Getriebe aus!");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (cmbKraftstoff.SelectedItem == null)
|
||||||
|
{
|
||||||
|
MessageBox.Show("Bitte wählen Sie einen Kraftstoff aus!");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
int baujahr = Convert.ToInt32(txtBaujahr.Text);
|
||||||
|
if (baujahr < 1900)
|
||||||
|
{
|
||||||
|
MessageBox.Show("Bitte geben Sie ein gültiges Baujahr ein!");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
MessageBox.Show("Bitte geben Sie ein gültiges Baujahr ein!");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (string.IsNullOrWhiteSpace(txtFarbe.Text))
|
||||||
|
{
|
||||||
|
MessageBox.Show("Bitte geben Sie eine Farbe ein!");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
int km = Convert.ToInt32(txtKilometer.Text);
|
||||||
|
if (km < 0)
|
||||||
|
{
|
||||||
|
MessageBox.Show("Bitte geben Sie einen gültigen Kilometerstand ein!");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
MessageBox.Show("Bitte geben Sie einen gültigen Kilometerstand ein!");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void Abbrechen(object sender, RoutedEventArgs e)
|
||||||
|
{
|
||||||
|
this.Close();
|
||||||
|
main.Show();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
31
FahrzeugProjekt/FahrzeugProjekt.csproj
Normal file
31
FahrzeugProjekt/FahrzeugProjekt.csproj
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<OutputType>WinExe</OutputType>
|
||||||
|
<TargetFramework>net9.0-windows</TargetFramework>
|
||||||
|
<Nullable>enable</Nullable>
|
||||||
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
|
<UseWPF>true</UseWPF>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="9.0.8" />
|
||||||
|
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="9.0.8" />
|
||||||
|
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="9.0.8">
|
||||||
|
<PrivateAssets>all</PrivateAssets>
|
||||||
|
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||||
|
</PackageReference>
|
||||||
|
<PackageReference Include="Microsoft.Extensions.Configuration" Version="9.0.8" />
|
||||||
|
<PackageReference Include="Microsoft.Extensions.Configuration.Binder" Version="9.0.8" />
|
||||||
|
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="9.0.8" />
|
||||||
|
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="9.0.8" />
|
||||||
|
<PackageReference Include="PDFsharp" Version="6.2.1" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<None Update="appsettings.json">
|
||||||
|
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||||
|
</None>
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
</Project>
|
38
FahrzeugProjekt/FahrzeugeProjektKontext.cs
Normal file
38
FahrzeugProjekt/FahrzeugeProjektKontext.cs
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
|
||||||
|
|
||||||
|
namespace FahrzeugProjekt
|
||||||
|
{
|
||||||
|
public class FahrzeugProjektKontext : DbContext
|
||||||
|
{
|
||||||
|
public DbSet<Arbeiter> Arbeiter { get; set; }
|
||||||
|
public DbSet<Ort> Orte { get; set; }
|
||||||
|
public DbSet<Marke> Marken { get; set; }
|
||||||
|
public DbSet<Modell> Modelle { get; set; }
|
||||||
|
public DbSet<Fahrzeug> Fahrzeuge { get; set; }
|
||||||
|
|
||||||
|
public FahrzeugProjektKontext(DbContextOptions<FahrzeugProjektKontext> options)
|
||||||
|
: base(options)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
||||||
|
{
|
||||||
|
|
||||||
|
modelBuilder.Entity<Marke>()
|
||||||
|
.HasMany(m => m.Modelle)
|
||||||
|
.WithOne(mo => mo.Marke)
|
||||||
|
.HasForeignKey(mo => mo.MarkeID);
|
||||||
|
|
||||||
|
modelBuilder.Entity<Modell>()
|
||||||
|
.HasMany(mo => mo.Fahrzeuge)
|
||||||
|
.WithOne(f => f.Modell)
|
||||||
|
.HasForeignKey(f => f.ModellID);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
43
FahrzeugProjekt/MainWindow.xaml
Normal file
43
FahrzeugProjekt/MainWindow.xaml
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
<Window x:Class="FahrzeugProjekt.MainWindow"
|
||||||
|
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:FahrzeugProjekt"
|
||||||
|
mc:Ignorable="d"
|
||||||
|
Title="Fahrzeug Verwaltung" Height="450" Width="800"
|
||||||
|
WindowStartupLocation="CenterScreen">
|
||||||
|
|
||||||
|
<Grid>
|
||||||
|
<Grid.RowDefinitions>
|
||||||
|
<RowDefinition Height="Auto"/>
|
||||||
|
<RowDefinition Height="*"/>
|
||||||
|
<RowDefinition Height="Auto"/>
|
||||||
|
</Grid.RowDefinitions>
|
||||||
|
|
||||||
|
<!-- Kopfzeile -->
|
||||||
|
<TextBlock Grid.Row="0" Text="Fahrzeug Verwaltungssystem"
|
||||||
|
FontSize="24" FontWeight="Bold"
|
||||||
|
HorizontalAlignment="Center"
|
||||||
|
Margin="20"/>
|
||||||
|
|
||||||
|
<!-- main -->
|
||||||
|
<StackPanel Grid.Row="1" HorizontalAlignment="Center" VerticalAlignment="Center">
|
||||||
|
<TextBlock Text="Wählen Sie eine Aktion:" FontSize="16"
|
||||||
|
HorizontalAlignment="Center" Margin="0,0,0,30"/>
|
||||||
|
|
||||||
|
<Button Name="FahAnzeigen" Content="Fahrzeuge Anzeigen"
|
||||||
|
Width="180" Height="50" Margin="10"
|
||||||
|
FontSize="14" Click="Anzeigen"/>
|
||||||
|
|
||||||
|
<Button Name="FahEintragen" Content="Neues Fahrzeug Eintragen"
|
||||||
|
Width="180" Height="50" Margin="10"
|
||||||
|
FontSize="14" Click="Eintragen"/>
|
||||||
|
</StackPanel>
|
||||||
|
|
||||||
|
<!-- Fußzeile -->
|
||||||
|
<TextBlock Grid.Row="2" Text="Firmen Fahrzeug Verwaltung"
|
||||||
|
HorizontalAlignment="Center"
|
||||||
|
Foreground="Gray" Margin="10"/>
|
||||||
|
</Grid>
|
||||||
|
</Window>
|
35
FahrzeugProjekt/MainWindow.xaml.cs
Normal file
35
FahrzeugProjekt/MainWindow.xaml.cs
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
|
using System.Windows;
|
||||||
|
|
||||||
|
namespace FahrzeugProjekt
|
||||||
|
{
|
||||||
|
public partial class MainWindow : Window
|
||||||
|
{
|
||||||
|
private IServiceProvider service;
|
||||||
|
|
||||||
|
public MainWindow(IServiceProvider serviceProvider)
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
service = serviceProvider; // Speichern für später
|
||||||
|
}
|
||||||
|
|
||||||
|
private void Anzeigen(object sender, RoutedEventArgs e)
|
||||||
|
{
|
||||||
|
// Fenster von anzeigen öffnen
|
||||||
|
FahrzeugeAnzeigenWindow fahrzeugeAnzeigenFenster = service.GetRequiredService<FahrzeugeAnzeigenWindow>();
|
||||||
|
fahrzeugeAnzeigenFenster.main = this; // Referenz von MainWindow
|
||||||
|
fahrzeugeAnzeigenFenster.Show();// Window zeigen
|
||||||
|
this.Hide();//window verstecken
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private void Eintragen(object sender, RoutedEventArgs e)
|
||||||
|
{
|
||||||
|
// Fenster von eintragen öffnen
|
||||||
|
FahrzeugEintragenWindow fahrzeugEintragenFenster = service.GetRequiredService<FahrzeugEintragenWindow>();
|
||||||
|
fahrzeugEintragenFenster.main = this;
|
||||||
|
fahrzeugEintragenFenster.Show();
|
||||||
|
this.Hide();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
19
FahrzeugProjekt/Marke.cs
Normal file
19
FahrzeugProjekt/Marke.cs
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
using System.ComponentModel.DataAnnotations.Schema;
|
||||||
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
|
||||||
|
namespace FahrzeugProjekt
|
||||||
|
{
|
||||||
|
[Table("Marken")]
|
||||||
|
public class Marke
|
||||||
|
{
|
||||||
|
[Column("MarkenID")] // DB hat MarkenID, nicht MarkeID
|
||||||
|
public int MarkeID { get; set; }
|
||||||
|
|
||||||
|
[Column("Name")] // DB hat Name, nicht Markenname
|
||||||
|
public string Markenname { get; set; }
|
||||||
|
|
||||||
|
public ICollection<Modell> Modelle { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
22
FahrzeugProjekt/Modell.cs
Normal file
22
FahrzeugProjekt/Modell.cs
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
using System.ComponentModel.DataAnnotations.Schema;
|
||||||
|
|
||||||
|
namespace FahrzeugProjekt
|
||||||
|
{
|
||||||
|
[Table("Modelle")]
|
||||||
|
public class Modell
|
||||||
|
{
|
||||||
|
[Column("ModellID")]
|
||||||
|
public int ModellID { get; set; }
|
||||||
|
|
||||||
|
[Column("Name")] // DB hat Name, nicht Modellname
|
||||||
|
public string Modellname { get; set; }
|
||||||
|
|
||||||
|
[Column("MarkenID")] // DB hat MarkenID, nicht MarkeID
|
||||||
|
public int MarkeID { get; set; }
|
||||||
|
|
||||||
|
public Marke Marke { get; set; }
|
||||||
|
public ICollection<Fahrzeug> Fahrzeuge { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
18
FahrzeugProjekt/Ort.cs
Normal file
18
FahrzeugProjekt/Ort.cs
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
using System.ComponentModel.DataAnnotations.Schema;
|
||||||
|
|
||||||
|
namespace FahrzeugProjekt
|
||||||
|
{
|
||||||
|
[Table("Orte")]
|
||||||
|
public class Ort
|
||||||
|
{
|
||||||
|
[Column("OrtID")]
|
||||||
|
public int OrtID { get; set; }
|
||||||
|
|
||||||
|
[Column("Stadt")] // DB hat Stadt, nicht Stadtname
|
||||||
|
public string Stadtname { get; set; }
|
||||||
|
|
||||||
|
[Column("Land")] // Zusätzliche Spalte die du hast
|
||||||
|
public string Land { get; set; }
|
||||||
|
}
|
||||||
|
}
|
5
FahrzeugProjekt/appsettings.json
Normal file
5
FahrzeugProjekt/appsettings.json
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
{
|
||||||
|
"ConnectionStrings": {
|
||||||
|
"FahrzeugProjektConnection": "Server=NBSTUD;Database=FahrzeugProjekt;Trusted_Connection=True;TrustServerCertificate=True;"
|
||||||
|
}
|
||||||
|
}
|
68
README.md
Normal file
68
README.md
Normal file
@ -0,0 +1,68 @@
|
|||||||
|
Fahrzeugverwaltung
|
||||||
|
|
||||||
|
Dies ist ein einfaches Projekt zur Verwaltung von Fahrzeugen. Es wurde im Rahmen eines Projekts an der Universität entwickelt. Die Anwendung ist mit .NET 9.0, Entity Framework Core und PdfSharp gebaut worden.
|
||||||
|
|
||||||
|
Projektbeschreibung
|
||||||
|
|
||||||
|
Die Anwendung erlaubt es, Fahrzeuge in einer Datenbank zu speichern, anzuzeigen und als PDF zu exportieren. Dabei werden Informationen zu Auto, Marke und Modell verwaltet.
|
||||||
|
|
||||||
|
Verwendete Technologien
|
||||||
|
|
||||||
|
.NET 9.0 – Für die Entwicklung der Anwendung.
|
||||||
|
|
||||||
|
Entity Framework Core (EF Core) – Für den Datenbankzugriff.
|
||||||
|
|
||||||
|
PdfSharp – Um PDF-Dateien zu erstellen.
|
||||||
|
|
||||||
|
Dependency Injection (DI) – Um Klassen flexibel zu verbinden.
|
||||||
|
|
||||||
|
Aufbau des Projekts
|
||||||
|
1. Modelle
|
||||||
|
|
||||||
|
Es gibt drei Hauptmodelle, die den Tabellen in der Datenbank entsprechen:
|
||||||
|
|
||||||
|
Auto
|
||||||
|
|
||||||
|
Marke
|
||||||
|
|
||||||
|
Modell
|
||||||
|
|
||||||
|
Diese Modelle enthalten Eigenschaften wie z. B. Name, Baujahr, oder Marke-ID. Sie bilden die Struktur der Datenbank ab.
|
||||||
|
|
||||||
|
2. Datenbank-Kontext
|
||||||
|
|
||||||
|
Es wurde eine Klasse FahrzeugDbContext erstellt, die von DbContext erbt. Sie verwaltet die Verbindung zur Datenbank. Alle Tabellen (Auto, Marke, Modell) sind als DbSet definiert.
|
||||||
|
|
||||||
|
3. Dependency Injection
|
||||||
|
|
||||||
|
Die Anwendung nutzt Dependency Injection, um bei jedem Zugriff eine neue Instanz des FahrzeugDbContext zu erstellen. So wird sichergestellt, dass der Datenbankzugriff immer aktuell ist und keine alten Daten verwendet werden.
|
||||||
|
|
||||||
|
Beispiel:
|
||||||
|
|
||||||
|
FahrzeugEintragenWindow fenster = service.GetRequiredService<FahrzeugEintragenWindow>();
|
||||||
|
|
||||||
|
|
||||||
|
Hier wird ein neues Fenster mit allen nötigen Diensten geöffnet.
|
||||||
|
|
||||||
|
4. Benutzeroberfläche (UI)
|
||||||
|
|
||||||
|
Die Anwendung hat ein Hauptfenster (MainWindow). Von dort kann man:
|
||||||
|
|
||||||
|
Neue Fahrzeuge eintragen
|
||||||
|
|
||||||
|
Bestehende Fahrzeuge anzeigen
|
||||||
|
|
||||||
|
Beide Fenster (FahrzeugEintragenWindow und FahrzeugeAnzeigenWindow) werden über den Dienstanbieter geöffnet. Danach wird das Hauptfenster versteckt.
|
||||||
|
|
||||||
|
Beispielcode: MainWindow
|
||||||
|
private void Eintragen(object sender, RoutedEventArgs e)
|
||||||
|
{
|
||||||
|
FahrzeugEintragenWindow fenster = service.GetRequiredService<FahrzeugEintragenWindow>();
|
||||||
|
fenster.main = this;
|
||||||
|
fenster.Show();
|
||||||
|
this.Hide();
|
||||||
|
}
|
||||||
|
|
||||||
|
Fazit
|
||||||
|
|
||||||
|
Mit diesem Projekt konnte gezeigt werden, wie man moderne .NET-Technologien verwendet, um eine einfache, aber funktionale Desktop-Anwendung zur Verwaltung von Fahrzeugen zu bauen. Die Trennung der Datenmodelle, der Datenbank und der Benutzeroberfläche sorgt für einen übersichtlichen Aufbau.
|
Loading…
x
Reference in New Issue
Block a user