jj_12_01_16
This commit is contained in:
@@ -11,28 +11,6 @@
|
||||
Return sqlCommand
|
||||
End Function
|
||||
|
||||
Public Shared Function LoadAutoValue(control As Windows.Forms.Control, RecordId As Integer, ParentRecordId As Integer)
|
||||
Dim AutoValue As String = String.Empty
|
||||
Dim ControlId As Integer = control.Tag
|
||||
Dim SQL As String = ClassDatabase.Execute_Scalar(String.Format("SELECT SQL_COMMAND_1 FROM TBPMO_CONTROL WHERE GUID = {0}", ControlId))
|
||||
SQL = ReplaceSqlCommandPlaceholders(SQL, RecordId, ParentRecordId)
|
||||
|
||||
If SQL = "" Or IsDBNull(SQL) Then
|
||||
Return control.Text
|
||||
End If
|
||||
|
||||
AutoValue = ClassDatabase.Execute_Scalar(SQL)
|
||||
|
||||
If String.IsNullOrEmpty(AutoValue) Or IsDBNull(AutoValue) Then
|
||||
SQL = String.Format("SELECT CONTROL_TEXT FROM TBPMO_CONTROL_SCREEN WHERE CONTROL_ID = {0}", ControlId)
|
||||
Dim value = ClassDatabase.Execute_Scalar(SQL)
|
||||
Return value
|
||||
Else
|
||||
Return AutoValue
|
||||
End If
|
||||
|
||||
End Function
|
||||
|
||||
End Class
|
||||
|
||||
Public Class _ListControl : Inherits _BaseControl
|
||||
@@ -47,10 +25,12 @@
|
||||
|
||||
Private Shared Function CheckForStaticList(controlId As Integer, recordId As Integer) As List(Of String)
|
||||
Try
|
||||
Dim SQL As String = String.Format("SELECT VALUE FROM VWPMO_VALUES WHERE CONTROL_ID = {0} AND RECORD_ID = {1}", controlId, recordId)
|
||||
' Der alte SQL Befehl hat nicht wirklich nach der StaticList geschaut o_O
|
||||
' Dim SQL As String = String.Format("SELECT VALUE FROM VWPMO_VALUES WHERE CONTROL_ID = {0} AND RECORD_ID = {1}", controlId, recordId)
|
||||
Dim SQL As String = String.Format("SELECT STATIC_LIST FROM TBPMO_CONTROL WHERE GUID = {0}", controlId)
|
||||
Dim staticList As String = ClassDatabase.Execute_Scalar(SQL)
|
||||
|
||||
If IsNothing(staticList) Then
|
||||
If IsNothing(staticList) Or String.IsNullOrWhiteSpace(staticList) Then
|
||||
Return Nothing
|
||||
Else
|
||||
Return New List(Of String)(staticList.Split(";"))
|
||||
@@ -100,6 +80,28 @@
|
||||
|
||||
Public Class Label : Inherits _BaseControl
|
||||
|
||||
Private Shared Function LoadAutoValue(control As Windows.Forms.Control, RecordId As Integer, ParentRecordId As Integer)
|
||||
Dim AutoValue As String = String.Empty
|
||||
Dim ControlId As Integer = control.Tag
|
||||
Dim SQL As String = ClassDatabase.Execute_Scalar(String.Format("SELECT SQL_COMMAND_1 FROM TBPMO_CONTROL WHERE GUID = {0}", ControlId))
|
||||
SQL = ReplaceSqlCommandPlaceholders(SQL, RecordId, ParentRecordId)
|
||||
|
||||
If SQL = "" Or IsDBNull(SQL) Then
|
||||
Return control.Text
|
||||
End If
|
||||
|
||||
AutoValue = ClassDatabase.Execute_Scalar(SQL)
|
||||
|
||||
If String.IsNullOrEmpty(AutoValue) Or IsDBNull(AutoValue) Then
|
||||
SQL = String.Format("SELECT CONTROL_TEXT FROM TBPMO_CONTROL_SCREEN WHERE CONTROL_ID = {0}", ControlId)
|
||||
Dim value = ClassDatabase.Execute_Scalar(SQL)
|
||||
Return value
|
||||
Else
|
||||
Return AutoValue
|
||||
End If
|
||||
|
||||
End Function
|
||||
|
||||
Public Shared Sub LoadValue(control As Windows.Forms.Label, recordId As Integer, parentRecordId As Integer, value As String)
|
||||
Dim autoValue = LoadAutoValue(control, recordId, parentRecordId)
|
||||
|
||||
@@ -154,7 +156,7 @@
|
||||
|
||||
Public Class Combobox : Inherits _ListControl
|
||||
|
||||
Public Shared Sub LoadValue(control As Windows.Forms.ComboBox, value As String)
|
||||
Public Shared Sub LoadValue(control As Windows.Forms.ComboBox, recordId As Integer, parentRecordId As Integer, value As String)
|
||||
control.Text = value
|
||||
End Sub
|
||||
|
||||
@@ -168,16 +170,42 @@
|
||||
|
||||
If dynamic.DataTable IsNot Nothing AndAlso dynamic.DataTable.Rows.Count > 0 Then
|
||||
Dim dt As DataTable = dynamic.DataTable
|
||||
Dim columnCount As Integer = dt.Columns.Count
|
||||
|
||||
control.DataSource = dt
|
||||
If dt.Columns.Count = 1 Then
|
||||
Dim sw2 = Stopwatch.StartNew()
|
||||
|
||||
'' Damit beim Setzen von DisplayMember und ValueMember kein Fehler auftritt,
|
||||
'' muss die Datasource zunächst geleert werden und der selected index auf -1 gesetzt werden.
|
||||
control.DataSource = Nothing
|
||||
control.SelectedIndex = -1
|
||||
|
||||
' Es ist wichtig, dass DisplayMember und ValueMember VOR der DataSource festgelegt werden,
|
||||
' Dadurch ist das Laden der Datasource um einiges SCHNELLER
|
||||
If columnCount = 1 Then
|
||||
control.DisplayMember = dt.Columns(0).ColumnName
|
||||
control.ValueMember = dt.Columns(0).ColumnName
|
||||
ElseIf dt.Columns.Count = 2 Then
|
||||
ElseIf columnCount = 2 Then
|
||||
control.DisplayMember = dt.Columns(1).ColumnName
|
||||
control.ValueMember = dt.Columns(0).ColumnName
|
||||
End If
|
||||
|
||||
' Als letztes setzen wir die DataSource
|
||||
control.DataSource = dt
|
||||
|
||||
' Die alte Methode:
|
||||
'control.DataSource = dt
|
||||
'If dt.Columns.Count = 1 Then
|
||||
' control.DisplayMember = dt.Columns(0).ColumnName
|
||||
' control.ValueMember = dt.Columns(0).ColumnName
|
||||
'ElseIf dt.Columns.Count = 2 Then
|
||||
' control.DisplayMember = dt.Columns(1).ColumnName
|
||||
' control.ValueMember = dt.Columns(0).ColumnName
|
||||
'End If
|
||||
|
||||
sw2.Stop()
|
||||
Console.WriteLine("Assingning the DataSource took {0}ms", sw2.ElapsedMilliseconds)
|
||||
|
||||
|
||||
CalculateDropdownWidth(control, dt)
|
||||
End If
|
||||
Catch ex As Exception
|
||||
|
||||
Reference in New Issue
Block a user