Baustellen können nun angelegt und ausgewählt werden
This commit is contained in:
@@ -22,6 +22,12 @@
|
||||
<Compile Update="UI\Projekt\UCProjektList.xaml.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Update="UI\Baustelle\UCBaustelleEdit.xaml.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Update="UI\Baustelle\UCBaustelleList.xaml.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Page Update="MainWindow.xaml">
|
||||
@@ -42,5 +48,11 @@
|
||||
<Page Update="UI\Projekt\UCProjektList.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
</Page>
|
||||
<Page Update="UI\Baustelle\UCBaustelleEdit.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
</Page>
|
||||
<Page Update="UI\Baustelle\UCBaustelleList.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
</Page>
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
@@ -19,14 +19,14 @@
|
||||
<StackPanel Grid.Column="0">
|
||||
<Button Content="Kunden" Name="btnKunden" Click="btnKunden_Click" />
|
||||
<Button Content="Projekte" Name="btnProjekte" Click="btnProjekte_Click" />
|
||||
<Button Content="Baustellen" Name="btnBaustellen" />
|
||||
<Button Content="Baustellen" Name="btnBaustellen" Click="btnBaustellen_Click" />
|
||||
<Button Content="Objekte" Name="btnObjekte" />
|
||||
</StackPanel>
|
||||
<ContentControl Grid.Column="1" Name="ContentController" Content="KanSan"/>
|
||||
<StatusBar Grid.ColumnSpan="2" Margin="0,1,0,0" Grid.Row="1">
|
||||
<StatusBarItem Content="{Binding SelectedKunde.Vorname}" />
|
||||
<StatusBarItem Content="{Binding SelectedProjekt.Projektnummer}" />
|
||||
<StatusBarItem Content="Baustelle" />
|
||||
<StatusBarItem Content="{Binding SelectedBaustelle.OrtTeil}" />
|
||||
</StatusBar>
|
||||
</Grid>
|
||||
</Window>
|
||||
|
||||
@@ -28,6 +28,7 @@ namespace KanSan
|
||||
UI.UCKundeEdit UCKundeEdit;
|
||||
UI.UCKundeList UCKundeList;
|
||||
UI.UCProjektList UCProjektList;
|
||||
UI.UCBaustelleList UCBaustelleList;
|
||||
|
||||
public MainWindow()
|
||||
{
|
||||
@@ -92,6 +93,39 @@ namespace KanSan
|
||||
{
|
||||
ContentController.Content = "MainView";
|
||||
}
|
||||
|
||||
private void btnBaustellen_Click(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 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);
|
||||
*/
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
21
KanSan/SampleData/BaustelleEditViewModelSampleData.cs
Normal file
21
KanSan/SampleData/BaustelleEditViewModelSampleData.cs
Normal file
@@ -0,0 +1,21 @@
|
||||
using KanSan.Base.Interfaces.UI;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace KanSan.SampleData
|
||||
{
|
||||
class BaustelleEditViewModelSampleData : IBaustelleEditViewModel
|
||||
{
|
||||
string baustelleNummer;
|
||||
string ortTeil;
|
||||
public string BaustelleNummer { get => baustelleNummer; set => baustelleNummer = value; }
|
||||
public string OrtTeil { get => ortTeil; set => ortTeil = value; }
|
||||
|
||||
public BaustelleEditViewModelSampleData()
|
||||
{
|
||||
baustelleNummer = "20-850-005";
|
||||
ortTeil = "Bramsche";
|
||||
}
|
||||
}
|
||||
}
|
||||
26
KanSan/SampleData/BaustelleListViewModelSampleData.cs
Normal file
26
KanSan/SampleData/BaustelleListViewModelSampleData.cs
Normal file
@@ -0,0 +1,26 @@
|
||||
using KanSan.Base.Interfaces.UI;
|
||||
using KanSan.Base.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace KanSan.SampleData
|
||||
{
|
||||
class BaustelleListViewModelSampleData : IBaustelleListViewModel
|
||||
{
|
||||
List<Baustelle> baustellen = new List<Baustelle>();
|
||||
public List<Baustelle> Baustellen => baustellen;
|
||||
|
||||
public BaustelleListViewModelSampleData()
|
||||
{
|
||||
for (int i = 0; i < 10; i++)
|
||||
{
|
||||
baustellen.Add(new Baustelle()
|
||||
{
|
||||
BaustelleNummer = "00" + i,
|
||||
OrtTeil = "Huntlosen "+i
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -6,7 +6,7 @@ using System.Text;
|
||||
|
||||
namespace KanSan.SampleData
|
||||
{
|
||||
class ProjektListViewModelSampleData : IProjekteListViewModel
|
||||
class ProjektListViewModelSampleData : IProjektListViewModel
|
||||
{
|
||||
private List<Projekt> _projekteVomKunde = new List<Projekt>();
|
||||
public List<Projekt> ProjekteVomKunde => _projekteVomKunde;
|
||||
|
||||
@@ -5,8 +5,27 @@
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:local="clr-namespace:KanSan.UI"
|
||||
mc:Ignorable="d"
|
||||
xmlns:sd ="clr-namespace:KanSan.SampleData"
|
||||
d:DesignHeight="450" d:DesignWidth="800">
|
||||
<d:UserControl.DataContext>
|
||||
<sd:BaustelleEditViewModelSampleData/>
|
||||
</d:UserControl.DataContext>
|
||||
<Grid>
|
||||
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition />
|
||||
<RowDefinition />
|
||||
<RowDefinition />
|
||||
</Grid.RowDefinitions>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition />
|
||||
<ColumnDefinition />
|
||||
</Grid.ColumnDefinitions>
|
||||
<Label Grid.Row="0" Grid.Column="0" Background="Beige" Content="OrtTeil" />
|
||||
<Label Grid.Row="1" Grid.Column="0" Background="Beige" Content="Projektnummer" />
|
||||
|
||||
<TextBox Grid.Row="0" Grid.Column="1" Text="{Binding OrtTeil}" />
|
||||
<TextBox Grid.Row="1" Grid.Column="1" Text="{Binding BaustelleNummer}"/>
|
||||
|
||||
<Button Grid.ColumnSpan="2" Grid.Row="2" Content="Speichern" Name="Speichern" Click="Speichern_Click" />
|
||||
</Grid>
|
||||
</UserControl>
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
using System;
|
||||
using KanSan.Base.Models;
|
||||
using KanSan.ViewModel;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Windows;
|
||||
@@ -18,9 +20,23 @@ namespace KanSan.UI
|
||||
/// </summary>
|
||||
public partial class UCBaustelleEdit : UserControl
|
||||
{
|
||||
public UCBaustelleEdit()
|
||||
public event EventHandler SpeichernClicked;
|
||||
public UCBaustelleEdit(Baustelle baustelle)
|
||||
{
|
||||
InitializeComponent();
|
||||
this.DataContext = new BaustelleEditViewModel(baustelle);
|
||||
}
|
||||
protected virtual void OnSpeichernKlicked(EventArgs e)
|
||||
{
|
||||
EventHandler handler = SpeichernClicked;
|
||||
if (handler != null)
|
||||
handler(this, e);
|
||||
}
|
||||
|
||||
private void Speichern_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
(DataContext as BaustelleEditViewModel).Speichern();
|
||||
OnSpeichernKlicked(EventArgs.Empty);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,9 +4,27 @@
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:local="clr-namespace:KanSan.UI"
|
||||
xmlns:sd ="clr-namespace:KanSan.SampleData"
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="450" d:DesignWidth="800">
|
||||
d:DesignHeight="450" d:DesignWidth="1024">
|
||||
<d:UserControl.DataContext>
|
||||
<sd:BaustelleListViewModelSampleData />
|
||||
</d:UserControl.DataContext>
|
||||
<Grid>
|
||||
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition />
|
||||
<RowDefinition Height="50" />
|
||||
<RowDefinition Height="50" />
|
||||
<RowDefinition Height="50" />
|
||||
</Grid.RowDefinitions>
|
||||
<DataGrid Name="dgBaustelle" ItemsSource="{Binding Baustellen}" AutoGenerateColumns="False">
|
||||
<DataGrid.Columns>
|
||||
<DataGridTextColumn Header="OrtTeil" Binding="{Binding OrtTeil}" />
|
||||
<DataGridTextColumn Header="BaustelleNummer" Binding="{Binding BaustelleNummer}"/>
|
||||
</DataGrid.Columns>
|
||||
</DataGrid>
|
||||
<Button Grid.Row="1" Name="BaustelleSelect" Content="Baustelle Auswählen" Click="BaustelleSelect_Click" />
|
||||
<Button Grid.Row="2" Name="BaustelleEdit" Content="Baustelle Editieren" Click="BaustelleEdit_Click" />
|
||||
<Button Grid.Row="3" Name="BaustelleNew" Content="Neue Baustelle Hinzufügen" Click="BaustelleNew_Click" />
|
||||
</Grid>
|
||||
</UserControl>
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
using System;
|
||||
using KanSan.Base.Models;
|
||||
using KanSan.ViewModel;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Windows;
|
||||
@@ -18,9 +20,59 @@ namespace KanSan.UI
|
||||
/// </summary>
|
||||
public partial class UCBaustelleList : UserControl
|
||||
{
|
||||
public UCBaustelleList()
|
||||
public event EventHandler<SelectBaustelleEventArgs> BaustelleSelected;
|
||||
public event EventHandler<SelectBaustelleEventArgs> BaustelleAdded;
|
||||
public event EventHandler<SelectBaustelleEventArgs> BaustelleEdited;
|
||||
public UCBaustelleList(Projekt projekt)
|
||||
{
|
||||
InitializeComponent();
|
||||
this.DataContext = new BaustellenListViewModel(projekt);
|
||||
}
|
||||
|
||||
private void BaustelleSelect_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
Baustelle selectedBaustelle = (dgBaustelle.SelectedItem as Baustelle);
|
||||
if (selectedBaustelle == null) return;
|
||||
OnClickBaustelleSelect(new SelectBaustelleEventArgs() { baustelle = selectedBaustelle });
|
||||
}
|
||||
|
||||
private void BaustelleEdit_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
Baustelle selectedBaustelle = (dgBaustelle.SelectedItem as Baustelle);
|
||||
if (selectedBaustelle == null) return;
|
||||
OnClickBaustelleEdit(new SelectBaustelleEventArgs() { baustelle = selectedBaustelle });
|
||||
}
|
||||
|
||||
private void BaustelleNew_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
OnClickBaustelleAdd(
|
||||
new SelectBaustelleEventArgs()
|
||||
{
|
||||
baustelle = (DataContext as BaustellenListViewModel).NeueBaustelle()
|
||||
});
|
||||
}
|
||||
|
||||
protected virtual void OnClickBaustelleSelect(SelectBaustelleEventArgs e)
|
||||
{
|
||||
EventHandler<SelectBaustelleEventArgs> handler = BaustelleSelected;
|
||||
if (handler != null)
|
||||
handler(this, e);
|
||||
}
|
||||
protected virtual void OnClickBaustelleAdd(SelectBaustelleEventArgs e)
|
||||
{
|
||||
EventHandler<SelectBaustelleEventArgs> handler = BaustelleAdded;
|
||||
if (handler != null)
|
||||
handler(this, e);
|
||||
}
|
||||
protected virtual void OnClickBaustelleEdit(SelectBaustelleEventArgs e)
|
||||
{
|
||||
EventHandler<SelectBaustelleEventArgs> handler = BaustelleEdited;
|
||||
if (handler != null)
|
||||
handler(this, e);
|
||||
}
|
||||
}
|
||||
public class SelectBaustelleEventArgs : EventArgs
|
||||
{
|
||||
public Baustelle baustelle { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user