Grundlegene Funktionen geschrieben

This commit is contained in:
2023-06-09 15:53:11 +02:00
parent 2c4e8fb4cb
commit fd84775aa4
26 changed files with 721 additions and 4 deletions

View File

@@ -13,5 +13,30 @@ namespace dcnsanplanung.wpf
/// </summary>
public partial class App : Application
{
protected override void OnStartup(StartupEventArgs e)
{
Application.Current.DispatcherUnhandledException += Current_DispatcherUnhandledException;
AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;
base.OnStartup(e);
}
private void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
{
try
{
Exception ex = (Exception)e.ExceptionObject;
string text = "An application error occured. Plrease contact the Administrator with the following information:\n\n";
MessageBox.Show(text + " " + ex.Message + "\n\n" + ex.StackTrace);
}
catch (Exception ex2)
{
MessageBox.Show("Fatal Non-UI error", ex2.Message, MessageBoxButton.OK, MessageBoxImage.Error);
}
}
private void Current_DispatcherUnhandledException(object sender, System.Windows.Threading.DispatcherUnhandledExceptionEventArgs e)
{
throw new NotImplementedException();
}
}
}

View File

@@ -5,8 +5,23 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:dcnsanplanung.wpf"
mc:Ignorable="d"
Title="MainWindow" Height="450" Width="800">
Title="MainWindow" Height="450" Width="800" Loaded="Window_Loaded">
<Grid>
<StackPanel>
<ComboBox Name="Items" SelectionChanged="Items_SelectionChanged">
<ComboBox.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal">
<TextBlock Text="{Binding Objektbezeichnung}" />
<TextBlock Text=" | " />
<TextBlock Text="{Binding Bewertungklasse}" />
</StackPanel>
</DataTemplate>
</ComboBox.ItemTemplate>
</ComboBox>
<Button Name="LoadXML" Click="LoadXML_Click" Content="LoadXML" />
</StackPanel>
</Grid>
</Window>

View File

@@ -1,4 +1,6 @@
using System;
using dcnsanplanung.shared.Model;
using Schnittstelle.Import.XML.v2013.Model;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
@@ -24,5 +26,33 @@ namespace dcnsanplanung.wpf
{
InitializeComponent();
}
private async void LoadXML_Click(object sender, RoutedEventArgs e)
{
DAL.Helper.WriteToDatabase writer = new DAL.Helper.WriteToDatabase(@"C:\Users\damia\source\repos\dcnsanplanung\test_code.xml");
//await writer.WriteInHaltung();
await writer.WriteInLV();
}
private void Items_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
Haltung? selectedItem = Items.SelectedItem as Haltung;
if (selectedItem == null) return;
W_ObjektView w_ObjektView = new W_ObjektView(selectedItem);
w_ObjektView.ShowDialog();
}
private async void Window_Loaded(object sender, RoutedEventArgs e)
{
//
DAL.Services.PostgresqlData.HaltungDataService haltungsdataservice = new DAL.Services.PostgresqlData.HaltungDataService("Host = localhost; Database = sanplaner; Username = dcnsanplaner; Password = sanplaner");
var s = await haltungsdataservice.GetAllByProjekt(0);
foreach(var item in s)
{
Items.Items.Add(item);
}
}
}
}

View File

@@ -0,0 +1,23 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using System.Threading.Tasks;
namespace dcnsanplanung.wpf.ViewModel
{
internal class BaseViewModel : INotifyPropertyChanged
{
public event PropertyChangedEventHandler? PropertyChanged;
void OnPropertyChanged([CallerMemberName] string propertyName = "")
{
if(PropertyChanged != null)
{
PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
}
}
}
}

View File

@@ -0,0 +1,13 @@
<Window x:Class="dcnsanplanung.wpf.W_ObjektView"
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:dcnsanplanung.wpf"
mc:Ignorable="d"
Title="W_ObjektView" Height="450" Width="800">
<Grid>
<Label Name="Schadensklasse" />
</Grid>
</Window>

View File

@@ -0,0 +1,31 @@
using dcnsanplanung.shared.Model;
using Schnittstelle.Import.XML.v2013.Model;
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;
namespace dcnsanplanung.wpf
{
/// <summary>
/// Interaktionslogik für W_ObjektView.xaml
/// </summary>
public partial class W_ObjektView : Window
{
public W_ObjektView(Haltung haltung)
{
InitializeComponent();
Schadensklasse.Content = haltung.Bewertungklasse;
}
}
}

View File

@@ -7,4 +7,10 @@
<UseWPF>true</UseWPF>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\dcnsanplanung.DAL\dcnsanplanung.DAL.csproj" />
<ProjectReference Include="..\dcnsanplanung.shared\dcnsanplanung.shared.csproj" />
<ProjectReference Include="..\Schnittstelle\Schnittstelle\Schnittstelle.csproj" />
</ItemGroup>
</Project>