This commit is contained in:
SchreiberM
2016-04-08 14:55:25 +02:00
parent d1eb7ecb5b
commit ef2a87d849
47 changed files with 12718 additions and 9964 deletions

View File

@@ -142,7 +142,7 @@ Public Class ClassControlValues
Return missingValues.Distinct().ToList()
End Function
Public Shared Sub LoadControlValues(RecordId As Integer, ParentRecordId As Integer, FormId As Integer, controls As Control.ControlCollection)
Public Shared Sub LoadControlValues(RecordId As Integer, ParentRecordId As Integer, FormId As Integer, controls As Control.ControlCollection, Entity_ID As Integer)
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 RECORD_ID = {0}", RecordId)
@@ -168,9 +168,9 @@ Public Class ClassControlValues
If TypeOf control Is GroupBox Then
Dim groupbox As GroupBox = DirectCast(control, GroupBox)
LoadControlValues(RecordId, ParentRecordId, FormId, groupbox.Controls)
LoadControlValues(RecordId, ParentRecordId, FormId, groupbox.Controls, Entity_ID)
Else
LoadControlValue(RecordId, ParentRecordId, ControlId, control, values)
LoadControlValue(RecordId, ParentRecordId, ControlId, control, values, Entity_ID)
End If
Next
@@ -198,11 +198,8 @@ Public Class ClassControlValues
End Sub
Private Shared Sub LoadControlValue(recordId As Integer, parentRecordId As Integer, controlId As Integer, control As Control, values As List(Of Object))
Private Shared Sub LoadControlValue(recordId As Integer, parentRecordId As Integer, controlId As Integer, control As Control, values As List(Of Object), entity_ID As Integer)
Try
Dim sw As New Stopwatch
sw.Start()
Dim elapsed As Double
' Für die meisten Controls wird nur das erste Element der Liste benötigt
Dim value As String = Nothing
@@ -212,60 +209,48 @@ Public Class ClassControlValues
Select Case control.GetType()
Case GetType(TextBox)
Dim textbox As TextBox = DirectCast(control, TextBox)
ControlLoader.TextBox.LoadValue(textbox, recordId, parentRecordId, value)
elapsed = sw.Elapsed.TotalSeconds
If LogErrorsOnly = False Then ClassLogger.Add(" >> LoadControlValue TextBox took " & Format(elapsed, "0.000000000") & " seconds", False)
ControlLoader.TextBox.LoadValue(textbox, recordId, parentRecordId, value, entity_ID)
Case GetType(Label)
Dim label As Label = DirectCast(control, Label)
ControlLoader.Label.LoadValue(label, recordId, parentRecordId, value)
elapsed = sw.Elapsed.TotalSeconds
If LogErrorsOnly = False Then ClassLogger.Add(" >> LoadControlValue Label took " & Format(elapsed, "0.000000000") & " seconds", False)
ControlLoader.Label.LoadValue(label, recordId, parentRecordId, value, entity_ID)
Case GetType(ComboBox)
Dim combobox As ComboBox = DirectCast(control, ComboBox)
ControlLoader.Combobox.LoadValue(combobox, recordId, parentRecordId, value)
elapsed = sw.Elapsed.TotalSeconds
If LogErrorsOnly = False Then ClassLogger.Add(" >> LoadControlValue ComboBox took " & Format(elapsed, "0.000000000") & " seconds", False)
Case GetType(CheckBox)
Dim checkbox As CheckBox = DirectCast(control, CheckBox)
ControlLoader.Checkbox.LoadValue(checkbox, value)
elapsed = sw.Elapsed.TotalSeconds
If LogErrorsOnly = False Then ClassLogger.Add(" >> LoadControlValue Checkbox took " & Format(elapsed, "0.000000000") & " seconds", False)
Case GetType(RadioButton)
If LogErrorsOnly = False Then ClassLogger.Add(" >> Sub LoadControlValueNeu - GetType(RadioButton) ", False)
Dim radiobutton As RadioButton = DirectCast(control, RadioButton)
ControlLoader.RadioButton.LoadValue(radiobutton, value)
elapsed = sw.Elapsed.TotalSeconds
If LogErrorsOnly = False Then ClassLogger.Add(" >> LoadControlValue RadioButton took " & Format(elapsed, "0.000000000") & " seconds", False)
Case GetType(DevExpress.XtraEditors.DateEdit)
Dim datepicker As DevExpress.XtraEditors.DateEdit = DirectCast(control, DevExpress.XtraEditors.DateEdit)
ControlLoader.DateTimePicker.LoadValue(datepicker, value)
elapsed = sw.Elapsed.TotalSeconds
If LogErrorsOnly = False Then ClassLogger.Add(" >> LoadControlValue DateEdit took " & Format(elapsed, "0.000000000") & " seconds", False)
Case GetType(DevExpress.XtraEditors.ListBoxControl)
Dim listbox As DevExpress.XtraEditors.ListBoxControl = DirectCast(control, DevExpress.XtraEditors.ListBoxControl)
ControlLoader.ListBox.LoadValue(listbox, value)
elapsed = sw.Elapsed.TotalSeconds
If LogErrorsOnly = False Then ClassLogger.Add(" >> LoadControlValue ListBoxControl took " & Format(elapsed, "0.000000000") & " seconds", False)
Case GetType(DevExpress.XtraEditors.CheckedListBoxControl)
Dim checkedlistbox As DevExpress.XtraEditors.CheckedListBoxControl = DirectCast(control, DevExpress.XtraEditors.CheckedListBoxControl)
ControlLoader.CheckedListBox.LoadValue(checkedlistbox, values)
elapsed = sw.Elapsed.TotalSeconds
If LogErrorsOnly = False Then ClassLogger.Add(" >> LoadControlValue CheckedListBoxControl took " & Format(elapsed, "0.000000000") & " seconds", False)
Case GetType(PictureBox)
Dim picturebox = DirectCast(control, PictureBox)
LoadImage(recordId, controlId, picturebox)
elapsed = sw.Elapsed.TotalSeconds
If LogErrorsOnly = False Then ClassLogger.Add(" >> LoadControlValue PictureBox took " & Format(elapsed, "0.000000000") & " seconds", False)
Case GetType(DataGridView)
Dim gridview = DirectCast(control, DataGridView)
ControlLoader.DataGridView.LoadValue(gridview, values)
elapsed = sw.Elapsed.TotalSeconds
If LogErrorsOnly = False Then ClassLogger.Add(" >> LoadControlValue DataGridView took " & Format(elapsed, "0.000000000") & " seconds", False)
Case Else
If LogErrorsOnly = False Then ClassLogger.Add(" >> Sub LoadControlValue - Control-Type nicht berücksichtigt: " & GetType(Control).ToString(), False)
ClassLogger.Add(" >> Sub LoadControlValue - Control-Type nicht berücksichtigt: " & GetType(Control).ToString(), False)
End Select
sw.Stop()
sw.Reset()
Catch ex As Exception
ClassLogger.Add("Unexpected Error in LoadControlValue: " & ex.Message, True)
MsgBox("Error in LoadControlValue:" & vbNewLine & ex.Message)
@@ -289,29 +274,25 @@ Public Class ClassControlValues
' CONTROL_SQLCOMMAND_1 wird als SQL gealiast
Dim SQL As String = String.Format("SELECT CONTROL_ID, CONTROL_CONNID_1,CONTROL_SQLCOMMAND_1 AS SQL FROM VWPMO_CONTROL_SCREEN WHERE FORM_ID = {0} AND CONTROL_SQLCOMMAND_1 NOT LIKE '%@%'", FormID)
Dim dt As DataTable = ClassDatabase.Return_Datatable(SQL)
Dim elapsed As Double
elapsed = swsql.Elapsed.TotalSeconds
swsql.Stop()
If LogErrorsOnly = False Then ClassLogger.Add(String.Format(">> LoadControlValuesList - Database took {0} milliseconds to load", swsql.ElapsedMilliseconds), False)
If LogErrorsOnly = False Then ClassLogger.Add(String.Format(" >> LoadControlValuesList - Database took {0} to load", Format(elapsed, "0.000000000") & " seconds"), False)
If dt.Rows.Count = 0 Then
Exit Sub
End If
For Each Ctrl As Control In controls
Dim swcontrol As Stopwatch = Stopwatch.StartNew()
Dim controlTagId = DirectCast(Ctrl.Tag, ClassControlMetadata).Id
'If controlTagId = 474 Then
' MsgBox("Thats it")
'End If
'Datatable nach row mit CONTROL_ID wie Ctrl suchen
Dim row As DataRow = dt.Select(String.Format("CONTROL_ID={0}", controlTagId)).FirstOrDefault()
If IsNothing(row) Then
Continue For
End If
Dim sqlcommand As String = row.Item("SQL")
Dim ConnID = row.Item("CONTROL_CONNID_1")
Select Case Ctrl.GetType()
@@ -328,14 +309,10 @@ Public Class ClassControlValues
ControlLoader.CheckedListBox.LoadList(chlistbox, FormID, ConnID, sqlcommand)
End Select
swcontrol.Stop()
If LogErrorsOnly = False Then ClassLogger.Add(String.Format(">> LoadControlValuesList Loading '{0}' took {1} milliseconds to load", Ctrl.Name, swcontrol.ElapsedMilliseconds), False)
Next
SW.Stop()
Dim elapsed As Double
elapsed = SW.Elapsed.TotalSeconds
elapsed = sw.Elapsed.TotalSeconds
SW.Stop()
SW.Reset()
If LogErrorsOnly = False Then ClassLogger.Add(" >> LoadControlValuesList took " & Format(elapsed, "0.000000000") & " seconds", False)
@@ -347,7 +324,7 @@ Public Class ClassControlValues
End Sub
Public Shared Sub LoadControlValuesListWithPlaceholders(FormId As Integer, RecordId As Integer, ParentRecordId As Integer, controls As Control.ControlCollection)
Public Shared Sub LoadControlValuesListWithPlaceholders(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)
@@ -376,7 +353,7 @@ Public Class ClassControlValues
Dim sqlcommand As String = row.Item("SQL")
sqlcommand = ReplaceSqlCommandPlaceholders(sqlcommand, RecordId, ParentRecordId)
sqlcommand = ReplaceSqlCommandPlaceholders(sqlcommand, RecordId, ParentRecordId, entity_ID)
Select Case Ctrl.GetType()
Case GetType(ComboBox)
@@ -393,21 +370,22 @@ Public Class ClassControlValues
End Select
Next
Dim elapsed As Double
elapsed = SW.Elapsed.TotalSeconds
SW.Stop()
Console.WriteLine("LoadControlValuesListWithPlaceholders took {0} milliseconds to load", SW.ElapsedMilliseconds)
Console.WriteLine("LoadControlValuesListWithPlaceholders took {0} to load", Format(elapsed, "0.000000000") & " seconds")
Catch ex As Exception
ClassLogger.Add("Unexpected Error in LoadControlValuesListWithPlaceholders: " & ex.Message, True)
MsgBox("Unexpected Error in LoadControlValuesListWithPlaceholders:" & vbNewLine & ex.Message, MsgBoxStyle.Critical)
End Try
End Sub
Public Shared Function ReplaceSqlCommandPlaceholders(sqlCommand As String, recordId As Integer, parentRecordId As Integer)
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)
sqlCommand = sqlCommand.Replace("@ENTITY_ID", entity_Id)
sqlCommand = sqlCommand.Replace("@PARENTRECORD_ID", parentRecordId)
sqlCommand = sqlCommand.Replace("@PARENTRECORDID", parentRecordId)
Return sqlCommand
End Function