MS_07.03.2016
This commit is contained in:
@@ -15,6 +15,7 @@
|
||||
Try
|
||||
Dim AutoValue As String = String.Empty
|
||||
Dim ControlId As Integer = DirectCast(control.Tag, ClassControlMetadata).Id
|
||||
Dim CONNID = ClassDatabase.Execute_Scalar(String.Format("SELECT CONNECTION_ID_1 FROM TBPMO_CONTROL WHERE GUID = {0}", ControlId))
|
||||
Dim SQL As String = ClassDatabase.Execute_Scalar(String.Format("SELECT SQL_COMMAND_1 FROM TBPMO_CONTROL WHERE GUID = {0}", ControlId))
|
||||
SQL = ClassControlValues.ReplaceSqlCommandPlaceholders(SQL, RecordId, ParentRecordId)
|
||||
|
||||
@@ -22,7 +23,12 @@
|
||||
Return Nothing
|
||||
End If
|
||||
|
||||
AutoValue = ClassDatabase.Execute_Scalar(SQL)
|
||||
If Not IsNothing(CONNID) Then
|
||||
AutoValue = ClassDatabase.Execute_ScalarWithConnection(CONNID, SQL)
|
||||
Else
|
||||
AutoValue = ClassDatabase.Execute_Scalar(SQL)
|
||||
End If
|
||||
' AutoValue = ClassDatabase.Execute_Scalar(SQL)
|
||||
|
||||
If String.IsNullOrEmpty(AutoValue) Or IsDBNull(AutoValue) Then
|
||||
Return Nothing
|
||||
@@ -41,11 +47,11 @@
|
||||
|
||||
Public Class _ListControl : Inherits _BaseControl
|
||||
|
||||
Public Shared Function GetDynamicValue(controlId As Integer, formId As Integer, sqlCommand As String) As DynamicValue
|
||||
Public Shared Function GetDynamicValue(controlId As Integer, formId As Integer, connID As Object, sqlCommand As String) As DynamicValue
|
||||
Dim returnValue As DynamicValue
|
||||
|
||||
returnValue.StaticList = CheckForStaticList(controlId)
|
||||
returnValue.DataTable = GetSqlList(controlId, formId, sqlCommand)
|
||||
returnValue.DataTable = GetSqlList(controlId, formId, connID, sqlCommand)
|
||||
|
||||
Return returnValue
|
||||
End Function
|
||||
@@ -68,7 +74,7 @@
|
||||
End Try
|
||||
End Function
|
||||
|
||||
Private Shared Function GetSqlList(controlId As Integer, formId As Integer, sqlCommand As String)
|
||||
Private Shared Function GetSqlList(controlId As Integer, formId As Integer, connection_Id As Object, sqlCommand As String)
|
||||
Try
|
||||
If sqlCommand Is Nothing Or sqlCommand = String.Empty Then
|
||||
Return Nothing
|
||||
@@ -78,7 +84,12 @@
|
||||
Dim final As DataTable
|
||||
|
||||
If cached Is Nothing Then
|
||||
final = ClassDatabase.Return_Datatable(sqlCommand)
|
||||
If Not IsDBNull(connection_Id) Then
|
||||
final = ClassDatabase.MSSQL_ReturnDTWithConnection(connection_Id, sqlCommand)
|
||||
Else
|
||||
final = ClassDatabase.Return_Datatable(sqlCommand)
|
||||
End If
|
||||
|
||||
ClassControlValueCache.SaveToCache(sqlCommand, final)
|
||||
Console.WriteLine("CACHE MISS")
|
||||
Else
|
||||
@@ -274,9 +285,9 @@
|
||||
control.Text = value
|
||||
End Sub
|
||||
|
||||
Public Shared Sub LoadList(control As Windows.Forms.ComboBox, formId As Integer, SQLCommand As String)
|
||||
Public Shared Sub LoadList(control As Windows.Forms.ComboBox, formId As Integer, connID As Object, SQLCommand As String)
|
||||
Try
|
||||
Dim dynamic As DynamicValue = GetDynamicValue(DirectCast(control.Tag, ClassControlMetadata).Id, formId, SQLCommand)
|
||||
Dim dynamic As DynamicValue = GetDynamicValue(DirectCast(control.Tag, ClassControlMetadata).Id, formId, connID, SQLCommand)
|
||||
|
||||
If dynamic.StaticList IsNot Nothing Then
|
||||
control.DataSource = dynamic.StaticList
|
||||
@@ -292,24 +303,32 @@
|
||||
End Sub
|
||||
|
||||
Private Shared Sub CalculateDropdownWidth(control As Windows.Forms.ComboBox, dt As DataTable)
|
||||
Const WIDEST_WIDTH As Integer = 300
|
||||
Dim FinalWidth As Integer = WIDEST_WIDTH
|
||||
For Each row As DataRow In dt.Rows
|
||||
'Die Breite der Dropdown-List anpassen
|
||||
Using g As Graphics = control.CreateGraphics()
|
||||
Dim valueWidth As Integer = g.MeasureString(row.Item(1).ToString(), control.Font).Width
|
||||
If valueWidth + 30 > FinalWidth Then
|
||||
FinalWidth = valueWidth + 30
|
||||
End If
|
||||
g.Dispose()
|
||||
End Using
|
||||
Next
|
||||
Try
|
||||
Const WIDEST_WIDTH As Integer = 300
|
||||
Dim FinalWidth As Integer = WIDEST_WIDTH
|
||||
Dim index As Integer = 1
|
||||
If dt.Columns.Count = 1 Then
|
||||
index = 0
|
||||
End If
|
||||
For Each row As DataRow In dt.Rows
|
||||
'Die Breite der Dropdown-List anpassen
|
||||
Using g As Graphics = control.CreateGraphics()
|
||||
Dim valueWidth As Integer = g.MeasureString(row.Item(index).ToString(), control.Font).Width
|
||||
If valueWidth + 30 > FinalWidth Then
|
||||
FinalWidth = valueWidth + 30
|
||||
End If
|
||||
g.Dispose()
|
||||
End Using
|
||||
Next
|
||||
|
||||
If FinalWidth > WIDEST_WIDTH Then
|
||||
control.DropDownWidth = Math.Max(FinalWidth, control.Width)
|
||||
End If
|
||||
If FinalWidth > WIDEST_WIDTH Then
|
||||
control.DropDownWidth = Math.Max(FinalWidth, control.Width)
|
||||
End If
|
||||
Catch ex As Exception
|
||||
MsgBox("Error in CalculateDropdownWidth:" & vbNewLine & ex.Message)
|
||||
End Try
|
||||
End Sub
|
||||
|
||||
|
||||
End Class
|
||||
|
||||
Public Class CheckedListBox : Inherits _ListControl
|
||||
@@ -329,9 +348,9 @@
|
||||
Next
|
||||
End Sub
|
||||
|
||||
Public Shared Sub LoadList(control As DevExpress.XtraEditors.CheckedListBoxControl, formId As Integer, SQLCommand As String)
|
||||
Public Shared Sub LoadList(control As DevExpress.XtraEditors.CheckedListBoxControl, formId As Integer, conn_Id As Object, SQLCommand As String)
|
||||
Try
|
||||
Dim dynamic As DynamicValue = GetDynamicValue(DirectCast(control.Tag, ClassControlMetadata).Id, formId, SQLCommand)
|
||||
Dim dynamic As DynamicValue = GetDynamicValue(DirectCast(control.Tag, ClassControlMetadata).Id, formId, conn_Id, SQLCommand)
|
||||
|
||||
If dynamic.StaticList IsNot Nothing Then
|
||||
control.DataSource = dynamic.StaticList
|
||||
@@ -358,8 +377,8 @@
|
||||
control.SelectedIndex = control.FindStringExact(value)
|
||||
End Sub
|
||||
|
||||
Public Shared Sub LoadList(control As DevExpress.XtraEditors.ListBoxControl, formId As Integer, SQLCommand As String)
|
||||
Dim dynamic As DynamicValue = GetDynamicValue(DirectCast(control.Tag, ClassControlMetadata).Id, formId, SQLCommand)
|
||||
Public Shared Sub LoadList(control As DevExpress.XtraEditors.ListBoxControl, formId As Integer, ConnId As Object, SQLCommand As String)
|
||||
Dim dynamic As DynamicValue = GetDynamicValue(DirectCast(control.Tag, ClassControlMetadata).Id, formId, ConnId, SQLCommand)
|
||||
|
||||
If dynamic.StaticList IsNot Nothing Then
|
||||
control.DataSource = dynamic.StaticList
|
||||
|
||||
Reference in New Issue
Block a user