2016-06-27 01:45:38 +02:00
using System ;
using System.Collections.Generic ;
using System.Collections.ObjectModel ;
using System.ComponentModel ;
2018-02-19 18:34:20 +01:00
using System.Diagnostics ;
2017-03-28 11:01:28 +02:00
using System.Drawing ;
2016-06-27 01:45:38 +02:00
using System.IO ;
using System.Linq ;
2017-11-16 15:37:29 +01:00
using System.Net ;
2017-02-01 13:53:59 +01:00
using System.Text ;
2016-06-27 01:45:38 +02:00
using System.Text.RegularExpressions ;
using System.Windows ;
using System.Windows.Controls ;
2017-03-28 11:01:28 +02:00
using System.Windows.Forms ;
2016-06-27 01:45:38 +02:00
using System.Windows.Input ;
2017-03-28 11:01:28 +02:00
using System.Windows.Media.Imaging ;
2017-08-29 14:16:33 +02:00
2016-06-27 01:45:38 +02:00
using BS.Shared ;
using BS.Shared.Core ;
using BS.Shared.DataContracts ;
using BS.Shared.DataContracts.Compact ;
using BS.Shared.Extensions ;
using BeWo.Controls ;
using BeWo.ServiceProxy ;
using BeWo.View ;
using BeWo.View.Controls ;
using BeWo.View.Detail ;
using BeWo.View.Detail.Accounting ;
using BeWo.View.Detail.Report ;
using BeWo.View.Master ;
using BeWo.View.Navigation ;
using BeWo.View.Report.Auslastung ;
using BeWo.View.Report.FLSReport ;
using BeWo.View.Search ;
using BeWo.ViewModel ;
using DevExpress.Xpf.Core ;
using DevExpress.Xpf.Core.Native ;
using DevExpress.Xpf.Grid ;
using DevExpress.XtraReports.UI ;
using DevExpress.Xpf.Printing ;
2017-03-28 11:01:28 +02:00
using Brushes = System . Windows . Media . Brushes ;
using Image = System . Windows . Controls . Image ;
using MessageBox = System . Windows . MessageBox ;
using Panel = System . Windows . Controls . Panel ;
using System.Windows.Media ;
2021-02-21 19:01:51 +01:00
using System.Windows.Threading ;
using BeWo.Core.Service ;
2017-11-13 10:59:42 +01:00
using BeWo.ownChat ;
2017-11-13 09:59:16 +01:00
using BeWo.PasswortSecurity ;
2019-02-28 12:38:29 +01:00
using BeWo.Scheduler.Utils ;
2021-02-21 19:01:51 +01:00
using BeWo.ViewModel.ListViewModel ;
2017-08-08 13:13:22 +02:00
using DevExpress.Xpf.Bars ;
2017-08-28 16:41:19 +02:00
using DevExpress.Xpf.DocumentViewer ;
using DevExpress.Xpf.Printing.PreviewControl.Bars ;
2019-02-28 12:38:29 +01:00
using DevExpress.XtraScheduler ;
2020-05-12 14:20:58 +02:00
using RestSharp ;
2019-08-29 12:38:48 +02:00
using Control = System . Windows . Controls . Control ;
2019-07-01 15:11:19 +02:00
using Utils = BS . Shared . Core . Utils ;
2020-09-30 10:00:31 +02:00
using Brush = System . Windows . Media . Brush ;
2022-04-25 15:45:02 +02:00
using BeWo.View.Detail.Zeiterfassung ;
2024-06-05 14:45:33 +02:00
using DevExpress.Xpf.Scheduling ;
using CommandBarStyle = DevExpress . Xpf . DocumentViewer . CommandBarStyle ;
using ImageSource = System . Windows . Media . ImageSource ;
2016-06-27 01:45:38 +02:00
namespace BeWo.Core
{
public static class BeWoUtils
{
2018-02-19 10:52:48 +01:00
public static ModalViewWindow CurrentModalViewWindow { get ; set ; }
2018-02-23 14:42:53 +01:00
private static readonly List < ModalViewWindow > _ModalViewWindowsToUpdate = new List < ModalViewWindow > ( ) ;
2016-06-27 01:45:38 +02:00
public static Dictionary < string , string > ParseQuery ( string query )
{
try
{
if ( query . IndexOf ( '?' ) > = 0 )
{
query = query . Split ( '?' ) [ 1 ] ;
var valueArray = Regex . Split ( query , @"[\&]{0,1}[A-Za-z0-9]+[\=]{1}" ) ;
var paramArray = Regex . Split ( query , @"[\=][A-Za-z0-9;]+" ) ;
valueArray = valueArray . Where ( t = > ! string . IsNullOrWhiteSpace ( t ) ) . ToArray ( ) ;
paramArray = paramArray . Where ( t = > ! string . IsNullOrWhiteSpace ( t ) ) . ToArray ( ) ;
var queryDictionary = new Dictionary < string , string > ( ) ;
int ixg = 0 ;
foreach ( var item in paramArray )
{
queryDictionary . Add ( item . Contains ( "&" ) ? Regex . Split ( item , @"[\?]|[\&]" ) [ 1 ] : item ,
valueArray [ ixg ] ) ;
ixg + + ;
if ( ixg > = valueArray . Length )
break ;
}
return queryDictionary ;
}
return new Dictionary < string , string > ( ) ;
}
catch ( Exception ex )
{
throw new Exception ( String . Format ( "Error while parsing query '{0}'\n{1}" , query , ex . Message ) , ex ) ;
}
}
public static void NavigateToReportUri ( string navigateUriString , string title )
{
2020-10-19 17:22:40 +02:00
NavigateToReportUri ( navigateUriString , title , null ) ;
2016-06-27 01:45:38 +02:00
}
2020-10-19 17:22:40 +02:00
public static void NavigateToReportUri ( string navigateUriString , string title , Action callback )
{
NavigateToReportUriWithDocumentPreviewControl ( navigateUriString , title , null , callback ) ;
}
public static void NavigateToReportUriWithDocumentPreviewControl ( string navigateUriString , string title , DocumentPreviewControl dp , Action callback )
2019-08-29 12:38:48 +02:00
{
var reportTemplates = ServiceFacade . DoOperationsServiceSync ( x = > x . GetReportTemplates ( navigateUriString ) ) ;
2017-08-28 16:41:19 +02:00
2019-08-29 12:38:48 +02:00
if ( reportTemplates ? . Count > 1 )
{
var control = new ListboxSelectControl ( reportTemplates . Cast < object > ( ) . ToList ( ) ) ;
var beWoWindow = new BeWoWindow
{
Height = 200 ,
Width = 500 ,
WindowStartupLocation = WindowStartupLocation . CenterOwner ,
GroupBoxContent = control ,
Owner = BeWoApp . CurrentBeWo . MainWindow ,
2021-10-01 16:49:37 +02:00
rootGroupBox = { Header = "Bericht auswählen" }
2019-08-29 12:38:48 +02:00
} ;
control . CancelButtonClicked + = ( ) = > beWoWindow . Close ( ) ;
control . SelectButtonClicked + = ( ) = >
{
if ( control . SelectedItem = = null ) return ;
beWoWindow . Close ( ) ;
var selectedTemplate = ( ReportTemplateDC ) control . SelectedItem ;
2019-08-29 12:42:07 +02:00
var newUri = navigateUriString + "&template=" + ( selectedTemplate . Oid . HasValue ? selectedTemplate . Oid . Value . ToString ( ) : "-1" ) ;
2017-08-28 16:41:19 +02:00
2019-08-29 12:42:07 +02:00
//var start = navigateUriString.IndexOf("type=");
//var end = navigateUriString.IndexOf('&', start);
//if (end == -1) end = navigateUriString.Length - 1;
//var typeString = navigateUriString.Substring(start, end - start + 1);
//var newUri = navigateUriString.Replace(typeString, "template=" + (selectedTemplate.Oid.HasValue ? selectedTemplate.Oid.Value.ToString() : "-1"));
2019-08-29 12:38:48 +02:00
BeWoApp . MainControl . StartWaiting ( ) ;
StartGetReportStreamAsync ( GetReportStreamForWPFControl , newUri , ms = > BeWoApp . MainControl . Dispatch ( delegate
{
2020-10-19 17:22:40 +02:00
if ( callback ! = null )
{
callback ( ) ;
}
2019-08-29 12:38:48 +02:00
ShowReportWindow ( ms , title , dp ) ;
} ) ) ;
} ;
beWoWindow . ShowDialog ( ) ;
}
else
{
BeWoApp . MainControl . StartWaiting ( ) ;
StartGetReportStreamAsync ( GetReportStreamForWPFControl , navigateUriString , ms = > BeWoApp . MainControl . Dispatch ( delegate
{
2020-10-19 17:22:40 +02:00
if ( callback ! = null )
{
callback ( ) ;
}
2019-08-29 12:38:48 +02:00
ShowReportWindow ( ms , title , dp ) ;
} ) ) ;
}
2019-09-02 16:02:44 +02:00
}
2017-08-28 16:41:19 +02:00
2019-07-25 15:16:24 +02:00
public static void CustomizeReportPreviewToolBar ( object s , RoutedEventArgs e )
2017-08-28 16:41:19 +02:00
{
var cont = LayoutHelper . FindElementByType ( s as FrameworkElement , typeof ( BarContainerControl ) ) as BarContainerControl ;
2017-08-28 18:55:26 +02:00
if ( cont ! = null )
{
var toolbar = cont . Bars . First ( ) as ToolBarControl ;
foreach ( var item in toolbar . Items )
{
if ( item . GetType ( ) = = typeof ( OpenDocumentBarItem ) | |
item . GetType ( ) = = typeof ( DocumentMapBarCheckItem ) | |
item . GetType ( ) = = typeof ( WatermarkBarItem ) | |
item . GetType ( ) = = typeof ( ScaleBarItem ) | |
item . GetType ( ) = = typeof ( PrintDirectBarItem ) | |
item . GetType ( ) = = typeof ( PageSetupBarItem ) | |
item . GetType ( ) = = typeof ( SaveBarItem ) | |
item . GetType ( ) = = typeof ( SendSplitItem ) | |
item . GetType ( ) = = typeof ( ParametersBarCheckItem ) | |
item . GetType ( ) = = typeof ( ThumbnailsBarCheckItem ) | |
item . GetType ( ) = = typeof ( EditingFieldsBarCheckItem ) )
{
item . SetPropertyValue ( "IsVisible" , false ) ;
}
if ( item . GetType ( ) = = typeof ( ExportSplitItem ) )
{
var exportSplitItem = item as ExportSplitItem ;
var popupMenu = ( PopupMenu ) exportSplitItem . PopupControl ;
foreach ( var link in popupMenu . Items )
{
var bbi = ( BarButtonItem ) link ;
switch ( bbi . BarItemName )
{
case "bExportMht" :
bbi . IsVisible = false ;
break ;
case "bExportCsv" :
bbi . IsVisible = false ;
break ;
case "bExportTxt" :
bbi . IsVisible = false ;
break ;
}
}
}
}
}
2017-08-28 16:41:19 +02:00
}
public static void StartGetReportStreamAsync ( Func < string , MemoryStream > func , string param , Action < MemoryStream > callback )
2016-06-27 01:45:38 +02:00
{
func . BeginInvoke ( param ,
cb = >
{
try
{
var result = func . EndInvoke ( cb ) ;
if ( callback ! = null )
{
callback ( result ) ;
}
}
catch ( Exception e )
{
2024-09-17 21:10:47 +02:00
BeWoApp . ShowErrorMessage ( e ) ;
2016-06-27 01:45:38 +02:00
BeWoApp . MainControl . EndWaiting ( ) ;
}
} ,
null ) ;
}
public static MemoryStream GetReportStreamForWPFControl ( string navigateUriString )
{
var webClient = new BeWoWebClient ( ) ;
var refreshedUriString = RefreshNavigateUriString ( navigateUriString ) ;
var data = webClient . DownloadData ( refreshedUriString ) ;
return new MemoryStream ( data ) ;
}
public static string RemoveAuthenticationInfoFromUri ( string navigateUri )
{
var regex = new Regex ( @"[\&|\?]?token\=[A-Za-z0-9]+|[\&|\?]?tenant\=[A-Za-z0-9]+|[\&|\?]?username\=[A-Za-z0-9.]+" ) ;
var splittedUri = regex . Split ( navigateUri . Split ( '?' ) [ 1 ] ) ;
var cleanedSplittedUri = splittedUri . Where ( t = > ! string . IsNullOrWhiteSpace ( t ) ) . ToArray ( ) ;
var uriValues = cleanedSplittedUri . Aggregate ( string . Empty , ( current , item ) = > current + item ) ;
return navigateUri . Split ( '?' ) [ 0 ] + "?" + uriValues ;
}
2025-01-29 10:47:18 +01:00
public static string RefreshNavigateUriString ( string navigateUri )
2016-06-27 01:45:38 +02:00
{
if ( navigateUri . Contains ( "tenant" ) )
navigateUri = RemoveAuthenticationInfoFromUri ( navigateUri ) ;
var tempToken = string . Empty ;
ServiceFacade . DoDownloadServiceSync ( s = > tempToken = s . CreateTemporaryToken ( navigateUri , false ) ) ;
var addChar = ( navigateUri . Contains ( "?" ) ) ? "&" : "?" ;
var finalUri = string . Format ( "{0}{1}token={2}" , navigateUri , addChar , tempToken ) ;
return finalUri ;
}
public static bool CheckPopupEditClickableSpace ( PopUpEdit popupedit , MouseButtonEventArgs e )
{
var buttonWidth = 22d ;
var pos = e . GetPosition ( popupedit ) ;
if ( popupedit . NewButtonVisibility = = Visibility . Visible )
buttonWidth + = 22 ;
if ( popupedit . DeleteButtonVisibility = = Visibility . Visible )
buttonWidth + = 22 ;
return ! ( pos . X > popupedit . ActualWidth - buttonWidth ) ;
}
public static void UpdateSearchViewObjectList < T , U > ( T searchView , U updatedDC )
where T : GenericSearchView < U >
where U : class , IDataContract , IFilterableDC
{
var newSearchObjectList = new List < U > ( ) ;
if ( typeof ( U ) = = typeof ( CompactSupportConceptDC ) )
{
var uSC = updatedDC as CompactSupportConceptDC ;
newSearchObjectList = searchView . ObjectList ;
if ( newSearchObjectList . Contains ( updatedDC ) )
{
newSearchObjectList [ newSearchObjectList . IndexOf ( updatedDC ) ] = updatedDC ;
}
foreach ( var oldDC in newSearchObjectList . Select ( item = > item as CompactSupportConceptDC ) . Where ( oldDC = > oldDC . Customer . Equals ( uSC . Customer ) ) )
{
oldDC . Customer = uSC . Customer ;
}
}
else
{
foreach ( var oldDC in searchView . ObjectList . Where ( oldDC = > ! newSearchObjectList . Contains ( oldDC ) ) )
{
newSearchObjectList . Add ( updatedDC . Equals ( oldDC ) ? updatedDC : oldDC ) ;
}
}
searchView . ObjectList = null ;
searchView . ObjectList = newSearchObjectList ;
}
public static void OpenModalViewWindow < T , U , V > (
T viewModel ,
2017-03-24 10:30:18 +01:00
V ownerView ,
2016-06-27 01:45:38 +02:00
Action applyChanges ,
EventHandler < EventArgs < OrganisationVM > > organisationSavedOrUpdated = null ,
2017-03-24 10:30:18 +01:00
EventHandler < EventArgs < PersonVM > > personSavedOrUpdated = null , bool allowSaveIfParentDirty = false )
2016-06-27 01:45:38 +02:00
where T : AbstractDCMapperVM < U >
where U : IDataContract , new ( )
where V : BeWoView
{
var tType = typeof ( T ) ;
2018-02-23 14:42:53 +01:00
var view = new BeWoView ( ) ;
2016-06-27 01:45:38 +02:00
if ( tType = = typeof ( EmployeeVM ) )
{
2018-02-23 14:42:53 +01:00
view = new EmployeeView ( viewModel as EmployeeVM ) { ParentView = ownerView , MinWidth = 800 , IsInWindow = true } ;
2016-06-27 01:45:38 +02:00
}
else if ( tType = = typeof ( WohnheimVM ) )
{
2018-02-23 14:42:53 +01:00
view = new WohnheimView ( viewModel as WohnheimVM ) { ParentView = ownerView , MinWidth = 800 , IsInWindow = true } ;
2016-06-27 01:45:38 +02:00
}
else if ( tType = = typeof ( OrganisationVM ) )
{
2018-02-23 14:42:53 +01:00
view = new OrganisationView ( viewModel as OrganisationVM ) { ParentView = ownerView , MinWidth = 800 , IsInWindow = true } ;
( ( OrganisationView ) view ) . OrganisationSavedOrUpdated + = organisationSavedOrUpdated ;
2016-06-27 01:45:38 +02:00
}
else if ( tType = = typeof ( PersonVM ) )
{
2018-02-23 14:42:53 +01:00
view = new PersonView ( viewModel as PersonVM ) { ParentView = ownerView , MinWidth = 800 , IsInWindow = true } ;
( ( PersonView ) view ) . PersonSavedOrUpdated + = personSavedOrUpdated ;
2016-06-27 01:45:38 +02:00
}
else if ( tType = = typeof ( TeamVM ) )
{
2018-02-23 14:42:53 +01:00
view = new TeamView ( viewModel as TeamVM ) { ParentView = ownerView , MinWidth = 800 , IsInWindow = true } ;
2016-06-27 01:45:38 +02:00
}
else if ( tType = = typeof ( CustomerVM ) )
{
2018-02-23 14:42:53 +01:00
view = new CustomerView ( viewModel as CustomerVM ) { ParentView = ownerView , MinWidth = 800 , IsInWindow = true } ;
2016-06-27 01:45:38 +02:00
}
else if ( tType = = typeof ( SupportConceptVM ) )
{
2018-02-23 14:42:53 +01:00
view = new SupportConceptView ( viewModel as SupportConceptVM ) { ParentView = ownerView , MinWidth = 800 , IsInWindow = true } ;
2016-06-27 01:45:38 +02:00
}
else
{
return ;
}
2018-02-23 14:42:53 +01:00
view . ModalEditViewUpdateCallback = applyChanges ;
2016-06-27 01:45:38 +02:00
2018-02-23 14:42:53 +01:00
CurrentModalViewWindow = new ModalViewWindow ( view , ownerView , allowSaveIfParentDirty )
{
Title = viewModel . ToString ( )
} ;
2016-06-27 01:45:38 +02:00
2018-02-19 10:52:48 +01:00
BeWoApp . MainControl . OpenedModalViewWindows . Add ( CurrentModalViewWindow ) ;
2018-02-23 14:42:53 +01:00
_ModalViewWindowsToUpdate . Add ( CurrentModalViewWindow ) ;
2016-06-27 01:45:38 +02:00
foreach ( var window in BeWoApp . MainControl . OpenedModalViewWindows . Where ( window = > ! BeWoApp . MainControl . OpenedModalViewWindows . Last ( ) . Equals ( window ) ) )
{
ShowModalBackground ( window . RootGrid ) ;
}
2018-02-19 10:52:48 +01:00
CurrentModalViewWindow . Show ( ) ;
}
2016-06-27 01:45:38 +02:00
2018-02-19 10:52:48 +01:00
public static void RemoveModalViewWindow ( )
{
if ( BeWoApp . MainControl . OpenedModalViewWindows . Count > 1 & & CurrentModalViewWindow ! = null )
2016-06-27 01:45:38 +02:00
{
2018-02-19 10:52:48 +01:00
var nextToLastWindowWithModalBackground = BeWoApp . MainControl . OpenedModalViewWindows . ElementAt ( BeWoApp . MainControl . OpenedModalViewWindows . Count - 2 ) ;
nextToLastWindowWithModalBackground . RootGrid . Children . RemoveAt ( 1 ) ;
2016-06-27 01:45:38 +02:00
}
2018-02-19 10:52:48 +01:00
BeWoApp . MainControl . OpenedModalViewWindows . Remove ( CurrentModalViewWindow ) ;
CurrentModalViewWindow = BeWoApp . MainControl . OpenedModalViewWindows . Count > 0 ? BeWoApp . MainControl . OpenedModalViewWindows . ElementAt ( BeWoApp . MainControl . OpenedModalViewWindows . Count - 1 ) : null ;
2016-06-27 01:45:38 +02:00
}
public static bool CheckViewIsCalledFromWindow ( BeWoView view )
{
return ( ( Grid ) view . Parent ) . Parent . GetType ( ) = = typeof ( Window ) ;
}
2018-02-19 10:52:48 +01:00
private static void ShowModalBackground ( Panel gridToBlock )
2016-06-27 01:45:38 +02:00
{
var detailViewBackGround = new Grid
{
IsHitTestVisible = true ,
Background = Brushes . White ,
Opacity = . 5 ,
Name = "DetailViewBackGround"
} ;
if ( gridToBlock . Children . OfType < Grid > ( ) . Any ( obj = > obj . Name . Equals ( "DetailViewBackGround" ) ) )
2018-02-19 10:52:48 +01:00
{
2016-06-27 01:45:38 +02:00
return ;
2018-02-19 10:52:48 +01:00
}
2016-06-27 01:45:38 +02:00
Grid . SetColumnSpan ( detailViewBackGround , 3 ) ;
Grid . SetRowSpan ( detailViewBackGround , 3 ) ;
2018-02-19 10:52:48 +01:00
2016-06-27 01:45:38 +02:00
gridToBlock . Children . Add ( detailViewBackGround ) ;
2018-02-19 10:52:48 +01:00
2016-06-27 01:45:38 +02:00
Panel . SetZIndex ( detailViewBackGround , int . MaxValue - 1 ) ;
}
public static void UpdateAllViews < T > ( T updatedObject ) where T : IFilterableDC
{
var activeView = BeWoApp . MainControl . ActiveView ;
UpdateView ( activeView , updatedObject ) ;
2018-02-23 14:42:53 +01:00
if ( BeWoApp . MainControl . OpenedModalViewWindows . Count < = 0 )
2016-06-27 01:45:38 +02:00
{
return ;
}
2018-02-23 14:42:53 +01:00
for ( var i = _ModalViewWindowsToUpdate . Count - 1 ; i > = 0 ; i - - )
2016-06-27 01:45:38 +02:00
{
2018-02-23 14:42:53 +01:00
UpdateView ( _ModalViewWindowsToUpdate . ElementAt ( i ) . DetailView , updatedObject ) ;
_ModalViewWindowsToUpdate . RemoveAt ( i ) ;
2016-06-27 01:45:38 +02:00
}
}
private static void UpdateView < T > ( BeWoView view , T updatedObject ) where T : IFilterableDC
{
2018-02-23 14:42:53 +01:00
if ( view . GetType ( ) = = typeof ( EmployeeView ) )
2016-06-27 01:45:38 +02:00
{
2018-02-23 14:42:53 +01:00
var employeeView = view as EmployeeView ;
UpdateEmployeeView ( employeeView , updatedObject ) ;
}
else if ( view . GetType ( ) = = typeof ( WohnheimView ) )
{
var wohnheimView = view as WohnheimView ;
UpdateWohnheimView ( wohnheimView , updatedObject ) ;
}
else if ( view . GetType ( ) = = typeof ( CustomerView ) )
{
var customerView = view as CustomerView ;
UpdateCustomerView ( customerView , updatedObject ) ;
}
else if ( view . GetType ( ) = = typeof ( OrganisationView ) )
{
var organisationView = view as OrganisationView ;
UpdateOrganisationView ( organisationView , updatedObject ) ;
}
else if ( view . GetType ( ) = = typeof ( BookingView ) )
{
var bookingView = view as BookingView ;
UpdateBookingView ( bookingView , updatedObject ) ;
}
else if ( view . GetType ( ) = = typeof ( FinanceView ) )
{
var financeView = view as FinanceView ;
UpdateFinanceView ( financeView , updatedObject ) ;
}
else if ( view . GetType ( ) = = typeof ( SupportConceptView ) )
{
var supportConceptView = view as SupportConceptView ;
UpdateSupportConceptView ( supportConceptView , updatedObject ) ;
}
else if ( view . GetType ( ) = = typeof ( ServiceRecordView2 ) )
{
var serviceRecordView = ( ServiceRecordView2 ) view ;
UpdateServiceRecordView ( serviceRecordView , updatedObject ) ;
}
else if ( view . GetType ( ) = = typeof ( TeamView ) )
{
var teamView = ( TeamView ) view ;
UpdateTeamView ( teamView , updatedObject ) ;
}
else if ( view . GetType ( ) = = typeof ( UserView ) )
{
var userView = ( UserView ) view ;
UpdateUserView ( userView ) ;
}
else if ( view . GetType ( ) = = typeof ( ReportView ) )
{
var reportView = ( ReportView ) view ;
UpdateReportView ( reportView , updatedObject ) ;
}
else if ( view . GetType ( ) = = typeof ( PersonView ) )
{
var personView = view as PersonView ;
UpdatePersonView ( personView , updatedObject ) ;
}
else if ( view . GetType ( ) = = typeof ( AdditionalServiceView ) )
{
var additionalServiceView = view as AdditionalServiceView ;
UpdateAdditionalServiceView ( additionalServiceView , updatedObject ) ;
}
}
private static void UpdateEmployeeView < T > ( EmployeeView pEmployeeView , T pUpdatedObject ) where T : IFilterableDC
{
if ( typeof ( T ) = = typeof ( CompactCustomerDC ) )
{
var updatedCustomer = new CompactCustomerDC ( ) ;
2016-06-27 01:45:38 +02:00
2018-02-23 14:42:53 +01:00
ServiceFacade . DoCustomerServiceSync ( s = > updatedCustomer = s . GetCompactCustomerDC ( ( pUpdatedObject as CompactCustomerDC ) . CustomerOid ) ) ;
2016-06-27 01:45:38 +02:00
2018-02-23 14:42:53 +01:00
foreach ( var item in pEmployeeView . ViewModel . CustomerRelations . VMList . Where ( item = > item . Customer . Equals ( updatedCustomer ) ) )
{
item . Customer = updatedCustomer ;
}
2016-06-27 01:45:38 +02:00
2018-02-23 14:42:53 +01:00
var grid = pEmployeeView . rootGrid . FindResource ( "grid_CustomerRelation" ) as GridControl ;
2016-06-27 01:45:38 +02:00
2018-02-23 14:42:53 +01:00
foreach ( var item in ( ( BindingList < CustomerEmployeeRelationVM > ) grid . ItemsSource ) . Where ( item = > item . Customer . Equals ( updatedCustomer ) ) )
2016-06-27 01:45:38 +02:00
{
2018-02-23 14:42:53 +01:00
item . Customer = null ;
item . Customer = updatedCustomer ;
2016-06-27 01:45:38 +02:00
}
2018-02-23 14:42:53 +01:00
grid . RefreshData ( ) ;
}
if ( typeof ( T ) = = typeof ( CompactEmployeeDC ) )
2016-06-27 01:45:38 +02:00
{
2018-02-23 14:42:53 +01:00
UpdateLoggedInEmployee ( ( pUpdatedObject as CompactEmployeeDC ) . EmployeeOid ) ;
pEmployeeView . ReloadViewModel ( ) ;
}
}
2016-06-27 01:45:38 +02:00
2018-02-23 14:42:53 +01:00
private static void UpdateWohnheimView < T > ( WohnheimView pWohnheimView , T pUpdateObject ) where T : IFilterableDC
{
if ( typeof ( T ) = = typeof ( CompactCustomerDC ) )
{
var updatedCustomer = new CompactCustomerDC ( ) ;
2016-06-27 01:45:38 +02:00
2018-02-23 14:42:53 +01:00
ServiceFacade . DoCustomerServiceSync ( s = > updatedCustomer = s . GetCompactCustomerDC ( ( pUpdateObject as CompactCustomerDC ) . CustomerOid ) ) ;
2016-06-27 01:45:38 +02:00
2018-02-23 14:42:53 +01:00
var grid = pWohnheimView . grid_CustomerRelation ;
2016-06-27 01:45:38 +02:00
2018-02-23 14:42:53 +01:00
foreach ( var item in ( ( BindingList < WohnheimCustomerRelationVM > ) grid . ItemsSource ) . Where ( item = > item . Customer . Equals ( updatedCustomer ) ) )
{
item . Customer = null ;
item . Customer = updatedCustomer ;
2016-06-27 01:45:38 +02:00
}
2018-02-23 14:42:53 +01:00
grid . RefreshData ( ) ;
}
2016-06-27 01:45:38 +02:00
2018-02-23 14:42:53 +01:00
if ( typeof ( T ) = = typeof ( CompactEmployeeDC ) )
{
var updatedEmployee = new CompactEmployeeDC ( ) ;
2016-06-27 01:45:38 +02:00
2018-02-23 14:42:53 +01:00
ServiceFacade . DoEmployeeServiceSync ( s = > updatedEmployee = s . LoadCompactEmployee ( ( pUpdateObject as CompactEmployeeDC ) . EmployeeOid ) ) ;
2016-06-27 01:45:38 +02:00
2018-02-23 14:42:53 +01:00
var employeeRelationsGrid = pWohnheimView . grid_EmployeeRelation ;
2016-06-27 01:45:38 +02:00
2018-02-23 14:42:53 +01:00
foreach ( var item in ( ( BindingList < WohnheimEmployeeRelationVM > ) employeeRelationsGrid . ItemsSource ) . Where ( item = > item . Employee . EmployeeOid . Equals ( updatedEmployee . EmployeeOid ) ) )
{
item . Employee = null ;
item . Employee = updatedEmployee ;
2016-06-27 01:45:38 +02:00
}
2018-02-23 14:42:53 +01:00
UpdateLoggedInEmployee ( ( pUpdateObject as CompactEmployeeDC ) . EmployeeOid ) ;
2016-06-27 01:45:38 +02:00
}
2018-02-23 14:42:53 +01:00
}
private static void UpdateCustomerView < T > ( CustomerView pCustomerView , T pUpdateObject ) where T : IFilterableDC
{
if ( typeof ( T ) = = typeof ( CompactEmployeeDC ) )
2016-06-27 01:45:38 +02:00
{
2018-02-23 14:42:53 +01:00
var updatedEmployee = new CompactEmployeeDC ( ) ;
2016-06-27 01:45:38 +02:00
2018-02-23 14:42:53 +01:00
if ( ! string . IsNullOrWhiteSpace ( pCustomerView . popupedit_employeeRelations . Text ) )
2016-06-27 01:45:38 +02:00
{
2018-02-23 14:42:53 +01:00
ServiceFacade . DoEmployeeServiceSync ( s = > updatedEmployee = s . LoadCompactEmployee ( ( pUpdateObject as CompactEmployeeDC ) . EmployeeOid ) ) ;
pCustomerView . ViewModel . EmployeeRelations . NewVM . Employee = null ;
pCustomerView . ViewModel . EmployeeRelations . NewVM . Employee = updatedEmployee ;
}
else
{
ServiceFacade . DoEmployeeServiceSync ( s = > updatedEmployee = s . LoadCompactEmployee ( ( pUpdateObject as CompactEmployeeDC ) . EmployeeOid ) ) ;
}
2016-06-27 01:45:38 +02:00
2018-02-23 14:42:53 +01:00
var grid = ( GridControl ) pCustomerView . root . Resources [ "datagrid_EmployeeRelation" ] ;
2016-06-27 01:45:38 +02:00
2018-02-23 14:42:53 +01:00
if ( grid . ItemsSource ! = null )
{
foreach ( var item in ( ( BindingList < CustomerEmployeeRelationVM > ) grid . ItemsSource ) . Where ( item = > item . Employee . EmployeeOid . Equals ( updatedEmployee . EmployeeOid ) ) )
2016-06-27 01:45:38 +02:00
{
item . Employee = null ;
item . Employee = updatedEmployee ;
}
grid . RefreshData ( ) ;
}
2018-02-23 14:42:53 +01:00
UpdateSearchViewObjectList ( pCustomerView . employeesearchview , updatedEmployee ) ;
UpdateLoggedInEmployee ( updatedEmployee . EmployeeOid ) ;
}
else if ( typeof ( T ) = = typeof ( CompactPersonDC ) )
{
var updatedPerson = new CompactPersonDC ( ) ;
2016-06-27 01:45:38 +02:00
2018-02-23 14:42:53 +01:00
ServiceFacade . DoCustomerServiceSync ( s = > updatedPerson = s . LoadPersonCompact ( ( pUpdateObject as CompactPersonDC ) . PersonOid ) ) ;
2016-06-27 01:45:38 +02:00
2018-02-23 14:42:53 +01:00
if ( ! string . IsNullOrWhiteSpace ( pCustomerView . popupedit_environmentPersonSearch . Text ) & & pCustomerView . popupedit_environmentPersonSearch . Text . Equals ( ( pUpdateObject as CompactPersonDC ) . ToString ( ) ) )
{
pCustomerView . ViewModel . EnvironmentPersons . NewVM . Person = null ;
pCustomerView . ViewModel . EnvironmentPersons . NewVM . Person = updatedPerson ;
}
2016-06-27 01:45:38 +02:00
2018-02-23 14:42:53 +01:00
var grid = ( GridControl ) pCustomerView . root . Resources [ "grid_PersonRelations" ] ;
2016-06-27 01:45:38 +02:00
2018-02-23 14:42:53 +01:00
var vmList = pCustomerView . ViewModel . EnvironmentPersons . VMList ;
var relVMs = vmList . Where ( w = > w . Person . PersonOid . Equals ( updatedPerson . PersonOid ) ) . Where ( w = > ! w . IsNew ) ;
var relPersonOids = relVMs . Select ( s = > s . CommitToDataContract ( ) . Customer2PersonOid . Value ) . ToList ( ) ;
2016-06-27 01:45:38 +02:00
2018-02-23 14:42:53 +01:00
var dataContracts = new List < CustomerPersonRelationDC > ( ) ;
ServiceFacade . DoCustomerServiceSync ( s = > dataContracts = s . LoadCustomerPersonRelationsByOid ( relPersonOids ) ) ;
2016-06-27 01:45:38 +02:00
2018-02-23 14:42:53 +01:00
var test = new List < CustomerPersonRelationVM > ( ) ;
2016-06-27 01:45:38 +02:00
2018-02-23 14:42:53 +01:00
dataContracts . DoForEach ( dfe = > test . Add ( new CustomerPersonRelationVM ( dfe ) ) ) ;
2016-06-27 01:45:38 +02:00
2018-02-23 14:42:53 +01:00
var vmMap = vmList . Where ( w = > relVMs . Contains ( w ) ) . ToDictionary ( vmList . IndexOf , v = > v . DataContract . Customer2PersonOid . Value ) ;
foreach ( var item in vmMap )
2016-06-27 01:45:38 +02:00
{
2018-02-23 14:42:53 +01:00
vmList [ item . Key ] = test . First ( f = > f . DataContract . Customer2PersonOid . Value . Equals ( item . Value ) ) ;
}
2016-06-27 01:45:38 +02:00
2018-02-23 14:42:53 +01:00
grid . RefreshData ( ) ;
2016-06-27 01:45:38 +02:00
2018-02-23 14:42:53 +01:00
UpdateSearchViewObjectList ( pCustomerView . personsearchview , updatedPerson ) ;
}
else if ( typeof ( T ) = = typeof ( CompactOrganisationDC ) )
{
var organisationToUpdate = pUpdateObject as CompactOrganisationDC ;
var updatedOrganisation = new CompactOrganisationDC ( ) ;
var organisationRelationGrid = new GridControl ( ) ;
var costBearerRelationGrid = new GridControl ( ) ;
2016-06-27 01:45:38 +02:00
2018-02-23 14:42:53 +01:00
if ( ! ( pUpdateObject is CompactOrganisationDC ) )
{
return ;
}
2016-06-27 01:45:38 +02:00
2018-02-23 14:42:53 +01:00
organisationRelationGrid = ( GridControl ) pCustomerView . root . Resources [ "grid_OrganisationRelations" ] ;
costBearerRelationGrid = ( GridControl ) pCustomerView . root . Resources [ "grid_costBearer" ] ;
2016-06-27 01:45:38 +02:00
2018-02-23 14:42:53 +01:00
ServiceFacade . DoCustomerServiceSync ( s = > updatedOrganisation = s . LoadOrganisationCompact ( organisationToUpdate . OrganisationOid ) ) ;
2016-06-27 01:45:38 +02:00
2018-02-23 14:42:53 +01:00
if ( ! string . IsNullOrWhiteSpace ( pCustomerView . popupedit_costBearer . Text ) & & pCustomerView . popupedit_costBearer . Text . Equals ( organisationToUpdate . ToString ( ) ) )
{
pCustomerView . ViewModel . CostBearers . NewVM . CostBearer = null ;
pCustomerView . ViewModel . CostBearers . NewVM . CostBearer = updatedOrganisation ;
pCustomerView . popupedit_costBearer . Text = updatedOrganisation . ToString ( ) ;
}
2016-06-27 01:45:38 +02:00
2018-02-23 14:42:53 +01:00
foreach ( var item in pCustomerView . ViewModel . CostBearers . VMList . Where ( item = > item . CostBearer . Equals ( updatedOrganisation ) ) )
{
item . CostBearer = null ;
item . CostBearer = updatedOrganisation ;
}
2016-06-27 01:45:38 +02:00
2018-02-23 14:42:53 +01:00
if ( ! string . IsNullOrWhiteSpace ( pCustomerView . popupedit_environmentOrganisationSearch . Text ) & & pCustomerView . popupedit_environmentOrganisationSearch . Text . Equals ( organisationToUpdate . ToString ( ) ) )
{
pCustomerView . ViewModel . EnvironmentOrganisations . NewVM . Organisation = null ;
pCustomerView . ViewModel . EnvironmentOrganisations . NewVM . Organisation = updatedOrganisation ;
pCustomerView . popupedit_environmentOrganisationSearch . Text = updatedOrganisation . ToString ( ) ;
}
2016-06-27 01:45:38 +02:00
2018-02-23 14:42:53 +01:00
var vmList = pCustomerView . ViewModel . EnvironmentOrganisations . VMList ;
var relVMs = vmList . Where ( w = > w . Organisation . OrganisationOid . Equals ( updatedOrganisation . OrganisationOid ) ) . Where ( w = > ! w . IsNew ) ;
var relOrganisationOids = relVMs . Select ( s = > s . CommitToDataContract ( ) . Customer2OrganisationOid . Value ) . ToList ( ) ;
var dataContracts = new List < CustomerOrganisationRelationDC > ( ) ;
var test = new List < CustomerOrganisationRelationVM > ( ) ;
2016-06-27 01:45:38 +02:00
2018-02-23 14:42:53 +01:00
ServiceFacade . DoCustomerServiceSync ( s = > dataContracts = s . LoadCustomerOrganisationRelationsByOid ( relOrganisationOids ) ) ;
2016-06-27 01:45:38 +02:00
2018-02-23 14:42:53 +01:00
dataContracts . DoForEach ( dfe = > test . Add ( new CustomerOrganisationRelationVM ( dfe ) ) ) ;
2016-06-27 01:45:38 +02:00
2018-02-23 14:42:53 +01:00
var vmMap = vmList . Where ( w = > relVMs . Contains ( w ) ) . ToDictionary ( vmList . IndexOf , v = > v . DataContract . Customer2OrganisationOid . Value ) ;
2016-06-27 01:45:38 +02:00
2018-02-23 14:42:53 +01:00
foreach ( var item in vmMap )
2016-06-27 01:45:38 +02:00
{
2018-02-23 14:42:53 +01:00
vmList [ item . Key ] = test . First ( f = > f . DataContract . Customer2OrganisationOid . Value . Equals ( item . Value ) ) ;
}
2016-06-27 01:45:38 +02:00
2018-02-23 14:42:53 +01:00
organisationRelationGrid . RefreshData ( ) ;
costBearerRelationGrid . RefreshData ( ) ;
2016-06-27 01:45:38 +02:00
2018-02-23 14:42:53 +01:00
UpdateSearchViewObjectList ( pCustomerView . costbearersearchview , updatedOrganisation ) ;
UpdateSearchViewObjectList ( pCustomerView . organisationsearchview , updatedOrganisation ) ;
}
else if ( typeof ( T ) = = typeof ( CompactTeamDC ) )
{
var teamToUpdate = pUpdateObject as CompactTeamDC ;
var updatedTeam = new CompactTeamDC ( ) ;
var grid = ( GridControl ) pCustomerView . root . Resources [ "datagrid_TeamRelation" ] ;
2016-06-27 01:45:38 +02:00
2018-02-23 14:42:53 +01:00
ServiceFacade . DoEmployeeServiceSync ( s = > updatedTeam = s . LoadCompactTeam ( teamToUpdate . TeamOid ) ) ;
2016-06-27 01:45:38 +02:00
2018-02-23 14:42:53 +01:00
if ( ! string . IsNullOrWhiteSpace ( pCustomerView . popupedit_teamRelations . Text ) & & pCustomerView . popupedit_teamRelations . Text . Equals ( teamToUpdate . ToString ( ) ) )
{
ServiceFacade . DoEmployeeServiceSync ( s = > updatedTeam = s . LoadCompactTeam ( teamToUpdate . TeamOid ) ) ;
pCustomerView . ViewModel . TeamRelations . NewVM . Team = null ;
pCustomerView . ViewModel . TeamRelations . NewVM . Team = updatedTeam ;
2016-06-27 01:45:38 +02:00
}
2018-02-23 14:42:53 +01:00
foreach ( var item in ( ( BindingList < CustomerTeamRelationVM > ) grid . ItemsSource ) . Where ( item = > item . Team . Equals ( updatedTeam ) ) )
2016-06-27 01:45:38 +02:00
{
2018-02-23 14:42:53 +01:00
item . Team = null ;
item . Team = updatedTeam ;
2016-06-27 01:45:38 +02:00
}
2018-02-23 14:42:53 +01:00
grid . RefreshData ( ) ;
UpdateSearchViewObjectList ( pCustomerView . teamsearchview , updatedTeam ) ;
2016-06-27 01:45:38 +02:00
}
2018-02-23 14:42:53 +01:00
else if ( typeof ( T ) = = typeof ( CompactCustomerDC ) )
2016-06-27 01:45:38 +02:00
{
2018-02-23 14:42:53 +01:00
pCustomerView . ReloadViewModel ( ) ;
}
}
private static void UpdateOrganisationView < T > ( OrganisationView pOrganisationView , T pUpdateObject ) where T : IFilterableDC
{
if ( typeof ( T ) = = typeof ( CompactPersonDC ) )
{
var updatedPerson = new CompactPersonDC ( ) ;
var grid = ( GridControl ) pOrganisationView . gridroot . Resources [ "datagrid_PersonRelation" ] ;
2016-06-27 01:45:38 +02:00
2018-02-23 14:42:53 +01:00
ServiceFacade . DoCustomerServiceSync ( s = > updatedPerson = s . LoadPersonCompact ( ( pUpdateObject as CompactPersonDC ) . PersonOid ) ) ;
2016-06-27 01:45:38 +02:00
2018-02-23 14:42:53 +01:00
var vmList = pOrganisationView . ViewModel . PersonRelations . VMList ;
var relVMs = vmList . Where ( w = > w . Person . PersonOid . Equals ( updatedPerson . PersonOid ) ) . Where ( w = > ! w . IsNew ) ;
var relPersonOids = relVMs . Select ( s = > s . CommitToDataContract ( ) . Organisation2PersonOid . Value ) . ToList ( ) ;
var dataContracts = new List < OrganisationPersonRelationDC > ( ) ;
var organisationPersonRelationVMs = new List < OrganisationPersonRelationVM > ( ) ;
2016-06-27 01:45:38 +02:00
2018-02-23 14:42:53 +01:00
ServiceFacade . DoOperationsServiceSync ( s = > dataContracts = s . LoadOrganisationPersonRelationsByOid ( relPersonOids ) ) ;
2016-06-27 01:45:38 +02:00
2018-02-23 14:42:53 +01:00
dataContracts . DoForEach ( dfe = > organisationPersonRelationVMs . Add ( new OrganisationPersonRelationVM ( dfe ) ) ) ;
2016-06-27 01:45:38 +02:00
2018-02-23 14:42:53 +01:00
var vmMap = vmList . Where ( w = > relVMs . Contains ( w ) ) . ToDictionary ( vmList . IndexOf , v = > v . DataContract . Organisation2PersonOid . Value ) ;
foreach ( var item in vmMap )
2016-06-27 01:45:38 +02:00
{
2018-02-23 14:42:53 +01:00
vmList [ item . Key ] = organisationPersonRelationVMs . First ( f = > f . DataContract . Organisation2PersonOid . Value . Equals ( item . Value ) ) ;
2016-06-27 01:45:38 +02:00
}
2018-02-23 14:42:53 +01:00
grid . RefreshData ( ) ;
2016-06-27 01:45:38 +02:00
}
2018-02-23 14:42:53 +01:00
else if ( typeof ( T ) = = typeof ( CompactOrganisationDC ) )
2016-06-27 01:45:38 +02:00
{
2018-02-23 14:42:53 +01:00
pOrganisationView . ReloadViewModel ( ) ;
}
}
2016-06-27 01:45:38 +02:00
2018-02-23 14:42:53 +01:00
private static void UpdateBookingView < T > ( BookingView pBookingView , T pUpdateObject ) where T : IFilterableDC
{
if ( typeof ( T ) ! = typeof ( CompactEmployeeDC ) )
{
return ;
}
2016-06-27 01:45:38 +02:00
2018-02-23 14:42:53 +01:00
var updatedEmployee = new CompactEmployeeDC ( ) ;
2016-06-27 01:45:38 +02:00
2018-02-23 14:42:53 +01:00
ServiceFacade . DoEmployeeServiceSync ( s = > updatedEmployee = s . LoadCompactEmployee ( ( pUpdateObject as CompactEmployeeDC ) . EmployeeOid ) ) ;
2016-06-27 01:45:38 +02:00
2018-02-23 14:42:53 +01:00
var sourceNew = pBookingView . combobox_newEmployee . ItemsSource as ObservableCollection < CompactEmployeeDC > ;
var sourceEdit = pBookingView . combobox_editEmployee . ItemsSource as ObservableCollection < CompactEmployeeDC > ;
2016-06-27 01:45:38 +02:00
2018-02-23 14:42:53 +01:00
var selectedNewIndex = pBookingView . combobox_newEmployee . SelectedIndex ;
var selectedEditIndex = pBookingView . combobox_editEmployee . SelectedIndex ;
2016-06-27 01:45:38 +02:00
2018-02-23 14:42:53 +01:00
foreach ( var item in pBookingView . ViewModel . VMList . Where ( item = > item . Employee . EmployeeOid . Equals ( updatedEmployee . EmployeeOid ) ) )
{
item . Employee = new CompactEmployeeDC ( ) ;
item . Employee = updatedEmployee ;
}
2016-06-27 01:45:38 +02:00
2018-02-23 14:42:53 +01:00
for ( var i = 0 ; i < sourceNew . Count ; i + + )
{
if ( ! sourceNew [ i ] . EmployeeOid . Equals ( updatedEmployee . EmployeeOid ) )
2016-06-27 01:45:38 +02:00
{
2018-02-23 14:42:53 +01:00
continue ;
2016-06-27 01:45:38 +02:00
}
2018-02-23 14:42:53 +01:00
sourceNew [ i ] = new CompactEmployeeDC ( ) ;
sourceNew [ i ] = updatedEmployee ;
}
for ( var i = 0 ; i < sourceNew . Count ; i + + )
{
if ( ! sourceEdit [ i ] . EmployeeOid . Equals ( updatedEmployee . EmployeeOid ) )
2016-06-27 01:45:38 +02:00
{
2018-02-23 14:42:53 +01:00
continue ;
2016-06-27 01:45:38 +02:00
}
2018-02-23 14:42:53 +01:00
sourceEdit [ i ] = new CompactEmployeeDC ( ) ;
sourceEdit [ i ] = updatedEmployee ;
}
2016-06-27 01:45:38 +02:00
2018-02-23 14:42:53 +01:00
pBookingView . combobox_newEmployee . ItemsSource = sourceNew ;
pBookingView . combobox_editEmployee . ItemsSource = sourceEdit ;
2016-06-27 01:45:38 +02:00
2018-02-23 14:42:53 +01:00
pBookingView . combobox_newEmployee . SelectedIndex = selectedNewIndex ;
pBookingView . combobox_editEmployee . SelectedIndex = selectedEditIndex ;
2016-06-27 01:45:38 +02:00
2018-02-23 14:42:53 +01:00
UpdateLoggedInEmployee ( updatedEmployee . EmployeeOid ) ;
}
2016-06-27 01:45:38 +02:00
2018-02-23 14:42:53 +01:00
private static void UpdateFinanceView < T > ( FinanceView pFinanceView , T pUpdateObject ) where T : IFilterableDC
{
var settlementInvoiceView = pFinanceView . tabitem_settlementinvoice . Content as SettlementInvoiceView ;
var equityInvoiceView = pFinanceView . tabitem_equityinvoice . Content as EquityInvoiceView ;
var generalInvoiceView = pFinanceView . tabitem_otherinvoice . Content as GeneralInvoiceView ;
var serviceInvoiceView = pFinanceView . tabitem_collectiveinvoice . Content as ServiceInvoiceView ;
var accountingTransactionBookingView = pFinanceView . tabitem_financeBooking . Content as AccountingTransactionBookingView ;
if ( typeof ( T ) = = typeof ( CompactCustomerDC ) )
{
var updatedCustomer = new CompactCustomerDC ( ) ;
ServiceFacade . DoCustomerServiceSync ( s = > updatedCustomer = s . GetCompactCustomerDC ( ( pUpdateObject as CompactCustomerDC ) . CustomerOid ) ) ;
2016-06-27 01:45:38 +02:00
2018-02-23 14:42:53 +01:00
if ( accountingTransactionBookingView ! = null )
{
foreach ( var item in accountingTransactionBookingView . ViewModel . AccountingTransactionVMList . Where ( item = > item . SupportConcept . Customer . Equals ( updatedCustomer ) ) )
{
item . SupportConcept . Customer = new CompactCustomerDC ( ) ;
item . SupportConcept . Customer = updatedCustomer ;
2016-06-27 01:45:38 +02:00
}
2018-02-23 14:42:53 +01:00
foreach ( var item in accountingTransactionBookingView . FlatSupportConceptItems . Where ( item = > item . SupportConceptTreeNodeDC ! = null ) . Where ( item = > item . SupportConceptTreeNodeDC . Customer . Equals ( updatedCustomer ) ) )
2016-06-27 01:45:38 +02:00
{
2018-02-23 14:42:53 +01:00
item . SupportConceptTreeNodeDC . Customer = new CompactCustomerDC ( ) ;
item . SupportConceptTreeNodeDC . Customer = updatedCustomer ;
}
2016-06-27 01:45:38 +02:00
2018-02-23 14:42:53 +01:00
UpdateSingleSupportConceptSelectionControl ( accountingTransactionBookingView . supportConceptSelectionControl , updatedCustomer ) ;
}
2016-06-27 01:45:38 +02:00
2018-02-23 14:42:53 +01:00
if ( settlementInvoiceView ! = null )
{
if ( settlementInvoiceView . SelectedSupportConcept ! = null )
2016-06-27 01:45:38 +02:00
{
2018-02-23 14:42:53 +01:00
if ( settlementInvoiceView . SelectedSupportConcept . Customer . Equals ( ( pUpdateObject as CompactCustomerDC ) ) )
2016-06-27 01:45:38 +02:00
{
2018-02-23 14:42:53 +01:00
settlementInvoiceView . SelectedSupportConcept . Customer = new CompactCustomerDC ( ) ;
settlementInvoiceView . SelectedSupportConcept . Customer = updatedCustomer ;
2016-06-27 01:45:38 +02:00
2018-02-23 14:42:53 +01:00
settlementInvoiceView . popupedit_CostBeaerer . Text = $"{settlementInvoiceView.SelectedSupportConcept.Customer.LastName}, {settlementInvoiceView.SelectedSupportConcept.Customer.FirstName} {settlementInvoiceView.SelectedSupportConcept.Customer.DateOfBirthString}" ;
2016-06-27 01:45:38 +02:00
}
2018-02-23 14:42:53 +01:00
UpdateSearchViewObjectList ( settlementInvoiceView . supportconceptsearchview , settlementInvoiceView . SelectedSupportConcept ) ;
2016-06-27 01:45:38 +02:00
}
2018-02-23 14:42:53 +01:00
else
2016-06-27 01:45:38 +02:00
{
2018-02-23 14:42:53 +01:00
UpdateSearchViewObjectList ( settlementInvoiceView . supportconceptsearchview , new CompactSupportConceptDC { Customer = updatedCustomer } ) ;
2016-06-27 01:45:38 +02:00
}
}
2018-02-23 14:42:53 +01:00
if ( equityInvoiceView ! = null )
{
if ( equityInvoiceView . SelectedSupportConcept ! = null )
2016-06-27 01:45:38 +02:00
{
2018-02-23 14:42:53 +01:00
equityInvoiceView . SelectedSupportConcept . Customer = new CompactCustomerDC ( ) ;
equityInvoiceView . SelectedSupportConcept . Customer = updatedCustomer ;
2016-06-27 01:45:38 +02:00
2018-02-23 14:42:53 +01:00
equityInvoiceView . popupedit_CostBeaerer . Text = $"{equityInvoiceView.SelectedSupportConcept.Customer.LastName}, {equityInvoiceView.SelectedSupportConcept.Customer.FirstName} {equityInvoiceView.SelectedSupportConcept.Customer.DateOfBirthString}" ;
2016-06-27 01:45:38 +02:00
2018-02-23 14:42:53 +01:00
UpdateSearchViewObjectList ( equityInvoiceView . supportconceptsearchview , equityInvoiceView . SelectedSupportConcept ) ;
2016-06-27 01:45:38 +02:00
}
2018-02-23 14:42:53 +01:00
else
2016-06-27 01:45:38 +02:00
{
2018-02-23 14:42:53 +01:00
UpdateSearchViewObjectList ( equityInvoiceView . supportconceptsearchview , new CompactSupportConceptDC { Customer = updatedCustomer } ) ;
2016-06-27 01:45:38 +02:00
}
}
2018-02-23 14:42:53 +01:00
if ( serviceInvoiceView ! = null )
{
if ( serviceInvoiceView . ViewModel . SelectedSupportConcept ! = null )
2016-06-27 01:45:38 +02:00
{
2018-02-23 14:42:53 +01:00
if ( serviceInvoiceView . ViewModel . SelectedSupportConcept . Customer . Equals ( ( pUpdateObject as CompactCustomerDC ) ) )
2016-06-27 01:45:38 +02:00
{
2018-02-23 14:42:53 +01:00
serviceInvoiceView . ViewModel . SelectedSupportConcept . Customer = new CompactCustomerDC ( ) ;
serviceInvoiceView . ViewModel . SelectedSupportConcept . Customer = updatedCustomer ;
2016-06-27 01:45:38 +02:00
2018-02-23 14:42:53 +01:00
serviceInvoiceView . popupedit_supportConcept . Text = $"{serviceInvoiceView.ViewModel.SelectedSupportConcept.Customer.LastName}, {serviceInvoiceView.ViewModel.SelectedSupportConcept.Customer.FirstName} {serviceInvoiceView.ViewModel.SelectedSupportConcept.Customer.DateOfBirthString}" ;
2016-06-27 01:45:38 +02:00
2018-02-23 14:42:53 +01:00
UpdateSearchViewObjectList ( serviceInvoiceView . supportConcept_search , serviceInvoiceView . ViewModel . SelectedSupportConcept ) ;
}
2016-06-27 01:45:38 +02:00
}
2018-02-23 14:42:53 +01:00
else
2016-06-27 01:45:38 +02:00
{
2018-02-23 14:42:53 +01:00
UpdateSearchViewObjectList ( serviceInvoiceView . supportConcept_search , new CompactSupportConceptDC { Customer = updatedCustomer } ) ;
2016-06-27 01:45:38 +02:00
}
}
}
2018-02-23 14:42:53 +01:00
else if ( typeof ( T ) = = typeof ( CompactSupportConceptDC ) )
2016-06-27 01:45:38 +02:00
{
2018-02-23 14:42:53 +01:00
var updatedSupportConcept = new CompactSupportConceptDC ( ) ;
ServiceFacade . DoCustomerServiceSync ( s = > updatedSupportConcept = s . LoadCompactSupportConceptDC ( ( pUpdateObject as CompactSupportConceptDC ) . SupportConceptOid , BeWoApp . LoggedOnEmployee . EmployeeOid ) ) ;
2016-06-27 01:45:38 +02:00
2018-02-23 14:42:53 +01:00
if ( equityInvoiceView ? . SelectedSupportConcept ! = null )
2016-06-27 01:45:38 +02:00
{
2018-02-23 14:42:53 +01:00
equityInvoiceView . ReloadViewModel ( ) ;
equityInvoiceView . popupedit_CostBeaerer . Text = $"{updatedSupportConcept.Customer.LastName}, {updatedSupportConcept.Customer.FirstName} {updatedSupportConcept.Customer.DateOfBirthString}" ;
2016-06-27 01:45:38 +02:00
2018-02-23 14:42:53 +01:00
UpdateSearchViewObjectList ( equityInvoiceView . supportconceptsearchview , equityInvoiceView . SelectedSupportConcept ) ;
}
2016-06-27 01:45:38 +02:00
2018-02-23 14:42:53 +01:00
if ( settlementInvoiceView ? . SelectedSupportConcept ! = null )
{
settlementInvoiceView . ReloadViewModel ( ) ;
settlementInvoiceView . popupedit_CostBeaerer . Text = $"{updatedSupportConcept.Customer.LastName}, {updatedSupportConcept.Customer.FirstName} {updatedSupportConcept.Customer.DateOfBirthString}" ;
UpdateSearchViewObjectList ( settlementInvoiceView . supportconceptsearchview , settlementInvoiceView . SelectedSupportConcept ) ;
}
2016-06-27 01:45:38 +02:00
2018-02-23 14:42:53 +01:00
if ( serviceInvoiceView ? . ViewModel . SelectedSupportConcept ! = null )
{
if ( serviceInvoiceView . ViewModel . SelectedSupportConcept . Equals ( updatedSupportConcept ) )
{
serviceInvoiceView . ViewModel . SelectedSupportConcept = updatedSupportConcept ;
2016-06-27 01:45:38 +02:00
}
2018-02-23 14:42:53 +01:00
UpdateSearchViewObjectList ( serviceInvoiceView . supportConcept_search , updatedSupportConcept ) ;
}
}
else if ( typeof ( T ) = = typeof ( CompactOrganisationDC ) )
{
var updatedOrganisation = new CompactOrganisationDC ( ) ;
ServiceFacade . DoCustomerServiceSync ( s = > updatedOrganisation = s . LoadOrganisationCompact ( ( pUpdateObject as CompactOrganisationDC ) . OrganisationOid ) ) ;
if ( generalInvoiceView ! = null )
{
if ( generalInvoiceView . SelectedOrganisation ! = null )
2016-06-27 01:45:38 +02:00
{
2018-02-23 14:42:53 +01:00
if ( generalInvoiceView . SelectedOrganisation . Equals ( updatedOrganisation ) )
2016-06-27 01:45:38 +02:00
{
2018-02-23 14:42:53 +01:00
generalInvoiceView . SelectedOrganisation = null ;
generalInvoiceView . SelectedOrganisation = updatedOrganisation ;
2016-06-27 01:45:38 +02:00
}
2018-02-23 14:42:53 +01:00
generalInvoiceView . popupedit_Recipient . Text = updatedOrganisation . ToString ( ) ;
2016-06-27 01:45:38 +02:00
}
2018-02-23 14:42:53 +01:00
UpdateSearchViewObjectList ( generalInvoiceView . recipientsearchview , updatedOrganisation ) ;
}
if ( serviceInvoiceView ! = null )
{
if ( serviceInvoiceView . ViewModel . SelectedCostBearer ! = null )
2016-06-27 01:45:38 +02:00
{
2018-02-23 14:42:53 +01:00
if ( serviceInvoiceView . ViewModel . SelectedCostBearer . Equals ( updatedOrganisation ) )
2016-06-27 01:45:38 +02:00
{
2018-02-23 14:42:53 +01:00
serviceInvoiceView . ViewModel . SelectedCostBearer = updatedOrganisation ;
2016-06-27 01:45:38 +02:00
}
}
2018-02-23 14:42:53 +01:00
UpdateSearchViewObjectList ( serviceInvoiceView . organisationSearchView , updatedOrganisation ) ;
}
}
}
2016-06-27 01:45:38 +02:00
2018-02-23 14:42:53 +01:00
private static void UpdateSupportConceptView < T > ( SupportConceptView pSupportConceptView , T pUpdatedObject ) where T : IFilterableDC
{
if ( typeof ( T ) = = typeof ( CompactEmployeeDC ) )
{
var updatedEmployee = new CompactEmployeeDC ( ) ;
ServiceFacade . DoEmployeeServiceSync ( s = > updatedEmployee = s . LoadCompactEmployee ( ( pUpdatedObject as CompactEmployeeDC ) . EmployeeOid ) ) ;
2016-06-27 01:45:38 +02:00
2019-02-28 12:38:29 +01:00
// TODO: an SchedulerAppointments anpassen! (angepasst)
//for(var i = 0; i < pSupportConceptView.ViewModel.Tasks.NewVM.Employees.Count; i++)
//{
// if(!pSupportConceptView.ViewModel.Tasks.NewVM.Employees[i].EmployeeOid.Equals(updatedEmployee.EmployeeOid))
// {
// continue;
// }
// pSupportConceptView.ViewModel.Tasks.NewVM.Employees[i] = null;
// pSupportConceptView.ViewModel.Tasks.NewVM.Employees[i] = updatedEmployee;
//}
for ( var i = 0 ; i < pSupportConceptView . ViewModel . Tasks . NewVM . EmployeeList . Count ; i + + )
2018-02-23 14:42:53 +01:00
{
2019-02-28 12:38:29 +01:00
if ( ! pSupportConceptView . ViewModel . Tasks . NewVM . EmployeeList . ElementAt ( i ) . Employee . EmployeeOid . Equals ( updatedEmployee . EmployeeOid ) )
2016-06-27 01:45:38 +02:00
{
2018-02-23 14:42:53 +01:00
continue ;
2016-06-27 01:45:38 +02:00
}
2019-02-28 12:38:29 +01:00
pSupportConceptView . ViewModel . Tasks . NewVM . EmployeeList . ElementAt ( i ) . Employee = null ;
pSupportConceptView . ViewModel . Tasks . NewVM . EmployeeList . ElementAt ( i ) . Employee = updatedEmployee ;
2018-02-23 14:42:53 +01:00
}
2016-06-27 01:45:38 +02:00
2018-02-23 14:42:53 +01:00
foreach ( var currentSC in pSupportConceptView . ViewModel . CostBearerRelations . VMList )
{
foreach ( var currentApprovalPeriodList in currentSC . ApprovalPeriodList . VMList )
2016-06-27 01:45:38 +02:00
{
2018-02-23 14:42:53 +01:00
if ( currentApprovalPeriodList . SupportConceptApprovalEmployeeRelations . VMList . Any ( a = > a . Employee . EmployeeOid . Equals ( updatedEmployee . EmployeeOid ) ) )
2016-06-27 01:45:38 +02:00
{
2018-02-23 14:42:53 +01:00
// Nur einmal in der Liste
var employeeContainingRel = currentApprovalPeriodList . SupportConceptApprovalEmployeeRelations . VMList . FirstOrDefault ( f = > f . Employee . EmployeeOid . Equals ( updatedEmployee . EmployeeOid ) ) ;
if ( employeeContainingRel ! = null )
2016-06-27 01:45:38 +02:00
{
2018-02-23 14:42:53 +01:00
employeeContainingRel . Employee = null ;
employeeContainingRel . Employee = updatedEmployee ;
2016-06-27 01:45:38 +02:00
}
}
}
}
2018-02-23 14:42:53 +01:00
if ( pSupportConceptView . ViewModel . CostBearerRelations . VMList . Any ( a = > a . ApprovalPeriodList . VMList . Any ( a2 = > a2 . SupportConceptApprovalEmployeeRelations . VMList . Any ( a3 = > a3 . Employee . EmployeeOid . Equals ( updatedEmployee . EmployeeOid ) ) ) ) )
2016-06-27 01:45:38 +02:00
{
2018-02-23 14:42:53 +01:00
var emp = pSupportConceptView . SelectedApprovalPeriodVM . SupportConceptApprovalEmployeeRelations . VMList . FirstOrDefault ( f = > f . Employee . EmployeeOid . Equals ( updatedEmployee . EmployeeOid ) ) ;
if ( emp ! = null )
{
emp . Employee = null ;
emp . Employee = updatedEmployee ;
emp . EmployeeString = updatedEmployee . ToString ( ) ;
}
}
2016-06-27 01:45:38 +02:00
2018-02-23 14:42:53 +01:00
if ( pSupportConceptView . SelectedApprovalPeriodVM . SupportConceptApprovalEmployeeRelations . NewVM . Employee . EmployeeOid . Equals ( updatedEmployee . EmployeeOid ) )
{
pSupportConceptView . SelectedApprovalPeriodVM . SupportConceptApprovalEmployeeRelations . NewVM . Employee = null ;
pSupportConceptView . SelectedApprovalPeriodVM . SupportConceptApprovalEmployeeRelations . NewVM . Employee = updatedEmployee ;
pSupportConceptView . SelectedApprovalPeriodVM . SupportConceptApprovalEmployeeRelations . NewVM . EmployeeString = updatedEmployee . ToString ( ) ;
}
2016-06-27 01:45:38 +02:00
2018-02-23 14:42:53 +01:00
if ( pSupportConceptView . ViewModel . Originator . EmployeeOid . Equals ( updatedEmployee . EmployeeOid ) )
{
pSupportConceptView . ViewModel . Originator = null ;
pSupportConceptView . ViewModel . Originator = updatedEmployee ;
pSupportConceptView . popupedit_employee . Text = updatedEmployee . ToString ( ) ;
2016-06-27 01:45:38 +02:00
}
2018-02-23 14:42:53 +01:00
if ( BeWoApp . LoggedOnUser . Employee . EmployeeOid . Equals ( updatedEmployee . EmployeeOid ) )
2016-06-27 01:45:38 +02:00
{
2018-02-23 14:42:53 +01:00
BeWoApp . LoggedOnUser . Employee = updatedEmployee ;
}
2016-06-27 01:45:38 +02:00
2018-02-23 14:42:53 +01:00
pSupportConceptView . popupedit_employee . Text = updatedEmployee . ToString ( ) ;
UpdateLoggedInEmployee ( updatedEmployee . EmployeeOid ) ;
UpdateSearchViewObjectList ( pSupportConceptView . employeesearchview , updatedEmployee ) ;
2016-06-27 01:45:38 +02:00
2018-02-23 14:42:53 +01:00
foreach ( var item in pSupportConceptView . ViewModel . Tasks . VMList )
{
2019-02-28 12:38:29 +01:00
for ( var i = 0 ; i < item . EmployeeList . Count ; i + + )
2018-02-23 14:42:53 +01:00
{
var prevDirty = item . IsDirty ;
2019-02-28 12:38:29 +01:00
if ( ! item . EmployeeList [ i ] . Employee . EmployeeOid . Equals ( updatedEmployee . EmployeeOid ) )
2018-02-23 14:42:53 +01:00
{
continue ;
}
2016-06-27 01:45:38 +02:00
2019-02-28 12:38:29 +01:00
item . EmployeeList [ i ] . Employee = updatedEmployee ;
2016-06-27 01:45:38 +02:00
2018-02-23 14:42:53 +01:00
if ( ! prevDirty & & item . IsDirty )
{
item . SetDirty ( false ) ;
}
}
2016-06-27 01:45:38 +02:00
}
2018-02-23 14:42:53 +01:00
pSupportConceptView . grid_tasks . RefreshData ( ) ;
2016-06-27 01:45:38 +02:00
}
2018-02-23 14:42:53 +01:00
else if ( typeof ( T ) = = typeof ( CompactPersonDC ) )
2016-06-27 01:45:38 +02:00
{
2018-02-23 14:42:53 +01:00
var updatedPerson = new CompactPersonDC ( ) ;
2016-06-27 01:45:38 +02:00
2018-02-23 14:42:53 +01:00
ServiceFacade . DoCustomerServiceSync ( s = > updatedPerson = s . LoadPersonCompact ( ( pUpdatedObject as CompactPersonDC ) . PersonOid ) ) ;
2016-06-27 01:45:38 +02:00
2018-02-23 14:42:53 +01:00
( ( SupportConceptCostBearerRelVM ) pSupportConceptView . tabcontrol_costbearers . SelectedItem ) . CostBearerContactPerson = null ;
( ( SupportConceptCostBearerRelVM ) pSupportConceptView . tabcontrol_costbearers . SelectedItem ) . CostBearerContactPerson = updatedPerson ;
}
else if ( typeof ( T ) = = typeof ( CompactCustomerDC ) )
{
var updatedCustomer = pSupportConceptView . ViewModel . Customer ;
2016-06-27 01:45:38 +02:00
2018-02-23 14:42:53 +01:00
ServiceFacade . DoCustomerServiceSync ( s = > updatedCustomer = s . GetCompactCustomerDC ( pSupportConceptView . ViewModel . Customer . CustomerOid ) ) ;
2016-06-27 01:45:38 +02:00
2018-02-23 14:42:53 +01:00
pSupportConceptView . ViewModel . Customer = new CompactCustomerDC ( ) ;
pSupportConceptView . ViewModel . Customer = updatedCustomer ;
2016-06-27 01:45:38 +02:00
2018-02-23 14:42:53 +01:00
pSupportConceptView . popupedit_customer . Text = updatedCustomer . ToString ( ) ;
2016-06-27 01:45:38 +02:00
2018-02-23 14:42:53 +01:00
UpdateSearchViewObjectList ( pSupportConceptView . customersearchview , updatedCustomer ) ;
}
}
2016-06-27 01:45:38 +02:00
2018-02-23 14:42:53 +01:00
private static void UpdateServiceRecordView < T > ( ServiceRecordView2 pServiceRecordView , T pUpdatedObject ) where T : IFilterableDC
{
if ( typeof ( T ) = = typeof ( CompactCustomerDC ) )
{
var updatedCustomer = new CompactCustomerDC ( ) ;
2016-06-27 01:45:38 +02:00
2018-02-23 14:42:53 +01:00
ServiceFacade . DoCustomerServiceSync ( s = > updatedCustomer = s . GetCompactCustomerDC ( ( pUpdatedObject as CompactCustomerDC ) . CustomerOid ) ) ;
2016-06-27 01:45:38 +02:00
2018-02-23 14:42:53 +01:00
foreach ( var item in pServiceRecordView . ViewModel . VMList . Where ( item = > item . Customer . Equals ( updatedCustomer ) ) )
{
item . Customer = new CompactCustomerDC ( ) ;
item . Customer = updatedCustomer ;
}
2016-06-27 01:45:38 +02:00
2018-02-23 14:42:53 +01:00
pServiceRecordView . multiSupportConceptControl . UpdateSupportConcepts ( updatedCustomer ) ;
pServiceRecordView . multiSupportConceptControl . UpdateListBox ( ) ;
2016-06-27 01:45:38 +02:00
2018-02-23 14:42:53 +01:00
UpdateSingleSupportConceptSelectionControl ( pServiceRecordView . supportConceptSelectionControl , updatedCustomer ) ;
}
else if ( typeof ( T ) = = typeof ( CompactEmployeeDC ) )
{
var updatedEmployee = new CompactEmployeeDC ( ) ;
ServiceFacade . DoEmployeeServiceSync ( s = > updatedEmployee = s . LoadCompactEmployee ( ( pUpdatedObject as CompactEmployeeDC ) . EmployeeOid ) ) ;
2017-02-15 10:54:29 +01:00
2018-02-23 14:42:53 +01:00
UpdateSearchViewObjectList ( pServiceRecordView . employeeSearchView , updatedEmployee ) ;
pServiceRecordView . popupedit_employee . Text = updatedEmployee . ToString ( ) ;
2016-06-27 01:45:38 +02:00
2018-02-23 14:42:53 +01:00
UpdateLoggedInEmployee ( ( pUpdatedObject as CompactEmployeeDC ) . EmployeeOid ) ;
2016-06-27 01:45:38 +02:00
2018-02-23 14:42:53 +01:00
for ( var i = 0 ; i < pServiceRecordView . multiEmployeeControl . SelectedEmployees . Count ; i + + )
{
if ( ! pServiceRecordView . multiEmployeeControl . SelectedEmployees [ i ] . EmployeeOid . Equals ( updatedEmployee . EmployeeOid ) )
2016-06-27 01:45:38 +02:00
{
2018-02-23 14:42:53 +01:00
continue ;
2016-06-27 01:45:38 +02:00
}
2018-02-23 14:42:53 +01:00
pServiceRecordView . multiEmployeeControl . SelectedEmployees [ i ] = new CompactEmployeeDC ( ) ;
pServiceRecordView . multiEmployeeControl . SelectedEmployees [ i ] = updatedEmployee ;
2016-06-27 01:45:38 +02:00
}
2018-02-23 14:42:53 +01:00
pServiceRecordView . multiEmployeeControl . UpdateListBox ( ) ;
UpdateSearchViewObjectList ( pServiceRecordView . multiEmployeeControl . employeesearchview , updatedEmployee ) ;
//CB EINKOMMENTIEREN
//if (pServiceRecordView.ViewModel.BedarfsMedViewModel.NewVM.Employee != null && pServiceRecordView.ViewModel.BedarfsMedViewModel.NewVM.Employee.EmployeeOid.Equals(updatedEmployee.EmployeeOid))
//{
// pServiceRecordView.ViewModel.BedarfsMedViewModel.NewVM.Employee = updatedEmployee;
// pServiceRecordView.popupedit_employee_bedarfsmed.Text = updatedEmployee.ToString();
// UpdateSearchViewObjectList(pServiceRecordView.MedRecordEmployeeSearchView, updatedEmployee);
//}
//// TODO: Bedarfsmedikationen
//UpdateSearchViewObjectList(pServiceRecordView.MedRecordEmployeeSearchView, updatedEmployee);
// foreach (var item in ((BindingList<MedRecordVM>)pServiceRecordView.MedRecordGridControl.ItemsSource).Where(item => item.Employee.EmployeeOid.Equals(updatedEmployee.EmployeeOid)))
//{
// item.Employee = null;
// item.Employee = updatedEmployee;
//}
//pServiceRecordView.MedRecordGridControl.RefreshData();
if ( pServiceRecordView . ViewModel . CustomerNodes . Count < = 0 | | pServiceRecordView . ViewModel . ServiceRecordsForSelectedCustomer = = null )
2016-06-27 01:45:38 +02:00
{
2018-02-23 14:42:53 +01:00
return ;
}
2016-06-27 01:45:38 +02:00
2018-02-23 14:42:53 +01:00
foreach ( var item in pServiceRecordView . ViewModel . ServiceRecordsForSelectedCustomer . Where ( item = > item . Employee . EmployeeOid . Equals ( updatedEmployee . EmployeeOid ) ) )
{
item . Employee = null ;
item . Employee = updatedEmployee ;
2016-06-27 01:45:38 +02:00
}
2018-02-23 14:42:53 +01:00
2019-10-10 22:07:42 +02:00
pServiceRecordView . ViewModel . RefreshServiceRecordsForSelectedTreeNode ( false ) ;
2016-06-27 01:45:38 +02:00
}
2018-02-23 14:42:53 +01:00
else if ( typeof ( T ) = = typeof ( CompactOrganisationDC ) )
2016-06-27 01:45:38 +02:00
{
2018-02-23 14:42:53 +01:00
var updatedOrganisation = new CompactOrganisationDC ( ) ;
2016-06-27 01:45:38 +02:00
2018-02-23 14:42:53 +01:00
ServiceFacade . DoCustomerServiceSync ( s = > updatedOrganisation = s . LoadOrganisationCompact ( ( pUpdatedObject as CompactOrganisationDC ) . OrganisationOid ) ) ;
2016-06-27 01:45:38 +02:00
2018-02-23 14:42:53 +01:00
foreach ( var item in pServiceRecordView . ViewModel . VMList . Where ( item = > item . CostBearer . Equals ( updatedOrganisation ) ) )
{
item . CostBearer = new CompactOrganisationDC ( ) ;
item . CostBearer = updatedOrganisation ;
}
}
}
2016-06-27 01:45:38 +02:00
2018-02-23 14:42:53 +01:00
private static void UpdateTeamView < T > ( TeamView pTeamView , T pUpdatedObject ) where T : IFilterableDC
{
if ( typeof ( T ) = = typeof ( CompactEmployeeDC ) )
{
var updatedEmployee = new CompactEmployeeDC ( ) ;
2016-06-27 01:45:38 +02:00
2018-02-23 14:42:53 +01:00
ServiceFacade . DoEmployeeServiceSync ( s = > updatedEmployee = s . LoadCompactEmployee ( ( pUpdatedObject as CompactEmployeeDC ) . EmployeeOid ) ) ;
2016-06-27 01:45:38 +02:00
2018-02-23 14:42:53 +01:00
if ( pTeamView . ViewModel . Leader . Equals ( pUpdatedObject as CompactEmployeeDC ) )
{
pTeamView . ViewModel . Leader = null ;
pTeamView . ViewModel . Leader = updatedEmployee ;
}
if ( pTeamView . ViewModel . Member . Contains ( updatedEmployee ) )
{
var newMember = new ObservableSortCollection < CompactEmployeeDC > ( ) ;
foreach ( var item in pTeamView . ViewModel . Member )
2016-06-27 01:45:38 +02:00
{
2018-02-23 14:42:53 +01:00
newMember . Add ( item . EmployeeOid . Equals ( updatedEmployee . EmployeeOid ) ? updatedEmployee : item ) ;
2016-06-27 01:45:38 +02:00
}
2018-02-23 14:42:53 +01:00
pTeamView . ViewModel . Member = null ;
pTeamView . ViewModel . Member = newMember ;
2016-06-27 01:45:38 +02:00
}
2018-02-23 14:42:53 +01:00
if ( pTeamView . ViewModel . Leader . EmployeeOid . Equals ( updatedEmployee . EmployeeOid ) )
2016-06-27 01:45:38 +02:00
{
2018-02-23 14:42:53 +01:00
pTeamView . ViewModel . Leader = null ;
pTeamView . ViewModel . Leader = updatedEmployee ;
2016-06-27 01:45:38 +02:00
}
2018-02-23 14:42:53 +01:00
UpdateSearchViewObjectList ( pTeamView . employeesearchview , updatedEmployee ) ;
UpdateSearchViewObjectList ( pTeamView . leaderSearchView , updatedEmployee ) ;
UpdateLoggedInEmployee ( updatedEmployee . EmployeeOid ) ;
2016-06-27 01:45:38 +02:00
}
2018-02-23 14:42:53 +01:00
else if ( typeof ( T ) = = typeof ( CompactTeamDC ) )
2016-06-27 01:45:38 +02:00
{
2018-02-23 14:42:53 +01:00
pTeamView . ReloadViewModel ( ) ;
}
}
2016-06-27 01:45:38 +02:00
2018-02-23 14:42:53 +01:00
private static void UpdateUserView ( UserView pUserView )
{
var updatedEmployee = new CompactEmployeeDC ( ) ;
2016-06-27 01:45:38 +02:00
2018-02-23 14:42:53 +01:00
ServiceFacade . DoEmployeeServiceSync ( s = > updatedEmployee = s . LoadCompactEmployee ( pUserView . ViewModel . Employee . EmployeeOid ) ) ;
2016-06-27 01:45:38 +02:00
2018-02-23 14:42:53 +01:00
pUserView . ViewModel . Employee = null ;
pUserView . ViewModel . Employee = updatedEmployee ;
2016-06-27 01:45:38 +02:00
2018-02-23 14:42:53 +01:00
var myView = new BeWoView ( ) ;
BeWoApp . MainControl . Views . TryGetValue ( UIContext . User , out myView ) ;
2016-06-27 01:45:38 +02:00
2018-02-23 14:42:53 +01:00
if ( myView is UserNavigationView naviView )
2016-06-27 01:45:38 +02:00
{
2018-02-23 14:42:53 +01:00
if ( naviView . ObjectList . Contains ( updatedEmployee ) )
{
var copiedList = naviView . ObjectList as List < IFilterableDC > ;
copiedList [ copiedList . IndexOf ( updatedEmployee ) ] = new CompactEmployeeDC ( ) ;
copiedList [ copiedList . IndexOf ( updatedEmployee ) ] = updatedEmployee ;
naviView . ObjectList = copiedList ;
}
2016-06-27 01:45:38 +02:00
2018-02-23 14:42:53 +01:00
if ( naviView . RecentList . Contains ( updatedEmployee ) )
2016-06-27 01:45:38 +02:00
{
2018-02-23 14:42:53 +01:00
var copiedList = naviView . RecentList as List < IFilterableDC > ;
copiedList [ copiedList . IndexOf ( updatedEmployee ) ] = new CompactEmployeeDC ( ) ;
copiedList [ copiedList . IndexOf ( updatedEmployee ) ] = updatedEmployee ;
naviView . RecentList = copiedList ;
}
}
2016-06-27 01:45:38 +02:00
2018-02-23 14:42:53 +01:00
UpdateSearchViewObjectList ( pUserView . employeeSearchView , updatedEmployee ) ;
UpdateLoggedInEmployee ( updatedEmployee . EmployeeOid ) ;
}
2016-06-27 01:45:38 +02:00
2018-02-23 14:42:53 +01:00
private static void UpdateReportView < T > ( ReportView pReportView , T pUpdatedObject ) where T : IFilterableDC
{
pReportView . OpenViews . TryGetValue ( pReportView . tabitem_maReport , out var aus ) ;
pReportView . OpenViews . TryGetValue ( pReportView . tabitem_flsReport , out var fls ) ;
pReportView . OpenViews . TryGetValue ( pReportView . tabitem_serviceOverview , out var serv ) ;
2016-06-27 01:45:38 +02:00
2018-02-23 14:42:53 +01:00
if ( typeof ( T ) = = typeof ( CompactCustomerDC ) )
{
var updatedCustomer = new CompactCustomerDC ( ) ;
ServiceFacade . DoCustomerServiceSync ( s = > updatedCustomer = s . GetCompactCustomerDC ( ( pUpdatedObject as CompactCustomerDC ) . CustomerOid ) ) ;
2016-06-27 01:45:38 +02:00
2018-02-23 14:42:53 +01:00
if ( fls is FLSReportView fls2 )
{
if ( fls2 . _SelectedCustomer ! = null )
2016-06-27 01:45:38 +02:00
{
2018-02-23 14:42:53 +01:00
if ( fls2 . _LastSelectedCustomer ! = null )
2016-06-27 01:45:38 +02:00
{
2018-02-23 14:42:53 +01:00
if ( fls2 . _LastSelectedCustomer . Equals ( updatedCustomer ) )
{
fls2 . _LastSelectedCustomer = updatedCustomer ;
}
2016-06-27 01:45:38 +02:00
}
2018-02-23 14:42:53 +01:00
fls2 . _SelectedCustomer = updatedCustomer ;
fls2 . popupedit_client . Text = updatedCustomer . ToString ( ) ;
2016-06-27 01:45:38 +02:00
}
2018-02-23 14:42:53 +01:00
UpdateSearchViewObjectList ( fls2 . customerSearchView , updatedCustomer ) ;
2016-06-27 01:45:38 +02:00
}
2018-02-23 14:42:53 +01:00
var serv2 = serv as ServicesReportView ;
2020-10-27 12:29:59 +01:00
if ( serv2 ! = null )
2018-02-23 14:42:53 +01:00
{
if ( serv2 . Customer ! = null )
2016-06-27 01:45:38 +02:00
{
2018-02-23 14:42:53 +01:00
serv2 . Customer = updatedCustomer ;
serv2 . popupedit_customer . Text = updatedCustomer . ToString ( ) ;
}
2016-06-27 01:45:38 +02:00
2018-02-23 14:42:53 +01:00
UpdateSearchViewObjectList ( serv2 . customersearchview , updatedCustomer ) ;
}
}
2016-06-27 01:45:38 +02:00
2018-02-23 14:42:53 +01:00
if ( typeof ( T ) = = typeof ( CompactEmployeeDC ) )
{
var updatedEmployee = new CompactEmployeeDC ( ) ;
ServiceFacade . DoEmployeeServiceSync ( s = > updatedEmployee = s . LoadCompactEmployee ( ( pUpdatedObject as CompactEmployeeDC ) . EmployeeOid ) ) ;
2016-06-27 01:45:38 +02:00
2018-02-23 14:42:53 +01:00
if ( aus is AuslastungReportView aus2 )
{
if ( aus2 . _SelectedEmployee ! = null )
2016-06-27 01:45:38 +02:00
{
2018-02-23 14:42:53 +01:00
if ( aus2 . _SelectedEmployee ! = null )
2016-06-27 01:45:38 +02:00
{
2018-02-23 14:42:53 +01:00
if ( aus2 . _SelectedEmployee . EmployeeOid . Equals ( updatedEmployee . EmployeeOid ) )
{
aus2 . _SelectedEmployee = updatedEmployee ;
}
2016-06-27 01:45:38 +02:00
}
2018-02-23 14:42:53 +01:00
if ( aus2 . _LastSelectedEmployee ! = null )
2016-06-27 01:45:38 +02:00
{
2018-02-23 14:42:53 +01:00
if ( aus2 . _LastSelectedEmployee . EmployeeOid . Equals ( updatedEmployee . EmployeeOid ) )
{
aus2 . _LastSelectedEmployee = updatedEmployee ;
}
2016-06-27 01:45:38 +02:00
}
2018-02-23 14:42:53 +01:00
if ( aus2 . _SelectedEmployee ! = null )
{
aus2 . popupedit_employee . Text = updatedEmployee . ToString ( ) ;
}
2016-06-27 01:45:38 +02:00
}
2018-02-23 14:42:53 +01:00
UpdateSearchViewObjectList ( aus2 . employeesearchview , updatedEmployee ) ;
2016-06-27 01:45:38 +02:00
}
2018-02-23 14:42:53 +01:00
if ( fls is FLSReportView fls2 )
{
if ( fls2 . _SelectedEmployee ! = null )
2016-06-27 01:45:38 +02:00
{
2018-02-23 14:42:53 +01:00
if ( fls2 . _LastSelectedEmployee ! = null )
2016-06-27 01:45:38 +02:00
{
2018-02-23 14:42:53 +01:00
if ( fls2 . _LastSelectedEmployee . EmployeeOid . Equals ( updatedEmployee . EmployeeOid ) )
{
fls2 . _LastSelectedEmployee = updatedEmployee ;
}
2016-06-27 01:45:38 +02:00
}
2018-02-23 14:42:53 +01:00
fls2 . _SelectedEmployee = updatedEmployee ;
fls2 . popupedit_employee . Text = updatedEmployee . ToString ( ) ;
2016-06-27 01:45:38 +02:00
}
2018-02-23 14:42:53 +01:00
UpdateSearchViewObjectList ( fls2 . employeeSearchView , updatedEmployee ) ;
2016-06-27 01:45:38 +02:00
}
2018-02-23 14:42:53 +01:00
if ( serv is ServicesReportView serv2 )
{
if ( serv2 . Employee ! = null )
2016-06-27 01:45:38 +02:00
{
2018-02-23 14:42:53 +01:00
serv2 . Employee = updatedEmployee ;
serv2 . popupedit_employee . Text = updatedEmployee . ToString ( ) ;
}
2016-06-27 01:45:38 +02:00
2018-02-23 14:42:53 +01:00
UpdateSearchViewObjectList ( serv2 . employeesearchview , updatedEmployee ) ;
}
2016-06-27 01:45:38 +02:00
2018-02-23 14:42:53 +01:00
UpdateLoggedInEmployee ( updatedEmployee . EmployeeOid ) ;
}
2016-06-27 01:45:38 +02:00
2018-02-23 14:42:53 +01:00
if ( typeof ( T ) = = typeof ( CompactOrganisationDC ) )
{
var updatedOrganisation = new CompactOrganisationDC ( ) ;
ServiceFacade . DoCustomerServiceSync ( s = > updatedOrganisation = s . LoadOrganisationCompact ( ( pUpdatedObject as CompactOrganisationDC ) . OrganisationOid ) ) ;
if ( serv is ServicesReportView serv2 )
{
if ( serv2 . Organisation ! = null )
{
serv2 . Organisation = updatedOrganisation ;
serv2 . popupedit_costbearer . Text = updatedOrganisation . ToString ( ) ;
2016-06-27 01:45:38 +02:00
}
2018-02-23 14:42:53 +01:00
UpdateSearchViewObjectList ( serv2 . organisationsearchview , updatedOrganisation ) ;
2016-06-27 01:45:38 +02:00
}
}
2018-02-23 14:42:53 +01:00
if ( typeof ( T ) = = typeof ( CompactTeamDC ) )
2016-06-27 01:45:38 +02:00
{
2018-02-23 14:42:53 +01:00
var updatedTeam = new CompactTeamDC ( ) ;
ServiceFacade . DoEmployeeServiceSync ( s = > updatedTeam = s . LoadCompactTeam ( ( pUpdatedObject as CompactTeamDC ) . TeamOid ) ) ;
2017-11-23 10:58:07 +01:00
2018-02-23 14:42:53 +01:00
if ( aus is AuslastungReportView aus2 )
2016-06-27 01:45:38 +02:00
{
2018-02-23 14:42:53 +01:00
if ( aus2 . _SelectedTeam ! = null )
{
if ( aus2 . _SelectedTeam . Equals ( updatedTeam ) )
{
aus2 . _SelectedTeam = updatedTeam ;
}
2016-06-27 01:45:38 +02:00
2018-02-23 14:42:53 +01:00
if ( aus2 . _LastSelectedTeam ! = null )
{
if ( aus2 . _LastSelectedTeam . Equals ( updatedTeam ) )
{
aus2 . _LastSelectedTeam = updatedTeam ;
}
}
2016-06-27 01:45:38 +02:00
2018-02-23 14:42:53 +01:00
aus2 . popupedit_team . Text = updatedTeam . ToString ( ) ;
}
2016-06-27 01:45:38 +02:00
2018-02-23 14:42:53 +01:00
UpdateSearchViewObjectList ( aus2 . teamsearchview , updatedTeam ) ;
}
}
}
2016-06-27 01:45:38 +02:00
2018-02-23 14:42:53 +01:00
private static void UpdatePersonView < T > ( PersonView pPersonView , T pUpdatedObject ) where T : IFilterableDC
{
if ( typeof ( T ) = = typeof ( CompactOrganisationDC ) )
{
var gridRelations = ( GridControl ) pPersonView . rootGrid . Resources [ "grid_Relations" ] ;
var updatedOrganisation = new CompactOrganisationDC ( ) ;
2016-06-27 01:45:38 +02:00
2018-02-23 14:42:53 +01:00
ServiceFacade . DoCustomerServiceSync ( s = > updatedOrganisation = s . LoadOrganisationCompact ( ( pUpdatedObject as CompactOrganisationDC ) . OrganisationOid ) ) ;
2016-06-27 01:45:38 +02:00
2018-02-23 14:42:53 +01:00
if ( ! string . IsNullOrWhiteSpace ( pPersonView . popupedit_organisation . Text ) & & pPersonView . popupedit_organisation . Text . Equals ( ( pUpdatedObject as CompactOrganisationDC ) . Name ) )
{
pPersonView . popupedit_organisation . Text = updatedOrganisation . ToString ( ) ;
2016-06-27 01:45:38 +02:00
}
2018-02-23 14:42:53 +01:00
foreach ( var item in pPersonView . ViewModel . OrganisationRelations . VMList . Where ( item = > item . Organisation . OrganisationOid = = updatedOrganisation . OrganisationOid ) )
2016-06-27 01:45:38 +02:00
{
2018-02-23 14:42:53 +01:00
item . OrganisationString = updatedOrganisation . Name ;
2016-06-27 01:45:38 +02:00
}
2018-02-23 14:42:53 +01:00
gridRelations . RefreshData ( ) ;
if ( pPersonView . ViewModel . OrganisationRelations . NewVM ? . Organisation ! = null )
2017-11-23 10:58:07 +01:00
{
2018-02-23 14:42:53 +01:00
if ( pPersonView . ViewModel . OrganisationRelations . NewVM . Organisation . OrganisationOid . Equals ( updatedOrganisation . OrganisationOid ) )
{
pPersonView . ViewModel . OrganisationRelations . NewVM . OrganisationString = updatedOrganisation . Name ;
}
2017-11-23 10:58:07 +01:00
}
2018-02-23 14:42:53 +01:00
UpdateSearchViewObjectList ( pPersonView . organisationSearchView , updatedOrganisation ) ;
2016-06-27 01:45:38 +02:00
}
2018-02-23 14:42:53 +01:00
else if ( typeof ( T ) = = typeof ( CompactPersonDC ) )
2016-06-27 01:45:38 +02:00
{
2018-02-23 14:42:53 +01:00
pPersonView . ReloadViewModel ( ) ;
}
else if ( typeof ( T ) = = typeof ( CompactCustomerDC ) )
{
pPersonView . UpdateCustomerList ( ) ;
}
}
2016-06-27 01:45:38 +02:00
2018-02-23 14:42:53 +01:00
private static void UpdateAdditionalServiceView < T > ( AdditionalServiceView pAdditionalServiceView , T pUpdatedObject ) where T : IFilterableDC
{
if ( typeof ( T ) = = typeof ( CompactEmployeeDC ) )
{
var updatedEmployee = new CompactEmployeeDC ( ) ;
ServiceFacade . DoEmployeeServiceSync ( s = > updatedEmployee = s . LoadCompactEmployee ( ( pUpdatedObject as CompactEmployeeDC ) . EmployeeOid ) ) ;
2016-06-27 01:45:38 +02:00
2018-02-23 14:42:53 +01:00
UpdateLoggedInEmployee ( ( pUpdatedObject as CompactEmployeeDC ) . EmployeeOid ) ;
2016-06-27 01:45:38 +02:00
2018-02-23 14:42:53 +01:00
for ( var i = 0 ; i < pAdditionalServiceView . MultiEmployeeControlAddServ . SelectedEmployees . Count ; i + + )
{
if ( ! pAdditionalServiceView . MultiEmployeeControlAddServ . SelectedEmployees [ i ] . EmployeeOid . Equals ( updatedEmployee . EmployeeOid ) )
2016-06-27 01:45:38 +02:00
{
2018-02-23 14:42:53 +01:00
continue ;
2016-06-27 01:45:38 +02:00
}
2018-02-23 14:42:53 +01:00
pAdditionalServiceView . MultiEmployeeControlAddServ . SelectedEmployees [ i ] = new CompactEmployeeDC ( ) ;
pAdditionalServiceView . MultiEmployeeControlAddServ . SelectedEmployees [ i ] = updatedEmployee ;
2016-06-27 01:45:38 +02:00
}
2018-02-23 14:42:53 +01:00
UpdateSearchViewObjectList ( pAdditionalServiceView . MultiEmployeeControlAddServ . employeesearchview , updatedEmployee ) ;
}
else if ( typeof ( T ) = = typeof ( CompactCustomerDC ) )
{
var updatedCustomer = new CompactCustomerDC ( ) ;
2016-06-27 01:45:38 +02:00
2018-02-23 14:42:53 +01:00
ServiceFacade . DoCustomerServiceSync ( s = > updatedCustomer = s . GetCompactCustomerDC ( ( pUpdatedObject as CompactCustomerDC ) . CustomerOid ) ) ;
2016-06-27 01:45:38 +02:00
2018-02-23 14:42:53 +01:00
pAdditionalServiceView . MultiAddServGroupOfPeopleSelectionControl . UpdateCustomers ( updatedCustomer ) ;
2016-06-27 01:45:38 +02:00
2018-02-23 14:42:53 +01:00
foreach ( var item in pAdditionalServiceView . AdditionalServiceBookings . VMList )
{
var newCustomerList = item . CustomerOidDict . ToDictionary ( element = > element . Key . Equals ( updatedCustomer . CustomerOid ) ? updatedCustomer . CustomerOid : element . Key , element = > element . Value ) ;
item . CustomerOidDict = newCustomerList ;
}
2016-06-27 01:45:38 +02:00
2018-02-23 14:42:53 +01:00
var containsUpdatedCustomer = false ;
2016-06-27 01:45:38 +02:00
2018-02-23 14:42:53 +01:00
foreach ( var element in from item in pAdditionalServiceView . AdditionalServiceBookings . VMList from element in item . CustomerOidDict where element . Key . Equals ( updatedCustomer . CustomerOid ) select element )
{
containsUpdatedCustomer = true ;
}
2016-06-27 01:45:38 +02:00
2018-02-23 14:42:53 +01:00
if ( ! containsUpdatedCustomer )
{
return ;
2016-06-27 01:45:38 +02:00
}
2018-02-23 14:42:53 +01:00
pAdditionalServiceView . UpdateTeilnahmeGrid ( ) ;
2016-06-27 01:45:38 +02:00
}
}
2018-02-23 14:42:53 +01:00
2016-06-27 01:45:38 +02:00
private static void UpdateSingleSupportConceptSelectionControl ( SingleSupportConceptSelectionControl control , CompactCustomerDC updatedCustomer )
{
if ( control . SelectedItem . SupportConceptTreeNodeDC = = null )
return ;
var supConSelConSeletedItem = control . SelectedItem ;
if ( supConSelConSeletedItem ! = null )
{
if ( supConSelConSeletedItem . SupportConceptTreeNodeDC . Customer . Equals ( updatedCustomer ) )
supConSelConSeletedItem . SupportConceptTreeNodeDC . Customer = updatedCustomer ;
if ( supConSelConSeletedItem . SupportConceptTreeNodeDC . SupportConcept . Customer . Equals ( updatedCustomer ) )
supConSelConSeletedItem . SupportConceptTreeNodeDC . SupportConcept . Customer = updatedCustomer ;
}
var newList = control . SearchView . ObjectList ;
foreach ( var concept in newList . Where ( concept = > concept . Customer . Equals ( updatedCustomer ) ) )
concept . Customer = updatedCustomer ;
control . SearchView . ObjectList = newList ;
control . SetSelectedSupportConceptOid ( control . SelectedItem . SupportConceptTreeNodeDC . SupportConcept . SupportConceptOid ) ;
control . UpdateControls ( ) ;
control . customerText . Text = updatedCustomer . ToString ( ) ;
}
private static void UpdateLoggedInEmployee ( long employeeOid )
{
if ( employeeOid ! = BeWoApp . LoggedOnUser . Employee . EmployeeOid )
return ;
ServiceFacade . DoEmployeeServiceSync ( s = > BeWoApp . LoggedOnUser . Employee = s . LoadCompactEmployee ( BeWoApp . LoggedOnUser . Employee . EmployeeOid ) ) ;
if ( BeWoApp . MainControl . HomeButtonPanel = = null )
return ;
2019-08-19 11:59:38 +02:00
//BeWoApp.MainControl.HomeView.txtHeader.Text = BeWoApp.LoggedOnUser.Employee.ToString();
2016-06-27 01:45:38 +02:00
}
public static void WriteExcelFile ( string content , string path )
{
using ( var uFileStream = File . Create ( path ) )
using ( var uSw = new StreamWriter ( uFileStream ) )
uSw . Write ( content ) ;
System . Diagnostics . Process . Start ( new System . Diagnostics . ProcessStartInfo ( path ) ) ;
}
2017-02-01 13:53:59 +01:00
public static void WriteFile ( string content , string path )
{
using ( var uFileStream = File . Create ( path ) )
using ( var uSw = new StreamWriter ( uFileStream , Encoding . GetEncoding ( 1252 ) ) )
uSw . Write ( content ) ;
if ( MessageBox . Show ( "Möchten Sie die Datei öffnen?" , "Datei öffnen" , MessageBoxButton . YesNo , MessageBoxImage . Question ) = = MessageBoxResult . Yes )
{
System . Diagnostics . Process . Start ( new System . Diagnostics . ProcessStartInfo ( path ) ) ;
}
}
//public static void Richloaded(object sender, RoutedEventArgs e)
//{
// var richEditControl1 = (RichEditControl) sender;
// richEditControl1.ActiveViewType = RichEditViewType.Simple;
// richEditControl1.ShowBorder = false;
// richEditControl1.ShowHoverMenu = false;
// richEditControl1.CornerBoxVisibility = Visibility.Visible;
// richEditControl1.VerticalRulerVisibility = Visibility.Collapsed;
// richEditControl1.HorizontalRulerVisibility = Visibility.Collapsed;
// richEditControl1.Language = System.Windows.Markup.XmlLanguage.GetLanguage("de-DE");
//}
//public static void Popupmenu(object sender, PopupMenuShowingEventArgs e)
//{
// foreach (var item in e.Menu.ItemLinks.Where(x => x.ActualIsVisible).Where(item => !(item is BarItemLinkSeparator)))
// {
// var btn = (BarButtonItemLink)item;
// if (btn.ActualContent.Equals("Lösche Zeile") ||
// btn.ActualContent.Equals("Lösche Spalte") ||
// btn.ActualContent.Equals("Lösche Zelle...") ||
// btn.ActualContent.Equals("Zellen verbinden") ||
// btn.ActualContent.Equals("Teile Zellen...") ||
// btn.ActualContent.Equals("Zellausrichtung") ||
// btn.ActualContent.Equals("AutoAnpassen") ||
// btn.ActualContent.Equals("Tabelleneigenschaften...") ||
// btn.ActualContent.Equals("Einzug erhöhen") ||
// btn.ActualContent.Equals("Einzug verringern") ||
// btn.ActualContent.Equals("Schriftart") ||
// btn.ActualContent.Equals("Absatz") ||
// btn.ActualContent.Equals("Nummerierun") ||
// btn.ActualContent.Equals("Lesezeichen...") ||
// btn.ActualContent.Equals("Hyperlink...") ||
// btn.ActualContent.Equals("Zeilenumbruch") ||
// btn.ActualContent.Equals("Eine Ebene nach vorne") ||
// btn.ActualContent.Equals("Eine Ebene nach hinten") ||
// btn.ActualContent.Equals("Layout"))
// item.IsVisible = false;
// }
//}
2016-06-27 01:45:38 +02:00
2023-10-26 00:06:56 +02:00
public static void OpenMailClient ( string mailAddress , string subject = "" , string body = "" )
2016-06-27 01:45:38 +02:00
{
2024-02-19 14:15:43 +01:00
//mailAddress = "cb@ownsoft.de";
//subject = "Betreff";
2023-10-26 00:06:56 +02:00
var mailCmd = string . Format ( @"mailto:{0}?subject={1}&body={2}" , mailAddress , subject , body ) ;
2016-06-27 01:45:38 +02:00
System . Diagnostics . Process . Start ( mailCmd ) ;
}
public static bool ValidateServiceRecordVM ( ServiceRecordVM vm , SupportConceptStatisticsDC statistics , FlatSupportConceptTreeNodeDC node , bool withoutClient , CompactEmployeeDC selectedEmployee , List < long > employeeOids , List < long > cb2ScOids )
{
var lValid = true ;
2018-04-18 14:33:21 +02:00
if ( vm . ServiceDescription = = null )
2016-06-27 01:45:38 +02:00
{
MessageBox . Show ( "Bitte wählen Sie eine Leistung aus. Sollten keine Leistungen für die gewählte Kategorie verfügbar sein, müssen diese zunächst in der Verwaltung angelegt werden." , "Speichern" , MessageBoxButton . OK , MessageBoxImage . Information ) ;
return false ;
}
2018-04-18 14:33:21 +02:00
if ( vm . GoalTree ! = null & & vm . GoalTree . Count > 0 & & ( cb2ScOids = = null | | cb2ScOids . Count < 2 ) )
2016-06-27 01:45:38 +02:00
{
2018-04-18 14:33:21 +02:00
if ( vm . SelectedGoals . Count = = 0 & & MessageBox . Show ( "Es wurde kein Ziel zugeordnet. Sind Sie sicher, dass Sie speichern möchten?" , "Speichern" , MessageBoxButton . YesNo , MessageBoxImage . Question ) = = MessageBoxResult . No )
{
return false ;
}
2016-06-27 01:45:38 +02:00
}
CompactSupportConceptDC scDc = null ;
CompactOrganisationDC cbDc = null ;
SupportConceptCostBearerRelDC relDc = null ;
if ( node ! = null & & node . SupportConceptTreeNodeDC ! = null )
{
scDc = node . SupportConceptTreeNodeDC . SupportConcept ;
cbDc = node . SupportConceptTreeNodeDC . CostBearer ;
relDc = node . SupportConceptTreeNodeDC . SupportConceptCostBearerRelDC ;
}
var dc = vm . CommitToDataContract ( ) ;
dc . Employee = selectedEmployee ? ? BeWoApp . LoggedOnUser . Employee ;
dc . SupportConcept = scDc ;
dc . CostBearer = cbDc ;
2017-01-31 07:15:00 +01:00
2016-06-27 01:45:38 +02:00
if ( relDc ! = null )
2021-07-05 18:05:43 +02:00
{
dc . CostBearer2SupportConceptOid = relDc . CostBearer2SupportConceptOid ;
}
2023-11-15 00:52:39 +01:00
else
{
dc . CostBearer2SupportConceptOid = null ;
}
2021-07-05 18:05:43 +02:00
var validationResults = new List < ServiceRecordValidationResultDC > ( ) ;
2016-06-27 01:45:38 +02:00
var maxdays = BeWoApp . AppSettings . MaxDaysEditServiceRecordsAllowed ;
if ( withoutClient & & BeWoApp . AppSettings . MaxDaysEditServiceRecordsAllowed < = 0 )
2021-07-05 18:05:43 +02:00
{
2016-06-27 01:45:38 +02:00
maxdays = - 1 ;
2021-07-05 18:05:43 +02:00
}
2016-06-27 01:45:38 +02:00
if ( BeWoApp . LoggedOnUser . HasRight ( UserRightType . ServiceRecord_AllowEditAfterMaxDaysInNextMonth ) )
2021-07-05 18:05:43 +02:00
{
2016-06-27 01:45:38 +02:00
maxdays = - 1 ;
2021-07-05 18:05:43 +02:00
}
2016-06-27 01:45:38 +02:00
2021-07-05 18:05:43 +02:00
ServiceFacade . DoOperationsServiceSync ( o = > validationResults = o . ValidateServiceRecord ( dc , statistics , maxdays , employeeOids , cb2ScOids ) ) ;
2016-06-27 01:45:38 +02:00
2021-07-05 18:05:43 +02:00
if ( validationResults . Count > 0 )
2016-06-27 01:45:38 +02:00
{
var exitLoop = false ;
2021-07-05 18:05:43 +02:00
foreach ( var result in validationResults )
2016-06-27 01:45:38 +02:00
{
switch ( result . ResultType )
{
case ServiceRecordValidationResult . OutsideOfSupportConcept :
2021-07-05 18:05:43 +02:00
MessageBox . Show ( $"Das gewählte Datum '{vm.StartDate.ToShortDateString()}' liegt außerhalb des Zeitraums des gewählten Hilfeplans ({relDc.DateRangeString}).\nDas Speichern ist nicht möglich." , "Speichern" , MessageBoxButton . OK , MessageBoxImage . Information ) ;
2016-06-27 01:45:38 +02:00
lValid = false ;
exitLoop = true ;
break ;
case ServiceRecordValidationResult . OutOfEditLimit :
2021-07-05 18:05:43 +02:00
MessageBox . Show ( $"Sie können keine neuen Leistungen für den {vm.StartDate.ToShortDateString()} dokumentieren, da bereits der {BeWoApp.AppSettings.MaxDaysEditServiceRecordsAllowed}. des nachfolgenden Monats überschritten ist." , "Speichern" , MessageBoxButton . OK , MessageBoxImage . Information ) ;
2016-06-27 01:45:38 +02:00
lValid = false ;
exitLoop = true ;
break ;
case ServiceRecordValidationResult . FristAbgelaufen :
if ( ! BeWoApp . LoggedOnUser . HasRight ( UserRightType . ServiceRecordAllowEditAfterMindays ) )
{
if ( BeWoApp . AppSettings . AnzTageZeiterfassErfolgt = = 1 )
{
2021-07-05 18:05:43 +02:00
MessageBox . Show ( $"Sie können keine neuen Leistungen für den {vm.StartDate.ToShortDateString()} dokumentieren, da die Zeiterfassung innerhalb von einem Tag erfolgen muss." , "Speichern" , MessageBoxButton . OK , MessageBoxImage . Information ) ;
2016-06-27 01:45:38 +02:00
}
else
{
2021-07-05 18:05:43 +02:00
MessageBox . Show ( $"Sie können keine neuen Leistungen für den {vm.StartDate.ToShortDateString()} dokumentieren, da die Zeiterfassung innerhalb von {BeWoApp.AppSettings.AnzTageZeiterfassErfolgt} Tagen erfolgen muss." , "Speichern" , MessageBoxButton . OK , MessageBoxImage . Information ) ;
2016-06-27 01:45:38 +02:00
}
lValid = false ;
exitLoop = true ;
}
break ;
case ServiceRecordValidationResult . Error :
MessageBox . Show ( "Beim Speichern ist ein Fehler aufgetreten.\nDas Speichern ist nicht möglich." , "Speichern nicht möglich" , MessageBoxButton . OK , MessageBoxImage . Error ) ;
lValid = false ;
exitLoop = true ;
break ;
case ServiceRecordValidationResult . ServiceRecordOverlapping :
if ( ! BeWoApp . LoggedOnUser . HasRight ( UserRightType . ServiceRecord_AllowCreateOverlappingFLS ) )
{
2022-11-25 15:22:38 +01:00
MessageBox . Show ( $"An dem gewählten Datum '{vm.StartDate.ToShortDateString()} {vm.StartDate.ToShortTimeString()}' existiert bereits ein Eintrag ({result.Message} bei " + BS . Shared . Translation . Translator . Translate ( "Klient/in" ) + " " + result . CustomerName + ") .\nSpeichern nicht möglich." , "Speichern nicht möglich" , MessageBoxButton . OK , MessageBoxImage . Information ) ;
2016-06-27 01:45:38 +02:00
lValid = false ;
}
2022-11-25 15:22:38 +01:00
else if ( MessageBox . Show ( $"An dem gewählten Datum '{vm.StartDate.ToShortDateString()} {vm.StartDate.ToShortTimeString()}' existiert bereits ein Eintrag ({result.Message} bei " + BS . Shared . Translation . Translator . Translate ( "Klient/in" ) + " " + result . CustomerName + ").\nMöchten Sie trotzdem speichern?" , "Speichern" , MessageBoxButton . YesNo , MessageBoxImage . Question ) = = MessageBoxResult . No )
2016-06-27 01:45:38 +02:00
{
lValid = false ;
exitLoop = true ;
}
break ;
case ServiceRecordValidationResult . EmployeeOverlapping :
if ( ! BeWoApp . LoggedOnUser . HasRight ( UserRightType . ServiceRecord_AllowCreateOverlappingFLSForEmployee ) )
{
2021-07-05 18:05:43 +02:00
MessageBox . Show ( $"An dem gewählten Datum '{vm.StartDate.ToShortDateString()} {vm.StartDate.ToShortTimeString()}' existiert bereits ein Eintrag von {result.EmployeeName}\n({result.Message}).\nSpeichern nicht möglich." , "Speichern nicht möglich" , MessageBoxButton . OK , MessageBoxImage . Information ) ;
2016-06-27 01:45:38 +02:00
lValid = false ;
}
2021-07-05 18:05:43 +02:00
else if ( MessageBox . Show ( $"An dem gewählten Datum '{vm.StartDate.ToShortDateString()} {vm.StartDate.ToShortTimeString()}' existiert bereits ein Eintrag von {result.EmployeeName}\n({result.Message}).\n\nMöchten Sie trotzdem speichern?" , "Speichern" , MessageBoxButton . YesNo , MessageBoxImage . Question ) = = MessageBoxResult . No )
2016-06-27 01:45:38 +02:00
{
lValid = false ;
exitLoop = true ;
}
break ;
case ServiceRecordValidationResult . ApprovedFLSOverspending :
2021-07-05 18:05:43 +02:00
var klient = "diesen Hilfeplan" ;
if ( ! string . IsNullOrEmpty ( result . CustomerName ) )
2017-04-03 13:07:06 +02:00
{
2022-11-25 15:22:38 +01:00
klient = BS . Shared . Translation . Translator . Translate ( "Klient/in" ) + " " + result . CustomerName ;
2017-04-03 13:07:06 +02:00
}
2021-07-05 18:05:43 +02:00
2023-08-08 10:34:13 +02:00
var msg = string . Format ( "Die für {2} genehmigten FLS ({0:N}) werden mit diesem Eintrag ({1:N}) überschritten." , result . ApprovedHours , result . HoursNew , klient ) ;
2017-04-03 13:07:06 +02:00
2016-06-27 01:45:38 +02:00
if ( ! BeWoApp . LoggedOnUser . HasRight ( UserRightType . ServiceRecord_AllowCreateMoreFLSThanApproved ) )
{
2023-08-08 10:34:13 +02:00
MessageBox . Show ( msg + "\nSpeichern nicht möglich." , "Speichern nicht möglich" , MessageBoxButton . OK , MessageBoxImage . Information ) ;
2016-06-27 01:45:38 +02:00
lValid = false ;
}
2023-08-08 10:34:13 +02:00
else if ( MessageBox . Show ( msg + "\nMöchten Sie trotzdem speichern?" , "Speichern" , MessageBoxButton . YesNo , MessageBoxImage . Question ) = = MessageBoxResult . No )
2016-06-27 01:45:38 +02:00
{
lValid = false ;
exitLoop = true ;
}
break ;
case ServiceRecordValidationResult . SettlementInvoiceAlreadyExisting :
2021-07-05 18:05:43 +02:00
var klient2 = "diesen Hilfeplan" ;
if ( ! string . IsNullOrEmpty ( result . CustomerName ) )
2017-04-03 13:07:06 +02:00
{
2022-11-25 15:22:38 +01:00
klient2 = BS . Shared . Translation . Translator . Translate ( "Klient/in" ) + " " + result . CustomerName ;
2017-04-03 13:07:06 +02:00
}
2016-06-27 01:45:38 +02:00
if ( ! BeWoApp . LoggedOnUser . HasRight ( UserRightType . BookServiceRecordAfterSettlementInvoice ) )
{
2021-07-05 18:05:43 +02:00
MessageBox . Show ( $"Sie können den Eintrag nicht bearbeiten, da bereits eine Spitzabrechnung für {klient2} erstellt wurde." , "Speichern nicht möglich" , MessageBoxButton . OK , MessageBoxImage . Warning ) ;
2016-06-27 01:45:38 +02:00
lValid = false ;
}
2021-07-05 18:05:43 +02:00
else if ( MessageBox . Show ( $"Es existiert bereits eine Spitzabrechnung für {klient2}. Um diesen Eintrag zu berücksichtigen, muss eventuell eine neue Spitzabrechnung erstellt werden.\nMöchten Sie trotzdem speichern?" , "Speichern" , MessageBoxButton . YesNo , MessageBoxImage . Warning ) . Equals ( MessageBoxResult . No ) )
2016-06-27 01:45:38 +02:00
{
lValid = false ;
exitLoop = true ;
}
break ;
case ServiceRecordValidationResult . Custom :
2017-02-22 17:59:08 +01:00
if ( result . Allow )
{
if ( MessageBox . Show ( result . Message , "Speichern" , MessageBoxButton . YesNo , MessageBoxImage . Warning ) . Equals ( MessageBoxResult . No ) )
{
lValid = false ;
exitLoop = true ;
}
}
else
{
MessageBox . Show ( result . Message , "Speichern nicht möglich" , MessageBoxButton . OK , MessageBoxImage . Error ) ;
lValid = false ;
exitLoop = true ;
}
2016-06-27 01:45:38 +02:00
break ;
2021-07-05 18:05:43 +02:00
case ServiceRecordValidationResult . SignatureExists :
if ( MessageBox . Show ( result . Message , "Speichern" , MessageBoxButton . YesNo , MessageBoxImage . Warning ) . Equals ( MessageBoxResult . No ) )
{
lValid = false ;
exitLoop = true ;
}
break ;
2016-06-27 01:45:38 +02:00
}
2021-07-05 18:05:43 +02:00
if ( exitLoop )
{
break ;
}
2016-06-27 01:45:38 +02:00
}
}
2021-07-05 18:05:43 +02:00
2016-06-27 01:45:38 +02:00
return lValid ;
}
2017-02-22 17:59:08 +01:00
public static bool ValidateServiceRecordDeletion ( ServiceRecordVM vm )
{
var lValid = true ;
var dc = vm . CommitToDataContract ( ) ;
var emp = BeWoApp . LoggedOnUser . Employee ;
var r = new List < ServiceRecordValidationResultDC > ( ) ;
2017-03-07 08:46:32 +01:00
ServiceFacade . DoOperationsServiceSync ( o = > r = o . ValidateServiceRecordDeletion ( dc , emp . EmployeeOid ) ) ;
2017-02-22 17:59:08 +01:00
if ( r . Count > 0 )
{
var exitLoop = false ;
foreach ( var result in r )
{
switch ( result . ResultType )
{
case ServiceRecordValidationResult . Custom :
if ( result . Allow )
{
if ( MessageBox . Show ( result . Message , "Löschen" , MessageBoxButton . YesNo , MessageBoxImage . Warning ) . Equals ( MessageBoxResult . No ) )
{
lValid = false ;
exitLoop = true ;
}
}
else
{
MessageBox . Show ( result . Message , "Löschen nicht möglich" , MessageBoxButton . OK , MessageBoxImage . Error ) ;
lValid = false ;
exitLoop = true ;
}
break ;
}
if ( exitLoop ) break ;
}
}
2017-03-07 08:46:32 +01:00
else
{
var msg = vm . GroupOid ! = null
2022-11-25 15:22:38 +01:00
? "ACHTUNG, wenn Sie fortfahren, löschen Sie die gesamte Gruppenbuchung.\nWenn Sie nur einzelne " + BS . Shared . Translation . Translator . Translate ( "Klienten" ) + " aus der Gruppe entfernen möchten,\neditieren Sie die Gruppe und entfernen den Klienten aus der Liste aller Hilfepläne.\nSind Sie sicher, dass Sie den gesamten Gruppeneintrag löschen möchten?"
2017-03-07 08:46:32 +01:00
: "Sind Sie sicher, dass Sie den gewählten Eintrag löschen möchten?" ;
if ( MessageBox . Show ( msg , "Eintrag löschen" , MessageBoxButton . YesNo , MessageBoxImage . Warning ) ! =
MessageBoxResult . Yes )
{
lValid = false ;
}
}
2017-02-22 17:59:08 +01:00
return lValid ;
}
2017-08-29 14:16:33 +02:00
/// <summary>
/// Erzeugt einen Report mit Hilfe des ReportServices und zeigt ihn in einem BeWoWindow
/// </summary>
/// <param name="title">Titel des Fensters</param>
/// <param name="variablen">Dictionary mit Variablen für das ReportObject</param>
/// <param name="reportType">Der Typ des Reports (z.B. KalenderMonatsformatReport)</param>
public static void ShowReport ( string title , Dictionary < string , object > variablen , ReportEnum reportType )
2016-06-27 01:45:38 +02:00
{
switch ( reportType )
{
case ReportEnum . KalenderMonatsReportEnum :
var appointmentIds = ( List < long > ) variablen [ "appointmentOidListe" ] ;
var selectedDays = ( List < DateTime > ) variablen [ "datesList" ] ;
var employeeOid = Convert . ToInt64 ( variablen [ "employeeOid" ] ) ;
var serienTermine = ( List < SchedulerAppointmentDC > ) variablen [ "serienTermine" ] ;
var mehrtaegigeTermine = ( List < SchedulerAppointmentDC > ) variablen [ "mehrtaegigeTermine" ] ;
2022-10-11 16:48:36 +02:00
var nullableAbsenceTimeOids = ( List < long? > ) variablen [ "absenceTimeOids" ] ? ? new List < long? > ( ) ;
2016-06-27 01:45:38 +02:00
2022-10-11 16:48:36 +02:00
var absenceTimeOids = new List < long > ( ) ;
foreach ( var absenceTimeOid in nullableAbsenceTimeOids )
{
if ( absenceTimeOid . HasValue )
{
absenceTimeOids . AddIfNotIn ( absenceTimeOid . Value ) ;
}
}
ServiceFacade . DoReportServiceAsync ( strom = > strom . CreateKalenderReportWithAbsenceTimes ( appointmentIds , employeeOid , serienTermine , selectedDays , mehrtaegigeTermine , absenceTimeOids ) , ms = > BeWoApp . MainControl . Dispatch ( ( ) = > ShowReportWindow ( ms , title ) ) ) ;
2017-08-28 16:41:19 +02:00
2016-06-27 01:45:38 +02:00
break ;
case ReportEnum . KassenbuchReportEnum :
var zeitraum = ( DateTime ) variablen [ "zeitraum" ] ;
var objectOid = Convert . ToInt64 ( variablen [ "objectoid" ] ) ;
var objectTid = ( TableID ) Enum . Parse ( typeof ( TableID ) , variablen [ "objecttid" ] . ToString ( ) ) ;
2016-10-06 14:45:14 +02:00
var endzeitraum = ( DateTime ) variablen [ "endzeitraum" ] ;
2016-06-27 01:45:38 +02:00
var kasse = ( BargeldkassenDC ) variablen [ "bargeldkasse" ] ;
2016-10-06 14:45:14 +02:00
2017-08-28 16:41:19 +02:00
ServiceFacade . DoReportServiceAsync ( strom = > strom . CreateKassenbuchReportImZeitraum ( zeitraum , endzeitraum , kasse , objectOid , objectTid ) , ms = > BeWoApp . MainControl . Dispatch ( ( ) = > ShowReportWindow ( ms , title ) ) ) ;
2017-08-29 14:16:33 +02:00
2016-06-27 01:45:38 +02:00
break ;
case ReportEnum . ZahlungsbelegEnum :
var transaktion = ( BargeldtransaktionDC ) variablen [ "transaktion" ] ;
var objectOid2 = Convert . ToInt64 ( variablen [ "objectoid" ] ) ;
var objectTid2 = ( TableID ) Enum . Parse ( typeof ( TableID ) , variablen [ "objecttid" ] . ToString ( ) ) ;
2017-08-28 16:41:19 +02:00
ServiceFacade . DoReportServiceAsync ( strom = > strom . CreateKassenbelegReport ( transaktion , objectOid2 , objectTid2 ) , ms = > BeWoApp . MainControl . Dispatch ( ( ) = > ShowReportWindow ( ms , title ) ) ) ;
2016-06-27 01:45:38 +02:00
break ;
}
}
2017-08-29 14:16:33 +02:00
public static void ShowReportWindow ( MemoryStream ms , string title , DocumentPreviewControl documentPreviewControl = null )
2016-06-27 01:45:38 +02:00
{
2024-04-11 09:19:36 +02:00
var report = new XtraReport ( ) ;
2017-08-28 16:41:19 +02:00
2016-06-27 01:45:38 +02:00
try
{
report . PrintingSystem . LoadDocument ( ms ) ;
}
2017-08-29 14:16:33 +02:00
catch ( Exception )
2016-06-27 01:45:38 +02:00
{
2017-08-28 16:41:19 +02:00
var msg = Encoding . ASCII . GetString ( ms . ToArray ( ) ) ;
2016-06-27 01:45:38 +02:00
2017-08-28 16:41:19 +02:00
MessageBox . Show ( "Beim Öffnen der Druckvorschau ist leider ein Fehler aufgetreten!\n\n" + msg , "Fehler" , MessageBoxButton . OK , MessageBoxImage . Exclamation ) ;
2016-06-27 01:45:38 +02:00
}
2017-08-28 16:41:19 +02:00
2016-06-27 01:45:38 +02:00
ms . Close ( ) ;
ms . Dispose ( ) ;
2017-12-07 11:14:50 +01:00
//report.DefaultPrinterSettingsUsing.UseLandscape = BeWoApp.AppSettings.PrinterSettingsUseLandscape;
//report.DefaultPrinterSettingsUsing.UseMargins = BeWoApp.AppSettings.PrinterSettingsUseMargins;
//report.DefaultPrinterSettingsUsing.UsePaperKind = BeWoApp.AppSettings.PrinterSettingsUsePaperKind;
2016-06-27 01:45:38 +02:00
2017-08-29 14:16:33 +02:00
BeWoWindow window = null ;
2017-08-28 16:41:19 +02:00
2017-08-29 14:16:33 +02:00
if ( documentPreviewControl = = null )
{
2017-12-11 14:31:59 +01:00
//ReportPrintTool tool = new ReportPrintTool(report);
//tool.ShowRibbonPreviewDialog(UserLookAndFeel.Default);
documentPreviewControl = new DocumentPreviewControl { CommandBarStyle = CommandBarStyle . Bars } ;
2017-08-29 14:16:33 +02:00
documentPreviewControl . Loaded + = CustomizeReportPreviewToolBar ;
2017-12-07 11:14:50 +01:00
documentPreviewControl . SnapsToDevicePixels = true ;
2017-08-29 14:16:33 +02:00
window = new BeWoWindow { GroupBoxContent = documentPreviewControl , Owner = BeWoApp . CurrentBeWo . MainWindow } ;
2017-08-28 16:41:19 +02:00
2019-08-19 11:59:38 +02:00
ThemeManager . SetTheme ( window , Theme . Office2010Black ) ;
}
ThemeManager . SetTheme ( documentPreviewControl , Theme . Office2010Black ) ;
2016-06-27 01:45:38 +02:00
2019-08-19 11:59:38 +02:00
documentPreviewControl . DocumentSource = report ;
2016-06-27 01:45:38 +02:00
2017-08-29 14:16:33 +02:00
if ( window ! = null )
{
window . rootGroupBox . Header = string . IsNullOrEmpty ( title ) ? "Druckvorschau" : title ;
window . Title = "Druckvorschau" ;
window . Show ( ) ;
}
2016-06-27 01:45:38 +02:00
2017-08-29 14:16:33 +02:00
documentPreviewControl . Visibility = Visibility . Visible ;
2016-06-27 01:45:38 +02:00
BeWoApp . MainControl . EndWaiting ( ) ;
}
2025-01-20 15:54:17 +01:00
public static void ShowPdfWindow ( byte [ ] bytes )
= > ShowPdfWindow ( new MemoryStream ( bytes ) ) ;
public static void ShowPdfWindow ( MemoryStream ms )
{
var control = new PdfViewer ( ) ;
control . PdfData = ms ;
var window = BeWoWindowBuilder . GetBeWoWindow ( "eRechnung" , control ) ;
window . Show ( ) ;
}
2016-12-22 09:43:35 +01:00
2017-02-01 13:53:59 +01:00
public static PasswortSecurityStrength CheckPasswordSecurity ( string paswd )
2016-12-22 09:43:35 +01:00
{
2017-11-13 09:59:16 +01:00
PasswortSicherheit pwS = new PasswortSicherheit ( ) ;
2016-12-22 09:43:35 +01:00
2017-11-13 09:59:16 +01:00
return pwS . PasswortSecurityStaerke ( paswd ) ;
2016-12-22 09:43:35 +01:00
}
2017-03-28 11:01:28 +02:00
public static void ShowImageForm ( ImageSource source )
{
try
{
2017-08-29 14:16:33 +02:00
using ( var form = new Form ( ) )
2017-03-28 11:01:28 +02:00
{
2017-08-29 14:16:33 +02:00
var imgg = new Image { Source = source } ;
2017-03-28 11:01:28 +02:00
2017-08-29 14:16:33 +02:00
var encoder = new BmpBitmapEncoder ( ) ;
2017-03-28 11:01:28 +02:00
2017-08-29 14:16:33 +02:00
using ( var ms = new MemoryStream ( ) )
2017-03-28 11:01:28 +02:00
{
encoder . Frames . Add ( BitmapFrame . Create ( ( BitmapSource ) imgg . Source ) ) ;
encoder . Save ( ms ) ;
2017-11-17 22:24:00 +01:00
2017-08-29 14:16:33 +02:00
var img = System . Drawing . Image . FromStream ( ms ) ;
2017-03-28 11:01:28 +02:00
2017-08-29 14:16:33 +02:00
using ( var imgbit = new Bitmap ( img ) )
2017-03-28 11:01:28 +02:00
{
form . StartPosition = FormStartPosition . CenterScreen ;
2017-12-17 17:29:07 +01:00
form . ClientSize = imgbit . Size ;
2017-03-28 11:01:28 +02:00
form . FormBorderStyle = FormBorderStyle . Sizable ;
2017-11-17 22:24:00 +01:00
form . ShowIcon = false ;
2017-08-29 14:16:33 +02:00
using ( var pb = new PictureBox ( ) )
2017-03-28 11:01:28 +02:00
{
pb . Dock = DockStyle . Fill ;
pb . Image = imgbit ;
pb . SizeMode = PictureBoxSizeMode . Zoom ;
form . Controls . Add ( pb ) ;
form . ShowDialog ( ) ;
2017-12-17 17:29:07 +01:00
2017-03-28 11:01:28 +02:00
}
}
}
}
}
catch ( Exception edf )
{
MessageBox . Show ( "Unbekannter Fehler: " + edf . Message + "\n" + edf . StackTrace , "Fehler" , MessageBoxButton . OK ) ;
}
}
2023-01-26 12:55:56 +01:00
public static void CreateZeiterfassung ( DateTime start , DateTime end , List < CompactCustomerDC > customer , List < CompactEmployeeDC > employees , string notice , Appointment appointment , Action < List < ServiceRecordDC > > schedulerCallback )
2017-03-28 11:01:28 +02:00
{
2020-08-04 12:45:46 +02:00
ChatDokumentationsView newView ;
2023-01-26 12:55:56 +01:00
if ( customer . Count = = 0 )
2017-03-28 11:01:28 +02:00
{
2020-08-04 12:45:46 +02:00
// Normale Buchung
2021-02-21 19:01:51 +01:00
newView = new ChatDokumentationsView ( notice , null , start , end , null , schedulerCallback , appointment ) ;
2017-03-28 11:01:28 +02:00
}
2023-01-26 12:55:56 +01:00
else if ( customer . Count = = 1 & & employees . Count < 2 )
2017-03-28 11:01:28 +02:00
{
var compactKlient = ServiceFacade . DoCustomerServiceSync ( s = > s . GetCompactCustomerDC ( customer [ 0 ] . CustomerOid ) ) ;
2020-08-04 12:45:46 +02:00
// Normale Buchung
2021-02-21 19:01:51 +01:00
newView = new ChatDokumentationsView ( notice , compactKlient , start , end , employees . Count = = 1 ? employees [ 0 ] : null , schedulerCallback , appointment ) ;
2017-03-28 11:01:28 +02:00
}
else
{
2023-01-26 12:55:56 +01:00
if ( employees . Count = = 0 )
2017-06-11 15:50:31 +02:00
{
employees . Add ( BeWoApp . CompactLoggedOnEmployee ) ;
}
2017-03-28 11:01:28 +02:00
2020-08-04 12:45:46 +02:00
// Gruppenbuchungen
newView = new ChatDokumentationsView ( notice , start , end , customer , employees , schedulerCallback , appointment ) ;
}
newView . ShowDialog ( ) ;
}
2017-03-28 11:01:28 +02:00
2024-06-05 14:45:33 +02:00
// Zeiterfassungseintrag aus dem neuen Kalendermodul erstellen
public static void CreateZeiterfassung ( DateTime start , DateTime end , List < CompactCustomerDC > customer , List < CompactEmployeeDC > employees , String notice , AppointmentItem appointment , Action schedulerCallback )
{
ChatDokumentationsView newView ;
if ( customer . Count = = 0 )
{
// Normale Buchung
newView = new ChatDokumentationsView ( notice , null , null , start , end , schedulerCallback , appointment ) ;
}
else if ( customer . Count = = 1 & & employees . Count < 2 )
{
var compactKlient = ServiceFacade . DoCustomerServiceSync ( s = > s . GetCompactCustomerDC ( customer [ 0 ] . CustomerOid ) ) ;
// Normale Buchung
newView = new ChatDokumentationsView ( notice , compactKlient , employees . Count = = 1 ? employees [ 0 ] : null , start , end , schedulerCallback , appointment ) ;
}
else
{
if ( employees . Count = = 0 )
{
employees . Add ( BeWoApp . CompactLoggedOnEmployee ) ;
}
// Gruppenbuchungen
newView = new ChatDokumentationsView ( appointment , notice , start , end , customer , employees , schedulerCallback ) ;
}
newView . ShowDialog ( ) ;
}
2020-08-04 12:45:46 +02:00
public static void CreateZeiterfassung ( DateTime start , DateTime end , List < CompactCustomerDC > customer , List < CompactEmployeeDC > employees , String notice )
{
ChatDokumentationsView newView ;
if ( customer . Count = = 0 )
{
// Normale Buchung
2021-02-21 19:01:51 +01:00
newView = new ChatDokumentationsView ( notice , null , start , end , null ) ;
2017-03-28 11:01:28 +02:00
}
2021-02-21 19:01:51 +01:00
else if ( customer . Count = = 1 & & employees . Count < 2 )
2020-08-04 12:45:46 +02:00
{
var compactKlient = ServiceFacade . DoCustomerServiceSync ( s = > s . GetCompactCustomerDC ( customer [ 0 ] . CustomerOid ) ) ;
// Normale Buchung
2021-02-21 19:01:51 +01:00
newView = new ChatDokumentationsView ( notice , compactKlient , start , end , employees . Count = = 1 ? employees [ 0 ] : null ) ;
2020-08-04 12:45:46 +02:00
}
else
{
if ( employees . Count = = 0 )
{
employees . Add ( BeWoApp . CompactLoggedOnEmployee ) ;
}
2017-03-28 11:01:28 +02:00
2020-08-04 12:45:46 +02:00
// Gruppenbuchungen
newView = new ChatDokumentationsView ( notice , start , end , customer , employees ) ;
2017-03-28 11:01:28 +02:00
}
2020-08-04 12:45:46 +02:00
newView . ShowDialog ( ) ;
2017-03-28 11:01:28 +02:00
}
2020-08-04 12:45:46 +02:00
2017-11-23 10:58:07 +01:00
public static void OwnChatSynchronisationVeranlassen ( )
2020-08-17 15:50:00 +02:00
{
2017-11-16 15:37:29 +01:00
if ( ! BeWoApp . Mandator . Apikey . IsNullOrEmpty ( ) )
{
try
{
2020-05-12 14:20:58 +02:00
var tenant = BeWoApp . Tenant ;
2017-11-16 15:37:29 +01:00
2020-05-12 14:20:58 +02:00
#if DEBUG
tenant = "5473568546" ;
#endif
BeWoApp . GetChatServerUrlAsync ( serverUrl = >
2017-11-23 10:58:07 +01:00
{
2020-05-12 14:20:58 +02:00
var client = new RestClient ( $"{serverUrl}/api/ownchat/sync/schedule/{BeWoApp.Mandator.Apikey}/{tenant}" ) ;
var request = new RestRequest ( ) ;
client . ExecuteAsync ( request , null ) ;
} ) ;
2017-11-16 15:37:29 +01:00
2020-05-12 14:20:58 +02:00
// var serverUrl = BeWoApp.GetChatServerURL();
2017-11-23 10:58:07 +01:00
2020-05-12 14:20:58 +02:00
// if (!string.IsNullOrEmpty(serverUrl))
// {
//#if DEBUG
// var endurl = serverUrl + "/api/ownchat/sync/schedule/" + BeWoApp.Mandator.Apikey + "/5473568546";
//#else
// var endurl = serverUrl + "/api/ownchat/sync/schedule/" + BeWoApp.Mandator.Apikey + "/" + BeWoApp.Tenant;
//#endif
// WebRequest request = WebRequest.Create(endurl);
2017-11-23 10:58:07 +01:00
2020-05-12 14:20:58 +02:00
// request.Credentials = CredentialCache.DefaultCredentials;
// var response = request.GetResponse();
2017-11-23 10:58:07 +01:00
2020-05-12 14:20:58 +02:00
// response.Close();
// response.Dispose();
2020-08-17 15:50:00 +02:00
2017-11-16 15:37:29 +01:00
}
2020-05-12 14:20:58 +02:00
catch ( Exception exception )
2017-11-16 15:37:29 +01:00
{
2020-08-17 15:50:00 +02:00
// MessageBox.Show("Die Verbindung konnte nicht aufgebaut werden.", "ownChat Fehler ", MessageBoxButton.OK);
2017-11-16 15:37:29 +01:00
}
}
}
2019-02-28 12:38:29 +01:00
public static bool HasRights ( IEnumerable < UserRightType > pUserRightTypes )
{
return BeWoApp . HasLoggedOnUserRight ( pUserRightTypes . ToArray ( ) ) ;
}
public static bool HasRight ( UserRightType pUserRightType )
{
return BeWoApp . LoggedOnUser . HasRight ( pUserRightType ) ;
}
2022-10-11 16:48:36 +02:00
public static bool CheckSchedulerRights ( Appointment pAppointment , bool pIsNew , SchedulerRightsCheckType pCheckType , List < long > teamMemberCustomerOids , bool ignoreViewEditCreateAllRights )
2019-02-28 12:38:29 +01:00
{
var storage = pAppointment . GetCustomFieldStorage ( ) ;
2022-10-11 16:48:36 +02:00
return Utils . CheckSchedulerRights ( storage . CustomerList , storage . ResourceList , storage . EmployeeList . ToList ( ) , storage . Originator , pIsNew , pCheckType , BeWoApp . LoggedOnUser , teamMemberCustomerOids , ignoreViewEditCreateAllRights ) ;
2021-02-21 19:01:51 +01:00
}
public static void EditServiceRecord ( ServiceRecordDC dc , DispatcherObject p )
{
var record = ServiceFacade . DoOperationsServiceSync ( s = > s . GetServiceRecordById ( dc . ServiceRecordOid . Value ) ) ;
//var allgoalsCopy = GoalService.CopyGoals(selectedRecord.AllGoals, false);
//var sr = new ServiceRecordVM(record, ViewModel.PrototypeVM.Category2Services,
//selectedRecord.AllGoalCategories, allgoalsCopy);
VMFactory . CreateServiceRecordVMAsync (
BeWoApp . LoggedOnUser . Employee . EmployeeOid ,
vmList = > p . Dispatch (
delegate
{
vmList . DispatcherObject = p ;
if ( record . Customer ! = null & & record . SupportConcept ! = null )
{
vmList . InitPrototypeVM ( record . Customer . CustomerOid , record . SupportConcept . SupportConceptOid , record . CostBearer2SupportConceptOid ) ;
}
//var allgoalsCopy = GoalService.CopyGoals(selectedRecord.AllGoals, false);
//var sr = new ServiceRecordVM(record, ViewModel.PrototypeVM.Category2Services,
// selectedRecord.AllGoalCategories, allgoalsCopy);
var vm = new ServiceRecordVM ( record , vmList . PrototypeVM . Category2Services , vmList . PrototypeVM . AllGoalCategories , vmList . PrototypeVM . AllGoals ) ;
EditServiceRecord ( vmList , vm ) ;
} ) ) ;
}
public static void EditServiceRecord ( ServiceRecordListVM listvm , ServiceRecordVM vm )
{
2021-07-05 18:05:43 +02:00
if ( vm = = null )
2021-02-21 19:01:51 +01:00
{
return ;
}
BeWoView serviceRecordEditView ;
if ( vm . GroupOid ! = null )
{
serviceRecordEditView = new ServiceRecordGroupEditView ( ) ;
}
else
{
serviceRecordEditView = new ServiceRecordEditView ( ) ;
}
double height = BeWoApp . MainControl . ActualHeight * 0.8 ;
double width = 710 ;
if ( BeWoApp . AppSettings . ShowRtfTextfield )
{
height = BeWoApp . MainControl . ActualHeight - 120 ;
width = 1000 ;
}
if ( BeWoApp . MainControl . ActualWidth < width )
{
width = BeWoApp . MainControl . ActualWidth ;
}
if ( height < 600 )
{
height = 600 ;
}
var beWoWindow = new BeWoWindow
{
Height = height ,
Width = width ,
WindowStartupLocation = WindowStartupLocation . CenterOwner ,
GroupBoxContent = serviceRecordEditView ,
Owner = BeWoApp . CurrentBeWo . MainWindow
} ;
beWoWindow . rootGroupBox . Style = null ;
beWoWindow . rootGroupBox . Visibility = Visibility . Visible ;
beWoWindow . rootGroupBox . Margin = new Thickness ( - 10 ) ;
beWoWindow . rootGroupBox . Padding = new Thickness ( 0 ) ;
if ( serviceRecordEditView . CommandBindings . Count = = 0 )
{
serviceRecordEditView . CommandBindings . Add (
new CommandBinding (
ApplicationCommands . Close ,
( s , e ) = >
{
var result = ServiceRecordDialogResult . ClosedWithoutSaving ;
if ( vm . EditAllowed )
{
if ( serviceRecordEditView is ServiceRecordEditView view )
{
result = view . CloseAndDoSaveCheck ( ) ;
}
else
{
result = ( ( ServiceRecordGroupEditView ) serviceRecordEditView ) . CloseAndDoSaveCheck ( ) ;
}
}
beWoWindow . Close ( ) ;
} ) ) ;
serviceRecordEditView . CommandBindings . Add (
new CommandBinding (
ApplicationCommands . Save ,
( s , e ) = >
{
if ( vm . EditAllowed )
{
bool save ;
if ( serviceRecordEditView is ServiceRecordEditView )
{
save = ( ( ServiceRecordEditView ) serviceRecordEditView ) . IsValid ( ) & &
( ( ServiceRecordEditView ) serviceRecordEditView ) . IsCustomerChangeAllowed ( ) ;
}
else
{
save = ( ( ServiceRecordGroupEditView ) serviceRecordEditView ) . IsValid ( ) & &
( ( ServiceRecordGroupEditView ) serviceRecordEditView )
. IsCustomerChangeAllowed ( ) ;
}
if ( ! save )
{
return ;
}
serviceRecordEditView . SaveData ( ) ;
}
beWoWindow . Close ( ) ;
} ) ) ;
}
if ( serviceRecordEditView is ServiceRecordEditView )
{
( ( ServiceRecordEditView ) serviceRecordEditView ) . InitView ( listvm , vm , vm . SupportConcept = = null ) ;
}
else
{
var group = ServiceFacade . DoOperationsServiceSync ( s = > s . GetServiceRecordGroup ( vm . GroupOid . Value ) ) ;
( ( ServiceRecordGroupEditView ) serviceRecordEditView ) . InitView ( listvm , vm , group ) ;
beWoWindow . Width + = 190 ;
}
beWoWindow . ShowDialog ( ) ;
}
2021-07-05 18:05:43 +02:00
public static bool CheckForExistingSignatures ( ServiceRecordDC serviceRecord )
{
var validationResult = ServiceFacade . DoOperationsServiceSync ( s = > s . CheckForExistingSignature ( serviceRecord ) ) ;
return validationResult ! = null & & MessageBox . Show ( validationResult . Message , "Speichern" , MessageBoxButton . YesNo , MessageBoxImage . Warning ) . Equals ( MessageBoxResult . Yes ) | | validationResult = = null ;
}
2016-06-27 01:45:38 +02:00
}
}