jj 08.03.2016 control abhängigkeiten
This commit is contained in:
@@ -78,6 +78,55 @@ Public Class ClassControlBuilder
|
||||
Dim combo As ComboBox = sender
|
||||
combo.BackColor = Color.White
|
||||
End Sub
|
||||
|
||||
Public Sub OnComboBoxValueChanged(sender As Object, ByVal e As EventArgs)
|
||||
Try
|
||||
Dim control As ComboBox = DirectCast(sender, ComboBox)
|
||||
Dim controlId As Integer = DirectCast(control.Tag, ClassControlMetadata).Id
|
||||
Dim SQL As String = String.Format("SELECT GUID, SQL_COMMAND_1 FROM TBPMO_CONTROL WHERE SQL_COMMAND_1 LIKE '%@{0}@%'", controlId)
|
||||
Dim value As String = control.SelectedValue
|
||||
Dim datatable As DataTable = ClassDatabase.Return_Datatable(SQL)
|
||||
|
||||
If datatable.Rows.Count = 0 Then
|
||||
Exit Sub
|
||||
End If
|
||||
|
||||
Dim sqlcommand As String = datatable.Rows(0).Item("SQL_COMMAND_1")
|
||||
|
||||
If IsNothing(sqlcommand) Then
|
||||
Exit Sub
|
||||
End If
|
||||
|
||||
If String.IsNullOrEmpty(value) Then
|
||||
Exit Sub
|
||||
End If
|
||||
|
||||
|
||||
|
||||
Dim regex As New System.Text.RegularExpressions.Regex("(@(\d+)@)")
|
||||
Dim match As System.Text.RegularExpressions.Match = regex.Match(sqlcommand)
|
||||
|
||||
If match.Success Then
|
||||
' DependingControlId bezeichnet das Control, das die Abhängigkeit enthält
|
||||
Dim dependingControlId As Integer = datatable.Rows(0).Item("GUID")
|
||||
Dim panel As Panel = DirectCast(control.Parent, Panel)
|
||||
' Über die Id das Control finden
|
||||
Dim dependingControl As ComboBox = Panel.Controls.OfType(Of ComboBox)().Where(Function(c As ComboBox)
|
||||
Return DirectCast(c.Tag, ClassControlMetadata).Id = dependingControlId
|
||||
End Function).SingleOrDefault()
|
||||
|
||||
sqlcommand = sqlcommand.Replace(match.Groups(1).Value, value)
|
||||
Console.WriteLine("Executing SQL_COMMAND: {0}", sqlcommand)
|
||||
Dim dt As DataTable = ClassDatabase.Return_Datatable(sqlcommand)
|
||||
ControlLoader.Combobox.SetDataSource(dependingControl, dt)
|
||||
End If
|
||||
|
||||
Console.WriteLine("value changed")
|
||||
Catch ex As Exception
|
||||
MsgBox("Error in OnComboBoxValueChanged: " & ex.Message)
|
||||
End Try
|
||||
End Sub
|
||||
|
||||
' ==================================================================================
|
||||
' Mouse Up/Down/Move-Handler für LevelDesigner festlegen
|
||||
' RecordChanged-Handler für Constructor festlegen
|
||||
@@ -104,6 +153,7 @@ Public Class ClassControlBuilder
|
||||
Case "ComboBox"
|
||||
Dim combo As ComboBox = CType(control, ComboBox)
|
||||
AddHandler combo.SelectedValueChanged, AddressOf RecordChanged
|
||||
AddHandler combo.SelectedValueChanged, AddressOf OnComboBoxValueChanged
|
||||
AddHandler combo.TextChanged, AddressOf RecordChanged
|
||||
AddHandler combo.GotFocus, AddressOf OnComboBoxFocus
|
||||
AddHandler combo.LostFocus, AddressOf OnComboBoxLostFocus
|
||||
|
||||
Reference in New Issue
Block a user