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

@@ -59,71 +59,71 @@ Public Class ClassControls
PrepareDependingControl(sender)
End Sub
Public Function AddVorschlag_ComboBox(indexname As String, y As Integer, conid As Integer, sql_Vorschlag As String, Multiselect As Boolean, DataType As String, Optional Vorgabe As String = "", Optional AddNewValues As Boolean = False, Optional PreventDuplicateValues As Boolean = False, Optional SQLSuggestion As Boolean = False) As Control
Try
Dim oSql As String = sql_Vorschlag
Dim oConnectionString As String
Dim oControl As New DigitalData.Controls.LookupGrid.LookupControl2 With {
.MultiSelect = Multiselect,
.AllowAddNewValues = AddNewValues,
.PreventDuplicates = PreventDuplicateValues,
.Location = New Point(11, y),
.Size = New Size(300, 27),
.Name = "cmbMulti" & indexname,
.Tag = New ControlMeta() With {
.IndexName = indexname,
.IndexType = DataType
}
}
oControl.Properties.AppearanceFocused.BackColor = Color.FromArgb(255, 214, 49)
'Public Function AddVorschlag_ComboBox(indexname As String, y As Integer, conid As Integer, sql_Vorschlag As String, Multiselect As Boolean, DataType As String, Optional Vorgabe As String = "", Optional AddNewValues As Boolean = False, Optional PreventDuplicateValues As Boolean = False, Optional SQLSuggestion As Boolean = False) As Control
' Try
' Dim oSql As String = sql_Vorschlag
' Dim oConnectionString As String
' Dim oControl As New DigitalData.Controls.LookupGrid.LookupControl3 With {
' .MultiSelect = Multiselect,
' .AllowAddNewValues = AddNewValues,
' .PreventDuplicates = PreventDuplicateValues,
' .Location = New Point(11, y),
' .Size = New Size(300, 27),
' .Name = "cmbMulti" & indexname,
' .Tag = New ControlMeta() With {
' .IndexName = indexname,
' .IndexType = DataType
' }
' }
' oControl.Properties.AppearanceFocused.BackColor = Color.FromArgb(255, 214, 49)
If Not String.IsNullOrEmpty(Vorgabe) Then
Dim oDefaultValues As New List(Of String)
' If Not String.IsNullOrEmpty(Vorgabe) Then
' Dim oDefaultValues As New List(Of String)
If Vorgabe.Contains(",") Then
oDefaultValues = Vorgabe.
Split(",").ToList().
Select(Function(item) item.Trim()).
ToList()
Else
oDefaultValues = Vorgabe.
Split(ClassConstants.VECTORSEPARATOR).ToList().
Select(Function(item) item.Trim()).
ToList()
End If
oControl.SelectedValues = oDefaultValues
End If
' If Vorgabe.Contains(",") Then
' oDefaultValues = Vorgabe.
' Split(",").ToList().
' Select(Function(item) item.Trim()).
' ToList()
' Else
' oDefaultValues = Vorgabe.
' Split(ClassConstants.VECTORSEPARATOR).ToList().
' Select(Function(item) item.Trim()).
' ToList()
' End If
' oControl.SelectedValues = oDefaultValues
' End If
AddHandler oControl.SelectedValuesChanged, AddressOf Lookup_SelectedValuesChanged
' AddHandler oControl.SelectedValuesChanged, AddressOf Lookup_SelectedValuesChanged
oConnectionString = ClassFormFunctions.GetConnectionString(conid)
' oConnectionString = ClassFormFunctions.GetConnectionString(conid)
If oConnectionString IsNot Nothing And oSql.Length > 0 And SQLSuggestion = True Then
LOGGER.Debug("Connection String (redacted): [{0}]", oConnectionString.Substring(0, 30))
' If oConnectionString IsNot Nothing And oSql.Length > 0 And SQLSuggestion = True Then
' LOGGER.Debug("Connection String (redacted): [{0}]", oConnectionString.Substring(0, 30))
If ClassPatterns.HasComplexPatterns(oSql) Then
LOGGER.Debug(" >>sql enthält Platzhalter und wird erst während der Laufzeit gefüllt!", False)
Else
oSql = ClassPatterns.ReplaceInternalValues(oSql)
oSql = ClassPatterns.ReplaceUserValues(oSql, USER_PRENAME, USER_SURNAME, USER_SHORTNAME, USER_LANGUAGE, USER_EMAIL, USER_ID, CURRENT_DOKART_ID)
' If ClassPatterns.HasComplexPatterns(oSql) Then
' LOGGER.Debug(" >>sql enthält Platzhalter und wird erst während der Laufzeit gefüllt!", False)
' Else
' oSql = ClassPatterns.ReplaceInternalValues(oSql)
' oSql = ClassPatterns.ReplaceUserValues(oSql, USER_PRENAME, USER_SURNAME, USER_SHORTNAME, USER_LANGUAGE, USER_EMAIL, USER_ID, CURRENT_DOKART_ID)
Dim oDatatable = ClassDatabase.Return_Datatable_Combined(oSql, oConnectionString, False)
oControl.DataSource = oDatatable
End If
Else
LOGGER.Warn("Connection String for control [{0}] is empty!", oControl.Name)
End If
' Dim oDatatable = ClassDatabase.Return_Datatable_Combined(oSql, oConnectionString, False)
' oControl.DataSource = oDatatable
' End If
' Else
' LOGGER.Warn("Connection String for control [{0}] is empty!", oControl.Name)
' End If
Return oControl
Catch ex As Exception
LOGGER.Info(" - Unvorhergesehener Unexpected error in AddVorschlag_ComboBox - Indexname: " & indexname & " - Fehler: " & vbNewLine & ex.Message)
LOGGER.Error(ex)
MsgBox(ex.Message, MsgBoxStyle.Critical, "Unvorhergesehener Unexpected error in AddVorschlag_ComboBox:")
Return Nothing
End Try
End Function
' Return oControl
' Catch ex As Exception
' LOGGER.Info(" - Unvorhergesehener Unexpected error in AddVorschlag_ComboBox - Indexname: " & indexname & " - Fehler: " & vbNewLine & ex.Message)
' LOGGER.Error(ex)
' MsgBox(ex.Message, MsgBoxStyle.Critical, "Unvorhergesehener Unexpected error in AddVorschlag_ComboBox:")
' Return Nothing
' End Try
'End Function
Private Sub Lookup_SelectedValuesChanged(sender As LookupControl2, SelectedValues As List(Of String))
Private Sub Lookup_SelectedValuesChanged(sender As LookupControl3, SelectedValues As List(Of String))
PrepareDependingControl(sender)
End Sub
@@ -474,9 +474,9 @@ Public Class ClassControls
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
DirectCast(oFoundControl, LookupControl3).Properties.DataSource = oDatatable
Case GetType(ComboBox).Name
LOGGER.Debug("Setting Value for Combobox [{0}]: [{1}]", oFoundControl.Name, "DATATABLE")
DirectCast(oFoundControl, ComboBox).DataSource = oDatatable