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
Try
FilesLoading = True
SplitContainerMain.Panel2.Enabled = True
Dim oDocument As Document = GridViewFiles.GetRow(e.FocusedRowHandle)
@ -240,12 +242,15 @@ Public Class frmImportMain
If oDocument.Mandator Is Nothing Then
lookupMandator.EditValue = Nothing
lookupMandator.BackColor = Color.LightCoral
End If
lookupMandator.EditValue = oDocument.Mandator
LoadDocument(oDocument)
Catch ex As Exception
FormHelper.ShowError(ex, My.Resources.frmImportMainExtra.Laden_des_Dokuments)
Finally
FilesLoading = False
End Try
End Sub
@ -443,7 +448,19 @@ Public Class frmImportMain
End Function
Private Async Sub btnReloadFile_ItemClick(sender As Object, e As DevExpress.XtraBars.ItemClickEventArgs) Handles btnReloadFile.ItemClick
Await ReloadFile()
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()
End If
End Sub
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
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
RibbonPageGroupEdit.Enabled = True
RibbonPageGroupTransfer.Enabled = True
@ -671,27 +688,16 @@ Public Class frmImportMain
End Function
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
BeginLoadingUI()
FilesLoading = True
If oResult = DialogResult.Yes Then
Dim oDocument As Document = GridViewFiles.GetRow(GridViewFiles.FocusedRowHandle)
Dim oNewDocument = Await DocumentLoader.LoadFile(oDocument.File, CurrentTemplate, lookupMandator.EditValue)
Dim oDocument As Document = GridViewFiles.GetRow(GridViewFiles.FocusedRowHandle)
Dim oNewDocument = Await DocumentLoader.LoadFile(oDocument.File, CurrentTemplate, lookupMandator.EditValue)
Dim oIndex = DocumentLoader.Files.IndexOf(oDocument)
DocumentLoader.Files.Item(oIndex) = oNewDocument
LoadDocument(oNewDocument)
End If
Catch ex As Exception
FormHelper.ShowError(ex, My.Resources.frmImportMainExtra.Neuladen_des_Dokuments)
@ -884,24 +890,35 @@ Public Class frmImportMain
End If
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
lookupMandator.BackColor = Color.LightCoral
AskReloadFile = False
Else
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 e.OldValue Is Nothing And e.NewValue IsNot Nothing And FilesLoading = False Then
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)
If AskReloadFile Then
AskReloadFile = False
If oResult = MsgBoxResult.Yes Then
Await ReloadFile()
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
Await ReloadFile()
End If
End If
End If
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 Class