MS_
This commit is contained in:
@@ -404,7 +404,61 @@ Public Class ClassControlValues
|
||||
MsgBox("Unexpected Error in LoadControlValuesListWithPlaceholders:" & vbNewLine & ex.Message, MsgBoxStyle.Critical)
|
||||
End Try
|
||||
End Sub
|
||||
Public Shared Sub Enable_Depending_Controls(FormId As Integer, RecordId As Integer, ParentRecordId As Integer, controls As Control.ControlCollection, entity_ID As Integer)
|
||||
Try
|
||||
If controls.Count = 0 Then
|
||||
'MsgBox("LoadControlValuesListWithPlaceholders: Control.ControlCollection is unexpected empty!", MsgBoxStyle.Exclamation)
|
||||
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)
|
||||
Dim SW As Stopwatch = Stopwatch.StartNew()
|
||||
Dim commands As New List(Of String)
|
||||
Dim dt As DataTable = ClassDatabase.Return_Datatable(SQL)
|
||||
|
||||
If dt.Rows.Count = 0 Then
|
||||
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()
|
||||
|
||||
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()
|
||||
Console.WriteLine("Enable_Depending_Controls took {0} to load", Format(elapsed, "0.000000000") & " seconds")
|
||||
Catch ex As Exception
|
||||
ClassLogger.Add("Unexpected Error in Enable_Depending_Controls: " & ex.Message, True)
|
||||
MsgBox("Unexpected Error in Enable_Depending_Controls:" & vbNewLine & ex.Message, MsgBoxStyle.Critical)
|
||||
End Try
|
||||
End Sub
|
||||
Public Shared Function ReplaceSqlCommandPlaceholders(sqlCommand As String, recordId As Integer, parentRecordId As Integer, entity_Id As Integer)
|
||||
sqlCommand = sqlCommand.Replace("@RECORD_ID", recordId)
|
||||
sqlCommand = sqlCommand.Replace("@RECORDID", recordId)
|
||||
|
||||
Reference in New Issue
Block a user