Fix loading/mandator selection

This commit is contained in:
Jonathan Jenne 2022-05-12 15:28:38 +02:00
parent e4345f3b76
commit 5dc851be7d

View File

@ -230,6 +230,8 @@ Public Class frmImportMain
Private Sub GridViewFiles_FocusedRowChanged(sender As Object, e As Views.Base.FocusedRowChangedEventArgs) Handles GridViewFiles.FocusedRowChanged Private Sub GridViewFiles_FocusedRowChanged(sender As Object, e As Views.Base.FocusedRowChangedEventArgs) Handles GridViewFiles.FocusedRowChanged
Try Try
FilesLoading = True
SplitContainerMain.Panel2.Enabled = True SplitContainerMain.Panel2.Enabled = True
Dim oDocument As Document = GridViewFiles.GetRow(e.FocusedRowHandle) Dim oDocument As Document = GridViewFiles.GetRow(e.FocusedRowHandle)
@ -240,12 +242,15 @@ Public Class frmImportMain
If oDocument.Mandator Is Nothing Then If oDocument.Mandator Is Nothing Then
lookupMandator.EditValue = Nothing lookupMandator.EditValue = Nothing
lookupMandator.BackColor = Color.LightCoral
End If End If
lookupMandator.EditValue = oDocument.Mandator lookupMandator.EditValue = oDocument.Mandator
LoadDocument(oDocument) LoadDocument(oDocument)
Catch ex As Exception Catch ex As Exception
FormHelper.ShowError(ex, My.Resources.frmImportMainExtra.Laden_des_Dokuments) FormHelper.ShowError(ex, My.Resources.frmImportMainExtra.Laden_des_Dokuments)
Finally
FilesLoading = False
End Try End Try
End Sub End Sub
@ -443,7 +448,19 @@ Public Class frmImportMain
End Function End Function
Private Async Sub btnReloadFile_ItemClick(sender As Object, e As DevExpress.XtraBars.ItemClickEventArgs) Handles btnReloadFile.ItemClick Private Async Sub btnReloadFile_ItemClick(sender As Object, e As DevExpress.XtraBars.ItemClickEventArgs) Handles btnReloadFile.ItemClick
Dim oCurrentMandator As Mandator = TryCast(lookupMandator.EditValue, Mandator)
'If oCurrentMandator Is Nothing Then
' MsgBox(My.Resources.frmImportMainExtra.Bitte_wählen_Sie_einen_Mandanten_aus__bevor_Sie_fortfahren, MsgBoxStyle.Exclamation, Text)
' Exit Sub
'End If
Dim oMessage = String.Format(My.Resources.frmImportMainExtra.Wollen_Sie_wirklich_die_aktuelle_Datei_neu_laden, oCurrentMandator)
Dim oResult As DialogResult = MsgBox(oMessage, MsgBoxStyle.Question Or MsgBoxStyle.YesNo, Text)
If oResult = DialogResult.Yes Then
Await ReloadFile() Await ReloadFile()
End If
End Sub End Sub
Private Sub btnOpenInputDirectory_ItemClick(sender As Object, e As DevExpress.XtraBars.ItemClickEventArgs) Handles btnOpenInputDirectory.ItemClick Private Sub btnOpenInputDirectory_ItemClick(sender As Object, e As DevExpress.XtraBars.ItemClickEventArgs) Handles btnOpenInputDirectory.ItemClick
@ -606,7 +623,7 @@ Public Class frmImportMain
RibbonPageGroupTransfer.Enabled = False RibbonPageGroupTransfer.Enabled = False
CurrentDocumentReadOnly = True CurrentDocumentReadOnly = True
MsgBox("Für die aktuelle Datei konnte kein Mandant zugeordnet werden! Bitte wählen Sie einen aus und laden Sie dann die Datei erneut.", MsgBoxStyle.Critical, Text) 'MsgBox("Für die aktuelle Datei konnte kein Mandant zugeordnet werden! Bitte wählen Sie einen aus und laden Sie dann die Datei erneut.", MsgBoxStyle.Critical, Text)
Else Else
RibbonPageGroupEdit.Enabled = True RibbonPageGroupEdit.Enabled = True
RibbonPageGroupTransfer.Enabled = True RibbonPageGroupTransfer.Enabled = True
@ -671,27 +688,16 @@ Public Class frmImportMain
End Function End Function
Public Async Function ReloadFile() As Task Public Async Function ReloadFile() As Task
Dim oCurrentMandator As Mandator = TryCast(lookupMandator.EditValue, Mandator)
If oCurrentMandator Is Nothing Then
MsgBox(My.Resources.frmImportMainExtra.Bitte_wählen_Sie_einen_Mandanten_aus__bevor_Sie_fortfahren, MsgBoxStyle.Exclamation, Text)
Exit Function
End If
Dim oMessage = String.Format(My.Resources.frmImportMainExtra.Wollen_Sie_wirklich_die_aktuelle_Datei_neu_laden, oCurrentMandator)
Dim oResult As DialogResult = MsgBox(oMessage, MsgBoxStyle.Question Or MsgBoxStyle.YesNo, Text)
Try Try
BeginLoadingUI() BeginLoadingUI()
FilesLoading = True FilesLoading = True
If oResult = DialogResult.Yes Then
Dim oDocument As Document = GridViewFiles.GetRow(GridViewFiles.FocusedRowHandle) Dim oDocument As Document = GridViewFiles.GetRow(GridViewFiles.FocusedRowHandle)
Dim oNewDocument = Await DocumentLoader.LoadFile(oDocument.File, CurrentTemplate, lookupMandator.EditValue) Dim oNewDocument = Await DocumentLoader.LoadFile(oDocument.File, CurrentTemplate, lookupMandator.EditValue)
Dim oIndex = DocumentLoader.Files.IndexOf(oDocument) Dim oIndex = DocumentLoader.Files.IndexOf(oDocument)
DocumentLoader.Files.Item(oIndex) = oNewDocument DocumentLoader.Files.Item(oIndex) = oNewDocument
LoadDocument(oNewDocument) LoadDocument(oNewDocument)
End If
Catch ex As Exception Catch ex As Exception
FormHelper.ShowError(ex, My.Resources.frmImportMainExtra.Neuladen_des_Dokuments) FormHelper.ShowError(ex, My.Resources.frmImportMainExtra.Neuladen_des_Dokuments)
@ -884,24 +890,35 @@ Public Class frmImportMain
End If End If
End Sub End Sub
Private Sub lookupMandator_EditValueChanged(sender As Object, e As EventArgs) Handles lookupMandator.EditValueChanged Private AskReloadFile As Boolean = False
Private Async Function lookupMandator_EditValueChanged(sender As Object, e As EventArgs) As Task Handles lookupMandator.EditValueChanged
Dim oMandator As Mandator = lookupMandator.EditValue
If lookupMandator.EditValue Is Nothing Then If lookupMandator.EditValue Is Nothing Then
lookupMandator.BackColor = Color.LightCoral lookupMandator.BackColor = Color.LightCoral
AskReloadFile = False
Else Else
lookupMandator.BackColor = Nothing lookupMandator.BackColor = Nothing
End If
End Sub
Private Async Function lookupMandator_EditValueChanging(sender As Object, e As DevExpress.XtraEditors.Controls.ChangingEventArgs) As Task Handles lookupMandator.EditValueChanging If AskReloadFile Then
If e.OldValue Is Nothing And e.NewValue IsNot Nothing And FilesLoading = False Then AskReloadFile = False
Dim oMandator As Mandator = e.NewValue
Dim oResult = MsgBox($"Sie haben den Mandanten '{oMandator}' ausgewählt. Wollen Sie jetzt die aktuelle Datei neu laden?", MsgBoxStyle.Question Or MsgBoxStyle.YesNo, Text) Dim oResult = MsgBox($"Sie haben den Mandanten '{oMandator}' ausgewählt. Wollen Sie jetzt die aktuelle Datei neu laden?", MsgBoxStyle.Question Or MsgBoxStyle.YesNo, Text)
If oResult = MsgBoxResult.Yes Then If oResult = MsgBoxResult.Yes Then
Await ReloadFile() Await ReloadFile()
End If End If
End If End If
End If
End Function End Function
Private Sub lookupMandator_EditValueChanging(sender As Object, e As DevExpress.XtraEditors.Controls.ChangingEventArgs) Handles lookupMandator.EditValueChanging
If e.OldValue Is Nothing And e.NewValue IsNot Nothing And FilesLoading = False Then
AskReloadFile = True
End If
End Sub
#End Region #End Region
End Class End Class