jj_12_01_16

This commit is contained in:
JenneJ
2016-01-12 15:13:13 +01:00
parent 4864a50133
commit 9d8b9a5365
8 changed files with 132 additions and 142 deletions

View File

@@ -135,7 +135,8 @@ Public Class ClassControlValues
#Region "#### ClassControlValues REWRITE ####"
Public Shared Sub LoadControlValuesNeu(RecordId As Integer, ParentRecordId As Integer, FormId As Integer, controls As Control.ControlCollection)
Try
Dim SQL As String = String.Format("SELECT * FROM VWPMO_VALUES WHERE VALUE <> '' AND RECORD_ID = {0}", RecordId)
'Dim SQL As String = String.Format("SELECT * FROM VWPMO_VALUES WHERE VALUE <> '' AND RECORD_ID = {0}", RecordId)
Dim SQL As String = String.Format("SELECT * FROM VWPMO_VALUES WHERE RECORD_ID = {0}", RecordId)
Dim DT_ControlValues As DataTable = ClassDatabase.Return_Datatable(SQL, "LoadControlValues")
If controls.Count = 0 Then
@@ -180,7 +181,7 @@ Public Class ClassControlValues
Case GetType(ComboBox)
Dim combobox As ComboBox = DirectCast(control, ComboBox)
ControlLoader.Combobox.LoadValue(combobox, value)
ControlLoader.Combobox.LoadValue(combobox, recordId, parentRecordId, value)
Case GetType(CheckBox)
Dim checkbox As CheckBox = DirectCast(control, CheckBox)
@@ -227,68 +228,10 @@ Public Class ClassControlValues
For Each Ctrl As Control In controls
If TypeOf Ctrl Is ComboBox Then
Dim ControlId = Ctrl.Tag
Dim swInner As Stopwatch = Stopwatch.StartNew()
Dim combobox As ComboBox = DirectCast(Ctrl, ComboBox)
ControlLoader.Combobox.LoadList(combobox, FormID, RecordID, ParentRecordId)
Dim Combobox = DirectCast(Ctrl, ComboBox)
Dim SQL As String = String.Format("SELECT SQL_COMMAND_1 FROM TBPMO_CONTROL WHERE GUID = {0}", ControlId) 'CURRENT_FORM_ID, Ctrl.Name)
Dim SQL2 As String = ClassDatabase.Execute_Scalar(SQL)
If SQL2 = "" Then
Continue For
End If
If SQL2.ToString.ToUpper.Contains("@") Then
SQL2 = SQL2.ToString.Replace("@RECORDID", CURRENT_RECORD_ID)
SQL2 = SQL2.ToString.Replace("@RECORD_ID", CURRENT_RECORD_ID)
SQL2 = SQL2.ToString.Replace("@PARENTRECORD_ID", CURRENT_PARENTID)
' If LogErrorsOnly = False Then ClassLogger.Add(">> SQL Combobox: " & cmbSql, False)
End If
'Dim controlId As Integer = GetControlID_for_Name(Combobox.Name, FormID)
'Dim DT_Combobox As DataTable = ClassDatabase.Return_Datatable(SQL2)
' Zuerst versuchen, DataTable aus dem Cache zu laden
Dim DT_Combobox As DataTable = ClassControlValueCache.LoadFromCache(FormID, ControlId)
' Wenn DataTable nicht im Cache vorhanden, aus der Datenbank laden
If IsNothing(DT_Combobox) Then
DT_Combobox = ClassDatabase.Return_Datatable(SQL2)
End If
If DT_Combobox Is Nothing = False Then
If DT_Combobox.Rows.Count > 0 Then
Combobox.DataSource = DT_Combobox
Combobox.DisplayMember = DT_Combobox.Columns(1).ColumnName
Combobox.ValueMember = DT_Combobox.Columns(0).ColumnName
ClassControlValueCache.SaveToCache(FormID, ControlId, DT_Combobox)
End If
Dim iWidestWidth As Integer = 300
For Each row As DataRow In DT_Combobox.Rows
'Die BReite der DropDown-Lsit anpassen
Using g As Graphics = Combobox.CreateGraphics
If g.MeasureString(row.Item(1).ToString, Combobox.Font).Width + 30 > iWidestWidth Then
iWidestWidth = g.MeasureString(row.Item(1).ToString, Combobox.Font).Width + 30
End If
g.Dispose()
End Using
' control.Items.Add(row.Item(0).ToString)
Next
If iWidestWidth > 300 Then
Combobox.DropDownWidth = Math.Max(iWidestWidth, Combobox.Width)
End If
'LoadControlValue(RecordID, ControlId, Ctrl)
LoadControlValueNeu(RecordID, ParentRecordId, ControlId, Ctrl, "")
End If
swInner.Stop()
Console.WriteLine("Loading List for Control {0} took {1} milliseconds", Ctrl.Name, swInner.ElapsedMilliseconds)
End If
Next
SW.Stop()