149 lines
5.2 KiB
C#
149 lines
5.2 KiB
C#
using BS.Shared.DataContracts;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using System.Windows;
|
|
|
|
namespace BeWo.View.Controls
|
|
{
|
|
public class DPCtrlEmployee : DienstplanerControl
|
|
{
|
|
public static readonly DependencyProperty EmployeeInformationProperty = DependencyProperty.Register(
|
|
"EmployeeInformation",
|
|
typeof(DPCtrlEmployeeInformation),
|
|
typeof(DPCtrlEmployee),
|
|
new UIPropertyMetadata(
|
|
(s, e) =>
|
|
{
|
|
var information = (DPCtrlEmployeeInformation)e.NewValue;
|
|
var ctrl = (DPCtrlEmployee)s;
|
|
|
|
if (ctrl != null)
|
|
{
|
|
if (information != null)
|
|
{
|
|
if(information.Employee != null)
|
|
{
|
|
switch (information.Row)
|
|
{
|
|
case 0:
|
|
ctrl.BorderBlack.BorderThickness = new Thickness(0, 0, 1, 0);
|
|
ctrl.BorderLight.BorderThickness = new Thickness(0, 0, 0, 1);
|
|
break;
|
|
case 1:
|
|
ctrl.BorderBlack.BorderThickness = new Thickness(0, 0, 1, 0);
|
|
ctrl.BorderLight.BorderThickness = new Thickness(0, 0, 0, 1);
|
|
break;
|
|
case 2:
|
|
ctrl.BorderBlack.BorderThickness = new Thickness(0, 0, 1, 1);
|
|
ctrl.BorderLight.BorderThickness = new Thickness(0, 0, 0, 1);
|
|
break;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
ctrl.BorderBlack.BorderThickness = new Thickness(0, 0, 1, 2);
|
|
ctrl.BorderLight.BorderThickness = new Thickness(0, 0, 0, 2);
|
|
}
|
|
|
|
|
|
ctrl.Text = ctrl.DisplayMember;
|
|
|
|
ctrl.ToolTip = new DPCtrlEmployeeTooltip(information.Employee, information.Contracts);
|
|
}
|
|
else
|
|
{
|
|
ctrl.ToolTip = null;
|
|
}
|
|
}
|
|
}));
|
|
|
|
|
|
|
|
public DPCtrlEmployee()
|
|
{
|
|
InitializeComponent();
|
|
FontSize = 12;
|
|
txt.HorizontalAlignment = HorizontalAlignment.Left;
|
|
}
|
|
|
|
public DPCtrlEmployeeInformation EmployeeInformation
|
|
{
|
|
get { return (DPCtrlEmployeeInformation)GetValue(EmployeeInformationProperty); }
|
|
|
|
set { SetValue(EmployeeInformationProperty, value); }
|
|
}
|
|
|
|
public string DisplayMember
|
|
{
|
|
get
|
|
{
|
|
var sb = new StringBuilder();
|
|
if (EmployeeInformation.Employee != null)
|
|
{
|
|
switch (EmployeeInformation.Row)
|
|
{
|
|
|
|
case 0: return EmployeeInformation.Employee.LastNameFirstName;
|
|
|
|
case 1:
|
|
|
|
foreach (var contract in EmployeeInformation.Contracts)
|
|
{
|
|
sb.Append(contract.EmploymentType?.Name);
|
|
sb.Append('/');
|
|
}
|
|
|
|
sb.Remove(sb.Length - 1, 1);
|
|
|
|
return sb.ToString();
|
|
|
|
case 2:
|
|
|
|
foreach (var contract in EmployeeInformation.Contracts)
|
|
{
|
|
sb.Append('(');
|
|
|
|
if (contract.EntryDate.HasValue)
|
|
sb.Append(contract.EntryDate.Value.ToString("dd.MM.yy"));
|
|
else
|
|
sb.Append("k.A.");
|
|
|
|
sb.Append('-');
|
|
|
|
if (contract.ContractEndDate.HasValue)
|
|
sb.Append(contract.ContractEndDate.Value.ToString("dd.MM.yy"));
|
|
else
|
|
sb.Append("unbefr.");
|
|
|
|
sb.Append(')');
|
|
|
|
sb.Append('/');
|
|
}
|
|
|
|
sb.Remove(sb.Length - 1, 1);
|
|
|
|
return sb.ToString();
|
|
|
|
}
|
|
}
|
|
else
|
|
{
|
|
return "Besetzungsstatus";
|
|
}
|
|
|
|
return null;
|
|
}
|
|
}
|
|
}
|
|
|
|
public class DPCtrlEmployeeInformation
|
|
{
|
|
public EmployeeDC Employee { get; set; }
|
|
public List<ContractDC> Contracts { get; set; }
|
|
public int Row { get; set; }
|
|
}
|
|
}
|