NullPointerException bei Zusagen/Absagen von Serienterminen gefixt. Terminanzeige im HomeView hat "In Zeiterfassung übertragen"-Icons Terminanzeige Termine werden wie folgt dargestellt: [Datum]: [Betreff] MoK: Auswahl des Ladeintervalls der Zeiterfassungseinträge ist standardmäßig auf "Letzte 7 Tage" und die Änderung wird nur in der Session gespeichert. Termine in die Zeiterfassung übertragen
1132 lines
45 KiB
C#
1132 lines
45 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Collections.ObjectModel;
|
|
using System.Collections.Specialized;
|
|
using System.ComponentModel;
|
|
using System.Globalization;
|
|
using System.Linq;
|
|
using System.Windows;
|
|
using System.Windows.Controls;
|
|
using System.Windows.Data;
|
|
using System.Windows.Input;
|
|
using BeWo.Annotations;
|
|
using BeWo.Core;
|
|
using BeWo.Scheduler.Utils;
|
|
using BeWo.Scheduler.ViewModel;
|
|
using BeWo.ServiceProxy;
|
|
using BeWo.View;
|
|
using BeWo.View.Detail;
|
|
using BeWo.View.Search;
|
|
|
|
using BS.Shared;
|
|
using BS.Shared.Core;
|
|
using BS.Shared.DataContracts;
|
|
using BS.Shared.DataContracts.Compact;
|
|
using BS.Shared.Extensions;
|
|
using DevExpress.Xpf.Editors;
|
|
using DevExpress.Xpf.Scheduler.UI;
|
|
using DevExpress.XtraScheduler;
|
|
using Employee2SchedulerAppointmentDC = BS.Shared.DataContracts.Employee2SchedulerAppointmentDC;
|
|
using SchedulerControl = DevExpress.Xpf.Scheduler.SchedulerControl;
|
|
|
|
namespace BeWo.Scheduler.View
|
|
{
|
|
public partial class SchedulerAppointmentEditForm : INotifyPropertyChanged
|
|
{
|
|
public bool IsInCustomerViewMode { get; set; }
|
|
|
|
private readonly bool _IsInTaskViewMode;
|
|
|
|
private List<ValueListEntryDC> _Categories;
|
|
public List<ValueListEntryDC> Categories
|
|
{
|
|
get => _Categories;
|
|
set { _Categories = value; OnPropertyChanged(nameof(Categories)); }
|
|
}
|
|
|
|
private List<ResourceDC> _ResourceList;
|
|
public List<ResourceDC> ResourceList
|
|
{
|
|
get => _ResourceList;
|
|
set { _ResourceList = value; OnPropertyChanged(nameof(ResourceList)); }
|
|
}
|
|
|
|
public SchedulerAppointmentListVM ViewModel { get; set; }
|
|
|
|
private static void RecurrenceControlLoaded(object sender, RoutedEventArgs e)
|
|
{
|
|
LocalizeVisualChild(sender as DependencyObject);
|
|
}
|
|
|
|
public NewSchedulerAppointmentFormController NewSchedulerAppointmentFormController => Controller as NewSchedulerAppointmentFormController;
|
|
|
|
private ObservableCollection<ResourceDC> _SelectedResources;
|
|
public ObservableCollection<ResourceDC> SelectedResources
|
|
{
|
|
get => _SelectedResources ?? (_SelectedResources = new ObservableCollection<ResourceDC>(NewSchedulerAppointmentFormController.ResourceList ?? new List<ResourceDC>()));
|
|
set
|
|
{
|
|
_SelectedResources = value;
|
|
SelectedResources.CollectionChanged += SelectedResourcesCollectionChanged;
|
|
NewSchedulerAppointmentFormController.ResourceList = value.ToList();
|
|
OnPropertyChanged(nameof(SelectedResources));
|
|
}
|
|
}
|
|
|
|
private ObservableCollection<Employee2SchedulerAppointmentDC> _SelectedEmployees;
|
|
public ObservableCollection<Employee2SchedulerAppointmentDC> SelectedEmployees
|
|
{
|
|
get => _SelectedEmployees ?? (_SelectedEmployees = new ObservableCollection<Employee2SchedulerAppointmentDC>(NewSchedulerAppointmentFormController.EmployeeList ?? new ObservableCollection<Employee2SchedulerAppointmentDC>()));
|
|
set
|
|
{
|
|
if(_SelectedEmployees.Equals(value))
|
|
{
|
|
return;
|
|
}
|
|
|
|
_SelectedEmployees = value;
|
|
SelectedEmployees.CollectionChanged += SelectedEmployeesCollectionChanged;
|
|
NewSchedulerAppointmentFormController.EmployeeList = value;
|
|
OnPropertyChanged(nameof(SelectedEmployees));
|
|
}
|
|
}
|
|
|
|
private ObservableCollection<CompactCustomerDC> _SelectedCustomers;
|
|
public ObservableCollection<CompactCustomerDC> SelectedCustomers
|
|
{
|
|
get => _SelectedCustomers ?? (_SelectedCustomers = new ObservableCollection<CompactCustomerDC>(NewSchedulerAppointmentFormController.CustomerList ?? new List<CompactCustomerDC>()));
|
|
set
|
|
{
|
|
if(_SelectedCustomers.Equals(value))
|
|
{
|
|
return;
|
|
}
|
|
|
|
_SelectedCustomers = value;
|
|
SelectedCustomers.CollectionChanged += SelectedCustomersCollectionChanged;
|
|
NewSchedulerAppointmentFormController.CustomerList = value.ToList();
|
|
OnPropertyChanged(nameof(SelectedCustomers));
|
|
}
|
|
}
|
|
|
|
private ObservableCollection<CompactSupportConceptDC> _SelectedSupportConcepts;
|
|
|
|
public ObservableCollection<CompactSupportConceptDC> SelectedSupportConcepts
|
|
{
|
|
get => _SelectedSupportConcepts ?? (_SelectedSupportConcepts = new ObservableCollection<CompactSupportConceptDC>(NewSchedulerAppointmentFormController.SupportConceptList ?? new List<CompactSupportConceptDC>()));
|
|
|
|
set
|
|
{
|
|
if(Equals(_SelectedSupportConcepts, value))
|
|
{
|
|
return;
|
|
}
|
|
|
|
_SelectedSupportConcepts = value;
|
|
SelectedSupportConcepts.CollectionChanged += SelectedSupportConceptsCollectionChanged;
|
|
NewSchedulerAppointmentFormController.SupportConceptList = value.ToList();
|
|
OnPropertyChanged(nameof(SelectedSupportConcepts));
|
|
}
|
|
}
|
|
|
|
public static Appointment CurrentAppointment { get; set; }
|
|
public static bool IsNew { get; set; }
|
|
public static bool IsOwnAppointment { get; set; }
|
|
public static bool IsAllowedToChange { get; set; }
|
|
|
|
public InformationView InformationView { get; set; }
|
|
public CompactCustomerDC Customer { get; set; }
|
|
|
|
public SchedulerAppointmentEditForm(SchedulerAppointmentListVM vm, SchedulerControl schedulerControl, Appointment appointment, IEnumerable<CompactEmployeeDC> employees, IEnumerable<CompactCustomerDC> customers, Dictionary<ValueListEntryDC, List<ResourceDC>> categoriesToResources, bool pIsInTaskViewMode) : base(schedulerControl, appointment)
|
|
{
|
|
ViewModel = vm;
|
|
|
|
CurrentAppointment = appointment;
|
|
IsNew = Controller.IsNewAppointment;
|
|
|
|
IsOwnAppointment = Equals(BeWoApp.CompactLoggedOnEmployee, NewSchedulerAppointmentFormController.Originator) && (NewSchedulerAppointmentFormController.EmployeeList?.Count == 0 || NewSchedulerAppointmentFormController.EmployeeList.Any(a => Equals(a.Employee, BeWoApp.CompactLoggedOnEmployee)));
|
|
|
|
_IsInTaskViewMode = pIsInTaskViewMode;
|
|
|
|
InitializeComponent();
|
|
|
|
EdtRecurrenceType.Visibility = ShouldShowRecurrence ? Visibility.Visible : Visibility.Collapsed;
|
|
|
|
SelectedResources.CollectionChanged += SelectedResourcesCollectionChanged;
|
|
SelectedCustomers.CollectionChanged += SelectedCustomersCollectionChanged;
|
|
SelectedEmployees.CollectionChanged += SelectedEmployeesCollectionChanged;
|
|
SelectedSupportConcepts.CollectionChanged += SelectedSupportConceptsCollectionChanged;
|
|
|
|
DataContext = this;
|
|
|
|
Categories = categoriesToResources.Keys.ToList();
|
|
|
|
if(categoriesToResources.Count > 0)
|
|
{
|
|
ResourceList = categoriesToResources.First().Value;
|
|
}
|
|
|
|
MonthlyRecurrenceControl.Loaded += RecurrenceControlLoaded;
|
|
YearlyRecurrenceControl.Loaded += RecurrenceControlLoaded;
|
|
|
|
ResourcesTreeSearchView.Sauce = categoriesToResources;
|
|
ResourcesTreeSearchView.AusgewaehlteRessourcen = SelectedResources.ToList();
|
|
ResourcesTreeSearchView.CommandBindings.Add(new CommandBinding(ApplicationCommands.Close, (s, e) => this.Dispatch(() => { PopupResource.IsOpen = false; })));
|
|
|
|
MultiEmployeeSearch.Sauce = employees.ToObservableCollection();
|
|
MultiEmployeeSearch.AusgewaehlteMitarbeiter = SelectedEmployees.Select(e=>e.Employee).ToList();
|
|
MultiEmployeeSearch.CommandBindings.Add(new CommandBinding(ApplicationCommands.Close, (s, e) => this.Dispatch(() => { PopupEmployee.IsOpen = false; })));
|
|
|
|
MultiCustomerSearch.Sauce = customers.ToObservableCollection();
|
|
MultiCustomerSearch.AusgewaehlteKlienten = SelectedCustomers.ToList();
|
|
MultiCustomerSearch.CommandBindings.Add(new CommandBinding(ApplicationCommands.Close, (s, e) => this.Dispatch(() => { CustomerSearchViewPopup.IsOpen = false; })));
|
|
|
|
EdtRecurrenceType.CustomDisplayText += EdtRecurrenceType_CustomDisplayText;
|
|
|
|
if(_IsInTaskViewMode && !SelectedEmployees.Any(a => a.Employee.Equals(BeWoApp.CompactLoggedOnEmployee)))
|
|
{
|
|
SelectedEmployees.Add(new Employee2SchedulerAppointmentDC { Employee = BeWoApp.CompactLoggedOnEmployee });
|
|
MitarbeiterToggleButton.IsChecked = true;
|
|
}
|
|
|
|
InitRights();
|
|
}
|
|
|
|
private void InitRights()
|
|
{
|
|
var darfKlientenAnsehen = BeWoUtils.HasRight(UserRightType.CustomerView_View) || BeWoUtils.HasRight(UserRightType.Customer_ViewMyTeams) || BeWoUtils.HasRight(UserRightType.Customer_ViewMyCustomers);
|
|
var darfKliententermineAnlegen = BeWoUtils.HasRight(UserRightType.KalenderKliententermineAnlegen);
|
|
var darfKliententermineAendern = BeWoUtils.HasRight(UserRightType.KalenderKliententermineAendern);
|
|
|
|
var darfMitarbeitertermineAnlegen = BeWoUtils.HasRight(UserRightType.KalenderMitarbeitertermineAnlegen);
|
|
var darfMitarbeitertermineAendern = BeWoUtils.HasRight(UserRightType.KalenderMitarbeitertermineAendern);
|
|
|
|
var darfRessourcentermineAnlegen = BeWoUtils.HasRight(UserRightType.KalenderRessourcentermineAnlegen);
|
|
var darfRessourcentermineAendern = BeWoUtils.HasRight(UserRightType.KalenderRessourcentermineAendern);
|
|
|
|
|
|
if(IsNew && !darfKliententermineAnlegen)
|
|
{
|
|
KlientenPopUpOeffnenBtn.Visibility = Visibility.Hidden;
|
|
SelectedCustomers.Clear();
|
|
}
|
|
|
|
if(!IsNew && (!darfKliententermineAendern || !darfKlientenAnsehen) || !darfKlientenAnsehen)
|
|
{
|
|
KlientenPopUpOeffnenBtn.Visibility = Visibility.Hidden;
|
|
}
|
|
|
|
// --------------------------------------------------------------------
|
|
|
|
if(IsNew && !darfMitarbeitertermineAnlegen)
|
|
{
|
|
MitarbeiterPopUpOeffnenBtn.Visibility = Visibility.Hidden;
|
|
SelectedEmployees.Clear();
|
|
}
|
|
|
|
if(!IsNew && (!darfMitarbeitertermineAendern || !darfMitarbeitertermineAnlegen))
|
|
{
|
|
MitarbeiterPopUpOeffnenBtn.Visibility = Visibility.Hidden;
|
|
}
|
|
|
|
// --------------------------------------------------------------------
|
|
|
|
if(IsNew && !darfRessourcentermineAnlegen)
|
|
{
|
|
RessourcenPopUpOeffnenBtn.Visibility = Visibility.Hidden;
|
|
SelectedResources.Clear();
|
|
}
|
|
|
|
if(!IsNew && !darfRessourcentermineAendern)
|
|
{
|
|
RessourcenPopUpOeffnenBtn.Visibility = Visibility.Hidden;
|
|
}
|
|
|
|
// --------------------------------------------------------------------
|
|
|
|
var customerOids = new List<long>();
|
|
ServiceFacade.DoEmployeeServiceSync(s => customerOids = s.LoadTeamsRelatedCustomerOids(BeWoApp.CompactLoggedOnEmployee.EmployeeOid));
|
|
|
|
var checkType = IsNew ? SchedulerRightsCheckType.Create : SchedulerRightsCheckType.Edit;
|
|
var allowedToChange = BS.Shared.Core.Utils.CheckSchedulerRights(SelectedCustomers.ToList(), SelectedResources.ToList(), SelectedEmployees.ToList(), NewSchedulerAppointmentFormController.Originator, IsNew, checkType, BeWoApp.LoggedOnUser, customerOids, true);
|
|
|
|
if(_IsInTaskViewMode)
|
|
{
|
|
BetreffLabel.Content = "Titel";
|
|
StartLabel.Content = "Beginn";
|
|
|
|
EndDate.Visibility = Visibility.Collapsed;
|
|
EndTime.Visibility = Visibility.Collapsed;
|
|
EndLabel.Visibility = Visibility.Collapsed;
|
|
|
|
StartTimeTextEdit.Visibility = Visibility.Collapsed;
|
|
|
|
AllDay.Visibility = Visibility.Collapsed;
|
|
OrtLabel.Visibility = Visibility.Collapsed;
|
|
Ort.Visibility = Visibility.Collapsed;
|
|
SerienLabel.Visibility = Visibility.Collapsed;
|
|
EdtRecurrenceType.Visibility = Visibility.Collapsed;
|
|
SerienGrid.Visibility = Visibility.Collapsed;
|
|
IsPrivateCheckBox.Visibility = Visibility.Collapsed;
|
|
NoticeLabel.Visibility = Visibility.Collapsed;
|
|
Notice.Visibility = Visibility.Collapsed;
|
|
|
|
DueDateLabel.Visibility = Visibility.Visible;
|
|
DueDate.Visibility = Visibility.Visible;
|
|
DueDateTime.Visibility = Visibility.Visible;
|
|
TaskDescriptionLabel.Visibility = Visibility.Visible;
|
|
TaskDescription.Visibility = Visibility.Visible;
|
|
|
|
SupportConceptBtn.Visibility = Visibility.Visible;
|
|
SupportConceptsPopUpOeffnenBtn.Visibility = Visibility.Visible;
|
|
SelectedSupportConceptsListBox.Visibility = Visibility.Visible;
|
|
|
|
CustomersLabel.Visibility = Visibility.Collapsed;
|
|
CustomersGrid.Visibility = Visibility.Collapsed;
|
|
CustomerSearchViewPopup.Visibility = Visibility.Collapsed;
|
|
SelectedCustomersListBox.Visibility = Visibility.Collapsed;
|
|
KlientenPopUpOeffnenBtn.Visibility = Visibility.Collapsed;
|
|
|
|
ResourceLabel.Visibility = Visibility.Collapsed;
|
|
ResourceToggleButtonGrid.Visibility = Visibility.Collapsed;
|
|
RessourcenPopUpOeffnenBtn.Visibility = Visibility.Collapsed;
|
|
PopupResource.Visibility = Visibility.Collapsed;
|
|
ResourceListBox.Visibility = Visibility.Collapsed;
|
|
|
|
StartDateDateEdit.IsEnabled = false;
|
|
BetreffEditText.IsEnabled = false;
|
|
DueDate.IsEnabled = false;
|
|
DueDateTime.IsEnabled = false;
|
|
SupportConceptBtn.IsEnabled = false;
|
|
SupportConceptsPopUpOeffnenBtn.IsEnabled = false;
|
|
Notice.IsEnabled = false;
|
|
TaskDescription.IsEnabled = false;
|
|
CompletedDate.IsEnabled = false;
|
|
MitarbeiterPopUpOeffnenBtn.IsEnabled = false;
|
|
|
|
DeleteButton.Visibility = Visibility.Collapsed;
|
|
|
|
SelectedCustomers.Clear();
|
|
|
|
if (!Controller.IsNewAppointment)
|
|
{
|
|
NoticeLabel.Visibility = Visibility.Visible;
|
|
Notice.Visibility = Visibility.Visible;
|
|
|
|
CompletedDateLabel.Visibility = Visibility.Visible;
|
|
CompletedDate.Visibility = Visibility.Visible;
|
|
}
|
|
}
|
|
|
|
NewSchedulerAppointmentFormController.DisplayDueDateTime = NewSchedulerAppointmentFormController.DueDate;
|
|
|
|
IsAllowedToChange = allowedToChange;
|
|
|
|
if(allowedToChange)
|
|
{
|
|
return;
|
|
}
|
|
|
|
BetreffEditText.IsReadOnly = true;
|
|
Ort.IsReadOnly = true;
|
|
StartDateDateEdit.IsReadOnly = true;
|
|
StartTimeTextEdit.IsReadOnly = true;
|
|
AllDay.IsReadOnly = true;
|
|
EndDate.IsReadOnly = true;
|
|
EndTime.IsReadOnly = true;
|
|
TaskDescription.IsReadOnly = true;
|
|
CompletedDate.IsReadOnly = true;
|
|
EdtRecurrenceType.IsReadOnly = true;
|
|
IsPrivateCheckBox.IsEnabled = false;
|
|
Notice.IsReadOnly = true;
|
|
|
|
KlientenPopUpOeffnenBtn.Visibility = Visibility.Hidden;
|
|
MitarbeiterPopUpOeffnenBtn.Visibility = Visibility.Hidden;
|
|
RessourcenPopUpOeffnenBtn.Visibility = Visibility.Hidden;
|
|
SupportConceptsPopUpOeffnenBtn.Visibility = Visibility.Collapsed;
|
|
|
|
OkButton.Visibility = Visibility.Collapsed;
|
|
DeleteButton.Visibility = Visibility.Collapsed;
|
|
|
|
CancelButton.HorizontalAlignment = HorizontalAlignment.Right;
|
|
}
|
|
|
|
private static void EdtRecurrenceType_CustomDisplayText(object sender, CustomDisplayTextEventArgs e)
|
|
{
|
|
var conv = new Converter.Recurrence2GermanConverter();
|
|
|
|
e.DisplayText = (string) conv.Convert(e.EditValue, typeof (string), null, null);
|
|
e.Handled = true;
|
|
}
|
|
|
|
public string CountSelectedEmployees => $"{SelectedEmployees.Count} " + BS.Shared.Translation.Translator.Translate("MitarbeiterPlural") + " ausgewählt";
|
|
public string CountSelectedResources => $"{SelectedResources.Count} Ressourcen ausgewählt";
|
|
public string CountSelectedCustomers => $"{SelectedCustomers.Count} " + BS.Shared.Translation.Translator.Translate("Klienten") + " ausgewählt";
|
|
public string CountSelectedSupportConcepts => $"{SelectedSupportConcepts.Count} Hilfepläne ausgewählt";
|
|
|
|
public override AppointmentFormController CreateFormController(SchedulerControl schedulerControl, Appointment appointment)
|
|
{
|
|
return new NewSchedulerAppointmentFormController(schedulerControl, appointment);
|
|
}
|
|
|
|
private void SelectedCustomersCollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
|
|
{
|
|
NewSchedulerAppointmentFormController.CustomerList = SelectedCustomers.ToList();
|
|
MultiCustomerSearch.AusgewaehlteKlienten = SelectedCustomers.ToList();
|
|
}
|
|
|
|
private void SelectedResourcesCollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
|
|
{
|
|
NewSchedulerAppointmentFormController.ResourceList = SelectedResources.ToList();
|
|
ResourcesTreeSearchView.AusgewaehlteRessourcen = SelectedResources.ToList();
|
|
}
|
|
|
|
private void SelectedEmployeesCollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
|
|
{
|
|
NewSchedulerAppointmentFormController.EmployeeList = SelectedEmployees;
|
|
MultiEmployeeSearch.AusgewaehlteMitarbeiter = SelectedEmployees.Select(em => em.Employee).ToList();
|
|
}
|
|
|
|
private void SelectedSupportConceptsCollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
|
|
{
|
|
NewSchedulerAppointmentFormController.SupportConceptList = SelectedSupportConcepts.ToList();
|
|
}
|
|
|
|
public event PropertyChangedEventHandler PropertyChanged;
|
|
[NotifyPropertyChangedInvocator]
|
|
protected void OnPropertyChanged(string propertyName)
|
|
{
|
|
var handler = PropertyChanged;
|
|
handler?.Invoke(this, new PropertyChangedEventArgs(propertyName));
|
|
}
|
|
|
|
private void EmployeePopupClick(object sender, RoutedEventArgs e)
|
|
{
|
|
PopupEmployee.IsOpen = true;
|
|
}
|
|
|
|
private void CustomerPopUpEditClick(object sender, RoutedEventArgs e)
|
|
{
|
|
ResourcesTreeSearchView.AusgewaehlteRessourcen = _SelectedResources.ToList();
|
|
CustomerSearchViewPopup.IsOpen = true;
|
|
}
|
|
|
|
private void ResourcePopUpClick(object sender, RoutedEventArgs e)
|
|
{
|
|
PopupResource.IsOpen = true;
|
|
}
|
|
|
|
private void OkButtonClick(object sender, RoutedEventArgs e)
|
|
{
|
|
try
|
|
{
|
|
if(NewSchedulerAppointmentFormController.IsTask)
|
|
{
|
|
MessageBox.Show("Aufgaben können nur im Hilfeplan angelegt und geändert werden", "Speichern nicht möglich", MessageBoxButton.OK, MessageBoxImage.Warning);
|
|
|
|
return;
|
|
}
|
|
|
|
var isWeeklyRecurrence = RecurrenceVisualController.IsWeeklyRecurrence;
|
|
var weekDays = WeeklyRecurrenceControl.WeekDays;
|
|
|
|
if (isWeeklyRecurrence && weekDays == 0)
|
|
{
|
|
MessageBox.Show("Bei einem sich wöchentlich wiederholenden Termin muss mindestens ein Wochentag ausgewählt sein!", "Fehler", MessageBoxButton.OK, MessageBoxImage.Warning);
|
|
|
|
return;
|
|
}
|
|
|
|
Controller.Storage.BeginUpdate();
|
|
|
|
var employees = NewSchedulerAppointmentFormController.EmployeeList;
|
|
var customers = NewSchedulerAppointmentFormController.CustomerList;
|
|
var resources = NewSchedulerAppointmentFormController.ResourceList;
|
|
var originator = NewSchedulerAppointmentFormController.Originator;
|
|
var isPrivate = NewSchedulerAppointmentFormController.IsPrivate;
|
|
var isTask = NewSchedulerAppointmentFormController.IsTask;
|
|
var taskDescription = NewSchedulerAppointmentFormController.TaskDescription;
|
|
var dueDate = NewSchedulerAppointmentFormController.DueDate;
|
|
var dueTime = NewSchedulerAppointmentFormController.DisplayDueDateTime;
|
|
var completedDate = NewSchedulerAppointmentFormController.CompletedDate;
|
|
var completedNotice = Appointment.Description;
|
|
var supportConceptList = NewSchedulerAppointmentFormController.SupportConceptList;
|
|
var start = NewSchedulerAppointmentFormController.Start;
|
|
var end = NewSchedulerAppointmentFormController.End;
|
|
|
|
ViewModel.NewVM.AllDay = NewSchedulerAppointmentFormController.AllDay;
|
|
ViewModel.NewVM.IsPrivate = isPrivate;
|
|
ViewModel.NewVM.ResourceList = resources;
|
|
ViewModel.NewVM.CustomerList = customers;
|
|
ViewModel.NewVM.EmployeeList = new ObservableCollection<Employee2SchedulerAppointmentDC>(employees);
|
|
ViewModel.NewVM.Originator = originator;
|
|
ViewModel.NewVM.IsTask = isTask;
|
|
ViewModel.NewVM.TaskDescription = taskDescription;
|
|
ViewModel.NewVM.DueDate = dueDate;
|
|
ViewModel.NewVM.DueTime = dueTime;
|
|
ViewModel.NewVM.CompletedDate = completedDate;
|
|
ViewModel.NewVM.CompletedNotice = completedNotice;
|
|
ViewModel.NewVM.SupportConceptList = supportConceptList;
|
|
ViewModel.NewVM.Start = start;
|
|
ViewModel.NewVM.End = end;
|
|
|
|
if (isTask && dueDate.HasValue)
|
|
{
|
|
ViewModel.NewVM.End = dueDate.Value.GetShortDateTime().AddDays(1);
|
|
}
|
|
|
|
// Änderung an den CustomFields lösen das NewSchedulerStorage_AppointmentsChanged-Event aus
|
|
|
|
var employeeOids = new List<long>();
|
|
var customerOids = new List<long>();
|
|
|
|
foreach (var emp in employees)
|
|
{
|
|
employeeOids.AddIfNotIn(emp.Employee.EmployeeOid);
|
|
}
|
|
|
|
foreach (var customer in customers)
|
|
{
|
|
customerOids.AddIfNotIn(customer.CustomerOid);
|
|
}
|
|
|
|
var item = Appointment.GetSourceObject(Control.GetCoreStorage());
|
|
|
|
ViewModel.ShouldLockOverlappingAppointmentCheck = Appointment.Type == AppointmentType.ChangedOccurrence;
|
|
|
|
if (Appointment.RecurrenceInfo != null)
|
|
{
|
|
var customFieldStorage = Appointment.GetCustomFieldStorage();
|
|
var serviceRecords = customFieldStorage?.ServiceRecordList ?? new List<ServiceRecordDC>();
|
|
|
|
ViewModel.ApplyChangesToChangedOccurencyCustomFields(employees, customers, resources, originator, isPrivate, Appointment.RecurrenceIndex.ToString(), new Guid(Appointment.RecurrenceInfo.Id.ToString()), isTask, taskDescription, completedDate, dueDate, completedNotice, supportConceptList, Appointment.Subject, Appointment.AllDay, serviceRecords);
|
|
|
|
var oldRecurrenceInfo = Appointment.RecurrenceInfo.ToXml();
|
|
var newRecurrenceInfo = ViewModel.NewVM.RecurrenceInfo;
|
|
|
|
if(!Equals(oldRecurrenceInfo, newRecurrenceInfo))
|
|
{
|
|
// Damit wird verhindert, dass beim Ändern von Zeitangaben bei Serienterminen die Ausnahmen gelöscht werden.
|
|
SaveFlagToInternInfo();
|
|
}
|
|
}
|
|
|
|
ApplyChanges();
|
|
}
|
|
catch (Exception exception)
|
|
{
|
|
MessageBox.Show(exception.Message + "\n" + exception.StackTrace);
|
|
}
|
|
finally
|
|
{
|
|
Controller.Storage.EndUpdate();
|
|
ViewModel.ShouldLockOverlappingAppointmentCheck = false;
|
|
}
|
|
}
|
|
|
|
private void CancelButtonClick(object sender, RoutedEventArgs e)
|
|
{
|
|
Cancel();
|
|
}
|
|
|
|
private void DeleteButtonClick(object sender, RoutedEventArgs e)
|
|
{
|
|
DeleteAppointment();
|
|
}
|
|
|
|
private void CreatZeiterfassungButtonClick(object sender, RoutedEventArgs e)
|
|
{
|
|
var employ = SelectedMitarbeiter.Items;
|
|
var y = SelectedCustomersListBox.Items;
|
|
|
|
|
|
if(y.Count == 0)
|
|
{
|
|
MessageBox.Show("Bitte wählen Sie mindestens " + BS.Shared.Translation.Translator.Translate("einen Klienten") + " aus!");
|
|
}
|
|
else
|
|
{
|
|
var startDate = StartDateDateEdit.DateTime;
|
|
var startTime = DateTime.Parse(StartTimeTextEdit.Text);
|
|
|
|
var endDate = EndDate.DateTime;
|
|
var endTime = DateTime.Parse(EndTime.Text);
|
|
|
|
var start = new DateTime(startDate.Year, startDate.Month, startDate.Day, startTime.Hour, startTime.Minute, startTime.Second);
|
|
var end = new DateTime(endDate.Year, endDate.Month, endDate.Day, endTime.Hour, endTime.Minute, endTime.Second);
|
|
|
|
var employeelist = (from Employee2SchedulerAppointmentDC xy in employ select xy.Employee).ToList();
|
|
|
|
var customerlist = y.Cast<CompactCustomerDC>().ToList();
|
|
|
|
BeWoUtils.CreateZeiterfassung(start, end, customerlist, employeelist, Notice.Text);
|
|
}
|
|
}
|
|
|
|
private void BtnRemoveElement_Click(object sender, RoutedEventArgs e)
|
|
{
|
|
if(_IsInTaskViewMode)
|
|
{
|
|
return;
|
|
}
|
|
|
|
var obj = ((Button) sender).Tag;
|
|
|
|
switch(obj)
|
|
{
|
|
case ResourceDC res:
|
|
SelectedResources.Remove(res);
|
|
OnPropertyChanged(nameof(CountSelectedResources));
|
|
break;
|
|
case CompactCustomerDC cus:
|
|
SelectedCustomers.Remove(cus);
|
|
OnPropertyChanged(nameof(CountSelectedCustomers));
|
|
break;
|
|
case CompactSupportConceptDC sup:
|
|
SelectedSupportConcepts.Remove(sup);
|
|
OnPropertyChanged(nameof(CountSelectedSupportConcepts));
|
|
break;
|
|
}
|
|
|
|
if(!(obj is Employee2SchedulerAppointmentDC))
|
|
{
|
|
return;
|
|
}
|
|
|
|
var emp = (Employee2SchedulerAppointmentDC) obj;
|
|
SelectedEmployees.Remove(emp);
|
|
OnPropertyChanged(nameof(CountSelectedEmployees));
|
|
}
|
|
private void btnInformation_Click(object sender, RoutedEventArgs e)
|
|
{
|
|
var obj = ((Button)sender).Tag;
|
|
|
|
if (obj == null || !(obj is CompactCustomerDC))
|
|
return;
|
|
|
|
Customer = (CompactCustomerDC)obj;
|
|
|
|
InformationView = new InformationView();
|
|
//ServiceFacade.DoOperationsServiceAsync(s => s.GetXAMLInformationStringForScheduler(Customer.CustomerOid), OpenWindow);
|
|
|
|
InformationView.SetXaml(ServiceFacade.DoOperationsServiceSync(s => s.GetXAMLInformationStringForScheduler(Customer.CustomerOid)));
|
|
|
|
var beWoWindow = new BeWoWindow();
|
|
InformationView.ButtonCloseClicked += () => beWoWindow.Close();
|
|
|
|
beWoWindow.Height = 200;
|
|
beWoWindow.Width = 600;
|
|
beWoWindow.WindowStartupLocation = WindowStartupLocation.CenterOwner;
|
|
beWoWindow.GroupBoxContent = InformationView;
|
|
beWoWindow.Owner = BeWoApp.CurrentBeWo.MainWindow;
|
|
//beWoWindow.rootGroupBox.Header = "Auslastung von " + Customer.FirstName + " " + Customer.LastName;
|
|
beWoWindow.ShowDialog();
|
|
}
|
|
|
|
public void OpenWindow(string xaml)
|
|
{
|
|
this.Dispatch(() =>
|
|
{
|
|
InformationView.SetXaml(xaml);
|
|
|
|
var beWoWindow = new BeWoWindow();
|
|
|
|
beWoWindow.Height = 200;
|
|
beWoWindow.Width = 500;
|
|
beWoWindow.WindowStartupLocation = WindowStartupLocation.CenterOwner;
|
|
beWoWindow.GroupBoxContent = Control;
|
|
beWoWindow.Owner = BeWoApp.CurrentBeWo.MainWindow;
|
|
beWoWindow.rootGroupBox.Header = "Auslastung von " + Customer.FirstName + " " + Customer.LastName;
|
|
beWoWindow.ShowDialog();
|
|
});
|
|
}
|
|
|
|
private void ResourcesTreeSearchView_OnSelectionChanged(object sender, RoutedEventArgs e)
|
|
{
|
|
var resourcesTreeSearchView = (ResourcesTreeSearchView) e.Source;
|
|
|
|
var resOC = resourcesTreeSearchView.SelectedResources.ToObservableCollection();
|
|
foreach (var res in resOC.Where(res => !SelectedResources.Contains(res)))
|
|
{
|
|
SelectedResources.Add(res);
|
|
}
|
|
|
|
SelectedResources = SelectedResources.Except(SelectedResources.Where(sr => !resOC.Contains(sr)).ToList()).ToObservableCollection();
|
|
|
|
OnPropertyChanged(nameof(CountSelectedResources));
|
|
}
|
|
|
|
private void MultiEmployeeSearch_OnSelectionChanged(object sender, RoutedEventArgs e)
|
|
{
|
|
var multiEmployeeSearch = (MultiEmployeeSearch)e.Source;
|
|
|
|
var empOC = multiEmployeeSearch.SelectedEmployees.ToObservableCollection();
|
|
foreach (var emp in empOC.Where(emp => !SelectedEmployees.Any(se => se.Employee.Equals(emp))))
|
|
{
|
|
SelectedEmployees.Add(new Employee2SchedulerAppointmentDC { Employee = emp, ParticipationAnswer = ParticipationAnswer.Offen });
|
|
}
|
|
|
|
var ex = SelectedEmployees.Where(se => !empOC.Contains(se.Employee));
|
|
var ab = SelectedEmployees.Except(ex);
|
|
var cd = ab.ToObservableCollection();
|
|
SelectedEmployees = cd;
|
|
|
|
OnPropertyChanged(nameof(CountSelectedEmployees));
|
|
}
|
|
|
|
private void MultiCustomerSearch_OnSelectionChanged(object sender, RoutedEventArgs e)
|
|
{
|
|
var multiCustomerSearchView = (MultiCustomerSearchView)e.Source;
|
|
SelectedCustomers = multiCustomerSearchView.SelectedCustomers.ToObservableCollection();
|
|
|
|
OnPropertyChanged(nameof(CountSelectedCustomers));
|
|
}
|
|
|
|
private void SupportConceptsPopUpClick(object sender, RoutedEventArgs e)
|
|
{
|
|
PopupSupportConcepts.IsOpen = true;
|
|
}
|
|
|
|
private void SupportConceptSelectionControl_ItemSelected(object sender, EventArgs<CompactSupportConceptDC> e)
|
|
{
|
|
PopupSupportConcepts.IsOpen = false;
|
|
|
|
SelectedSupportConcepts.Clear();
|
|
SelectedSupportConcepts.Add(e.Data);
|
|
|
|
OnPropertyChanged(nameof(CountSelectedSupportConcepts));
|
|
OnPropertyChanged(nameof(SelectedSupportConcepts));
|
|
}
|
|
|
|
private void BtnRemoveSupportConcept_Click(object sender, RoutedEventArgs e)
|
|
{
|
|
if(((Button) sender).Tag is CompactSupportConceptDC dc)
|
|
{
|
|
SelectedSupportConcepts.Remove(dc);
|
|
|
|
OnPropertyChanged(nameof(CountSelectedSupportConcepts));
|
|
}
|
|
}
|
|
|
|
private void DueDate_OnEditValueChanged(object sender, EditValueChangedEventArgs e)
|
|
{
|
|
// if(e.NewValue != null && e.NewValue is DateTime dueDate)
|
|
// {
|
|
// var newEnd = dueDate.GetShortDateTime().AddDays(1);
|
|
|
|
// NewSchedulerAppointmentFormController.End = newEnd;
|
|
// NewSchedulerAppointmentFormController.DisplayEnd = newEnd;
|
|
// NewSchedulerAppointmentFormController.DisplayEndDate = newEnd;
|
|
//}
|
|
}
|
|
|
|
/*
|
|
* Appointment.End:
|
|
* ======================================================================================================
|
|
* The End property is usually specified by the Appointment.Start and Appointment.
|
|
* Duration properties, and is always calculated as End = Start + Duration.
|
|
* When setting the End property, the Appointment. Start property retains its value, and the Appointment.
|
|
* Duration is changed according to the new value of the End property.
|
|
* If the new Appointment. End property's value is less than the Appointment.
|
|
* Start property's value, an exception is raised.
|
|
*
|
|
* Ende = Start + Vorherige Dauer
|
|
*/
|
|
|
|
private DateTime? _PreviousEndDate;
|
|
private DateTime? _PreviousEndDate2;
|
|
|
|
private bool _EndTimeHasBeenChangedByStartTime;
|
|
private bool _EndDateHasBeenChangedByStartDate;
|
|
|
|
// TODO: Bei jeder Änderung darauf achten, dass keinn anderer Wert manipuliert wird!
|
|
|
|
private void StartDate_OnChange(object sender, EditValueChangedEventArgs e)
|
|
{
|
|
// BeWoApp.LogMessage("StartDate changed", Colors.DarkTurquoise);
|
|
// LogAllDates();
|
|
|
|
//_EndTimeHasBeenChangedByStartTime = false;
|
|
|
|
// _PreviousEndDate2 = NewSchedulerAppointmentFormController.End;
|
|
|
|
//_EndDateHasBeenChangedByStartDate = true;
|
|
}
|
|
|
|
private void EndDate_OnChange(object sender, EditValueChangedEventArgs e)
|
|
{
|
|
// BeWoApp.LogMessage("EndDate changed", Colors.DarkTurquoise);
|
|
// LogAllDates();
|
|
|
|
//_EndTimeHasBeenChangedByStartTime = false;
|
|
|
|
|
|
// if(_EndDateHasBeenChangedByStartDate && _PreviousEndDate2.HasValue)
|
|
// {
|
|
// var start = NewSchedulerAppointmentFormController.Start;
|
|
|
|
// if(_PreviousEndDate2 > start)
|
|
// {
|
|
// var neuesEnddatum = NewSchedulerAppointmentFormController.End.MergeDatesByDateReversed(_PreviousEndDate2.Value);
|
|
|
|
// //NewSchedulerAppointmentFormController.End = neuesEnddatum;
|
|
// }
|
|
// }
|
|
|
|
// _EndDateHasBeenChangedByStartDate = true;
|
|
}
|
|
|
|
private void StartTimeTextEdit_OnEditValueChanged(object sender, EditValueChangedEventArgs e)
|
|
{
|
|
// BeWoApp.LogMessage("StartTime changed", Colors.DarkTurquoise);
|
|
// LogAllDates();
|
|
|
|
//_PreviousEndDate = NewSchedulerAppointmentFormController.End;
|
|
|
|
// _EndTimeHasBeenChangedByStartTime = true;
|
|
}
|
|
|
|
private void EndTimeTextEdit_OnEditValueChanged(object sender, EditValueChangedEventArgs e)
|
|
{
|
|
// BeWoApp.LogMessage("EndTime changed", Colors.DarkTurquoise);
|
|
// LogAllDates();
|
|
|
|
//if (_EndTimeHasBeenChangedByStartTime && _PreviousEndDate.HasValue)
|
|
// {
|
|
// var start = NewSchedulerAppointmentFormController.Start;
|
|
|
|
// if (_PreviousEndDate > start)
|
|
// {
|
|
// //NewSchedulerAppointmentFormController.End = NewSchedulerAppointmentFormController.End.MergeDatesByDate(_PreviousEndDate.Value);
|
|
// }
|
|
// }
|
|
|
|
// _EndTimeHasBeenChangedByStartTime = false;
|
|
}
|
|
|
|
// Was beeinflusst was? Startzeit -> Endzeit
|
|
// Ganztag -> DisplayEndDate
|
|
//
|
|
|
|
private void AllDay_OnEditValueChanged(object sender, EditValueChangedEventArgs e)
|
|
{
|
|
//BeWoApp.LogMessage("AllDay changed", Colors.DarkTurquoise);
|
|
//LogAllDates();
|
|
}
|
|
|
|
private static void SaveFlagToInternInfo()
|
|
{
|
|
if (CurrentAppointment.IsRecurring)
|
|
{
|
|
var internalInfo = CurrentAppointment.GetCustomFieldStorage().InternalInfo ?? new InternalInfo();
|
|
internalInfo.IsTimeChangedRecurringAppointment = true;
|
|
|
|
CurrentAppointment.GetCustomFieldStorage().InternalInfo = internalInfo;
|
|
}
|
|
}
|
|
|
|
private void LogAllDates()
|
|
{
|
|
var initialStartValue = NewSchedulerAppointmentFormController.Start;
|
|
var initialEndValue = NewSchedulerAppointmentFormController.End;
|
|
var isAllDay = NewSchedulerAppointmentFormController.AllDay;
|
|
var initialDisplayStart = NewSchedulerAppointmentFormController.DisplayStart;
|
|
var initialDisplayEnd = NewSchedulerAppointmentFormController.DisplayEnd;
|
|
|
|
BeWoApp.LogMessage("\n" +
|
|
$"\t\t\tIs AllDay: {isAllDay}\n" +
|
|
$"\t\t\tStart: {initialStartValue:dd.MM.yy HH:mm}\n" +
|
|
$"\t\t\tEnd: {initialEndValue:dd.MM.yy HH:mm}\n" +
|
|
$"\t\t\tDisplayStart: {initialDisplayStart:dd.MM.yy HH:mm}\n" +
|
|
$"\t\t\tDisplayEnd: {initialDisplayEnd:dd.MM.yy HH:mm}");
|
|
}
|
|
|
|
|
|
}
|
|
|
|
public class NewSchedulerAppointmentFormController : AppointmentFormController
|
|
{
|
|
private List<ResourceDC> SourceResourceList
|
|
{
|
|
get => SourceAppointment.CF_ResourceList();
|
|
set => SourceAppointment.CF_ResourceList(value);
|
|
}
|
|
public List<ResourceDC> ResourceList
|
|
{
|
|
get => EditedAppointmentCopy.CF_ResourceList();
|
|
set => EditedAppointmentCopy.CF_ResourceList(value);
|
|
}
|
|
|
|
private ObservableCollection<Employee2SchedulerAppointmentDC> SourceEmployeeList
|
|
{
|
|
get => SourceAppointment.CF_EmployeeList();
|
|
set => SourceAppointment.CF_EmployeeList(value);
|
|
}
|
|
public ObservableCollection<Employee2SchedulerAppointmentDC> EmployeeList
|
|
{
|
|
get => EditedAppointmentCopy.CF_EmployeeList();
|
|
set => EditedAppointmentCopy.CF_EmployeeList(value);
|
|
}
|
|
|
|
private List<CompactCustomerDC> SourceCustomerList
|
|
{
|
|
get => SourceAppointment.CF_CustomerList();
|
|
set => SourceAppointment.CF_CustomerList(value);
|
|
}
|
|
public List<CompactCustomerDC> CustomerList
|
|
{
|
|
get => EditedAppointmentCopy.CF_CustomerList();
|
|
set => EditedAppointmentCopy.CF_CustomerList(value);
|
|
}
|
|
|
|
private List<CompactSupportConceptDC> SourceSupportConceptList
|
|
{
|
|
get => SourceAppointment.CF_SupportConceptList();
|
|
set => SourceAppointment.CF_SupportConceptList(value);
|
|
}
|
|
public List<CompactSupportConceptDC> SupportConceptList
|
|
{
|
|
get => EditedAppointmentCopy.CF_SupportConceptList();
|
|
set => EditedAppointmentCopy.CF_SupportConceptList(value);
|
|
}
|
|
|
|
private CompactEmployeeDC SourceOriginator
|
|
{
|
|
get => SourceAppointment.CF_Originator();
|
|
set => SourceAppointment.CF_Originator(value);
|
|
}
|
|
public CompactEmployeeDC Originator
|
|
{
|
|
get => EditedAppointmentCopy.CF_Originator();
|
|
set => EditedAppointmentCopy.CF_Originator(value);
|
|
}
|
|
|
|
private bool SourceIsPrivate
|
|
{
|
|
get => SourceAppointment.CF_IsPrivate();
|
|
set => SourceAppointment.CF_IsPrivate(value);
|
|
}
|
|
public bool IsPrivate
|
|
{
|
|
get => EditedAppointmentCopy.CF_IsPrivate();
|
|
set => EditedAppointmentCopy.CF_IsPrivate(value);
|
|
}
|
|
|
|
private DateTime? SourceDueDate
|
|
{
|
|
get => SourceAppointment.CF_DueDate();
|
|
set => SourceAppointment.CF_DueDate(value);
|
|
}
|
|
public DateTime? DueDate
|
|
{
|
|
get => EditedAppointmentCopy.CF_DueDate();
|
|
set => EditedAppointmentCopy.CF_DueDate(value);
|
|
}
|
|
|
|
public DateTime? DisplayDueDateDate
|
|
{
|
|
get => DueDate?.Date;
|
|
set
|
|
{
|
|
if (value == null)
|
|
{
|
|
DueDate = null;
|
|
|
|
EditedAppointmentCopy.Start = DateTime.Now;
|
|
EditedAppointmentCopy.End = new DateTime(9999, 12, 31, 0, 0, 0);
|
|
|
|
NotifyPropertyChanged(nameof(DisplayDueDateTime));
|
|
|
|
return;
|
|
}
|
|
|
|
var newEnd = value.Value.Date.AddDays(1);
|
|
|
|
EditedAppointmentCopy.Start = CompletedDate.HasValue ? newEnd.AddDays(-1) : DateTime.Today;
|
|
EditedAppointmentCopy.End = newEnd;
|
|
|
|
if (DueDate == null)
|
|
{
|
|
DueDate = value;
|
|
|
|
NotifyPropertyChanged(nameof(DisplayDueDateTime));
|
|
return;
|
|
}
|
|
|
|
DueDate = value.Value.MergeDatesByDate(DueDate.Value);//new DateTime(value.Value.Year, value.Value.Month, value.Value.Day, DueDate.Value.Hour, DueDate.Value.Minute, DueDate.Value.Second));
|
|
NotifyPropertyChanged(nameof(DisplayDueDateTime));
|
|
}
|
|
}
|
|
|
|
private DateTime? _DueTime;
|
|
|
|
public DateTime? DisplayDueDateTime
|
|
{
|
|
get => _DueTime ?? EditedAppointmentCopy.CF_DueDate();
|
|
|
|
set
|
|
{
|
|
if(!Equals(value, _DueTime))
|
|
{
|
|
_DueTime = value;
|
|
}
|
|
}
|
|
}
|
|
|
|
private DateTime? SourceCompletedDate
|
|
{
|
|
get => SourceAppointment.CF_CompletedDate();
|
|
set => SourceAppointment.CF_CompletedDate(value);
|
|
|
|
}
|
|
|
|
public DateTime? CompletedDate
|
|
{
|
|
get => EditedAppointmentCopy.CF_CompletedDate();
|
|
set => EditedAppointmentCopy.CF_CompletedDate(value);
|
|
|
|
}
|
|
|
|
public DateTime? DisplayCompletedDateDate
|
|
{
|
|
get => CompletedDate?.Date;
|
|
set
|
|
{
|
|
if (CompletedDate == null)
|
|
{
|
|
CompletedDate = value;
|
|
return;
|
|
}
|
|
|
|
if (value != null)
|
|
{
|
|
CompletedDate = new DateTime(value.Value.Year, value.Value.Month, value.Value.Day, CompletedDate.Value.Hour, CompletedDate.Value.Minute, CompletedDate.Value.Second);
|
|
}
|
|
}
|
|
}
|
|
|
|
public TimeSpan? DisplayCompletedDateTime
|
|
{
|
|
get => CompletedDate?.TimeOfDay;
|
|
|
|
set
|
|
{
|
|
if (CompletedDate != null && value.HasValue)
|
|
{
|
|
CompletedDate = CompletedDate.Value.Date + value.Value;
|
|
}
|
|
}
|
|
}
|
|
|
|
private bool SourceIsTask
|
|
{
|
|
get => SourceAppointment.CF_IsTask();
|
|
set => SourceAppointment.CF_IsTask(value);
|
|
}
|
|
public bool IsTask
|
|
{
|
|
get => EditedAppointmentCopy.CF_IsTask();
|
|
set => EditedAppointmentCopy.CF_IsTask(value);
|
|
}
|
|
|
|
private string SourceTaskDescription
|
|
{
|
|
get => SourceAppointment.CF_TaskDescription();
|
|
set => SourceAppointment.CF_TaskDescription(value);
|
|
}
|
|
public string TaskDescription
|
|
{
|
|
get => EditedAppointmentCopy.CF_TaskDescription();
|
|
set => EditedAppointmentCopy.CF_TaskDescription(value);
|
|
}
|
|
|
|
public override bool IsAppointmentChanged()
|
|
{
|
|
if(base.IsAppointmentChanged())
|
|
{
|
|
return true;
|
|
}
|
|
|
|
if (SourceResourceList != null && ResourceList != null ||
|
|
SourceEmployeeList != null && EmployeeList != null ||
|
|
SourceCustomerList != null && CustomerList != null ||
|
|
SourceOriginator != null && Originator != null)
|
|
{
|
|
return false;
|
|
}
|
|
|
|
var resourceListsAreEqual = SourceResourceList == null || ResourceList == null || !Equals(SourceResourceList, ResourceList);
|
|
var employeeListsAreEqual = SourceEmployeeList == null || EmployeeList == null || !Equals(SourceEmployeeList, EmployeeList);
|
|
var customerListsAreEqual = SourceCustomerList == null || CustomerList == null || !Equals(SourceCustomerList, CustomerList);
|
|
var originatorsAreEqual = SourceOriginator == null || Originator == null || !Equals(SourceOriginator, Originator);
|
|
var isPrivatesAreEqual = !Equals(SourceIsPrivate, IsPrivate);
|
|
var dueDatesAreEqal = Equals(SourceDueDate, DueDate);
|
|
var completedDatesAreEqal = Equals(SourceCompletedDate, CompletedDate);
|
|
var taskDescriptionsAreEqual = Equals(SourceTaskDescription, TaskDescription);
|
|
var supportConceptListsAreEqual = SourceSupportConceptList == null || SupportConceptList == null || !Equals(SourceSupportConceptList, SupportConceptList);
|
|
|
|
return resourceListsAreEqual || employeeListsAreEqual || customerListsAreEqual || originatorsAreEqual || isPrivatesAreEqual || dueDatesAreEqal || completedDatesAreEqal || taskDescriptionsAreEqual || supportConceptListsAreEqual;
|
|
}
|
|
|
|
public NewSchedulerAppointmentFormController(SchedulerControl control, Appointment apt) : base(control, apt)
|
|
{
|
|
|
|
}
|
|
|
|
protected override void ApplyCustomFieldsValues()
|
|
{
|
|
SourceResourceList = ResourceList;
|
|
SourceEmployeeList = EmployeeList;
|
|
SourceCustomerList = CustomerList;
|
|
SourceOriginator = Originator;
|
|
SourceIsPrivate = IsPrivate;
|
|
SourceDueDate = DueDate;
|
|
|
|
if(_DueTime.HasValue)
|
|
{
|
|
SourceDueDate = SourceDueDate?.MergeDatesByDate(_DueTime.Value);
|
|
}
|
|
|
|
SourceCompletedDate = CompletedDate;
|
|
SourceTaskDescription = TaskDescription;
|
|
SourceSupportConceptList = SupportConceptList;
|
|
}
|
|
}
|
|
|
|
public class RemoveElementVisibilityConverter : IValueConverter
|
|
{
|
|
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
|
{
|
|
if(value == null)
|
|
{
|
|
return Visibility.Visible;
|
|
}
|
|
|
|
var customerOids = new List<long>();
|
|
ServiceFacade.DoEmployeeServiceSync(s => customerOids = s.LoadTeamsRelatedCustomerOids(BeWoApp.CompactLoggedOnEmployee.EmployeeOid));
|
|
|
|
var isNew = SchedulerAppointmentEditForm.IsNew;
|
|
|
|
var isAllowedToChange = BeWoUtils.CheckSchedulerRights(SchedulerAppointmentEditForm.CurrentAppointment, isNew, SchedulerRightsCheckType.Edit, customerOids, true);
|
|
|
|
return isAllowedToChange ? Visibility.Visible : Visibility.Hidden;
|
|
}
|
|
|
|
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
|
|
{
|
|
throw new NotImplementedException();
|
|
}
|
|
}
|
|
public class InformationVisibilityConverter : IValueConverter
|
|
{
|
|
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
|
{
|
|
return value is CompactCustomerDC ? Visibility.Visible : Visibility.Collapsed;
|
|
}
|
|
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
|
|
{
|
|
throw new NotImplementedException();
|
|
}
|
|
}
|
|
}
|