Leistungsverzeichnisposition kann nun bearbeitet werden
This commit is contained in:
84
KanSan.ViewModel/LeistungsverzeichnisPositionViewModel.cs
Normal file
84
KanSan.ViewModel/LeistungsverzeichnisPositionViewModel.cs
Normal file
@@ -0,0 +1,84 @@
|
|||||||
|
using KanSan.Base;
|
||||||
|
using KanSan.Base.Interfaces;
|
||||||
|
using KanSan.Base.Interfaces.UI;
|
||||||
|
using KanSan.Base.Models;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace KanSan.ViewModel
|
||||||
|
{
|
||||||
|
public class LeistungsverzeichnisPositionViewModel : PropertyChangedClass, INotifyPropertyChanged, ILeistungsverzeichnisPositionViewModel
|
||||||
|
{
|
||||||
|
IUnitOfWork unitOfWork = new UnitOfWork(new KanSanContext());
|
||||||
|
|
||||||
|
LeistungsverzeichnisPosition model;
|
||||||
|
string positionsnummer;
|
||||||
|
string beschreibung;
|
||||||
|
string einheit;
|
||||||
|
string tag;
|
||||||
|
|
||||||
|
public string Positionsnummer
|
||||||
|
{
|
||||||
|
get => positionsnummer;
|
||||||
|
set
|
||||||
|
{
|
||||||
|
if (positionsnummer == value) return;
|
||||||
|
positionsnummer = value;
|
||||||
|
OnPropertyChanged();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public string Beschreibung
|
||||||
|
{
|
||||||
|
get => beschreibung;
|
||||||
|
set
|
||||||
|
{
|
||||||
|
if (beschreibung == value) return;
|
||||||
|
beschreibung = value;
|
||||||
|
OnPropertyChanged();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public string Einheit
|
||||||
|
{
|
||||||
|
get => einheit;
|
||||||
|
set
|
||||||
|
{
|
||||||
|
if (einheit == value) return;
|
||||||
|
einheit = value;
|
||||||
|
OnPropertyChanged();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public string Tag
|
||||||
|
{
|
||||||
|
get => tag;
|
||||||
|
set
|
||||||
|
{
|
||||||
|
if (tag == value) return;
|
||||||
|
tag = value;
|
||||||
|
OnPropertyChanged();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public LeistungsverzeichnisPositionViewModel(LeistungsverzeichnisPosition position)
|
||||||
|
{
|
||||||
|
this.model = position;
|
||||||
|
positionsnummer = model.Positionsnummer;
|
||||||
|
beschreibung = model.Beschreibung;
|
||||||
|
einheit = model.Einheit;
|
||||||
|
tag = model.Tag;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Speichern()
|
||||||
|
{
|
||||||
|
model.Positionsnummer = positionsnummer;
|
||||||
|
model.Beschreibung = beschreibung;
|
||||||
|
model.Einheit = einheit;
|
||||||
|
model.Tag = tag;
|
||||||
|
|
||||||
|
unitOfWork.LeistungsverzeichnisRepository.Update(model);
|
||||||
|
unitOfWork.Commit();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -123,6 +123,8 @@ namespace KanSan
|
|||||||
|
|
||||||
private void rbKunden_Checked(object sender, RoutedEventArgs e)
|
private void rbKunden_Checked(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
|
rbLeistungsverzeichnis.IsChecked = false;
|
||||||
|
rbLeistungsverzeichnisBaustellen.IsChecked = false;
|
||||||
UCKundeList = new UI.UCKundeList();
|
UCKundeList = new UI.UCKundeList();
|
||||||
UCKundeList.KundeAdded += UCKundeList_KundeAdded;
|
UCKundeList.KundeAdded += UCKundeList_KundeAdded;
|
||||||
UCKundeList.KundeSelect += UCKundeList_KundeSelect;
|
UCKundeList.KundeSelect += UCKundeList_KundeSelect;
|
||||||
@@ -131,6 +133,8 @@ namespace KanSan
|
|||||||
|
|
||||||
private void rbProjekte_Checked(object sender, RoutedEventArgs e)
|
private void rbProjekte_Checked(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
|
rbLeistungsverzeichnis.IsChecked = false;
|
||||||
|
rbLeistungsverzeichnisBaustellen.IsChecked = false;
|
||||||
Kunde client = (DataContext as MainWindowViewModel).SelectedKunde;
|
Kunde client = (DataContext as MainWindowViewModel).SelectedKunde;
|
||||||
if (client == null) return;
|
if (client == null) return;
|
||||||
UCProjektList = new UI.UCProjektList(client);
|
UCProjektList = new UI.UCProjektList(client);
|
||||||
@@ -142,6 +146,8 @@ namespace KanSan
|
|||||||
|
|
||||||
private void rbBaustellen_Checked(object sender, RoutedEventArgs e)
|
private void rbBaustellen_Checked(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
|
rbLeistungsverzeichnis.IsChecked = false;
|
||||||
|
rbLeistungsverzeichnisBaustellen.IsChecked = false;
|
||||||
Projekt projekt = (DataContext as MainWindowViewModel).SelectedProjekt;
|
Projekt projekt = (DataContext as MainWindowViewModel).SelectedProjekt;
|
||||||
if (projekt == null) return;
|
if (projekt == null) return;
|
||||||
UCBaustelleList = new UI.UCBaustelleList(projekt);
|
UCBaustelleList = new UI.UCBaustelleList(projekt);
|
||||||
@@ -153,6 +159,8 @@ namespace KanSan
|
|||||||
|
|
||||||
private void rbObjekte_Checked(object sender, RoutedEventArgs e)
|
private void rbObjekte_Checked(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
|
rbLeistungsverzeichnis.IsChecked = false;
|
||||||
|
rbLeistungsverzeichnisBaustellen.IsChecked = false;
|
||||||
rbObjekte.IsChecked = true;
|
rbObjekte.IsChecked = true;
|
||||||
UI.UCObjekteList uCObjekteList = new UI.UCObjekteList((DataContext as MainWindowViewModel).SelectedBaustelle);
|
UI.UCObjekteList uCObjekteList = new UI.UCObjekteList((DataContext as MainWindowViewModel).SelectedBaustelle);
|
||||||
uCObjekteList.ObjektSelected += UCObjekteList_ObjektSelected;
|
uCObjekteList.ObjektSelected += UCObjekteList_ObjektSelected;
|
||||||
@@ -161,12 +169,28 @@ namespace KanSan
|
|||||||
|
|
||||||
private void rbLeistungsverzeichnis_Checked(object sender, RoutedEventArgs e)
|
private void rbLeistungsverzeichnis_Checked(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
|
rbBaustellen.IsChecked = false;
|
||||||
|
rbKunden.IsChecked = false;
|
||||||
|
rbObjekte.IsChecked = false;
|
||||||
|
rbProjekte.IsChecked = false;
|
||||||
UCLeistungsverzeichnisPosList = new UI.UCLeistungsverzeichnisPosList();
|
UCLeistungsverzeichnisPosList = new UI.UCLeistungsverzeichnisPosList();
|
||||||
|
UCLeistungsverzeichnisPosList.LeistungsverzeichnisEdited += UCLeistungsverzeichnisPosList_LeistungsverzeichnisEdited;
|
||||||
ContentController.Content = UCLeistungsverzeichnisPosList;
|
ContentController.Content = UCLeistungsverzeichnisPosList;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void UCLeistungsverzeichnisPosList_LeistungsverzeichnisEdited(object sender, UI.SelectedLeistungsverzeichnisEventArgs e)
|
||||||
|
{
|
||||||
|
|
||||||
|
UI.UCLeistungsverzeichnisPosition uCLeistungsverzeichnisPosition = new UI.UCLeistungsverzeichnisPosition(e.LeistungsverzeichnisPosition);
|
||||||
|
ContentController.Content = uCLeistungsverzeichnisPosition;
|
||||||
|
}
|
||||||
|
|
||||||
private void rbLeistungsverzeichnisBaustellen_Checked(object sender, RoutedEventArgs e)
|
private void rbLeistungsverzeichnisBaustellen_Checked(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
|
rbBaustellen.IsChecked = false;
|
||||||
|
rbKunden.IsChecked = false;
|
||||||
|
rbObjekte.IsChecked = false;
|
||||||
|
rbProjekte.IsChecked = false;
|
||||||
UCLeistungsverzeichnisPositionenBaustelle = new UI.UCLeistungsverzeichnisPositionenBaustelle();
|
UCLeistungsverzeichnisPositionenBaustelle = new UI.UCLeistungsverzeichnisPositionenBaustelle();
|
||||||
ContentController.Content = UCLeistungsverzeichnisPositionenBaustelle;
|
ContentController.Content = UCLeistungsverzeichnisPositionenBaustelle;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,7 +15,7 @@
|
|||||||
<RowDefinition Height="373*" />
|
<RowDefinition Height="373*" />
|
||||||
<RowDefinition Height="77*" />
|
<RowDefinition Height="77*" />
|
||||||
</Grid.RowDefinitions>
|
</Grid.RowDefinitions>
|
||||||
<DataGrid ItemsSource="{Binding LVPositionen}" AutoGenerateColumns="False">
|
<DataGrid ItemsSource="{Binding LVPositionen}" Name="dgLeistungsverzeichnis" AutoGenerateColumns="False">
|
||||||
<DataGrid.Columns>
|
<DataGrid.Columns>
|
||||||
<DataGridTextColumn Header="Positionsnummer" Binding="{Binding Positionsnummer}" />
|
<DataGridTextColumn Header="Positionsnummer" Binding="{Binding Positionsnummer}" />
|
||||||
<DataGridTextColumn Header="Beschreibung" Binding="{Binding Beschreibung}" />
|
<DataGridTextColumn Header="Beschreibung" Binding="{Binding Beschreibung}" />
|
||||||
@@ -23,6 +23,15 @@
|
|||||||
<DataGridTextColumn Header="Tag" Binding="{Binding Tag}" />
|
<DataGridTextColumn Header="Tag" Binding="{Binding Tag}" />
|
||||||
</DataGrid.Columns>
|
</DataGrid.Columns>
|
||||||
</DataGrid>
|
</DataGrid>
|
||||||
|
<Grid Grid.Row="1">
|
||||||
|
<Grid.RowDefinitions>
|
||||||
|
<RowDefinition />
|
||||||
|
<RowDefinition />
|
||||||
|
</Grid.RowDefinitions>
|
||||||
|
<Button Grid.Row="0" Name="EditLVPosition" Content="Leistungsverzeichnis Position Editieren" Click="EditLVPosition_Click" />
|
||||||
<Button Grid.Row="1" Name="NewLVPosition" Content="Neue LeistungsverzeichnisPosition" Click="NewLVPosition_Click" />
|
<Button Grid.Row="1" Name="NewLVPosition" Content="Neue LeistungsverzeichnisPosition" Click="NewLVPosition_Click" />
|
||||||
|
|
||||||
|
</Grid>
|
||||||
|
|
||||||
</Grid>
|
</Grid>
|
||||||
</UserControl>
|
</UserControl>
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
using KanSan.ViewModel;
|
using KanSan.Base.Models;
|
||||||
|
using KanSan.ViewModel;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Diagnostics;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Windows;
|
using System.Windows;
|
||||||
using System.Windows.Controls;
|
using System.Windows.Controls;
|
||||||
@@ -19,6 +21,7 @@ namespace KanSan.UI
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public partial class UCLeistungsverzeichnisPosList : UserControl
|
public partial class UCLeistungsverzeichnisPosList : UserControl
|
||||||
{
|
{
|
||||||
|
public event EventHandler<SelectedLeistungsverzeichnisEventArgs> LeistungsverzeichnisEdited;
|
||||||
public UCLeistungsverzeichnisPosList()
|
public UCLeistungsverzeichnisPosList()
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
@@ -29,5 +32,28 @@ namespace KanSan.UI
|
|||||||
{
|
{
|
||||||
(DataContext as LeistungsverzeichnisPositionenListViewModel).NeueLeistungsverzeichnisPosition();
|
(DataContext as LeistungsverzeichnisPositionenListViewModel).NeueLeistungsverzeichnisPosition();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void EditLVPosition_Click(object sender, RoutedEventArgs e)
|
||||||
|
{
|
||||||
|
LeistungsverzeichnisPosition pos = (dgLeistungsverzeichnis.SelectedItem as LeistungsverzeichnisPosition);
|
||||||
|
if (pos == null) return;
|
||||||
|
OnClickLeistungsverzeichnisEdit(new SelectedLeistungsverzeichnisEventArgs()
|
||||||
|
{
|
||||||
|
LeistungsverzeichnisPosition = pos
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
protected virtual void OnClickLeistungsverzeichnisEdit(SelectedLeistungsverzeichnisEventArgs e)
|
||||||
|
{
|
||||||
|
EventHandler<SelectedLeistungsverzeichnisEventArgs> handler = LeistungsverzeichnisEdited;
|
||||||
|
if (handler != null)
|
||||||
|
handler(this, e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public class SelectedLeistungsverzeichnisEventArgs : EventArgs
|
||||||
|
{
|
||||||
|
public LeistungsverzeichnisPosition LeistungsverzeichnisPosition { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -33,6 +33,6 @@
|
|||||||
<TextBox Grid.Column="1" Grid.Row="2" Text="{Binding Einheit}" />
|
<TextBox Grid.Column="1" Grid.Row="2" Text="{Binding Einheit}" />
|
||||||
<TextBox Grid.Column="1" Grid.Row="3" Text="{Binding Tag}" />
|
<TextBox Grid.Column="1" Grid.Row="3" Text="{Binding Tag}" />
|
||||||
|
|
||||||
<Button Grid.Column="0" Grid.Row="4" Grid.ColumnSpan="2" Content="Speichern" Name="Save" />
|
<Button Grid.Column="0" Grid.Row="4" Grid.ColumnSpan="2" Content="Speichern" Name="Save" Click="Save_Click" />
|
||||||
</Grid>
|
</Grid>
|
||||||
</UserControl>
|
</UserControl>
|
||||||
|
|||||||
@@ -1,4 +1,6 @@
|
|||||||
using System;
|
using KanSan.Base.Models;
|
||||||
|
using KanSan.ViewModel;
|
||||||
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Windows;
|
using System.Windows;
|
||||||
@@ -18,9 +20,16 @@ namespace KanSan.UI
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public partial class UCLeistungsverzeichnisPosition : UserControl
|
public partial class UCLeistungsverzeichnisPosition : UserControl
|
||||||
{
|
{
|
||||||
public UCLeistungsverzeichnisPosition()
|
public UCLeistungsverzeichnisPosition(LeistungsverzeichnisPosition leistungsverzeichnisPosition)
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
|
this.DataContext = new LeistungsverzeichnisPositionViewModel(leistungsverzeichnisPosition);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private void Save_Click(object sender, RoutedEventArgs e)
|
||||||
|
{
|
||||||
|
(DataContext as LeistungsverzeichnisPositionViewModel).Speichern();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,7 +18,7 @@
|
|||||||
<ControlTemplate TargetType="{x:Type Calendar}">
|
<ControlTemplate TargetType="{x:Type Calendar}">
|
||||||
<StackPanel HorizontalAlignment="Center" Name="PART_Root">
|
<StackPanel HorizontalAlignment="Center" Name="PART_Root">
|
||||||
<CalendarItem Background="{TemplateBinding Control.Background}" BorderBrush="{TemplateBinding Control.BorderBrush}" BorderThickness="{TemplateBinding Control.BorderThickness}" Name="PART_CalendarItem" Style="{TemplateBinding Calendar.CalendarItemStyle}" />
|
<CalendarItem Background="{TemplateBinding Control.Background}" BorderBrush="{TemplateBinding Control.BorderBrush}" BorderThickness="{TemplateBinding Control.BorderThickness}" Name="PART_CalendarItem" Style="{TemplateBinding Calendar.CalendarItemStyle}" />
|
||||||
<Button Content="Today" Command="local:CalendarCommands.SelectToday" CommandParameter="{Binding RelativeSource={RelativeSource Mode=TemplatedParent}}"/>
|
<Button Content="Heute" Command="local:CalendarCommands.SelectToday" CommandParameter="{Binding RelativeSource={RelativeSource Mode=TemplatedParent}}"/>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
</ControlTemplate>
|
</ControlTemplate>
|
||||||
</Setter.Value>
|
</Setter.Value>
|
||||||
@@ -49,8 +49,8 @@
|
|||||||
|
|
||||||
<TextBox Grid.Row="0" Grid.Column="1" Text="{Binding Mitarbeiter}" />
|
<TextBox Grid.Row="0" Grid.Column="1" Text="{Binding Mitarbeiter}" />
|
||||||
|
|
||||||
<Calendar Style="{StaticResource DefaultCalendar}" Grid.Row="2" Grid.Column="1" Name="Calender" SelectedDate="{Binding ZeitStempel}"/>
|
<Calendar Style="{StaticResource DefaultCalendar}" Grid.Row="2" Grid.Column="1" Name="Calender" SelectedDate="{Binding ZeitStempel}" Margin="-220,0,0,0"/>
|
||||||
<ComboBox Grid.Row="3" Grid.Column="1" ItemsSource="{Binding LVPositionen}" SelectedItem="{Binding Leistungsverzeichnis}">
|
<ComboBox Grid.Row="3" Grid.Column="1" ItemsSource="{Binding LVPositionen}" SelectedItem="{Binding Leistungsverzeichnis}" IsSynchronizedWithCurrentItem="True">
|
||||||
<ComboBox.ItemTemplate>
|
<ComboBox.ItemTemplate>
|
||||||
<DataTemplate>
|
<DataTemplate>
|
||||||
<TextBlock Text="{Binding Beschreibung}" />
|
<TextBlock Text="{Binding Beschreibung}" />
|
||||||
|
|||||||
Reference in New Issue
Block a user