use LookupControl3, fix double profile items in combobox, fix crashes

This commit is contained in:
Jonathan Jenne
2021-03-22 16:13:49 +01:00
parent f53f83e403
commit 271d38bd05
5 changed files with 122 additions and 106 deletions

View File

@@ -7,6 +7,7 @@ Imports System.Security.Principal
Imports System.DirectoryServices
Imports DigitalData.Modules.Logging
Imports DigitalData.Controls.LookupGrid
Imports DigitalData.GUIs.GlobalIndexer
Public Class frmIndex
#Region "+++++ Variablen ++++++"
@@ -355,8 +356,8 @@ Public Class frmIndex
End If
If oControl.Name.StartsWith("cmbMulti") Then
Dim oLookup = DirectCast(oControl, DigitalData.Controls.LookupGrid.LookupControl2)
Dim values As List(Of String) = oLookup.SelectedValues
Dim oLookup = DirectCast(oControl, DigitalData.Controls.LookupGrid.LookupControl3)
Dim values As List(Of String) = oLookup.Properties.SelectedValues
If values.Count = 0 Then
Dim optional_index As Boolean = ClassDatabase.Execute_Scalar("SELECT OPTIONAL FROM TBDD_INDEX_MAN WHERE DOK_ID = " & dokartid & " AND NAME = '" & Replace(oLookup.Name, "cmbMulti", "") & "'", MyConnectionString, True)
@@ -1569,13 +1570,13 @@ Public Class frmIndex
checkItemPreselection.Checked = True
If CURRENT_LASTDOKART <> "" Then
Dim oFoundDocType = ComboBoxEdit1.Properties.Items.
Dim oFoundDocType = ComboboxDoctype.Properties.Items.
Cast(Of DocType)().
Where(Function(dt) dt.Name = CURRENT_LASTDOKART).
FirstOrDefault()
If oFoundDocType IsNot Nothing Then
ComboBoxEdit1.SelectedItem = oFoundDocType
ComboboxDoctype.SelectedItem = oFoundDocType
End If
'cmbDokumentart.SelectedIndex = cmbDokumentart.FindStringExact(CURRENT_LASTDOKART)
@@ -1590,13 +1591,13 @@ Public Class frmIndex
_Logger.Debug("Regex: [{0}], FileName: [{1}]", oRoW.Item("Regex"), oOnlyFilename)
'cmbDokumentart.SelectedIndex = cmbDokumentart.FindStringExact(oRoW.Item("DOCTYPE"))
Dim oFoundDocType = ComboBoxEdit1.Properties.Items.
Dim oFoundDocType = ComboboxDoctype.Properties.Items.
Cast(Of DocType)().
Where(Function(dt) dt.Name = CURRENT_LASTDOKART).
FirstOrDefault()
If oFoundDocType IsNot Nothing Then
ComboBoxEdit1.SelectedItem = oFoundDocType
ComboboxDoctype.SelectedItem = oFoundDocType
End If
Exit For
@@ -1620,20 +1621,26 @@ Public Class frmIndex
'cmbDokumentart.AutoCompleteSource = AutoCompleteSource.ListItems
'cmbDokumentart.SelectedIndex = -1
ComboboxDoctype.Properties.Items.Clear()
For Each oRow As DataRow In oDoctypes.Rows
ComboBoxEdit1.Properties.Items.Add(New DocType With {
ComboboxDoctype.Properties.Items.Add(New DocType With {
.Guid = oRow.Item("DOCTYPE_ID"),
.Name = oRow.Item("DOCTYPE")
})
Next
ComboboxDoctype.SelectedIndex = -1
Catch ex As Exception
ShowErrorMessage(ex, "Refresh_Dokart")
End Try
End Sub
Private Sub ComboBoxEdit1_SelectedIndexChanged(sender As Object, e As EventArgs) Handles ComboBoxEdit1.SelectedIndexChanged
If ComboBoxEdit1.SelectedIndex <> -1 And FormLoaded = True Then
Dim oSelectedItem As DocType = ComboBoxEdit1.SelectedItem
Private Sub ComboBoxEdit1_SelectedIndexChanged(sender As Object, e As EventArgs) Handles ComboboxDoctype.SelectedIndexChanged
If ComboboxDoctype.SelectedIndex <> -1 And FormLoaded = True Then
Dim oSelectedItem As DocType = ComboboxDoctype.SelectedItem
CURRENT_DOKART_ID = oSelectedItem.Guid
@@ -1728,8 +1735,8 @@ Public Class frmIndex
' ShowError("Keine Manuellen Indizes für die " & vbNewLine & "Dokumentart " & cmbDokumentart.Text & " definiert")
'_Logger.Info(" - Keine Manuellen Indizes für die " & vbNewLine & "Dokumentart " & cmbDokumentart.Text & " definiert")
ShowError("Keine Manuellen Indizes für die " & vbNewLine & "Dokumentart " & ComboBoxEdit1.Text & " definiert")
_Logger.Info(" - Keine Manuellen Indizes für die " & vbNewLine & "Dokumentart " & ComboBoxEdit1.Text & " definiert")
ShowError("Keine Manuellen Indizes für die " & vbNewLine & "Dokumentart " & ComboboxDoctype.Text & " definiert")
_Logger.Info(" - Keine Manuellen Indizes für die " & vbNewLine & "Dokumentart " & ComboboxDoctype.Text & " definiert")
End If
For Each oRow As DataRow In DT_INDEXEMAN.Rows
@@ -1823,7 +1830,7 @@ Public Class frmIndex
End Try
End Sub
Private Function GetLookupData(pLookup As LookupControl2, pSQLCommand As String, pConnectionId As Integer)
Private Function GetLookupData(pLookup As LookupControl3, pSQLCommand As String, pConnectionId As Integer)
Dim oConnectionString = ClassFormFunctions.GetConnectionString(pConnectionId)
If oConnectionString IsNot Nothing And pSQLCommand.Length > 0 Then
@@ -1851,7 +1858,7 @@ Public Class frmIndex
End If
Try
Dim oMeta = DirectCast(Control.Tag, ClassControls.ControlMeta)
Dim oMeta = DirectCast(Control.Tag, ControlCreator.ControlMeta)
Dim oIndexName As String = oMeta.IndexName
Dim oSQL = $"SELECT * FROM TBDD_INDEX_MAN WHERE SQL_RESULT LIKE '%{oIndexName}%'"
Dim oDatatable As DataTable = ClassDatabase.Return_Datatable(oSQL)
@@ -1897,7 +1904,7 @@ Public Class frmIndex
Continue For
End If
Dim oMeta = DirectCast(oControl.Tag, ClassControls.ControlMeta)
Dim oMeta = DirectCast(oControl.Tag, ControlCreator.ControlMeta)
Dim oIndex As String = oMeta.IndexName
If oIndex = IndexName Then
@@ -1908,10 +1915,12 @@ Public Class frmIndex
If oFoundControl Is Nothing Then
LOGGER.Warn("Depending Control for Index [{0}] not found!", IndexName)
Exit Sub
End If
If oDatatable Is Nothing Then
LOGGER.Warn("Error in SQL Command: {0}", SqlCommand)
Exit Sub
End If
Select Case oFoundControl.GetType.Name
@@ -1926,9 +1935,15 @@ Public Class frmIndex
DirectCast(oFoundControl, DevExpress.XtraEditors.TextEdit).Text = oValue
End If
End If
Case GetType(LookupControl2).Name
Case GetType(LookupControl3).Name
LOGGER.Debug("Setting Value for LookupControl [{0}]: [{1}]", oFoundControl.Name, "DATATABLE")
DirectCast(oFoundControl, LookupControl2).DataSource = oDatatable
Dim oLookupControl = DirectCast(oFoundControl, LookupControl3)
oLookupControl.Properties.DataSource = oDatatable
If oDatatable.Columns.Count > 0 Then
oLookupControl.Properties.ValueMember = oDatatable.Columns.Item(0).ColumnName
oLookupControl.Properties.DisplayMember = oDatatable.Columns.Item(0).ColumnName
End If
Case GetType(ComboBox).Name
LOGGER.Debug("Setting Value for Combobox [{0}]: [{1}]", oFoundControl.Name, "DATATABLE")
DirectCast(oFoundControl, ComboBox).DataSource = oDatatable
@@ -2146,7 +2161,7 @@ Public Class frmIndex
_Logger.Debug("Manuelle Indexe geladen")
If MyDataset.VWDDINDEX_MAN.Rows.Count > 0 Then
Dim oDokart As DocType = ComboBoxEdit1.SelectedItem
Dim oDokart As DocType = ComboboxDoctype.SelectedItem
CURRENT_DOKART_ID = oDokart.Guid
If CheckWrite_IndexeMan(oDokart.Guid) = True Then