155 lines
5.5 KiB
C#
155 lines
5.5 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Diagnostics;
|
|
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.Navigation;
|
|
using System.Windows.Shapes;
|
|
using KanSan.Base;
|
|
using KanSan.Base.Models;
|
|
using KanSan.ViewModel;
|
|
using Microsoft.EntityFrameworkCore;
|
|
|
|
namespace KanSan
|
|
{
|
|
/// <summary>
|
|
/// Interaction logic for MainWindow.xaml
|
|
/// </summary>
|
|
public partial class MainWindow : Window
|
|
{
|
|
UI.UCKundeEdit UCKundeEdit;
|
|
UI.UCKundeList UCKundeList;
|
|
UI.UCProjektList UCProjektList;
|
|
UI.UCBaustelleList UCBaustelleList;
|
|
|
|
|
|
public MainWindow()
|
|
{
|
|
InitializeComponent();
|
|
this.DataContext = new MainWindowViewModel();
|
|
|
|
UCKundeList = new UI.UCKundeList();
|
|
UCKundeList.KundeAdded += UCKundeList_KundeAdded;
|
|
UCKundeList.KundeSelect += UCKundeList_KundeSelect;
|
|
}
|
|
|
|
private void UCProjektList_ProjektAdded(object sender, UI.SelectProjektEventArgs e)
|
|
{
|
|
if (e.projekt == null) return;
|
|
UI.UCProjektEdit uCProjektEdit = new UI.UCProjektEdit(e.projekt);
|
|
ContentController.Content = uCProjektEdit;
|
|
}
|
|
|
|
private void UCProjektList_ProjektSelected(object sender, UI.SelectProjektEventArgs e)
|
|
{
|
|
(DataContext as MainWindowViewModel).SelectedProjekt = e.projekt;
|
|
}
|
|
|
|
private void UCKundeList_KundeSelect(object sender, UI.KundeAddedKlickEventArgs e)
|
|
{
|
|
(DataContext as MainWindowViewModel).SelectedKunde = e.kunde;
|
|
}
|
|
|
|
private void UCKundeList_KundeAdded(object sender, UI.KundeAddedKlickEventArgs e)
|
|
{
|
|
UCKundeEdit = new UI.UCKundeEdit(e.kunde);
|
|
UCKundeEdit.SpeichernClicked += Edit_SpeichernClicked;
|
|
ContentController.Content = UCKundeEdit;
|
|
}
|
|
|
|
|
|
|
|
private void UCProjektList_ProjektEdited(object sender, UI.SelectProjektEventArgs e)
|
|
{
|
|
if (e.projekt == null) return;
|
|
UI.UCProjektEdit uCProjektEdit = new UI.UCProjektEdit(e.projekt);
|
|
|
|
uCProjektEdit.SpeichernClicked += Edit_SpeichernClicked;
|
|
ContentController.Content = uCProjektEdit;
|
|
}
|
|
|
|
private void Edit_SpeichernClicked(object sender, EventArgs e)
|
|
{
|
|
ContentController.Content = "MainView";
|
|
}
|
|
|
|
|
|
private void UCBaustelleList_BaustelleSelected(object sender, UI.SelectBaustelleEventArgs e)
|
|
{
|
|
(DataContext as MainWindowViewModel).SelectedBaustelle = e.baustelle;
|
|
}
|
|
|
|
private void UCBaustelleList_BaustelleEdited(object sender, UI.SelectBaustelleEventArgs e)
|
|
{
|
|
if (e.baustelle == null) return;
|
|
UI.UCBaustelleEdit uCBaustelleEdit = new UI.UCBaustelleEdit(e.baustelle);
|
|
|
|
uCBaustelleEdit.SpeichernClicked += Edit_SpeichernClicked;
|
|
ContentController.Content = uCBaustelleEdit;
|
|
|
|
}
|
|
|
|
private void UCBaustelleList_BaustelleAdded(object sender, UI.SelectBaustelleEventArgs e)
|
|
{
|
|
if (e.baustelle == null) return;
|
|
UI.UCBaustelleEdit uBaustelleEdit = new UI.UCBaustelleEdit(e.baustelle);
|
|
uBaustelleEdit.SpeichernClicked += Edit_SpeichernClicked;
|
|
ContentController.Content = uBaustelleEdit;
|
|
}
|
|
|
|
|
|
private void UCObjekteList_ObjektSelected(object sender, UI.ObjektSelectEventArgs e)
|
|
{
|
|
if (e.Objekt == null) return;
|
|
(DataContext as MainWindowViewModel).SelectedObjekt = e.Objekt;
|
|
UI.UCObjektEdit uCObjektEdit = new UI.UCObjektEdit();
|
|
ContentController.Content = uCObjektEdit;
|
|
//Debugger.Break();
|
|
}
|
|
|
|
private void rbKunden_Checked(object sender, RoutedEventArgs e)
|
|
{
|
|
ContentController.Content = UCKundeList;
|
|
}
|
|
|
|
private void rbProjekte_Checked(object sender, RoutedEventArgs e)
|
|
{
|
|
Kunde client = (DataContext as MainWindowViewModel).SelectedKunde;
|
|
if (client == null) return;
|
|
UCProjektList = new UI.UCProjektList(client);
|
|
UCProjektList.ProjektSelected += UCProjektList_ProjektSelected;
|
|
UCProjektList.ProjektAdded += UCProjektList_ProjektAdded;
|
|
UCProjektList.ProjektEdited += UCProjektList_ProjektEdited;
|
|
ContentController.Content = UCProjektList;
|
|
}
|
|
|
|
private void rbBaustellen_Checked(object sender, RoutedEventArgs e)
|
|
{
|
|
Projekt projekt = (DataContext as MainWindowViewModel).SelectedProjekt;
|
|
if (projekt == null) return;
|
|
UCBaustelleList = new UI.UCBaustelleList(projekt);
|
|
UCBaustelleList.BaustelleAdded += UCBaustelleList_BaustelleAdded;
|
|
UCBaustelleList.BaustelleEdited += UCBaustelleList_BaustelleEdited;
|
|
UCBaustelleList.BaustelleSelected += UCBaustelleList_BaustelleSelected;
|
|
ContentController.Content = UCBaustelleList;
|
|
}
|
|
|
|
private void rbObjekte_Checked(object sender, RoutedEventArgs e)
|
|
{
|
|
rbObjekte.IsChecked = true;
|
|
UI.UCObjekteList uCObjekteList = new UI.UCObjekteList((DataContext as MainWindowViewModel).SelectedBaustelle);
|
|
uCObjekteList.ObjektSelected += UCObjekteList_ObjektSelected;
|
|
ContentController.Content = uCObjekteList;
|
|
}
|
|
}
|
|
|
|
}
|