fix selection error on second profile open

This commit is contained in:
Jonathan Jenne 2022-02-03 11:37:34 +01:00
parent ea41de3623
commit 8d42a486ed

View File

@ -44,6 +44,8 @@ Public Class frmIndex
Private Const LANG_DE = "de-DE"
Private Property DocTypes As New List(Of DocType)
Private _Logger As Logger
#End Region
@ -1668,7 +1670,6 @@ Public Class frmIndex
FormLoaded = True
Try
_Logger.Info("Profile Preselected enabled: {0}", CONFIG.Config.ProfilePreselection)
' Letzte Auswahl merken überschreibt die automatische selektion
If CONFIG.Config.ProfilePreselection Then
@ -1677,7 +1678,7 @@ Public Class frmIndex
If CURRENT_LASTDOKART <> "" Then
_Logger.Info("Last Saved DocType: {0}", CURRENT_LASTDOKART)
Dim oDocTypes As List(Of DocType) = ComboboxDoctype.Properties.DataSource
Dim oDocTypes As List(Of DocType) = DocTypes
Dim oFoundDocType = oDocTypes.
Where(Function(dt) dt.Name = CURRENT_LASTDOKART).
FirstOrDefault()
@ -1688,7 +1689,6 @@ Public Class frmIndex
ComboboxDoctype.EditValue = oFoundDocType
End If
'cmbDokumentart.SelectedIndex = cmbDokumentart.FindStringExact(CURRENT_LASTDOKART)
End If
End If
@ -1702,9 +1702,8 @@ Public Class frmIndex
_Logger.Debug("There is a match on REGEX_DOCTYPE: [{0}]", oRoW.Item("DOCTYPE"))
_Logger.Debug("Regex: [{0}], FileName: [{1}]", oRoW.Item("Regex"), oOnlyFilename)
'cmbDokumentart.SelectedIndex = cmbDokumentart.FindStringExact(oRoW.Item("DOCTYPE"))
Dim oDoctypes As List(Of DocType) = ComboboxDoctype.Properties.DataSource
Dim oDoctypes As List(Of DocType) = DocTypes
Dim oFoundDocType As DocType = oDoctypes.
Where(Function(dt) dt.Guid = oRoW.Item("DOCTYPE_ID")).
FirstOrDefault()
@ -1712,12 +1711,11 @@ Public Class frmIndex
If oFoundDocType IsNot Nothing Then
_Logger.Debug("DocType found: [{0}]", oFoundDocType)
ComboboxDoctype.EditValue = oFoundDocType
Exit For
End If
End If
Next
Else
ComboboxDoctype.EditValue = Nothing
End If
Catch ex As Exception
ShowErrorMessage(ex, "Form Shown")
@ -1728,24 +1726,20 @@ Public Class frmIndex
Dim sql = String.Format("SELECT DISTINCT DOCTYPE_ID, DOCTYPE, SEQUENCE FROM VWGI_DOCTYPE where UPPER(USERNAME) = UPPER('{0}') ORDER BY SEQUENCE", Environment.UserName)
_Logger.Info("SQL DoctypeList: " & sql)
Dim oDoctypes = DATABASE_ECM.GetDatatable(sql)
'cmbDokumentart.DataSource = oDoctypes
'cmbDokumentart.ValueMember = oDoctypes.Columns("DOCTYPE_ID").ColumnName
'cmbDokumentart.DisplayMember = oDoctypes.Columns("DOCTYPE").ColumnName
'cmbDokumentart.AutoCompleteMode = AutoCompleteMode.Suggest
'cmbDokumentart.AutoCompleteSource = AutoCompleteSource.ListItems
'cmbDokumentart.SelectedIndex = -1
Dim oDocTypeList As New List(Of DocType)
ComboboxDoctype.EditValue = Nothing
ComboboxDoctype.Properties.DataSource = Nothing
DocTypes.Clear()
For Each oRow As DataRow In oDoctypes.Rows
Dim oDocType = New DocType With {.Guid = oRow.Item("DOCTYPE_ID"), .Name = oRow.Item("DOCTYPE")}
oDocTypeList.Add(oDocType)
Dim oDocType = New DocType With {
.Guid = oRow.Item("DOCTYPE_ID"),
.Name = oRow.Item("DOCTYPE")
}
DocTypes.Add(oDocType)
Next
ComboboxDoctype.Properties.DataSource = oDocTypeList
'ComboboxDoctype.Properties.ValueMember = "Guid"
'ComboboxDoctype.Properties.DisplayMember = "Name"
' ComboboxDoctype.SelectedIndex = -1
ComboboxDoctype.Properties.DataSource = DocTypes
Catch ex As Exception
ShowErrorMessage(ex, "Refresh_Dokart")
End Try
@ -1756,6 +1750,7 @@ Public Class frmIndex
Dim oSelectedItem As DocType = ComboboxDoctype.EditValue
CURRENT_DOKART_ID = oSelectedItem.Guid
CURRENT_LASTDOKART = oSelectedItem.Name
'lblhinweis.Visible = False
ClearNotice()
@ -2297,7 +2292,7 @@ Public Class frmIndex
'Die Datei verschieben
If Move_File2_Target() = True Then
_Logger.Debug(" ...Move_File2_Target durchlaufen")
CURRENT_LASTDOKART = oDokart.Name
_Logger.Info("Datei '" & CURRENT_NEWFILENAME & "' erfolgreich erzeugt.")
Dim oDEL As String = "DELETE FROM TBGI_FILES_USER WHERE GUID = " & CURRENT_WORKFILE_GUID
DATABASE_ECM.ExecuteNonQuery(oDEL)