This commit is contained in:
SchreiberM
2016-01-26 13:36:08 +01:00
5 changed files with 61 additions and 64 deletions

View File

@@ -45,6 +45,7 @@ Public Class ClassControlBuilder
Dim onRecordChangedHandler As EventHandler = CType(Me.Events(_onRecordChangedName), EventHandler) Dim onRecordChangedHandler As EventHandler = CType(Me.Events(_onRecordChangedName), EventHandler)
If (onRecordChangedHandler IsNot Nothing) Then If (onRecordChangedHandler IsNot Nothing) Then
Console.WriteLine("RecordChanged")
onRecordChangedHandler.Invoke(sender, e) onRecordChangedHandler.Invoke(sender, e)
End If End If
End Sub End Sub
@@ -806,37 +807,6 @@ Public Class ClassControlBuilder
control.Size = New Size(vwidth, vheight) control.Size = New Size(vwidth, vheight)
End If End If
'SQL-Command vorhanden also Ausführen des SQL
' TODO: ERST LADEN WENN EDIT MODE ENABLEDs
'If sqlcommand.Length > 1 Then
' Dim DT_Combobox As DataTable = ClassDatabase.Return_Datatable(sqlcommand)
' If DT_Combobox Is Nothing = False Then
' If DT_Combobox.Rows.Count > 0 Then
' control.DataSource = DT_Combobox
' control.DisplayMember = DT_Combobox.Columns(1).ColumnName
' control.ValueMember = DT_Combobox.Columns(0).ColumnName
' control.AutoCompleteMode = AutoCompleteMode.SuggestAppend
' control.AutoCompleteSource = AutoCompleteSource.ListItems
' 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 = control.CreateGraphics
' If g.MeasureString(row.Item(1).ToString, control.Font).Width + 30 > iWidestWidth Then
' iWidestWidth = g.MeasureString(row.Item(1).ToString, control.Font).Width + 30
' End If
' g.Dispose()
' End Using
' ' control.Items.Add(row.Item(0).ToString)
' Next
' If iWidestWidth > 300 Then
' control.DropDownWidth = Math.Max(iWidestWidth, control.Width)
' End If
' End If
'End If
' Wenn statische liste vorhanden, werte splitten und einfügen ' Wenn statische liste vorhanden, werte splitten und einfügen
If static_list.Length > 0 Then If static_list.Length > 0 Then
Dim items() As String = static_list.Split(";") Dim items() As String = static_list.Split(";")
@@ -845,7 +815,6 @@ Public Class ClassControlBuilder
Next Next
End If End If
Me.SetEventHandlers(control) Me.SetEventHandlers(control)
Me.CurrentControl = DirectCast(control, ComboBox) Me.CurrentControl = DirectCast(control, ComboBox)
If Not IsNothing(parent) Then If Not IsNothing(parent) Then

View File

@@ -31,7 +31,7 @@ Public Class ClassControlCommandsUI
Dim SQL As String = "SELECT * FROM VWPMO_CONTROL_SCREEN WHERE FORM_ID = " & FormId & " and SCREEN_ID = 1" Dim SQL As String = "SELECT * FROM VWPMO_CONTROL_SCREEN WHERE FORM_ID = " & FormId & " and SCREEN_ID = 1"
Dim DT As DataTable = ClassDatabase.Return_Datatable(SQL) Dim DT As DataTable = ClassDatabase.Return_Datatable(SQL)
_CtrlBuilder.MasterPanel.SuspendLayout()
For Each dr As DataRow In DT.Rows For Each dr As DataRow In DT.Rows
@@ -249,6 +249,9 @@ Public Class ClassControlCommandsUI
dr.Item("CONTROL_SQLCOMMAND_1"), dr.Item("CONTROL_SQLCOMMAND_1"),
parent) parent)
End Select End Select
_CtrlBuilder.MasterPanel.ResumeLayout()
' ContextMenuStrip zuweisen ' ContextMenuStrip zuweisen
' MasterDataID im ContextMenuStrip Speichern ' MasterDataID im ContextMenuStrip Speichern
If dr.Item("CTRLSCR_MASTER_DATA_ID") <> 0 Then If dr.Item("CTRLSCR_MASTER_DATA_ID") <> 0 Then

View File

@@ -11,6 +11,26 @@
Return sqlCommand Return sqlCommand
End Function 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 = ClassControlValues.ReplaceSqlCommandPlaceholders(SQL, RecordId, ParentRecordId)
If SQL = "" Or IsDBNull(SQL) Then
Return Nothing
End If
AutoValue = ClassDatabase.Execute_Scalar(SQL)
If String.IsNullOrEmpty(AutoValue) Or IsDBNull(AutoValue) Then
Return Nothing
End If
Return AutoValue
End Function
End Class End Class
Public Class _ListControl : Inherits _BaseControl Public Class _ListControl : Inherits _BaseControl
@@ -19,8 +39,7 @@
Dim returnValue As DynamicValue Dim returnValue As DynamicValue
returnValue.StaticList = CheckForStaticList(controlId) returnValue.StaticList = CheckForStaticList(controlId)
returnValue.DataTable = GetSqlList(controlId, formId, SQLCommand) returnValue.DataTable = GetSqlList(controlId, formId, sqlCommand)
'returnValue.DataTable = CheckForSqlCommand(controlId, formId)
Return returnValue Return returnValue
End Function End Function
@@ -49,16 +68,16 @@
Return Nothing Return Nothing
End If End If
'Dim cached As DataTable = ClassControlValueCache.LoadFromCache(formId, controlId)
Dim cached As DataTable = ClassControlValueCache.LoadFromCache(sqlCommand) Dim cached As DataTable = ClassControlValueCache.LoadFromCache(sqlCommand)
Dim final As DataTable Dim final As DataTable
If cached Is Nothing Then If cached Is Nothing Then
final = ClassDatabase.Return_Datatable(sqlCommand) final = ClassDatabase.Return_Datatable(sqlCommand)
'ClassControlValueCache.SaveToCache(formId, controlId, final)
ClassControlValueCache.SaveToCache(sqlCommand, final) ClassControlValueCache.SaveToCache(sqlCommand, final)
Console.WriteLine("CACHE MISS")
Else Else
final = cached final = cached
Console.WriteLine("CACHE HIT")
End If End If
Return final Return final
@@ -69,8 +88,11 @@
End Function End Function
Overloads Shared Sub SetDataSource(control As Windows.Forms.ComboBox, dt As DataTable) Overloads Shared Sub SetDataSource(control As Windows.Forms.ComboBox, dt As DataTable)
Dim sw As Stopwatch = Stopwatch.StartNew()
Dim columnCount As Integer = dt.Columns.Count Dim columnCount As Integer = dt.Columns.Count
control.BeginUpdate()
' Damit beim Setzen von DisplayMember und ValueMember kein Fehler auftritt, ' 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. ' muss die Datasource zunächst geleert werden und der selected index auf -1 gesetzt werden.
control.DataSource = Nothing control.DataSource = Nothing
@@ -88,6 +110,11 @@
' Als letztes setzen wir die DataSource ' Als letztes setzen wir die DataSource
control.DataSource = dt control.DataSource = dt
control.EndUpdate()
sw.Stop()
Console.WriteLine("SetDataSource for {0} took {1}ms", control.Name, sw.ElapsedMilliseconds)
End Sub End Sub
Overloads Shared Sub SetDataSource(control As DevExpress.XtraEditors.CheckedListBoxControl, dt As DataTable) Overloads Shared Sub SetDataSource(control As DevExpress.XtraEditors.CheckedListBoxControl, dt As DataTable)
@@ -143,33 +170,14 @@
Public Class Label : Inherits _BaseControl 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 = ClassControlValues.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) Public Shared Sub LoadValue(control As Windows.Forms.Label, recordId As Integer, parentRecordId As Integer, value As String)
Dim autoValue = LoadAutoValue(control, recordId, parentRecordId) Dim autoValue = LoadAutoValue(control, recordId, parentRecordId)
If IsNothing(autoValue) Then If IsNothing(autoValue) Then
control.Text = value Dim ControlId As Integer = control.Tag
Dim SQL = String.Format("SELECT CONTROL_TEXT FROM TBPMO_CONTROL_SCREEN WHERE CONTROL_ID = {0}", ControlId)
Dim labelText As String = ClassDatabase.Execute_Scalar(SQL)
control.Text = labelText
Else Else
control.Text = autoValue control.Text = autoValue
End If End If
@@ -199,8 +207,14 @@
Public Class TextBox : Inherits _BaseControl Public Class TextBox : Inherits _BaseControl
Public Shared Sub LoadValue(control As Windows.Forms.TextBox, value As String) Public Shared Sub LoadValue(control As Windows.Forms.TextBox, recordId As Integer, parentRecordId As Integer, value As String)
control.Text = value Dim autoValue = LoadAutoValue(control, recordId, parentRecordId)
If IsNothing(autoValue) Then
control.Text = value
Else
control.Text = autoValue
End If
End Sub End Sub
End Class End Class

View File

@@ -44,7 +44,7 @@ Public Class ClassControlValues
Select Case control.GetType() Select Case control.GetType()
Case GetType(TextBox) Case GetType(TextBox)
Dim textbox As TextBox = DirectCast(control, TextBox) Dim textbox As TextBox = DirectCast(control, TextBox)
ControlLoader.TextBox.LoadValue(textbox, value) ControlLoader.TextBox.LoadValue(textbox, recordId, parentRecordId, value)
Case GetType(Label) Case GetType(Label)
Dim label As Label = DirectCast(control, Label) Dim label As Label = DirectCast(control, Label)
@@ -97,17 +97,25 @@ Public Class ClassControlValues
End If End If
Dim SW As Stopwatch = Stopwatch.StartNew() Dim SW As Stopwatch = Stopwatch.StartNew()
Dim swsql As Stopwatch = Stopwatch.StartNew()
' Zuerst alle SQL Commands für FormID finden ' Zuerst alle SQL Commands für FormID finden
' CONTROL_SQLCOMMAND_1 wird als SQL gealiast ' CONTROL_SQLCOMMAND_1 wird als SQL gealiast
Dim SQL As String = String.Format("SELECT CONTROL_ID, CONTROL_SQLCOMMAND_1 AS SQL FROM VWPMO_CONTROL_SCREEN WHERE FORM_ID = {0} AND CONTROL_SQLCOMMAND_1 <> '' AND CONTROL_SQLCOMMAND_1 NOT LIKE '%@%'", FormID) Dim SQL As String = String.Format("SELECT CONTROL_ID, CONTROL_SQLCOMMAND_1 AS SQL FROM VWPMO_CONTROL_SCREEN WHERE FORM_ID = {0} AND CONTROL_SQLCOMMAND_1 <> '' AND CONTROL_SQLCOMMAND_1 NOT LIKE '%@%'", FormID)
Dim dt As DataTable = ClassDatabase.Return_Datatable(SQL) Dim dt As DataTable = ClassDatabase.Return_Datatable(SQL)
swsql.Stop()
Console.WriteLine("LoadControlValuesList - Database took {0} milliseconds to load", swsql.ElapsedMilliseconds)
If dt.Rows.Count = 0 Then If dt.Rows.Count = 0 Then
Exit Sub Exit Sub
End If End If
For Each Ctrl As Control In controls For Each Ctrl As Control In controls
Dim swcontrol As Stopwatch = Stopwatch.StartNew()
Dim controlTagId = CInt(Ctrl.Tag) Dim controlTagId = CInt(Ctrl.Tag)
'If controlTagId = 474 Then 'If controlTagId = 474 Then
' MsgBox("Thats it") ' MsgBox("Thats it")
@@ -135,6 +143,9 @@ Public Class ClassControlValues
ControlLoader.CheckedListBox.LoadList(chlistbox, FormID, sqlcommand) ControlLoader.CheckedListBox.LoadList(chlistbox, FormID, sqlcommand)
End Select End Select
swcontrol.Stop()
Console.WriteLine("LoadControlValuesList Loading {0} took {1} milliseconds to load", Ctrl.Name, swcontrol.ElapsedMilliseconds)
Next Next
SW.Stop() SW.Stop()

View File

@@ -1653,7 +1653,7 @@
<value>True</value> <value>True</value>
</metadata> </metadata>
<metadata name="$this.TrayHeight" type="System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> <metadata name="$this.TrayHeight" type="System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>242</value> <value>150</value>
</metadata> </metadata>
<data name="$this.AutoScaleDimensions" type="System.Drawing.SizeF, System.Drawing"> <data name="$this.AutoScaleDimensions" type="System.Drawing.SizeF, System.Drawing">
<value>6, 13</value> <value>6, 13</value>