Projekte integration angefangen
This commit is contained in:
@@ -27,6 +27,7 @@ namespace KanSan.ViewModel
|
|||||||
}
|
}
|
||||||
public ICommand AddNewClientCommand { get; set; }
|
public ICommand AddNewClientCommand { get; set; }
|
||||||
public ICommand EditClientCommand { get; set; }
|
public ICommand EditClientCommand { get; set; }
|
||||||
|
public ICommand SelectClientCommand { get; set; }
|
||||||
|
|
||||||
public List<Kunde> Kunden
|
public List<Kunde> Kunden
|
||||||
{
|
{
|
||||||
@@ -42,6 +43,13 @@ namespace KanSan.ViewModel
|
|||||||
|
|
||||||
AddNewClientCommand = new RelayCommand(parameter => NewClient());
|
AddNewClientCommand = new RelayCommand(parameter => NewClient());
|
||||||
EditClientCommand = new RelayCommand(parameter => EditClient());
|
EditClientCommand = new RelayCommand(parameter => EditClient());
|
||||||
|
SelectClientCommand = new RelayCommand(parameter => SelectClient());
|
||||||
|
}
|
||||||
|
|
||||||
|
private void SelectClient()
|
||||||
|
{
|
||||||
|
if (selectedKunde == null) return;
|
||||||
|
Mediator.Notify("ClientSelected", selectedKunde);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void NewClient()
|
private void NewClient()
|
||||||
|
|||||||
@@ -243,9 +243,25 @@ namespace KanSan.ViewModel
|
|||||||
|
|
||||||
Mediator.Subscribe("GoToListClientScreen", OnGoToListClientScreen);
|
Mediator.Subscribe("GoToListClientScreen", OnGoToListClientScreen);
|
||||||
Mediator.Subscribe("GoToEditClientScreen", OnGoToEditClientScreen);
|
Mediator.Subscribe("GoToEditClientScreen", OnGoToEditClientScreen);
|
||||||
|
Mediator.Subscribe("ClientSelected", OnSelectedClient);
|
||||||
|
|
||||||
|
Mediator.Subscribe("GoToEditProjektScreen", OnGoToEditProjektScreen);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void OnGoToEditProjektScreen(object obj)
|
||||||
|
{
|
||||||
|
if (!(obj is Projekt)) return;
|
||||||
|
ActualViewModel = new ProjektEditViewModel((obj as Projekt));
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnSelectedClient(object obj)
|
||||||
|
{
|
||||||
|
if (!(obj is Kunde)) return;
|
||||||
|
SelectedKunde = (obj as Kunde);
|
||||||
|
ListProjekte();
|
||||||
|
}
|
||||||
|
|
||||||
private void OnGoToEditClientScreen(object obj)
|
private void OnGoToEditClientScreen(object obj)
|
||||||
{
|
{
|
||||||
if (!(obj is Kunde)) return;
|
if (!(obj is Kunde)) return;
|
||||||
@@ -278,7 +294,10 @@ namespace KanSan.ViewModel
|
|||||||
|
|
||||||
private void ListProjekte()
|
private void ListProjekte()
|
||||||
{
|
{
|
||||||
ActualViewModel = new ProjektListViewModel(SelectedKunde);
|
if (SelectedKunde == null)
|
||||||
|
ActualViewModel = new KundenListViewModel();
|
||||||
|
else
|
||||||
|
ActualViewModel = new ProjektListViewModel(SelectedKunde);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ListBaustellen()
|
private void ListBaustellen()
|
||||||
|
|||||||
@@ -2,10 +2,13 @@
|
|||||||
using KanSan.Base.Interfaces;
|
using KanSan.Base.Interfaces;
|
||||||
using KanSan.Base.Interfaces.UI;
|
using KanSan.Base.Interfaces.UI;
|
||||||
using KanSan.Base.Models;
|
using KanSan.Base.Models;
|
||||||
|
using KanSan.ViewModel.Commands;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Diagnostics;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
using System.Windows.Input;
|
||||||
|
|
||||||
namespace KanSan.ViewModel
|
namespace KanSan.ViewModel
|
||||||
{
|
{
|
||||||
@@ -22,26 +25,38 @@ namespace KanSan.ViewModel
|
|||||||
}
|
}
|
||||||
private Kunde selectedKunde;
|
private Kunde selectedKunde;
|
||||||
|
|
||||||
|
public ICommand NewProjekt { get; set; }
|
||||||
|
public ICommand EditProjekt { get; set; }
|
||||||
|
public ICommand SelectProjekt { get; set; }
|
||||||
|
public Projekt SelectedProjekt { get; set; }
|
||||||
|
|
||||||
public ProjektListViewModel(Kunde client)
|
public ProjektListViewModel(Kunde client)
|
||||||
{
|
{
|
||||||
|
|
||||||
this.selectedKunde = client;
|
this.selectedKunde = client;
|
||||||
|
|
||||||
|
|
||||||
projektevonKunde = unitOfWork.ProjekteRepository.Get(x => x.Kunde.Equals(client)).ToList();
|
projektevonKunde = unitOfWork.ProjekteRepository.Get(x => x.Kunde.Equals(client)).ToList();
|
||||||
|
|
||||||
|
EditProjekt = new RelayCommand(parameter => EditSelectedProjekt());
|
||||||
|
NewProjekt = new RelayCommand(parameter => AddNewProjekt());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SelectProjekt()
|
private void AddNewProjekt()
|
||||||
{
|
{
|
||||||
|
Projekt newProj = NeueProjekt();
|
||||||
|
Mediator.Notify("GoToEditProjektScreen", newProj);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void EditSelectedProjekt()
|
||||||
|
{
|
||||||
|
Mediator.Notify("GoToEditProjektScreen", SelectedProjekt);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Projekt NeueProjekt()
|
public Projekt NeueProjekt()
|
||||||
{
|
{
|
||||||
Guid guid = Guid.NewGuid();
|
|
||||||
Projekt newProjekt = new Projekt()
|
Projekt newProjekt = new Projekt()
|
||||||
{
|
{
|
||||||
GuidNr = guid,
|
GuidNr = Guid.NewGuid(),
|
||||||
Kunde = selectedKunde
|
Kunde = selectedKunde
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -49,9 +64,7 @@ namespace KanSan.ViewModel
|
|||||||
//unitOfWork.ProjekteRepository.Insert(newProjekt);
|
//unitOfWork.ProjekteRepository.Insert(newProjekt);
|
||||||
unitOfWork.Commit();
|
unitOfWork.Commit();
|
||||||
|
|
||||||
List<Projekt> res = unitOfWork.ProjekteRepository.Get(x => x.GuidNr.Equals(guid)).ToList();
|
return newProjekt;
|
||||||
if (res.Count < 1) throw new Exception("Der zuvor eingefügte Projekt konnte nicht in der Datenbank gefunden werden");
|
|
||||||
return res.First();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,7 +24,7 @@
|
|||||||
<DataGridTextColumn Header="Ort" Binding="{Binding Ort}" />
|
<DataGridTextColumn Header="Ort" Binding="{Binding Ort}" />
|
||||||
</DataGrid.Columns>
|
</DataGrid.Columns>
|
||||||
</DataGrid>
|
</DataGrid>
|
||||||
<Button Grid.Row="1" Name="SelectKunde" Content="Kunde Auswählen" />
|
<Button Grid.Row="1" Name="SelectKunde" Content="Kunde Auswählen" Command="{Binding SelectClientCommand}" />
|
||||||
<Button Grid.Row="2" Name="EditKunde" Content="Kunde Editieren" Command="{Binding EditClientCommand}" />
|
<Button Grid.Row="2" Name="EditKunde" Content="Kunde Editieren" Command="{Binding EditClientCommand}" />
|
||||||
<Button Grid.Row="3" Name="NeueKunde" Content="Neue Kunde anlegen" Command="{Binding AddNewClientCommand}" />
|
<Button Grid.Row="3" Name="NeueKunde" Content="Neue Kunde anlegen" Command="{Binding AddNewClientCommand}" />
|
||||||
|
|
||||||
|
|||||||
@@ -23,7 +23,7 @@
|
|||||||
|
|
||||||
<Label Background="Beige" Grid.Column="0" Grid.Row="0" Content="Projektnummer" />
|
<Label Background="Beige" Grid.Column="0" Grid.Row="0" Content="Projektnummer" />
|
||||||
<Label Background="Beige" Grid.Column="0" Grid.Row="1" Content="Ort" />
|
<Label Background="Beige" Grid.Column="0" Grid.Row="1" Content="Ort" />
|
||||||
<Button Grid.Row="2" Grid.ColumnSpan="2" Name="Speichern" Content="Speichern" Click="Speichern_Click" />
|
<Button Grid.Row="2" Grid.ColumnSpan="2" Name="Speichern" Content="Speichern" />
|
||||||
|
|
||||||
<TextBox Grid.Column="1" Grid.Row="0" Text="{Binding Projektnummer}" />
|
<TextBox Grid.Column="1" Grid.Row="0" Text="{Binding Projektnummer}" />
|
||||||
<TextBox Grid.Row="1" Grid.Column="1" Text="{Binding Ort}" />
|
<TextBox Grid.Row="1" Grid.Column="1" Text="{Binding Ort}" />
|
||||||
|
|||||||
@@ -20,25 +20,9 @@ namespace KanSan.UI
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public partial class UCProjektEdit : UserControl
|
public partial class UCProjektEdit : UserControl
|
||||||
{
|
{
|
||||||
public event EventHandler SpeichernClicked;
|
public UCProjektEdit()
|
||||||
|
|
||||||
protected virtual void OnSpeichernKlicked(EventArgs e)
|
|
||||||
{
|
|
||||||
EventHandler handler = SpeichernClicked;
|
|
||||||
if (handler != null)
|
|
||||||
handler(this, e);
|
|
||||||
}
|
|
||||||
public UCProjektEdit(Projekt projekt)
|
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
|
|
||||||
this.DataContext = new ProjektEditViewModel(projekt);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void Speichern_Click(object sender, RoutedEventArgs e)
|
|
||||||
{
|
|
||||||
(DataContext as ProjektEditViewModel).Speichern();
|
|
||||||
OnSpeichernKlicked(EventArgs.Empty);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,14 +17,14 @@
|
|||||||
<RowDefinition Height="50" />
|
<RowDefinition Height="50" />
|
||||||
<RowDefinition Height="50" />
|
<RowDefinition Height="50" />
|
||||||
</Grid.RowDefinitions>
|
</Grid.RowDefinitions>
|
||||||
<DataGrid ItemsSource="{Binding ProjekteVomKunde}" Name="dgProjekte" AutoGenerateColumns="False">
|
<DataGrid IsReadOnly="True" ItemsSource="{Binding ProjekteVomKunde}" SelectedItem="{Binding SelectedProjekt}" Name="dgProjekte" AutoGenerateColumns="False">
|
||||||
<DataGrid.Columns>
|
<DataGrid.Columns>
|
||||||
<DataGridTextColumn Header="Projektnummer" Binding="{Binding Projektnummer}" />
|
<DataGridTextColumn Header="Projektnummer" Binding="{Binding Projektnummer}" />
|
||||||
<DataGridTextColumn Header="Ort" Binding="{Binding Ort}" />
|
<DataGridTextColumn Header="Ort" Binding="{Binding Ort}" />
|
||||||
</DataGrid.Columns>
|
</DataGrid.Columns>
|
||||||
</DataGrid>
|
</DataGrid>
|
||||||
<Button Grid.Row="1" x:Name="ProjektSelect" Content="Projekt Auswählen" Click="ProjektSelect_Click" />
|
<Button Grid.Row="1" x:Name="ProjektSelect" Content="Projekt Auswählen" Command="{Binding SelectProjekt}"/>
|
||||||
<Button Grid.Row="2" Name="ProjektEdit" Content="Projekt Editieren" Click="ProjektEdit_Click" />
|
<Button Grid.Row="2" Name="ProjektEdit" Content="Projekt Editieren" Command="{Binding EditProjekt}"/>
|
||||||
<Button Grid.Row="3" Name="ProjektNew" Content="Neue Projekt Hinzufügen" Click="ProjektNew_Click" />
|
<Button Grid.Row="3" Name="ProjektNew" Content="Neue Projekt Hinzufügen" Command="{Binding NewProjekt}" />
|
||||||
</Grid>
|
</Grid>
|
||||||
</UserControl>
|
</UserControl>
|
||||||
|
|||||||
@@ -20,65 +20,10 @@ namespace KanSan.UI
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public partial class UCProjektList : UserControl
|
public partial class UCProjektList : UserControl
|
||||||
{
|
{
|
||||||
public event EventHandler<SelectProjektEventArgs> ProjektAdded;
|
|
||||||
public event EventHandler<SelectProjektEventArgs> ProjektEdited;
|
|
||||||
public event EventHandler<SelectProjektEventArgs> ProjektSelected;
|
|
||||||
public UCProjektList()
|
public UCProjektList()
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
|
|
||||||
}
|
}
|
||||||
public UCProjektList(Kunde selectedKunde)
|
|
||||||
{
|
|
||||||
InitializeComponent();
|
|
||||||
this.DataContext = new ProjektListViewModel(selectedKunde);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void ProjektSelect_Click(object sender, RoutedEventArgs e)
|
|
||||||
{
|
|
||||||
Projekt selectedProjekt = (dgProjekte.SelectedItem as Projekt);
|
|
||||||
if (selectedProjekt == null) return;
|
|
||||||
OnClickProjektSelect(new SelectProjektEventArgs() { projekt = selectedProjekt });
|
|
||||||
}
|
|
||||||
|
|
||||||
private void ProjektEdit_Click(object sender, RoutedEventArgs e)
|
|
||||||
{
|
|
||||||
Projekt selectedProjekt = (dgProjekte.SelectedItem as Projekt);
|
|
||||||
if (selectedProjekt == null) return;
|
|
||||||
OnClickProjektEdit(new SelectProjektEventArgs() { projekt = selectedProjekt });
|
|
||||||
}
|
|
||||||
|
|
||||||
private void ProjektNew_Click(object sender, RoutedEventArgs e)
|
|
||||||
{
|
|
||||||
OnClickProjektAdd(
|
|
||||||
new SelectProjektEventArgs()
|
|
||||||
{
|
|
||||||
projekt = (DataContext as ProjektListViewModel).NeueProjekt()
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
protected virtual void OnClickProjektSelect(SelectProjektEventArgs e)
|
|
||||||
{
|
|
||||||
EventHandler<SelectProjektEventArgs> handler = ProjektSelected;
|
|
||||||
if (handler != null)
|
|
||||||
handler(this, e);
|
|
||||||
}
|
|
||||||
protected virtual void OnClickProjektEdit(SelectProjektEventArgs e)
|
|
||||||
{
|
|
||||||
EventHandler<SelectProjektEventArgs> handler = ProjektEdited;
|
|
||||||
if (handler != null)
|
|
||||||
handler(this, e);
|
|
||||||
}
|
|
||||||
protected virtual void OnClickProjektAdd(SelectProjektEventArgs e)
|
|
||||||
{
|
|
||||||
EventHandler<SelectProjektEventArgs> handler = ProjektAdded;
|
|
||||||
if (handler != null)
|
|
||||||
handler(this, e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public class SelectProjektEventArgs : EventArgs
|
|
||||||
{
|
|
||||||
public Projekt projekt { get; set; }
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,6 +6,9 @@
|
|||||||
<DataTemplate x:Key="SanierungViewModelDataTemplate" DataType="{x:Type l:UCHarzSanierung }">
|
<DataTemplate x:Key="SanierungViewModelDataTemplate" DataType="{x:Type l:UCHarzSanierung }">
|
||||||
<l:UCHarzSanierung />
|
<l:UCHarzSanierung />
|
||||||
</DataTemplate>
|
</DataTemplate>
|
||||||
|
<DataTemplate DataType="{x:Type vm:ProjektEditViewModel}">
|
||||||
|
<l:UCProjektEdit />
|
||||||
|
</DataTemplate>
|
||||||
<DataTemplate DataType="{x:Type vm:KundenListViewModel}">
|
<DataTemplate DataType="{x:Type vm:KundenListViewModel}">
|
||||||
<l:UCKundeList/>
|
<l:UCKundeList/>
|
||||||
</DataTemplate>
|
</DataTemplate>
|
||||||
|
|||||||
Reference in New Issue
Block a user