807 lines
27 KiB
C#
807 lines
27 KiB
C#
using System;
|
|
using System.Windows;
|
|
using System.Windows.Input;
|
|
using BeWo.ServiceProxy;
|
|
using BS.Shared.Extensions;
|
|
using System.Windows.Controls;
|
|
using System.Collections.Generic;
|
|
using System.ComponentModel;
|
|
using System.Linq;
|
|
using System.Runtime.CompilerServices;
|
|
using BeWo.Annotations;
|
|
using BS.Shared;
|
|
using BS.Shared.DataContracts.Compact;
|
|
using DevExpress.Xpf.Editors;
|
|
using DevExpress.Xpf.Grid;
|
|
|
|
namespace BeWo.SchulbegleitenderDienst
|
|
{
|
|
public partial class VertretungsSearchView : INotifyPropertyChanged
|
|
{
|
|
public event EventHandler<VertretungSelectedEventArgs> RaiseCustomEvent;
|
|
|
|
private List<SearchViewDaten> _dataListEmployee = new List<SearchViewDaten>();
|
|
|
|
private readonly CompactCustomerDC _Customer;
|
|
private readonly CompactEmployeeDC _Employee;
|
|
|
|
private List<SearchViewDaten> _CurrentData = new List<SearchViewDaten>();
|
|
|
|
private readonly Dictionary<string, CompactTokenDC> _VerfuegbareWunschkriterien = new Dictionary<string, CompactTokenDC>();
|
|
private readonly Dictionary<string, CompactTokenDC> _VerfuegbareAusschlusskriterien = new Dictionary<string, CompactTokenDC>();
|
|
|
|
private TagesansichtVM _Tagesansicht;
|
|
public TagesansichtVM Tagesansicht
|
|
{
|
|
get => _Tagesansicht;
|
|
set
|
|
{
|
|
if(!Equals(_Tagesansicht, value))
|
|
{
|
|
_Tagesansicht = value;
|
|
OnPropertyChanged(nameof(Tagesansicht));
|
|
}
|
|
}
|
|
}
|
|
|
|
public string CustomerName
|
|
{
|
|
get
|
|
{
|
|
if(_Tagesansicht?.Customer != null)
|
|
{
|
|
return _Tagesansicht.Customer.Name ?? string.Empty;
|
|
}
|
|
|
|
return string.Empty;
|
|
}
|
|
}
|
|
|
|
public string CustomerStreet
|
|
{
|
|
get
|
|
{
|
|
if(_Tagesansicht?.Customer != null)
|
|
{
|
|
return _Tagesansicht.Customer.Street ?? string.Empty;
|
|
}
|
|
|
|
return string.Empty;
|
|
}
|
|
}
|
|
|
|
public string CustomerCity => _Tagesansicht?.Customer != null ? $"{_Tagesansicht.Customer.PostalCode ?? string.Empty} {_Tagesansicht.Customer.Town ?? string.Empty}" : string.Empty;
|
|
|
|
private readonly WochenansichtVM _Wochenansicht;
|
|
|
|
private DateTime _SubstitutionStart;
|
|
|
|
public DateTime SubstitutionStart
|
|
{
|
|
get => _SubstitutionStart;
|
|
set
|
|
{
|
|
if(!Equals(_SubstitutionStart, value))
|
|
{
|
|
_SubstitutionStart = value;
|
|
OnPropertyChanged(nameof(SubstitutionStart));
|
|
|
|
if(_SubstitutionStart > _SubstitutionEnd)
|
|
{
|
|
SubstitutionEnd = _SubstitutionStart;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
private DateTime _SubstitutionEnd;
|
|
|
|
public DateTime SubstitutionEnd
|
|
{
|
|
get => _SubstitutionEnd;
|
|
set
|
|
{
|
|
if(!Equals(_SubstitutionEnd, value))
|
|
{
|
|
_SubstitutionEnd = value;
|
|
OnPropertyChanged(nameof(SubstitutionEnd));
|
|
|
|
if(_SubstitutionEnd < _SubstitutionStart)
|
|
{
|
|
SubstitutionStart = _SubstitutionEnd;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
public VertretungsSearchView(DateTime currentDate, CompactCustomerDC customer, TagesansichtVM tagesansicht, WochenansichtVM wochenansicht, CompactEmployeeDC employee)
|
|
{
|
|
InitializeComponent();
|
|
|
|
DataContext = this;
|
|
|
|
Tagesansicht = tagesansicht;
|
|
_Wochenansicht = wochenansicht;
|
|
_Customer = customer;
|
|
_Employee = employee;
|
|
SetzeStartEndDatum(currentDate);
|
|
|
|
GetAllTokensAndSetAll();
|
|
|
|
rootGroupBox.Header += " / " + currentDate.ToString("dddd dd.MM.yyyy");
|
|
|
|
SetCustomerInfos();
|
|
|
|
Loaded += VertretungsSearchView_Loaded;
|
|
|
|
CommandBindings.Add(new CommandBinding(ApplicationCommands.Close, (s, e) => { Close(); }));
|
|
}
|
|
|
|
private void VertretungsSearchView_Loaded(object sender, EventArgs e)
|
|
{
|
|
try
|
|
{
|
|
Mouse.OverrideCursor = Cursors.Wait;
|
|
SucheVertreter();
|
|
|
|
SetzeLetzteVertreter();
|
|
}
|
|
finally
|
|
{
|
|
Mouse.OverrideCursor = null;
|
|
}
|
|
}
|
|
|
|
private void SetzeStartEndDatum(DateTime currentDate)
|
|
{
|
|
DateTime? start = _Tagesansicht.Datum;
|
|
DateTime? end = _Tagesansicht.Datum;
|
|
|
|
if (_Tagesansicht.Absencetime?.Start != null)
|
|
{
|
|
start = _Tagesansicht.Absencetime.Start.Value;
|
|
}
|
|
|
|
if (_Tagesansicht.Absencetime?.End != null)
|
|
{
|
|
end = _Tagesansicht.Absencetime.End.Value;
|
|
}
|
|
|
|
if (_Tagesansicht.Vertretung != null)
|
|
{
|
|
start = _Tagesansicht.Vertretung.VertretungsZeitraumVon;
|
|
}
|
|
if (_Tagesansicht.Vertretung != null)
|
|
{
|
|
end = _Tagesansicht.Vertretung.VertretungsZeitraumBis;
|
|
}
|
|
|
|
//Laut VKM Aachen
|
|
start = currentDate.Date;
|
|
end = currentDate.Date;
|
|
|
|
SubstitutionStart = start.Value;
|
|
|
|
SubstitutionEnd = end.Value;
|
|
}
|
|
|
|
private void RootGroupBox_OnMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
|
|
{
|
|
DragMove();
|
|
}
|
|
|
|
private void SetCustomerInfos()
|
|
{
|
|
lblCustomerName.Content = string.Empty;
|
|
lblCustomerStreet.Content = string.Empty;
|
|
lblCustomerCity.Content = string.Empty;
|
|
|
|
lblSchoolName.Content = string.Empty;
|
|
lblSchoolStreet.Content = string.Empty;
|
|
lblSchoolCity.Content = string.Empty;
|
|
|
|
if (_Tagesansicht.Customer != null)
|
|
{
|
|
lblCustomerName.Content = _Tagesansicht.Customer.Name;
|
|
lblCustomerStreet.Content = _Tagesansicht.Customer.Street;
|
|
lblCustomerCity.Content = $"{_Tagesansicht.Customer.PostalCode} {_Tagesansicht.Customer.Town}";
|
|
}
|
|
|
|
if (_Tagesansicht.Schule != null)
|
|
{
|
|
lblSchoolName.Content = _Tagesansicht.Schule.Name;
|
|
lblSchoolStreet.Content = _Tagesansicht.Schule.Street;
|
|
lblSchoolCity.Content = $"{_Tagesansicht.Schule.PostalCode} {_Tagesansicht.Schule.Town}";
|
|
}
|
|
}
|
|
|
|
private void SetzeLetzteVertreter()
|
|
{
|
|
if (_Customer != null)
|
|
{
|
|
var employeeList = ServiceFacade.DoOperationsServiceSync(r => r.GetLastVertreter(_Customer.CustomerOid)).Where(w => !Equals(w.CompactEmployee, _Employee));
|
|
var list = CreateSuchergebnisListe(employeeList);
|
|
|
|
ListBoxLetzteVertreter.ItemsSource = list;
|
|
}
|
|
}
|
|
|
|
private void SucheVertreter()
|
|
{
|
|
_dataListEmployee.Clear();
|
|
long? customerOid = null;
|
|
var dateTime = DateTime.Now;
|
|
|
|
if (_Tagesansicht != null)
|
|
{
|
|
if (_Tagesansicht.Customer != null)
|
|
{
|
|
customerOid = _Tagesansicht.Customer.CustomerOid;
|
|
}
|
|
|
|
dateTime = _Tagesansicht.Datum;
|
|
}
|
|
|
|
ServiceFacade.DoEmployeeServiceAsync(s => s.GetAllActiveVertreterEmployeesCompact(customerOid, dateTime), r => this.Dispatch(delegate
|
|
{
|
|
GridControlPossibleVertreter.Visibility = Visibility.Hidden;
|
|
((TableView)GridControlPossibleVertreter.View).VerticalScrollbarVisibility = ScrollBarVisibility.Disabled;
|
|
|
|
var list = CreateSuchergebnisListe(r);
|
|
|
|
_dataListEmployee = list;
|
|
|
|
GridControlPossibleVertreter.ItemsSource = list;
|
|
GridControlPossibleVertreter.Visibility = Visibility.Visible;
|
|
((TableView)GridControlPossibleVertreter.View).VerticalScrollbarVisibility = ScrollBarVisibility.Auto;
|
|
|
|
_CurrentData = _dataListEmployee;
|
|
}), true);
|
|
}
|
|
|
|
private List<SearchViewDaten> CreateSuchergebnisListe(IEnumerable<CompactVertreterEmployeeDC> employeeList)
|
|
{
|
|
var result = new List<SearchViewDaten>();
|
|
|
|
foreach (var employee in employeeList)
|
|
{
|
|
var arbeitszeitEintrag = string.Empty;
|
|
|
|
foreach (var arbeitszeit in employee.Arbeitszeit)
|
|
{
|
|
foreach (var eintrag in arbeitszeit.Eintraege)
|
|
{
|
|
if (eintrag != null && (int)_Tagesansicht.Datum.DayOfWeek == (int)eintrag.Tag + 1)
|
|
{
|
|
arbeitszeitEintrag = eintrag.UhrzeitVon + " - " + eintrag.UhrzeitBis;
|
|
}
|
|
}
|
|
}
|
|
|
|
var sex = employee.Geschlecht == Sex.Male ? "Männlich" : "Weiblich";
|
|
|
|
result.Add(new SearchViewDaten(employee.FirstName, employee.LastName, employee.PersonAdressPLZ, employee.PersonAdressStr, employee.PersonAdressStadt, arbeitszeitEintrag, employee, sex));
|
|
}
|
|
|
|
return result;
|
|
}
|
|
|
|
private void ButtonBase_OnClick(object sender, RoutedEventArgs e)
|
|
{
|
|
if(!(GridControlPossibleVertreter.SelectedItem is SearchViewDaten item))
|
|
{
|
|
return;
|
|
}
|
|
|
|
CloseSearchView(item);
|
|
}
|
|
|
|
private void ButtonClose_OnClick(object sender, RoutedEventArgs e)
|
|
{
|
|
Close();
|
|
}
|
|
|
|
public void GetAllTokensAndSetAll()
|
|
{
|
|
if (_Customer != null)
|
|
{
|
|
ServiceFacade.DoOperationsServiceAsync(
|
|
r => r.GetAllTokens(SchulbegleitenderZugehoerigkeitsTyp.Klient, _Customer.CustomerOid), x => this.Dispatch(
|
|
delegate
|
|
{
|
|
var wunschliste = new List<string>();
|
|
var ausschlussliste = new List<string>();
|
|
|
|
foreach (var token in x)
|
|
{
|
|
if (token.MemberOid == _Customer.CustomerOid)
|
|
{
|
|
if (token.TokenType == TokenTyp.WunschKriterium)
|
|
{
|
|
wunschliste.Add(token.Beschreibung);
|
|
}
|
|
else if (token.TokenType == TokenTyp.AusschlussKriterium)
|
|
{
|
|
ausschlussliste.Add(token.Beschreibung);
|
|
}
|
|
}
|
|
}
|
|
|
|
TokenBoxWunschAnzeige.EditValue = wunschliste;
|
|
TokenBoxAusschlussAnzeige.EditValue = ausschlussliste;
|
|
}));
|
|
}
|
|
|
|
LoadEmployeeCriterias();
|
|
}
|
|
|
|
private void LoadEmployeeCriterias()
|
|
{
|
|
ServiceFacade.DoOperationsServiceAsync(
|
|
r => r.GetAllTokens(SchulbegleitenderZugehoerigkeitsTyp.Mitarbeiter, 0), tokens => this.Dispatch(delegate
|
|
{
|
|
_VerfuegbareWunschkriterien.Clear();
|
|
_VerfuegbareAusschlusskriterien.Clear();
|
|
|
|
foreach (var token in tokens)
|
|
{
|
|
if (token.TokenType == TokenTyp.WunschKriterium)
|
|
{
|
|
if (!_VerfuegbareWunschkriterien.ContainsKey(token.Beschreibung))
|
|
{
|
|
_VerfuegbareWunschkriterien.Add(token.Beschreibung, token);
|
|
}
|
|
}
|
|
|
|
if (token.TokenType == TokenTyp.AusschlussKriterium)
|
|
{
|
|
if (!_VerfuegbareAusschlusskriterien.ContainsKey(token.Beschreibung))
|
|
{
|
|
_VerfuegbareAusschlusskriterien.Add(token.Beschreibung, token);
|
|
}
|
|
}
|
|
}
|
|
}));
|
|
}
|
|
|
|
private void RBMaennlich_OnClick(object sender, RoutedEventArgs e)
|
|
{
|
|
var isOtherActive = RBWeiblich.IsChecked != null && RBWeiblich.IsChecked.Value;
|
|
|
|
if (RBMaennlich.IsChecked != null && RBMaennlich.IsChecked.Value)
|
|
{
|
|
GeschlechtsUmwandlung(3, isOtherActive);
|
|
}
|
|
else
|
|
{
|
|
GeschlechtsUmwandlung(1, isOtherActive);
|
|
}
|
|
}
|
|
|
|
private void RBWeiblich_OnClick(object sender, RoutedEventArgs e)
|
|
{
|
|
var isOtherActive = RBMaennlich.IsChecked != null && RBMaennlich.IsChecked.Value;
|
|
|
|
GeschlechtsUmwandlung(RBWeiblich.IsChecked != null && RBWeiblich.IsChecked.Value ? 4 : 2, isOtherActive);
|
|
}
|
|
|
|
private void GeschlechtsUmwandlung(int i, bool isOtherActive)
|
|
{
|
|
var newItems = new List<SearchViewDaten>();
|
|
|
|
// 1 == entferne jungs | 2 == entferne mädels | 3 füge jungs hinzu | 4 füge mädels hinzu
|
|
|
|
if (i == 1)
|
|
{
|
|
foreach (var item in _CurrentData)
|
|
{
|
|
if (item.Geschlecht.Equals("Weiblich") && isOtherActive)
|
|
{
|
|
newItems.Add(item);
|
|
}
|
|
}
|
|
}
|
|
else if (i == 2)
|
|
{
|
|
foreach (var item in _CurrentData)
|
|
{
|
|
if (item.Geschlecht.Equals("Männlich") && isOtherActive)
|
|
{
|
|
newItems.Add(item);
|
|
}
|
|
}
|
|
}
|
|
else if (i == 3)
|
|
{
|
|
foreach (var item in _CurrentData)
|
|
{
|
|
if (!item.Geschlecht.Equals("Weiblich") && isOtherActive == false)
|
|
{
|
|
newItems.Add(item);
|
|
}
|
|
else if (isOtherActive)
|
|
{
|
|
newItems.Add(item);
|
|
}
|
|
}
|
|
}
|
|
else if (i == 4)
|
|
{
|
|
foreach (var item in _CurrentData)
|
|
{
|
|
if (!item.Geschlecht.Equals("Männlich") && isOtherActive == false)
|
|
{
|
|
newItems.Add(item);
|
|
}
|
|
else if (isOtherActive)
|
|
{
|
|
newItems.Add(item);
|
|
}
|
|
}
|
|
}
|
|
|
|
GridControlPossibleVertreter.ItemsSource = newItems;
|
|
|
|
AbhaengigkeitGeschlechtPLZOrt();
|
|
|
|
GridControlPossibleVertreter.RefreshData();
|
|
GridControlPossibleVertreter.RefreshUI();
|
|
}
|
|
|
|
private void OrtKlient_OnTextChanged(object sender, TextChangedEventArgs e)
|
|
{
|
|
List<SearchViewDaten> ndaten = new List<SearchViewDaten>();
|
|
|
|
foreach (var daten in _CurrentData)
|
|
{
|
|
if (daten.Stadt != null)
|
|
{
|
|
if (daten.Postleitzahl != null && daten.Postleitzahl.StartsWith(PlzKlient.Text) &&
|
|
daten.Stadt.StartsWith(OrtKlient.Text))
|
|
{
|
|
ndaten.Add(daten);
|
|
}
|
|
else if (daten.Stadt.StartsWith(OrtKlient.Text) && PlzKlient.Text.Length == 0)
|
|
{
|
|
ndaten.Add(daten);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if (PlzKlient.Text.Length == 0 && OrtKlient.Text.Length == 0)
|
|
{
|
|
ndaten.Add(daten);
|
|
}
|
|
else if (daten.Postleitzahl != null && daten.Postleitzahl.StartsWith(PlzKlient.Text))
|
|
{
|
|
ndaten.Add(daten);
|
|
}
|
|
}
|
|
}
|
|
|
|
GridControlPossibleVertreter.ItemsSource = ndaten;
|
|
|
|
RbErmittler(ndaten);
|
|
|
|
GridControlPossibleVertreter.RefreshData();
|
|
GridControlPossibleVertreter.RefreshUI();
|
|
}
|
|
|
|
private void PlzKlient_OnTextChanged(object sender, EditValueChangedEventArgs e)
|
|
{
|
|
List<SearchViewDaten> ndaten = new List<SearchViewDaten>();
|
|
|
|
foreach (var daten in _CurrentData)
|
|
{
|
|
if (daten.Postleitzahl != null)
|
|
{
|
|
if (daten.Stadt != null && daten.Stadt.StartsWith(OrtKlient.Text) &&
|
|
daten.Postleitzahl.StartsWith(PlzKlient.Text))
|
|
{
|
|
ndaten.Add(daten);
|
|
}
|
|
else if (daten.Postleitzahl.StartsWith(PlzKlient.Text) && OrtKlient.Text.Length == 0)
|
|
{
|
|
ndaten.Add(daten);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if (PlzKlient.Text.Length == 0 && OrtKlient.Text.Length == 0)
|
|
{
|
|
ndaten.Add(daten);
|
|
}
|
|
else if (daten.Stadt != null && daten.Stadt.StartsWith(OrtKlient.Text))
|
|
{
|
|
ndaten.Add(daten);
|
|
}
|
|
}
|
|
}
|
|
|
|
GridControlPossibleVertreter.ItemsSource = ndaten;
|
|
|
|
RbErmittler(ndaten);
|
|
|
|
GridControlPossibleVertreter.RefreshData();
|
|
GridControlPossibleVertreter.RefreshUI();
|
|
}
|
|
|
|
private void AbhaengigkeitGeschlechtPLZOrt()
|
|
{
|
|
var ndaten = new List<SearchViewDaten>();
|
|
|
|
if (OrtKlient.Text.Length != 0 && PlzKlient.Text.Length == 0)
|
|
{
|
|
foreach (var daten in _CurrentData)
|
|
{
|
|
if (daten.Stadt != null)
|
|
{
|
|
if (daten.Postleitzahl != null && daten.Postleitzahl.StartsWith(PlzKlient.Text) &&
|
|
daten.Stadt.StartsWith(OrtKlient.Text))
|
|
{
|
|
ndaten.Add(daten);
|
|
}
|
|
else if (daten.Stadt.StartsWith(OrtKlient.Text) && PlzKlient.Text.Length == 0)
|
|
{
|
|
ndaten.Add(daten);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if (PlzKlient.Text.Length == 0 && OrtKlient.Text.Length == 0)
|
|
{
|
|
ndaten.Add(daten);
|
|
}
|
|
else if (daten.Postleitzahl != null && daten.Postleitzahl.StartsWith(PlzKlient.Text))
|
|
{
|
|
ndaten.Add(daten);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
else if (PlzKlient.Text.Length != 0 && OrtKlient.Text.Length == 0)
|
|
{
|
|
foreach (var daten in _CurrentData)
|
|
{
|
|
if (daten.Postleitzahl != null)
|
|
{
|
|
if (daten.Stadt != null && daten.Stadt.StartsWith(OrtKlient.Text) &&
|
|
daten.Postleitzahl.StartsWith(PlzKlient.Text))
|
|
{
|
|
ndaten.Add(daten);
|
|
}
|
|
else if (daten.Postleitzahl.StartsWith(PlzKlient.Text) && OrtKlient.Text.Length == 0)
|
|
{
|
|
ndaten.Add(daten);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if (PlzKlient.Text.Length == 0 && OrtKlient.Text.Length == 0)
|
|
{
|
|
ndaten.Add(daten);
|
|
}
|
|
else if (daten.Stadt != null && daten.Stadt.StartsWith(OrtKlient.Text))
|
|
{
|
|
ndaten.Add(daten);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
else if(PlzKlient.Text.Length != 0 && OrtKlient.Text.Length != 0)
|
|
{
|
|
//muss noch ermittelt werden
|
|
foreach (var daten in _CurrentData)
|
|
{
|
|
if (daten.Stadt != null && daten .Postleitzahl != null && daten.Stadt.StartsWith(OrtKlient.Text) &&
|
|
daten.Postleitzahl.StartsWith(PlzKlient.Text))
|
|
{
|
|
ndaten.Add(daten);
|
|
}
|
|
}
|
|
}else if (PlzKlient.Text.Length == 0 && OrtKlient.Text.Length == 0)
|
|
{
|
|
foreach (var daten in _CurrentData)
|
|
{
|
|
ndaten.Add(daten);
|
|
}
|
|
}
|
|
|
|
GridControlPossibleVertreter.ItemsSource = ndaten;
|
|
|
|
RbErmittler(ndaten);
|
|
|
|
GridControlPossibleVertreter.RefreshData();
|
|
GridControlPossibleVertreter.RefreshUI();
|
|
}
|
|
|
|
private void RbErmittler(List<SearchViewDaten> daten )
|
|
{
|
|
bool isOtherActive = RBMaennlich.IsChecked.Value;
|
|
|
|
if (RBWeiblich.IsChecked.Value)
|
|
{
|
|
Geschlechtsermittlung(daten,4, isOtherActive);
|
|
}
|
|
else
|
|
{
|
|
Geschlechtsermittlung(daten, 2, isOtherActive);
|
|
}
|
|
|
|
bool isOtherActive2 = RBWeiblich.IsChecked.Value;
|
|
|
|
if (RBMaennlich.IsChecked.Value)
|
|
{
|
|
Geschlechtsermittlung(daten, 3, isOtherActive2);
|
|
}
|
|
else
|
|
{
|
|
Geschlechtsermittlung(daten, 1, isOtherActive2);
|
|
}
|
|
}
|
|
|
|
private void Geschlechtsermittlung(IEnumerable<SearchViewDaten> daten, int i, bool isOtherActive)
|
|
{
|
|
List<SearchViewDaten> newItems = new List<SearchViewDaten>();
|
|
|
|
// 1 == entferne jungs | 2 == entferne mädels | 3 füge jungs hinzu | 4 füge mädels hinzu
|
|
|
|
if (i == 1)
|
|
{
|
|
foreach (var item in daten)
|
|
{
|
|
if (item.Geschlecht.Equals("Weiblich") && isOtherActive)
|
|
{
|
|
newItems.Add(item);
|
|
}
|
|
}
|
|
}
|
|
else if (i == 2)
|
|
{
|
|
foreach (var item in daten)
|
|
{
|
|
if (item.Geschlecht.Equals("Männlich") && isOtherActive)
|
|
{
|
|
newItems.Add(item);
|
|
}
|
|
}
|
|
}
|
|
else if (i == 3)
|
|
{
|
|
foreach (var item in daten)
|
|
{
|
|
if (!item.Geschlecht.Equals("Weiblich") && isOtherActive == false)
|
|
{
|
|
newItems.Add(item);
|
|
}
|
|
else if (isOtherActive)
|
|
{
|
|
newItems.Add(item);
|
|
}
|
|
}
|
|
}
|
|
else if (i == 4)
|
|
{
|
|
foreach (var item in daten)
|
|
{
|
|
if (!item.Geschlecht.Equals("Männlich") && isOtherActive == false)
|
|
{
|
|
newItems.Add(item);
|
|
}
|
|
else if (isOtherActive)
|
|
{
|
|
newItems.Add(item);
|
|
}
|
|
}
|
|
}
|
|
|
|
GridControlPossibleVertreter.ItemsSource = newItems;
|
|
|
|
GridControlPossibleVertreter.RefreshData();
|
|
GridControlPossibleVertreter.RefreshUI();
|
|
}
|
|
|
|
private void LetzteVertreter_OnLostFocus(object sender, RoutedEventArgs e)
|
|
{
|
|
ListBoxLetzteVertreter.SelectedIndex = -1;
|
|
}
|
|
|
|
private void LetzteVertreter_OnSelectionChanged(object sender, SelectionChangedEventArgs e)
|
|
{
|
|
if (ListBoxLetzteVertreter.SelectedItem is SearchViewDaten selectedItem)
|
|
{
|
|
var items = new BindingList<SearchViewDaten>((List<SearchViewDaten>) GridControlPossibleVertreter.ItemsSource);
|
|
|
|
foreach (var item in items)
|
|
{
|
|
if (item.Vorname == selectedItem.Vorname && item.Nachname == selectedItem.Nachname)
|
|
{
|
|
GridControlPossibleVertreter.SelectedItem = item;
|
|
GridControlPossibleVertreter.View.ScrollIntoView(GridControlPossibleVertreter.View.FocusedRowHandle);
|
|
}
|
|
|
|
}
|
|
}
|
|
}
|
|
|
|
private void TableView_OnRowDoubleClick(object sender, RowDoubleClickEventArgs e)
|
|
{
|
|
if (!(GridControlPossibleVertreter.SelectedItem is SearchViewDaten item))
|
|
{
|
|
return;
|
|
}
|
|
|
|
CloseSearchView(item);
|
|
}
|
|
|
|
private void CloseSearchView(SearchViewDaten item)
|
|
{
|
|
var vertreter = item.EmployeeDC.CompactEmployee;
|
|
|
|
RaiseCustomEvent?.Invoke(this, new VertretungSelectedEventArgs(vertreter, _SubstitutionStart, _SubstitutionEnd, _Tagesansicht, _Wochenansicht));
|
|
|
|
Close();
|
|
}
|
|
|
|
public event PropertyChangedEventHandler PropertyChanged;
|
|
|
|
[NotifyPropertyChangedInvocator]
|
|
protected virtual void OnPropertyChanged([CallerMemberName] string propertyName = null)
|
|
{
|
|
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
|
|
}
|
|
}
|
|
|
|
public class VertretungSelectedEventArgs : EventArgs
|
|
{
|
|
public VertretungSelectedEventArgs(CompactEmployeeDC employee, DateTime vertretungVon, DateTime vertretungBis, TagesansichtVM tagesItem, WochenansichtVM wochenItem)
|
|
{
|
|
Employee = employee;
|
|
VertretungVon = vertretungVon;
|
|
VertretungBis = vertretungBis;
|
|
TagesItem = tagesItem;
|
|
WochenItem = wochenItem;
|
|
}
|
|
|
|
public CompactEmployeeDC Employee { get; set; }
|
|
|
|
public DateTime? VertretungVon { get; set; }
|
|
|
|
public DateTime? VertretungBis { get; set; }
|
|
|
|
public TagesansichtVM TagesItem { get; set; }
|
|
|
|
public WochenansichtVM WochenItem { get; set; }
|
|
|
|
}
|
|
|
|
public class SearchViewDaten
|
|
{
|
|
public string Vorname { get; set; }
|
|
public string Nachname { get; set; }
|
|
public string Postleitzahl { get; set; }
|
|
public string Strasse { get; set; }
|
|
public string Stadt { get; set; }
|
|
public string Geschlecht { get; set; }
|
|
public string Arbeitszeit { get; set; }
|
|
public CompactVertreterEmployeeDC EmployeeDC{ get; set; }
|
|
|
|
public SearchViewDaten(string vorname,string nachname, string postleitzahl, string strasse, string stadt, string arbeitszeit, CompactVertreterEmployeeDC empdc, string geschlecht)
|
|
{
|
|
Vorname = vorname;
|
|
Nachname = nachname;
|
|
Postleitzahl = postleitzahl;
|
|
Strasse = strasse;
|
|
Stadt = stadt;
|
|
Arbeitszeit = arbeitszeit;
|
|
EmployeeDC = empdc;
|
|
Geschlecht = geschlecht;
|
|
}
|
|
|
|
public override string ToString()
|
|
{
|
|
return String.Format("{0} {1}", Vorname, Nachname);
|
|
}
|
|
}
|
|
}
|