Files
BeWoPlaner/BeWo/View/Detail/EnvironmentRoleView.xaml.cs
2019-08-09 16:40:41 +02:00

144 lines
4.4 KiB
C#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows;
using BeWo.Core;
using BeWo.Core.Service;
using BeWo.ServiceProxy;
using BeWo.ViewModel;
using BeWo.ViewModel.ListViewModel;
using BS.Shared;
using BS.Shared.Extensions;
using System.Windows.Controls;
namespace BeWo.View.Detail
{
/// <summary>
/// Interaction logic for EmploymentTypeView.xaml
/// </summary>
public partial class EnvironmentRoleView : BeWoView
{
private ValueListView personView = null;
private ValueListView organisationView = null;
private ValueListView roleInOrganisation = null;
private ValueListView roleInFamily = null;
//private ValueListView nationality = null;
//private ValueListView aufenthaltsstatus = null;
//private ValueListView migrationshintergrund = null;
public EnvironmentRoleView(ValueListEntryListVM pViewModelPerson, ValueListEntryListVM pViewModelOrganisation, ValueListEntryListVM pViewModelRoleInOrganisation, ValueListEntryListVM pViewModelRoleInFamily)
{
this.InitializeComponent();
roleInFamily = new ValueListView(pViewModelRoleInFamily);
personView = new ValueListView(pViewModelPerson);
organisationView = new ValueListView(pViewModelOrganisation);
roleInOrganisation = new ValueListView(pViewModelRoleInOrganisation);
roleInFamily.SetValue(Grid.RowProperty, 0);
personView.SetValue(Grid.RowProperty, 1);
organisationView.SetValue(Grid.RowProperty, 2);
roleInOrganisation.SetValue(Grid.RowProperty, 3);
personView.Margin = new Thickness(0, 10, 0, 0);
organisationView.Margin = new Thickness(0, 10, 0, 0);
roleInOrganisation.Margin = new Thickness(0, 10, 0, 0);
rootGrid.Children.Add(roleInFamily);
rootGrid.Children.Add(personView);
rootGrid.Children.Add(organisationView);
rootGrid.Children.Add(roleInOrganisation);
}
//Für Funktionen
public EnvironmentRoleView(ValueListEntryListVM personFunktionList, ValueListEntryListVM orgFunktionList)
{
this.InitializeComponent();
personView = new ValueListView(personFunktionList);
organisationView = new ValueListView(orgFunktionList);
personView.SetValue(Grid.RowProperty, 0);
organisationView.SetValue(Grid.RowProperty, 1);
organisationView.Margin = new Thickness(0, 10, 0, 0);
rootGrid.Children.Add(personView);
rootGrid.Children.Add(organisationView);
}
public override bool IsDirty
{
get
{
bool dirty = false;
if (personView != null)
dirty = this.personView.IsDirty;
if (!dirty && organisationView != null)
dirty = this.organisationView.IsDirty;
if (!dirty && roleInOrganisation != null)
dirty = this.roleInOrganisation.IsDirty;
if (!dirty && roleInFamily != null)
dirty = roleInFamily.IsDirty;
return dirty;
}
}
public override string Title
{
get
{
return null;
}
}
protected override void Save()
{
bool valid = true;
if (personView != null){
if (this.personView.IsDirty)
valid = this.personView.SaveData();
}
if (organisationView != null)
{
if (valid && this.organisationView.IsDirty)
this.organisationView.SaveData();
}
if (roleInOrganisation != null)
{
if (valid && roleInOrganisation.IsDirty)
this.roleInOrganisation.SaveData();
}
if (roleInFamily != null)
{
if (valid && roleInFamily.IsDirty)
roleInFamily.SaveData();
}
}
internal override DependencyObject ValidationOnSaveRootElement
{
get { return this.borderTemp; }
}
}
}