jj 08.03.2016 control abhängigkeiten
This commit is contained in:
parent
72d2f25bcb
commit
9e9c1ee150
@ -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
|
||||
|
||||
@ -167,7 +167,7 @@ Public Class ClassControlValues
|
||||
Dim groupbox As GroupBox = DirectCast(control, GroupBox)
|
||||
LoadControlValues(RecordId, ParentRecordId, FormId, groupbox.Controls)
|
||||
Else
|
||||
LoadControlValueNeu(RecordId, ParentRecordId, ControlId, control, value)
|
||||
LoadControlValue(RecordId, ParentRecordId, ControlId, control, value)
|
||||
End If
|
||||
|
||||
Next
|
||||
@ -178,7 +178,7 @@ Public Class ClassControlValues
|
||||
|
||||
End Sub
|
||||
|
||||
Private Shared Sub LoadControlValueNeu(recordId As Integer, parentRecordId As Integer, controlId As Integer, control As Control, value As Object)
|
||||
Private Shared Sub LoadControlValue(recordId As Integer, parentRecordId As Integer, controlId As Integer, control As Control, value As Object)
|
||||
Try
|
||||
Select Case control.GetType()
|
||||
Case GetType(TextBox)
|
||||
|
||||
@ -409,6 +409,8 @@ Public Class frmFormInput
|
||||
' SelectedFormID = RowView.Item(1)
|
||||
RefreshRecordByID(SelectedRecordID)
|
||||
|
||||
ClassControlValues.LoadControlValuesList(thisformid, pnlView.Controls)
|
||||
ClassControlValues.LoadControlValuesListWithPlaceholders(thisformid, SelectedRecordID, CURRENT_PARENT_ID, pnlView.Controls)
|
||||
ClassControlValues.LoadControlValues(SelectedRecordID, CURRENT_PARENT_ID, thisformid, pnlView.Controls)
|
||||
End If
|
||||
load_Documents()
|
||||
@ -457,6 +459,8 @@ Public Class frmFormInput
|
||||
|
||||
Private Sub tsButtonAdd_Click(sender As Object, e As EventArgs) Handles tsButtonAdd.Click
|
||||
'CtrlCommandUI.LoadControls(thisformid)
|
||||
ClassControlValues.UnloadControlValuesList(SelectedRecordID, thisformid, pnlView.Controls)
|
||||
ClassControlValues.LoadControlValuesList(thisformid, pnlView.Controls)
|
||||
ClassControlValues.LoadDefaultValues(thisformid, SelectedRecordID, pnlView.Controls)
|
||||
|
||||
'Das Flag INSERT nach LoadControls setzen
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user