2016-06-27 01:45:38 +02:00
using System ;
using System.Collections.Generic ;
using System.ComponentModel ;
using System.Globalization ;
using System.Linq ;
using System.Windows ;
using System.Windows.Controls ;
using System.Windows.Controls.Primitives ;
using System.Windows.Data ;
using System.Windows.Input ;
using System.Windows.Media ;
2020-08-17 15:50:00 +02:00
using System.Windows.Media.Animation ;
2016-06-27 01:45:38 +02:00
using System.Windows.Threading ;
using BeWo.Annotations ;
using BeWo.Controls ;
using BeWo.Core ;
using BeWo.Core.Service ;
2017-11-06 10:30:25 +01:00
using BeWo.MultiLanguage ;
2019-02-28 12:38:29 +01:00
using BeWo.Scheduler.ViewModel ;
2016-06-27 01:45:38 +02:00
using BeWo.ServiceProxy ;
using BeWo.Validation ;
using BeWo.ViewModel ;
using BS.Shared ;
using BS.Shared.Core ;
using BS.Shared.DataContracts ;
using BS.Shared.DataContracts.ClientPartials ;
using BS.Shared.DataContracts.Compact ;
using BS.Shared.Extensions ;
2017-11-06 10:30:25 +01:00
using BS.Shared.Translation ;
2020-08-17 15:50:00 +02:00
using DevExpress.Mvvm.POCO ;
2016-06-27 01:45:38 +02:00
using DevExpress.Utils ;
using DevExpress.Xpf.Editors.Settings ;
using DevExpress.Xpf.Grid ;
using DevExpress.Xpf.Editors ;
2022-10-10 12:57:34 +02:00
using System.Windows.Navigation ;
using System.Windows.Documents ;
2024-10-21 13:27:52 +02:00
using System.Collections.ObjectModel ;
2016-06-27 01:45:38 +02:00
namespace BeWo.View.Detail
{
public partial class SupportConceptView : INotifyPropertyChanged
{
#region Constants and Fields
private TreeViewItem _SelectedGoalTreeNode ;
2019-08-06 13:08:15 +02:00
2016-06-27 01:45:38 +02:00
private PersonView _PersonModalPopUp ;
private List < ServiceRecordDC > _ServiceRecords ;
private SupportConceptVM _ViewModel ;
private bool employeeEditFlag ;
2019-08-06 13:08:15 +02:00
private bool isChangingCostbearer ;
2016-06-27 01:45:38 +02:00
2019-08-06 13:08:15 +02:00
private SupportConceptCostBearerRelVM supportConceptCostBearerRel2Change ;
2016-06-27 01:45:38 +02:00
2019-02-28 12:38:29 +01:00
private readonly SchedulerAppointmentDC taskToEdit ;
2017-12-11 14:31:59 +01:00
#region Rechtebinding
public static bool IsAllowedToChangeCostbeaerer
2019-08-06 13:08:15 +02:00
{
get { return BeWoApp . LoggedOnUser . HasRight ( UserRightType . CostbearerAllowChange ) ; }
}
2016-06-27 01:45:38 +02:00
2019-08-06 13:08:15 +02:00
public static bool IsAllowedToEditCostbearers
{
get { return BeWoApp . LoggedOnUser . HasRight ( UserRightType . SupportConceptView_Edit ) ; }
}
2016-06-27 01:45:38 +02:00
2019-08-06 13:08:15 +02:00
public static bool IsAllowedToEditGoals
{
get { return BeWoApp . LoggedOnUser . HasRight ( UserRightType . SupportConcept_AllowEditGoals ) ; }
}
#endregion
2016-06-27 01:45:38 +02:00
2019-08-06 13:08:15 +02:00
#endregion
2016-06-27 01:45:38 +02:00
2019-08-06 13:08:15 +02:00
#region Constructors and Destructors
2016-06-27 01:45:38 +02:00
2019-08-06 13:08:15 +02:00
public SupportConceptView ( SupportConceptVM pViewModel )
2016-06-27 01:45:38 +02:00
{
InitializeComponent ( ) ;
ViewModel = pViewModel ;
2020-04-08 14:25:01 +02:00
//tabitem_goalsNeu.Visibility = Visibility.Collapsed;
2024-06-19 16:13:56 +02:00
if ( ! BeWoApp . AppSettings . ShowPersehImport | | ! BeWoApp . LoggedOnUser . HasRight ( UserRightType . SupportConcept_ImportData ) )
{
ButtenImport . Visibility = Visibility . Collapsed ;
}
2019-08-06 13:08:15 +02:00
if ( ! BeWoApp . LoggedOnUser . HasRight ( UserRightType . SupportConceptView_AllowArchiving ) )
{
lblArchiviert . Visibility = Visibility . Hidden ;
chkArchiviert . Visibility = Visibility . Hidden ;
}
if ( ! BeWoApp . LoggedOnUser . HasRight ( UserRightType . DocumentsAllowViewAll ) & & ! BeWoApp . LoggedOnUser . HasRight ( UserRightType . DokumenteHilfeplaene ) )
{
tabitem_documents . Visibility = Visibility . Collapsed ;
}
2024-09-17 21:10:47 +02:00
tabitem_grid_tasks . IsEnabled = false ;
if ( BeWoApp . LoggedOnUser . HasRight ( UserRightType . SupportConcept_AllowEditTasks ) )
{
tabitem_grid_tasks . IsEnabled = true ;
}
2019-08-06 13:08:15 +02:00
if ( ! BeWoApp . LoggedOnUser . HasRight ( UserRightType . SupportConceptView_Edit ) )
2019-08-26 16:11:00 +02:00
{
2019-08-06 13:08:15 +02:00
grid_details . IsEnabled = false ;
button_addCostBearer . IsEnabled = false ;
//tabitem_documents.IsEnabled = false;
grid_serviceaccountings . IsEnabled = false ;
if ( BeWoApp . LoggedOnUser . HasRight ( UserRightType . SupportConcept_AllowEditTasks ) )
{
tabitem_tasks . IsSelected = true ;
}
2024-09-17 21:10:47 +02:00
2019-08-06 13:08:15 +02:00
if ( BeWoApp . LoggedOnUser . HasRight ( UserRightType . SupportConcept_AllowEditGoals ) )
{
tabitem_goals . IsSelected = true ;
}
}
2024-09-17 21:10:47 +02:00
2018-10-08 11:57:16 +02:00
if ( pViewModel . VarFields = = null | | pViewModel . VarFields . VMList . Count = = 0 )
{
tabitem_varFields . Visibility = Visibility . Collapsed ;
}
// HACK: Force the devexpress grid to end editing when the mouse is over savebutton
2016-06-27 01:45:38 +02:00
// by setting the focus to another element.
this . MouseMove + = ( s , e ) = >
{
if ( ! this . gridViewTasks . IsVisible )
{
return ;
}
Point p = e . GetPosition ( this . btnSave ) ;
if ( p . X > = 0 & & p . X < this . btnSave . ActualWidth & & p . Y > = 0 & & p . Y < this . btnSave . ActualHeight )
{
bool b = this . gridViewTasks . Focus ( ) ;
}
} ;
2017-12-11 14:31:59 +01:00
this . Loaded + = OnLoaded ;
2016-06-27 01:45:38 +02:00
}
2017-12-11 14:31:59 +01:00
private void OnLoaded ( object sender , RoutedEventArgs routedEventArgs )
2016-06-27 01:45:38 +02:00
{
2024-10-08 19:30:58 +02:00
if ( taskToEdit ! = null & & ViewModel ! = null & & ViewModel . Tasks ! = null )
2016-06-27 01:45:38 +02:00
{
2019-02-28 12:38:29 +01:00
tabitem_tasks . IsSelected = true ;
2016-06-27 01:45:38 +02:00
2019-02-28 12:38:29 +01:00
var item = ViewModel . Tasks . VMList . Single ( vm = > vm . DataContract . SchedulerAppointmentOid . Equals ( taskToEdit . SchedulerAppointmentOid ) ) ;
var handle = grid_tasks . GetRowHandleByListIndex ( ViewModel . Tasks . VMList . IndexOf ( item ) ) ;
2016-06-27 01:45:38 +02:00
2019-02-28 12:38:29 +01:00
gridViewTasks . FocusedRowHandle = handle ;
2017-12-11 14:31:59 +01:00
grid_tasks . CurrentColumn = TaskGridColumnCompletedDate ;
2019-02-28 12:38:29 +01:00
Dispatcher . BeginInvoke ( new Action ( ( ) = > { gridViewTasks . ShowEditor ( ) ; } ) , DispatcherPriority . Background ) ;
2016-06-27 01:45:38 +02:00
}
}
2019-02-28 12:38:29 +01:00
public SupportConceptView ( SupportConceptVM pViewModel , SchedulerAppointmentDC pTaskToEdit ) : this ( pViewModel )
2017-12-11 14:31:59 +01:00
{
taskToEdit = pTaskToEdit ;
}
2016-06-27 01:45:38 +02:00
#endregion
#region Properties
private SupportConceptApprovalPeriodVM _SelectedApprovalPeriodVM ;
public SupportConceptApprovalPeriodVM SelectedApprovalPeriodVM
{
2019-02-28 12:38:29 +01:00
get = > _SelectedApprovalPeriodVM ;
2016-06-27 01:45:38 +02:00
set
{
_SelectedApprovalPeriodVM = value ;
2019-02-28 12:38:29 +01:00
OnPropertyChanged ( nameof ( SelectedApprovalPeriodVM ) ) ;
2016-06-27 01:45:38 +02:00
}
}
2019-02-28 12:38:29 +01:00
public bool ShowHilfeplanBezeichnung = > BeWoApp . AppSettings . ShowHilfeplanBezeichnung ;
2017-06-11 15:50:31 +02:00
2019-02-28 12:38:29 +01:00
public override bool IsDirty = > ViewModel ! = null & & ViewModel . IsDirty ;
2016-06-27 01:45:38 +02:00
2019-02-28 12:38:29 +01:00
public override string Title = > Translator . Translate ( "Hilfepläne" ) ;
2016-06-27 01:45:38 +02:00
2019-02-28 12:38:29 +01:00
internal override DependencyObject ValidationOnSaveRootElement = > grid_details ;
2016-06-27 01:45:38 +02:00
internal SupportConceptVM ViewModel
{
get
{
return _ViewModel ;
}
set
{
var i = 0 ;
if ( tabcontrol_costbearers ! = null )
{
i = tabcontrol_costbearers . SelectedIndex ;
}
_ViewModel = value ;
DataContext = value ;
if ( ViewModel . Originator ! = null )
{
popupedit_employee . Text = ViewModel . Originator . ToString ( ) ;
}
if ( ViewModel . Customer ! = null )
{
popupedit_customer . Text = ViewModel . Customer . ToString ( ) ;
}
2020-08-17 15:50:00 +02:00
//treeview_Goals.ItemsSource = value.CombinedGoalTree;
2016-06-27 01:45:38 +02:00
if ( tabcontrol_costbearers ! = null )
{
tabcontrol_costbearers . SelectedIndex = i ;
}
treeview_serviceAccountings . ItemsSource = value . GlobalServiceTree ;
//this.treeview_individualServiceAccountings.ItemsSource = value.IndividualServiceTree;
}
}
#endregion
#region Public Methods
2024-12-19 17:13:03 +01:00
//private void InitSortCombo(ComboBox cb)
//{
// var list = new List<String>();
// list.Add("aufsteigend");
// list.Add("absteigend");
// cb.ItemsSource = list;
// cb.SelectedIndex = BeWoApp.AppSettings.LastBewilligungSortOrder;
//}
2016-06-27 01:45:38 +02:00
public override void ModalPopUpCloseInvoked ( )
{
this . MainControl . CloseCurrentPopUp ( ) ;
}
public override void ModalPopUpSaveInvoked ( )
{
// TODO nicht schön, umbauen wenn an weiteren Stellen popup hierachien nötig werden
if ( this . _PersonModalPopUp . _OrganisationModalPopUp ! = null )
{
this . _PersonModalPopUp . _OrganisationModalPopUp . SaveData ( ) ;
}
else
{
this . _PersonModalPopUp . SaveData ( ) ;
}
}
#endregion
#region Methods
protected override UserRightType [ ] GetSaveDemands ( )
{
return ViewModel . IsNew
? new [ ]
{
UserRightType . CreateAll , UserRightType . SupportConceptView_Create
}
: new [ ]
{
UserRightType . EditAll , UserRightType . SupportConceptView_Edit , UserRightType . SupportConcept_AllowEditGoals , UserRightType . SupportConcept_AllowEditTasks
} ;
}
protected override void Save ( )
{
if ( ViewModel . CostBearerRelations . VMList . Exists ( vm = > vm . CostBearer = = null ) )
{
2017-11-06 10:30:25 +01:00
MessageBox . Show ( Translator . Translate ( "Bitte wählen Sie einen Kostenträger aus" ) , "Fehlende Eingabe" , MessageBoxButton . OK ) ;
2016-06-27 01:45:38 +02:00
return ;
}
2017-04-03 13:07:06 +02:00
foreach ( var cbr in ViewModel . CostBearerRelations . VMList )
2016-06-27 01:45:38 +02:00
{
2017-04-03 13:07:06 +02:00
foreach ( var ap in cbr . ApprovalPeriodList . VMList )
{
2019-02-28 12:38:29 +01:00
var isAbsolute = false ;
2017-04-03 13:07:06 +02:00
decimal summe = 0 ;
foreach ( var ape in ap . SupportConceptApprovalEmployeeRelations . VMList )
{
summe + = ape . Betreuungsschluessel ;
isAbsolute = ape . IsAbsolut ;
}
if ( isAbsolute )
{
2019-08-06 13:08:15 +02:00
if ( ap . ApprovedBEPerInterval . HasValue & & summe > ( ap . ApprovedBEPerInterval . Value * 60 ) )
2017-04-03 13:07:06 +02:00
{
2019-02-28 12:38:29 +01:00
MessageBox . Show ( $"Die Summe der Anteile liegt bei über {(ap.ApprovedBEPerInterval.Value * 60):0} Minuten. Speichern nicht möglich." , "Fehler" , MessageBoxButton . OK , MessageBoxImage . Warning ) ;
2017-04-03 13:07:06 +02:00
return ;
}
}
else if ( summe > 100 )
{
MessageBox . Show ( "Die Summe der Anteile liegt bei über 100%. Speichern nicht möglich." , "Fehler" , MessageBoxButton . OK , MessageBoxImage . Warning ) ;
return ;
}
}
2016-06-27 01:45:38 +02:00
}
2017-04-03 13:07:06 +02:00
//var mehrAlsHundertProzentBetreuungsschluessel = ViewModel.CostBearerRelations.VMList.Any(a => a.ApprovalPeriodList.VMList.Any(a2 => a2.SupportConceptApprovalEmployeeRelations.VMList.Sum(s => s.Betreuungsschluessel) > 100));
//if (mehrAlsHundertProzentBetreuungsschluessel)
//{
// MessageBox.Show("Die Summe der Anteile liegt bei über 100%. Hinzufügen nicht möglich.", "Fehler", MessageBoxButton.OK, MessageBoxImage.Warning);
// return;
//}
2016-06-27 01:45:38 +02:00
var lDataContract = ViewModel . CommitToDataContract ( ) ;
var recordOutOfConcept = true ;
ServiceFacade . DoCustomerServiceSync ( s = > recordOutOfConcept = s . ServiceRecordOutOfSupportConcept ( lDataContract ) ) ;
if ( recordOutOfConcept )
{
if ( ! BeWoApp . LoggedOnUser . HasRight ( UserRightType . BookServiceRecordOutOfSupportConcept ) )
{
2019-02-28 12:38:29 +01:00
MessageBox . Show ( Translator . Translate ( "Es existiert mindestens eine Buchung außerhalb des Hilfeplanzeitraums." ) , "Speichern nicht möglich" , MessageBoxButton . OK , MessageBoxImage . Warning ) ;
2016-06-27 01:45:38 +02:00
}
else
{
2019-02-28 12:38:29 +01:00
var mbResult = MessageBox . Show ( Translator . Translate ( "Es existiert mindestens eine Buchung außerhalb des Hilfeplanzeitraums.\nMöchten Sie trotzdem speichern?" ) , "Speichern" , MessageBoxButton . YesNo , MessageBoxImage . Warning ) ;
2016-06-27 01:45:38 +02:00
2019-08-06 13:08:15 +02:00
if ( mbResult . Equals ( MessageBoxResult . No ) )
2019-02-28 12:38:29 +01:00
{
2016-06-27 01:45:38 +02:00
return ;
2019-02-28 12:38:29 +01:00
}
2016-06-27 01:45:38 +02:00
}
}
try
{
2017-03-28 11:01:28 +02:00
//#region Neue Individuelle Ziele speichern
2016-06-27 01:45:38 +02:00
var neueZM = ViewModel . CombinedGoals . VMList . Where ( w = > w . IsNew ) ;
2025-02-20 00:20:46 +01:00
2016-06-27 01:45:38 +02:00
ViewModel . TreeViewItemsList = new List < SupportConceptGoalTreeItem > ( ) ;
ViewModel . GetAllTreeViewItems ( ) ;
var obersteZiele = neueZM . Where ( w = > w . IsNew & & ( w . ParentEntry ! = null & & w . ParentEntry . ValueListEntryOid ! = null ) | | w . ParentEntry = = null ) . ToList ( ) ;
var alleNeuenZiele = new List < ValueListEntryDC > ( ) ;
foreach ( var ziel in obersteZiele )
{
var treeItem = ViewModel . TreeViewItemsList . FirstOrDefault ( f = > f . GoalEntryVM ! = null & & f . GoalEntryVM . Equals ( ziel ) ) ;
if ( treeItem ! = null )
{
alleNeuenZiele . AddRange ( GoalService . SaveIndividualGoalsAndMassnahmenRecursively ( treeItem ) ) ;
}
}
2017-03-28 11:01:28 +02:00
lDataContract = ViewModel . CommitToDataContract ( ) ;
lDataContract . Goals . RemoveRange ( lDataContract . Goals . Where ( g = > ! g . ValueListEntryOid . HasValue ) ) ;
//ViewModel.CombinedGoals.VMList.RemoveRange(ViewModel.CombinedGoals.VMList.Where(w => w.IsNew));
2016-06-27 01:45:38 +02:00
foreach ( var zielDC in alleNeuenZiele )
{
2017-03-28 11:01:28 +02:00
lDataContract . Goals . Add ( zielDC ) ;
//ViewModel.CombinedGoals.VMList.Add(new ValueListEntryVM(zielDC));
2016-06-27 01:45:38 +02:00
}
2017-03-28 11:01:28 +02:00
//#endregion
2016-06-27 01:45:38 +02:00
if ( ViewModel . IsNew )
{
ServiceFacade . DoCustomerServiceAsync ( s = > s . InsertNewSupportConcept ( lDataContract ) , ReloadViewModel ) ;
}
else
{
ServiceFacade . DoCustomerServiceAsync ( s = > s . UpdateSupportConcept ( lDataContract ) , ReloadViewModel ) ;
}
Cache . GetInstance ( ) . ClearSupportConceptTree ( ) ;
BeWoApp . MainControl . ResetView ( UIContext . SupportConcept ) ;
}
catch ( Exception e )
{
MessageBox . Show ( e . Message ) ;
}
}
private void Button_Loaded ( object sender , RoutedEventArgs e )
{
2019-08-06 13:08:15 +02:00
var t = new DispatcherTimer ( DispatcherPriority . Normal , Dispatcher ) { Interval = TimeSpan . FromSeconds ( . 5 ) } ;
2016-06-27 01:45:38 +02:00
t . Tick + = delegate
{
( ( Button ) sender ) . Click + = add_edit_employee_Click ;
t . Stop ( ) ;
} ;
t . Start ( ) ;
}
private void CostBearerSearchView_OrganisationSelected ( object sender , EventArgs < CompactOrganisationDC > e )
{
popup_costbearer . IsOpen = false ;
if ( ViewModel . CostBearerRelations . VMList . Exists ( vm = > vm . CostBearer ! = null & & vm . CostBearer . CostBearerOid . Equals ( e . Data . CostBearerOid ) ) )
{
2017-11-06 10:30:25 +01:00
MessageBox . Show ( Translator . Translate ( "Dieser Kostenträger wurde bereits hinzugefügt." ) , "Zufügen nicht möglich" , MessageBoxButton . OK , MessageBoxImage . Information ) ;
2016-06-27 01:45:38 +02:00
return ;
}
2019-08-06 13:08:15 +02:00
if ( ! isChangingCostbearer )
{
var newVm = ViewModel . CostBearerRelations . NewVM ;
newVm . CostBearer = e . Data ;
2016-06-27 01:45:38 +02:00
2019-08-06 13:08:15 +02:00
if ( ViewModel . Customer ! = null & & string . IsNullOrEmpty ( newVm . CustomerReferenceNumber ) & &
ViewModel . Customer . CostBearerReferenceNumbers . ContainsKey ( e . Data . CostBearerOid . Value ) )
{
newVm . CustomerReferenceNumber = ViewModel . Customer . CostBearerReferenceNumbers [ e . Data . CostBearerOid . Value ] ;
}
2016-06-27 01:45:38 +02:00
2019-08-06 13:08:15 +02:00
ViewModel . CostBearerRelations . AddNewVMToList ( ) ;
tabcontrol_costbearers . SelectedIndex = tabcontrol_costbearers . Items . Count - 1 ;
2016-06-27 01:45:38 +02:00
2019-08-06 13:08:15 +02:00
AddNewApprovalPeriod ( newVm ) ;
}
else
{
supportConceptCostBearerRel2Change . CostBearer = e . Data ;
2016-06-27 01:45:38 +02:00
2019-08-06 13:08:15 +02:00
if ( ViewModel . Customer ! = null & & ViewModel . Customer . CostBearerReferenceNumbers . ContainsKey ( e . Data . CostBearerOid . Value ) )
{
supportConceptCostBearerRel2Change . CustomerReferenceNumber = ViewModel . Customer . CostBearerReferenceNumbers [ e . Data . CostBearerOid . Value ] ;
}
else
{
supportConceptCostBearerRel2Change . CustomerReferenceNumber = null ;
}
2016-06-27 01:45:38 +02:00
2019-08-06 13:08:15 +02:00
supportConceptCostBearerRel2Change . CostBearerContactPerson = null ;
}
2016-06-27 01:45:38 +02:00
2019-08-06 13:08:15 +02:00
isChangingCostbearer = false ;
supportConceptCostBearerRel2Change = null ;
2016-06-27 01:45:38 +02:00
}
private void CustomerSearchView_CustomerSelected ( object sender , EventArgs < CompactCustomerDC > e )
{
popup_customer . IsOpen = false ;
popupedit_customer . Focus ( ) ;
var newCustomer = e . Data ;
if ( ViewModel . Customer ! = null & & ! ViewModel . Customer . Equals ( newCustomer ) )
{
if ( ! ViewModel . IsNew )
{
if ( HasServiceRecords ( ViewModel ) )
{
2017-11-06 10:30:25 +01:00
MessageBox . Show ( Translator . Translate (
2019-08-06 13:08:15 +02:00
"Für diesen Klienten wurden bereits Leistungen hinterlegt. Sie müssen diese Leistungen erst löschen bevor Sie den Klient wechseln können." ) ,
"Fehler" ,
MessageBoxButton . OK ,
2016-06-27 01:45:38 +02:00
MessageBoxImage . Exclamation ) ;
return ;
}
}
}
ViewModel . Customer = e . Data ;
}
private void EmployeeSearchView_EmployeeSelected ( object sender , EventArgs < CompactEmployeeDC > e )
{
popup_employee . IsOpen = false ;
if ( ! tabitem_tasks . IsSelected )
{
ViewModel . Originator = e . Data ;
popupedit_employee . Focus ( ) ;
popupedit_employee . Text = e . Data . ToString ( ) ;
}
else
{
2019-08-06 13:08:15 +02:00
if ( employeeEditFlag )
2016-06-27 01:45:38 +02:00
{
2019-02-28 12:38:29 +01:00
var data = grid_tasks . View . FocusedRowData ;
2016-06-27 01:45:38 +02:00
2019-08-06 13:08:15 +02:00
if ( data ? . RowHandle ! = null )
2016-06-27 01:45:38 +02:00
{
2019-02-28 12:38:29 +01:00
var vm = grid_tasks . GetRow ( data . RowHandle . Value ) as SchedulerAppointmentVM ;
2016-06-27 01:45:38 +02:00
2019-02-28 12:38:29 +01:00
if ( ! vm . EmployeeList . Exists ( i = > i . Employee . EmployeeOid . Equals ( e . Data . EmployeeOid ) ) )
2016-06-27 01:45:38 +02:00
{
2019-02-28 12:38:29 +01:00
vm . EmployeeList . Add ( new Employee2SchedulerAppointmentDC { Employee = e . Data } ) ;
2016-06-27 01:45:38 +02:00
}
}
}
2019-08-06 13:08:15 +02:00
else if ( ! ViewModel . Tasks . NewVM . EmployeeList . Exists ( i = > i . Employee . EmployeeOid . Equals ( e . Data . EmployeeOid ) ) )
2016-06-27 01:45:38 +02:00
{
2019-02-28 12:38:29 +01:00
ViewModel . Tasks . NewVM . EmployeeList . Add ( new Employee2SchedulerAppointmentDC { Employee = e . Data } ) ;
2016-06-27 01:45:38 +02:00
}
employeeEditFlag = false ;
}
}
private List < ServiceRecordDC > GetServiceRecords ( )
{
if ( _ServiceRecords = = null & & ViewModel . Customer ! = null )
{
2019-08-06 13:08:15 +02:00
_ServiceRecords = ViewModel . IsArchived
? ServiceFacade . DoOperationsServiceSync ( s = > s . GetCustomerServiceRecords ( ViewModel . Customer . CustomerOid , true ) )
2016-06-27 01:45:38 +02:00
: ServiceFacade . DoOperationsServiceSync ( s = > s . GetCustomerServiceRecords ( ViewModel . Customer . CustomerOid , false ) ) ;
}
return _ServiceRecords ;
}
private bool HasServiceRecords ( SupportConceptCostBearerRelVM relVM )
{
var records = GetServiceRecords ( ) ;
if ( records ! = null )
{
return records . Where ( srDC = > srDC . SupportConcept ! = null & & srDC . CostBearer ! = null & & relVM . CostBearer ! = null )
. Any ( srDC = > srDC . SupportConcept . SupportConceptOid = = ViewModel . DataContract . SupportConceptOid & & relVM . CostBearer . CostBearerOid = = srDC . CostBearer . CostBearerOid ) ;
}
return false ;
}
private bool HasServiceRecords ( SupportConceptVM vm )
{
var records = GetServiceRecords ( ) ;
if ( records ! = null & & records . Count > 0 )
{
return records . Where ( srDC = > srDC . SupportConcept ! = null ) . Any ( srDC = > srDC . SupportConcept . SupportConceptOid = = vm . DataContract . SupportConceptOid ) ;
}
return false ;
}
private void ReloadViewModel ( long pOID )
{
2019-02-28 12:38:29 +01:00
var updatedTasks = ViewModel . Tasks . VMList . Where ( w = > ! w . IsNew & & w . IsDirty ) . ToList ( ) ;
2022-09-07 14:43:01 +02:00
var newTasks = ViewModel . Tasks . CopyToDCList ( true ) . Where ( w = > ! w . SchedulerAppointmentOid . HasValue ) . ToList ( ) ;
2019-02-28 12:38:29 +01:00
var updatedTaskDCs = new List < SchedulerAppointmentDC > ( ) ;
2019-08-06 13:08:15 +02:00
foreach ( var t in updatedTasks )
2019-02-28 12:38:29 +01:00
{
t . CommitToDataContract ( ) ;
updatedTaskDCs . Add ( t . DataContract ) ;
}
2019-08-06 13:08:15 +02:00
2019-02-28 12:38:29 +01:00
ServiceFacade . DoResourceServiceAsync ( s = > s . DeleteSchedulerAppointments ( _DeletedTasks . ToDictionary ( d = > d . SchedulerAppointmentOid . Value , d = > d . NewSchedulerAppointmentVersion . Value ) ) , ( ) = >
{
ServiceFacade . DoResourceServiceAsync ( s2 = > s2 . UpdateSchedulerAppointments ( updatedTaskDCs ) , cb2 = >
{
ServiceFacade . DoResourceServiceAsync ( s = > s . InsertSchedulerAppointments ( newTasks ) , ( ) = >
{
this . Dispatch ( ( ) = >
{
// reload to update version information and oid
VMFactory . CreateSupportConceptVMAsync ( pOID , cb = > this . Dispatch ( delegate
{
ViewModel = cb ;
_DeletedTasks . Clear ( ) ;
2020-09-23 22:10:52 +02:00
FilterTreeItems ( ) ;
2019-02-28 12:38:29 +01:00
} ) ) ;
} ) ;
} ) ;
} ) ;
} ) ;
2016-06-27 01:45:38 +02:00
}
private void _PersonModalPopUp_PersonSavedOrUpdated ( object sender , EventArgs < PersonVM > e )
{
ServiceFacade . DoCustomerServiceAsync (
s = > s . LoadPersonCompact ( e . Data . DataContract . PersonOid . Value ) ,
p = > this . Dispatch (
delegate
{
var cbRelVM = tabcontrol_costbearers . SelectedItem as SupportConceptCostBearerRelVM ;
cbRelVM . CostBearerContactPerson = p ;
MainControl . CloseCurrentPopUp ( ) ;
} ) ) ;
}
private void add_edit_employee_Click ( object sender , RoutedEventArgs e )
{
2019-08-06 13:08:15 +02:00
employeeEditFlag = true ;
2016-06-27 01:45:38 +02:00
popup_employee . IsOpen = true ;
}
private void btn_deleteApprovalPeriod_Click ( object sender , RoutedEventArgs e )
{
var vm = ( ( Button ) sender ) . Tag as SupportConceptApprovalPeriodVM ;
var cbRelVM = tabcontrol_costbearers . SelectedItem as SupportConceptCostBearerRelVM ;
if ( cbRelVM . ApprovalPeriodList . VMList . Count = = 1 )
{
MessageBox . Show ( "Diese Bewilligungsperiode kann nicht gelöscht werden da mindestens eine vorhanden sein muss." ) ;
return ;
}
cbRelVM . ApprovalPeriodList . VMList . Remove ( vm ) ;
}
private void btn_deleteCBRel_Click ( object sender , RoutedEventArgs e )
{
var cbRelVM = tabcontrol_costbearers . SelectedItem as SupportConceptCostBearerRelVM ;
if ( HasServiceRecords ( cbRelVM ) )
{
2017-11-06 10:30:25 +01:00
MessageBox . Show ( Translator . Translate (
2019-08-06 13:08:15 +02:00
"Für diesen Kostenträger wurden bereits Leistungen hinterlegt. Sie müssen diese Leistungen erst löschen bevor Sie den Kostenträger entfernen können." ) ,
"Löschen" ,
MessageBoxButton . OK ,
2016-06-27 01:45:38 +02:00
MessageBoxImage . Exclamation ) ;
return ;
}
ViewModel . CostBearerRelations . VMList . Remove ( cbRelVM ) ;
}
private void button_addApprovalPeriod_Click ( object sender , RoutedEventArgs e )
{
AddNewApprovalPeriod ( ( ( Button ) sender ) . Tag as SupportConceptCostBearerRelVM ) ;
}
private static void AddNewApprovalPeriod ( SupportConceptCostBearerRelVM vm )
{
//var cbRelVM = this.tabcontrol_costbearers.SelectedItem as SupportConceptCostBearerRelVM;
2019-08-06 13:08:15 +02:00
//var actual = cbRelVM.ApprovalPeriodList.VMList.OrderByDescending(i => i.StartDate).FirstOrDefault();
//if (actual != null)
//{
// vm.ApprovalPeriodList.NewVM.StartDate = vm.StartDate;
// vm.ApprovalPeriodList.NewVM.EndDate = vm.EndDate;
// vm.ApprovalPeriodList.NewVM.ApprovedBEInterval = actual.ApprovedBEInterval;
// vm.ApprovalPeriodList.NewVM.ApprovedBEPerInterval = actual.ApprovedBEPerInterval;
// vm.ApprovalPeriodList.NewVM.ApprovedBETotal = actual.ApprovedBETotal;
// vm.ApprovalPeriodList.NewVM.ApprovedFixedAmount = actual.ApprovedFixedAmount;
// vm.ApprovalPeriodList.NewVM.ApprovedFixedAmountInterval = actual.ApprovedFixedAmountInterval;
// vm.ApprovalPeriodList.NewVM.IsApprovedBEShifting = actual.IsApprovedBEShifting;
// vm.ApprovalPeriodList.NewVM.IsApprovedFixedAmountShifting = actual.IsApprovedFixedAmountShifting;
// vm.ApprovalPeriodList.NewVM.MonthlyPayment = actual.MonthlyPayment;
// vm.ApprovalPeriodList.NewVM.ServiceUnitName = actual.ServiceUnitName;
// //actual.StartDate = DateTime.Now.Date.AddDays(1);
// //actual.EndDate = vm.ApprovedEndDate;
//}
//else
//{
vm . ApprovalPeriodList . NewVM . StartDate = vm . StartDate ;
vm . ApprovalPeriodList . NewVM . EndDate = vm . EndDate ;
vm . ApprovalPeriodList . NewVM . ApprovedBEInterval = SupportConceptApprovalInterval . Weekly ;
vm . ApprovalPeriodList . NewVM . IsApprovedBEShifting = true ;
vm . ApprovalPeriodList . NewVM . IsApprovedFixedAmountShifting = true ;
if ( vm . CostBearer ! = null )
{
vm . ApprovalPeriodList . NewVM . ServiceUnitName = vm . CostBearer . ServiceUnitName ;
}
2016-06-27 01:45:38 +02:00
//}
vm . ApprovalPeriodList . AddNewVMToList ( ) ;
}
private void button_addCostBearer_Click ( object sender , RoutedEventArgs e )
{
popup_costbearer . IsOpen = true ;
}
2019-02-28 12:38:29 +01:00
private void Button_AddTask_Click ( object sender , RoutedEventArgs e )
2016-06-27 01:45:38 +02:00
{
2019-02-28 12:38:29 +01:00
if ( ValidationTrigger . Validate ( groupbox_newTask ) & & ViewModel . DataContract . SupportConceptOid . HasValue )
2016-06-27 01:45:38 +02:00
{
2021-01-12 01:12:03 +01:00
//ServiceFacade.DoCustomerServiceAsync(s => s.LoadCompactSupportConceptDC(ViewModel.DataContract.SupportConceptOid.Value, null), sc =>
//{
// this.Dispatch(() =>
// {
var csc = new CompactSupportConceptDC ( ) ;
csc . SupportConceptOid = ViewModel . DataContract . SupportConceptOid . Value ;
ViewModel . Tasks . NewVM . SupportConceptList . Add ( csc ) ;
ViewModel . Tasks . NewVM . IsTask = true ;
ViewModel . Tasks . NewVM . AllDay = true ;
if ( ViewModel . Tasks . NewVM . DueDate = = null )
2019-02-28 12:38:29 +01:00
{
2021-01-12 01:12:03 +01:00
ViewModel . Tasks . NewVM . Start = DateTime . Today ;
ViewModel . Tasks . NewVM . End = new DateTime ( 9999 , 12 , 31 , 0 , 0 , 0 ) ;
}
else
{
var end = ViewModel . Tasks . NewVM . DueDate . Value . AddDays ( 1 ) ;
ViewModel . Tasks . NewVM . Start = DateTime . Today ;
ViewModel . Tasks . NewVM . End = end ;
}
2019-02-28 12:38:29 +01:00
2021-01-12 01:12:03 +01:00
ViewModel . Tasks . AddNewVMToList ( ) ;
ViewModel . Tasks . NewVM . EmployeeList . Add ( new Employee2SchedulerAppointmentDC { Employee = BeWoApp . CompactLoggedOnEmployee } ) ;
// });
//});
2016-06-27 01:45:38 +02:00
}
}
2019-02-28 12:38:29 +01:00
private void Button_AddEmployee_Click ( object sender , RoutedEventArgs e )
2016-06-27 01:45:38 +02:00
{
popup_employee . IsOpen = true ;
}
2022-12-15 13:21:56 +01:00
private void button_addAllEmployee_Click ( object sender , RoutedEventArgs e )
{
if ( MessageBox . Show ( "Wollen Sie die Aufgabe " + Translator . Translate ( "jedem Mitarbeiter" ) + " zuordnen?" , "Achtung" , MessageBoxButton . YesNo , MessageBoxImage . Exclamation ) = = MessageBoxResult . Yes )
{
var allEmployee = ServiceFacade . DoEmployeeServiceSync ( s = > s . GetAllActiveEmployeesCompact ( ) ) ;
//var relations = SelectedApprovalPeriodVM.SupportConceptApprovalEmployeeRelations;
foreach ( var emp in allEmployee )
{
if ( employeeEditFlag )
{
var data = grid_tasks . View . FocusedRowData ;
if ( data ? . RowHandle ! = null )
{
var vm = grid_tasks . GetRow ( data . RowHandle . Value ) as SchedulerAppointmentVM ;
if ( ! vm . EmployeeList . Exists ( i = > i . Employee . EmployeeOid . Equals ( emp . EmployeeOid ) ) )
{
vm . EmployeeList . Add ( new Employee2SchedulerAppointmentDC { Employee = emp } ) ;
}
}
}
else if ( ! ViewModel . Tasks . NewVM . EmployeeList . Exists ( i = > i . Employee . EmployeeOid . Equals ( emp . EmployeeOid ) ) )
{
ViewModel . Tasks . NewVM . EmployeeList . Add ( new Employee2SchedulerAppointmentDC { Employee = emp } ) ;
}
}
employeeEditFlag = false ;
}
}
2016-06-27 01:45:38 +02:00
2019-02-28 12:38:29 +01:00
private readonly List < SchedulerAppointmentDC > _DeletedTasks = new List < SchedulerAppointmentDC > ( ) ;
2019-08-06 13:08:15 +02:00
2019-02-28 12:38:29 +01:00
private void Button_RemoveTask_Click ( object sender , RoutedEventArgs e )
2016-06-27 01:45:38 +02:00
{
2019-02-28 12:38:29 +01:00
var test = grid_tasks . GetCurrentValue < SchedulerAppointmentVM > ( ) ;
2019-08-06 13:08:15 +02:00
if ( test . DataContract ? . SchedulerAppointmentOid ! = null )
2019-02-28 12:38:29 +01:00
{
_DeletedTasks . AddIfNotIn ( test . CommitToDataContract ( ) ) ;
}
ViewModel . Tasks . VMList . Remove ( test ) ;
2016-06-27 01:45:38 +02:00
BeWoWpfUtils . RefreshDXGrid ( grid_tasks ) ;
}
2019-02-28 12:38:29 +01:00
private void Button_Remove_Edit_Employee_Click ( object sender , RoutedEventArgs e )
2016-06-27 01:45:38 +02:00
{
var data = grid_tasks . View . FocusedRowData ;
2019-02-28 12:38:29 +01:00
if ( data ? . RowHandle ! = null )
2016-06-27 01:45:38 +02:00
{
2019-02-28 12:38:29 +01:00
var vm = grid_tasks . GetRow ( data . RowHandle . Value ) as SchedulerAppointmentVM ;
2019-08-06 13:08:15 +02:00
2019-02-28 12:38:29 +01:00
vm ? . EmployeeList . Remove ( ( Employee2SchedulerAppointmentDC ) ( ( Button ) sender ) . Tag ) ;
2016-06-27 01:45:38 +02:00
}
}
2019-02-28 12:38:29 +01:00
private void Button_Remove_Employee_Click ( object sender , RoutedEventArgs e )
2016-06-27 01:45:38 +02:00
{
2019-02-28 12:38:29 +01:00
ViewModel . Tasks . NewVM . EmployeeList . Remove ( ( Employee2SchedulerAppointmentDC ) ( ( Button ) sender ) . Tag ) ;
2016-06-27 01:45:38 +02:00
}
2019-02-28 12:38:29 +01:00
2016-06-27 01:45:38 +02:00
private void personsearchview_CostBearerContactPersonSelected ( object sender , EventArgs < CompactPersonDC > e )
{
popup_person . IsOpen = false ;
personsearchview . ItemSelected - = personsearchview_CostBearerContactPersonSelected ;
var cbRelVM = tabcontrol_costbearers . SelectedItem as SupportConceptCostBearerRelVM ;
cbRelVM . CostBearerContactPerson = e . Data ;
}
2022-08-05 13:42:20 +02:00
private long newPersonOid = 0 ;
2016-06-27 01:45:38 +02:00
private void popupedit_costBearerContactPersonSearch_NewClick ( object sender , RoutedEventArgs e )
{
2019-10-10 22:07:42 +02:00
if ( ViewModel . IsNew )
{
MessageBox . Show ( "Bevor Sie eine neue Person anlegen können, muss dieser Datensatz zuerst gespeichert werden." , "Erst speichern bitte" , MessageBoxButton . OK , MessageBoxImage . Information ) ;
return ;
}
else
{
2022-08-05 13:42:20 +02:00
newPersonOid = 0L ;
2019-10-10 22:07:42 +02:00
VMFactory . CreatePersonVMAsync (
2016-06-27 01:45:38 +02:00
cb = > this . Dispatch (
( ) = > BeWoUtils . OpenModalViewWindow < PersonVM , PersonDC , SupportConceptView > ( cb , this , ( ) = > this . Dispatch (
delegate
2019-10-10 22:07:42 +02:00
{
2022-08-05 13:42:20 +02:00
if ( newPersonOid > 0 )
{
var newPerson = new CompactPersonDC ( ) ;
2016-06-27 01:45:38 +02:00
2022-08-05 13:42:20 +02:00
//ServiceFacade.DoCustomerServiceSync(s => newPersonOid = s.InsertNewPerson(cb.CommitToDataContract()));
2016-06-27 01:45:38 +02:00
2022-08-05 13:42:20 +02:00
ServiceFacade . DoCustomerServiceSync ( s = > newPerson = s . LoadPersonCompact ( newPersonOid ) ) ;
2016-06-27 01:45:38 +02:00
2022-08-05 13:42:20 +02:00
( ( SupportConceptCostBearerRelVM ) tabcontrol_costbearers . SelectedItem ) . CostBearerContactPerson = null ;
( ( SupportConceptCostBearerRelVM ) tabcontrol_costbearers . SelectedItem ) . CostBearerContactPerson = newPerson ;
personsearchview . ObjectList . Add ( newPerson ) ;
}
2019-10-10 22:07:42 +02:00
}
2022-08-05 13:42:20 +02:00
) , personSavedOrUpdated : personModalPopUp_PersonSavedOrUpdated ) ) ) ;
2019-10-10 22:07:42 +02:00
}
2016-06-27 01:45:38 +02:00
}
2022-08-05 13:42:20 +02:00
private void personModalPopUp_PersonSavedOrUpdated ( object sender , EventArgs < PersonVM > e )
{
if ( e . Data ! = null & & e . Data . DataContract . PersonOid . HasValue )
{
newPersonOid = e . Data . DataContract . PersonOid . Value ;
}
}
2016-06-27 01:45:38 +02:00
private void popupedit_costBearerContactPersonSearch_PopUpClick ( object sender , RoutedEventArgs e )
{
personsearchview . ItemSelected + = personsearchview_CostBearerContactPersonSelected ;
popup_person . IsOpen = true ;
}
private void popupedit_costBearer_PopUpClick ( object sender , RoutedEventArgs e )
{
// sccbrvm = (SupportConceptCostBearerRelVM)((Control)sender).Tag;
// popup_costbearer.IsOpen = true;
}
private void popupedit_customer_PopUpClick ( object sender , RoutedEventArgs e )
{
popup_customer . IsOpen = true ;
}
private void popupedit_employee_PopUpClick ( object sender , RoutedEventArgs e )
{
popup_employee . IsOpen = true ;
}
private void tabitem_documents_Selected ( object sender , RoutedEventArgs e )
{
if ( ViewModel . IsNew )
{
2019-02-28 12:38:29 +01:00
MessageBox . Show ( "Bevor zu einem Datensatz Dokumente hinterlegt werden können, muss dieser gespeichert werden." , "Erst speichern bitte" , MessageBoxButton . OK , MessageBoxImage . Information ) ;
2016-06-27 01:45:38 +02:00
return ;
}
if ( tabitem_documents . Content = = null )
{
tabitem_documents . Content = new BeWoFileView ( TableID . SupportConcept , ViewModel . DataContract . SupportConceptOid . Value ) ;
}
}
2020-08-17 15:50:00 +02:00
//private void tabitem_goalsNeu_selected(object sender, RoutedEventArgs e)
//{
// //if (ViewModel.IsNew)
// //{
// // MessageBox.Show("Bevor Sie Angaben zum Schulbegleitenden Dienst hinterlegen können, muss dieser Datensatz zuerst gespeichert werden.", "Erst speichern bitte", MessageBoxButton.OK, MessageBoxImage.Information);
// // return;
// //}
// if (GridGoals.Children.Count == 0)
// {
// GridGoals.Children.Add(new SupportConceptGoalView(ViewModel));
// }
//}
2020-03-03 09:27:02 +01:00
2016-06-27 01:45:38 +02:00
// Kann das weg?
private void ContextMenu_Click ( object sender , RoutedEventArgs e )
{
//###IndServices
//if (e.OriginalSource is MenuItem)
//{
// var twi = e.OriginalSource as MenuItem;
// ServiceCategoryTreeItem selectedItem = this.treeview_individualServiceAccountings.SelectedItem as ServiceCategoryTreeItem;
// if (twi.Header.Equals("Neue Leistung"))
// {
// this.treeview_individualServiceAccountings.ItemContainerGenerator.StatusChanged +=
// this.ItemContainerGenerator_StatusChanged;
// ViewModel.AddIndividualService(selectedItem);
// }
// else if (twi.Header.Equals("Umbenennen"))
// {
// this.EditItem(this.treeview_individualServiceAccountings, null, selectedItem);
// }
// else if (twi.Header.Equals("Löschen"))
// {
// if (selectedItem != null && MessageBox.Show("ACHTUNG: Das Löschen von Leistungen kann nicht rückgängig gemacht werden.\n" +
// "Alle verknüpften Eintragungen in der Zeiterfassung bleiben erhalten.\n\n" +
// "Wollen Sie die Leistung '" + selectedItem.Name + "' wirklich löschen?", "Löschen bestätigen", MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.Yes)
// {
// ViewModel.DeleteIndividualService(selectedItem);
// }
// }
//}
}
private void ItemContainerGenerator_StatusChanged ( object sender , EventArgs e )
{
//###IndServices
//var ig = (ItemContainerGenerator)sender;
//if (ig.Status != GeneratorStatus.ContainersGenerated)
//{
// return;
//}
//var n = ig.ContainerFromIndex(this.treeview_individualServiceAccountings.Items.Count - 1) as TreeViewItem;
//if (n != null)
//{
// n.IsSelected = true;
// new DispatcherTimer(
// TimeSpan.FromMilliseconds(200),
// DispatcherPriority.Background,
// (s1, e1) =>
// {
// ServiceCategoryTreeItem item = ig.ItemFromContainer(n) as ServiceCategoryTreeItem;
// this.EditItem(this.treeview_individualServiceAccountings, null, item);
// ((DispatcherTimer)s1).Stop();
// },
// this.Dispatcher).Start();
//}
//this.treeview_individualServiceAccountings.ItemContainerGenerator.StatusChanged -= this.ItemContainerGenerator_StatusChanged;
}
private void ContextMenu_Opened ( object sender , RoutedEventArgs e )
{
//if (e.OriginalSource is ContextMenu)
//{
// ContextMenu menu = e.OriginalSource as ContextMenu;
// ServiceAccountingVM folder = this.treeview_individualServiceAccountings.SelectedItem as ServiceAccountingVM;
// foreach (var item in menu.Items)
// {
// if (item is MenuItem)
// {
// MenuItem menuitem = item as MenuItem;
// if (menuitem.Header.Equals("Umbenennen"))
// menuitem.IsEnabled = true;
// }
// }
//}
}
private void TextBox_KeyDown ( object sender , KeyEventArgs e )
{
if ( e . Key = = Key . Return )
{
UpdateSelectedTreeItemText ( ( TextBox ) sender ) ;
}
}
private void TextBox_LostFocus ( object sender , RoutedEventArgs e )
{
UpdateSelectedTreeItemText ( ( TextBox ) sender ) ;
}
private static void UpdateSelectedTreeItemText ( TextBoxBase textBox )
{
if ( ! textBox . IsReadOnly )
{
textBox . Background = Brushes . Transparent ;
textBox . IsReadOnly = true ;
textBox . BorderThickness = new Thickness ( 0 ) ;
textBox . Padding = new Thickness ( 1 , 3 , 1 , 3 ) ;
}
}
// scheint nicht mehr genutzt zu werden
private void TreeViewItem_PreviewMouseRightButtonDown ( object sender , MouseButtonEventArgs e )
{
var source = e . OriginalSource as DependencyObject ;
while ( source ! = null & & ! ( source is TreeViewItem ) )
{
source = VisualTreeHelper . GetParent ( source ) ;
}
if ( source ! = null )
{
( ( TreeViewItem ) source ) . IsSelected = true ;
//this._SelectedTreeNode = (TreeViewItem)source;
}
else
{
//this._SelectedTreeNode = null;
}
}
private void GoalTreeViewItem_PreviewMouseRightButtonDown ( object sender , MouseButtonEventArgs e )
{
var source = e . OriginalSource as DependencyObject ;
while ( source ! = null & & ! ( source is TreeViewItem ) )
{
source = VisualTreeHelper . GetParent ( source ) ;
}
if ( source ! = null )
{
( ( TreeViewItem ) source ) . IsSelected = true ;
_SelectedGoalTreeNode = ( TreeViewItem ) source ;
}
else
{
_SelectedGoalTreeNode = null ;
}
}
private void ContextMenuGoals_Click ( object sender , RoutedEventArgs e )
{
2019-08-26 16:11:00 +02:00
if ( ! ( e . OriginalSource is MenuItem twi ) ) return ;
2016-06-27 01:45:38 +02:00
2019-08-26 16:11:00 +02:00
var selectedItem = treeview_Goals . SelectedItem as SupportConceptGoalTreeItem ;
2019-08-06 13:08:15 +02:00
2019-08-26 16:11:00 +02:00
switch ( twi . Header )
{
case "Neues individuelles Ziel" :
2019-08-06 13:08:15 +02:00
if ( _SelectedGoalTreeNode ! = null )
{
2019-08-26 16:11:00 +02:00
ViewModel . AddTreeItemWithControl ( selectedItem , ValueListEntryType . SupportConceptIndividualGoalCategoryType , "Ziel hinzufügen" ) ;
2019-08-06 13:08:15 +02:00
}
2019-08-26 16:11:00 +02:00
break ;
case "Neue individuelle Maßnahme" :
if ( _SelectedGoalTreeNode ! = null )
{
ViewModel . AddTreeItemWithControl ( selectedItem , ValueListEntryType . SupportConceptIndividualGoalType , "Maßnahme hinzufügen" ) ;
}
break ;
case "Löschen" :
2016-06-27 01:45:38 +02:00
if ( selectedItem ! = null )
{
var zielOderMassnahme = selectedItem . GoalEntryVM . Type = = ValueListEntryType . SupportConceptGoalCategoryType | | selectedItem . GoalEntryVM . Type = = ValueListEntryType . SupportConceptIndividualGoalCategoryType ? "das Ziel" : "die Maßnahme" ;
var pluralendung = zielOderMassnahme . Equals ( "das Ziel" ) ? "en" : "n" ;
if ( MessageBox . Show ( "ACHTUNG: Das Löschen von " + zielOderMassnahme . Substring ( 4 ) + pluralendung + " kann nicht rückgängig gemacht werden.\n" +
2019-08-26 16:11:00 +02:00
"Alle verknüpften Eintragungen in der Zeiterfassung bleiben erhalten.\n\n" +
"Wollen Sie " + zielOderMassnahme + " '" + selectedItem . GoalEntryVM ? . DisplayName + "' wirklich löschen?" , "Löschen bestätigen" , MessageBoxButton . YesNo , MessageBoxImage . Question ) = = MessageBoxResult . Yes )
2016-06-27 01:45:38 +02:00
{
ViewModel . DeleteIndividualGoal ( selectedItem ) ;
}
}
2019-08-26 16:11:00 +02:00
break ;
case "Bearbeiten" :
if ( selectedItem ! = null )
ViewModel . EditTreeItem ( selectedItem . GoalEntryVM ) ;
break ;
2016-06-27 01:45:38 +02:00
}
}
2019-08-26 16:11:00 +02:00
2016-06-27 01:45:38 +02:00
private void ContextMenuGoals_Opened ( object sender , RoutedEventArgs e )
{
if ( e . OriginalSource is ContextMenu )
{
var menu = e . OriginalSource as ContextMenu ;
var goal = treeview_Goals . SelectedItem as SupportConceptGoalTreeItem ;
foreach ( var menuitem in menu . Items . OfType < MenuItem > ( ) . Select ( item = > item ) )
{
2019-08-26 16:11:00 +02:00
if ( menuitem . Header . Equals ( "Bearbeiten" ) )
2016-06-27 01:45:38 +02:00
{
menuitem . IsEnabled = goal ! = null & & ( goal . GoalType . Equals ( ValueListEntryType . SupportConceptIndividualGoalCategoryType ) | | goal . GoalType . Equals ( ValueListEntryType . SupportConceptIndividualGoalType ) ) ;
}
else if ( menuitem . Header . Equals ( "Neues individuelles Ziel" ) | | menuitem . Header . Equals ( "Neue individuelle Maßnahme" ) )
{
menuitem . IsEnabled = goal ! = null & & ( goal . GoalType . Equals ( ValueListEntryType . SupportConceptIndividualGoalCategoryType ) | | goal . GoalType . Equals ( ValueListEntryType . SupportConceptGoalCategoryType ) ) ;
}
else if ( menuitem . Header . Equals ( "Löschen" ) )
{
menuitem . IsEnabled = goal ! = null & & ( goal . GoalType . Equals ( ValueListEntryType . SupportConceptIndividualGoalCategoryType ) | | goal . GoalType . Equals ( ValueListEntryType . SupportConceptIndividualGoalType ) ) ;
}
2024-10-21 13:27:52 +02:00
if ( ! BeWoApp . LoggedOnUser . HasRight ( UserRightType . SupportConcept_AllowEditGoals ) )
{
menuitem . IsEnabled = false ;
}
2016-06-27 01:45:38 +02:00
}
}
}
#endregion
private void CboServiceCategory_OnInitialized ( object sender , EventArgs e )
{
var cbo = sender as ComboBoxEdit ;
if ( cbo ! = null )
{
Cache . GetInstance ( ) . GetServiceCategoryDescriptionDict (
cb = > cbo . Dispatch ( delegate
{
2019-08-06 13:08:15 +02:00
cbo . ItemsSource = cb . Keys . Where ( cat = > cat . ScopeType = = ScopeTypeId . Global ) . ToList ( ) ;
2016-06-27 01:45:38 +02:00
} ) ) ;
}
}
private void ButtonInfo_OnClick ( object sender , RoutedEventArgs e )
{
var btn = sender as Button ;
2019-08-06 13:08:15 +02:00
var bc = btn . TemplatedParent as ButtonContainer ;
2016-06-27 01:45:38 +02:00
if ( bc ! = null )
{
var bi = bc . Content as ButtonInfo ;
if ( bi ! = null )
{
var vm = bi . Tag as SupportConceptApprovalPeriodVM ;
if ( vm ! = null )
{
vm . ServiceCategory = null ;
}
}
}
}
private void Popupedit_employee_OnPreviewMouseDoubleClick ( object sender , MouseButtonEventArgs e )
{
// EmployeeView
if ( ! BeWoUtils . CheckPopupEditClickableSpace ( ( PopUpEdit ) sender , e ) | | ViewModel . Originator = = null | | ! BeWoApp . LoggedOnUser . HasRight ( UserRightType . EmployeeView_View ) )
{
return ;
}
VMFactory . CreateEmployeeVMAsync ( ViewModel . Originator . EmployeeOid ,
cb = > this . Dispatch (
2019-08-06 13:08:15 +02:00
( ) = > BeWoUtils . OpenModalViewWindow < EmployeeVM , EmployeeDC , SupportConceptView > ( cb , this ,
2016-06-27 01:45:38 +02:00
( ) = > this . Dispatch ( ( ) = > BeWoUtils . UpdateAllViews ( ViewModel . Originator ) ) ) ) ) ;
}
private void Popupedit_customer_OnPreviewMouseDoubleClick ( object sender , MouseButtonEventArgs e )
{
// CustomerView
if ( ! BeWoUtils . CheckPopupEditClickableSpace ( ( PopUpEdit ) sender , e ) | | ViewModel . Customer = = null | | ! BeWoApp . LoggedOnUser . HasRight ( UserRightType . CustomerView_View ) )
{
return ;
}
VMFactory . CreateCustomerVMAsync ( ViewModel . Customer . CustomerOid ,
cb = > this . Dispatch (
2019-08-06 13:08:15 +02:00
( ) = > BeWoUtils . OpenModalViewWindow < CustomerVM , CustomerDC , SupportConceptView > ( cb , this ,
2016-06-27 01:45:38 +02:00
( ) = > this . Dispatch ( ( ) = > BeWoUtils . UpdateAllViews ( ViewModel . Customer ) ) ) ) ) ;
}
private void Popupedit_costBearerContactPersonSearch_OnPreviewMouseDoubleClick ( object sender , MouseButtonEventArgs e )
{
var contactPerson = ( ( SupportConceptCostBearerRelVM ) tabcontrol_costbearers . SelectedItem ) . CostBearerContactPerson ;
if ( ! BeWoUtils . CheckPopupEditClickableSpace ( ( PopUpEdit ) sender , e ) | | contactPerson = = null | | ! BeWoApp . LoggedOnUser . HasRight ( UserRightType . PersonView_View ) )
{
return ;
}
VMFactory . CreatePersonVMAsync ( contactPerson . PersonOid ,
cb = > this . Dispatch (
2019-08-06 13:08:15 +02:00
( ) = > BeWoUtils . OpenModalViewWindow < PersonVM , PersonDC , SupportConceptView > ( cb , this ,
2016-06-27 01:45:38 +02:00
( ) = > this . Dispatch ( ( ) = > BeWoUtils . UpdateAllViews ( contactPerson ) ) , personSavedOrUpdated : _PersonModalPopUp_PersonSavedOrUpdated ) ) ) ;
}
private void DoubleClickHandler ( object sender , MouseButtonEventArgs e )
{
var selectedEmployee = ( ( ListBoxItem ) sender ) . Content as CompactEmployeeDC ;
if ( selectedEmployee = = null | | ! BeWoApp . LoggedOnUser . HasRight ( UserRightType . EmployeeView_View ) )
{
return ;
}
VMFactory . CreateEmployeeVMAsync ( selectedEmployee . EmployeeOid ,
cb = > this . Dispatch (
( ) = > BeWoUtils . OpenModalViewWindow < EmployeeVM , EmployeeDC , SupportConceptView > ( cb , this ,
( ) = > this . Dispatch ( ( ) = > BeWoUtils . UpdateAllViews ( selectedEmployee ) ) ) ) ) ;
}
private void Control_OnPreviewMouseDoubleClick ( object sender , MouseButtonEventArgs e )
{
2019-08-06 13:08:15 +02:00
var label = sender as Label ;
2016-06-27 01:45:38 +02:00
var labelparent = label . Parent as StackPanel ;
2019-08-06 13:08:15 +02:00
var btn = labelparent . Children [ 0 ] as Button ;
var Employee = btn . Tag as CompactEmployeeDC ;
2016-06-27 01:45:38 +02:00
VMFactory . CreateEmployeeVMAsync ( Employee . EmployeeOid ,
cb = > this . Dispatch (
( ) = > BeWoUtils . OpenModalViewWindow < EmployeeVM , EmployeeDC , SupportConceptView > ( cb , this ,
( ) = > this . Dispatch ( ( ) = > BeWoUtils . UpdateAllViews ( Employee ) ) ) ) ) ;
}
2019-08-06 13:08:15 +02:00
private void ListItemGrid_OnLoaded ( object sender , RoutedEventArgs e )
{
var grid = sender as Grid ;
var vm = grid . DataContext as SupportConceptApprovalPeriodVM ;
2016-06-27 01:45:38 +02:00
2019-08-06 13:08:15 +02:00
if ( vm ! = null & & ! SupportConceptApprovalPeriodVM . ShowContactCountFields )
{
grid . Children [ grid . Children . Count - 2 ] . Visibility = Visibility . Collapsed ;
grid . Children [ grid . Children . Count - 3 ] . Visibility = Visibility . Collapsed ;
2016-06-27 01:45:38 +02:00
grid . Children [ grid . Children . Count - 4 ] . Visibility = Visibility . Collapsed ;
2019-08-06 13:08:15 +02:00
grid . Children [ grid . Children . Count - 5 ] . Visibility = Visibility . Collapsed ;
}
var gridControl = new GridControl ( ) ;
2016-06-27 01:45:38 +02:00
2023-06-22 21:23:09 +02:00
Grid . SetRow ( gridControl , 10 ) ;
2016-06-27 01:45:38 +02:00
Grid . SetColumn ( gridControl , 0 ) ;
2019-10-10 22:07:42 +02:00
Grid . SetColumnSpan ( gridControl , 7 ) ;
2016-06-27 01:45:38 +02:00
2019-08-06 13:08:15 +02:00
gridControl . Margin = new Thickness ( 3d ) ;
2016-06-27 01:45:38 +02:00
var itemsSourceBinding = new Binding ( "SupportConceptApprovalEmployeeRelations.VMList" ) { Source = grid . DataContext } ;
2019-08-06 13:08:15 +02:00
gridControl . SetBinding ( DataControlBase . ItemsSourceProperty , itemsSourceBinding ) ;
2016-06-27 01:45:38 +02:00
var gridControlVisibilityBinding = new Binding ( "SupportConceptApprovalEmployeeRelations.GridVisibility" ) { UpdateSourceTrigger = UpdateSourceTrigger . PropertyChanged , Source = grid . DataContext } ;
2019-08-06 13:08:15 +02:00
gridControl . SetBinding ( VisibilityProperty , gridControlVisibilityBinding ) ;
2017-04-03 13:07:06 +02:00
gridControl . IsVisibleChanged + = GridControl_IsVisibleChanged ;
2019-08-06 13:08:15 +02:00
var deleteColumn = new GridColumn { Header = "" , FixedWidth = true , Width = 24 , ReadOnly = true , CellTemplate = ( DataTemplate ) Resources [ "DeleteBtnBetreuungsschluesselDataTemplate" ] } ;
2016-06-27 01:45:38 +02:00
2019-08-06 13:08:15 +02:00
gridControl . Columns . Add ( deleteColumn ) ;
2016-06-27 01:45:38 +02:00
2022-11-25 15:22:38 +01:00
var employeeColumn = new GridColumn { Header = Translator . Translate ( "MitarbeiterSingular" ) , FieldName = "EmployeeString" , AllowEditing = DefaultBoolean . False , Width = 250 } ;
2016-06-27 01:45:38 +02:00
var allowEditingBetreuungsschluesselColumn = BeWoApp . HasLoggedOnUserRight ( new [ ] { UserRightType . EditAll , UserRightType . Betreuungsschluessel_Edit } ) ? DefaultBoolean . True : DefaultBoolean . False ;
2017-04-03 13:07:06 +02:00
var betreuungsschluesselColumn = new GridColumn { Name = "ColumnBSProzent" , Header = "Anteil an der Betreuung" , FieldName = "Betreuungsschluessel" , AllowEditing = allowEditingBetreuungsschluesselColumn , Width = 170 , EditSettings = new TextEditSettings { MaskUseAsDisplayFormat = true , MaskType = MaskType . Numeric , Mask = "########0.00" } } ;
//var betreuungsschluesselColumnAbsolut = new GridColumn { Name = "ColumnBSAbsolut", Header = "Betreuung in Minuten", FieldName = "Betreuungsschluessel", AllowEditing = allowEditingBetreuungsschluesselColumn, Width = 170, EditSettings = new TextEditSettings { MaskUseAsDisplayFormat = true, MaskType = MaskType.Numeric, Mask = "########0" } };
2019-08-06 13:08:15 +02:00
//betreuungsschluesselColumnAbsolut.Visible = false;
2016-06-27 01:45:38 +02:00
gridControl . Columns . Add ( employeeColumn ) ;
gridControl . Columns . Add ( betreuungsschluesselColumn ) ;
2017-04-03 13:07:06 +02:00
//gridControl.Columns.Add(betreuungsschluesselColumnAbsolut);
2016-06-27 01:45:38 +02:00
2019-08-06 13:08:15 +02:00
gridControl . View = new TableView { AutoWidth = false , ShowGroupPanel = false , ShowGroupedColumns = false , ShowTotalSummary = false , NavigationStyle = GridViewNavigationStyle . Cell } ;
2016-06-27 01:45:38 +02:00
2019-08-06 13:08:15 +02:00
grid . Children . Add ( gridControl ) ;
}
2016-06-27 01:45:38 +02:00
2017-04-03 13:07:06 +02:00
private void GridControl_IsVisibleChanged ( object sender , DependencyPropertyChangedEventArgs e )
{
2019-08-06 13:08:15 +02:00
if ( ( bool ) e . NewValue )
2017-04-03 13:07:06 +02:00
{
GridControl gc = sender as GridControl ;
var list = gc . ItemsSource as BindingList < SupportConceptApprovalPeriodEmployeeRelVM > ;
bool isAbsolute = false ;
if ( list ! = null & & list . Count > 0 )
{
isAbsolute = list [ 0 ] . IsAbsolut ;
}
if ( isAbsolute )
{
gc . Columns [ 2 ] . Header = "Betreuung in Minuten" ;
2019-08-06 13:08:15 +02:00
( ( TextEditSettings ) gc . Columns [ 2 ] . EditSettings ) . Mask = "########0" ;
2017-04-03 13:07:06 +02:00
}
else
{
gc . Columns [ 2 ] . Header = "Anteil an der Betreuung (%)" ;
( ( TextEditSettings ) gc . Columns [ 2 ] . EditSettings ) . Mask = "########0.00" ;
}
}
}
private void ChangeCostbearerBtn_Click ( object sender , RoutedEventArgs e )
2019-08-06 13:08:15 +02:00
{
supportConceptCostBearerRel2Change = ( SupportConceptCostBearerRelVM ) ( ( Button ) sender ) . Tag ;
isChangingCostbearer = true ;
2016-06-27 01:45:38 +02:00
2019-08-06 13:08:15 +02:00
popup_costbearer . IsOpen = true ;
}
2016-06-27 01:45:38 +02:00
2019-08-06 13:08:15 +02:00
private void button_checkAllGoals_Click ( object sender , RoutedEventArgs e )
{
CheckAllGoalTreeItems ( true ) ;
}
2016-06-27 01:45:38 +02:00
2019-08-06 13:08:15 +02:00
private void button_uncheckAllGoals_Click ( object sender , RoutedEventArgs e )
{
CheckAllGoalTreeItems ( false ) ;
}
2016-06-27 01:45:38 +02:00
2016-09-28 13:33:36 +02:00
private void button_aufklappenAllGoals_Click ( object sender , RoutedEventArgs e )
{
SwitchAllGoalTreeItems ( true ) ;
}
private void button_zuklappenAllGoals_Click ( object sender , RoutedEventArgs e )
{
SwitchAllGoalTreeItems ( false ) ;
}
2019-08-06 13:08:15 +02:00
2016-09-28 13:33:36 +02:00
private void button_checkAllLeistungen_Click ( object sender , RoutedEventArgs e )
{
CheckAllLeistungTreeItems ( true ) ;
}
private void button_uncheckAllLeistungen_Click ( object sender , RoutedEventArgs e )
{
CheckAllLeistungTreeItems ( false ) ;
}
private void button_aufklappenAllLeistungen_Click ( object sender , RoutedEventArgs e )
{
SwitchAllLeistungTreeItems ( true ) ;
}
private void button_zuklappenAllLeistungen_Click ( object sender , RoutedEventArgs e )
{
SwitchAllLeistungTreeItems ( false ) ;
}
private void CheckAllLeistungTreeItems ( bool check )
{
var allItems = treeview_serviceAccountings . ItemsSource as IList < ServiceCategoryTreeItem > ;
foreach ( var item in allItems )
{
item . IsChecked = check ;
}
}
private void SwitchAllLeistungTreeItems ( bool check )
2019-08-06 13:08:15 +02:00
{
2016-09-28 13:33:36 +02:00
Style stylee = new Style
{
TargetType = typeof ( TreeViewItem )
} ;
2019-08-06 13:08:15 +02:00
stylee . Setters . Add ( new Setter ( TreeViewItem . IsExpandedProperty , check ) ) ;
treeview_serviceAccountings . ItemContainerStyle = stylee ;
2016-09-28 13:33:36 +02:00
}
private void SwitchAllGoalTreeItems ( bool check )
{
Style stylee = new Style
{
TargetType = typeof ( TreeViewItem )
} ;
stylee . Setters . Add ( new Setter ( TreeViewItem . IsExpandedProperty , check ) ) ;
treeview_Goals . ItemContainerStyle = stylee ;
}
2019-08-06 13:08:15 +02:00
private void CheckAllGoalTreeItems ( bool check )
{
2020-08-17 15:50:00 +02:00
foreach ( var item in treeview_Goals . ItemsSource )
2019-08-06 13:08:15 +02:00
{
2020-08-17 15:50:00 +02:00
( ( SupportConceptGoalTreeItem ) item ) . IsChecked = check ;
2019-08-06 13:08:15 +02:00
}
}
2016-06-27 01:45:38 +02:00
private void button_openAddBetreuungsschluessel_Click ( object sender , RoutedEventArgs e )
{
popup_newBetreuungsschluessel . IsOpen = true ;
2019-08-06 13:08:15 +02:00
var btn = ( Button ) sender ;
var grid = ( Grid ) btn . Parent ;
var border = ( Border ) grid . Parent ;
var contentPresenter = ( ContentPresenter ) border . TemplatedParent ;
2016-06-27 01:45:38 +02:00
SelectedApprovalPeriodVM = ( SupportConceptApprovalPeriodVM ) contentPresenter . Content ;
2019-08-06 13:08:15 +02:00
if ( SelectedApprovalPeriodVM ! = null )
{
bool isabsolute = false ;
2017-04-03 13:07:06 +02:00
2019-08-06 13:08:15 +02:00
if ( SelectedApprovalPeriodVM . SupportConceptApprovalEmployeeRelations . VMList . Count = = 0 )
{
RadioAbsolPro . Visibility = Visibility . Visible ;
RadioProzent . IsChecked = true ;
SelectedApprovalPeriodVM . SupportConceptApprovalEmployeeRelations . NewVM . Betreuungsschluessel = 100 ;
2017-04-03 13:07:06 +02:00
2019-08-06 13:08:15 +02:00
}
else
{
2016-11-08 13:50:58 +01:00
RadioAbsolPro . Visibility = Visibility . Collapsed ;
2019-08-06 13:08:15 +02:00
2017-04-03 13:07:06 +02:00
if ( SelectedApprovalPeriodVM . SupportConceptApprovalEmployeeRelations . VMList . Last ( ) . IsAbsolut )
{
isabsolute = true ;
2019-08-06 13:08:15 +02:00
2016-11-08 13:50:58 +01:00
SelectedApprovalPeriodVM . SupportConceptApprovalEmployeeRelations . NewVM . IsAbsolut = true ;
2017-10-11 14:43:49 +02:00
//var cbRelVM = this.tabcontrol_costbearers.SelectedItem as SupportConceptCostBearerRelVM;
//var actual = cbRelVM.ApprovalPeriodList.VMList.OrderByDescending(i => i.StartDate).FirstOrDefault();
2016-11-08 13:50:58 +01:00
2017-04-03 13:07:06 +02:00
decimal max = 0 ;
2017-10-11 14:43:49 +02:00
if ( SelectedApprovalPeriodVM . ApprovedBEPerInterval . HasValue )
{
max = SelectedApprovalPeriodVM . ApprovedBEPerInterval . Value * 60 ;
editAbsolut . MaxValue = max ;
2019-08-06 13:08:15 +02:00
}
2016-11-08 13:50:58 +01:00
2019-08-06 13:08:15 +02:00
var alt =
SelectedApprovalPeriodVM . SupportConceptApprovalEmployeeRelations . VMList . Sum (
s = > s . Betreuungsschluessel ) ;
2016-11-08 13:50:58 +01:00
2019-08-06 13:08:15 +02:00
if ( alt > max )
alt = max ;
2016-11-08 13:50:58 +01:00
2017-04-03 13:07:06 +02:00
SelectedApprovalPeriodVM . SupportConceptApprovalEmployeeRelations . NewVM . Betreuungsschluessel = ( int ) ( max - alt ) ;
2016-11-08 13:50:58 +01:00
2019-08-06 13:08:15 +02:00
}
else
{
2016-11-08 13:50:58 +01:00
SelectedApprovalPeriodVM . SupportConceptApprovalEmployeeRelations . NewVM . IsAbsolut = false ;
var alt = SelectedApprovalPeriodVM . SupportConceptApprovalEmployeeRelations . VMList . Sum ( s = > s . Betreuungsschluessel ) ;
if ( alt > 100 )
alt = 100 ;
SelectedApprovalPeriodVM . SupportConceptApprovalEmployeeRelations . NewVM . Betreuungsschluessel = 100 - alt ;
2019-08-06 13:08:15 +02:00
}
}
if ( isabsolute )
{
LabelProzentual . Visibility = Visibility . Collapsed ;
LabelAbsolut . Visibility = Visibility . Visible ;
2016-11-08 13:50:58 +01:00
2019-08-06 13:08:15 +02:00
editProzentual . Visibility = Visibility . Collapsed ;
editAbsolut . Visibility = Visibility . Visible ;
2017-04-03 13:07:06 +02:00
2019-08-06 13:08:15 +02:00
}
else
{
LabelProzentual . Visibility = Visibility . Visible ;
LabelAbsolut . Visibility = Visibility . Collapsed ;
2017-04-03 13:07:06 +02:00
2019-08-06 13:08:15 +02:00
editProzentual . Visibility = Visibility . Visible ;
editAbsolut . Visibility = Visibility . Collapsed ;
}
}
2016-06-27 01:45:38 +02:00
}
private void button_addBetreuungsschluessel_Click ( object sender , RoutedEventArgs e )
{
if ( SelectedApprovalPeriodVM ! = null & & Validate ( groupbox_newBetreuungsschluessel ) )
{
2016-11-08 13:50:58 +01:00
if ( SelectedApprovalPeriodVM . SupportConceptApprovalEmployeeRelations . NewVM . IsAbsolut )
{
var alt = SelectedApprovalPeriodVM . SupportConceptApprovalEmployeeRelations . VMList . Sum ( s = > s . Betreuungsschluessel ) ;
2017-04-03 13:07:06 +02:00
if ( editAbsolut . MaxValue . HasValue )
2016-11-08 13:50:58 +01:00
{
2017-04-03 13:07:06 +02:00
if ( alt +
SelectedApprovalPeriodVM . SupportConceptApprovalEmployeeRelations . NewVM . Betreuungsschluessel >
editAbsolut . MaxValue )
{
MessageBox . Show ( String . Format ( "Die Summe der Anteile liegt bei über {0:0} Minuten. Hinzufügen nicht möglich." , editAbsolut . MaxValue ) , "Fehler" , MessageBoxButton . OK , MessageBoxImage . Warning ) ;
return ;
}
}
2016-11-08 13:50:58 +01:00
}
else
2016-06-27 01:45:38 +02:00
{
2016-11-08 13:50:58 +01:00
var alt = SelectedApprovalPeriodVM . SupportConceptApprovalEmployeeRelations . VMList . Sum ( s = > s . Betreuungsschluessel ) ;
if ( alt + SelectedApprovalPeriodVM . SupportConceptApprovalEmployeeRelations . NewVM . Betreuungsschluessel > 100 )
{
MessageBox . Show ( "Die Summe der Anteile liegt bei über 100%. Hinzufügen nicht möglich." , "Fehler" , MessageBoxButton . OK , MessageBoxImage . Warning ) ;
return ;
2019-08-06 13:08:15 +02:00
}
2016-06-27 01:45:38 +02:00
}
2019-08-06 13:08:15 +02:00
2016-06-27 01:45:38 +02:00
SelectedApprovalPeriodVM . SupportConceptApprovalEmployeeRelations . AddNewVMToList ( ) ;
}
SelectedApprovalPeriodVM = null ;
popup_newBetreuungsschluessel . IsOpen = false ;
2016-11-08 13:50:58 +01:00
2016-06-27 01:45:38 +02:00
}
private void button_cancelBetreuungsschluessel_Click ( object sender , RoutedEventArgs e )
{
popup_newBetreuungsschluessel . IsOpen = false ;
SelectedApprovalPeriodVM = null ;
}
private void popupedit_betreuungsschluessel_PopUpClick ( object sender , RoutedEventArgs e )
{
popup_employee2 . IsOpen = true ;
}
private void Popupedit_betreuungsschluessel_OnPreviewMouseDoubleClick ( object sender , MouseButtonEventArgs e )
{
2019-08-06 13:08:15 +02:00
if ( ! BeWoUtils . CheckPopupEditClickableSpace ( ( PopUpEdit ) sender , e ) | |
SelectedApprovalPeriodVM . SupportConceptApprovalEmployeeRelations . NewVM . Employee = = null | |
2016-06-27 01:45:38 +02:00
! BeWoApp . LoggedOnUser . HasRight ( UserRightType . EmployeeView_View ) )
{
return ;
}
VMFactory . CreateEmployeeVMAsync ( SelectedApprovalPeriodVM . SupportConceptApprovalEmployeeRelations . NewVM . Employee . EmployeeOid ,
cb = > this . Dispatch (
( ) = > BeWoUtils . OpenModalViewWindow < EmployeeVM , EmployeeDC , SupportConceptView > ( cb , this ,
( ) = > this . Dispatch ( ( ) = > BeWoUtils . UpdateAllViews ( SelectedApprovalPeriodVM . SupportConceptApprovalEmployeeRelations . NewVM . Employee ) ) ) ) ) ;
}
private void EmployeeSearchView_EmployeeSelected2 ( object sender , EventArgs < CompactEmployeeDC > e )
{
if ( SelectedApprovalPeriodVM . SupportConceptApprovalEmployeeRelations . VMList . Any ( a = > a . Employee . EmployeeOid . Equals ( e . Data . EmployeeOid ) ) )
{
2022-11-25 15:22:38 +01:00
MessageBox . Show ( "Sie können " + Translator . Translate ( "einen Betreuer" ) + " nicht mehrmals hinzufügen." , "Ungültige Auswahl" , MessageBoxButton . OK , MessageBoxImage . Warning ) ;
2016-06-27 01:45:38 +02:00
return ;
}
popup_employee2 . IsOpen = false ;
SelectedApprovalPeriodVM . SupportConceptApprovalEmployeeRelations . NewVM . Employee = e . Data ;
popup_newBetreuungsschluessel . Focus ( ) ;
}
public event PropertyChangedEventHandler PropertyChanged ;
[NotifyPropertyChangedInvocator]
protected virtual void OnPropertyChanged ( string propertyName )
{
var handler = PropertyChanged ;
if ( handler ! = null ) handler ( this , new PropertyChangedEventArgs ( propertyName ) ) ;
}
private void DeleteBetreuungsschluesselButton_Click ( object sender , RoutedEventArgs e )
{
2019-08-06 13:08:15 +02:00
var btn = ( Button ) sender ;
var currentObject = ( SupportConceptApprovalPeriodEmployeeRelVM ) ( ( EditGridCellData ) btn . Tag ) . RowData . Row ;
2016-06-27 01:45:38 +02:00
var supportConceptCostBearerRel = ViewModel . CostBearerRelations . VMList . FirstOrDefault ( f = > f . ApprovalPeriodList . VMList . Any ( a = > a . SupportConceptApprovalEmployeeRelations . VMList . Contains ( currentObject ) ) ) ;
var approvalPeriod = supportConceptCostBearerRel . ApprovalPeriodList . VMList . FirstOrDefault ( f = > f . SupportConceptApprovalEmployeeRelations . VMList . Contains ( currentObject ) ) ;
approvalPeriod . SupportConceptApprovalEmployeeRelations . VMList . Remove ( currentObject ) ;
var abc = SelectedApprovalPeriodVM ;
}
2016-11-08 13:50:58 +01:00
private void ToggledProz_OnChecked ( object sender , RoutedEventArgs e )
{
LabelProzentual . Visibility = Visibility . Visible ;
LabelAbsolut . Visibility = Visibility . Collapsed ;
editProzentual . Visibility = Visibility . Visible ;
editAbsolut . Visibility = Visibility . Collapsed ;
SelectedApprovalPeriodVM . SupportConceptApprovalEmployeeRelations . NewVM . IsAbsolut = false ;
2017-04-03 13:07:06 +02:00
SelectedApprovalPeriodVM . SupportConceptApprovalEmployeeRelations . NewVM . Betreuungsschluessel = 100 ;
2016-11-08 13:50:58 +01:00
}
private void ToggledAbsol_OnChecked ( object sender , RoutedEventArgs e )
{
var cbRelVM = this . tabcontrol_costbearers . SelectedItem as SupportConceptCostBearerRelVM ;
2017-10-11 14:43:49 +02:00
2019-08-06 13:08:15 +02:00
var actual = SelectedApprovalPeriodVM ? ? cbRelVM . ApprovalPeriodList . VMList . OrderByDescending ( i = > i . StartDate ) . FirstOrDefault ( ) ;
2016-11-08 13:50:58 +01:00
2017-04-03 13:07:06 +02:00
if ( actual . ApprovedBEPerInterval . HasValue )
{
editAbsolut . MaxValue = actual . ApprovedBEPerInterval * 60 ;
2019-08-06 13:08:15 +02:00
2017-04-03 13:07:06 +02:00
}
2016-11-08 13:50:58 +01:00
2017-04-03 13:07:06 +02:00
SelectedApprovalPeriodVM . SupportConceptApprovalEmployeeRelations . NewVM . Betreuungsschluessel = editAbsolut . MaxValue ? ? 0 ;
2016-11-08 13:50:58 +01:00
LabelProzentual . Visibility = Visibility . Collapsed ;
LabelAbsolut . Visibility = Visibility . Visible ;
editProzentual . Visibility = Visibility . Collapsed ;
editAbsolut . Visibility = Visibility . Visible ;
SelectedApprovalPeriodVM . SupportConceptApprovalEmployeeRelations . NewVM . IsAbsolut = true ;
}
2019-02-28 12:38:29 +01:00
private void Tabitem_tasks_OnSelected ( object sender , RoutedEventArgs e )
{
2019-08-06 13:08:15 +02:00
if ( ViewModel . IsNew )
2019-02-28 12:38:29 +01:00
{
tabitem_grid_tasks . Visibility = Visibility . Collapsed ;
MessageBox . Show ( "Bevor zu einem Datensatz Aufgaben angelegt werden können, muss dieser gespeichert werden." , "Erst speichern bitte" , MessageBoxButton . OK , MessageBoxImage . Information ) ;
return ;
}
tabitem_grid_tasks . Visibility = Visibility . Visible ;
}
2019-08-06 13:08:15 +02:00
private void RadioButton_Checked ( object sender , RoutedEventArgs e )
{
var check = ( RadioButton ) sender ;
var selected = ( SupportConceptApprovalPeriodVM ) check . Tag ;
2019-08-26 16:11:00 +02:00
2019-08-06 13:08:15 +02:00
switch ( check . Name )
{
case "RadioButtonBudget" :
selected . Bewilligungsart = Bewilligungsart . Budget ;
break ;
case "RadioButtonDirekt" :
selected . Bewilligungsart = Bewilligungsart . Direkt ;
break ;
}
}
2020-08-17 15:50:00 +02:00
private void BtnEditRating_Click ( object sender , RoutedEventArgs e )
{
var btn = sender as Button ;
if ( btn ! = null )
{
var rating = btn . Tag as RatingVM ;
if ( rating ! = null )
{
var ratingCopy = CopyRatingVM ( rating ) ;
var changed = EditRating ( ratingCopy ) ;
if ( changed ! = null )
{
rating . StartDate = changed . StartDate ;
rating . DisplayName = changed . DisplayName ;
rating . Notice = changed . Notice ;
rating . RTFNotice = changed . RTFNotice ;
rating . RatingId = changed . RatingId ;
rating . GoalRatingList . VMList . Clear ( ) ;
foreach ( var goalRatingVm in changed . GoalRatingList . VMList )
{
rating . GoalRatingList . VMList . Add ( goalRatingVm ) ;
}
2020-11-10 02:25:15 +01:00
2020-08-17 15:50:00 +02:00
}
}
}
}
private RatingVM CopyRatingVM ( RatingVM rating )
{
2020-10-27 12:29:59 +01:00
RatingDC dc = rating . DataContract ;
2020-11-10 02:25:15 +01:00
//if (rating.IsNew)
//{
2020-10-27 12:29:59 +01:00
dc = rating . CommitToDataContract ( ) ;
2020-11-10 02:25:15 +01:00
//}
2020-10-27 12:29:59 +01:00
var newVm = new RatingVM ( dc ) ;
2020-08-17 15:50:00 +02:00
return newVm ;
}
2022-10-10 12:57:34 +02:00
2020-08-17 15:50:00 +02:00
private void BtnDeleteRating_Click ( object sender , RoutedEventArgs e )
{
var btn = sender as Button ;
if ( btn ! = null )
{
var rating = btn . Tag as RatingVM ;
ViewModel . Ratings . VMList . Remove ( rating ) ;
}
}
private void BtnAddRating_Click ( object sender , RoutedEventArgs e )
{
var rating = new RatingVM ( new RatingDC ( ) ) ;
rating . StartDate = DateTime . Now ;
foreach ( var goal in ViewModel . GetSelectedGoals ( ) )
{
if ( goal . Type = = ValueListEntryType . SupportConceptGoalCategoryType | |
goal . Type = = ValueListEntryType . SupportConceptIndividualGoalCategoryType )
{
2020-08-20 18:35:33 +02:00
AddIfNotExist ( rating , goal ) ;
}
else
{
//Find Parent Goal
if ( goal . ParentOid . HasValue )
{
var p = ViewModel . CombinedGoals . VMList . FirstOrDefault ( vm = > vm . DataContract . ValueListEntryOid = = goal . ParentOid ) ;
if ( p ! = null )
{
AddIfNotExist ( rating , p . DataContract ) ;
}
}
2020-08-17 15:50:00 +02:00
}
}
var savedRating = EditRating ( rating ) ;
if ( savedRating ! = null )
{
ViewModel . Ratings . VMList . Add ( savedRating ) ;
}
}
2020-08-20 18:35:33 +02:00
private void AddIfNotExist ( RatingVM rating , ValueListEntryDC goal )
{
if ( ! rating . GoalRatingList . VMList . Any ( vm = > vm . GoalEntry . Equals ( goal ) ) )
{
var gr = rating . GoalRatingList . VMList . AddNew ( ) ;
gr . GoalEntry = goal ;
}
}
2020-08-17 15:50:00 +02:00
private RatingVM EditRating ( RatingVM vm )
{
var control = new RatingEditView ( ) ;
control . InitView ( vm ) ;
var beWoWindow = new BeWoWindow
{
rootGroupBox = { Header = "Bewertung bearbeiten" } ,
Height = this . Height ,
Width = 1000 ,
MinWidth = 550 ,
WindowStartupLocation = WindowStartupLocation . CenterOwner ,
GroupBoxContent = control ,
Owner = BeWoApp . CurrentBeWo . MainWindow
} ;
bool saved = false ;
control . ButtonSavedClicked + = ( ) = >
{
saved = true ;
beWoWindow . Close ( ) ;
} ;
control . ButtonCancelClicked + = ( ) = >
{
beWoWindow . Close ( ) ;
} ;
beWoWindow . ShowDialog ( ) ;
if ( ! saved )
{
return null ;
}
return control . ViewModel ;
}
public void AnimateOpacity ( double pOpacitiy , double pDuration )
{
// System.Windows.Media.TransformGroup group = this.DetailFrame.RenderTransform as System.Windows.Media.TransformGroup;
// System.Windows.Media.ScaleTransform scale = group.Children[0] as System.Windows.Media.ScaleTransform;
var lAnimation = new DoubleAnimation
{
From = root . Opacity ,
To = pOpacitiy ,
Duration = TimeSpan . FromMilliseconds ( pDuration )
} ;
// lAnimation.From = scale.ScaleX;
// lAnimation.To = pOpacitiy;
root . BeginAnimation ( OpacityProperty , lAnimation ) ;
// scale.BeginAnimation(System.Windows.Media.ScaleTransform.ScaleXProperty, lAnimation);
// scale.BeginAnimation(System.Windows.Media.ScaleTransform.ScaleYProperty, lAnimation);
}
private void AuswertungTab_OnSelected ( object sender , RoutedEventArgs e )
{
//RatingView.UpdateControl();
}
private void TxtSearchGoals_OnEditValueChanged ( object sender , EditValueChangedEventArgs e )
{
FilterTreeItems ( ) ;
}
private void FilterTreeItems ( )
{
String searchtext = TxtSearchGoals . Text ;
bool onlyChecked = chkShowSelectedGoals . IsChecked . HasValue & & chkShowSelectedGoals . IsChecked . Value ;
foreach ( var goal in treeview_Goals . Items )
{
SetTreeItemVisibility ( treeview_Goals . ItemContainerGenerator , goal as SupportConceptGoalTreeItem , searchtext , onlyChecked ) ;
//if (ig.Status != GeneratorStatus.ContainersGenerated)
//{
// return;
//}
//var n = ig.ContainerFromIndex(this.treeview_individualServiceAccountings.Items.Count - 1) as TreeViewItem;
//if (n != null)
//{
// n.IsSelected = true;
// new DispatcherTimer(
// TimeSpan.FromMilliseconds(200),
// DispatcherPriority.Background,
// (s1, e1) =>
// {
// ServiceCategoryTreeItem item = ig.ItemFromContainer(n) as ServiceCategoryTreeItem;
// this.EditItem(this.treeview_individualServiceAccountings, null, item);
// ((DispatcherTimer)s1).Stop();
// },
// this.Dispatcher).Start();
//}
//this.treeview_individualServiceAccountings.ItemContainerGenerator.StatusChanged -= this.ItemContainerGenerator_StatusChanged;
}
}
private void SetTreeItemVisibility ( ItemContainerGenerator ig , SupportConceptGoalTreeItem goal , string searchtext , bool onlyChecked )
{
2020-08-20 18:35:33 +02:00
2020-08-17 15:50:00 +02:00
var item = ig . ContainerFromItem ( goal ) as TreeViewItem ;
2020-08-20 18:35:33 +02:00
if ( item = = null )
{
treeview_Goals . UpdateLayout ( ) ;
item = ig . ContainerFromItem ( goal ) as TreeViewItem ;
}
2020-08-17 15:50:00 +02:00
if ( item = = null )
return ;
2020-08-20 18:35:33 +02:00
if ( item . ToString ( ) . ToLower ( ) . Contains ( "fussball" ) )
{
int test = 0 ;
}
2025-02-20 00:20:46 +01:00
if ( goal . Items = = null | | goal . Items . Count = = 0 )
2020-08-17 15:50:00 +02:00
{
if ( IsTreeItemVisible ( goal , searchtext , onlyChecked ) )
{
item . Visibility = Visibility . Visible ;
}
else
{
item . Visibility = Visibility . Collapsed ;
}
}
else
{
foreach ( var child in goal . Items )
{
SetTreeItemVisibility ( item . ItemContainerGenerator , child , searchtext , onlyChecked ) ;
}
if ( IsAtLeastOneChildVisible ( goal . Items , searchtext , onlyChecked ) )
{
item . Visibility = Visibility . Visible ;
}
else
{
if ( IsTreeItemVisible ( goal , searchtext , onlyChecked ) )
{
item . Visibility = Visibility . Visible ;
}
else
{
item . Visibility = Visibility . Collapsed ;
}
}
}
}
private bool IsTreeItemVisible ( SupportConceptGoalTreeItem goal , string searchtext , bool onlyChecked )
{
if ( onlyChecked & & ! goal . IsChecked & & goal . GoalType ! = ValueListEntryType . SupportConceptIndividualGoalType & & goal . GoalType ! = ValueListEntryType . SupportConceptIndividualGoalCategoryType )
{
return false ;
}
if ( ! String . IsNullOrEmpty ( searchtext ) & & ( String . IsNullOrEmpty ( goal . DetailDescription ) | | ! goal . DetailDescription . ToLower ( ) . Contains ( searchtext . ToLower ( ) ) ) )
{
return false ;
}
return true ;
}
private bool IsAtLeastOneChildVisible ( BindingList < SupportConceptGoalTreeItem > children , string searchtext , bool onlyChecked )
{
foreach ( var child in children )
{
bool visible = IsTreeItemVisible ( child , searchtext , onlyChecked ) | | IsAtLeastOneChildVisible ( child . Items , searchtext , onlyChecked ) ;
if ( visible )
{
return true ;
}
}
return false ;
}
private void ChkShowSelectedGoals_OnChecked ( object sender , RoutedEventArgs e )
{
FilterTreeItems ( ) ;
}
private void ChkShowSelectedGoals_OnUnchecked ( object sender , RoutedEventArgs e )
{
FilterTreeItems ( ) ;
}
2022-04-13 17:40:15 +02:00
private void popupedit_costBearerContactPersonSearch_DeleteClick ( object sender , RoutedEventArgs e )
{
var vm = tabcontrol_costbearers . SelectedItem as SupportConceptCostBearerRelVM ;
if ( vm ! = null )
{
vm . CostBearerContactPerson = null ;
}
}
2022-11-09 09:44:24 +01:00
private void linkPdfExport_Click ( object sender , RoutedEventArgs e )
{
var link = sender as Hyperlink ;
if ( link ! = null )
{
var rating = link . Tag as RatingVM ;
if ( rating ! = null & & rating . DataContract . RatingOid . HasValue )
{
var url = BeWoApp . SiteOfOrigin + "/ReportView.aspx"
+ "?scOid=" + ( this . ViewModel . DataContract . SupportConceptOid ? ? 0 )
+ "&rOid=" + ( rating . DataContract . RatingOid ? ? 0 )
+ "&type=" + Utils . EnumName ( ReportTypes . RatingReport ) ;
url = BeWoWpfUtils . GetHTMLEncodedURL ( url ) ;
link . NavigateUri = new Uri ( url ) ;
BeWoUtils . NavigateToReportUri ( ( sender as System . Windows . Documents . Hyperlink ) . NavigateUri . ToString ( ) , Translator . Translate ( "Bewertung" ) ) ;
}
}
}
2022-12-15 13:21:56 +01:00
2024-06-19 16:13:56 +02:00
private void ButtenImport_Click ( object sender , RoutedEventArgs e )
{
var ctrl = new HilfeplanImportView ( this . ViewModel . DataContract . SupportConceptOid ) ;
var beWoWindow = BeWoWindowBuilder . GetBeWoWindow ( Translator . Translate ( "Importiere Hilfeplan" ) , ctrl , this . Height , this . Width ) ;
ctrl . CloseButtonClicked + = ( ) = > beWoWindow . Close ( ) ;
beWoWindow . ShowDialog ( ) ;
2024-10-21 13:27:52 +02:00
if ( ctrl . ImportedSupportConcept ! = null )
{
AddMissingGoals ( ctrl . ImportedSupportConcept . Goals ) ;
2025-02-20 00:20:46 +01:00
FilterTreeItems ( ) ;
2024-10-21 13:27:52 +02:00
}
}
private void AddMissingGoals ( List < ValueListEntryDC > goals )
{
foreach ( var g in goals )
{
2025-01-13 10:10:44 +01:00
if ( ! g . ValueListEntryOid . HasValue )
2024-10-21 13:27:52 +02:00
{
2025-01-13 10:10:44 +01:00
if ( g . Parent ! = null )
2024-10-21 13:27:52 +02:00
{
2025-02-20 00:20:46 +01:00
//Prüfen, ob bereits vorhanden
var existingItem = FindGoalTreeItem ( ViewModel . CombinedGoalTree , g . TypeDescription ) ;
if ( existingItem = = null )
2025-01-13 10:10:44 +01:00
{
2025-02-20 00:20:46 +01:00
var parent = FindGoalTreeItem ( ViewModel . CombinedGoalTree , g . Parent . TypeDescription ) ;
if ( parent = = null & & g . Parent . ValueListEntryOid . HasValue )
{
//Bereich ist noch nicht vorhanden wurde aber serverseitig schon angelegt. Also hinzufügen
parent = ViewModel . AddTreeItem ( null , g . Parent . Type , g . Parent . TypeDescription , g . Parent . Abbreviation , "" , null ) ;
parent . GoalEntryVM . DataContract . ValueListEntryOid = g . Parent . ValueListEntryOid ;
parent . GoalEntryVM . IsNew = false ; // Sonst wird das Ziel noch mal gespeichert
//parent = FindGoalTreeItem(ViewModel.CombinedGoalTree, g.Parent.TypeDescription);
}
if ( parent ! = null )
{
ViewModel . AddTreeItem ( parent , g . Type , g . TypeDescription , g . Abbreviation , "" , null ) ;
}
2025-01-13 10:10:44 +01:00
}
2024-10-21 13:27:52 +02:00
}
2025-01-13 10:10:44 +01:00
2024-10-21 13:27:52 +02:00
}
}
2024-06-19 16:13:56 +02:00
}
2025-01-13 10:10:44 +01:00
private SupportConceptGoalTreeItem FindGoalTreeItem ( IList < SupportConceptGoalTreeItem > treeItems , String ziel )
2024-10-21 13:27:52 +02:00
{
if ( treeItems ! = null )
{
foreach ( var item in treeItems )
{
2025-01-13 10:10:44 +01:00
if ( item . GoalEntryVM . Description = = ziel )
2024-10-21 13:27:52 +02:00
{
return item ;
}
2025-01-13 10:10:44 +01:00
var p = FindGoalTreeItem ( item . Items , ziel ) ;
2024-10-21 13:27:52 +02:00
if ( p ! = null )
{
return p ;
}
}
}
return null ;
}
2024-12-19 17:13:03 +01:00
private void SortComboBox_Loaded ( object sender , RoutedEventArgs e )
{
var cb = sender as ComboBox ;
if ( cb ! = null )
{
//InitSortCombo(cb);
}
}
private void SortComboBox_SelectionChanged ( object sender , SelectionChangedEventArgs e )
{
var cb = sender as ComboBox ;
//if (cb != null)
//{
var cb2 = e . OriginalSource as DependencyObject ;
var sp2 = VisualTreeHelper . GetParent ( cb2 ) ;
//Finde ListView
var sp = cb . Parent as StackPanel ;
if ( sp2 = = sp )
{
int test = 0 ;
}
var g = sp . Parent as Grid ;
var gb = g . Parent as GroupBox ;
var lv = gb . Content as ListView ;
//lv.ItemsSource = null;
var c2s = cb . Tag as SupportConceptCostBearerRelVM ;
//var list = lv.ItemsSource as BindingList<SupportConceptApprovalPeriodVM>;
//lv.ItemsSource = null;
//if (cb.SelectedIndex == 0)
//{
// list.Sort((a, b) => a.StartDate.HasValue ? a.StartDate.Value.CompareTo(b.StartDate) : 0);
//}
//else
//{
// list.Sort((a, b) => b.StartDate.HasValue ? b.StartDate.Value.CompareTo(a.StartDate) : 0);
//}
//list.Sort((a, b) => b.StartDate.HasValue ? b.StartDate.Value.CompareTo(a.StartDate) : 0);
//lv.Items.SortDescriptions.Add(new SortDescription { PropertyName = "StartDate", Direction = ListSortDirection.Descending });
//lv.ItemsSource = c2s.ApprovalPeriodList.VMList;
//lv.ItemsSource.RaisePropertyChanged
//BeWoApp.AppSettings.LastBewilligungSortOrder = cb.SelectedIndex;
BeWoApp . SaveAppSettings ( ) ;
//}
}
2016-06-27 01:45:38 +02:00
}
public class ValueListEntryTypeToColorConverter : IValueConverter
{
public object Convert ( object value , Type targetType , object parameter , CultureInfo culture )
{
2019-08-06 13:08:15 +02:00
var type = ( ValueListEntryType ) value ;
2016-06-27 01:45:38 +02:00
if ( type . Equals ( ValueListEntryType . SupportConceptIndividualGoalCategoryType ) | | type . Equals ( ValueListEntryType . SupportConceptIndividualGoalType ) )
{
return new SolidColorBrush ( Colors . SteelBlue ) ;
}
return new SolidColorBrush ( Colors . Black ) ;
}
public object ConvertBack ( object value , Type targetType , object parameter , CultureInfo culture )
{
throw new NotImplementedException ( ) ;
}
}
2024-12-19 17:13:03 +01:00
2016-06-27 01:45:38 +02:00
}