2016-06-27 01:45:38 +02:00
using System ;
using System.Windows ;
using System.Windows.Controls ;
2024-10-22 11:40:46 +02:00
using System.Windows.Input ;
2016-06-27 01:45:38 +02:00
using System.Windows.Navigation ;
using BeWo.Core ;
using BeWo.Core.Service ;
2023-10-26 00:06:56 +02:00
using BeWo.SchulbegleitenderDienst.View ;
2016-06-27 01:45:38 +02:00
using BeWo.ServiceProxy ;
2016-12-08 14:17:41 +01:00
using BeWo.Validation ;
2016-06-27 01:45:38 +02:00
using BeWo.ViewModel ;
using BS.Shared ;
using BS.Shared.Core ;
using BS.Shared.DataContracts ;
2016-12-08 14:17:41 +01:00
using BS.Shared.DataContracts.Compact ;
2024-10-17 13:57:06 +02:00
using BS.Shared.DataContracts.GkvAbrechnung ;
2016-06-27 01:45:38 +02:00
using BS.Shared.Extensions ;
2018-11-22 14:05:45 +01:00
using BS.Shared.Translation ;
2016-06-27 01:45:38 +02:00
using DevExpress.Xpf.Grid ;
namespace BeWo.View.Detail
{
public partial class OrganisationView
{
private OrganisationVM _ViewModel ;
private GridControl grid_GroupBoxPersonGrid ;
public OrganisationView ( OrganisationVM pOrganisationVM )
{
InitializeComponent ( ) ;
ViewModel = pOrganisationVM ;
if ( pOrganisationVM . VarFields = = null | | pOrganisationVM . VarFields . VMList . Count = = 0 )
{
tabitem_varFields . Visibility = Visibility . Collapsed ;
}
tabitem_costbearer . Visibility = BeWoApp . LoggedOnUser . HasRight ( UserRightType . OrganisationView_AllowEditCostBearer ) ? Visibility . Visible : Visibility . Collapsed ;
2018-10-08 11:57:16 +02:00
if ( BeWoApp . Mandator ! = null & & BeWoApp . Mandator . AllowSbd )
{
tabitem_schuldienst . Visibility = Visibility . Visible ;
}
else
{
tabitem_schuldienst . Visibility = Visibility . Collapsed ;
}
2016-06-27 01:45:38 +02:00
2016-11-08 13:50:58 +01:00
comboBox_Function . ItemsSource = _ViewModel . Functions ;
2016-12-08 14:17:41 +01:00
Combobox_Rolle . ItemsSource = _ViewModel . RoleInOrganisations ;
2016-06-27 01:45:38 +02:00
if ( ! BeWoApp . LoggedOnUser . HasRight ( UserRightType . Organisation_AllowArchiving ) )
{
lblArchiviert . Visibility = Visibility . Hidden ;
chkArchiviert . Visibility = Visibility . Hidden ;
}
if ( ! BeWoApp . LoggedOnUser . HasRight ( UserRightType . DocumentsAllowViewAll ) & & ! BeWoApp . LoggedOnUser . HasRight ( UserRightType . DokumenteOrganisationen ) )
{
tabitem_documents . Visibility = Visibility . Collapsed ;
}
2024-10-17 13:57:06 +02:00
2024-10-22 11:40:46 +02:00
#if ! DEBUG
2024-10-17 13:57:06 +02:00
label_verfahrensstufe . Visibility = Visibility . Collapsed ;
radiobuttons_verfahrensstufe . Visibility = Visibility . Collapsed ;
#endif
2016-06-27 01:45:38 +02:00
}
public event EventHandler < EventArgs < OrganisationVM > > OrganisationSavedOrUpdated ;
public override bool IsDirty
{
get
{
return ViewModel ! = null & & ViewModel . IsDirty ;
}
}
public override string Title
{
get
{
return "Organisationen" ;
}
}
internal OrganisationVM ViewModel
{
get
{
return _ViewModel ;
}
set
{
_ViewModel = value ;
DataContext = value ;
2019-09-27 15:55:01 +02:00
2018-11-22 14:05:45 +01:00
if ( tabitem_schuldienst . Content ! = null )
{
2019-09-27 15:55:01 +02:00
if ( tabitem_schuldienst . Content is StundenplanView view )
2018-11-22 14:05:45 +01:00
{
2019-09-27 15:55:01 +02:00
view . ViewModel = value . Arbeitszeiten ;
2018-11-22 14:05:45 +01:00
view . RefreshView ( ) ;
}
}
2016-06-27 01:45:38 +02:00
}
}
protected override UserRightType [ ] GetSaveDemands ( )
{
return ViewModel . IsNew ? new [ ] { UserRightType . CreateAll , UserRightType . OrganisationView_Create } : new [ ] { UserRightType . EditAll , UserRightType . OrganisationView_Edit } ;
}
protected override void Save ( )
{
var lDC = ViewModel . CommitToDataContract ( ) ;
if ( ViewModel . IsNew )
{
IsDoneWithInsertOrUpdate = false ;
ServiceFacade . DoCustomerServiceAsync ( s = > s . InsertNewOrganisation ( lDC ) , ReloadViewModel ) ;
}
else
{
IsDoneWithInsertOrUpdate = false ;
ServiceFacade . DoCustomerServiceAsync ( s = > s . UpdateOrganisation ( lDC ) , ReloadViewModel ) ;
}
Cache . GetInstance ( ) . ClearSupportConceptTree ( ) ;
BeWoApp . MainControl . ResetView ( UIContext . Organisation ) ;
}
private void ReloadViewModel ( long pOid )
{
VMFactory . CreateOrganisationVMAsync (
pOid ,
cb = > this . Dispatch (
delegate
{
if ( OrganisationSavedOrUpdated ! = null )
{
OrganisationSavedOrUpdated ( this , new EventArgs < OrganisationVM > ( cb ) ) ;
}
ViewModel = cb ;
if ( ModalEditViewUpdateCallback ! = null )
{
ModalEditViewUpdateCallback ( ) ;
}
} ) ) ;
IsDoneWithInsertOrUpdate = true ;
}
public void ReloadViewModel ( )
{
2023-10-26 00:06:56 +02:00
if ( ViewModel . DataContract . OrganisationOid . HasValue )
{
ReloadViewModel ( ViewModel . DataContract . OrganisationOid . Value ) ;
}
2016-06-27 01:45:38 +02:00
}
private void bt_addQualificationRate_Click ( object sender , RoutedEventArgs e )
{
var stand = ViewModel . CostRatePeriods . GetLatestRate ( CostRatePeriodType . HourlyRate ) ;
if ( stand ! = null )
{
ViewModel . CostRatePeriods . NewVM . CostRateValue = stand . CostRateValue ;
}
ViewModel . CostRatePeriods . NewVM . ValueListEntry = ( ValueListEntryDC ) cb_qualifications . SelectedItem ;
ViewModel . CostRatePeriods . NewVM . CostRateType = CostRatePeriodType . HourlyRate ;
ViewModel . CostRatePeriods . AddNewVMToList ( ) ;
}
private void button_deleteCostRatePeriodGroup_Click ( object sender , RoutedEventArgs e )
{
var valueListEntry = ( sender as Button ) . Tag as ValueListEntryDC ;
ViewModel . CostRatePeriods . VMList . RemoveRange ( i = > i . ValueListEntry ! = null & & i . ValueListEntry . ValueListEntryOid . Equals ( valueListEntry . ValueListEntryOid ) ) ;
}
private void tabitem_documents_Selected ( object sender , RoutedEventArgs e )
{
if ( ViewModel . IsNew )
{
MessageBox . Show ( "Bevor zu einem Datensatz Dokumente hinterlegt werden können, muss dieser gespeichert werden." , "Erst speichern bitte" , MessageBoxButton . OK , MessageBoxImage . Information ) ;
return ;
}
if ( tabitem_documents . Content = = null )
{
tabitem_documents . Content = new BeWoFileView ( TableID . Organisation , ViewModel . DataContract . OrganisationOid . Value ) ;
}
}
private void TabItemsPersons_Selected ( object sender , RoutedEventArgs e )
{
if ( grid_GroupBoxPersonGrid = = null )
{
grid_GroupBoxPersonGrid = gridroot . Resources [ "datagrid_PersonRelation" ] as GridControl ;
GroupBoxPersonGrid . Content = grid_GroupBoxPersonGrid ;
}
}
2018-05-23 10:37:57 +02:00
private void Button_deleteAnsprechpartnerClick ( object sender , RoutedEventArgs e )
{
var vm = grid_GroupBoxPersonGrid . GetCurrentValue < OrganisationPersonRelationVM > ( ) ;
2022-11-25 15:22:38 +01:00
if ( MessageBox . Show ( String . Format ( "Möchten Sie " + Translator . Translate ( "den gewählten Ansprechpartner" ) + " '{0}, {1}' wirklich löschen?" , vm . Person . LastName , vm . Person . FirstName ) , "Löschen" ,
2018-05-23 10:37:57 +02:00
MessageBoxButton . YesNo , MessageBoxImage . Question ) = = MessageBoxResult . Yes )
{
ViewModel . PersonRelations . VMList . Remove ( vm ) ;
BeWoWpfUtils . RefreshDXGrid ( grid_GroupBoxPersonGrid ) ;
ServiceFacade . DoOperationsServiceSync ( s = >
s . DeletePerson2OrganisationRelation ( vm . DataContract . Organisation2PersonOid . Value ) ) ;
}
}
2016-06-27 01:45:38 +02:00
private void TableView_OnRowDoubleClick ( object sender , RowDoubleClickEventArgs e )
{
var grid = ( GridControl ) gridroot . Resources [ "datagrid_PersonRelation" ] ;
var selectedPerson = ( grid . GetRow ( e . HitInfo . RowHandle ) as OrganisationPersonRelationVM ) . Person ;
if ( selectedPerson = = null | | ! BeWoApp . LoggedOnUser . HasRight ( UserRightType . PersonView_View ) )
return ;
VMFactory . CreatePersonVMAsync ( selectedPerson . PersonOid ,
cb = > this . Dispatch (
( ) = > BeWoUtils . OpenModalViewWindow < PersonVM , PersonDC , OrganisationView > ( cb , this , ( ) = > this . Dispatch (
( ) = > BeWoUtils . UpdateAllViews ( selectedPerson ) ) , personSavedOrUpdated : ( s , args ) = > this . Dispatch ( delegate { } ) ) ) ) ;
}
private void EMailButton_OnClick ( object sender , RoutedEventArgs e )
{
BeWoUtils . OpenMailClient ( ViewModel . EMail ) ;
}
private void Hyperlink_OnRequestNavigate ( object sender , RequestNavigateEventArgs e )
{
BeWoUtils . OpenMailClient ( e . Uri . ToString ( ) ) ;
}
2016-12-08 14:17:41 +01:00
private void CreateNewAnsprechpartner_OnClick ( object sender , RoutedEventArgs e )
{
2018-04-27 14:13:42 +02:00
if ( ValidationTrigger . Validate ( groupbox_newOrganisationAnsprechpartner ) & & pes ! = null )
2016-12-08 14:17:41 +01:00
{
2018-04-27 14:13:42 +02:00
2016-12-08 14:17:41 +01:00
var mail = textbox_mail . Text ;
var fax = textbox_fax . Text ;
var phone = textbox_phone . Text ;
var notice = textbox_notice . Text ;
var ldc = ViewModel . CommitToDataContract ( ) ;
2018-05-23 10:37:57 +02:00
if ( pes . PersonOid ! = 0 )
{
//ViewModel.PersonRelations.AddNewVMToList();
ServiceFacade . DoOperationsServiceSync ( s = > s . CreateNewPerson2OrganisationRelation ( ldc . OrganisationOid . Value , ( ValueListEntryDC ) Combobox_Rolle . SelectedItem , pes . PersonOid , mail , fax , phone . ToString ( ) , notice . ToString ( ) ) ) ;
2024-03-26 01:01:03 +01:00
Save ( ) ;
2018-05-23 10:37:57 +02:00
}
2016-12-08 14:17:41 +01:00
2018-05-23 10:37:57 +02:00
2018-04-27 14:13:42 +02:00
textbox_mail . Text = "" ;
textbox_fax . Text = "" ;
textbox_phone . Text = "" ;
textbox_notice . Text = "" ;
2024-03-26 01:01:03 +01:00
2018-04-27 14:13:42 +02:00
//ReloadViewModel();
pes = null ;
2016-12-08 14:17:41 +01:00
}
}
CompactPersonDC pes = new CompactPersonDC ( ) ;
private void popupedit_Person_PopUpClick ( object sender , RoutedEventArgs e )
{
personsearchview . ItemSelected + = personsearchview_EnvironmentPersonSelected ;
popup_person . IsOpen = true ;
}
private void personsearchview_EnvironmentPersonSelected ( object sender , EventArgs < CompactPersonDC > e )
{
popup_person . IsOpen = false ;
personsearchview . ItemSelected - = personsearchview_EnvironmentPersonSelected ;
pes = e . Data ;
popupedit_environmentPersonSearch . Text = pes . FirstName + " " + pes . LastName ;
popupedit_environmentPersonSearch . Focus ( ) ;
}
2018-10-08 11:57:16 +02:00
private void tabitem_SchulDienst_Selected ( object sender , RoutedEventArgs e )
{
2023-10-26 00:06:56 +02:00
if ( GridSBD . Children . Count = = 0 )
2018-10-08 11:57:16 +02:00
{
2023-10-26 00:06:56 +02:00
var sp = new StundenplanView ( ViewModel . Arbeitszeiten , Translator . Translate ( "OrganisationStundenplan" ) ) ;
Grid . SetRow ( sp , 0 ) ;
GridSBD . Children . Add ( sp ) ;
var ov = new SbdOrganisationView ( ViewModel . Feiertage ) ;
ov . Margin = new Thickness ( 0 , 10 , 0 , 0 ) ;
Grid . SetRow ( ov , 1 ) ;
GridSBD . Children . Add ( ov ) ;
2018-10-08 11:57:16 +02:00
}
}
2024-10-17 13:57:06 +02:00
private void IKNumber_Button_Click ( object sender , RoutedEventArgs e )
{
2024-10-25 17:30:27 +02:00
var req = new GkvServerGetIKRequestDC ( ) ;
2024-10-17 13:57:06 +02:00
req . IKKrankenkasse = ViewModel . IKKrankenkasse ;
req . Leistungserbringergruppe = ViewModel . Leistungserbringergruppe ;
ServiceFacade . DoAccountingServiceAsync ( x = > x . SendApp8GetIKRequest ( req ) , cb = > Dispatcher . Invoke ( ( ) = > IKRequestCallback ( req , cb ) ) ) ;
}
2024-10-25 17:30:27 +02:00
private void IKRequestCallback ( GkvServerGetIKRequestDC req , GkvServerGetIKResponseDC response )
2024-10-17 13:57:06 +02:00
{
2024-10-23 17:05:20 +02:00
if ( response is null | | ! response . Success )
{
MessageBox . Show ( $"Interner Serverfehler." , "Fehler" ) ;
return ;
}
2024-10-17 13:57:06 +02:00
if ( ! response . Gefunden )
{
MessageBox . Show ( $"Für die Organisation mit dem IK \" { req . IKKrankenkasse } \ " und Leistungserbringergruppe \"{req.Leistungserbringergruppe}\" konnte keine Datenannahmestelle gefunden werden. " +
$"Bitte informieren Sie sich bei der Krankenkasse, ob zum elektronischen Datenaustausch " +
2024-10-23 17:05:20 +02:00
$"eine seperate Anmeldung benötigt wird." , "Fehler" ) ;
2024-10-17 13:57:06 +02:00
return ;
}
ViewModel . BezDatenannahmestelle = response . BezDatenannahmestelle ;
ViewModel . IKKostentrager = response . IKKostentrager ;
ViewModel . IKDatenannahmestelle = response . IKDatenannahmestelle ;
2024-10-22 11:40:46 +02:00
CommandManager . InvalidateRequerySuggested ( ) ;
}
2024-10-17 13:57:06 +02:00
}
2016-06-27 01:45:38 +02:00
}