jj 28.04.16

This commit is contained in:
JenneJ
2016-04-28 16:49:08 +02:00
parent 89275ed3f0
commit 31063ef93c
4 changed files with 55 additions and 36 deletions

View File

@@ -411,8 +411,9 @@ Public Class ClassControlValues
ClassLogger.Add("Enable_Depending_Controls: Control.ControlCollection is unexpected empty!")
Exit Sub
End If
Dim SQL As String = String.Format("select GUID,SQL_COMMAND_2 from TBPMO_CONTROL where FORM_ID = {0} AND SQL_COMMAND_2 IS NOT NULL " _
& "AND LEN(SQL_COMMAND_2) > 10 AND SQL_COMMAND_2 LIKE '%@%@%", FormId)
' Alle Controls finden, die Abhängigkeiten haben
Dim SQL As String = String.Format("select GUID,NAME,SQL_COMMAND_2 from TBPMO_CONTROL where FORM_ID = {0} AND SQL_COMMAND_2 IS NOT NULL " _
& "AND LEN(SQL_COMMAND_2) > 10 AND SQL_COMMAND_2 LIKE '%@%@%'", FormId)
Dim SW As Stopwatch = Stopwatch.StartNew()
Dim commands As New List(Of String)
Dim dt As DataTable = ClassDatabase.Return_Datatable(SQL)
@@ -421,35 +422,47 @@ Public Class ClassControlValues
Exit Sub
End If
For Each Ctrl As Control In controls
Dim controlTagId = DirectCast(Ctrl.Tag, ClassControlMetadata).Id
Dim row As DataRow = dt.Select(String.Format("CONTROL_ID={0}", controlTagId)).FirstOrDefault()
For Each row As DataRow In dt.Rows
Dim DependingControlId As Integer = row.Item("GUID")
Dim DependingControlSQL As String = row.Item("SQL_COMMAND_2")
Dim DependingControl As Control = controls.OfType(Of Control)().Where(Function(c As Control)
Return DirectCast(c.Tag, ClassControlMetadata).Id = DependingControlId
End Function).SingleOrDefault()
Dim regex As New System.Text.RegularExpressions.Regex("(@(\d+)@)")
Dim match As System.Text.RegularExpressions.Match = regex.Match(DependingControlSQL)
If match.Success Then
' Wir suchen aus dem SQL Befehl die ControlId heraus,
' von dem das aktuelle Control abhängt
Dim otherControlId As Integer
Integer.TryParse(match.Groups(2).Value, otherControlId)
' Jetzt suchen wir das Control, das zu dieser ControlId passt
Dim otherControl As Control = controls.OfType(Of Control)().Where(Function(c As Control)
Return DirectCast(c.Tag, ClassControlMetadata).Id = otherControlId
End Function).SingleOrDefault()
Dim otherControlType As String = otherControl.GetType().Name
' Jetzt holen wir uns den Wert von dem 'OtherControl'
' und geben seinen Value zusammen mit dem dependingControl weiter
Dim value As Object
Select Case otherControlType
Case "CheckBox"
value = DirectCast(otherControl, CheckBox).Checked
Case "TextBox"
value = DirectCast(otherControl, TextBox).Text
Case "CustomComboBox"
value = DirectCast(otherControl, CustomComboBox).SelectedText
Case "DateEdit"
value = DirectCast(otherControl, DevExpress.XtraEditors.DateEdit).EditValue
End Select
CtrlBuilder.Enable_Controls(DependingControl, dt, value)
If IsNothing(row) Then
Continue For
End If
Dim connID = row.Item("CONTROL_CONNID_1")
Dim sqlcommand As String = row.Item("SQL")
sqlcommand = ReplaceSqlCommandPlaceholders(sqlcommand, RecordId, ParentRecordId, entity_ID)
Select Case Ctrl.GetType()
Case GetType(CustomComboBox)
Dim combobox = DirectCast(Ctrl, CustomComboBox)
ControlLoader.Combobox.LoadList(combobox, FormId, connID, sqlcommand)
Case GetType(DevExpress.XtraEditors.ListBoxControl)
Dim listbox = DirectCast(Ctrl, DevExpress.XtraEditors.ListBoxControl)
ControlLoader.ListBox.LoadList(listbox, FormId, connID, sqlcommand)
Case GetType(DevExpress.XtraEditors.CheckedListBoxControl)
Dim chlistbox = DirectCast(Ctrl, DevExpress.XtraEditors.CheckedListBoxControl)
ControlLoader.CheckedListBox.LoadList(chlistbox, FormId, connID, sqlcommand)
End Select
Next
Dim elapsed As Double
elapsed = SW.Elapsed.TotalSeconds
SW.Stop()