add depending controls for lookupgrid

This commit is contained in:
Jonathan Jenne 2020-02-11 14:44:25 +01:00
parent acf61c9ca5
commit b4e410291a
6 changed files with 2769 additions and 487 deletions

View File

@ -8,6 +8,8 @@ Public Class ClassControls
Public Class ControlMeta Public Class ControlMeta
Public Property IndexName As String Public Property IndexName As String
Public Property IndexType As String
Public Property MultipleValues As Boolean = False
End Class End Class
Public Sub New(Panel As Panel, Form As frmIndex) Public Sub New(Panel As Panel, Form As frmIndex)
@ -23,7 +25,8 @@ Public Class ClassControls
chk.Size = New Size(100, 27) chk.Size = New Size(100, 27)
chk.Location = New Point(11, y) chk.Location = New Point(11, y)
chk.Tag = New ControlMeta() With { chk.Tag = New ControlMeta() With {
.IndexName = indexname .IndexName = indexname,
.IndexType = "BOOLEAN"
} }
If caption <> "" Then If caption <> "" Then
@ -54,7 +57,7 @@ Public Class ClassControls
PrepareDependingControl(sender) PrepareDependingControl(sender)
End Sub End Sub
Public Function AddVorschlag_ComboBox(indexname As String, y As Integer, conid As Integer, sql_Vorschlag As String, Multiselect As Boolean, Optional Vorgabe As String = "", Optional AddNewValues As Boolean = False, Optional PreventDuplicateValues As Boolean = False) As Control 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) As Control
Try Try
Dim oSql As String = sql_Vorschlag Dim oSql As String = sql_Vorschlag
Dim oConnectionString As String Dim oConnectionString As String
@ -66,11 +69,12 @@ Public Class ClassControls
.Size = New Size(300, 27), .Size = New Size(300, 27),
.Name = "cmbMulti" & indexname, .Name = "cmbMulti" & indexname,
.Tag = New ControlMeta() With { .Tag = New ControlMeta() With {
.IndexName = indexname .IndexName = indexname,
.IndexType = DataType
} }
} }
AddHandler oControl. AddHandler oControl.SelectedValuesChanged, AddressOf Lookup_SelectedValuesChanged
oConnectionString = ClassFormFunctions.GetConnectionString(conid) oConnectionString = ClassFormFunctions.GetConnectionString(conid)
If oConnectionString IsNot Nothing Then If oConnectionString IsNot Nothing Then
@ -90,6 +94,10 @@ Public Class ClassControls
End Try End Try
End Function End Function
Private Sub Lookup_SelectedValuesChanged(sender As LookupControl2, SelectedValues As List(Of String))
PrepareDependingControl(sender)
End Sub
Function AddCombobox(indexname As String, y As Integer) Function AddCombobox(indexname As String, y As Integer)
Dim cmb As New ComboBox Dim cmb As New ComboBox
cmb.Name = "cmb" & indexname cmb.Name = "cmb" & indexname
@ -251,31 +259,26 @@ Public Class ClassControls
Catch ex As Exception Catch ex As Exception
End Try End Try
End If End If
End If End If
End If End If
Next Next
End If End If
Catch ex As Exception Catch ex As Exception
ClassLogger.Add(" - Unvorhergesehener Unexpected error in Renew_ComboboxResults - Fehler: " & vbNewLine & ex.Message) ClassLogger.Add(" - Unvorhergesehener Unexpected error in Renew_ComboboxResults - Fehler: " & vbNewLine & ex.Message)
MsgBox(ex.Message, MsgBoxStyle.Critical, "Unvorhergesehener Unexpected error in Renew_ComboboxResults:") MsgBox(ex.Message, MsgBoxStyle.Critical, "Unvorhergesehener Unexpected error in Renew_ComboboxResults:")
End Try End Try
End Sub End Sub
Public Function AddTextBox(indexname As String, y As Integer, text As String) As TextBox Public Function AddTextBox(indexname As String, y As Integer, text As String, DataType As String) As TextBox
Dim txt As New TextBox Dim txt As New TextBox
txt.Name = "txt" & indexname txt.Name = "txt" & indexname
txt.Size = New Size(260, 27) txt.Size = New Size(260, 27)
txt.Location = New Point(11, y) txt.Location = New Point(11, y)
txt.Tag = New ControlMeta() With { txt.Tag = New ControlMeta() With {
.IndexName = indexname .IndexName = indexname,
.IndexType = DataType
} }
If text <> "" Then If text <> "" Then

View File

@ -1,4 +1,5 @@
Imports System.Text.RegularExpressions Imports System.Text.RegularExpressions
Imports DigitalData.Controls.LookupGrid
Imports WINDREAMLib Imports WINDREAMLib
''' <summary> ''' <summary>
@ -151,8 +152,8 @@ Public Class ClassPatterns
End If End If
Dim controlName As String = GetNextPattern(result, PATTERN_CTRL).Value Dim controlName As String = GetNextPattern(result, PATTERN_CTRL).Value
'Dim control As Control = panel.Controls.Find(controlName, False).FirstOrDefault()
Dim oFoundControl As Control = Nothing Dim oFoundControl As Control = Nothing
Dim oFoundType As String = Nothing
For Each oControl As Control In panel.Controls For Each oControl As Control In panel.Controls
If TypeOf oControl Is Label Then If TypeOf oControl Is Label Then
@ -160,10 +161,10 @@ Public Class ClassPatterns
End If End If
Dim oMeta = DirectCast(oControl.Tag, ClassControls.ControlMeta) Dim oMeta = DirectCast(oControl.Tag, ClassControls.ControlMeta)
Dim oIndex As String = oMeta.IndexName
If oIndex = controlName Then If oMeta.IndexName = controlName Then
oFoundControl = oControl oFoundControl = oControl
oFoundType = oMeta.IndexType
Exit For Exit For
End If End If
Next Next
@ -175,6 +176,20 @@ Public Class ClassPatterns
oValue = DirectCast(oFoundControl, TextBox).Text oValue = DirectCast(oFoundControl, TextBox).Text
ElseIf TypeOf oFoundControl Is CheckBox Then ElseIf TypeOf oFoundControl Is CheckBox Then
oValue = IIf(DirectCast(oFoundControl, CheckBox).Checked, 1, 0) oValue = IIf(DirectCast(oFoundControl, CheckBox).Checked, 1, 0)
ElseIf TypeOf oFoundControl Is LookupControl2 Then
Dim oLookupControl = DirectCast(oFoundControl, LookupControl2)
If oLookupControl.MultiSelect Then
Select Case oFoundType
Case "INTEGER"
oValue = String.Join(",", oLookupControl.SelectedValues)
Case "VARCHAR"
Dim oWrapped = oLookupControl.SelectedValues.Select(Function(v) $"'{v}'")
oValue = String.Join(",", oWrapped)
End Select
Else
oValue = NotNull(oLookupControl.SelectedValues.Item(0), "")
End If
Else Else
oValue = "" oValue = ""
End If End If

View File

@ -957,11 +957,6 @@ Partial Class frmAdministration
' '
'XtraTabControl1 'XtraTabControl1
' '
Me.XtraTabControl1.AppearancePage.HeaderHotTracked.BackColor = System.Drawing.Color.Fuchsia
Me.XtraTabControl1.AppearancePage.HeaderHotTracked.BackColor2 = CType(resources.GetObject("XtraTabControl1.AppearancePage.HeaderHotTracked.BackColor2"), System.Drawing.Color)
Me.XtraTabControl1.AppearancePage.HeaderHotTracked.Font = CType(resources.GetObject("XtraTabControl1.AppearancePage.HeaderHotTracked.Font"), System.Drawing.Font)
Me.XtraTabControl1.AppearancePage.HeaderHotTracked.Options.UseBackColor = True
Me.XtraTabControl1.AppearancePage.HeaderHotTracked.Options.UseFont = True
resources.ApplyResources(Me.XtraTabControl1, "XtraTabControl1") resources.ApplyResources(Me.XtraTabControl1, "XtraTabControl1")
Me.XtraTabControl1.Name = "XtraTabControl1" Me.XtraTabControl1.Name = "XtraTabControl1"
Me.XtraTabControl1.SelectedTabPage = Me.XtraTabPage1 Me.XtraTabControl1.SelectedTabPage = Me.XtraTabPage1

File diff suppressed because it is too large Load Diff

View File

@ -424,9 +424,13 @@ Public Class frmAdministration
If frmloaded = True Then If frmloaded = True Then
If SUGGESTIONCheckBox.CheckState = CheckState.Checked Then If SUGGESTIONCheckBox.CheckState = CheckState.Checked Then
btnSQLView.Visible = True btnSQLView.Visible = True
'VKT_ADD_ITEMCheckbox.Enabled = True MULTISELECTCheckBox.Visible = True
VKT_ADD_ITEMCheckbox.Visible = True
Else Else
btnSQLView.Visible = False btnSQLView.Visible = False
MULTISELECTCheckBox.Visible = False
VKT_ADD_ITEMCheckbox.Visible = False
'If (_indexIsVectorField) Then 'If (_indexIsVectorField) Then
' VKT_ADD_ITEMCheckbox.Enabled = True ' VKT_ADD_ITEMCheckbox.Enabled = True

View File

@ -1502,32 +1502,32 @@ Public Class frmIndex
End If End If
Case "INTEGER" Case "INTEGER"
If DR.Item("SUGGESTION") = True And DR.Item("SQL_RESULT").ToString.Length > 0 Then If DR.Item("SUGGESTION") = True And DR.Item("SQL_RESULT").ToString.Length > 0 Then
Dim oControl = oControls.AddVorschlag_ComboBox(DR.Item("NAME"), y, DR.Item("CONNECTION_ID"), DR.Item("SQL_RESULT"), MultiSelect, DefaultValue, AddNewItems, PreventDuplicates) Dim oControl = oControls.AddVorschlag_ComboBox(DR.Item("NAME"), y, DR.Item("CONNECTION_ID"), DR.Item("SQL_RESULT"), MultiSelect, DR.Item("DATATYPE"), DefaultValue, AddNewItems, PreventDuplicates)
If Not IsNothing(oControl) Then If Not IsNothing(oControl) Then
pnlIndex.Controls.Add(oControl) pnlIndex.Controls.Add(oControl)
End If End If
Else Else
'nur eine Textbox 'nur eine Textbox
Dim oControl = oControls.AddTextBox(DR.Item("NAME"), y, DefaultValue) Dim oControl = oControls.AddTextBox(DR.Item("NAME"), y, DefaultValue, DR.Item("DATATYPE"))
If Not IsNothing(oControl) Then If Not IsNothing(oControl) Then
pnlIndex.Controls.Add(oControl) pnlIndex.Controls.Add(oControl)
End If End If
End If End If
Case "VARCHAR" Case "VARCHAR"
If DR.Item("SUGGESTION") = True And DR.Item("SQL_RESULT").ToString.Length > 0 Then If DR.Item("SUGGESTION") = True And DR.Item("SQL_RESULT").ToString.Length > 0 Then
Dim oControl = oControls.AddVorschlag_ComboBox(DR.Item("NAME"), y, DR.Item("CONNECTION_ID"), DR.Item("SQL_RESULT"), MultiSelect, DefaultValue, AddNewItems, PreventDuplicates) Dim oControl = oControls.AddVorschlag_ComboBox(DR.Item("NAME"), y, DR.Item("CONNECTION_ID"), DR.Item("SQL_RESULT"), MultiSelect, DR.Item("DATATYPE"), DefaultValue, AddNewItems, PreventDuplicates)
If Not IsNothing(oControl) Then If Not IsNothing(oControl) Then
pnlIndex.Controls.Add(oControl) pnlIndex.Controls.Add(oControl)
End If End If
Else Else
If DR.Item("NAME").ToString.ToLower = "dateiname" Then If DR.Item("NAME").ToString.ToLower = "dateiname" Then
Dim oControl = oControls.AddTextBox(DR.Item("NAME"), y, System.IO.Path.GetFileNameWithoutExtension(CURRENT_WORKFILE)) Dim oControl = oControls.AddTextBox(DR.Item("NAME"), y, System.IO.Path.GetFileNameWithoutExtension(CURRENT_WORKFILE), DR.Item("DATATYPE"))
If Not IsNothing(oControl) Then If Not IsNothing(oControl) Then
pnlIndex.Controls.Add(oControl) pnlIndex.Controls.Add(oControl)
End If End If
Else Else
Dim VORBELGUNG As String = DefaultValue Dim VORBELGUNG As String = DefaultValue
Dim oControl = oControls.AddTextBox(DR.Item("NAME"), y, VORBELGUNG) Dim oControl = oControls.AddTextBox(DR.Item("NAME"), y, VORBELGUNG, DR.Item("DATATYPE"))
If Not IsNothing(oControl) Then If Not IsNothing(oControl) Then
pnlIndex.Controls.Add(oControl) pnlIndex.Controls.Add(oControl)
End If End If