Files
BeWoPlaner/BeWo/View/Detail/Zeiterfassung/ServiceRecordEditView.xaml.cs

1178 lines
45 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.Editors;
using DevExpress.Xpf.RichEdit;
using SupportConceptService = BeWo.Core.Service.SupportConceptService;
using System.Windows.Media;
using BeWo.ViewModel.Controls.AI;
namespace BeWo.View.Detail.Zeiterfassung
{
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 || _ServiceRecordVM.IsNew);
public override string SaveObjectName => Translator.Translate("dieser Leistungsbuchung");
public override string Title => Translator.Translate("Leistungsbuchung bearbeiten");
public ServiceRecordListVM ViewModel { get; set; }
public ServiceRecordDC ServiceRecord => _ServiceRecordVM?.CommitToDataContract();
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;
numerictb_betrag.Visibility = BeWoApp.AppSettings.ShowBetrag ? Visibility.Visible : Visibility.Collapsed;
lblBetrag.Visibility = BeWoApp.AppSettings.ShowBetrag ? 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;
_ServiceRecordVM.Statistics = pListViewModel.Statistics;
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
{
//Köln Ring (BeWoClientType 3)
chkServiceRecordTypeContent.Visibility = BeWoApp.Mandator.BeWoClientType == 3 ? Visibility.Visible : Visibility.Collapsed;
}
ViewModel = pListViewModel;
CreateCustomStatistic();
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();
}
else
{
ConfigureDocTypes();
}
IsEndDateVisible(pSCViewModel.ServiceRecordFormat, pSCViewModel.DauerEinheit);
if(!pSCViewModel.EditAllowed)
{
GridOben.IsEnabled = false;
TextboxNotice.IsReadOnly = true;
TextboxNotice2.IsReadOnly = true;
TextboxNotice3.IsReadOnly = true;
TextboxNotice4.IsReadOnly = true;
TextboxNotice5.IsReadOnly = true;
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);
}
stackpanel_ai.DataContext = ViewModel;
if (!BeWoApp.AppSettings.ShowAI)
{
stackpanel_ai.Visibility = Visibility.Collapsed;
}
}
private static void CheckRecursive(List<SupportConceptGoalDC> goalTree, bool wert)
{
if(goalTree is null)
{
return;
}
foreach(var goal in goalTree)
{
goal.CheckRecursive = wert;
CheckRecursive(goal.Children, wert);
}
}
private static void ExpandCheckedGoals(List<SupportConceptGoalDC> goalTree)
{
if(goalTree is null)
{
return;
}
foreach(var scg in goalTree)
{
if(scg.IsChecked)
{
ExpandParent(scg);
}
ExpandCheckedGoals(scg.Children);
}
}
private static void ExpandParent(SupportConceptGoalDC scg)
{
if(scg.ParentGoal is null)
{
return;
}
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.ZeiterfassungMitEndDatum) //Settings.IsEndDateVisible)
{
if (settings.EinheitZeiterfassung.Equals("1"))
{
ComboBoxDauerEinheitMitEndDatum.Visibility = Visibility.Collapsed;
DauerLabelMitEndDatum.Content = "Dauer (h)";
DauerLabelMitEndDatum.SetValue(Grid.ColumnProperty, 2);
DauerLabelMitEndDatum.HorizontalAlignment = HorizontalAlignment.Right;
SpinEditDurationMitEndDatum.SetValue(Grid.ColumnProperty, 3);
}
else
{
ComboBoxDauerEinheitMitEndDatum.Visibility = Visibility.Visible;
DauerLabelMitEndDatum.Content = "Dauer";
DauerLabelMitEndDatum.SetValue(Grid.ColumnProperty, 0);
SpinEditDurationMitEndDatum.SetValue(Grid.ColumnProperty, 1);
}
GridMitEnddatum.Visibility = Visibility.Visible;
GridOhneEnddatum.Visibility = Visibility.Collapsed;
//GridMitJahrMonat.Visibility = Visibility.Collapsed;
if (!settings.EinheitZeiterfassung.Equals("2") && zsd != ZeiterfassungsDauer.Stunden)
{
return;
}
if (zsd == ZeiterfassungsDauer.Stunden)
{
SpinEditDurationMitEndDatum.IsFloatValue = true;
SpinEditDurationMitEndDatum.Mask = "########0.00";
}
else
{
SpinEditDurationMitEndDatum.IsFloatValue = false;
SpinEditDurationMitEndDatum.Mask = "########0";
}
}
else
{
GridOhneEnddatum.Visibility = Visibility.Visible;
GridMitEnddatum.Visibility = Visibility.Collapsed;
//GridMitJahrMonat.Visibility = Visibility.Collapsed;
if(!settings.EinheitZeiterfassung.Equals("2") && zsd != ZeiterfassungsDauer.Stunden)
{
return;
}
if (settings.EinheitZeiterfassung.Equals("1"))
{
ComboBoxDauerEinheitOhneEndDatum.Visibility = Visibility.Collapsed;
DauerLabelOhneEndDatum.Content = "Dauer (h)";
DauerLabelOhneEndDatum.SetValue(Grid.ColumnProperty, 2);
SpinEditDurationOhneEndDatum.SetValue(Grid.ColumnProperty, 3);
//MinStdDauerlbl.SetValue(Grid.ColumnSpanProperty, 2);
//MinStdDauerlbl.HorizontalAlignment = HorizontalAlignment.Right;
}
else
{
ComboBoxDauerEinheitOhneEndDatum.Visibility = Visibility.Visible;
DauerLabelOhneEndDatum.Content = "Dauer";
DauerLabelOhneEndDatum.SetValue(Grid.ColumnProperty, 0);
SpinEditDurationOhneEndDatum.SetValue(Grid.ColumnProperty, 1);
}
if(zsd == ZeiterfassungsDauer.Stunden)
{
SpinEditDurationOhneEndDatum.IsFloatValue = true;
SpinEditDurationOhneEndDatum.Mask = "########0.00";
}
else
{
SpinEditDurationOhneEndDatum.IsFloatValue = false;
SpinEditDurationOhneEndDatum.Mask = "########0";
}
}
}
public bool IsCustomerChangeAllowed()
{
var lAllowed = true;
if(_OriginalNode is null)
{
return lAllowed;
}
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)
{
var copyVm = _ServiceRecordVM.Clone();
copyVm.DataContract.ServiceRecordOid = _ServiceRecordVM.DataContract.ServiceRecordOid;
lValid = BeWoUtils.ValidateServiceRecordVM(copyVm, ViewModel.StatisticsDC, _ServiceRecordVM.ChoosenNode, false, _ServiceRecordVM.Employee, null, null, 1);
if(lValid)
{
lValid = BeWoUtils.CheckForExistingSignatures(copyVm.CommitToDataContract());
}
}
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)
{
return;
}
//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;
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
{
var insertedOids = ServiceFacade.DoOperationsServiceSync(s => s.InsertNewServiceRecords(list));
if(!insertedOids.Any())
{
return;
}
var oid = insertedOids.First();
ServiceRecordDC serviceRecord = null;
ServiceFacade.DoOperationsServiceSync(s => serviceRecord = s.GetServiceRecordById(oid));
if(!(serviceRecord is null))
{
_ServiceRecordVM = new ServiceRecordVM(serviceRecord, _ServiceRecordVM.Category2Services, _ServiceRecordVM.AllGoalCategories, _ServiceRecordVM.AllGoals);
}
//ServiceFacade.DoOperationsServiceAsync(s => s.GetServiceRecordById(oid), serviceRecord =>
//{
// this.Dispatch(() =>
// {
// _ServiceRecordVM = new ServiceRecordVM(serviceRecord, _ServiceRecordVM.Category2Services, _ServiceRecordVM.AllGoalCategories, _ServiceRecordVM.AllGoals);
// });
//});
}
}
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 = 179;
}
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 (ComboBoxDauerEinheitOhneEndDatum.Text == ZeiterfassungsDauer.Minuten.ToString())
{
SpinEditDurationOhneEndDatum.IsFloatValue = false;
SpinEditDurationOhneEndDatum.Mask = "########0";
}
else
{
SpinEditDurationOhneEndDatum.IsFloatValue = true;
SpinEditDurationOhneEndDatum.Mask = "########0.00";
}
}
private void MinSTDMitEnd_OnSelectedIndexChanged(object sender, RoutedEventArgs e)
{
if (ComboBoxDauerEinheitMitEndDatum.Text == ZeiterfassungsDauer.Minuten.ToString())
{
SpinEditDurationMitEndDatum.IsFloatValue = false;
SpinEditDurationMitEndDatum.Mask = "########0";
}
else
{
SpinEditDurationMitEndDatum.IsFloatValue = true;
SpinEditDurationMitEndDatum.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();
}
private void TimeTextBox_OnLostFocus(object sender, RoutedEventArgs e)
{
var te = sender as TextEdit;
if (te != null)
{
te.EditValue = te.DisplayText.Replace("_", "0").Replace(" ", "");
}
}
private void CreateCustomStatistic()
{
if (ViewModel.RecordStatisticsDC != null)
{
var info = ViewModel.RecordStatisticsDC;
StatisticInfoGrid.Children.Clear();
StatisticInfoGrid.ColumnDefinitions.Clear();
StatisticInfoGrid.RowDefinitions.Clear();
if (info.Header != null)
{
StatisticInfoGrid.ColumnDefinitions.Add(new ColumnDefinition
{
Width = new GridLength(1, GridUnitType.Auto)
});
foreach (var header in info.Header)
{
StatisticInfoGrid.RowDefinitions.Add(new RowDefinition());
}
int rowIndex = 0;
foreach (var header in info.Header)
{
var txt = new TextBlock();
txt.SetValue(Grid.ColumnProperty, 0);
txt.SetValue(Grid.RowProperty, rowIndex);
txt.Foreground =
new SolidColorBrush(
(Color)ColorConverter.ConvertFromString(info.ForegroundColor[rowIndex]));
txt.Height = 14;
txt.Text = header;
StatisticInfoGrid.Children.Add(txt);
rowIndex++;
}
if (info.PeriodStatisticInfos != null)
{
foreach (var periodInfo in info.PeriodStatisticInfos)
{
StatisticInfoGrid.ColumnDefinitions.Add(new ColumnDefinition
{
Width = new GridLength(1, GridUnitType.Auto)
});
StatisticInfoGrid.ColumnDefinitions.Add(new ColumnDefinition
{
Width = new GridLength(1, GridUnitType.Auto)
});
}
int colIndex = 1;
foreach (var periodInfo in info.PeriodStatisticInfos)
{
rowIndex = 0;
foreach (var lv in periodInfo.LeftValues)
{
if (!String.IsNullOrEmpty(lv))
{
var txt = new TextBlock();
txt.SetValue(Grid.ColumnProperty, colIndex);
txt.SetValue(Grid.RowProperty, rowIndex);
txt.Foreground = new SolidColorBrush(
(Color)ColorConverter.ConvertFromString(periodInfo.LeftValueColors[rowIndex]));
txt.Height = 12;
txt.FontWeight = FontWeights.Bold;
txt.Text = lv;
txt.HorizontalAlignment = HorizontalAlignment.Right;
txt.Margin = new Thickness(10, 0, 0, 0);
txt.Padding = new Thickness(1, 0, 1, 0);
if (String.IsNullOrEmpty(periodInfo.RightValues[rowIndex]))
{
txt.SetValue(Grid.ColumnSpanProperty, 2);
}
StatisticInfoGrid.Children.Add(txt);
//<TextBlock x:Name="txtStatisticInfoHeader" Grid.Column="0" Grid.Row="0"
// Text="{Binding Path=Header}" Grid.ColumnSpan="4"
// FontWeight="Bold" FontSize="12" Foreground="{DynamicResource BigInfoTextBrush}" Height="14"/>
}
if (!String.IsNullOrEmpty(periodInfo.RightValues[rowIndex]))
{
var txt = new TextBlock();
txt.SetValue(Grid.ColumnProperty, colIndex + 1);
txt.SetValue(Grid.RowProperty, rowIndex);
txt.Foreground =
new SolidColorBrush(
(Color)ColorConverter.ConvertFromString(
periodInfo.RightValueColors[rowIndex]));
txt.Height = 12;
txt.FontWeight = FontWeights.Bold;
txt.Text = periodInfo.RightValues[rowIndex];
txt.HorizontalAlignment = HorizontalAlignment.Right;
txt.Margin = new Thickness(10, 0, 0, 0);
txt.Padding = new Thickness(1, 0, 1, 0);
StatisticInfoGrid.Children.Add(txt);
//<TextBlock x:Name="txtStatisticInfoHeader" Grid.Column="0" Grid.Row="0"
// Text="{Binding Path=Header}" Grid.ColumnSpan="4"
// FontWeight="Bold" FontSize="12" Foreground="{DynamicResource BigInfoTextBrush}" Height="14"/>
}
rowIndex++;
}
colIndex += 2;
}
}
}
}
}
public void SetAiViewmodel(AiChatButtonWithHistoryViewModel aiChatButtonWithHistoryView)
{
btn_ai_docu.DataContext = aiChatButtonWithHistoryView;
}
}
}