Depending Controls
This commit is contained in:
@@ -352,6 +352,8 @@ Public Class ClassControls
|
||||
Dim oDatatable As DataTable = ClassDatabase.Return_Datatable(oSQL)
|
||||
|
||||
If Not IsNothing(oDatatable) Then
|
||||
LOGGER.Debug("Found [{0}] depending controls for [{1}]", oDatatable.Rows.Count, Control.Name)
|
||||
|
||||
For Each oRow As DataRow In oDatatable.Rows
|
||||
Dim oControlName As String = NotNull(oRow.Item("NAME"), "")
|
||||
Dim oConnectionId As Integer = NotNull(oRow.Item("CONNECTION_ID"), -1)
|
||||
@@ -366,9 +368,11 @@ Public Class ClassControls
|
||||
oControlSql = ClassPatterns.ReplaceInternalValues(oControlSql)
|
||||
oControlSql = ClassPatterns.ReplaceControlValues(oControlSql, Panel)
|
||||
|
||||
|
||||
LOGGER.Debug("SQL After Preparing: [{0}]", oControlSql)
|
||||
LOGGER.Debug("Setting new value for [{0}]", oControlName)
|
||||
SetDependingControlResult(oControlName, oControlSql, oConnectionId)
|
||||
Next
|
||||
|
||||
End If
|
||||
Catch ex As Exception
|
||||
LOGGER.Error(ex)
|
||||
@@ -377,6 +381,11 @@ Public Class ClassControls
|
||||
|
||||
Private Sub SetDependingControlResult(IndexName As String, SqlCommand As String, SqlConnectionId As Integer)
|
||||
Try
|
||||
If SqlCommand Is Nothing OrElse SqlCommand = String.Empty Then
|
||||
LOGGER.Warn("New Value for Index [{0}] could not be set. Supplied SQL is empty.")
|
||||
Exit Sub
|
||||
End If
|
||||
|
||||
Dim oConnectionString = ClassFormFunctions.GetConnectionString(SqlConnectionId)
|
||||
Dim oDatatable As DataTable = ClassDatabase.Return_Datatable_CS(SqlCommand, oConnectionString)
|
||||
Dim oFoundControl As Control = Nothing
|
||||
@@ -404,10 +413,21 @@ Public Class ClassControls
|
||||
End If
|
||||
|
||||
If TypeOf oFoundControl Is TextBox Then
|
||||
DirectCast(oFoundControl, TextBox).Text = oDatatable.Rows.Item(0).Item(0)
|
||||
If oDatatable.Rows.Count > 0 Then
|
||||
Dim oFirstRow As DataRow = oDatatable.Rows.Item(0)
|
||||
|
||||
If oFirstRow.ItemArray.Length > 0 Then
|
||||
Dim oValue = oFirstRow.Item(0).ToString()
|
||||
|
||||
LOGGER.Debug("Setting Value for control [{0}]: [{1}]", oFoundControl.Name, oValue)
|
||||
DirectCast(oFoundControl, TextBox).Text = oValue
|
||||
End If
|
||||
End If
|
||||
ElseIf TypeOf oFoundControl Is LookupControl2 Then
|
||||
LOGGER.Debug("Setting Value for control [{0}]: [{1}]", oFoundControl.Name, "DATATABLE")
|
||||
DirectCast(oFoundControl, LookupControl2).DataSource = oDatatable
|
||||
ElseIf TypeOf oFoundControl Is ComboBox Then
|
||||
LOGGER.Debug("Setting Value for control [{0}]: [{1}]", oFoundControl.Name, "DATATABLE")
|
||||
DirectCast(oFoundControl, ComboBox).DataSource = oDatatable
|
||||
End If
|
||||
Catch ex As Exception
|
||||
|
||||
Reference in New Issue
Block a user