From bbc75f1dca38ebf2d8440efd30088befdddd36a3 Mon Sep 17 00:00:00 2001 From: Lyndon Date: Fri, 23 Feb 2018 14:42:53 +0100 Subject: [PATCH] Modale Fenster sind beim Update nicht mehr in einer Endlosschleife gefangen, wenn man z.B. zwei vom gleichen Mitarbeiter offen hat und speichert. Die Statistik in der mobilen Version ist jetzt gleich der der Windows-Version. --- BeWo/Core/BeWoUtils.cs | 2056 +++++++++-------- BeWo/View/Detail/CustomerView.xaml.cs | 46 +- BeWo/View/Detail/EmployeeView.xaml.cs | 30 +- BeWo/View/Detail/ModalViewWindow.xaml.cs | 3 + BeWo/View/Detail/ServiceRecordView2.xaml.cs | 12 +- BeWoPlanerMobil/BeWoPlanerMobil.csproj | 2 + BeWoPlanerMobil/Content/BeWoMobileStyle.css | 2 +- BeWoPlanerMobil/Content/statisticsStyle.css | 19 + BeWoPlanerMobil/Controllers/MainController.cs | 6 +- BeWoPlanerMobil/Scripts/mainView.js | 182 +- BeWoPlanerMobil/Scripts/statistics.js | 116 + BeWoPlanerMobil/Views/Main/Main.cshtml | 64 +- BeWoPlanerMobil/Views/Shared/_Layout.cshtml | 4 +- .../SupportConceptStatisticsDC.cs | 3 - 14 files changed, 1282 insertions(+), 1263 deletions(-) create mode 100644 BeWoPlanerMobil/Content/statisticsStyle.css create mode 100644 BeWoPlanerMobil/Scripts/statistics.js diff --git a/BeWo/Core/BeWoUtils.cs b/BeWo/Core/BeWoUtils.cs index ce940ad58..32d0c1625 100644 --- a/BeWo/Core/BeWoUtils.cs +++ b/BeWo/Core/BeWoUtils.cs @@ -57,6 +57,8 @@ namespace BeWo.Core { public static ModalViewWindow CurrentModalViewWindow { get; set; } + private static readonly List _ModalViewWindowsToUpdate = new List(); + public static Dictionary ParseQuery(string query) { try @@ -276,55 +278,58 @@ namespace BeWo.Core where V : BeWoView { var tType = typeof(T); - var View = new BeWoView(); + var view = new BeWoView(); if (tType == typeof(EmployeeVM)) { - View = new EmployeeView(viewModel as EmployeeVM) { ParentView = ownerView, MinWidth = 800, IsInWindow = true }; + view = new EmployeeView(viewModel as EmployeeVM) { ParentView = ownerView, MinWidth = 800, IsInWindow = true }; } else if (tType == typeof(WohnheimVM)) { - View = new WohnheimView(viewModel as WohnheimVM) { ParentView = ownerView, MinWidth = 800, IsInWindow = true }; + view = new WohnheimView(viewModel as WohnheimVM) { ParentView = ownerView, MinWidth = 800, IsInWindow = true }; } else if (tType == typeof (OrganisationVM)) { - View = new OrganisationView(viewModel as OrganisationVM) { ParentView = ownerView, MinWidth = 800, IsInWindow = true }; - ((OrganisationView) View).OrganisationSavedOrUpdated += organisationSavedOrUpdated; + view = new OrganisationView(viewModel as OrganisationVM) { ParentView = ownerView, MinWidth = 800, IsInWindow = true }; + ((OrganisationView) view).OrganisationSavedOrUpdated += organisationSavedOrUpdated; } else if (tType == typeof (PersonVM)) { - View = new PersonView(viewModel as PersonVM) {ParentView = ownerView, MinWidth = 800, IsInWindow = true}; - ((PersonView) View).PersonSavedOrUpdated += personSavedOrUpdated; + view = new PersonView(viewModel as PersonVM) {ParentView = ownerView, MinWidth = 800, IsInWindow = true}; + ((PersonView) view).PersonSavedOrUpdated += personSavedOrUpdated; } else if (tType == typeof (TeamVM)) { - View = new TeamView(viewModel as TeamVM) {ParentView = ownerView, MinWidth = 800, IsInWindow = true}; + view = new TeamView(viewModel as TeamVM) {ParentView = ownerView, MinWidth = 800, IsInWindow = true}; } else if(tType==typeof(CustomerVM)) { - View = new CustomerView(viewModel as CustomerVM) { ParentView = ownerView, MinWidth = 800, IsInWindow = true }; + view = new CustomerView(viewModel as CustomerVM) { ParentView = ownerView, MinWidth = 800, IsInWindow = true }; } else if(tType==typeof(SupportConceptVM)) { - View = new SupportConceptView(viewModel as SupportConceptVM) { ParentView = ownerView, MinWidth = 800, IsInWindow = true }; + view = new SupportConceptView(viewModel as SupportConceptVM) { ParentView = ownerView, MinWidth = 800, IsInWindow = true }; } else { return; } - View.ModalEditViewUpdateCallback = applyChanges; + view.ModalEditViewUpdateCallback = applyChanges; - CurrentModalViewWindow = new ModalViewWindow(View, ownerView, allowSaveIfParentDirty) {Title = viewModel.ToString()}; + CurrentModalViewWindow = new ModalViewWindow(view, ownerView, allowSaveIfParentDirty) + { + Title = viewModel.ToString() + }; BeWoApp.MainControl.OpenedModalViewWindows.Add(CurrentModalViewWindow); + _ModalViewWindowsToUpdate.Add(CurrentModalViewWindow); foreach (var window in BeWoApp.MainControl.OpenedModalViewWindows.Where(window => !BeWoApp.MainControl.OpenedModalViewWindows.Last().Equals(window))) { ShowModalBackground(window.RootGrid); } - //var dialogResult = CurrentModalViewWindow.Show(); } @@ -371,1032 +376,1089 @@ namespace BeWo.Core public static void UpdateAllViews(T updatedObject) where T : IFilterableDC { - var callingMethodName = new StackTrace().GetFrame(1).GetMethod().Name; - var activeView = BeWoApp.MainControl.ActiveView; UpdateView(activeView, updatedObject); - if (BeWoApp.MainControl.OpenedModalViewWindows.Count <= 0) + if(BeWoApp.MainControl.OpenedModalViewWindows.Count <= 0) { return; } - foreach(var view in BeWoApp.MainControl.OpenedModalViewWindows) + for(var i = _ModalViewWindowsToUpdate.Count - 1; i >= 0; i--) { - UpdateView(view.DetailView, updatedObject); + UpdateView(_ModalViewWindowsToUpdate.ElementAt(i).DetailView, updatedObject); + _ModalViewWindowsToUpdate.RemoveAt(i); } } - // TODO: manchmal in Endlosschleife gefangen, wenn in modalem Fenster geöffnet private static void UpdateView(BeWoView view, T updatedObject) where T : IFilterableDC { - if (view.GetType() == typeof (EmployeeView)) + if(view.GetType() == typeof(EmployeeView)) { - #region EmployeeView - if (typeof (T) == typeof (CompactCustomerDC)) - { - var updatedCustomer = new CompactCustomerDC(); - - ServiceFacade.DoCustomerServiceSync(s => updatedCustomer = s.GetCompactCustomerDC((updatedObject as CompactCustomerDC).CustomerOid)); - - foreach (var item in (view as EmployeeView).ViewModel.CustomerRelations.VMList.Where(item => item.Customer.Equals(updatedCustomer))) - { - item.Customer = updatedCustomer; - } - - var grid = (view as EmployeeView).rootGrid.FindResource("grid_CustomerRelation") as GridControl; - - foreach (var item in ((BindingList) grid.ItemsSource).Where(item => item.Customer.Equals(updatedCustomer))) - { - item.Customer = null; - item.Customer = updatedCustomer; - } - - grid.RefreshData(); - } - if (typeof (T) == typeof (CompactEmployeeDC)) - { - UpdateLoggedInEmployee((updatedObject as CompactEmployeeDC).EmployeeOid); - (view as EmployeeView).ReloadViewModel(); - } - - #endregion - } - else if (view.GetType() == typeof(WohnheimView)) - { - #region WohnheimView - if (typeof(T) == typeof(CompactCustomerDC)) - { - var updatedCustomer = new CompactCustomerDC(); - - ServiceFacade.DoCustomerServiceSync(s => updatedCustomer = s.GetCompactCustomerDC((updatedObject as CompactCustomerDC).CustomerOid)); - - var grid = (view as WohnheimView).grid_CustomerRelation; - - foreach (var item in ((BindingList)grid.ItemsSource).Where(item => item.Customer.Equals(updatedCustomer))) - { - item.Customer = null; - item.Customer = updatedCustomer; - } - - grid.RefreshData(); - } - - if (typeof(T) == typeof(CompactEmployeeDC)) - { - var updatedEmployee = new CompactEmployeeDC(); - - ServiceFacade.DoEmployeeServiceSync(s => updatedEmployee = s.LoadCompactEmployee((updatedObject as CompactEmployeeDC).EmployeeOid)); - - var employeeRelationsGrid = (view as WohnheimView).grid_EmployeeRelation; - - foreach (var item in ((BindingList)employeeRelationsGrid.ItemsSource).Where(item => item.Employee.EmployeeOid.Equals(updatedEmployee.EmployeeOid))) - { - item.Employee = null; - item.Employee = updatedEmployee; - } - - UpdateLoggedInEmployee((updatedObject as CompactEmployeeDC).EmployeeOid); - } - - #endregion + var employeeView = view as EmployeeView; + UpdateEmployeeView(employeeView, updatedObject); } - else if (view.GetType() == typeof(CustomerView)) + else if(view.GetType() == typeof(WohnheimView)) + { + var wohnheimView = view as WohnheimView; + UpdateWohnheimView(wohnheimView, updatedObject); + } + else if(view.GetType() == typeof(CustomerView)) { - #region CustomerView var customerView = view as CustomerView; - - if (typeof(T) == typeof(CompactEmployeeDC)) - { - var updatedEmployee = new CompactEmployeeDC(); - var grid = new GridControl(); - - if (!string.IsNullOrWhiteSpace(customerView.popupedit_employeeRelations.Text)) - { - ServiceFacade.DoEmployeeServiceSync(s => updatedEmployee = s.LoadCompactEmployee((updatedObject as CompactEmployeeDC).EmployeeOid)); - customerView.ViewModel.EmployeeRelations.NewVM.Employee = null; - customerView.ViewModel.EmployeeRelations.NewVM.Employee = updatedEmployee; - } - else - { - ServiceFacade.DoEmployeeServiceSync(s => updatedEmployee = s.LoadCompactEmployee((updatedObject as CompactEmployeeDC).EmployeeOid)); - } - - grid = (GridControl)customerView.root.Resources["datagrid_EmployeeRelation"]; - - foreach (var item in ((BindingList)grid.ItemsSource).Where(item => item.Employee.EmployeeOid.Equals(updatedEmployee.EmployeeOid))) - { - item.Employee = null; - item.Employee = updatedEmployee; - } - - grid.RefreshData(); - - UpdateSearchViewObjectList(customerView.employeesearchview, updatedEmployee); - UpdateLoggedInEmployee(updatedEmployee.EmployeeOid); - } - else if (typeof(T) == typeof(CompactPersonDC)) - { - var grid = new GridControl(); - var updatedPerson = new CompactPersonDC(); - - ServiceFacade.DoCustomerServiceSync(s => updatedPerson = s.LoadPersonCompact((updatedObject as CompactPersonDC).PersonOid)); - - if (!(string.IsNullOrWhiteSpace(customerView.popupedit_environmentPersonSearch.Text)) && (view as CustomerView).popupedit_environmentPersonSearch.Text.Equals((updatedObject as CompactPersonDC).ToString())) - { - customerView.ViewModel.EnvironmentPersons.NewVM.Person = null; - customerView.ViewModel.EnvironmentPersons.NewVM.Person = updatedPerson; - } - - grid = (GridControl) customerView.root.Resources["grid_PersonRelations"]; - - var vmList = customerView.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(); - - var dataContracts = new List(); - ServiceFacade.DoCustomerServiceSync(s => dataContracts = s.LoadCustomerPersonRelationsByOid(relPersonOids)); - - var test = new List(); - - dataContracts.DoForEach(dfe => test.Add(new CustomerPersonRelationVM(dfe))); - - var vmMap = vmList.Where(w => relVMs.Contains(w)).ToDictionary(vmList.IndexOf, v => v.DataContract.Customer2PersonOid.Value); - foreach (var item in vmMap) - { - vmList[item.Key] = test.First(f => f.DataContract.Customer2PersonOid.Value.Equals(item.Value)); - } - - grid.RefreshData(); - - UpdateSearchViewObjectList(customerView.personsearchview, updatedPerson); - } - else if (typeof(T) == typeof(CompactOrganisationDC)) - { - var organisationToUpdate = updatedObject as CompactOrganisationDC; - var updatedOrganisation = new CompactOrganisationDC(); - var organisationRelationGrid = new GridControl(); - var costBearerRelationGrid = new GridControl(); - - if ((updatedObject as CompactOrganisationDC) == null) - { - return; - } - - organisationRelationGrid = (GridControl) customerView.root.Resources["grid_OrganisationRelations"]; - costBearerRelationGrid = (GridControl) customerView.root.Resources["grid_costBearer"]; - - ServiceFacade.DoCustomerServiceSync(s => updatedOrganisation = s.LoadOrganisationCompact(organisationToUpdate.OrganisationOid)); - - if (!(string.IsNullOrWhiteSpace(customerView.popupedit_costBearer.Text)) && customerView.popupedit_costBearer.Text.Equals(organisationToUpdate.ToString())) - { - customerView.ViewModel.CostBearers.NewVM.CostBearer = null; - customerView.ViewModel.CostBearers.NewVM.CostBearer = updatedOrganisation; - customerView.popupedit_costBearer.Text = updatedOrganisation.ToString(); - } - - foreach (var item in (customerView.ViewModel.CostBearers.VMList).Where(item => item.CostBearer.Equals(updatedOrganisation))) - { - item.CostBearer = null; - item.CostBearer = updatedOrganisation; - } - - if (!(string.IsNullOrWhiteSpace(customerView.popupedit_environmentOrganisationSearch.Text)) && customerView.popupedit_environmentOrganisationSearch.Text.Equals(organisationToUpdate.ToString())) - { - customerView.ViewModel.EnvironmentOrganisations.NewVM.Organisation = null; - customerView.ViewModel.EnvironmentOrganisations.NewVM.Organisation = updatedOrganisation; - customerView.popupedit_environmentOrganisationSearch.Text = updatedOrganisation.ToString(); - } - - var vmList = customerView.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(); - var test = new List(); - - ServiceFacade.DoCustomerServiceSync(s => dataContracts = s.LoadCustomerOrganisationRelationsByOid(relOrganisationOids)); - - dataContracts.DoForEach(dfe => test.Add(new CustomerOrganisationRelationVM(dfe))); - - var vmMap = vmList.Where(w => relVMs.Contains(w)).ToDictionary(vmList.IndexOf, v => v.DataContract.Customer2OrganisationOid.Value); - - foreach (var item in vmMap) - { - vmList[item.Key] = test.First(f => f.DataContract.Customer2OrganisationOid.Value.Equals(item.Value)); - } - - organisationRelationGrid.RefreshData(); - costBearerRelationGrid.RefreshData(); - - UpdateSearchViewObjectList(customerView.costbearersearchview, updatedOrganisation); - UpdateSearchViewObjectList(customerView.organisationsearchview, updatedOrganisation); - } - else if (typeof(T) == typeof(CompactTeamDC)) - { - var teamToUpdate = updatedObject as CompactTeamDC; - var updatedTeam = new CompactTeamDC(); - var grid = (GridControl) customerView.root.Resources["datagrid_TeamRelation"]; - - ServiceFacade.DoEmployeeServiceSync(s => updatedTeam = s.LoadCompactTeam(teamToUpdate.TeamOid)); - - if (!(string.IsNullOrWhiteSpace(customerView.popupedit_teamRelations.Text)) && customerView.popupedit_teamRelations.Text.Equals(teamToUpdate.ToString())) - { - ServiceFacade.DoEmployeeServiceSync(s => updatedTeam = s.LoadCompactTeam(teamToUpdate.TeamOid)); - customerView.ViewModel.TeamRelations.NewVM.Team = null; - customerView.ViewModel.TeamRelations.NewVM.Team = updatedTeam; - } - - foreach (var item in ((BindingList) grid.ItemsSource).Where(item => item.Team.Equals(updatedTeam))) - { - item.Team = null; - item.Team = updatedTeam; - } - - grid.RefreshData(); - UpdateSearchViewObjectList(customerView.teamsearchview, updatedTeam); - } - else if (typeof (T) == typeof (CompactCustomerDC)) - { - customerView.ReloadViewModel(); - } - #endregion + UpdateCustomerView(customerView, updatedObject); } - else if (view.GetType() == typeof(OrganisationView)) + else if(view.GetType() == typeof(OrganisationView)) { - #region OrganisationView - if (typeof (T) == typeof (CompactPersonDC)) - { - var organisationView = view as OrganisationView; - var updatedPerson = new CompactPersonDC(); - var grid = (GridControl) organisationView.gridroot.Resources["datagrid_PersonRelation"]; - - ServiceFacade.DoCustomerServiceSync(s => updatedPerson = s.LoadPersonCompact((updatedObject as CompactPersonDC).PersonOid)); - - var vmList = organisationView.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(); - var test = new List(); - - ServiceFacade.DoOperationsServiceSync(s => dataContracts = s.LoadOrganisationPersonRelationsByOid(relPersonOids)); - - dataContracts.DoForEach(dfe => test.Add(new OrganisationPersonRelationVM(dfe))); - - var vmMap = vmList.Where(w => relVMs.Contains(w)).ToDictionary(vmList.IndexOf, v => v.DataContract.Organisation2PersonOid.Value); - foreach (var item in vmMap) - { - vmList[item.Key] = test.First(f => f.DataContract.Organisation2PersonOid.Value.Equals(item.Value)); - } - - grid.RefreshData(); - } - else if (typeof (T) == typeof (CompactOrganisationDC)) - { - (view as OrganisationView).ReloadViewModel(); - } - #endregion + var organisationView = view as OrganisationView; + UpdateOrganisationView(organisationView, updatedObject); } - else if (view.GetType() == typeof(BookingView)) + else if(view.GetType() == typeof(BookingView)) { - #region BookingView - - if (typeof (T) != typeof (CompactEmployeeDC)) - return; - var bookingView = view as BookingView; - var updatedEmployee = new CompactEmployeeDC(); - - ServiceFacade.DoEmployeeServiceSync(s => updatedEmployee = s.LoadCompactEmployee((updatedObject as CompactEmployeeDC).EmployeeOid)); - - var sourceNew = bookingView.combobox_newEmployee.ItemsSource as ObservableCollection; - var sourceEdit = bookingView.combobox_editEmployee.ItemsSource as ObservableCollection; - - var selectedNewIndex = bookingView.combobox_newEmployee.SelectedIndex; - var selectedEditIndex = bookingView.combobox_editEmployee.SelectedIndex; - - foreach (var item in bookingView.ViewModel.VMList.Where(item => item.Employee.EmployeeOid.Equals(updatedEmployee.EmployeeOid))) - { - item.Employee = new CompactEmployeeDC(); - item.Employee = updatedEmployee; - } - - for (var i = 0; i < sourceNew.Count; i++) - { - if (!sourceNew[i].EmployeeOid.Equals(updatedEmployee.EmployeeOid)) continue; - sourceNew[i] = new CompactEmployeeDC(); - sourceNew[i] = updatedEmployee; - } - - for (var i = 0; i < sourceNew.Count; i++) - { - if (!sourceEdit[i].EmployeeOid.Equals(updatedEmployee.EmployeeOid)) continue; - sourceEdit[i] = new CompactEmployeeDC(); - sourceEdit[i] = updatedEmployee; - } - - bookingView.combobox_newEmployee.ItemsSource = sourceNew; - bookingView.combobox_editEmployee.ItemsSource = sourceEdit; - - bookingView.combobox_newEmployee.SelectedIndex = selectedNewIndex; - bookingView.combobox_editEmployee.SelectedIndex = selectedEditIndex; - - UpdateLoggedInEmployee(updatedEmployee.EmployeeOid); - #endregion + UpdateBookingView(bookingView, updatedObject); } - else if (view.GetType() == typeof(FinanceView)) + else if(view.GetType() == typeof(FinanceView)) { - #region FinanceView - var v = (FinanceView) view; - var settlementInvoiceView = v.tabitem_settlementinvoice.Content as SettlementInvoiceView; - var equityInvoiceView = v.tabitem_equityinvoice.Content as EquityInvoiceView; - var generalInvoiceView = v.tabitem_otherinvoice.Content as GeneralInvoiceView; - var serviceInvoiceView = v.tabitem_collectiveinvoice.Content as ServiceInvoiceView; - var accountingTransactionBookingView = v.tabitem_financeBooking.Content as AccountingTransactionBookingView; - - if(typeof (T) == typeof(CompactCustomerDC)) - { - var updatedCustomer = new CompactCustomerDC(); - ServiceFacade.DoCustomerServiceSync(s => updatedCustomer = s.GetCompactCustomerDC((updatedObject as CompactCustomerDC).CustomerOid)); - - 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; - } - - foreach (var item in accountingTransactionBookingView.FlatSupportConceptItems.Where(item => item.SupportConceptTreeNodeDC != null).Where(item => item.SupportConceptTreeNodeDC.Customer.Equals(updatedCustomer))) - { - item.SupportConceptTreeNodeDC.Customer = new CompactCustomerDC(); - item.SupportConceptTreeNodeDC.Customer = updatedCustomer; - } - - UpdateSingleSupportConceptSelectionControl(accountingTransactionBookingView.supportConceptSelectionControl, updatedCustomer); - } - if(settlementInvoiceView != null) - { - if(settlementInvoiceView.SelectedSupportConcept != null) - { - if(settlementInvoiceView.SelectedSupportConcept.Customer.Equals((updatedObject as CompactCustomerDC))) - { - settlementInvoiceView.SelectedSupportConcept.Customer = new CompactCustomerDC(); - settlementInvoiceView.SelectedSupportConcept.Customer = updatedCustomer; - - settlementInvoiceView.popupedit_CostBeaerer.Text = $"{settlementInvoiceView.SelectedSupportConcept.Customer.LastName}, {settlementInvoiceView.SelectedSupportConcept.Customer.FirstName} {settlementInvoiceView.SelectedSupportConcept.Customer.DateOfBirthString}"; - } - - UpdateSearchViewObjectList(settlementInvoiceView.supportconceptsearchview, settlementInvoiceView.SelectedSupportConcept); - } - else - { - UpdateSearchViewObjectList(settlementInvoiceView.supportconceptsearchview, new CompactSupportConceptDC{Customer = updatedCustomer}); - } - } - if (equityInvoiceView != null) - { - if (equityInvoiceView.SelectedSupportConcept != null) - { - equityInvoiceView.SelectedSupportConcept.Customer = new CompactCustomerDC(); - equityInvoiceView.SelectedSupportConcept.Customer = updatedCustomer; - - equityInvoiceView.popupedit_CostBeaerer.Text = $"{equityInvoiceView.SelectedSupportConcept.Customer.LastName}, {equityInvoiceView.SelectedSupportConcept.Customer.FirstName} {equityInvoiceView.SelectedSupportConcept.Customer.DateOfBirthString}"; - - UpdateSearchViewObjectList(equityInvoiceView.supportconceptsearchview, equityInvoiceView.SelectedSupportConcept); - } - else - { - UpdateSearchViewObjectList(equityInvoiceView.supportconceptsearchview, new CompactSupportConceptDC { Customer = updatedCustomer }); - } - } - if (serviceInvoiceView != null) - { - if (serviceInvoiceView.ViewModel.SelectedSupportConcept != null) - { - if (serviceInvoiceView.ViewModel.SelectedSupportConcept.Customer.Equals((updatedObject as CompactCustomerDC))) - { - serviceInvoiceView.ViewModel.SelectedSupportConcept.Customer = new CompactCustomerDC(); - serviceInvoiceView.ViewModel.SelectedSupportConcept.Customer = updatedCustomer; - - serviceInvoiceView.popupedit_supportConcept.Text = $"{serviceInvoiceView.ViewModel.SelectedSupportConcept.Customer.LastName}, {serviceInvoiceView.ViewModel.SelectedSupportConcept.Customer.FirstName} {serviceInvoiceView.ViewModel.SelectedSupportConcept.Customer.DateOfBirthString}"; - - UpdateSearchViewObjectList(serviceInvoiceView.supportConcept_search, serviceInvoiceView.ViewModel.SelectedSupportConcept); - } - } - else - { - UpdateSearchViewObjectList(serviceInvoiceView.supportConcept_search, new CompactSupportConceptDC { Customer = updatedCustomer }); - } - } - } - else if (typeof(T) == typeof(CompactSupportConceptDC)) - { - var updatedSupportConcept = new CompactSupportConceptDC(); - ServiceFacade.DoCustomerServiceSync(s => updatedSupportConcept = s.LoadCompactSupportConceptDC((updatedObject as CompactSupportConceptDC).SupportConceptOid, BeWoApp.LoggedOnEmployee.EmployeeOid)); - - if (equityInvoiceView?.SelectedSupportConcept != null) - { - equityInvoiceView.ReloadViewModel(); - equityInvoiceView.popupedit_CostBeaerer.Text = $"{updatedSupportConcept.Customer.LastName}, {updatedSupportConcept.Customer.FirstName} {updatedSupportConcept.Customer.DateOfBirthString}"; - - UpdateSearchViewObjectList(equityInvoiceView.supportconceptsearchview, equityInvoiceView.SelectedSupportConcept); - } - - if (settlementInvoiceView?.SelectedSupportConcept != null) - { - settlementInvoiceView.ReloadViewModel(); - settlementInvoiceView.popupedit_CostBeaerer.Text = $"{updatedSupportConcept.Customer.LastName}, {updatedSupportConcept.Customer.FirstName} {updatedSupportConcept.Customer.DateOfBirthString}"; - - UpdateSearchViewObjectList(settlementInvoiceView.supportconceptsearchview, settlementInvoiceView.SelectedSupportConcept); - } - - if (serviceInvoiceView != null && serviceInvoiceView.ViewModel.SelectedSupportConcept != null) - { - if (serviceInvoiceView.ViewModel.SelectedSupportConcept.Equals(updatedSupportConcept)) - serviceInvoiceView.ViewModel.SelectedSupportConcept = updatedSupportConcept; - - UpdateSearchViewObjectList(serviceInvoiceView.supportConcept_search, updatedSupportConcept); - } - } - else if (typeof(T) == typeof(CompactOrganisationDC)) - { - var updatedOrganisation = new CompactOrganisationDC(); - ServiceFacade.DoCustomerServiceSync(s => updatedOrganisation = s.LoadOrganisationCompact((updatedObject as CompactOrganisationDC).OrganisationOid)); - - if (generalInvoiceView != null) - { - if (generalInvoiceView.SelectedOrganisation != null) - { - if (generalInvoiceView.SelectedOrganisation.Equals(updatedOrganisation)) - { - generalInvoiceView.SelectedOrganisation = null; - generalInvoiceView.SelectedOrganisation = updatedOrganisation; - } - - generalInvoiceView.popupedit_Recipient.Text = updatedOrganisation.ToString(); - } - - UpdateSearchViewObjectList(generalInvoiceView.recipientsearchview, updatedOrganisation); - } - - if (serviceInvoiceView != null) - { - if (serviceInvoiceView.ViewModel.SelectedCostBearer != null) - { - if (serviceInvoiceView.ViewModel.SelectedCostBearer.Equals(updatedOrganisation)) - { - serviceInvoiceView.ViewModel.SelectedCostBearer = updatedOrganisation; - } - } - - UpdateSearchViewObjectList(serviceInvoiceView.organisationSearchView, updatedOrganisation); - } - } - #endregion + var financeView = view as FinanceView; + UpdateFinanceView(financeView, updatedObject); } - else if (view.GetType() == typeof(SupportConceptView)) + else if(view.GetType() == typeof(SupportConceptView)) { - #region SupportConceptView - var SupportConceptView = view as SupportConceptView; - - if (typeof (T) == typeof (CompactEmployeeDC)) - { - var updatedEmployee = new CompactEmployeeDC(); - - ServiceFacade.DoEmployeeServiceSync(s => updatedEmployee = s.LoadCompactEmployee((updatedObject as CompactEmployeeDC).EmployeeOid)); - - for (var i = 0; i < SupportConceptView.ViewModel.Tasks.NewVM.Employees.Count; i++) - { - if (!SupportConceptView.ViewModel.Tasks.NewVM.Employees[i].EmployeeOid.Equals(updatedEmployee.EmployeeOid)) - { - continue; - } - - SupportConceptView.ViewModel.Tasks.NewVM.Employees[i] = null; - SupportConceptView.ViewModel.Tasks.NewVM.Employees[i] = updatedEmployee; - } - - foreach(var currentSC in SupportConceptView.ViewModel.CostBearerRelations.VMList) - { - foreach(var currentApprovalPeriodList in currentSC.ApprovalPeriodList.VMList) - { - if (currentApprovalPeriodList.SupportConceptApprovalEmployeeRelations.VMList.Any(a => a.Employee.EmployeeOid.Equals(updatedEmployee.EmployeeOid))) - { - // Nur einmal in der Liste - var employeeContainingRel = currentApprovalPeriodList.SupportConceptApprovalEmployeeRelations.VMList.FirstOrDefault(f => f.Employee.EmployeeOid.Equals(updatedEmployee.EmployeeOid)); - if (employeeContainingRel != null) - { - employeeContainingRel.Employee = null; - employeeContainingRel.Employee = updatedEmployee; - } - } - } - } - - if (SupportConceptView.ViewModel.CostBearerRelations.VMList.Any(a => a.ApprovalPeriodList.VMList.Any(a2 => a2.SupportConceptApprovalEmployeeRelations.VMList.Any(a3 => a3.Employee.EmployeeOid.Equals(updatedEmployee.EmployeeOid))))) - { - var emp = SupportConceptView.SelectedApprovalPeriodVM.SupportConceptApprovalEmployeeRelations.VMList.FirstOrDefault(f => f.Employee.EmployeeOid.Equals(updatedEmployee.EmployeeOid)); - if (emp != null) - { - emp.Employee = null; - emp.Employee = updatedEmployee; - emp.EmployeeString = updatedEmployee.ToString(); - } - } - - if (SupportConceptView.SelectedApprovalPeriodVM.SupportConceptApprovalEmployeeRelations.NewVM.Employee.EmployeeOid.Equals(updatedEmployee.EmployeeOid)) - { - SupportConceptView.SelectedApprovalPeriodVM.SupportConceptApprovalEmployeeRelations.NewVM.Employee = null; - SupportConceptView.SelectedApprovalPeriodVM.SupportConceptApprovalEmployeeRelations.NewVM.Employee = updatedEmployee; - SupportConceptView.SelectedApprovalPeriodVM.SupportConceptApprovalEmployeeRelations.NewVM.EmployeeString = updatedEmployee.ToString(); - } - - if (SupportConceptView.ViewModel.Originator.EmployeeOid.Equals(updatedEmployee.EmployeeOid)) - { - SupportConceptView.ViewModel.Originator = null; - SupportConceptView.ViewModel.Originator = updatedEmployee; - SupportConceptView.popupedit_employee.Text = updatedEmployee.ToString(); - } - - if (BeWoApp.LoggedOnUser.Employee.EmployeeOid.Equals(updatedEmployee.EmployeeOid)) - { - BeWoApp.LoggedOnUser.Employee = updatedEmployee; - } - - SupportConceptView.popupedit_employee.Text = updatedEmployee.ToString(); - UpdateLoggedInEmployee(updatedEmployee.EmployeeOid); - UpdateSearchViewObjectList(SupportConceptView.employeesearchview, updatedEmployee); - - foreach (var item in SupportConceptView.ViewModel.Tasks.VMList) - { - for (var i = 0; i < item.Employees.Count; i++) - { - var prevDirty = item.IsDirty; - if (!item.Employees[i].EmployeeOid.Equals(updatedEmployee.EmployeeOid)) - { - continue; - } - - item.Employees[i] = updatedEmployee; - - if (!prevDirty && item.IsDirty) - { - item.SetDirty(false); - } - } - } - - SupportConceptView.grid_tasks.RefreshData(); - } - else if (typeof(T) == typeof(CompactPersonDC)) - { - var updatedPerson = new CompactPersonDC(); - - ServiceFacade.DoCustomerServiceSync(s => updatedPerson = s.LoadPersonCompact((updatedObject as CompactPersonDC).PersonOid)); - - ((SupportConceptCostBearerRelVM)SupportConceptView.tabcontrol_costbearers.SelectedItem).CostBearerContactPerson = null; - ((SupportConceptCostBearerRelVM)SupportConceptView.tabcontrol_costbearers.SelectedItem).CostBearerContactPerson = updatedPerson; - } - else if (typeof (T) == typeof (CompactCustomerDC)) - { - var updatedCustomer = SupportConceptView.ViewModel.Customer; - - ServiceFacade.DoCustomerServiceSync(s => updatedCustomer = s.GetCompactCustomerDC(SupportConceptView.ViewModel.Customer.CustomerOid)); - - SupportConceptView.ViewModel.Customer = new CompactCustomerDC(); - SupportConceptView.ViewModel.Customer = updatedCustomer; - - SupportConceptView.popupedit_customer.Text = updatedCustomer.ToString(); - - UpdateSearchViewObjectList(SupportConceptView.customersearchview, updatedCustomer); - } - #endregion + var supportConceptView = view as SupportConceptView; + UpdateSupportConceptView(supportConceptView, updatedObject); } - else if (view.GetType() == typeof(ServiceRecordView2)) + else if(view.GetType() == typeof(ServiceRecordView2)) { - #region ServiceRecordView2 - var ServiceRecordView2 = view as ServiceRecordView2; - - if (typeof (T) == typeof (CompactCustomerDC)) - { - var updatedCustomer = new CompactCustomerDC(); - - ServiceFacade.DoCustomerServiceSync(s => updatedCustomer = s.GetCompactCustomerDC((updatedObject as CompactCustomerDC).CustomerOid)); - - foreach (var item in ServiceRecordView2.ViewModel.VMList.Where(item => item.Customer.Equals(updatedCustomer))) - { - item.Customer = new CompactCustomerDC(); - item.Customer = updatedCustomer; - } - - ServiceRecordView2.multiSupportConceptControl.UpdateSupportConcepts(updatedCustomer); - ServiceRecordView2.multiSupportConceptControl.UpdateListBox(); - - UpdateSingleSupportConceptSelectionControl(ServiceRecordView2.supportConceptSelectionControl, updatedCustomer); - } - else if (typeof (T) == typeof (CompactEmployeeDC)) - { - var updatedEmployee = new CompactEmployeeDC(); - ServiceFacade.DoEmployeeServiceSync(s => updatedEmployee = s.LoadCompactEmployee((updatedObject as CompactEmployeeDC).EmployeeOid)); - - UpdateSearchViewObjectList(ServiceRecordView2.employeeSearchView, updatedEmployee); - ServiceRecordView2.popupedit_employee.Text = updatedEmployee.ToString(); - - UpdateLoggedInEmployee((updatedObject as CompactEmployeeDC).EmployeeOid); - - for (var i = 0; i < ServiceRecordView2.multiEmployeeControl.SelectedEmployees.Count; i++) - { - if (!ServiceRecordView2.multiEmployeeControl.SelectedEmployees[i].EmployeeOid.Equals(updatedEmployee.EmployeeOid)) - { - continue; - } - - ServiceRecordView2.multiEmployeeControl.SelectedEmployees[i] = new CompactEmployeeDC(); - ServiceRecordView2.multiEmployeeControl.SelectedEmployees[i] = updatedEmployee; - } - - ServiceRecordView2.multiEmployeeControl.UpdateListBox(); - UpdateSearchViewObjectList(ServiceRecordView2.multiEmployeeControl.employeesearchview, updatedEmployee); - - //CB EINKOMMENTIEREN - //if (ServiceRecordView2.ViewModel.BedarfsMedViewModel.NewVM.Employee != null && ServiceRecordView2.ViewModel.BedarfsMedViewModel.NewVM.Employee.EmployeeOid.Equals(updatedEmployee.EmployeeOid)) - //{ - // ServiceRecordView2.ViewModel.BedarfsMedViewModel.NewVM.Employee = updatedEmployee; - // ServiceRecordView2.popupedit_employee_bedarfsmed.Text = updatedEmployee.ToString(); - // UpdateSearchViewObjectList(ServiceRecordView2.MedRecordEmployeeSearchView, updatedEmployee); - //} - - //// TODO: Bedarfsmedikationen - //UpdateSearchViewObjectList(ServiceRecordView2.MedRecordEmployeeSearchView, updatedEmployee); - - - // foreach (var item in ((BindingList)ServiceRecordView2.MedRecordGridControl.ItemsSource).Where(item => item.Employee.EmployeeOid.Equals(updatedEmployee.EmployeeOid))) - //{ - // item.Employee = null; - // item.Employee = updatedEmployee; - //} - - //ServiceRecordView2.MedRecordGridControl.RefreshData(); - - if (ServiceRecordView2.ViewModel.CustomerNodes.Count <= 0 || ServiceRecordView2.ViewModel.ServiceRecordsForSelectedCustomer == null) - { - return; - } - - foreach (var item in ServiceRecordView2.ViewModel.ServiceRecordsForSelectedCustomer.Where(item => item.Employee.EmployeeOid.Equals(updatedEmployee.EmployeeOid))) - { - item.Employee = null; - item.Employee = updatedEmployee; - } - - ServiceRecordView2.ViewModel.RefreshServiceRecordsForSelectedTreeNode(); - } - else if (typeof(T) == typeof(CompactOrganisationDC)) - { - var updatedOrganisation = new CompactOrganisationDC(); - - ServiceFacade.DoCustomerServiceSync(s => updatedOrganisation = s.LoadOrganisationCompact((updatedObject as CompactOrganisationDC).OrganisationOid)); - - foreach (var item in ServiceRecordView2.ViewModel.VMList.Where(item => item.CostBearer.Equals(updatedOrganisation))) - { - item.CostBearer = new CompactOrganisationDC(); - item.CostBearer = updatedOrganisation; - } - } - #endregion + var serviceRecordView = (ServiceRecordView2) view; + UpdateServiceRecordView(serviceRecordView, updatedObject); } - else if (view.GetType() == typeof(TeamView)) + else if(view.GetType() == typeof(TeamView)) { - #region TeamView - if (typeof (T) == typeof (CompactEmployeeDC)) - { - var TeamView = view as TeamView; - var updatedEmployee = new CompactEmployeeDC(); - - ServiceFacade.DoEmployeeServiceSync(s => updatedEmployee = s.LoadCompactEmployee((updatedObject as CompactEmployeeDC).EmployeeOid)); - - if (TeamView.ViewModel.Leader.Equals(updatedObject as CompactEmployeeDC)) - { - TeamView.ViewModel.Leader = null; - TeamView.ViewModel.Leader = updatedEmployee; - } - - if (TeamView.ViewModel.Member.Contains(updatedEmployee)) - { - var newMember = new ObservableSortCollection(); - foreach (var item in TeamView.ViewModel.Member) - newMember.Add(item.EmployeeOid.Equals(updatedEmployee.EmployeeOid) ? updatedEmployee : item); - - TeamView.ViewModel.Member = null; - TeamView.ViewModel.Member = newMember; - } - - if (TeamView.ViewModel.Leader.EmployeeOid.Equals(updatedEmployee.EmployeeOid)) - { - TeamView.ViewModel.Leader = null; - TeamView.ViewModel.Leader = updatedEmployee; - } - - UpdateSearchViewObjectList(TeamView.employeesearchview, updatedEmployee); - UpdateSearchViewObjectList(TeamView.leaderSearchView, updatedEmployee); - UpdateLoggedInEmployee(updatedEmployee.EmployeeOid); - } - else if (typeof (T) == typeof (CompactTeamDC)) - { - (view as TeamView).ReloadViewModel(); - } - #endregion + var teamView = (TeamView) view; + UpdateTeamView(teamView, updatedObject); } - else if (view.GetType() == typeof(UserView)) + else if(view.GetType() == typeof(UserView)) { - #region UserView - var updatedEmployee = new CompactEmployeeDC(); - var UserView = view as UserView; - - ServiceFacade.DoEmployeeServiceSync(s => updatedEmployee = s.LoadCompactEmployee(UserView.ViewModel.Employee.EmployeeOid)); - - UserView.ViewModel.Employee = null; - UserView.ViewModel.Employee = updatedEmployee; - - var myView = new BeWoView(); - BeWoApp.MainControl.Views.TryGetValue(UIContext.User, out myView); - - var naviView = myView as UserNavigationView; - if (naviView != null) - { - if (naviView.ObjectList.Contains(updatedEmployee)) - { - var copiedList = naviView.ObjectList as List; - copiedList[copiedList.IndexOf(updatedEmployee)] = new CompactEmployeeDC(); - copiedList[copiedList.IndexOf(updatedEmployee)] = updatedEmployee; - naviView.ObjectList = copiedList; - } - - if (naviView.RecentList.Contains(updatedEmployee)) - { - var copiedList = naviView.RecentList as List; - copiedList[copiedList.IndexOf(updatedEmployee)] = new CompactEmployeeDC(); - copiedList[copiedList.IndexOf(updatedEmployee)] = updatedEmployee; - naviView.RecentList = copiedList; - } - } - UpdateSearchViewObjectList(UserView.employeeSearchView, updatedEmployee); - UpdateLoggedInEmployee(updatedEmployee.EmployeeOid); - #endregion + var userView = (UserView)view; + UpdateUserView(userView); } - else if (view.GetType() == typeof(ReportView)) + else if(view.GetType() == typeof(ReportView)) { - #region ReportView - var v = view as ReportView; - - var aus = new BeWoView(); v.OpenViews.TryGetValue(v.tabitem_maReport, out aus); - var fls = new BeWoView(); v.OpenViews.TryGetValue(v.tabitem_flsReport, out fls); - var serv = new BeWoView(); v.OpenViews.TryGetValue(v.tabitem_serviceOverview, out serv); - - if (typeof (T) == typeof (CompactCustomerDC)) - { - var updatedCustomer = new CompactCustomerDC(); - ServiceFacade.DoCustomerServiceSync(s => updatedCustomer = s.GetCompactCustomerDC((updatedObject as CompactCustomerDC).CustomerOid)); - - var fls2 = fls as FLSReportView; - if (fls2 != null) - { - if (fls2._SelectedCustomer != null) - { - if (fls2._LastSelectedCustomer != null) - if (fls2._LastSelectedCustomer.Equals(updatedCustomer)) - fls2._LastSelectedCustomer = updatedCustomer; - - fls2._SelectedCustomer = updatedCustomer; - fls2.popupedit_client.Text = updatedCustomer.ToString(); - } - - UpdateSearchViewObjectList(fls2.customerSearchView, updatedCustomer); - } - - var serv2 = serv as ServicesReportView; - if (serv != null) - { - if (serv2.Customer != null) - { - serv2.Customer = updatedCustomer; - serv2.popupedit_customer.Text = updatedCustomer.ToString(); - } - - UpdateSearchViewObjectList(serv2.customersearchview, updatedCustomer); - } - } - if (typeof (T) == typeof (CompactEmployeeDC)) - { - var updatedEmployee = new CompactEmployeeDC(); - ServiceFacade.DoEmployeeServiceSync(s => updatedEmployee = s.LoadCompactEmployee((updatedObject as CompactEmployeeDC).EmployeeOid)); - - var aus2 = aus as AuslastungReportView; - if (aus2 != null) - { - if (aus2._SelectedEmployee != null) - { - if (aus2._SelectedEmployee != null) - if (aus2._SelectedEmployee.EmployeeOid.Equals(updatedEmployee.EmployeeOid)) - aus2._SelectedEmployee = updatedEmployee; - - if (aus2._LastSelectedEmployee != null) - if (aus2._LastSelectedEmployee.EmployeeOid.Equals(updatedEmployee.EmployeeOid)) - aus2._LastSelectedEmployee = updatedEmployee; - - if (aus2._SelectedEmployee != null) - aus2.popupedit_employee.Text = updatedEmployee.ToString(); - } - - UpdateSearchViewObjectList(aus2.employeesearchview, updatedEmployee); - } - - var fls2 = fls as FLSReportView; - if (fls2 != null) - { - if (fls2._SelectedEmployee != null) - { - if (fls2._LastSelectedEmployee != null) - if (fls2._LastSelectedEmployee.EmployeeOid.Equals(updatedEmployee.EmployeeOid)) - fls2._LastSelectedEmployee = updatedEmployee; - - fls2._SelectedEmployee = updatedEmployee; - fls2.popupedit_employee.Text = updatedEmployee.ToString(); - } - - UpdateSearchViewObjectList(fls2.employeeSearchView, updatedEmployee); - } - - var serv2 = serv as ServicesReportView; - if (serv2 != null) - { - if (serv2.Employee != null) - { - serv2.Employee = updatedEmployee; - serv2.popupedit_employee.Text = updatedEmployee.ToString(); - } - - UpdateSearchViewObjectList(serv2.employeesearchview, updatedEmployee); - } - - UpdateLoggedInEmployee(updatedEmployee.EmployeeOid); - } - if (typeof (T) == typeof (CompactOrganisationDC)) - { - var updatedOrganisation = new CompactOrganisationDC(); - ServiceFacade.DoCustomerServiceSync(s => updatedOrganisation = s.LoadOrganisationCompact((updatedObject as CompactOrganisationDC).OrganisationOid)); - - var serv2 = serv as ServicesReportView; - if (serv2 != null) - { - if (serv2.Organisation != null) - { - serv2.Organisation = updatedOrganisation; - serv2.popupedit_costbearer.Text = updatedOrganisation.ToString(); - } - - UpdateSearchViewObjectList(serv2.organisationsearchview, updatedOrganisation); - } - } - if (typeof (T) == typeof (CompactTeamDC)) - { - var updatedTeam = new CompactTeamDC(); - ServiceFacade.DoEmployeeServiceSync(s => updatedTeam = s.LoadCompactTeam((updatedObject as CompactTeamDC).TeamOid)); - - var aus2 = aus as AuslastungReportView; - if (aus2 != null) - { - if (aus2._SelectedTeam != null) - { - if (aus2._SelectedTeam.Equals(updatedTeam)) - aus2._SelectedTeam = updatedTeam; - - if (aus2._LastSelectedTeam != null) - if (aus2._LastSelectedTeam.Equals(updatedTeam)) - aus2._LastSelectedTeam = updatedTeam; - - aus2.popupedit_team.Text = updatedTeam.ToString(); - } - - UpdateSearchViewObjectList(aus2.teamsearchview, updatedTeam); - } - } - #endregion + var reportView = (ReportView) view; + UpdateReportView(reportView, updatedObject); } - else if (view.GetType() == typeof(PersonView)) + else if(view.GetType() == typeof(PersonView)) { - #region PersonView - - if (typeof(T) == typeof(CompactOrganisationDC)) - { - var PersonView = view as PersonView; - var grid_Relations = (GridControl) PersonView.rootGrid.Resources["grid_Relations"]; - var updatedOrganisation = new CompactOrganisationDC(); - - ServiceFacade.DoCustomerServiceSync(s => - updatedOrganisation = - s.LoadOrganisationCompact((updatedObject as CompactOrganisationDC).OrganisationOid)); - - if (!(string.IsNullOrWhiteSpace(PersonView.popupedit_organisation.Text)) && - PersonView.popupedit_organisation.Text.Equals((updatedObject as CompactOrganisationDC).Name)) - PersonView.popupedit_organisation.Text = updatedOrganisation.ToString(); - - foreach (var item in PersonView.ViewModel.OrganisationRelations.VMList.Where(item => - item.Organisation.OrganisationOid == updatedOrganisation.OrganisationOid)) - item.OrganisationString = updatedOrganisation.Name; - - grid_Relations.RefreshData(); - - if (PersonView.ViewModel.OrganisationRelations.NewVM != null && - PersonView.ViewModel.OrganisationRelations.NewVM.Organisation != null) - if (PersonView.ViewModel.OrganisationRelations.NewVM.Organisation.OrganisationOid.Equals( - updatedOrganisation.OrganisationOid)) - PersonView.ViewModel.OrganisationRelations.NewVM.OrganisationString = - updatedOrganisation.Name; - - UpdateSearchViewObjectList((view as PersonView).organisationSearchView, updatedOrganisation); - } - else if (typeof(T) == typeof(CompactPersonDC)) - { - (view as PersonView).ReloadViewModel(); - } - else if (typeof(T) == typeof(CompactCustomerDC)) - { - var pv = view as PersonView; - pv.UpdateCustomerList(); - } - - #endregion + var personView = view as PersonView; + UpdatePersonView(personView, updatedObject); } - else if (view.GetType() == typeof(AdditionalServiceView)) + else if(view.GetType() == typeof(AdditionalServiceView)) { - #region AdditionalServiceView - var additionalServiceView = view as AdditionalServiceView; - - if (typeof(T) == typeof(CompactEmployeeDC)) - { - var updatedEmployee = new CompactEmployeeDC(); - ServiceFacade.DoEmployeeServiceSync( - s => updatedEmployee = s.LoadCompactEmployee((updatedObject as CompactEmployeeDC).EmployeeOid)); - - UpdateLoggedInEmployee((updatedObject as CompactEmployeeDC).EmployeeOid); - - for (var i = 0; i < additionalServiceView.MultiEmployeeControlAddServ.SelectedEmployees.Count; i++) - { - if ( - !additionalServiceView.MultiEmployeeControlAddServ.SelectedEmployees[i].EmployeeOid.Equals( - updatedEmployee.EmployeeOid)) - continue; - - additionalServiceView.MultiEmployeeControlAddServ.SelectedEmployees[i] = - new CompactEmployeeDC(); - additionalServiceView.MultiEmployeeControlAddServ.SelectedEmployees[i] = updatedEmployee; - } - - UpdateSearchViewObjectList(additionalServiceView.MultiEmployeeControlAddServ.employeesearchview, - updatedEmployee); - - } - else if (typeof(T) == typeof(CompactCustomerDC)) - { - var updatedCustomer = new CompactCustomerDC(); - - ServiceFacade.DoCustomerServiceSync( - s => updatedCustomer = - s.GetCompactCustomerDC((updatedObject as CompactCustomerDC).CustomerOid)); - - additionalServiceView.MultiAddServGroupOfPeopleSelectionControl.UpdateCustomers(updatedCustomer); - - foreach (var item in additionalServiceView.AdditionalServiceBookings.VMList) - { - var newCustomerList = - item.CustomerOidDict.ToDictionary( - element => - element.Key.Equals(updatedCustomer.CustomerOid) - ? updatedCustomer.CustomerOid - : element.Key, element => element.Value); - item.CustomerOidDict = newCustomerList; - } - - var containsUpdatedCustomer = false; - - foreach (var element in from item in additionalServiceView.AdditionalServiceBookings.VMList - from element in item.CustomerOidDict - where element.Key.Equals(updatedCustomer.CustomerOid) - select element) - containsUpdatedCustomer = true; - - if (!containsUpdatedCustomer) - return; - - additionalServiceView.UpdateTeilnahmeGrid(); - } - - #endregion + UpdateAdditionalServiceView(additionalServiceView, updatedObject); } } + private static void UpdateEmployeeView(EmployeeView pEmployeeView, T pUpdatedObject) where T : IFilterableDC + { + if(typeof(T) == typeof(CompactCustomerDC)) + { + var updatedCustomer = new CompactCustomerDC(); + + ServiceFacade.DoCustomerServiceSync(s => updatedCustomer = s.GetCompactCustomerDC((pUpdatedObject as CompactCustomerDC).CustomerOid)); + + foreach(var item in pEmployeeView.ViewModel.CustomerRelations.VMList.Where(item => item.Customer.Equals(updatedCustomer))) + { + item.Customer = updatedCustomer; + } + + var grid = pEmployeeView.rootGrid.FindResource("grid_CustomerRelation") as GridControl; + + foreach(var item in ((BindingList)grid.ItemsSource).Where(item => item.Customer.Equals(updatedCustomer))) + { + item.Customer = null; + item.Customer = updatedCustomer; + } + + grid.RefreshData(); + } + + if(typeof(T) == typeof(CompactEmployeeDC)) + { + UpdateLoggedInEmployee((pUpdatedObject as CompactEmployeeDC).EmployeeOid); + pEmployeeView.ReloadViewModel(); + } + } + + private static void UpdateWohnheimView(WohnheimView pWohnheimView, T pUpdateObject) where T : IFilterableDC + { + if(typeof(T) == typeof(CompactCustomerDC)) + { + var updatedCustomer = new CompactCustomerDC(); + + ServiceFacade.DoCustomerServiceSync(s => updatedCustomer = s.GetCompactCustomerDC((pUpdateObject as CompactCustomerDC).CustomerOid)); + + var grid = pWohnheimView.grid_CustomerRelation; + + foreach(var item in ((BindingList)grid.ItemsSource).Where(item => item.Customer.Equals(updatedCustomer))) + { + item.Customer = null; + item.Customer = updatedCustomer; + } + + grid.RefreshData(); + } + + if(typeof(T) == typeof(CompactEmployeeDC)) + { + var updatedEmployee = new CompactEmployeeDC(); + + ServiceFacade.DoEmployeeServiceSync(s => updatedEmployee = s.LoadCompactEmployee((pUpdateObject as CompactEmployeeDC).EmployeeOid)); + + var employeeRelationsGrid = pWohnheimView.grid_EmployeeRelation; + + foreach(var item in ((BindingList)employeeRelationsGrid.ItemsSource).Where(item => item.Employee.EmployeeOid.Equals(updatedEmployee.EmployeeOid))) + { + item.Employee = null; + item.Employee = updatedEmployee; + } + + UpdateLoggedInEmployee((pUpdateObject as CompactEmployeeDC).EmployeeOid); + } + } + + private static void UpdateCustomerView(CustomerView pCustomerView, T pUpdateObject) where T : IFilterableDC + { + if(typeof(T) == typeof(CompactEmployeeDC)) + { + var updatedEmployee = new CompactEmployeeDC(); + + if(!string.IsNullOrWhiteSpace(pCustomerView.popupedit_employeeRelations.Text)) + { + 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)); + } + + var grid = (GridControl)pCustomerView.root.Resources["datagrid_EmployeeRelation"]; + + if(grid.ItemsSource != null) + { + foreach(var item in ((BindingList)grid.ItemsSource).Where(item => item.Employee.EmployeeOid.Equals(updatedEmployee.EmployeeOid))) + { + item.Employee = null; + item.Employee = updatedEmployee; + } + + grid.RefreshData(); + } + + UpdateSearchViewObjectList(pCustomerView.employeesearchview, updatedEmployee); + UpdateLoggedInEmployee(updatedEmployee.EmployeeOid); + } + else if(typeof(T) == typeof(CompactPersonDC)) + { + var updatedPerson = new CompactPersonDC(); + + ServiceFacade.DoCustomerServiceSync(s => updatedPerson = s.LoadPersonCompact((pUpdateObject as CompactPersonDC).PersonOid)); + + 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; + } + + var grid = (GridControl) pCustomerView.root.Resources["grid_PersonRelations"]; + + 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(); + + var dataContracts = new List(); + ServiceFacade.DoCustomerServiceSync(s => dataContracts = s.LoadCustomerPersonRelationsByOid(relPersonOids)); + + var test = new List(); + + dataContracts.DoForEach(dfe => test.Add(new CustomerPersonRelationVM(dfe))); + + var vmMap = vmList.Where(w => relVMs.Contains(w)).ToDictionary(vmList.IndexOf, v => v.DataContract.Customer2PersonOid.Value); + foreach(var item in vmMap) + { + vmList[item.Key] = test.First(f => f.DataContract.Customer2PersonOid.Value.Equals(item.Value)); + } + + grid.RefreshData(); + + 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(); + + if(!(pUpdateObject is CompactOrganisationDC)) + { + return; + } + + organisationRelationGrid = (GridControl) pCustomerView.root.Resources["grid_OrganisationRelations"]; + costBearerRelationGrid = (GridControl) pCustomerView.root.Resources["grid_costBearer"]; + + ServiceFacade.DoCustomerServiceSync(s => updatedOrganisation = s.LoadOrganisationCompact(organisationToUpdate.OrganisationOid)); + + 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(); + } + + foreach(var item in pCustomerView.ViewModel.CostBearers.VMList.Where(item => item.CostBearer.Equals(updatedOrganisation))) + { + item.CostBearer = null; + item.CostBearer = updatedOrganisation; + } + + 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(); + } + + 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(); + var test = new List(); + + ServiceFacade.DoCustomerServiceSync(s => dataContracts = s.LoadCustomerOrganisationRelationsByOid(relOrganisationOids)); + + dataContracts.DoForEach(dfe => test.Add(new CustomerOrganisationRelationVM(dfe))); + + var vmMap = vmList.Where(w => relVMs.Contains(w)).ToDictionary(vmList.IndexOf, v => v.DataContract.Customer2OrganisationOid.Value); + + foreach(var item in vmMap) + { + vmList[item.Key] = test.First(f => f.DataContract.Customer2OrganisationOid.Value.Equals(item.Value)); + } + + organisationRelationGrid.RefreshData(); + costBearerRelationGrid.RefreshData(); + + 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"]; + + ServiceFacade.DoEmployeeServiceSync(s => updatedTeam = s.LoadCompactTeam(teamToUpdate.TeamOid)); + + 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; + } + + foreach(var item in ((BindingList)grid.ItemsSource).Where(item => item.Team.Equals(updatedTeam))) + { + item.Team = null; + item.Team = updatedTeam; + } + + grid.RefreshData(); + UpdateSearchViewObjectList(pCustomerView.teamsearchview, updatedTeam); + } + else if(typeof(T) == typeof(CompactCustomerDC)) + { + pCustomerView.ReloadViewModel(); + } + } + + private static void UpdateOrganisationView(OrganisationView pOrganisationView, T pUpdateObject) where T : IFilterableDC + { + if(typeof(T) == typeof(CompactPersonDC)) + { + var updatedPerson = new CompactPersonDC(); + var grid = (GridControl) pOrganisationView.gridroot.Resources["datagrid_PersonRelation"]; + + ServiceFacade.DoCustomerServiceSync(s => updatedPerson = s.LoadPersonCompact((pUpdateObject as CompactPersonDC).PersonOid)); + + 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(); + var organisationPersonRelationVMs = new List(); + + ServiceFacade.DoOperationsServiceSync(s => dataContracts = s.LoadOrganisationPersonRelationsByOid(relPersonOids)); + + dataContracts.DoForEach(dfe => organisationPersonRelationVMs.Add(new OrganisationPersonRelationVM(dfe))); + + var vmMap = vmList.Where(w => relVMs.Contains(w)).ToDictionary(vmList.IndexOf, v => v.DataContract.Organisation2PersonOid.Value); + foreach(var item in vmMap) + { + vmList[item.Key] = organisationPersonRelationVMs.First(f => f.DataContract.Organisation2PersonOid.Value.Equals(item.Value)); + } + + grid.RefreshData(); + } + else if(typeof(T) == typeof(CompactOrganisationDC)) + { + pOrganisationView.ReloadViewModel(); + } + } + + private static void UpdateBookingView(BookingView pBookingView, T pUpdateObject) where T : IFilterableDC + { + if(typeof(T) != typeof(CompactEmployeeDC)) + { + return; + } + + var updatedEmployee = new CompactEmployeeDC(); + + ServiceFacade.DoEmployeeServiceSync(s => updatedEmployee = s.LoadCompactEmployee((pUpdateObject as CompactEmployeeDC).EmployeeOid)); + + var sourceNew = pBookingView.combobox_newEmployee.ItemsSource as ObservableCollection; + var sourceEdit = pBookingView.combobox_editEmployee.ItemsSource as ObservableCollection; + + var selectedNewIndex = pBookingView.combobox_newEmployee.SelectedIndex; + var selectedEditIndex = pBookingView.combobox_editEmployee.SelectedIndex; + + foreach(var item in pBookingView.ViewModel.VMList.Where(item => item.Employee.EmployeeOid.Equals(updatedEmployee.EmployeeOid))) + { + item.Employee = new CompactEmployeeDC(); + item.Employee = updatedEmployee; + } + + for(var i = 0; i < sourceNew.Count; i++) + { + if(!sourceNew[i].EmployeeOid.Equals(updatedEmployee.EmployeeOid)) + { + continue; + } + + sourceNew[i] = new CompactEmployeeDC(); + sourceNew[i] = updatedEmployee; + } + + for(var i = 0; i < sourceNew.Count; i++) + { + if(!sourceEdit[i].EmployeeOid.Equals(updatedEmployee.EmployeeOid)) + { + continue; + } + + sourceEdit[i] = new CompactEmployeeDC(); + sourceEdit[i] = updatedEmployee; + } + + pBookingView.combobox_newEmployee.ItemsSource = sourceNew; + pBookingView.combobox_editEmployee.ItemsSource = sourceEdit; + + pBookingView.combobox_newEmployee.SelectedIndex = selectedNewIndex; + pBookingView.combobox_editEmployee.SelectedIndex = selectedEditIndex; + + UpdateLoggedInEmployee(updatedEmployee.EmployeeOid); + } + + private static void UpdateFinanceView(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)); + + 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; + } + + foreach(var item in accountingTransactionBookingView.FlatSupportConceptItems.Where(item => item.SupportConceptTreeNodeDC != null).Where(item => item.SupportConceptTreeNodeDC.Customer.Equals(updatedCustomer))) + { + item.SupportConceptTreeNodeDC.Customer = new CompactCustomerDC(); + item.SupportConceptTreeNodeDC.Customer = updatedCustomer; + } + + UpdateSingleSupportConceptSelectionControl(accountingTransactionBookingView.supportConceptSelectionControl, updatedCustomer); + } + + if(settlementInvoiceView != null) + { + if(settlementInvoiceView.SelectedSupportConcept != null) + { + if(settlementInvoiceView.SelectedSupportConcept.Customer.Equals((pUpdateObject as CompactCustomerDC))) + { + settlementInvoiceView.SelectedSupportConcept.Customer = new CompactCustomerDC(); + settlementInvoiceView.SelectedSupportConcept.Customer = updatedCustomer; + + settlementInvoiceView.popupedit_CostBeaerer.Text = $"{settlementInvoiceView.SelectedSupportConcept.Customer.LastName}, {settlementInvoiceView.SelectedSupportConcept.Customer.FirstName} {settlementInvoiceView.SelectedSupportConcept.Customer.DateOfBirthString}"; + } + + UpdateSearchViewObjectList(settlementInvoiceView.supportconceptsearchview, settlementInvoiceView.SelectedSupportConcept); + } + else + { + UpdateSearchViewObjectList(settlementInvoiceView.supportconceptsearchview, new CompactSupportConceptDC { Customer = updatedCustomer }); + } + } + + if(equityInvoiceView != null) + { + if(equityInvoiceView.SelectedSupportConcept != null) + { + equityInvoiceView.SelectedSupportConcept.Customer = new CompactCustomerDC(); + equityInvoiceView.SelectedSupportConcept.Customer = updatedCustomer; + + equityInvoiceView.popupedit_CostBeaerer.Text = $"{equityInvoiceView.SelectedSupportConcept.Customer.LastName}, {equityInvoiceView.SelectedSupportConcept.Customer.FirstName} {equityInvoiceView.SelectedSupportConcept.Customer.DateOfBirthString}"; + + UpdateSearchViewObjectList(equityInvoiceView.supportconceptsearchview, equityInvoiceView.SelectedSupportConcept); + } + else + { + UpdateSearchViewObjectList(equityInvoiceView.supportconceptsearchview, new CompactSupportConceptDC { Customer = updatedCustomer }); + } + } + + if(serviceInvoiceView != null) + { + if(serviceInvoiceView.ViewModel.SelectedSupportConcept != null) + { + if(serviceInvoiceView.ViewModel.SelectedSupportConcept.Customer.Equals((pUpdateObject as CompactCustomerDC))) + { + serviceInvoiceView.ViewModel.SelectedSupportConcept.Customer = new CompactCustomerDC(); + serviceInvoiceView.ViewModel.SelectedSupportConcept.Customer = updatedCustomer; + + serviceInvoiceView.popupedit_supportConcept.Text = $"{serviceInvoiceView.ViewModel.SelectedSupportConcept.Customer.LastName}, {serviceInvoiceView.ViewModel.SelectedSupportConcept.Customer.FirstName} {serviceInvoiceView.ViewModel.SelectedSupportConcept.Customer.DateOfBirthString}"; + + UpdateSearchViewObjectList(serviceInvoiceView.supportConcept_search, serviceInvoiceView.ViewModel.SelectedSupportConcept); + } + } + else + { + UpdateSearchViewObjectList(serviceInvoiceView.supportConcept_search, new CompactSupportConceptDC { Customer = updatedCustomer }); + } + } + } + else if(typeof(T) == typeof(CompactSupportConceptDC)) + { + var updatedSupportConcept = new CompactSupportConceptDC(); + ServiceFacade.DoCustomerServiceSync(s => updatedSupportConcept = s.LoadCompactSupportConceptDC((pUpdateObject as CompactSupportConceptDC).SupportConceptOid, BeWoApp.LoggedOnEmployee.EmployeeOid)); + + if(equityInvoiceView?.SelectedSupportConcept != null) + { + equityInvoiceView.ReloadViewModel(); + equityInvoiceView.popupedit_CostBeaerer.Text = $"{updatedSupportConcept.Customer.LastName}, {updatedSupportConcept.Customer.FirstName} {updatedSupportConcept.Customer.DateOfBirthString}"; + + UpdateSearchViewObjectList(equityInvoiceView.supportconceptsearchview, equityInvoiceView.SelectedSupportConcept); + } + + if(settlementInvoiceView?.SelectedSupportConcept != null) + { + settlementInvoiceView.ReloadViewModel(); + settlementInvoiceView.popupedit_CostBeaerer.Text = $"{updatedSupportConcept.Customer.LastName}, {updatedSupportConcept.Customer.FirstName} {updatedSupportConcept.Customer.DateOfBirthString}"; + + UpdateSearchViewObjectList(settlementInvoiceView.supportconceptsearchview, settlementInvoiceView.SelectedSupportConcept); + } + + if(serviceInvoiceView?.ViewModel.SelectedSupportConcept != null) + { + if(serviceInvoiceView.ViewModel.SelectedSupportConcept.Equals(updatedSupportConcept)) + { + serviceInvoiceView.ViewModel.SelectedSupportConcept = updatedSupportConcept; + } + + 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) + { + if(generalInvoiceView.SelectedOrganisation.Equals(updatedOrganisation)) + { + generalInvoiceView.SelectedOrganisation = null; + generalInvoiceView.SelectedOrganisation = updatedOrganisation; + } + + generalInvoiceView.popupedit_Recipient.Text = updatedOrganisation.ToString(); + } + + UpdateSearchViewObjectList(generalInvoiceView.recipientsearchview, updatedOrganisation); + } + + if(serviceInvoiceView != null) + { + if(serviceInvoiceView.ViewModel.SelectedCostBearer != null) + { + if(serviceInvoiceView.ViewModel.SelectedCostBearer.Equals(updatedOrganisation)) + { + serviceInvoiceView.ViewModel.SelectedCostBearer = updatedOrganisation; + } + } + + UpdateSearchViewObjectList(serviceInvoiceView.organisationSearchView, updatedOrganisation); + } + } + } + + private static void UpdateSupportConceptView(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)); + + 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; + } + + foreach(var currentSC in pSupportConceptView.ViewModel.CostBearerRelations.VMList) + { + foreach(var currentApprovalPeriodList in currentSC.ApprovalPeriodList.VMList) + { + if(currentApprovalPeriodList.SupportConceptApprovalEmployeeRelations.VMList.Any(a => a.Employee.EmployeeOid.Equals(updatedEmployee.EmployeeOid))) + { + // Nur einmal in der Liste + var employeeContainingRel = currentApprovalPeriodList.SupportConceptApprovalEmployeeRelations.VMList.FirstOrDefault(f => f.Employee.EmployeeOid.Equals(updatedEmployee.EmployeeOid)); + if(employeeContainingRel != null) + { + employeeContainingRel.Employee = null; + employeeContainingRel.Employee = updatedEmployee; + } + } + } + } + + if(pSupportConceptView.ViewModel.CostBearerRelations.VMList.Any(a => a.ApprovalPeriodList.VMList.Any(a2 => a2.SupportConceptApprovalEmployeeRelations.VMList.Any(a3 => a3.Employee.EmployeeOid.Equals(updatedEmployee.EmployeeOid))))) + { + 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(); + } + } + + 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(); + } + + if(pSupportConceptView.ViewModel.Originator.EmployeeOid.Equals(updatedEmployee.EmployeeOid)) + { + pSupportConceptView.ViewModel.Originator = null; + pSupportConceptView.ViewModel.Originator = updatedEmployee; + pSupportConceptView.popupedit_employee.Text = updatedEmployee.ToString(); + } + + if(BeWoApp.LoggedOnUser.Employee.EmployeeOid.Equals(updatedEmployee.EmployeeOid)) + { + BeWoApp.LoggedOnUser.Employee = updatedEmployee; + } + + pSupportConceptView.popupedit_employee.Text = updatedEmployee.ToString(); + UpdateLoggedInEmployee(updatedEmployee.EmployeeOid); + UpdateSearchViewObjectList(pSupportConceptView.employeesearchview, updatedEmployee); + + foreach(var item in pSupportConceptView.ViewModel.Tasks.VMList) + { + for(var i = 0; i < item.Employees.Count; i++) + { + var prevDirty = item.IsDirty; + if(!item.Employees[i].EmployeeOid.Equals(updatedEmployee.EmployeeOid)) + { + continue; + } + + item.Employees[i] = updatedEmployee; + + if(!prevDirty && item.IsDirty) + { + item.SetDirty(false); + } + } + } + + pSupportConceptView.grid_tasks.RefreshData(); + } + else if(typeof(T) == typeof(CompactPersonDC)) + { + var updatedPerson = new CompactPersonDC(); + + ServiceFacade.DoCustomerServiceSync(s => updatedPerson = s.LoadPersonCompact((pUpdatedObject as CompactPersonDC).PersonOid)); + + ((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; + + ServiceFacade.DoCustomerServiceSync(s => updatedCustomer = s.GetCompactCustomerDC(pSupportConceptView.ViewModel.Customer.CustomerOid)); + + pSupportConceptView.ViewModel.Customer = new CompactCustomerDC(); + pSupportConceptView.ViewModel.Customer = updatedCustomer; + + pSupportConceptView.popupedit_customer.Text = updatedCustomer.ToString(); + + UpdateSearchViewObjectList(pSupportConceptView.customersearchview, updatedCustomer); + } + } + + private static void UpdateServiceRecordView(ServiceRecordView2 pServiceRecordView, T pUpdatedObject) where T : IFilterableDC + { + if(typeof(T) == typeof(CompactCustomerDC)) + { + var updatedCustomer = new CompactCustomerDC(); + + ServiceFacade.DoCustomerServiceSync(s => updatedCustomer = s.GetCompactCustomerDC((pUpdatedObject as CompactCustomerDC).CustomerOid)); + + foreach(var item in pServiceRecordView.ViewModel.VMList.Where(item => item.Customer.Equals(updatedCustomer))) + { + item.Customer = new CompactCustomerDC(); + item.Customer = updatedCustomer; + } + + pServiceRecordView.multiSupportConceptControl.UpdateSupportConcepts(updatedCustomer); + pServiceRecordView.multiSupportConceptControl.UpdateListBox(); + + UpdateSingleSupportConceptSelectionControl(pServiceRecordView.supportConceptSelectionControl, updatedCustomer); + } + else if(typeof(T) == typeof(CompactEmployeeDC)) + { + var updatedEmployee = new CompactEmployeeDC(); + ServiceFacade.DoEmployeeServiceSync(s => updatedEmployee = s.LoadCompactEmployee((pUpdatedObject as CompactEmployeeDC).EmployeeOid)); + + UpdateSearchViewObjectList(pServiceRecordView.employeeSearchView, updatedEmployee); + pServiceRecordView.popupedit_employee.Text = updatedEmployee.ToString(); + + UpdateLoggedInEmployee((pUpdatedObject as CompactEmployeeDC).EmployeeOid); + + for(var i = 0; i < pServiceRecordView.multiEmployeeControl.SelectedEmployees.Count; i++) + { + if(!pServiceRecordView.multiEmployeeControl.SelectedEmployees[i].EmployeeOid.Equals(updatedEmployee.EmployeeOid)) + { + continue; + } + + pServiceRecordView.multiEmployeeControl.SelectedEmployees[i] = new CompactEmployeeDC(); + pServiceRecordView.multiEmployeeControl.SelectedEmployees[i] = updatedEmployee; + } + + 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)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) + { + return; + } + + foreach(var item in pServiceRecordView.ViewModel.ServiceRecordsForSelectedCustomer.Where(item => item.Employee.EmployeeOid.Equals(updatedEmployee.EmployeeOid))) + { + item.Employee = null; + item.Employee = updatedEmployee; + } + + pServiceRecordView.ViewModel.RefreshServiceRecordsForSelectedTreeNode(); + } + else if(typeof(T) == typeof(CompactOrganisationDC)) + { + var updatedOrganisation = new CompactOrganisationDC(); + + ServiceFacade.DoCustomerServiceSync(s => updatedOrganisation = s.LoadOrganisationCompact((pUpdatedObject as CompactOrganisationDC).OrganisationOid)); + + foreach(var item in pServiceRecordView.ViewModel.VMList.Where(item => item.CostBearer.Equals(updatedOrganisation))) + { + item.CostBearer = new CompactOrganisationDC(); + item.CostBearer = updatedOrganisation; + } + } + } + + private static void UpdateTeamView(TeamView pTeamView, T pUpdatedObject) where T : IFilterableDC + { + if(typeof(T) == typeof(CompactEmployeeDC)) + { + var updatedEmployee = new CompactEmployeeDC(); + + ServiceFacade.DoEmployeeServiceSync(s => updatedEmployee = s.LoadCompactEmployee((pUpdatedObject as CompactEmployeeDC).EmployeeOid)); + + 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(); + foreach(var item in pTeamView.ViewModel.Member) + { + newMember.Add(item.EmployeeOid.Equals(updatedEmployee.EmployeeOid) ? updatedEmployee : item); + } + + pTeamView.ViewModel.Member = null; + pTeamView.ViewModel.Member = newMember; + } + + if(pTeamView.ViewModel.Leader.EmployeeOid.Equals(updatedEmployee.EmployeeOid)) + { + pTeamView.ViewModel.Leader = null; + pTeamView.ViewModel.Leader = updatedEmployee; + } + + UpdateSearchViewObjectList(pTeamView.employeesearchview, updatedEmployee); + UpdateSearchViewObjectList(pTeamView.leaderSearchView, updatedEmployee); + UpdateLoggedInEmployee(updatedEmployee.EmployeeOid); + } + else if(typeof(T) == typeof(CompactTeamDC)) + { + pTeamView.ReloadViewModel(); + } + } + + private static void UpdateUserView(UserView pUserView) + { + var updatedEmployee = new CompactEmployeeDC(); + + ServiceFacade.DoEmployeeServiceSync(s => updatedEmployee = s.LoadCompactEmployee(pUserView.ViewModel.Employee.EmployeeOid)); + + pUserView.ViewModel.Employee = null; + pUserView.ViewModel.Employee = updatedEmployee; + + var myView = new BeWoView(); + BeWoApp.MainControl.Views.TryGetValue(UIContext.User, out myView); + + if(myView is UserNavigationView naviView) + { + if(naviView.ObjectList.Contains(updatedEmployee)) + { + var copiedList = naviView.ObjectList as List; + copiedList[copiedList.IndexOf(updatedEmployee)] = new CompactEmployeeDC(); + copiedList[copiedList.IndexOf(updatedEmployee)] = updatedEmployee; + naviView.ObjectList = copiedList; + } + + if(naviView.RecentList.Contains(updatedEmployee)) + { + var copiedList = naviView.RecentList as List; + copiedList[copiedList.IndexOf(updatedEmployee)] = new CompactEmployeeDC(); + copiedList[copiedList.IndexOf(updatedEmployee)] = updatedEmployee; + naviView.RecentList = copiedList; + } + } + + UpdateSearchViewObjectList(pUserView.employeeSearchView, updatedEmployee); + UpdateLoggedInEmployee(updatedEmployee.EmployeeOid); + } + + private static void UpdateReportView(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); + + if(typeof(T) == typeof(CompactCustomerDC)) + { + var updatedCustomer = new CompactCustomerDC(); + ServiceFacade.DoCustomerServiceSync(s => updatedCustomer = s.GetCompactCustomerDC((pUpdatedObject as CompactCustomerDC).CustomerOid)); + + if(fls is FLSReportView fls2) + { + if(fls2._SelectedCustomer != null) + { + if(fls2._LastSelectedCustomer != null) + { + if(fls2._LastSelectedCustomer.Equals(updatedCustomer)) + { + fls2._LastSelectedCustomer = updatedCustomer; + } + } + + fls2._SelectedCustomer = updatedCustomer; + fls2.popupedit_client.Text = updatedCustomer.ToString(); + } + + UpdateSearchViewObjectList(fls2.customerSearchView, updatedCustomer); + } + + var serv2 = serv as ServicesReportView; + if(serv != null) + { + if(serv2.Customer != null) + { + serv2.Customer = updatedCustomer; + serv2.popupedit_customer.Text = updatedCustomer.ToString(); + } + + UpdateSearchViewObjectList(serv2.customersearchview, updatedCustomer); + } + } + + if(typeof(T) == typeof(CompactEmployeeDC)) + { + var updatedEmployee = new CompactEmployeeDC(); + ServiceFacade.DoEmployeeServiceSync(s => updatedEmployee = s.LoadCompactEmployee((pUpdatedObject as CompactEmployeeDC).EmployeeOid)); + + if(aus is AuslastungReportView aus2) + { + if(aus2._SelectedEmployee != null) + { + if(aus2._SelectedEmployee != null) + { + if(aus2._SelectedEmployee.EmployeeOid.Equals(updatedEmployee.EmployeeOid)) + { + aus2._SelectedEmployee = updatedEmployee; + } + } + + if(aus2._LastSelectedEmployee != null) + { + if(aus2._LastSelectedEmployee.EmployeeOid.Equals(updatedEmployee.EmployeeOid)) + { + aus2._LastSelectedEmployee = updatedEmployee; + } + } + + if(aus2._SelectedEmployee != null) + { + aus2.popupedit_employee.Text = updatedEmployee.ToString(); + } + } + + UpdateSearchViewObjectList(aus2.employeesearchview, updatedEmployee); + } + + if(fls is FLSReportView fls2) + { + if(fls2._SelectedEmployee != null) + { + if(fls2._LastSelectedEmployee != null) + { + if(fls2._LastSelectedEmployee.EmployeeOid.Equals(updatedEmployee.EmployeeOid)) + { + fls2._LastSelectedEmployee = updatedEmployee; + } + } + + fls2._SelectedEmployee = updatedEmployee; + fls2.popupedit_employee.Text = updatedEmployee.ToString(); + } + + UpdateSearchViewObjectList(fls2.employeeSearchView, updatedEmployee); + } + + if(serv is ServicesReportView serv2) + { + if(serv2.Employee != null) + { + serv2.Employee = updatedEmployee; + serv2.popupedit_employee.Text = updatedEmployee.ToString(); + } + + UpdateSearchViewObjectList(serv2.employeesearchview, updatedEmployee); + } + + UpdateLoggedInEmployee(updatedEmployee.EmployeeOid); + } + + 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(); + } + + UpdateSearchViewObjectList(serv2.organisationsearchview, updatedOrganisation); + } + } + + if(typeof(T) == typeof(CompactTeamDC)) + { + var updatedTeam = new CompactTeamDC(); + ServiceFacade.DoEmployeeServiceSync(s => updatedTeam = s.LoadCompactTeam((pUpdatedObject as CompactTeamDC).TeamOid)); + + if(aus is AuslastungReportView aus2) + { + if(aus2._SelectedTeam != null) + { + if(aus2._SelectedTeam.Equals(updatedTeam)) + { + aus2._SelectedTeam = updatedTeam; + } + + if(aus2._LastSelectedTeam != null) + { + if(aus2._LastSelectedTeam.Equals(updatedTeam)) + { + aus2._LastSelectedTeam = updatedTeam; + } + } + + aus2.popupedit_team.Text = updatedTeam.ToString(); + } + + UpdateSearchViewObjectList(aus2.teamsearchview, updatedTeam); + } + } + } + + private static void UpdatePersonView(PersonView pPersonView, T pUpdatedObject) where T : IFilterableDC + { + if(typeof(T) == typeof(CompactOrganisationDC)) + { + var gridRelations = (GridControl)pPersonView.rootGrid.Resources["grid_Relations"]; + var updatedOrganisation = new CompactOrganisationDC(); + + ServiceFacade.DoCustomerServiceSync(s => updatedOrganisation = s.LoadOrganisationCompact((pUpdatedObject as CompactOrganisationDC).OrganisationOid)); + + if(!string.IsNullOrWhiteSpace(pPersonView.popupedit_organisation.Text) && pPersonView.popupedit_organisation.Text.Equals((pUpdatedObject as CompactOrganisationDC).Name)) + { + pPersonView.popupedit_organisation.Text = updatedOrganisation.ToString(); + } + + foreach(var item in pPersonView.ViewModel.OrganisationRelations.VMList.Where(item => item.Organisation.OrganisationOid == updatedOrganisation.OrganisationOid)) + { + item.OrganisationString = updatedOrganisation.Name; + } + + gridRelations.RefreshData(); + + if(pPersonView.ViewModel.OrganisationRelations.NewVM?.Organisation != null) + { + if(pPersonView.ViewModel.OrganisationRelations.NewVM.Organisation.OrganisationOid.Equals(updatedOrganisation.OrganisationOid)) + { + pPersonView.ViewModel.OrganisationRelations.NewVM.OrganisationString = updatedOrganisation.Name; + } + } + + UpdateSearchViewObjectList(pPersonView.organisationSearchView, updatedOrganisation); + } + else if(typeof(T) == typeof(CompactPersonDC)) + { + pPersonView.ReloadViewModel(); + } + else if(typeof(T) == typeof(CompactCustomerDC)) + { + pPersonView.UpdateCustomerList(); + } + } + + private static void UpdateAdditionalServiceView(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)); + + UpdateLoggedInEmployee((pUpdatedObject as CompactEmployeeDC).EmployeeOid); + + for(var i = 0; i < pAdditionalServiceView.MultiEmployeeControlAddServ.SelectedEmployees.Count; i++) + { + if(!pAdditionalServiceView.MultiEmployeeControlAddServ.SelectedEmployees[i].EmployeeOid.Equals(updatedEmployee.EmployeeOid)) + { + continue; + } + + pAdditionalServiceView.MultiEmployeeControlAddServ.SelectedEmployees[i] = new CompactEmployeeDC(); + pAdditionalServiceView.MultiEmployeeControlAddServ.SelectedEmployees[i] = updatedEmployee; + } + + UpdateSearchViewObjectList(pAdditionalServiceView.MultiEmployeeControlAddServ.employeesearchview, updatedEmployee); + } + else if(typeof(T) == typeof(CompactCustomerDC)) + { + var updatedCustomer = new CompactCustomerDC(); + + ServiceFacade.DoCustomerServiceSync(s => updatedCustomer = s.GetCompactCustomerDC((pUpdatedObject as CompactCustomerDC).CustomerOid)); + + pAdditionalServiceView.MultiAddServGroupOfPeopleSelectionControl.UpdateCustomers(updatedCustomer); + + 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; + } + + var containsUpdatedCustomer = false; + + 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; + } + + if(!containsUpdatedCustomer) + { + return; + } + + pAdditionalServiceView.UpdateTeilnahmeGrid(); + } + } + + private static void UpdateSingleSupportConceptSelectionControl(SingleSupportConceptSelectionControl control, CompactCustomerDC updatedCustomer) { if (control.SelectedItem.SupportConceptTreeNodeDC == null) diff --git a/BeWo/View/Detail/CustomerView.xaml.cs b/BeWo/View/Detail/CustomerView.xaml.cs index 6627bbae8..2b7d9359b 100644 --- a/BeWo/View/Detail/CustomerView.xaml.cs +++ b/BeWo/View/Detail/CustomerView.xaml.cs @@ -379,17 +379,18 @@ namespace BeWo.View.Detail internal override bool DoSaveCheck() { - if (this.IsDirty) + if(IsDirty) { - CustomerDC cdc = ViewModel.CommitToDataContract(); + var cdc = ViewModel.CommitToDataContract(); var message = ServiceFacade.DoCustomerServiceSync(s => s.AllowSavingCustomer(cdc)); - if (!String.IsNullOrEmpty(message)) + if(!string.IsNullOrEmpty(message)) { MessageBox.Show(message, "Änderungen speichern", MessageBoxButton.OK, MessageBoxImage.Exclamation); return false; } } + return base.DoSaveCheck(); } @@ -408,17 +409,15 @@ namespace BeWo.View.Detail ViewModel.EmployeeRelations.IsDirty || ViewModel.TerminationDate != ViewModel.DataContract.TerminationDate) { - DoOwnChatSync = true; } } - CustomerDC cdc = ViewModel.CommitToDataContract(); + + var cdc = ViewModel.CommitToDataContract(); //var lDataContract = ViewModel.CommitToDataContract(); try { - - long oid = 0; IsDoneWithInsertOrUpdate = false; if (ViewModel.IsNew) @@ -438,6 +437,7 @@ namespace BeWo.View.Detail MessageBox.Show("Dieser Datensatz wurde in der Zwischenzeit von einem anderen Benutzer geändert. Klicken Sie Ok, um den Datansatz erneut zu laden. Ihre Änderungen gehen dabei leider verloren."); ReloadViewModel(cdc.CustomerOid.Value); } + _saveInProgress = false; } } @@ -534,10 +534,7 @@ namespace BeWo.View.Detail // reload to update version information and oid VMFactory.CreateCustomerVMAsync(pCustomerOID, cb => this.Dispatch(delegate { ViewModel = cb; UpdateUris(); })); - if (ModalEditViewUpdateCallback != null) - { - ModalEditViewUpdateCallback(); - } + ModalEditViewUpdateCallback?.Invoke(); IsDoneWithInsertOrUpdate = true; } @@ -556,7 +553,9 @@ namespace BeWo.View.Detail GroupBoxAbsenceTimes.Content = grid_AbsenceTimes; if (ViewModel.AbsenceTimes != null && grid_AbsenceTimes != null) + { grid_AbsenceTimes.Columns["Reason"].EditSettings = new ComboBoxEditSettings { ItemsSource = ViewModel.AbsenceTimes.PossibleReasons }; + } } // private void ComboBox_Loaded(object sender, RoutedEventArgs e) @@ -588,10 +587,10 @@ namespace BeWo.View.Detail grid_EmployeeRelation.Columns["Role"].EditSettings = new ComboBoxEditSettings { ItemsSource = ViewModel.EmployeeRelations.PossibleRoles }; } - if (!BeWoApp.LoggedOnUser.HasRight(UserRightType.ChatSettings)) - { - //grid_EmployeeRelation.Columns["Chatpartner"].Visible = false; - } + //if (!BeWoApp.LoggedOnUser.HasRight(UserRightType.ChatSettings)) + //{ + // grid_EmployeeRelation.Columns["Chatpartner"].Visible = false; + //} } if (grid_TeamRelation == null) @@ -602,7 +601,9 @@ namespace BeWo.View.Detail teamGrid.Children.Add(grid_TeamRelation); //if (ViewModel.TeamRelations != null) + //{ // grid_TeamRelation.Columns["Role"].EditSettings = new ComboBoxEditSettings { ItemsSource = ViewModel.EmployeeRelations.PossibleRoles }; + //} } } @@ -969,7 +970,6 @@ namespace BeWo.View.Detail popupedit_environmentOrganisationSearch.Focus(); } - //######################## Neu #################################### private void ansprechpartnersearchview_EnvironmentPersonSelected(object sender, EventArgs e) { popup_ansprechpartner.IsOpen = false; @@ -986,8 +986,6 @@ namespace BeWo.View.Detail popupedit_environmentPersonOrganisationSearch.Focus(); } - //################################################################### - private void popupedit_costBearer_PopUpClick(object sender, RoutedEventArgs e) { popup_costBearer.IsOpen = true; @@ -1039,7 +1037,6 @@ namespace BeWo.View.Detail popup_person.IsOpen = true; } - // ##################### Neu ###################### private void popupedit_environmentPersonOrganisationSearch_PopUpClick(object sender, RoutedEventArgs e) { personOrganisationsearchview.ItemSelected += PersonOrganisationsearchview_EnvironmentPersonSelected; @@ -1052,8 +1049,6 @@ namespace BeWo.View.Detail popup_ansprechpartner.IsOpen = true; } - //################################################# - private void popupedit_environmentOrganisationSearch_PopUpClick(object sender, RoutedEventArgs e) { organisationsearchview.ItemSelected += organisationsearchview_EnvironmentOrganisationSelected; @@ -1273,7 +1268,7 @@ namespace BeWo.View.Detail VMFactory.CreateEmployeeVMAsync((pDC as CompactEmployeeDC).EmployeeOid, cb => this.Dispatch( () => BeWoUtils.OpenModalViewWindow(cb, this, () => this.Dispatch( - () => BeWoUtils.UpdateAllViews(ViewModel.EmployeeRelations.NewVM.Employee ?? (pDC as CompactEmployeeDC))), allowSaveIfParentDirty: true))); + () => BeWoUtils.UpdateAllViews(ViewModel.EmployeeRelations.NewVM.Employee ?? pDC as CompactEmployeeDC)), allowSaveIfParentDirty: true))); } if (pDCType == typeof(CompactOrganisationDC)) @@ -1283,7 +1278,7 @@ namespace BeWo.View.Detail () => BeWoUtils.OpenModalViewWindow(cb, this, () => this.Dispatch( delegate { - CompactOrganisationDC selectedOrganisation = (isCostBearer ? ViewModel.CostBearers.NewVM.CostBearer : ViewModel.EnvironmentOrganisations.NewVM.Organisation) ?? (pDC as CompactOrganisationDC); + CompactOrganisationDC selectedOrganisation = (isCostBearer ? ViewModel.CostBearers.NewVM.CostBearer : ViewModel.EnvironmentOrganisations.NewVM.Organisation) ?? pDC as CompactOrganisationDC; BeWoUtils.UpdateAllViews(selectedOrganisation); }), (s, args) => this.Dispatch(delegate { }), allowSaveIfParentDirty: true))); } @@ -1293,7 +1288,7 @@ namespace BeWo.View.Detail VMFactory.CreatePersonVMAsync((pDC as CompactPersonDC).PersonOid, cb => this.Dispatch( () => BeWoUtils.OpenModalViewWindow(cb, this, () => this.Dispatch( - () => BeWoUtils.UpdateAllViews(ViewModel.EnvironmentPersons.NewVM.Person ?? (pDC as CompactPersonDC))), personSavedOrUpdated: (s, args) => this.Dispatch(delegate{}), allowSaveIfParentDirty: true))); + () => BeWoUtils.UpdateAllViews(ViewModel.EnvironmentPersons.NewVM.Person ?? pDC as CompactPersonDC)), personSavedOrUpdated: (s, args) => this.Dispatch(delegate{}), allowSaveIfParentDirty: true))); } if (pDCType == typeof(CompactTeamDC)) @@ -1301,7 +1296,7 @@ namespace BeWo.View.Detail VMFactory.CreateTeamVMAsync((pDC as CompactTeamDC).TeamOid, cb => this.Dispatch( () => BeWoUtils.OpenModalViewWindow(cb, this, () => this.Dispatch( - () => BeWoUtils.UpdateAllViews(ViewModel.TeamRelations.NewVM.Team ?? (pDC as CompactTeamDC))), allowSaveIfParentDirty: true))); + () => BeWoUtils.UpdateAllViews(ViewModel.TeamRelations.NewVM.Team ?? pDC as CompactTeamDC)), allowSaveIfParentDirty: true))); } } @@ -1888,5 +1883,4 @@ namespace BeWo.View.Detail } } } - } diff --git a/BeWo/View/Detail/EmployeeView.xaml.cs b/BeWo/View/Detail/EmployeeView.xaml.cs index 7fac6ec09..3ea4698a9 100644 --- a/BeWo/View/Detail/EmployeeView.xaml.cs +++ b/BeWo/View/Detail/EmployeeView.xaml.cs @@ -1,15 +1,12 @@ using System; using System.Collections.Generic; -using System.Drawing; -using System.IO; using System.Linq; -using System.Reflection; using System.ServiceModel; using System.Windows; -using System.Windows.Forms; using System.Windows.Input; using System.Windows.Media; using System.Windows.Media.Imaging; + using BeWo.Core; using BeWo.Core.Service; using BeWo.ownChat; @@ -27,8 +24,6 @@ using BS.Shared.Extensions; using DevExpress.Xpf.Editors.Settings; using DevExpress.Xpf.Grid; using Button = System.Windows.Controls.Button; -using Color = System.Drawing.Color; -using Image = System.Windows.Controls.Image; using MessageBox = System.Windows.MessageBox; using Point = System.Windows.Point; @@ -234,29 +229,28 @@ namespace BeWo.View.Detail return new[] {UserRightType.EditAll, UserRightType.EmployeeView_Edit, UserRightType.Employee_AllowEditOwnEmployees}; return new[] {UserRightType.EditAll, UserRightType.EmployeeView_Edit}; } - - protected override void Save() { - if (!ValidateContracts()) + if(!ValidateContracts()) { return; } - if (BeWoApp.AppSettings.IsChatAllowed) + if(BeWoApp.AppSettings.IsChatAllowed) { - if (ViewModel.DataContract.FirstName != ViewModel.FirstName || - ViewModel.DataContract.LastName != ViewModel.LastName) + if (ViewModel.DataContract.FirstName != ViewModel.FirstName || ViewModel.DataContract.LastName != ViewModel.LastName) { DoOwnChatSync = true; } } - EmployeeDC lDataContract = ViewModel.CommitToDataContract(); + + var lDataContract = ViewModel.CommitToDataContract(); + try { - if (ViewModel.IsNew) + if(ViewModel.IsNew) { IsDoneWithInsertOrUpdate = false; DoOwnChatSync = true; @@ -272,7 +266,7 @@ namespace BeWo.View.Detail Cache.GetInstance().ClearEmployees(); BeWoApp.MainControl.ResetView(UIContext.Employee); } - catch (FaultException) + catch(FaultException) { MessageBox.Show("Dieser Datensatz wurde in der Zwischenzeit von einem anderen Benutzer geändert. Klicken Sie Ok, um den Datansatz erneut zu laden. Ihre Änderungen gehen dabei leider verloren."); ReloadViewModel(lDataContract.EmployeeOid.Value); @@ -315,8 +309,7 @@ namespace BeWo.View.Detail this.Dispatch( delegate { - MessageBox.Show("Leider besitzen Sie nicht genügend Lizenzen, um einen neuen Benutzer anzulegen!", - "Benutzer anlegen", MessageBoxButton.OK, MessageBoxImage.Information); + MessageBox.Show("Leider besitzen Sie nicht genügend Lizenzen, um einen neuen Benutzer anzulegen!", "Benutzer anlegen", MessageBoxButton.OK, MessageBoxImage.Information); }); } else @@ -338,8 +331,6 @@ namespace BeWo.View.Detail } IsDoneWithInsertOrUpdate = true; - - } private void PreselectEmployeeBrush() @@ -626,7 +617,6 @@ namespace BeWo.View.Detail PreselectEmployeeBrush(); } - private void Img_OnMouseDoubleClick(object sender, MouseButtonEventArgs e) { BeWoUtils.ShowImageForm(Img.Source); diff --git a/BeWo/View/Detail/ModalViewWindow.xaml.cs b/BeWo/View/Detail/ModalViewWindow.xaml.cs index 47432ae89..e29718d3a 100644 --- a/BeWo/View/Detail/ModalViewWindow.xaml.cs +++ b/BeWo/View/Detail/ModalViewWindow.xaml.cs @@ -1,4 +1,5 @@ using System; +using System.Diagnostics; using System.Linq; using System.Windows; using System.Windows.Controls; @@ -14,6 +15,8 @@ namespace BeWo.View.Detail { private readonly bool _AllowSaveIfParentDirty; + public Action ModalEditViewUpdateCallback; + public BeWoView DetailView { get; set; } public BeWoView ParentView { get; set; } public Grid RootGrid => rootGrid; diff --git a/BeWo/View/Detail/ServiceRecordView2.xaml.cs b/BeWo/View/Detail/ServiceRecordView2.xaml.cs index fcbe0d6c7..5175d5d4e 100644 --- a/BeWo/View/Detail/ServiceRecordView2.xaml.cs +++ b/BeWo/View/Detail/ServiceRecordView2.xaml.cs @@ -3259,7 +3259,17 @@ namespace BeWo.View.Detail var employeeCompact = ViewModel.SelectedEmployee ?? BeWoApp.LoggedOnUser.Employee; - VMFactory.CreateEmployeeVMAsync(employeeCompact.EmployeeOid, cb => this.Dispatch(() => BeWoUtils.OpenModalViewWindow(cb, this, () => this.Dispatch(() => BeWoUtils.UpdateAllViews(employeeCompact))))); + VMFactory.CreateEmployeeVMAsync( + employeeCompact.EmployeeOid, + employeeVM => this.Dispatch( + () => BeWoUtils.OpenModalViewWindow( + employeeVM, + this, + () => this.Dispatch( + () => + { + BeWoUtils.UpdateAllViews(employeeCompact); + })))); } private void ReloadButton_OnClick(object sender, RoutedEventArgs e) diff --git a/BeWoPlanerMobil/BeWoPlanerMobil.csproj b/BeWoPlanerMobil/BeWoPlanerMobil.csproj index c05d36ec0..7ba96bc04 100644 --- a/BeWoPlanerMobil/BeWoPlanerMobil.csproj +++ b/BeWoPlanerMobil/BeWoPlanerMobil.csproj @@ -196,6 +196,7 @@ + @@ -204,6 +205,7 @@ + diff --git a/BeWoPlanerMobil/Content/BeWoMobileStyle.css b/BeWoPlanerMobil/Content/BeWoMobileStyle.css index b614ba923..7bf398d73 100644 --- a/BeWoPlanerMobil/Content/BeWoMobileStyle.css +++ b/BeWoPlanerMobil/Content/BeWoMobileStyle.css @@ -50,7 +50,7 @@ a, a:active, a:visited, a:hover { position: relative; line-height: 14px; display: block; - margin: 0 0 0.1em 0; + margin: 0 0 .1em 0; } .cell-content { diff --git a/BeWoPlanerMobil/Content/statisticsStyle.css b/BeWoPlanerMobil/Content/statisticsStyle.css new file mode 100644 index 000000000..c13fbd946 --- /dev/null +++ b/BeWoPlanerMobil/Content/statisticsStyle.css @@ -0,0 +1,19 @@ +#statisticsChartContainer { + margin-top: 1em; +} + +#myChart { + margin-top: 1em; + margin-bottom: 1em; +} + +fieldset { + color: #555; + border: 1px solid #bbb; + margin-right: .45em; + margin-top: .5em; +} + +p { + color: #555; +} \ No newline at end of file diff --git a/BeWoPlanerMobil/Controllers/MainController.cs b/BeWoPlanerMobil/Controllers/MainController.cs index ba1b072df..44ec27874 100644 --- a/BeWoPlanerMobil/Controllers/MainController.cs +++ b/BeWoPlanerMobil/Controllers/MainController.cs @@ -434,14 +434,14 @@ namespace BeWoPlanerMobil.Controllers { try { - if (Model == null) + if(Model == null) { return "SessionTimeout"; } - var parents = OperationsService.CreateSupportConceptStatistics(oid,DateTime.Now); + var supportConceptStatistics = OperationsService.CreateSupportConceptStatistics(oid, DateTime.Now); - return SerializeObject(parents); + return SerializeObject(supportConceptStatistics); } catch (Exception e) { diff --git a/BeWoPlanerMobil/Scripts/mainView.js b/BeWoPlanerMobil/Scripts/mainView.js index eb3beff46..4cfc22732 100644 --- a/BeWoPlanerMobil/Scripts/mainView.js +++ b/BeWoPlanerMobil/Scripts/mainView.js @@ -886,164 +886,6 @@ function showKalender() { initCalendar(); } -var ChartAnz; -var ArrayStatistika; -var StringProvided = "Geleistet diese Woche"; -var StringProvidedTotal = "Gesamt"; -var StringApproved = "Bewilligt pro Woche"; -var StringApprovedTotal = "Gesamt"; -var StringFree = "Frei pro Woche (Ø)"; -var StringFreeTotal = "Gesamt"; - -function showStatistics() { - $("#customersDropDown").val($("#customersDropDown option").eq(0).val()); - $("#zeiterfassung").css("display", "none"); - $("#KalenderNavigation").css("display", "none"); - $("#Kalender").css("display", "none"); - $("#klienten").css("display", "none"); - $("#colorRibbon").css("background-color", "#04b4d0"); - $("#UnterschriftBereich").css("display", "none"); - $("#Statistics").css("display","none"); - $("#SupportStatistik").css("display", "block"); - - const zahl = $("#scDropDown").val(); - - if (zahl >= 0) { - $("#StatisticUberschrift").val("Hilfeplan Statistik: " + $(`#scDropDown option[value='${zahl}']`).text()); - loadSupportConceptStatistics(zahl); - - } else { - $("#StatisticUberschrift").val("Hilfeplan Statistik: Es wurde kein Hilfeplan ausgewählt"); - $("#Statistic1").val("Keine Datensätze gefunden "); - $("#Statistic2").val("Keine Datensätze gefunden "); - $("#Statistic3").val("Keine Datensätze gefunden "); - document.getElementById("Statistic1").onclick = ""; - document.getElementById("Statistic2").onclick = ""; - document.getElementById("Statistic3").onclick = ""; - StatisticDesign(100, 200); - - $("#LegendStatistic2").val(100); - $("#LegendStatistic1").val(200); - } -} - -function StatisticDesign(wert1, wert2, string1, string2) { - const data = [ - { - value: wert1, - color: "#F7464A", - highlight: "#FF5A5E", - label: string1 - }, - { - value: wert2, - color: "#00FF00", - highlight: "#99FF00", - label: string2 - }]; - - const options = { - scaleShowLabelBackdrop: true, - scaleBackdropColor: "rgba(255,255,255,0.75)", - scaleBeginAtZero: true, - scaleBackdropPaddingY: 2, - scaleBackdropPaddingX: 2, - scaleShowLine: true, - segmentShowStroke: true, - segmentStrokeColor: "#fff", - segmentStrokeWidth: 1, - animationSteps: 150, - animationEasing: "easeOutBounce", - responsive: true, - animateRotate: true, - animateScale: true, - legendTemplate: "
    -legend\"><% for (var i=0; i
  • \"><%if(segments[i].label){%><%=segments[i].label%><%}%>
  • <%}%>
" - } - - const ctx = document.getElementById("myChart").getContext("2d"); - - if(ChartAnz != null) { - ChartAnz.destroy(); - } - - ChartAnz = new Chart(ctx).Doughnut(data, options); -} - -function loadSupportConceptStatistics(oid) { - $.ajax({ - type: "GET", - url: LoadStatisticsUrl, - data: {oid:oid }, - success: function (jsonServiceRecord) { - var KalenderRec = $.parseJSON(jsonServiceRecord); - - var Description = KalenderRec.Subject; - - var Provided = KalenderRec.MinutesProvidedThisWeek; - var Approved = KalenderRec.MinutesApprovedPerWeek; - var FreeWeek = KalenderRec.MinutesFreePerWeekAverage; - - var ProvidedTotal = KalenderRec.MinutesProvidedTotalRounded; - var ApprovedTotal = KalenderRec.MinutesApprovedTotal; - var FreeWeekTotal = ApprovedTotal - ProvidedTotal; - - Provided = (Provided / 60).toFixed(2); - Approved = (Approved / 60).toFixed(2); - FreeWeek = (FreeWeek / 60).toFixed(2); - - ProvidedTotal = (ProvidedTotal / 60).toFixed(2); - ApprovedTotal = (ApprovedTotal / 60).toFixed(2); - FreeWeekTotal = (FreeWeekTotal / 60).toFixed(2); - - - ArrayStatistika = new Array(); - - ArrayStatistika[0] = Provided; - ArrayStatistika[1] = Approved; - ArrayStatistika[2] = FreeWeek; - - ArrayStatistika[3] = ProvidedTotal; - ArrayStatistika[4] = ApprovedTotal; - ArrayStatistika[5] = FreeWeekTotal; - - var berechne = ArrayStatistika[3] - ArrayStatistika[0]; - - if (berechne < 0)berechne = 0; - - StatisticDesign(ArrayStatistika[0], berechne, StringProvided, StringProvidedTotal); - - $("#LegendStatistic2").val(ArrayStatistika[0] + " / " + StringProvided); - $("#LegendStatistic1").val(ArrayStatistika[3] + " / " + StringProvidedTotal); - - - loadDataIntoTextField(ArrayStatistika); - } - }); -} - -function loadDataIntoTextField(ArrayStatistika) { - if ($("#Statistic1").val() == "") { - $("#Statistic1").val(StringProvided + ": " + ArrayStatistika[0] + " / Gesamt: " + ArrayStatistika[3]); - $("#Statistic2").val(StringApproved + ": " + ArrayStatistika[1] + " / Gesamt: " + ArrayStatistika[4]); - $("#Statistic3").val(StringFree + ": " + ArrayStatistika[2] + " / Gesamt: " + ArrayStatistika[5]); - } -} - -function StatisticÄnderung(value) { - const value1 = ArrayStatistika[value + 2]; - const value2 = ArrayStatistika[value - 1]; - var difference = value1 - value2; - - if (difference < 0) { - difference = 0; - } - - StatisticDesign(value2, difference, StringProvided, StringProvidedTotal); - - $("#LegendStatistic2").val(value2 + " / " + StringProvided); - $("#LegendStatistic1").val(value1 + " / " + StringProvidedTotal); -} - function showUsAendern() { $("#TerminSpeichern").prop('disabled', false); $("#AenderePopupDivSchalter").val("true"); @@ -1063,21 +905,23 @@ function initCalendar() { $("html, body").animate({ scrollTop: 0 }, "fast"); var newtoday; - var datumStr = $("#KalenderDatum").val(); + const datumStr = $("#KalenderDatum").val(); var nextdatum; if (datumStr === "") { nextdatum = new Date(); - var ddi0 = nextdatum.getDate(); - var mmi0 = nextdatum.getMonth() + 1; - var yyyyi0 = nextdatum.getFullYear(); + const ddi0 = nextdatum.getDate(); + const mmi0 = nextdatum.getMonth() + 1; + const yyyyi0 = nextdatum.getFullYear(); - var ddStri0 = ddi0 < 10 ? "0" + ddi0 : ddi0; - var mmStri0 = mmi0 < 10 ? "0" + mmi0 : mmi0; + const ddStri0 = ddi0 < 10 ? "0" + ddi0 : ddi0; + const mmStri0 = mmi0 < 10 ? "0" + mmi0 : mmi0; $("#KalenderDatum").val(yyyyi0 + "-" + mmStri0 + "-" + ddStri0); + newtoday = ddStri0 + '.' + mmStri0 + "." + yyyyi0; + $("#KalenderDatumFormat").val(newtoday); loadAppointments(newtoday); @@ -1085,15 +929,15 @@ function initCalendar() { } function initAppointmentEditForm() { - var currTime = new Date(); + const currTime = new Date(); if (currTime.getMinutes() <= 30) { - var k = 30 - currTime.getMinutes(); + const k = 30 - currTime.getMinutes(); currTime.setMinutes(currTime.getMinutes() + k); } if (currTime.getMinutes() > 30) { - var j = 60 - currTime.getMinutes(); + const j = 60 - currTime.getMinutes(); currTime.setMinutes(currTime.getMinutes() + j); } @@ -1132,12 +976,12 @@ function hideEditForm() { } function nextDayButtonClick() { - var nextdatum = new Date($("#KalenderDatum").val()); + const nextdatum = new Date($("#KalenderDatum").val()); nextdatum.setDate((nextdatum.getDate() + 1)); $("#KalenderDatum").val(toDateStringYearMonthDay(nextdatum)); - var newtoday = getDateStringWithLeadingZeros(nextdatum); + const newtoday = getDateStringWithLeadingZeros(nextdatum); $("#KalenderDatumFormat").val(newtoday); diff --git a/BeWoPlanerMobil/Scripts/statistics.js b/BeWoPlanerMobil/Scripts/statistics.js new file mode 100644 index 000000000..d0ef58bdf --- /dev/null +++ b/BeWoPlanerMobil/Scripts/statistics.js @@ -0,0 +1,116 @@ +var chartAnz; + +function showStatistics() { + $("#customersDropDown").val($("#customersDropDown option").eq(0).val()); + $("#zeiterfassung").css("display", "none"); + $("#KalenderNavigation").css("display", "none"); + $("#Kalender").css("display", "none"); + $("#klienten").css("display", "none"); + $("#colorRibbon").css("background-color", "#04b4d0"); + $("#UnterschriftBereich").css("display", "none"); + $("#Statistics").css("display", "none"); + $("#SupportStatistik").css("display", "block"); + + const supportConceptOid = $("#scDropDown").val(); + + if(supportConceptOid >= 0) { + $("#StatisticUberschrift").html(`Hilfeplan Statistik: ${$(`#scDropDown option[value='${supportConceptOid}']`).text()}`); + loadSupportConceptStatistics(supportConceptOid); + } else { + $("#StatisticUberschrift").html("Hilfeplan Statistik: Es wurde kein Hilfeplan ausgewählt"); + + statisticDesign(0, 0); + + $("#LegendStatistic2").val(0); + $("#LegendStatistic1").val(0); + } +} + +function statisticDesign(wert1, wert2, string1, string2) { + const data = [ + { + value: wert1, + color: "#F7464A", + highlight: "#FF5A5E", + label: string1 + }, + { + value: wert2, + color: "#00FF00", + highlight: "#99FF00", + label: string2 + }]; + + const options = { + scaleShowLabelBackdrop: true, + scaleBackdropColor: "rgba(255,255,255,0.75)", + scaleBeginAtZero: true, + scaleBackdropPaddingY: 2, + scaleBackdropPaddingX: 2, + scaleShowLine: true, + segmentShowStroke: true, + segmentStrokeColor: "#fff", + segmentStrokeWidth: 1, + animationSteps: 1, + animationEasing: "easeOutBounce", + responsive: true, + animateRotate: false, + animateScale: false, + legendTemplate: "
    -legend\">" + + "<% for (var i=0; i" + + "
  • " + + "\">" + + "<%if(segments[i].label){%><%=segments[i].label%><%}%>" + + "
  • <%}%>" + + "
" + } + + const ctx = $("#myChart").get(0).getContext("2d"); + + if(chartAnz != null) { + chartAnz.destroy(); + } + + chartAnz = new Chart(ctx).Doughnut(data, options); +} + +/* +Geleistet diese Woche / Gesamt 0,00 34,00 +Bewilligt pro Woche / Gesamt 0,97 101,25 +Frei pro Woche(O) / Gesamt 1,27 67,25 +*/ +function loadSupportConceptStatistics(oid) { + $.ajax({ + type: "GET", + url: loadStatisticsUrl, + data: { oid: oid }, + success: function(jsonServiceRecord) { + const supportConceptStatistics = $.parseJSON(jsonServiceRecord); + + var provided = supportConceptStatistics.MinutesProvidedThisWeek; + var approved = supportConceptStatistics.MinutesApprovedPerWeek; + var freePerWeek = supportConceptStatistics.MinutesFreePerWeekAverage; + + var providedTotal = supportConceptStatistics.MinutesProvidedTotalRounded; + var approvedTotal = supportConceptStatistics.MinutesApprovedTotal; + var freePerWeekTotal = approvedTotal - providedTotal; + + provided = (provided / 60).toFixed(2); + approved = (approved / 60).toFixed(2); + freePerWeek = (freePerWeek / 60).toFixed(2); + + providedTotal = (providedTotal / 60).toFixed(2); + approvedTotal = (approvedTotal / 60).toFixed(2); + freePerWeekTotal = (freePerWeekTotal / 60).toFixed(2); + + statisticDesign(providedTotal, approvedTotal, "Bewilligt gesamt", "Geleistet gesamt"); + + $("#LegendStatistic2").val(`Bewilligt gesamt: ${approvedTotal}`); + $("#LegendStatistic1").val(`Geleistet gesamt: ${providedTotal}`); + + $("#supportConceptStatisticsProvided").html(`Geleistet diese Woche/Gesamt: ${provided} / ${providedTotal}`); + $("#supportConceptStatisticsApproved").html(`Bewilligt pro Woche/Gesamt: ${approved} / ${approvedTotal}`); + $("#supportConceptStatisticsFree").html(`Frei pro Woche(Ø)/Gesamt: ${freePerWeek} / ${freePerWeekTotal}`); + } + }); +} \ No newline at end of file diff --git a/BeWoPlanerMobil/Views/Main/Main.cshtml b/BeWoPlanerMobil/Views/Main/Main.cshtml index f5e475bb8..229fc1c37 100644 --- a/BeWoPlanerMobil/Views/Main/Main.cshtml +++ b/BeWoPlanerMobil/Views/Main/Main.cshtml @@ -797,48 +797,28 @@