954 lines
36 KiB
C#
954 lines
36 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Windows;
|
|
using System.Windows.Controls;
|
|
using System.Windows.Input;
|
|
|
|
using BeWo.Controls;
|
|
using BeWo.Core;
|
|
using BeWo.ServiceProxy;
|
|
using BeWo.Validation;
|
|
using BeWo.View.Search;
|
|
using BeWo.ViewModel;
|
|
using BeWo.ViewModel.ListViewModel;
|
|
using BeWo.Core.Service;
|
|
|
|
using BS.Shared;
|
|
using BS.Shared.Extensions;
|
|
using BS.Shared.Core;
|
|
using BS.Shared.DataContracts;
|
|
using BS.Shared.DataContracts.ClientPartials;
|
|
using BS.Shared.DataContracts.Compact;
|
|
using BS.Shared.Services;
|
|
using BS.Shared.Translation;
|
|
using DevExpress.Xpf.RichEdit;
|
|
using SupportConceptService = BeWo.Core.Service.SupportConceptService;
|
|
|
|
namespace BeWo.View.Detail
|
|
{
|
|
public partial class ServiceRecordEditView
|
|
{
|
|
public static double DocumentationTextBoxFontSize => BeWoApp.AppSettings.DocumentationFontSize;
|
|
|
|
private readonly List<TabItem> _NoticeTabItemList;
|
|
|
|
private readonly List<TabItem> _RTFNoticeTabItemList;
|
|
|
|
private readonly List<Button> _TextModuleButtonList;
|
|
|
|
private readonly List<TextBox> _NoticeTextBoxList;
|
|
|
|
private TextBox _GrosseDokuTextBox;
|
|
|
|
private FlatSupportConceptTreeNodeDC _OriginalNode;
|
|
|
|
private ServiceCategoryDC _OldCategory;
|
|
|
|
private ServiceDescriptionDC _OldServiceDescription;
|
|
|
|
private ServiceRecordVM _ServiceRecordVM;
|
|
|
|
private CompactEmployeeDC _SelectedEmployee;
|
|
|
|
|
|
private bool _HideCustomers;
|
|
|
|
public ServiceRecordEditView()
|
|
{
|
|
InitializeComponent();
|
|
|
|
_NoticeTabItemList = new List<TabItem>
|
|
{
|
|
TabItem1_Notice,
|
|
TabItem2_Notice,
|
|
TabItem3_Notice,
|
|
TabItem4_Notice,
|
|
TabItem5_Notice
|
|
};
|
|
|
|
_RTFNoticeTabItemList = new List<TabItem>
|
|
{
|
|
TabitemRtf1Note,
|
|
TabitemRtf2Note,
|
|
TabitemRtf3Note,
|
|
TabitemRtf4Note,
|
|
TabitemRtf5Note
|
|
};
|
|
|
|
_TextModuleButtonList = new List<Button>
|
|
{
|
|
TextbausteineButton1,
|
|
TextbausteineButton2,
|
|
TextbausteineButton3,
|
|
TextbausteineButton4,
|
|
TextbausteineButton5
|
|
};
|
|
|
|
_NoticeTextBoxList = new List<TextBox>
|
|
{
|
|
TextboxNotice,
|
|
TextboxNotice2,
|
|
TextboxNotice3,
|
|
TextboxNotice4,
|
|
TextboxNotice5
|
|
};
|
|
}
|
|
|
|
public override bool CanDelete => false;
|
|
|
|
public override bool IsDirty => _ServiceRecordVM != null && _ServiceRecordVM.IsDirty;
|
|
|
|
public override string SaveObjectName => Translator.Translate("dieser Leistungsbuchung");
|
|
|
|
public override string Title => Translator.Translate("Leistungsbuchung bearbeiten");
|
|
|
|
public ServiceRecordListVM ViewModel { get; set; }
|
|
|
|
public void InitView(ServiceRecordListVM pListViewModel, ServiceRecordVM pSCViewModel, bool hideCustomerCombo)
|
|
{
|
|
InitializeComponent();
|
|
|
|
if (!hideCustomerCombo)
|
|
{
|
|
supportConceptSelectionControl.Loaded += (s, e) => SetSelectedCustomerNode();
|
|
|
|
combobox_services.SelectionChanged += (s, e) =>
|
|
{
|
|
if (combobox_services.SelectedIndex == -1)
|
|
combobox_services.SelectedIndex = 0;
|
|
};
|
|
}
|
|
else
|
|
{
|
|
supportConceptSelectionControl.Visibility = Visibility.Collapsed;
|
|
customerComboColumn.Width = new GridLength(0);
|
|
}
|
|
|
|
|
|
if (!BeWoApp.LoggedOnUser.HasRight(UserRightType.ServiceRecord_AllowCreationForOtherEmployees) && !BeWoApp.LoggedOnUser.HasRight(UserRightType.ServiceRecord_AllowCreationForOtherTeamMember))
|
|
{
|
|
lblEmployee.Visibility = Visibility.Collapsed;
|
|
popupedit_employee.Visibility = Visibility.Collapsed;
|
|
}
|
|
|
|
if (!BeWoApp.LoggedOnUser.HasRight(UserRightType.ServiceRecord_AllowCreationForOtherEmployees))
|
|
{
|
|
employeeSearchView.SearchMode = SearchMode.OnlyTeamMember;
|
|
}
|
|
|
|
numerictb_distance.Visibility = BeWoApp.AppSettings.ShowDistanceFields ? Visibility.Visible : Visibility.Collapsed;
|
|
lblDistance.Visibility = BeWoApp.AppSettings.ShowDistanceFields ? Visibility.Visible : Visibility.Collapsed;
|
|
|
|
_HideCustomers = hideCustomerCombo;
|
|
_ServiceRecordVM = pSCViewModel;
|
|
|
|
//ServiceRecordVM clone = pSCViewModel.Clone();
|
|
|
|
//clone.Category2Services = pListViewModel.PrototypeVM.Category2Services;
|
|
_OldCategory = _ServiceRecordVM.Category;
|
|
_OldServiceDescription = _ServiceRecordVM.ServiceDescription;
|
|
|
|
//_SelectedEmployee = clone.Employee;
|
|
|
|
DataContext = _ServiceRecordVM;
|
|
|
|
if (_ServiceRecordVM.Employee != null)
|
|
{
|
|
popupedit_employee.Text = _ServiceRecordVM.Employee.ToString();
|
|
}
|
|
|
|
if (!hideCustomerCombo)
|
|
{
|
|
var node = SupportConceptService.CreateFlatSupportConceptItem(pSCViewModel.SupportConcept, pSCViewModel.CostBearer);
|
|
|
|
_OriginalNode = node;
|
|
_ServiceRecordVM.ChoosenNode = node;
|
|
|
|
SetSearchText(node.CustomerName);
|
|
}
|
|
|
|
if (BeWoApp.AppSettings.ShowMarker)
|
|
{
|
|
chkServiceRecordTypeContent.Content = "Marker";
|
|
chkServiceRecordTypeContent.Visibility = Visibility.Visible;
|
|
}
|
|
else
|
|
{
|
|
if (BeWoApp.Mandator.BeWoClientType == 3)
|
|
{
|
|
//Köln Ring
|
|
chkServiceRecordTypeContent.Visibility = Visibility.Visible;
|
|
}
|
|
else
|
|
{
|
|
chkServiceRecordTypeContent.Visibility = Visibility.Collapsed;
|
|
}
|
|
}
|
|
|
|
//pListViewModel.SelectedVMForEditing = clone;
|
|
ViewModel = pListViewModel;
|
|
|
|
Focus();
|
|
TextboxNotice.Focus();
|
|
|
|
CheckRecursive(_ServiceRecordVM.GoalTree, false);
|
|
|
|
ComboBoxTreeViewControl.TreeViewSourceList = _ServiceRecordVM.GoalTree;
|
|
ComboBoxTreeViewControl.Visibility = (_ServiceRecordVM.IsGoalTreeVisible) ? Visibility.Visible : Visibility.Collapsed;
|
|
Loaded += ServiceRecordEditView_Loaded;
|
|
|
|
// TODO: Rechte beachten bezüglich der Textbausteine!
|
|
if(BeWoApp.AppSettings.ShowRtfTextfield)
|
|
{
|
|
ConfigureRTFDocTypes();
|
|
//LoadNoticeInRTFTxte();
|
|
}
|
|
else
|
|
{
|
|
ConfigureDocTypes();
|
|
}
|
|
|
|
IsEndDateVisible(pSCViewModel.ServiceRecordFormat, pSCViewModel.DurationInStunden.Value);
|
|
|
|
if (!pSCViewModel.EditAllowed)
|
|
{
|
|
GridOben.IsEnabled = false;
|
|
|
|
btnSave.Visibility = Visibility.Hidden;
|
|
}
|
|
|
|
if (_ServiceRecordVM != null)
|
|
{
|
|
ExpandCheckedGoals(_ServiceRecordVM.GoalTree);
|
|
}
|
|
|
|
if(!BeWoApp.LoggedOnUser.HasRight(UserRightType.TextbausteineAlleAnsehen) && !BeWoApp.LoggedOnUser.HasRight(UserRightType.TextbausteineNurEigeneAnsehen))
|
|
{
|
|
_TextModuleButtonList.DoForEach(button => button.Visibility = Visibility.Collapsed);
|
|
}
|
|
}
|
|
|
|
private void CheckRecursive(List<SupportConceptGoalDC> goalTree, bool wert)
|
|
{
|
|
if (goalTree != null)
|
|
{
|
|
foreach (var goal in goalTree)
|
|
{
|
|
goal.CheckRecursive = wert;
|
|
CheckRecursive(goal.Children, wert);
|
|
}
|
|
}
|
|
}
|
|
|
|
private void ExpandCheckedGoals(List<SupportConceptGoalDC> goalTree)
|
|
{
|
|
if (goalTree != null)
|
|
{
|
|
foreach (var scg in goalTree)
|
|
{
|
|
if (scg.IsChecked)
|
|
{
|
|
|
|
ExpandParent(scg);
|
|
}
|
|
|
|
ExpandCheckedGoals(scg.Children);
|
|
}
|
|
}
|
|
}
|
|
|
|
private static void ExpandParent(SupportConceptGoalDC scg)
|
|
{
|
|
if (scg.ParentGoal != null)
|
|
{
|
|
scg.ParentGoal.IsExpanded = true;
|
|
ExpandParent(scg.ParentGoal);
|
|
}
|
|
}
|
|
|
|
public void SetSearchText(string text)
|
|
{
|
|
supportConceptSelectionControl.SearchText = text;
|
|
}
|
|
|
|
public void SetLoggedOnEmployee()
|
|
{
|
|
popupedit_employee.Text = BeWoApp.LoggedOnUser.Employee.ToString();
|
|
}
|
|
|
|
private void IsEndDateVisible(ServiceRecordFormate? scv, ZeiterfassungsDauer zsd)
|
|
{
|
|
var settings = BeWoApp.AppSettings;
|
|
|
|
if (scv == ServiceRecordFormate.ZeiterfassungMitMonatJahr)
|
|
{
|
|
GridMitJahrMonat.Visibility = Visibility.Visible;
|
|
GridOhneEnddatum.Visibility = Visibility.Collapsed;
|
|
GridMitEnddatum.Visibility = Visibility.Collapsed;
|
|
|
|
numerictb_distance.SetValue(WidthProperty, (double) 93);
|
|
numerictb_distance.SetValue(HorizontalAlignmentProperty, HorizontalAlignment.Right);
|
|
lblDistance.SetValue(Grid.ColumnProperty, 0);
|
|
lblDistance.SetValue(Grid.ColumnSpanProperty, 2);
|
|
|
|
}
|
|
else
|
|
{
|
|
if (settings.IsZeiterfassungInStdMin || zsd == ZeiterfassungsDauer.Stunden)
|
|
{
|
|
MinSTDOhneEnd.Visibility = Visibility.Visible;
|
|
MinStdDauerLabel.SetValue(Grid.ColumnProperty, 0);
|
|
numerictb_duration.SetValue(Grid.ColumnProperty, 1);
|
|
MinStdDauerLabel.Content = "Dauer";
|
|
MinStdDauerlbl.Content = "Dauer";
|
|
|
|
if (zsd == ZeiterfassungsDauer.Stunden)
|
|
{
|
|
numerictb_duration.IsFloatValue = true;
|
|
numerictb_duration.Mask = "########0.00";
|
|
}
|
|
else
|
|
{
|
|
numerictb_duration.IsFloatValue = false;
|
|
numerictb_duration.Mask = "########";
|
|
}
|
|
}
|
|
|
|
if (scv == ServiceRecordFormate.ZeiterfassungMitEndDatum)//Settings.IsEndDateVisible)
|
|
{
|
|
GridMitEnddatum.Visibility = Visibility.Visible;
|
|
GridOhneEnddatum.Visibility = Visibility.Collapsed;
|
|
GridMitJahrMonat.Visibility = Visibility.Collapsed;
|
|
}
|
|
else
|
|
{
|
|
GridOhneEnddatum.Visibility = Visibility.Visible;
|
|
GridMitEnddatum.Visibility = Visibility.Collapsed;
|
|
GridMitJahrMonat.Visibility = Visibility.Collapsed;
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
public bool IsCustomerChangeAllowed()
|
|
{
|
|
var lAllowed = true;
|
|
|
|
if (_OriginalNode != null)
|
|
{
|
|
if (_ServiceRecordVM.Customer != null && _OriginalNode.SupportConceptTreeNodeDC.Customer != null && _ServiceRecordVM.Customer.CustomerOid != _OriginalNode.SupportConceptTreeNodeDC.Customer.CustomerOid)
|
|
{
|
|
if (MessageBox.Show(Translator.Translate("Möchten Sie diese Leistung wirklich auf Klient {0} umbuchen?", _ServiceRecordVM.Customer.FirstName + " " + _ServiceRecordVM.Customer.LastName), "Speichern", MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.No)
|
|
{
|
|
lAllowed = false;
|
|
}
|
|
}
|
|
else if (_ServiceRecordVM.SupportConcept != null && _OriginalNode.SupportConceptTreeNodeDC.SupportConcept != null && _ServiceRecordVM.SupportConcept.SupportConceptOid != _OriginalNode.SupportConceptTreeNodeDC.SupportConcept.SupportConceptOid)
|
|
{
|
|
if (MessageBox.Show(Translator.Translate("Möchten Sie diese Leistung wirklich auf einen anderen Hilfeplan umbuchen?"), "Speichern", MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.No)
|
|
{
|
|
lAllowed = false;
|
|
}
|
|
}
|
|
else if (_ServiceRecordVM.CostBearer != null && _OriginalNode.SupportConceptTreeNodeDC.CostBearer != null && _ServiceRecordVM.CostBearer.CostBearerOid != _OriginalNode.SupportConceptTreeNodeDC.CostBearer.CostBearerOid)
|
|
{
|
|
if (MessageBox.Show(Translator.Translate("Möchten Sie diese Leistung wirklich auf den Kostenträger {0} umbuchen?", _ServiceRecordVM.CostBearer.Name), "Speichern", MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.No)
|
|
{
|
|
lAllowed = false;
|
|
}
|
|
}
|
|
}
|
|
|
|
return lAllowed;
|
|
}
|
|
|
|
public bool IsValid()
|
|
{
|
|
var selectedNode = _ServiceRecordVM.ChoosenNode;
|
|
|
|
var lValid = !(!_HideCustomers && selectedNode == null);
|
|
|
|
lValid = ValidationTrigger.Validate(rootGrid) && lValid;
|
|
|
|
if (lValid)
|
|
{
|
|
lValid = BeWoUtils.ValidateServiceRecordVM(_ServiceRecordVM, ViewModel.StatisticsDC, _ServiceRecordVM.ChoosenNode, false, _ServiceRecordVM.Employee, null, null);
|
|
}
|
|
|
|
return lValid;
|
|
}
|
|
|
|
internal override bool DoSaveCheck()
|
|
{
|
|
if (IsDirty)
|
|
{
|
|
var lResult = ShowSaveQuestion();
|
|
|
|
if (lResult == MessageBoxResult.Cancel)
|
|
{
|
|
Focus();
|
|
return false;
|
|
}
|
|
|
|
if (lResult == MessageBoxResult.Yes)
|
|
{
|
|
if (!IsValid() || !IsCustomerChangeAllowed())
|
|
{
|
|
return false;
|
|
}
|
|
|
|
SaveData();
|
|
}
|
|
}
|
|
|
|
return true;
|
|
}
|
|
|
|
public ServiceRecordDialogResult CloseAndDoSaveCheck()
|
|
{
|
|
if (IsDirty)
|
|
{
|
|
var lResult = ShowSaveQuestion();
|
|
|
|
if (lResult == MessageBoxResult.Cancel)
|
|
{
|
|
Focus();
|
|
return ServiceRecordDialogResult.SavingNotAllowed;
|
|
}
|
|
|
|
if (lResult == MessageBoxResult.Yes)
|
|
{
|
|
if (!IsValid() || !IsCustomerChangeAllowed())
|
|
return ServiceRecordDialogResult.SavingNotAllowed;
|
|
|
|
SaveData();
|
|
|
|
return ServiceRecordDialogResult.ClosedWithSaving;
|
|
}
|
|
}
|
|
|
|
return ServiceRecordDialogResult.ClosedWithoutSaving;
|
|
}
|
|
|
|
protected override void Save()
|
|
{
|
|
if (IsDirty)
|
|
{
|
|
//var valid = ServiceFacade.DoOperationsServiceSync(s => s.CheckExistingSettlementInvoices(_OriginalVM.CommitToDataContract()));
|
|
|
|
//if (valid.Contains(ServiceRecordValidationResult.SettlementInvoiceAlreadyExisting))
|
|
//{
|
|
// MessageBox.Show("Es existiert bereits eine Spitzabrechnung. Um die Änderungen zu berücksichtigen muss gegebenenfalls eine neue Spitzabrechnung erstellt werden.",
|
|
// "Speichern", MessageBoxButton.OK, MessageBoxImage.Warning);
|
|
// //return;
|
|
//}
|
|
|
|
//ViewModel.SelectedVMForEditing.CopyTo(_OriginalVM);
|
|
|
|
|
|
//if (!_HideCustomers)
|
|
// _ServiceRecordVM.ChoosenNode = _SelectedNode;
|
|
|
|
//if (!_HideCustomers && _ServiceRecordVM.ServiceDescription.Category != null && _ServiceRecordVM.ServiceDescription.Category.IsBillable && _ServiceRecordVM.ChoosenNode.SupportConceptTreeNodeDC.CostBearer != null)
|
|
// {
|
|
|
|
// Calculations calc = Calculations.GetInstance(_ServiceRecordVM.ChoosenNode.SupportConceptTreeNodeDC.CostBearer.CostBearerID);
|
|
// var roundedDuration = calc.GetRoundedDuration(
|
|
// _ServiceRecordVM.ChoosenNode.SupportConceptTreeNodeDC.CostBearer.ActualMinuteIntervall,
|
|
// _ServiceRecordVM.Duration.Value);
|
|
|
|
// _ServiceRecordVM.RoundedDuration = roundedDuration;
|
|
|
|
// }
|
|
// else
|
|
// {
|
|
// _ServiceRecordVM.RoundedDuration = _ServiceRecordVM.Duration.Value;
|
|
// }
|
|
|
|
//if (BeWoApp.AppSettings.ShowRtfTextfield)
|
|
//{
|
|
// SetRTFDaten();
|
|
//}
|
|
|
|
_ServiceRecordVM.RoundedDuration = _ServiceRecordVM.Duration.Value;
|
|
|
|
if (_SelectedEmployee != null)
|
|
{
|
|
_ServiceRecordVM.Employee = _SelectedEmployee;
|
|
}
|
|
|
|
var lDC = _ServiceRecordVM.CommitToDataContract();
|
|
|
|
if (!_HideCustomers)
|
|
{
|
|
if (_ServiceRecordVM.ChoosenNode.SupportConceptTreeNodeDC.SupportConceptCostBearerRelDC != null)
|
|
{
|
|
lDC.CostBearer2SupportConceptOid = _ServiceRecordVM.ChoosenNode.SupportConceptTreeNodeDC.SupportConceptCostBearerRelDC.CostBearer2SupportConceptOid;
|
|
}
|
|
}
|
|
|
|
var list = new List<ServiceRecordDC> {lDC};
|
|
|
|
if (lDC.ServiceRecordOid.HasValue)
|
|
{
|
|
ServiceFacade.DoOperationsServiceSync(s => s.UpdateServiceRecords(list));
|
|
}
|
|
else
|
|
{
|
|
ServiceFacade.DoOperationsServiceSync(s => s.InsertNewServiceRecords(list));
|
|
}
|
|
|
|
}
|
|
}
|
|
|
|
private void EmployeeSearchView_CustomerSelected(object sender, EventArgs<CompactEmployeeDC> e)
|
|
{
|
|
_ServiceRecordVM.Employee = e.Data;
|
|
popupedit_employee.Text = _ServiceRecordVM.Employee.ToString();
|
|
popup_employee.IsOpen = false;
|
|
}
|
|
|
|
private void ServiceRecordEditView_Loaded(object sender, RoutedEventArgs e)
|
|
{
|
|
if (_OldCategory != null && _OldCategory.ActivationType == ActivationTypeId.Deleted)
|
|
{
|
|
_ServiceRecordVM.SetDirty(true);
|
|
}
|
|
else
|
|
{
|
|
_ServiceRecordVM.Category = _OldCategory;
|
|
_ServiceRecordVM.ServiceDescription = _OldServiceDescription;
|
|
_ServiceRecordVM.SetDirty(false);
|
|
}
|
|
|
|
if (ActualHeight > 0)
|
|
{
|
|
ComboBoxTreeViewControl.ParentWindowHeight = ActualHeight;
|
|
}
|
|
|
|
ComboBoxTreeViewControl.Imitationheader.Width = 189;
|
|
}
|
|
|
|
private void SetSelectedCustomerNode()
|
|
{
|
|
supportConceptSelectionControl.SelectedItem = _OriginalNode;
|
|
|
|
//ViewModel.SelectedVMForEditing.ChoosenNode = _SelectedNode;
|
|
}
|
|
|
|
private void supportConceptSelectionControl_ItemSelected(object sender, EventArgs<FlatSupportConceptTreeNodeDC> e)
|
|
{
|
|
if (!_HideCustomers)
|
|
{
|
|
_ServiceRecordVM.ChoosenNode = e.Data;
|
|
//if (selectedNode != null && ViewModel != null)
|
|
// ViewModel.SelectedVMForEditing.ChoosenNode = selectedNode;
|
|
}
|
|
}
|
|
|
|
private void popupedit_employee_PopUpClick(object sender, RoutedEventArgs e)
|
|
{
|
|
popup_employee.IsOpen = true;
|
|
}
|
|
|
|
private void Popupedit_employee_OnPreviewMouseDoubleClick(object sender, MouseButtonEventArgs e)
|
|
{
|
|
if (!BeWoUtils.CheckPopupEditClickableSpace((PopUpEdit)sender, e) || _SelectedEmployee == null || !BeWoApp.LoggedOnUser.HasRight(UserRightType.EmployeeView_View))
|
|
{
|
|
return;
|
|
}
|
|
|
|
VMFactory.CreateEmployeeVMAsync(_SelectedEmployee.EmployeeOid,
|
|
cb => this.Dispatch(() => BeWoUtils.OpenModalViewWindow<EmployeeVM, EmployeeDC, ServiceRecordEditView>(cb, this, () => this.Dispatch(
|
|
delegate
|
|
{
|
|
ServiceFacade.DoEmployeeServiceSync(s => _SelectedEmployee = s.LoadCompactEmployee(_SelectedEmployee.EmployeeOid));
|
|
BeWoUtils.UpdateSearchViewObjectList(employeeSearchView, _SelectedEmployee);
|
|
popupedit_employee.Text = _SelectedEmployee.ToString();
|
|
|
|
BeWoUtils.UpdateAllViews(_SelectedEmployee);
|
|
}
|
|
))));
|
|
}
|
|
|
|
private void ConfigureRTFDocTypes()
|
|
{
|
|
TabitemRtf1Note.IsSelected = true;
|
|
|
|
_NoticeTabItemList.DoForEach(tabItem => tabItem.Visibility = Visibility.Collapsed);
|
|
|
|
_RTFNoticeTabItemList.DoForEach(tabItem => tabItem.Visibility = Visibility.Visible);
|
|
|
|
var docTypeCount = ViewModel.AllDocTypes.Count;
|
|
|
|
if(docTypeCount == 0)
|
|
{
|
|
TabitemRtf1Note.Header = "Dokumentation";
|
|
|
|
_RTFNoticeTabItemList.DoForEach(tabItem => { tabItem.Visibility = _RTFNoticeTabItemList.IndexOf(tabItem) > 0 ? Visibility.Collapsed : Visibility.Visible; });
|
|
}
|
|
|
|
for(var i = 0; i < 5; i++)
|
|
{
|
|
_RTFNoticeTabItemList[i].Header = i < docTypeCount ? ViewModel.AllDocTypes[i].ToString() : string.Empty;
|
|
_RTFNoticeTabItemList[i].Visibility = i < docTypeCount ? Visibility.Visible : Visibility.Collapsed;
|
|
}
|
|
}
|
|
|
|
private void ConfigureDocTypes()
|
|
{
|
|
barManager.Visibility = Visibility.Collapsed;
|
|
TabBorder.Background = null;
|
|
|
|
var docTypeCount = ViewModel.AllDocTypes.Count;
|
|
|
|
if(docTypeCount == 0)
|
|
{
|
|
TabItem1_Notice.Header = "Dokumentation";
|
|
|
|
_NoticeTabItemList.DoForEach(tabItem => { tabItem.Visibility = _NoticeTabItemList.IndexOf(tabItem) > 0 ? Visibility.Collapsed : Visibility.Visible; });
|
|
}
|
|
|
|
for(var i = 0; i < 5; i++)
|
|
{
|
|
_NoticeTabItemList[i].Header = i < docTypeCount ? ViewModel.AllDocTypes[i].ToString() : string.Empty;
|
|
_NoticeTabItemList[i].Visibility = i < docTypeCount ? Visibility.Visible : Visibility.Collapsed;
|
|
}
|
|
}
|
|
|
|
private void MinSTDOhneEnd_OnSelectedIndexChanged(object sender, RoutedEventArgs e)
|
|
{
|
|
if (MinSTDOhneEnd.Text == ZeiterfassungsDauer.Minuten.ToString())
|
|
{
|
|
numerictb_duration.IsFloatValue = false;
|
|
numerictb_duration.Mask = "########";
|
|
}
|
|
else
|
|
{
|
|
numerictb_duration.IsFloatValue = true;
|
|
numerictb_duration.Mask = "########0.00";
|
|
}
|
|
}
|
|
|
|
private void MinSTDMitEnd_OnSelectedIndexChanged(object sender, RoutedEventArgs e)
|
|
{
|
|
if (MinSTDMitEnd.Text == ZeiterfassungsDauer.Minuten.ToString())
|
|
{
|
|
numeric_duration.IsFloatValue = false;
|
|
numeric_duration.Mask = "########";
|
|
}
|
|
else
|
|
{
|
|
numeric_duration.IsFloatValue = true;
|
|
numeric_duration.Mask = "########0.00";
|
|
}
|
|
}
|
|
|
|
private void TabItem_RtfDokuSelected(object sender, RoutedEventArgs e)
|
|
{
|
|
RemoveBarManagerRef();
|
|
InitRichTextEdit(sender as TabItem);
|
|
}
|
|
|
|
private void InitRichTextEdit(TabItem tabItem)
|
|
{
|
|
RichEditControl richEditControl;
|
|
|
|
if (tabItem.Content == null)
|
|
{
|
|
var dockPanel = new DockPanel();
|
|
|
|
richEditControl = new RichEditControl
|
|
{
|
|
CommandBarStyle = CommandBarStyle.Empty,
|
|
HorizontalAlignment = HorizontalAlignment.Stretch,
|
|
VerticalAlignment = VerticalAlignment.Stretch,
|
|
Margin = new Thickness(0)
|
|
};
|
|
|
|
if (tabItem.Name == TabitemRtf1Note.Name)
|
|
{
|
|
InitTextForRichText(richEditControl, _ServiceRecordVM.Notice, _ServiceRecordVM.RTFNotice);
|
|
}
|
|
else if (tabItem.Name == TabitemRtf2Note.Name)
|
|
{
|
|
InitTextForRichText(richEditControl, _ServiceRecordVM.Notice2, _ServiceRecordVM.RTFNotice2);
|
|
}
|
|
else if (tabItem.Name == TabitemRtf3Note.Name)
|
|
{
|
|
InitTextForRichText(richEditControl, _ServiceRecordVM.Notice3, _ServiceRecordVM.RTFNotice3);
|
|
}
|
|
else if (tabItem.Name == TabitemRtf4Note.Name)
|
|
{
|
|
InitTextForRichText(richEditControl, _ServiceRecordVM.Notice4, _ServiceRecordVM.RTFNotice4);
|
|
}
|
|
else if (tabItem.Name == TabitemRtf5Note.Name)
|
|
{
|
|
InitTextForRichText(richEditControl, _ServiceRecordVM.Notice5, _ServiceRecordVM.RTFNotice5);
|
|
}
|
|
|
|
dockPanel.Children.Add(richEditControl);
|
|
tabItem.Content = dockPanel;
|
|
}
|
|
else
|
|
{
|
|
richEditControl = GetRichEditFromTabItem(tabItem);
|
|
}
|
|
|
|
richEditControl.BarManager = barManager;
|
|
richEditControl.ContentChanged += RichEdit_ContentChanged;
|
|
|
|
FontSizeComboBox.OfficeFontSizeProvider = richEditControl;
|
|
RichEditStyleComboBox.RichEditControl = richEditControl;
|
|
biPageLayoutSizeList.RichEditControl = richEditControl;
|
|
biMailMergeInsertFieldPlaceholder.RichEditControl = richEditControl;
|
|
biReviewReviewers.RichEditControl = richEditControl;
|
|
}
|
|
|
|
private void RichEdit_ContentChanged(object sender, EventArgs e)
|
|
{
|
|
if (sender is RichEditControl richEditControl)
|
|
{
|
|
if (TabitemRtf1Note.IsSelected)
|
|
{
|
|
_ServiceRecordVM.Notice = richEditControl.Text;
|
|
_ServiceRecordVM.RTFNotice = richEditControl.RtfText;
|
|
}
|
|
else if (TabitemRtf2Note.IsSelected)
|
|
{
|
|
_ServiceRecordVM.Notice2 = richEditControl.Text;
|
|
_ServiceRecordVM.RTFNotice2 = richEditControl.RtfText;
|
|
}
|
|
else if (TabitemRtf3Note.IsSelected)
|
|
{
|
|
_ServiceRecordVM.Notice3 = richEditControl.Text;
|
|
_ServiceRecordVM.RTFNotice3 = richEditControl.RtfText;
|
|
}
|
|
else if (TabitemRtf4Note.IsSelected)
|
|
{
|
|
_ServiceRecordVM.Notice4 = richEditControl.Text;
|
|
_ServiceRecordVM.RTFNotice4 = richEditControl.RtfText;
|
|
}
|
|
else if (TabitemRtf5Note.IsSelected)
|
|
{
|
|
_ServiceRecordVM.Notice5 = richEditControl.Text;
|
|
_ServiceRecordVM.RTFNotice5 = richEditControl.RtfText;
|
|
}
|
|
}
|
|
}
|
|
|
|
private static void InitTextForRichText(RichEditControl re, string notice, string rtfNotice)
|
|
{
|
|
if (!string.IsNullOrWhiteSpace(rtfNotice))
|
|
{
|
|
re.RtfText = rtfNotice;
|
|
}
|
|
else if (!string.IsNullOrWhiteSpace(notice))
|
|
{
|
|
re.Text = notice;
|
|
}
|
|
}
|
|
|
|
private void RemoveBarManagerRef()
|
|
{
|
|
_RTFNoticeTabItemList.DoForEach(RemoveBarManagerFromTabItem);
|
|
}
|
|
|
|
private void RemoveBarManagerFromTabItem(TabItem tabitem)
|
|
{
|
|
var rec = GetRichEditFromTabItem(tabitem);
|
|
|
|
if (rec != null)
|
|
{
|
|
rec.ContentChanged -= RichEdit_ContentChanged;
|
|
rec.BarManager = null;
|
|
}
|
|
}
|
|
|
|
public RichEditControl GetRichEditFromTabItem(TabItem tabitemRtf1Note)
|
|
{
|
|
if (tabitemRtf1Note.Content is DockPanel dp && dp.Children.Count > 0)
|
|
{
|
|
return dp.Children[0] as RichEditControl;
|
|
}
|
|
|
|
return null;
|
|
}
|
|
|
|
private void IncreaseFontSizeBtn_Click(object sender, RoutedEventArgs e)
|
|
{
|
|
if(!BeWoApp.AppSettings.ShowRtfTextfield)
|
|
{
|
|
_NoticeTextBoxList.DoForEach(textBox => textBox.FontSize++);
|
|
|
|
BeWoApp.AppSettings.DocumentationFontSize = TextboxNotice.FontSize;
|
|
}
|
|
}
|
|
|
|
private void DecreaseFontSizeBtn_Click(object sender, RoutedEventArgs e)
|
|
{
|
|
if(!BeWoApp.AppSettings.ShowRtfTextfield)
|
|
{
|
|
if(TextboxNotice.FontSize <= 1 || TextboxNotice2.FontSize <= 1 ||
|
|
TextboxNotice3.FontSize <= 1 ||
|
|
TextboxNotice4.FontSize <= 1 || TextboxNotice5.FontSize <= 1)
|
|
{
|
|
return;
|
|
}
|
|
|
|
_NoticeTextBoxList.DoForEach(textBox => textBox.FontSize--);
|
|
|
|
BeWoApp.AppSettings.DocumentationFontSize = TextboxNotice.FontSize;
|
|
}
|
|
}
|
|
|
|
private void ButtonBase_OnClick(object sender, RoutedEventArgs e)
|
|
{
|
|
ServiceFacade.DoOperationsServiceAsync(s => s.GetTextModules(false, BeWoApp.LoggedOnEmployeeOid.Value, BeWoApp.HasLoggedOnUserRight(new[] { UserRightType.TextbausteineAlleAnsehen, UserRightType.ViewAll }), false), textModules => this.Dispatch(delegate
|
|
{
|
|
popup_textbausteine.IsOpen = true;
|
|
|
|
if(textbausteineSearchView.ServiceCategoryOid > 0)
|
|
{
|
|
var selectedTextmodules = textModules.Where(w => w.ServiceCategory != null && w.ServiceCategory.ServiceCategoryOid == textbausteineSearchView.ServiceCategoryOid || w.ServiceCategory == null).ToList();
|
|
|
|
textModules = Utils.GetParentTextModules(selectedTextmodules);
|
|
textModules.AddRangeIfElementsNotIn(selectedTextmodules);
|
|
}
|
|
|
|
textbausteineSearchView.InitSearchView(textModules);
|
|
}));
|
|
}
|
|
|
|
private void TextModulesSearchView_OnItemSelected(object sender, EventArgs<TextModuleDC> e)
|
|
{
|
|
if(TabItem1_Notice.IsSelected)
|
|
{
|
|
ServiceRecordView2.AddTextModuleToTextBox(e.Data.Text, TextboxNotice, _GrosseDokuTextBox);
|
|
}
|
|
else if(TabItem2_Notice.IsSelected)
|
|
{
|
|
ServiceRecordView2.AddTextModuleToTextBox(e.Data.Text, TextboxNotice2, _GrosseDokuTextBox);
|
|
}
|
|
else if(TabItem3_Notice.IsSelected)
|
|
{
|
|
ServiceRecordView2.AddTextModuleToTextBox(e.Data.Text, TextboxNotice3, _GrosseDokuTextBox);
|
|
}
|
|
else if(TabItem4_Notice.IsSelected)
|
|
{
|
|
ServiceRecordView2.AddTextModuleToTextBox(e.Data.Text, TextboxNotice4, _GrosseDokuTextBox);
|
|
}
|
|
else if(TabItem5_Notice.IsSelected)
|
|
{
|
|
ServiceRecordView2.AddTextModuleToTextBox(e.Data.Text, TextboxNotice5, _GrosseDokuTextBox);
|
|
}
|
|
|
|
popup_textbausteine.IsOpen = false;
|
|
}
|
|
|
|
private void FullscreenBtn_Click(object sender, RoutedEventArgs e)
|
|
{
|
|
var stackPanel = new StackPanel
|
|
{
|
|
Orientation = Orientation.Horizontal,
|
|
HorizontalAlignment = HorizontalAlignment.Left
|
|
};
|
|
|
|
var schriftVergroessern = new Button
|
|
{
|
|
Margin = new Thickness(3),
|
|
HorizontalAlignment = HorizontalAlignment.Left,
|
|
Content = "A+"
|
|
};
|
|
var schriftVerkleinern = new Button
|
|
{
|
|
Margin = new Thickness(3),
|
|
HorizontalAlignment = HorizontalAlignment.Left,
|
|
Content = "A-"
|
|
};
|
|
var textbausteine = new Button { Margin = new Thickness(3), HorizontalAlignment = HorizontalAlignment.Left, Content = "Textbausteine" };
|
|
|
|
textbausteine.Click += ButtonBase_OnClick;
|
|
|
|
if(!BeWoApp.LoggedOnUser.HasRight(UserRightType.TextbausteineAlleAnsehen) &&
|
|
!BeWoApp.LoggedOnUser.HasRight(UserRightType.TextbausteineNurEigeneAnsehen))
|
|
{
|
|
textbausteine.Visibility = Visibility.Collapsed;
|
|
}
|
|
|
|
stackPanel.Children.Add(schriftVergroessern);
|
|
stackPanel.Children.Add(schriftVerkleinern);
|
|
stackPanel.Children.Add(textbausteine);
|
|
|
|
var header = Translator.Translate("Dokumentation");
|
|
|
|
if(TabItem1_Notice.IsSelected)
|
|
{
|
|
_GrosseDokuTextBox = ServiceRecordView2.InitMaximizedDocumentationTextBox(TextboxNotice);
|
|
header = TabItem1_Notice.Header.ToString();
|
|
}
|
|
else if(TabItem2_Notice.IsSelected)
|
|
{
|
|
_GrosseDokuTextBox = ServiceRecordView2.InitMaximizedDocumentationTextBox(TextboxNotice2);
|
|
header = TabItem2_Notice.Header.ToString();
|
|
}
|
|
else if(TabItem3_Notice.IsSelected)
|
|
{
|
|
_GrosseDokuTextBox = ServiceRecordView2.InitMaximizedDocumentationTextBox(TextboxNotice3);
|
|
header = TabItem3_Notice.Header.ToString();
|
|
}
|
|
else if(TabItem4_Notice.IsSelected)
|
|
{
|
|
_GrosseDokuTextBox = ServiceRecordView2.InitMaximizedDocumentationTextBox(TextboxNotice4);
|
|
header = TabItem4_Notice.Header.ToString();
|
|
}
|
|
else if(TabItem5_Notice.IsSelected)
|
|
{
|
|
_GrosseDokuTextBox = ServiceRecordView2.InitMaximizedDocumentationTextBox(TextboxNotice5);
|
|
header = TabItem5_Notice.Header.ToString();
|
|
}
|
|
|
|
schriftVergroessern.Click += delegate (object o, RoutedEventArgs args)
|
|
{
|
|
IncreaseFontSizeBtn_Click(o, args);
|
|
_GrosseDokuTextBox.FontSize = TextboxNotice.FontSize;
|
|
};
|
|
|
|
schriftVerkleinern.Click += delegate (object o, RoutedEventArgs args)
|
|
{
|
|
DecreaseFontSizeBtn_Click(o, args);
|
|
_GrosseDokuTextBox.FontSize = TextboxNotice.FontSize;
|
|
};
|
|
|
|
Grid.SetRow(stackPanel, 0);
|
|
Grid.SetRow(_GrosseDokuTextBox, 1);
|
|
|
|
_GrosseDokuTextBox.SpellCheck.IsEnabled = true;
|
|
|
|
var rootGrid2 = new Grid();
|
|
rootGrid2.RowDefinitions.Add(new RowDefinition { Height = GridLength.Auto });
|
|
rootGrid2.RowDefinitions.Add(new RowDefinition { Height = new GridLength(1, GridUnitType.Star) });
|
|
rootGrid2.Children.Add(stackPanel);
|
|
rootGrid2.Children.Add(_GrosseDokuTextBox);
|
|
|
|
var neunzigProzentHoehe = MainControl.ActualHeight * .9;
|
|
var neunzigProzentBreite = MainControl.ActualWidth * .9;
|
|
|
|
var beWoWindow = new BeWoWindow(rootGrid2, "MainContentGroupBoxWithMinimizeBtnStyle")
|
|
{
|
|
Width = neunzigProzentBreite,
|
|
Height = neunzigProzentHoehe,
|
|
rootGroupBox = { Header = header },
|
|
WindowStartupLocation = WindowStartupLocation.CenterScreen
|
|
};
|
|
|
|
beWoWindow.Closed += delegate
|
|
{
|
|
_GrosseDokuTextBox = null;
|
|
};
|
|
|
|
beWoWindow.ShowDialog();
|
|
}
|
|
}
|
|
} |