Intervallfinder überarbeitet & Bug gefixt, der zu einem Fehler beim Suchen nach freien Intervallen über mehrere Tage geführt hatte, wenn die Enduhrzeit vor der Startuhrzeit lag. Berichte mit Parametern. Verbesserte Mitarbeiter-, Klienten-, Team-, und Organisationsdropdowns mit Suche. Quittierungsbelegresultate (zum Unterschreiben) wird wie die Zeiterfassung paginiert. FaC: neuer Kalender noch nicht fertig.
262 lines
9.6 KiB
C#
262 lines
9.6 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Collections.ObjectModel;
|
|
using System.ComponentModel;
|
|
using System.Linq;
|
|
using System.Windows;
|
|
using BeWo.Annotations;
|
|
using BeWo.Scheduling.ViewModel;
|
|
using BeWo.ServiceProxy;
|
|
using BS.Shared;
|
|
using BS.Shared.DataContracts;
|
|
using BS.Shared.Extensions;
|
|
using DevExpress.Xpf.Editors;
|
|
|
|
namespace BeWo.Scheduling.View
|
|
{
|
|
public partial class OpenAppointmentsView : INotifyPropertyChanged
|
|
{
|
|
private bool _RaiseChangeEvent = true;
|
|
|
|
public static readonly RoutedEvent ParticipationChangedEvent = EventManager.RegisterRoutedEvent(nameof(ParticipationChanged), RoutingStrategy.Bubble, typeof(RoutedEventHandler), typeof(OpenAppointmentsView));
|
|
public event RoutedEventHandler ParticipationChanged
|
|
{
|
|
add => AddHandler(ParticipationChangedEvent, value);
|
|
remove => RemoveHandler(ParticipationChangedEvent, value);
|
|
}
|
|
|
|
private void RaiseParticipationChangedEventEvent()
|
|
{
|
|
var newEventArgs = new RoutedEventArgs(ParticipationChangedEvent);
|
|
RaiseEvent(newEventArgs);
|
|
}
|
|
|
|
|
|
private ObservableCollection<SchedulingAppointmentVM> _OpenAppointments;
|
|
public ObservableCollection<SchedulingAppointmentVM> OpenAppointments
|
|
{
|
|
get => _OpenAppointments ?? (_OpenAppointments = new ObservableCollection<SchedulingAppointmentVM>());
|
|
|
|
set
|
|
{
|
|
_OpenAppointments = value is null ?
|
|
new ObservableCollection<SchedulingAppointmentVM>() :
|
|
new ObservableCollection<SchedulingAppointmentVM>(value.OrderBy(o => o.Start));
|
|
|
|
OnPropertyChanged(nameof(OpenAppointments));
|
|
}
|
|
}
|
|
|
|
private SchedulingAppointmentVM _SelectedAppointment;
|
|
|
|
public SchedulingAppointmentVM SelectedAppointment
|
|
{
|
|
get => _SelectedAppointment;
|
|
set
|
|
{
|
|
_SelectedAppointment = value;
|
|
OnPropertyChanged(nameof(SelectedAppointment));
|
|
}
|
|
}
|
|
|
|
|
|
|
|
public OpenAppointmentsView(IEnumerable<SchedulingAppointmentVM> openAppointments, IEnumerable<SchedulingAppointmentVM> statusUpdates)
|
|
{
|
|
InitializeComponent();
|
|
|
|
OpenAppointments = new ObservableCollection<SchedulingAppointmentVM>(openAppointments.Union(statusUpdates));
|
|
|
|
DataContext = this;
|
|
|
|
if(OpenAppointments.Any())
|
|
{
|
|
OpenAppointmentsList.SelectedIndex = 0;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
private void OpenAppointmentsView_OnClosing(object sender, CancelEventArgs e)
|
|
{
|
|
BeWoApp.MainControl.AufOffeneTerminePruefen();
|
|
}
|
|
|
|
public event PropertyChangedEventHandler PropertyChanged;
|
|
|
|
[NotifyPropertyChangedInvocator]
|
|
protected virtual void OnPropertyChanged(string propertyName)
|
|
{
|
|
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
|
|
}
|
|
|
|
private void UpdateView(List<SchedulerAppointmentDC> updatedAppointments)
|
|
{
|
|
ServiceFacade.DoResourceServiceAsync(s => s.GetAllOpenAppointmentsForEmployee(BeWoApp.CompactLoggedOnEmployee.EmployeeOid), openAppointments =>
|
|
{
|
|
this.Dispatch(() =>
|
|
{
|
|
var statusUpdatesAndAppointments = SchedulingUtils.Utils.SeperateStatusUpdatesAndAppointments(openAppointments);
|
|
|
|
OpenAppointments = new ObservableCollection<SchedulingAppointmentVM>(statusUpdatesAndAppointments.Appointments.Union(statusUpdatesAndAppointments.StatusUpdates));
|
|
|
|
RaiseParticipationChangedEventEvent();
|
|
|
|
ToggleControls();
|
|
|
|
if(_RaiseChangeEvent)
|
|
{
|
|
if(OpenAppointments.Count == 0)
|
|
{
|
|
Close();
|
|
}
|
|
else
|
|
{
|
|
OpenAppointmentsList.SelectedIndex = 0;
|
|
}
|
|
}
|
|
});
|
|
});
|
|
}
|
|
|
|
private void ToggleControls()
|
|
{
|
|
ZusagenStack.IsEnabled = !ZusagenStack.IsEnabled;
|
|
OkButton.IsEnabled = !OkButton.IsEnabled;
|
|
AlleBestaetigen.IsEnabled = !AlleBestaetigen.IsEnabled;
|
|
}
|
|
|
|
private void UpdateSelectedAppointment(ParticipationAnswer participationAnswer)
|
|
{
|
|
if(!(SelectedAppointment is null))
|
|
{
|
|
foreach(var employee2Appointment in SelectedAppointment.EmployeeList)
|
|
{
|
|
if(employee2Appointment.Employee.Equals(BeWoApp.CompactLoggedOnEmployee))
|
|
{
|
|
employee2Appointment.ParticipationAnswer = participationAnswer;
|
|
}
|
|
}
|
|
}
|
|
|
|
ToggleControls();
|
|
|
|
_RaiseChangeEvent = true;
|
|
|
|
ServiceFacade.DoResourceServiceAsync(s => s.UpdateSchedulerAppointments(new List<SchedulerAppointmentDC> { SelectedAppointment.CommitToDataContract() }), UpdateView);
|
|
}
|
|
|
|
private void CloseButton_OnClick(object sender, RoutedEventArgs e)
|
|
{
|
|
Close();
|
|
}
|
|
|
|
private void PopupBaseEdit_OnPopupOpening(object sender, OpenPopupEventArgs e)
|
|
{
|
|
// Es wird verhindert, dass das Popup angezeigt wird auch wenn das DateEdit readonly ist, damit man es nicht auf disabled setzen muss, da sonst die Schriftfarbe schwer lesbar ist.
|
|
e.Cancel = true;
|
|
}
|
|
|
|
private void ConfirmAllButton_OnClick(object sender, RoutedEventArgs e)
|
|
{
|
|
var appointments2Update = new List<SchedulerAppointmentDC>();
|
|
|
|
foreach(var appointment in OpenAppointments)
|
|
{
|
|
foreach(var employee2Appointment in appointment.EmployeeList)
|
|
{
|
|
employee2Appointment.IsPC_CheckedTs = DateTime.Now;
|
|
|
|
if(employee2Appointment.Employee.Equals(BeWoApp.CompactLoggedOnEmployee))
|
|
{
|
|
if(appointment.Start < DateTime.Now && appointment.End < DateTime.Now)
|
|
{
|
|
employee2Appointment.ParticipationAnswer = ParticipationAnswer.Verstrichen;
|
|
employee2Appointment.IsPC_CheckedTs = DateTime.Now;
|
|
employee2Appointment.IsPChanged = false;
|
|
}
|
|
else
|
|
{
|
|
employee2Appointment.IsPChanged = true;
|
|
employee2Appointment.ParticipationAnswer = ParticipationAnswer.Zusage;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
employee2Appointment.IsPChanged = false;
|
|
}
|
|
}
|
|
}
|
|
|
|
ToggleControls();
|
|
|
|
_RaiseChangeEvent = false;
|
|
|
|
ServiceFacade.DoResourceServiceAsync(s => s.UpdateSchedulerAppointments(appointments2Update), updatedAppointments =>
|
|
{
|
|
UpdateView(updatedAppointments);
|
|
this.Dispatch(Close);
|
|
});
|
|
}
|
|
|
|
private void ConfirmButton_OnClick(object sender, RoutedEventArgs e)
|
|
{
|
|
UpdateSelectedAppointment(ParticipationAnswer.Zusage);
|
|
}
|
|
|
|
private void ConfirmWithReservationButton_OnClick(object sender, RoutedEventArgs e)
|
|
{
|
|
UpdateSelectedAppointment(ParticipationAnswer.Vorbehalt);
|
|
}
|
|
|
|
private void RejectButton_OnClick(object sender, RoutedEventArgs e)
|
|
{
|
|
UpdateSelectedAppointment(ParticipationAnswer.Absage);
|
|
}
|
|
|
|
private void OkButton_OnClick(object sender, RoutedEventArgs e)
|
|
{
|
|
if(SelectedAppointment?.LiesInPast ?? false)
|
|
{
|
|
var employee2Appointment = SelectedAppointment.EmployeeList.ToList().Find(e2a => e2a.Employee2SchedulerAppointmentOid == SelectedAppointment.LabelKey) ??
|
|
SelectedAppointment.EmployeeList.ToList().Find(e2a => e2a.Employee.Equals(BeWoApp.CompactLoggedOnEmployee));
|
|
|
|
if(!(employee2Appointment is null))
|
|
{
|
|
if(employee2Appointment.Employee.Equals(BeWoApp.CompactLoggedOnEmployee))
|
|
{
|
|
employee2Appointment.ParticipationAnswer = ParticipationAnswer.Verstrichen;
|
|
}
|
|
|
|
employee2Appointment.IsPC_CheckedTs = DateTime.Now;
|
|
employee2Appointment.IsPChanged = true;
|
|
|
|
ToggleControls();
|
|
_RaiseChangeEvent = true;
|
|
|
|
ServiceFacade.DoResourceServiceAsync(s => s.UpdateSchedulerAppointments(new List<SchedulerAppointmentDC> { SelectedAppointment.CommitToDataContract() }), UpdateView);
|
|
return;
|
|
}
|
|
}
|
|
|
|
if(SelectedAppointment?.LabelKey is null)
|
|
{
|
|
return;
|
|
}
|
|
|
|
var employee2Appointment2 = SelectedAppointment.EmployeeList.ToList().Find(e2a => e2a.Employee2SchedulerAppointmentOid == SelectedAppointment.LabelKey);
|
|
|
|
if(employee2Appointment2 != null)
|
|
{
|
|
employee2Appointment2.IsPC_CheckedTs = DateTime.Now;
|
|
employee2Appointment2.IsPChanged = false;
|
|
|
|
ToggleControls();
|
|
_RaiseChangeEvent = true;
|
|
|
|
ServiceFacade.DoResourceServiceAsync(s => s.UpdateSchedulerAppointments(new List<SchedulerAppointmentDC> { SelectedAppointment.CommitToDataContract() }), UpdateView);
|
|
}
|
|
}
|
|
}
|
|
}
|