Support for SetControlData for LookupGrids
This commit is contained in:
parent
d92a640bce
commit
153d5a6128
@ -1406,17 +1406,7 @@ Public Class frmValidator
|
||||
LOGGER.Debug("onLookUpselectedValue_Control2Set")
|
||||
Dim oRepositoryItem As RepositoryItemLookupControl3 = sender
|
||||
Dim oLookup As LookupControl3 = oRepositoryItem.OwnerEdit
|
||||
Try
|
||||
If Not IsNothing(SelectedValues) Then
|
||||
If SelectedValues.Count = 1 Then
|
||||
SetControlValues(oLookup, SelectedValues)
|
||||
Else
|
||||
LOGGER.Debug("Attention - onLookUpselectedValue_Control2Set: SelectedValues.Count <> 1 - Not implemented multiple selections!")
|
||||
End If
|
||||
End If
|
||||
Catch ex As Exception
|
||||
LOGGER.Error(ex)
|
||||
End Try
|
||||
SetControlValues(oLookup, SelectedValues)
|
||||
End Sub
|
||||
|
||||
Private Sub Dynamic_SetControlData(pControl As Control, oDataRow As DataRow)
|
||||
@ -1541,132 +1531,180 @@ Public Class frmValidator
|
||||
LOGGER.Debug($"Error Dynamic_SetControlData: Check ConnID and SQL on NULL VALUES!")
|
||||
End If
|
||||
End Sub
|
||||
Private Sub SetControlValues(LookupControl As LookupControl3, SelectedValues As List(Of String))
|
||||
Dim oLOOKUPValue = SelectedValues.Item(0)
|
||||
Dim oLOOKUPName = LookupControl.Name
|
||||
LOGGER.Debug($"oLOOKUPValue is [{oLOOKUPValue}]!")
|
||||
Dim oControlID = DirectCast(LookupControl.Tag, ClassControlCreator.ControlMetadata).Guid
|
||||
Dim oFilteredDatatable As DataTable = DT_CONTROLS.Clone()
|
||||
Dim oExpression = $"GUID = {oControlID} and LEN(SET_CONTROL_DATA) > 0"
|
||||
DT_CONTROLS.Select(oExpression).CopyToDataTable(oFilteredDatatable, LoadOption.PreserveChanges)
|
||||
If oFilteredDatatable.Rows.Count = 1 Then
|
||||
LOGGER.Debug($"We got a definition for SetControlValues!!")
|
||||
Else
|
||||
Exit Sub
|
||||
End If
|
||||
|
||||
Dim oControl2Set
|
||||
Dim oControlGUID2Set = oControlID
|
||||
Dim oControlname2Set = oFilteredDatatable.Rows(0).Item("NAME")
|
||||
LOGGER.Debug($"Workin on SetControLValue for {oControlname2Set} ...")
|
||||
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
|
||||
|
||||
If _SetControlValue_in_action = True Then
|
||||
LOGGER.Debug($"..but _SetControlValue_in_action = True ==> Exit Sub!")
|
||||
LOGGER.Debug("SetControlValue in action. Exiting.")
|
||||
Exit Sub
|
||||
End If
|
||||
If Not IsDBNull(oFilteredDatatable.Rows(0).Item("CONNECTION_ID")) And Not IsDBNull(oFilteredDatatable.Rows(0).Item("SET_CONTROL_DATA")) Then
|
||||
Dim oSqlCommand = IIf(IsDBNull(oFilteredDatatable.Rows(0).Item("SET_CONTROL_DATA")), "", oFilteredDatatable.Rows(0).Item("SET_CONTROL_DATA"))
|
||||
oSqlCommand = clsPatterns.ReplaceAllValues(oSqlCommand, PanelValidatorControl, True)
|
||||
_SetControlValue_in_action = True
|
||||
Dim oDTDEPENDING_RESULT As DataTable = ClassDatabase.Return_Datatable_ConId(oSqlCommand, oFilteredDatatable.Rows(0).Item("CONNECTION_ID"), $"SetControlValues - CTRLID {oControlID}")
|
||||
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
|
||||
'Dim oDependingLookup As LookupControl3 = pnldesigner.Controls.Find(oDEPENDING_CtrlName, False).FirstOrDefault()
|
||||
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..")
|
||||
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 Control2Set for [{oControlname2Set}]: " & ex.Message)
|
||||
_SetControlValue_in_action = False
|
||||
End Try
|
||||
Next
|
||||
Else
|
||||
LOGGER.Debug($"Error: Check CoNN ID and SQL on NULL VALUES!")
|
||||
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()
|
||||
DT_CONTROLS.
|
||||
Select($"GUID = {oControlID} and LEN(SET_CONTROL_DATA) > 0").
|
||||
CopyToDataTable(oFilteredDatatable, LoadOption.PreserveChanges)
|
||||
|
||||
If oFilteredDatatable.Rows.Count < 1 Then
|
||||
LOGGER.Debug("SET_CONTROL_DATA is empty for control [{0}]. Exiting.", oControlName)
|
||||
Exit Sub
|
||||
End If
|
||||
|
||||
Dim oRow As DataRow = oFilteredDatatable.Rows.Item(0)
|
||||
Dim oControlGUID2Set = oControlID
|
||||
Dim oControlname2Set = oRow.Item("NAME")
|
||||
LOGGER.Debug($"Workin on SetControLValue for {oControlname2Set} ...")
|
||||
|
||||
Dim oConnectionId = NotNull(oRow.Item("CONNECTION_ID"), 0)
|
||||
Dim oControlDataSql = NotNull(oRow.Item("SET_CONTROL_DATA"), String.Empty)
|
||||
|
||||
If oConnectionId = 0 Or oControlDataSql = String.Empty Then
|
||||
LOGGER.Debug($"Error: Check CoNN ID and SQL on NULL VALUES!")
|
||||
Exit Sub
|
||||
End If
|
||||
|
||||
Dim oSqlCommand = NotNull(oRow.Item("SET_CONTROL_DATA"), String.Empty)
|
||||
oSqlCommand = clsPatterns.ReplaceAllValues(oSqlCommand, PanelValidatorControl, True)
|
||||
|
||||
Dim oControlDataResult As DataTable = ClassDatabase.Return_Datatable_ConId(oSqlCommand, oConnectionId, $"SetControlValues - CTRLID {oControlID}")
|
||||
|
||||
If oControlDataResult Is Nothing Then
|
||||
Exit Sub
|
||||
End If
|
||||
|
||||
For Each oResultRow As DataRow In oControlDataResult.Rows
|
||||
Try
|
||||
_SetControlValue_in_action = True
|
||||
|
||||
Dim oControl2Set = oResultRow.Item("Control2Set")
|
||||
If oControl2Set.ToString.ToUpper = "BTN_FINISH".ToUpper Then
|
||||
Try
|
||||
Dim btntext = oResultRow.Item("Caption")
|
||||
btnSave.Text = btntext & " (F2)"
|
||||
Catch ex As Exception
|
||||
LOGGER.Error(ex)
|
||||
End Try
|
||||
|
||||
Try
|
||||
Dim oColor1 = Color.FromName(oResultRow.Item("BackgroundColor"))
|
||||
btnSave.BackColor = oColor1
|
||||
Catch ex As Exception
|
||||
LOGGER.Error(ex)
|
||||
btnSave.BackColor = Color.Transparent
|
||||
End Try
|
||||
|
||||
Try
|
||||
Dim oColor2 = Color.FromName(oResultRow.Item("FontColor"))
|
||||
btnSave.ForeColor = oColor2
|
||||
Catch ex As Exception
|
||||
LOGGER.Error(ex)
|
||||
btnSave.ForeColor = Color.Black
|
||||
End Try
|
||||
|
||||
_SetControlValue_in_action = False
|
||||
Continue For
|
||||
End If
|
||||
|
||||
Dim oFound As Boolean = False
|
||||
Dim oControlId2Set As Integer
|
||||
|
||||
If Not Integer.TryParse(oControl2Set, oControlId2Set) Then
|
||||
LOGGER.Warn("Careful: the oControl2Set contains no CONTROL_GUID")
|
||||
Exit Sub
|
||||
End If
|
||||
|
||||
For Each oControl As Control In PanelValidatorControl.Controls
|
||||
Dim oMeta As ClassControlCreator.ControlMetadata = DirectCast(oControl.Tag, ClassControlCreator.ControlMetadata)
|
||||
|
||||
If oMeta.Guid = oControlId2Set Then
|
||||
|
||||
LOGGER.Debug($"Got the Control22Set: {oControlId2Set}..Setting the values..")
|
||||
Dim oCaption As Object = oResultRow.Item("Caption")
|
||||
|
||||
Dim oTextOption = Nothing
|
||||
Try
|
||||
oTextOption = oResultRow.Item("TextOption")
|
||||
Catch ex As Exception
|
||||
LOGGER.Error(ex)
|
||||
oTextOption = "Replace"
|
||||
End Try
|
||||
|
||||
Select Case oControl.GetType()
|
||||
Case GetType(TextBox)
|
||||
Try
|
||||
If oTextOption = "Replace" Then
|
||||
oControl.Text = oCaption
|
||||
Else
|
||||
oControl.Text &= oCaption
|
||||
End If
|
||||
Catch ex As Exception
|
||||
LOGGER.Error(ex)
|
||||
End Try
|
||||
|
||||
Dim oColor
|
||||
Try
|
||||
oColor = Color.FromName(oResultRow.Item("BackgroundColor"))
|
||||
oControl.BackColor = oColor
|
||||
Catch ex As Exception
|
||||
LOGGER.Error(ex)
|
||||
oControl.BackColor = Color.White
|
||||
End Try
|
||||
|
||||
Try
|
||||
oColor = Color.FromName(oResultRow.Item("FontColor"))
|
||||
oControl.ForeColor = oColor
|
||||
Catch ex As Exception
|
||||
LOGGER.Error(ex)
|
||||
oControl.ForeColor = Color.Black
|
||||
End Try
|
||||
|
||||
Case GetType(LookupControl3)
|
||||
Dim oDependingLookup As LookupControl3 = oControl
|
||||
If oDependingLookup.Properties.MultiSelect = True Then
|
||||
If oTextOption = "Replace" Then
|
||||
oDependingLookup.Properties.SelectedValues = New List(Of String) From {oCaption}
|
||||
Else
|
||||
oDependingLookup.Properties.SelectedValues.Add(oCaption)
|
||||
End If
|
||||
Else
|
||||
oDependingLookup.Properties.SelectedValues = New List(Of String) From {oCaption}
|
||||
End If
|
||||
|
||||
Case Else
|
||||
LOGGER.Warn("SetControlData used on unsupported control")
|
||||
|
||||
End Select
|
||||
|
||||
oFound = True
|
||||
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.Error(ex)
|
||||
LOGGER.Warn($"Error while Control2Set for [{oControlname2Set}]: " & ex.Message)
|
||||
Finally
|
||||
_SetControlValue_in_action = False
|
||||
End Try
|
||||
Next
|
||||
End Sub
|
||||
Private Sub LookupControl_DependingControls(LookupControl As LookupControl3, SelectedValues As List(Of String))
|
||||
Dim oLOOKUPValue = SelectedValues.Item(0)
|
||||
@ -5659,14 +5697,4 @@ Public Class frmValidator
|
||||
End If
|
||||
|
||||
End Sub
|
||||
|
||||
Private Sub BarButtonItem6_ItemClick_2(sender As Object, e As DevExpress.XtraBars.ItemClickEventArgs) Handles BarButtonItem6.ItemClick
|
||||
For Each oControl In PanelValidatorControl.Controls
|
||||
If TypeOf oControl Is GridControl Then
|
||||
Dim oGrid = DirectCast(oControl, GridControl)
|
||||
Dim oView = DirectCast(oGrid.FocusedView, GridView)
|
||||
oView.FocusInvalidRow()
|
||||
End If
|
||||
Next
|
||||
End Sub
|
||||
End Class
|
||||
Loading…
x
Reference in New Issue
Block a user