Consolidate SetControlData logic into function SetControlValues_FromControl
This commit is contained in:
parent
326190ad76
commit
b07f5a77bb
@ -1070,13 +1070,7 @@ Public Class frmValidator
|
|||||||
If DirectCast(oTextbox.Tag, ClassControlCreator.ControlMetadata).ReadOnly = False Then
|
If DirectCast(oTextbox.Tag, ClassControlCreator.ControlMetadata).ReadOnly = False Then
|
||||||
oTextbox.BackColor = Color.White
|
oTextbox.BackColor = Color.White
|
||||||
End If
|
End If
|
||||||
Dim oCONTROL_ID = DirectCast(oTextbox.Tag, ClassControlCreator.ControlMetadata).Guid
|
SetControlValues_FromControl(oTextbox)
|
||||||
Dim ofilteredData As DataTable = DT_CONTROLS.Clone()
|
|
||||||
Dim oExpression = $"GUID = {oCONTROL_ID} and Len(SET_CONTROL_DATA) > 0"
|
|
||||||
DT_CONTROLS.Select(oExpression).CopyToDataTable(ofilteredData, LoadOption.PreserveChanges)
|
|
||||||
If ofilteredData.Rows.Count = 1 Then
|
|
||||||
Dynamic_SetControlData(oTextbox, ofilteredData.Rows(0))
|
|
||||||
End If
|
|
||||||
|
|
||||||
ClassControlCreator.GridTables_HandleControlValueChange(PanelValidatorControl, DT_COLUMNS_GRID_WITH_SQL_WITH_CTRL_PLACEHOLDER)
|
ClassControlCreator.GridTables_HandleControlValueChange(PanelValidatorControl, DT_COLUMNS_GRID_WITH_SQL_WITH_CTRL_PLACEHOLDER)
|
||||||
End Sub
|
End Sub
|
||||||
@ -1133,9 +1127,7 @@ Public Class frmValidator
|
|||||||
LOGGER.Error(ex)
|
LOGGER.Error(ex)
|
||||||
LOGGER.Info("Unexpected Error in Eventhandler Variable SQL Result - ERROR: " & ex.Message)
|
LOGGER.Info("Unexpected Error in Eventhandler Variable SQL Result - ERROR: " & ex.Message)
|
||||||
End Try
|
End Try
|
||||||
If oTextBox.Name = last_control.Name Then
|
If oTextBox.Name <> last_control.Name Then
|
||||||
' Abschluss()
|
|
||||||
Else
|
|
||||||
SendKeys.Send("{TAB}")
|
SendKeys.Send("{TAB}")
|
||||||
ControlHandleStarted = True
|
ControlHandleStarted = True
|
||||||
End If
|
End If
|
||||||
@ -1386,15 +1378,8 @@ Public Class frmValidator
|
|||||||
CheckBox_DependingControls(oCheckbox)
|
CheckBox_DependingControls(oCheckbox)
|
||||||
Checkbox_EnablingControls(oCheckbox)
|
Checkbox_EnablingControls(oCheckbox)
|
||||||
CheckBox_DependingColumn(oCheckbox)
|
CheckBox_DependingColumn(oCheckbox)
|
||||||
|
SetControlValues_FromControl(oCheckbox)
|
||||||
ClassControlCreator.GridTables_HandleControlValueChange(PanelValidatorControl, DT_COLUMNS_GRID_WITH_SQL_WITH_CTRL_PLACEHOLDER)
|
ClassControlCreator.GridTables_HandleControlValueChange(PanelValidatorControl, DT_COLUMNS_GRID_WITH_SQL_WITH_CTRL_PLACEHOLDER)
|
||||||
|
|
||||||
Dim oCONTROL_ID = DirectCast(oCheckbox.Tag, ClassControlCreator.ControlMetadata).Guid
|
|
||||||
Dim ofilteredData As DataTable = DT_CONTROLS.Clone()
|
|
||||||
Dim oExpression = $"GUID = {oCONTROL_ID} and Len(SET_CONTROL_DATA) > 0"
|
|
||||||
DT_CONTROLS.Select(oExpression).CopyToDataTable(ofilteredData, LoadOption.PreserveChanges)
|
|
||||||
If ofilteredData.Rows.Count = 1 Then
|
|
||||||
Dynamic_SetControlData(oCheckbox, ofilteredData.Rows(0))
|
|
||||||
End If
|
|
||||||
Catch ex As Exception
|
Catch ex As Exception
|
||||||
LOGGER.Error(ex)
|
LOGGER.Error(ex)
|
||||||
End Try
|
End Try
|
||||||
@ -1407,134 +1392,12 @@ Public Class frmValidator
|
|||||||
LOGGER.Debug("onLookUpselectedValue_Control2Set")
|
LOGGER.Debug("onLookUpselectedValue_Control2Set")
|
||||||
Dim oRepositoryItem As RepositoryItemLookupControl3 = sender
|
Dim oRepositoryItem As RepositoryItemLookupControl3 = sender
|
||||||
Dim oLookup As LookupControl3 = oRepositoryItem.OwnerEdit
|
Dim oLookup As LookupControl3 = oRepositoryItem.OwnerEdit
|
||||||
SetControlValues(oLookup, SelectedValues)
|
SetControlValues_FromControl(oLookup)
|
||||||
End Sub
|
End Sub
|
||||||
|
|
||||||
Private Sub Dynamic_SetControlData(pControl As Control, oDataRow As DataRow)
|
Private Sub SetControlValues_FromControl(pControl As Control)
|
||||||
If FormLoaded = False Then
|
Dim oControlName = pControl.Name
|
||||||
Exit Sub
|
Dim oControlMeta = DirectCast(pControl.Tag, ClassControlCreator.ControlMetadata)
|
||||||
End If
|
|
||||||
LOGGER.Debug("onDynamic_SetControlData")
|
|
||||||
Dim oControlID = DirectCast(pControl.Tag, ClassControlCreator.ControlMetadata).Guid
|
|
||||||
|
|
||||||
Dim oControl2Set
|
|
||||||
Dim oControlGUID2Set = oControlID
|
|
||||||
Dim oControlname2Set = oDataRow.Item("NAME")
|
|
||||||
LOGGER.Debug($"Workin on SetControLValue for Control [{oControlID}-{oControlname2Set}] ...")
|
|
||||||
|
|
||||||
If _SetControlValue_in_action = True Then
|
|
||||||
LOGGER.Debug($"..but _SetControlValue_in_action = True ==> Exit Sub!")
|
|
||||||
Exit Sub
|
|
||||||
End If
|
|
||||||
If Not IsDBNull(oDataRow.Item("CONNECTION_ID")) And Not IsDBNull(oDataRow.Item("SET_CONTROL_DATA")) Then
|
|
||||||
Dim oSqlCommand = IIf(IsDBNull(oDataRow.Item("SET_CONTROL_DATA")), "", oDataRow.Item("SET_CONTROL_DATA"))
|
|
||||||
oSqlCommand = clsPatterns.ReplaceAllValues(oSqlCommand, PanelValidatorControl, True)
|
|
||||||
_SetControlValue_in_action = True
|
|
||||||
Dim oDTDEPENDING_RESULT As DataTable = ClassDatabase.Return_Datatable_ConId(oSqlCommand, oDataRow.Item("CONNECTION_ID"), $"Dynamic_SetControlData-Control [{oControlID}-{oControlname2Set}]")
|
|
||||||
For Each oRowControl2Set As DataRow In oDTDEPENDING_RESULT.Rows
|
|
||||||
Try
|
|
||||||
oControl2Set = oRowControl2Set.Item("Control2Set")
|
|
||||||
If oControl2Set.ToString.ToUpper = "BTN_FINISH".ToUpper Then
|
|
||||||
Try
|
|
||||||
Try
|
|
||||||
Dim btntext = oRowControl2Set.Item("Caption")
|
|
||||||
btnSave.Text = btntext & " (F2)"
|
|
||||||
Catch ex As Exception
|
|
||||||
|
|
||||||
End Try
|
|
||||||
Try
|
|
||||||
Dim oColor1 = System.Drawing.Color.FromName(oRowControl2Set.Item("BackgroundColor"))
|
|
||||||
btnSave.BackColor = oColor1
|
|
||||||
Catch ex As Exception
|
|
||||||
btnSave.BackColor = Color.Transparent
|
|
||||||
End Try
|
|
||||||
Try
|
|
||||||
Dim oColor2 = System.Drawing.Color.FromName(oRowControl2Set.Item("FontColor"))
|
|
||||||
btnSave.ForeColor = oColor2
|
|
||||||
Catch ex As Exception
|
|
||||||
btnSave.ForeColor = Color.Black
|
|
||||||
End Try
|
|
||||||
|
|
||||||
Catch ex As Exception
|
|
||||||
|
|
||||||
End Try
|
|
||||||
_SetControlValue_in_action = False
|
|
||||||
Continue For
|
|
||||||
End If
|
|
||||||
Dim oFound As Boolean = False
|
|
||||||
If IsNumeric(oControl2Set) = False Then
|
|
||||||
LOGGER.Warn("Careful: the oControl2Set contains no CONTROL_GUID")
|
|
||||||
Exit Sub
|
|
||||||
End If
|
|
||||||
|
|
||||||
For Each oControl As Control In PanelValidatorControl.Controls
|
|
||||||
If DirectCast(oControl.Tag, ClassControlCreator.ControlMetadata).Guid = oControl2Set Then
|
|
||||||
oFound = True
|
|
||||||
LOGGER.Debug($"Got the Control22Set: {oControl2Set}..Setting the values..")
|
|
||||||
'NUR TEXTBOX
|
|
||||||
Select Case oControl.GetType.ToString
|
|
||||||
|
|
||||||
Case GetType(TextBox).ToString
|
|
||||||
Dim oTextOption = "Replace"
|
|
||||||
Try
|
|
||||||
oTextOption = oRowControl2Set.Item("TextOption")
|
|
||||||
Catch ex As Exception
|
|
||||||
oTextOption = "Replace"
|
|
||||||
End Try
|
|
||||||
Try
|
|
||||||
Dim oTEXT = oRowControl2Set.Item("Caption")
|
|
||||||
If oTextOption = "Replace" Then
|
|
||||||
oControl.Text = oTEXT
|
|
||||||
Else
|
|
||||||
oControl.Text = oControl.Text & oTEXT
|
|
||||||
End If
|
|
||||||
Catch ex As Exception
|
|
||||||
|
|
||||||
End Try
|
|
||||||
Dim oColor
|
|
||||||
Try
|
|
||||||
oColor = System.Drawing.Color.FromName(oRowControl2Set.Item("BackgroundColor"))
|
|
||||||
oControl.BackColor = oColor
|
|
||||||
Catch ex As Exception
|
|
||||||
oControl.BackColor = Color.White
|
|
||||||
End Try
|
|
||||||
Try
|
|
||||||
oColor = System.Drawing.Color.FromName(oRowControl2Set.Item("FontColor"))
|
|
||||||
oControl.ForeColor = oColor
|
|
||||||
Catch ex As Exception
|
|
||||||
oControl.ForeColor = Color.Black
|
|
||||||
End Try
|
|
||||||
|
|
||||||
Case GetType(LookupControl3).ToString
|
|
||||||
Dim oDependingLookup As LookupControl3 = oControl
|
|
||||||
oDependingLookup.Properties.DataSource = oDTDEPENDING_RESULT
|
|
||||||
oDependingLookup.Properties.ValueMember = oDTDEPENDING_RESULT.Columns.Item(0).ColumnName
|
|
||||||
oDependingLookup.Properties.DisplayMember = oDTDEPENDING_RESULT.Columns.Item(0).ColumnName
|
|
||||||
Case GetType(GridControl).ToString
|
|
||||||
'ClassControlCreator.GridTables
|
|
||||||
|
|
||||||
End Select
|
|
||||||
_SetControlValue_in_action = False
|
|
||||||
Exit For
|
|
||||||
End If
|
|
||||||
|
|
||||||
Next
|
|
||||||
|
|
||||||
If oFound = False Then
|
|
||||||
LOGGER.Debug($"Could not find the Control2Set with ID {oControlGUID2Set} on panel!!!")
|
|
||||||
End If
|
|
||||||
Catch ex As Exception
|
|
||||||
LOGGER.Warn($"Error while Dynamic_SetControlData for [{oControlname2Set}]: " & ex.Message)
|
|
||||||
_SetControlValue_in_action = False
|
|
||||||
End Try
|
|
||||||
Next
|
|
||||||
Else
|
|
||||||
LOGGER.Debug($"Error Dynamic_SetControlData: Check ConnID and SQL on NULL VALUES!")
|
|
||||||
End If
|
|
||||||
End Sub
|
|
||||||
Private Sub SetControlValues(pLookupControl As LookupControl3, pSelectedValues As List(Of String))
|
|
||||||
Dim oControlName = pLookupControl.Name
|
|
||||||
Dim oControlMeta = DirectCast(pLookupControl.Tag, ClassControlCreator.ControlMetadata)
|
|
||||||
Dim oControlID = oControlMeta.Guid
|
Dim oControlID = oControlMeta.Guid
|
||||||
|
|
||||||
If _SetControlValue_in_action = True Then
|
If _SetControlValue_in_action = True Then
|
||||||
@ -1542,19 +1405,6 @@ Public Class frmValidator
|
|||||||
Exit Sub
|
Exit Sub
|
||||||
End If
|
End If
|
||||||
|
|
||||||
If pSelectedValues Is Nothing Then
|
|
||||||
LOGGER.Warn("Cannot set Control Values from Lookup [{0}], selected values are empty.", oControlName)
|
|
||||||
Exit Sub
|
|
||||||
End If
|
|
||||||
|
|
||||||
If pSelectedValues.Count > 1 Then
|
|
||||||
LOGGER.Warn("Cannot set Control Values from Lookup [{0}], selected values more than one.", oControlName)
|
|
||||||
Exit Sub
|
|
||||||
End If
|
|
||||||
|
|
||||||
Dim oControlValue = pSelectedValues.First()
|
|
||||||
LOGGER.Debug("Control Value is [{0}]!", oControlValue)
|
|
||||||
|
|
||||||
Dim oFilteredDatatable As DataTable = DT_CONTROLS.Clone()
|
Dim oFilteredDatatable As DataTable = DT_CONTROLS.Clone()
|
||||||
DT_CONTROLS.
|
DT_CONTROLS.
|
||||||
Select($"GUID = {oControlID} and LEN(SET_CONTROL_DATA) > 0").
|
Select($"GUID = {oControlID} and LEN(SET_CONTROL_DATA) > 0").
|
||||||
@ -2079,12 +1929,8 @@ Public Class frmValidator
|
|||||||
ClassControlCreator.GridTables_HandleControlValueChange(PanelValidatorControl, DT_COLUMNS_GRID_WITH_SQL_WITH_CTRL_PLACEHOLDER)
|
ClassControlCreator.GridTables_HandleControlValueChange(PanelValidatorControl, DT_COLUMNS_GRID_WITH_SQL_WITH_CTRL_PLACEHOLDER)
|
||||||
|
|
||||||
Controls2beEnabled(oCombobox.Name)
|
Controls2beEnabled(oCombobox.Name)
|
||||||
Dim ofilteredData As DataTable = DT_CONTROLS.Clone()
|
|
||||||
Dim oExpression = $"GUID = {CONTROL_ID} and Len(SET_CONTROL_DATA) > 0"
|
SetControlValues_FromControl(oCombobox)
|
||||||
DT_CONTROLS.Select(oExpression).CopyToDataTable(ofilteredData, LoadOption.PreserveChanges)
|
|
||||||
If ofilteredData.Rows.Count = 1 Then
|
|
||||||
Dynamic_SetControlData(oCombobox, ofilteredData.Rows(0))
|
|
||||||
End If
|
|
||||||
Catch ex As Exception
|
Catch ex As Exception
|
||||||
LOGGER.Error(ex)
|
LOGGER.Error(ex)
|
||||||
LOGGER.Info("Unexpected Error in Eventhandler Variable SQL Result ComboBox - ERROR: " & ex.Message)
|
LOGGER.Info("Unexpected Error in Eventhandler Variable SQL Result ComboBox - ERROR: " & ex.Message)
|
||||||
@ -5378,19 +5224,11 @@ Public Class frmValidator
|
|||||||
ToolTip1.Show(oMsg, btnSave)
|
ToolTip1.Show(oMsg, btnSave)
|
||||||
End Sub
|
End Sub
|
||||||
|
|
||||||
Private Sub frmValidator_KeyDown(sender As Object, e As KeyEventArgs) Handles Me.KeyDown
|
|
||||||
|
|
||||||
End Sub
|
|
||||||
|
|
||||||
Private Sub CheckBox1_CheckedChanged(sender As Object, e As EventArgs)
|
|
||||||
|
|
||||||
End Sub
|
|
||||||
Sub Reload_Controls(SingleAttribute As String)
|
Sub Reload_Controls(SingleAttribute As String)
|
||||||
If IDB_ACTIVE = True Then
|
If IDB_ACTIVE = True Then
|
||||||
Load_IDB_DOC_DATA()
|
Load_IDB_DOC_DATA()
|
||||||
End If
|
End If
|
||||||
FillIndexValues(False)
|
FillIndexValues(False)
|
||||||
|
|
||||||
End Sub
|
End Sub
|
||||||
|
|
||||||
Sub SetStatusLabel(infotext As String, Optional pColor As String = "")
|
Sub SetStatusLabel(infotext As String, Optional pColor As String = "")
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user