Haltungedit erweitert

This commit is contained in:
2023-04-11 15:57:22 +02:00
parent 7999b7ffd0
commit d9e3fdb793
7 changed files with 108 additions and 10 deletions

View File

@@ -62,9 +62,9 @@ namespace SewerStammGen.EntityFramework.Services
throw new NotImplementedException(); throw new NotImplementedException();
} }
public Task<Kanal> Update(int id, Kanal entity) public async Task<Kanal> Update(int id, Kanal entity)
{ {
throw new NotImplementedException(); return await _nonQueryDataService.Update(id, entity);
} }
} }
} }

View File

@@ -76,6 +76,7 @@ namespace SewerStammGen.HostBuilders
{ {
return () => new HaltungEditViewModel( return () => new HaltungEditViewModel(
services.GetRequiredService<IHaltungDataService>(), services.GetRequiredService<IHaltungDataService>(),
services.GetRequiredService<ISchachtDataService>(),
services.GetRequiredService<IActualState>() services.GetRequiredService<IActualState>()
); );
}); });

View File

@@ -14,6 +14,7 @@
</PackageReference> </PackageReference>
<PackageReference Include="Microsoft.Extensions.Hosting" Version="7.0.1" /> <PackageReference Include="Microsoft.Extensions.Hosting" Version="7.0.1" />
<PackageReference Include="Microsoft.Extensions.Hosting.Abstractions" Version="7.0.0" /> <PackageReference Include="Microsoft.Extensions.Hosting.Abstractions" Version="7.0.0" />
<PackageReference Include="Microsoft.Xaml.Behaviors.Wpf" Version="1.1.39" />
<PackageReference Include="Syncfusion.SfGrid.WPF" Version="20.4.0.54" /> <PackageReference Include="Syncfusion.SfGrid.WPF" Version="20.4.0.54" />
</ItemGroup> </ItemGroup>

View File

@@ -4,6 +4,7 @@ using Shared.Contracts;
using Shared.Domain; using Shared.Domain;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
@@ -18,6 +19,40 @@ namespace SewerStammGen.WPF.ViewModel
private readonly IHaltungDataService _kanalDataService; private readonly IHaltungDataService _kanalDataService;
private Kanal _model; private Kanal _model;
private ObservableCollection<Schacht> _verfuegbareSchaechte;
public ObservableCollection<Schacht> VerfuegbareSchaechte
{
get => _verfuegbareSchaechte;
}
public Schacht ObereSchacht
{
get => _model.StartSchacht;
set
{
if(_model.StartSchacht != value)
{
_model.StartSchacht = value;
OnPropertyChanged();
}
}
}
public Schacht UntereSchacht
{
get => _model.EndSchacht;
set
{
if(_model.EndSchacht != value)
{
_model.EndSchacht = value;
OnPropertyChanged();
}
}
}
public string Haltungsbezeichnung public string Haltungsbezeichnung
{ {
get => _model.Objektbezeichnung; get => _model.Objektbezeichnung;
@@ -69,14 +104,34 @@ namespace SewerStammGen.WPF.ViewModel
public ICommand Speichern { get; set; } public ICommand Speichern { get; set; }
public HaltungEditViewModel(IHaltungDataService kanalDataService, IActualState actualState) public HaltungEditViewModel(IHaltungDataService kanalDataService,
ISchachtDataService schachtDataService,
IActualState actualState)
{ {
_actualState = actualState; _actualState = actualState;
_kanalDataService = kanalDataService; _kanalDataService = kanalDataService;
_verfuegbareSchaechte = new ObservableCollection<Schacht>();
_model = new Kanal(); _model = new Kanal();
Speichern = new RelayCommand((x) => SaveKanal()); Speichern = new RelayCommand((x) => SaveKanal());
LoadModel(); LoadModel();
LoadSchaechte(schachtDataService);
}
private async void LoadSchaechte(ISchachtDataService schachtDataService)
{
var s = await schachtDataService.GetAll(_actualState.ProjektID);
InitCollection(_verfuegbareSchaechte, s);
}
private void InitCollection(ObservableCollection<Schacht> dst, IEnumerable<Schacht> src)
{
dst.Clear();
foreach (var srcItem in src) {
dst.Add(srcItem);
}
OnPropertyChanged(nameof(VerfuegbareSchaechte));
} }
private void SaveKanal() private void SaveKanal()
@@ -87,10 +142,12 @@ namespace SewerStammGen.WPF.ViewModel
private async void LoadModel() private async void LoadModel()
{ {
_model = await _kanalDataService.Get(_actualState.HaltungID); _model = await _kanalDataService.Get(_actualState.HaltungID);
OnPropertyChanged(nameof(ObereSchacht));
OnPropertyChanged(nameof(UntereSchacht));
OnPropertyChanged(nameof(Haltungslaenge)); OnPropertyChanged(nameof(Haltungslaenge));
OnPropertyChanged(nameof(Haltungsbezeichnung)); OnPropertyChanged(nameof(Haltungsbezeichnung));
OnPropertyChanged(nameof(Material)); OnPropertyChanged(nameof(Material));
OnPropertyChanged(nameof(Haltungslaenge)); OnPropertyChanged(nameof(Durchmesser));
} }
} }
} }

View File

@@ -0,0 +1,18 @@
using Microsoft.Xaml.Behaviors;
using Syncfusion.UI.Xaml.Grid;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace SewerStammGen.WPF.Views
{
public class TextBoxFilterAction : TargetedTriggerAction<SfMultiColumnDropDownControl>
{
protected override void Invoke(object parameter)
{
throw new NotImplementedException();
}
}
}

View File

@@ -3,13 +3,22 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:behaviors="http://schemas.microsoft.com/xaml/behaviors"
xmlns:syncfusion="http://schemas.syncfusion.com/wpf" xmlns:syncfusion="http://schemas.syncfusion.com/wpf"
xmlns:local="clr-namespace:SewerStammGen.WPF.Views" xmlns:local="clr-namespace:SewerStammGen.WPF.Views"
mc:Ignorable="d" mc:Ignorable="d"
d:DesignHeight="450" d:DesignWidth="800"> d:DesignHeight="450" d:DesignWidth="800">
<UserControl.Resources> <UserControl.Resources>
<DataTemplate x:Key="headerTemplate"> <DataTemplate x:Key="headerTemplate">
<TextBox></TextBox> <TextBox x:Name="searchTextBox" Margin="4" Text="{Binding Path=DataContext.SearchText, Mode=TwoWay,UpdateSourceTrigger=PropertyChanged, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=syncfusion:SfMultiColumnDropDownControl}}">
<behaviors:Interaction.Triggers>
<behaviors:EventTrigger EventName="TextChanged">
<local:TextBoxFilterAction TargetObject="{x:Reference Name=MultiColumnControl5}" />
</behaviors:EventTrigger>
</behaviors:Interaction.Triggers>
</TextBox>
</DataTemplate> </DataTemplate>
</UserControl.Resources> </UserControl.Resources>
<Grid> <Grid>
@@ -38,6 +47,8 @@
Width="250" Width="250"
Margin="10,0" Margin="10,0"
ItemsSource="{Binding VerfuegbareSchaechte}"
SelectedItem="{Binding ObereSchacht, Mode=TwoWay}"
HorizontalAlignment="Left" HorizontalAlignment="Left"
VerticalAlignment="Top" VerticalAlignment="Top"
@@ -45,17 +56,21 @@
AllowImmediatePopup="True" AllowImmediatePopup="True"
AllowIncrementalFiltering="True" AllowIncrementalFiltering="True"
AutoGenerateColumns="False" AutoGenerateColumns="False"
DisplayMember="Title" DisplayMember="Objektbezeichnung"
HeaderTemplate="{StaticResource headerTemplate}" HeaderTemplate="{StaticResource headerTemplate}"
PopupWidth="400" PopupWidth="400"
ValueMember="Cast" ValueMember="Cast"
> >
<syncfusion:SfMultiColumnDropDownControl.Columns>
<syncfusion:GridTextColumn MappingName="Objektbezeichnung" />
</syncfusion:SfMultiColumnDropDownControl.Columns>
</syncfusion:SfMultiColumnDropDownControl> </syncfusion:SfMultiColumnDropDownControl>
<syncfusion:SfMultiColumnDropDownControl Grid.Column="1" Grid.Row="1" <syncfusion:SfMultiColumnDropDownControl Grid.Column="1" Grid.Row="1"
Width="250" Width="250"
Margin="10,0" Margin="10,0"
ItemsSource="{Binding VerfuegbareSchaechte}"
HorizontalAlignment="Left" HorizontalAlignment="Left"
VerticalAlignment="Top" VerticalAlignment="Top"
@@ -63,11 +78,16 @@
AllowImmediatePopup="True" AllowImmediatePopup="True"
AllowIncrementalFiltering="True" AllowIncrementalFiltering="True"
AutoGenerateColumns="False" AutoGenerateColumns="False"
DisplayMember="Title" DisplayMember="Objektbezeichnung"
HeaderTemplate="{StaticResource headerTemplate}" HeaderTemplate="{StaticResource headerTemplate}"
PopupWidth="400" PopupWidth="400"
ValueMember="Cast" ValueMember="Cast"
></syncfusion:SfMultiColumnDropDownControl> SelectedItem="{Binding UntereSchacht }"
>
<syncfusion:SfMultiColumnDropDownControl.Columns>
<syncfusion:GridTextColumn MappingName="Objektbezeichnung" />
</syncfusion:SfMultiColumnDropDownControl.Columns>
</syncfusion:SfMultiColumnDropDownControl>
<TextBox Grid.Row="2" Grid.Column="1" Margin="5" Text="{Binding Haltungsbezeichnung}" /> <TextBox Grid.Row="2" Grid.Column="1" Margin="5" Text="{Binding Haltungsbezeichnung}" />
</Grid> </Grid>
@@ -98,7 +118,8 @@
</DockPanel> </DockPanel>
</Grid> </Grid>
<StackPanel Grid.Row="4"> <StackPanel Grid.Row="4">
<Button Content="Speichern" /> <Button Content="Speichern" Command="{Binding Speichern}" />
<ListBox ItemsSource="{Binding VerfuegbareSchaechte }" />
</StackPanel> </StackPanel>
</Grid> </Grid>
</Grid> </Grid>

View File

@@ -8,7 +8,7 @@
d:DesignHeight="450" d:DesignWidth="800"> d:DesignHeight="450" d:DesignWidth="800">
<Grid> <Grid>
<StackPanel> <StackPanel>
<DataGrid ItemsSource="{Binding Haltungen}" SelectedItem="{Binding SelectedHaltung}"> <DataGrid ItemsSource="{Binding Haltungen}" SelectedItem="{Binding SelectedHaltung}" IsReadOnly="False">
</DataGrid> </DataGrid>
<Button Content="Hinzufügen" Command="{Binding AddCommand}" /> <Button Content="Hinzufügen" Command="{Binding AddCommand}" />