Autoload template, ask for reload on selecting mandator
This commit is contained in:
@@ -39,6 +39,7 @@ Public Class frmImportMain
|
||||
Private CurrentGrid As GridControl = Nothing
|
||||
Private CurrentDocument As Document = Nothing
|
||||
Private CurrentDocumentReadOnly As Boolean = False
|
||||
Private FilesLoading As Boolean = False
|
||||
|
||||
Public Sub New(pLogConfig As LogConfig, pConfigManager As ConfigManager(Of Config), pTemplate As Template)
|
||||
InitializeComponent()
|
||||
@@ -80,7 +81,7 @@ Public Class frmImportMain
|
||||
Text = String.Format(My.Resources.frmShared._0____WebService_Multitool_für_WinLine, CurrentTemplate.Name)
|
||||
End Sub
|
||||
|
||||
Private Sub frmImportMain_Shown(sender As Object, e As EventArgs) Handles MyBase.Shown
|
||||
Private Async Sub frmImportMain_Shown(sender As Object, e As EventArgs) Handles MyBase.Shown
|
||||
btnLoadFiles.Enabled = False
|
||||
SplashScreenManager.ShowWaitForm()
|
||||
|
||||
@@ -114,6 +115,8 @@ Public Class frmImportMain
|
||||
SplashScreenManager.CloseWaitForm()
|
||||
btnLoadFiles.Enabled = True
|
||||
End Try
|
||||
|
||||
Await LoadFiles()
|
||||
End Sub
|
||||
|
||||
Private Sub frmImportMain_FormClosing(sender As Object, e As FormClosingEventArgs) Handles Me.FormClosing
|
||||
@@ -440,34 +443,7 @@ Public Class frmImportMain
|
||||
End Function
|
||||
|
||||
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)
|
||||
|
||||
Try
|
||||
BeginLoadingUI()
|
||||
|
||||
If oResult = DialogResult.Yes Then
|
||||
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)
|
||||
|
||||
Finally
|
||||
EndLoadingUI()
|
||||
|
||||
End Try
|
||||
Await ReloadFile()
|
||||
End Sub
|
||||
|
||||
Private Sub btnOpenInputDirectory_ItemClick(sender As Object, e As DevExpress.XtraBars.ItemClickEventArgs) Handles btnOpenInputDirectory.ItemClick
|
||||
@@ -661,6 +637,7 @@ Public Class frmImportMain
|
||||
Private Async Function LoadFiles() As Task
|
||||
Try
|
||||
BeginLoadingUI()
|
||||
FilesLoading = True
|
||||
|
||||
DocumentCleaner.CleanImportedDocuments(DocumentLoader.Files)
|
||||
|
||||
@@ -688,10 +665,44 @@ Public Class frmImportMain
|
||||
FormHelper.ShowError(ex, My.Resources.frmImportMainExtra.Laden_der_Dokumente)
|
||||
|
||||
Finally
|
||||
FilesLoading = False
|
||||
EndLoadingUI()
|
||||
End Try
|
||||
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 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)
|
||||
|
||||
Finally
|
||||
FilesLoading = False
|
||||
EndLoadingUI()
|
||||
|
||||
End Try
|
||||
End Function
|
||||
|
||||
Private Function EditRow(pRow As DataRow, pView As GridView) As DocumentRow
|
||||
Try
|
||||
If CurrentDocumentReadOnly = True Then
|
||||
@@ -832,6 +843,7 @@ Public Class frmImportMain
|
||||
SetDocumentButtonsEnabled(False)
|
||||
GridControlFiles.Enabled = False
|
||||
SplitContainerGrids.Enabled = False
|
||||
lookupMandator.Enabled = False
|
||||
|
||||
RibbonPageGroupLoad.Enabled = False
|
||||
RibbonPageGroupEdit.Enabled = False
|
||||
@@ -845,6 +857,7 @@ Public Class frmImportMain
|
||||
RibbonPageGroupReport.Enabled = True
|
||||
RibbonPageGroupTransfer.Enabled = True
|
||||
|
||||
lookupMandator.Enabled = True
|
||||
SplitContainerGrids.Enabled = True
|
||||
GridControlFiles.Enabled = True
|
||||
SetDocumentButtonsEnabled(True)
|
||||
@@ -861,14 +874,6 @@ Public Class frmImportMain
|
||||
btnEditRow.Enabled = pEnabled
|
||||
End Sub
|
||||
|
||||
Private Sub lookupMandator_EditValueChanged(sender As Object, e As EventArgs) Handles lookupMandator.EditValueChanged
|
||||
If lookupMandator.EditValue Is Nothing Then
|
||||
lookupMandator.BackColor = Color.LightCoral
|
||||
Else
|
||||
lookupMandator.BackColor = Nothing
|
||||
End If
|
||||
End Sub
|
||||
|
||||
Private Sub btnShowErrors_ItemClick(sender As Object, e As DevExpress.XtraBars.ItemClickEventArgs) Handles btnShowErrors.ItemClick
|
||||
If CurrentDocument IsNot Nothing Then
|
||||
Dim oErrors = CurrentDocument.Errors.
|
||||
@@ -879,8 +884,24 @@ Public Class frmImportMain
|
||||
End If
|
||||
End Sub
|
||||
|
||||
Private Sub lookupMandator_EditValueChanged(sender As Object, e As EventArgs) Handles lookupMandator.EditValueChanged
|
||||
If lookupMandator.EditValue Is Nothing Then
|
||||
lookupMandator.BackColor = Color.LightCoral
|
||||
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 oResult = MsgBoxResult.Yes Then
|
||||
Await ReloadFile()
|
||||
End If
|
||||
End If
|
||||
End Function
|
||||
#End Region
|
||||
|
||||
End Class
|
||||
Reference in New Issue
Block a user