MS_Dec2015

This commit is contained in:
SchreiberM
2016-01-04 09:59:07 +01:00
parent 343fffe9ca
commit 3bcfde3a6f
25 changed files with 1213 additions and 482 deletions

View File

@@ -4,37 +4,42 @@ Public Class ClassControlValues
Private Shared Function LoadControlAutoValue(ControlID As Integer, RecordID As Integer, control As Control) As String
If TypeOf control Is Label Then
Dim SQL As String = "SELECT CONTROL_TYPE_ID FROM TBPMO_CONTROL WHERE GUID = " & ControlID
Dim type As Integer = ClassDatabase.Execute_Scalar(SQL)
'If ControlID = 320 Then
' MsgBox("")
'End If
' Dim SQL As String = "SELECT CONTROL_TYPE_ID FROM TBPMO_CONTROL WHERE GUID = " & ControlID
' Dim type As Integer = ClassDatabase.Execute_Scalar(SQL)
Dim SQL
' Wenn kein/leerer Wert gefunden, suche nach einem SQL Command für Automatischen Wert
If type = 1 Then
Dim autoValue
SQL = "SELECT SQL_COMMAND_1 FROM TBPMO_CONTROL WHERE GUID = " & ControlID
Dim result = ClassDatabase.Execute_Scalar(SQL)
result = result.Replace("@FORM_ID", CURRENT_FORM_ID)
result = result.Replace("@RECORD_ID", CURRENT_RECORD_ID)
result = result.Replace("@RECORDID", CURRENT_RECORD_ID)
result = result.Replace("@PARENTRECORD_ID", CURRENT_PARENTID)
' Wenn das SQL Command leer ist, hat dieses Control kein SQL Command
' Gib den ursprünlichen Text zurück
If result = "" Then
Return control.Text
Else
autoValue = ClassDatabase.Execute_Scalar(result)
'If type = 1 Then
Dim autoValue
SQL = "SELECT SQL_COMMAND_1 FROM TBPMO_CONTROL WHERE GUID = " & ControlID
Dim result = ClassDatabase.Execute_Scalar(SQL)
result = result.Replace("@FORM_ID", CURRENT_FORM_ID)
result = result.Replace("@RECORD_ID", CURRENT_RECORD_ID)
result = result.Replace("@RECORDID", CURRENT_RECORD_ID)
result = result.Replace("@PARENTRECORD_ID", CURRENT_PARENTID)
' Wenn das SQL Command leer ist, hat dieses Control kein SQL Command
' Gib den ursprünlichen Text zurück
If result = "" Then
Return control.Text
Else
autoValue = ClassDatabase.Execute_Scalar(result)
' Wenn das SQL Command DBNull zurück gibt,
' Überschreibe den alten Wert mit " " (Leerzeichen)
If IsDBNull(autoValue) Then
SQL = "SELECT CONTROL_TEXT FROM TBPMO_CONTROL_SCREEN WHERE CONTROL_ID = " & ControlID
Dim value = ClassDatabase.Execute_Scalar(SQL)
Return value
Else
Return autoValue
End If
' Wenn das SQL Command DBNull zurück gibt,
' Überschreibe den alten Wert mit " " (Leerzeichen)
If IsDBNull(autoValue) Then
SQL = "SELECT CONTROL_TEXT FROM TBPMO_CONTROL_SCREEN WHERE CONTROL_ID = " & ControlID
Dim value = ClassDatabase.Execute_Scalar(SQL)
Return value
Else
Return autoValue
End If
End If
'End If
'Return Nothing
Else
Return Nothing
End If
@@ -42,6 +47,7 @@ Public Class ClassControlValues
Public Shared Sub LoadControlValue(RecordID As Integer, ControlID As Integer, control As Control)
Try
' Dim DT1 As DataTable = ClassDatabase.Return_Datatable()
Dim DT As DataTable = ClassDatabase.Return_Datatable("SELECT * FROM VWPMO_VALUES WHERE RECORD_ID = " & RecordID & " and CONTROL_ID = " & ControlID, "LaodControlValue: ReturnValues")
If DT.Rows.Count = 0 Then
Dim autoValue = LoadControlAutoValue(ControlID, RecordID, control)
@@ -128,7 +134,7 @@ Public Class ClassControlValues
ClassLogger.Add(" >> Achtung, der Value für Control-ID: " & ControlID & " ist DBNull", False)
End If
Catch ex As Exception
MsgBox("Error in LoadControlValue:" & vbNewLine & ex.Message, MsgBoxStyle.Critical)
End Try
@@ -138,30 +144,108 @@ Public Class ClassControlValues
Public Shared Sub LoadControlValuesNeu(RecordId As Integer, FormId As Integer, controls As Control.ControlCollection)
ClearControlValues(controls)
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")
For Each control As Control In controls
Dim ControlId As Integer = CInt(control.Tag)
' Wert per LINQ aus DT_ControlValues suchen der zur aktuellen controlId passt
Dim value = (From row In DT_ControlValues.AsEnumerable()
Where row.Item("CONTROL_ID") = ControlId
Select row.Item("VALUE")).SingleOrDefault()
If IsNothing(value) Then
Continue For
Try
' Dim SQL As String = String.Format("SELECT * FROM VWPMO_VALUES WHERE VALUE <> '' AND RECORD_ID = {0}", RecordId)
' Dim DT_ControlValues As DataTable = ClassDatabase.Return_Datatable(SQL, "LoadControlValues")
If controls.Count = 0 Then
ClassLogger.Add("the control-Collection in LoadControlValuesNeu is empty!", True)
End If
For Each control As Control In controls
Dim ControlId As Integer = CInt(control.Tag)
Dim SQL1 As String = String.Format("SELECT VALUE FROM VWPMO_VALUES WHERE CONTROL_ID = {0} AND VALUE <> '' AND RECORD_ID = {1}", ControlId, RecordId)
Dim value = ClassDatabase.Execute_Scalar(SQL1)
If TypeOf control Is GroupBox Then
Dim groupbox As GroupBox = DirectCast(control, GroupBox)
LoadControlValuesNeu(RecordId, FormId, groupbox.Controls)
Else
LoadControlValueNeu(RecordId, ControlId, control, value)
End If
'' Wert per LINQ aus DT_ControlValues suchen der zur aktuellen controlId passt
'Dim value = (From row In DT_ControlValues.AsEnumerable()
' Where row.Item("CONTROL_ID") = ControlId
' Select row.Item("VALUE")).SingleOrDefault()
Next
If Not IsNothing(value) Then
' Continue For
If TypeOf control Is GroupBox Then
Dim groupbox As GroupBox = DirectCast(control, GroupBox)
LoadControlValuesNeu(RecordId, FormId, groupbox.Controls)
Else
LoadControlValueNeu(RecordId, ControlId, control, value)
End If
Else
If TypeOf control Is DevExpress.XtraEditors.CheckedListBoxControl Then
If LogErrorsOnly = False Then ClassLogger.Add(">> control DevExpress.XtraEditors.CheckedListBoxControl", False)
Dim chklbx As DevExpress.XtraEditors.CheckedListBoxControl
chklbx = DirectCast(control, DevExpress.XtraEditors.CheckedListBoxControl)
Dim chklbSql As String = "SELECT SQL_COMMAND_1 FROM TBPMO_CONTROL WHERE GUID = " & ControlId
' chklbSql = ClassDatabase.Execute_Scalar(chklbSql)
' If Not (chklbSql Is Nothing Or chklbSql = String.Empty) Then
' If chklbSql.ToString.Contains("@") Then
' chklbSql = chklbSql.ToString.Replace("@RECORDID", CURRENT_RECORD_ID)
' chklbSql = chklbSql.ToString.Replace("@RECORD_ID", CURRENT_RECORD_ID)
' chklbSql = chklbSql.ToString.Replace("@PARENTRECORD_ID", CURRENT_PARENTID)
' If LogErrorsOnly = False Then ClassLogger.Add(">> SQL CheckedListBox: " & chklbSql, False)
' 'SQL-Command vorhanden also Ausführen des SQL
' Dim DT_ListBox As DataTable = ClassDatabase.Return_Datatable(chklbSql, "LoadControlValues: CheckedListBox")
' If DT_ListBox Is Nothing = False Then
' chklbx.DataSource = DT_ListBox
' Select Case DT_ListBox.Columns.Count
' Case 2
' chklbx.DisplayMember = DT_ListBox.Columns(1).ColumnName
' chklbx.ValueMember = DT_ListBox.Columns(0).ColumnName
' Case 1
' chklbx.DisplayMember = DT_ListBox.Columns(0).ColumnName
' chklbx.ValueMember = DT_ListBox.Columns(0).ColumnName
' End Select
' End If
' End If
' ElseIf (chklbSql = String.Empty) Then
' ' Wenn keine SQL Command ein leerer String ist,
' ' lade das Control ohne Datenbank, da es wahrscheinlich eine Static List ist
' chklbSql = "SELECT VALUE FROM VWPMO_VALUES WHERE CONTROL_ID = " & CONTROL_ID & " AND RECORD_ID = " & RecordID
' Dim result As String = ClassDatabase.Execute_Scalar(chklbSql)
' If Not IsNothing(result) Then
' If result.ToString <> String.Empty Then
' Dim entries() As String = result.Split(";")
' For Each entry As String In entries
' Dim position = chklbx.FindStringExact(entry)
' chklbx.SetItemCheckState(position, CheckState.Checked)
' Next
' End If
' End If
' Continue For
' Else
' If LogErrorsOnly = False Then ClassLogger.Add(">> chklbSql is nothing", False)
' End If
' chklbx.UnCheckAll()
' 'Recorddatensätze durchlaufen und überprüfen ob angehakt??
' Dim index As Integer = 0
' For i As Integer = 0 To chklbx.ItemCount - 1
' Dim item = chklbx.GetItem(i)
' Dim row As DataRowView = CType(item, DataRowView)
' If CInt(row(0)) > 0 Then
' 'Überprüfen ob es den Record gibt
' Dim SQL = "SELECT COUNT(*) FROM TBPMO_RECORD_CONNECT WHERE RECORD1_ID = " & CURRENT_RECORD_ID & " AND RECORD2_ID = " & CInt(row(0))
' If ClassDatabase.Execute_Scalar(SQL) = 1 Then
' chklbx.SetItemChecked(i, True)
' End If
' End If
' Next
ElseIf TypeOf control Is Label Then
LoadControlValueNeu(RecordId, ControlId, control, value)
End If
End If
Next
Catch ex As Exception
MsgBox("Error in LoadControlValuesNeu:" & vbNewLine & ex.Message, MsgBoxStyle.Critical)
End Try
End Sub
Private Shared Sub LoadControlValueNeu(recordId As Integer, controlId As Integer, control As Control, value As Object)
@@ -200,11 +284,23 @@ Public Class ClassControlValues
listbox.SelectedIndex = listbox.FindStringExact(value)
Case GetType(PictureBox)
LoadImage(recordId, controlId, control)
Case GetType(DevExpress.XtraEditors.CheckedListBoxControl)
Dim chklbx As DevExpress.XtraEditors.CheckedListBoxControl
chklbx = DirectCast(control, DevExpress.XtraEditors.CheckedListBoxControl)
If Not IsNothing(value) Then
If value.ToString <> String.Empty Then
Dim entries() As String = value.Split(";")
For Each entry As String In entries
Dim position = chklbx.FindStringExact(entry)
chklbx.SetItemCheckState(position, CheckState.Checked)
Next
End If
End If
Case Else
If LogErrorsOnly = False Then ClassLogger.Add(">> Sub LoadControlValue - Control-Type nicht berücksichtigt: " & GetType(Control).ToString(), False)
If LogErrorsOnly = False Then ClassLogger.Add(">> Sub LoadControlValueNeu - Control-Type is not being worked: " & GetType(Control).ToString(), False)
End Select
Catch ex As Exception
MsgBox("Error in LoadControlValue:" & vbNewLine & ex.Message)
MsgBox("Error in LoadControlValueNeu:" & vbNewLine & ex.Message)
End Try
End Sub
@@ -254,282 +350,285 @@ Public Class ClassControlValues
Public Shared Sub LoadControlValues(RecordID As Integer, FormID As Integer, controls As Control.ControlCollection)
Try
Dim CONTROL_ID As Integer
'Public Shared Sub LoadControlValues(RecordID As Integer, FormID As Integer, controls As Control.ControlCollection)
' Try
' Dim CONTROL_ID As Integer
ClearControlValues(controls)
' ClearControlValues(controls)
For Each control As Control In controls
'Überhaupt Columns in Grid?
CONTROL_ID = GetControlID_for_RecordID(control.Name, RecordID)
If CONTROL_ID = -1 Then
CONTROL_ID = GetControlID_for_Name(control.Name, FormID)
End If
If LogErrorsOnly = False Then ClassLogger.Add(">> CONTROL_ID:" & CONTROL_ID, False)
ClearControlValue(control)
If TypeOf control Is ComboBox Then
LoadControlValue_forControl(RecordID, FormID, DirectCast(control, ComboBox), CONTROL_ID)
'LoadControlValues(RecordID, FormID, DirectCast(control, ComboBox).Controls)
ElseIf TypeOf control Is GroupBox Then
'LoadControlValue_forControl(RecordID, FormID, DirectCast(control, GroupBox), CONTROL_ID)
LoadControlValues(RecordID, FormID, DirectCast(control, GroupBox).Controls)
ElseIf TypeOf control Is PictureBox Then
LoadImage(RecordID, CONTROL_ID, control)
Else
LoadControlValue(RecordID, CONTROL_ID, control)
End If
''EINE CheckedListBoxControl
'If TypeOf control Is DevExpress.XtraEditors.CheckedListBoxControl Then
' If LogErrorsOnly = False Then ClassLogger.Add(">> control DevExpress.XtraEditors.CheckedListBoxControl", False)
' Dim chklbx As DevExpress.XtraEditors.CheckedListBoxControl
' chklbx = DirectCast(control, DevExpress.XtraEditors.CheckedListBoxControl)
' For Each control As Control In controls
' 'Überhaupt Columns in Grid?
' CONTROL_ID = GetControlID_for_RecordID(control.Name, RecordID)
' If CONTROL_ID = -1 Then
' CONTROL_ID = GetControlID_for_Name(control.Name, FormID)
' End If
' If LogErrorsOnly = False Then ClassLogger.Add(">> CONTROL_ID:" & CONTROL_ID, False)
' ClearControlValue(control)
' If TypeOf control Is ComboBox Then
' LoadControlValue_forControl(RecordID, FormID, DirectCast(control, ComboBox), CONTROL_ID)
' 'LoadControlValues(RecordID, FormID, DirectCast(control, ComboBox).Controls)
' ElseIf TypeOf control Is GroupBox Then
' 'LoadControlValue_forControl(RecordID, FormID, DirectCast(control, GroupBox), CONTROL_ID)
' LoadControlValues(RecordID, FormID, DirectCast(control, GroupBox).Controls)
' ElseIf TypeOf control Is PictureBox Then
' LoadImage(RecordID, CONTROL_ID, control)
' Else
' LoadControlValue(RecordID, CONTROL_ID, control)
' End If
' ''EINE CheckedListBoxControl
' 'If TypeOf control Is DevExpress.XtraEditors.CheckedListBoxControl Then
' ' If LogErrorsOnly = False Then ClassLogger.Add(">> control DevExpress.XtraEditors.CheckedListBoxControl", False)
' ' Dim chklbx As DevExpress.XtraEditors.CheckedListBoxControl
' ' chklbx = DirectCast(control, DevExpress.XtraEditors.CheckedListBoxControl)
' Dim chklbSql As String = "SELECT SQL_COMMAND_1 FROM TBPMO_CONTROL WHERE GUID = " & CONTROL_ID
' chklbSql = ClassDatabase.Execute_Scalar(chklbSql)
' If Not (chklbSql Is Nothing Or chklbSql = String.Empty) Then
' If chklbSql.ToString.Contains("@") Then
' chklbSql = chklbSql.ToString.Replace("@RECORDID", CURRENT_RECORD_ID)
' chklbSql = chklbSql.ToString.Replace("@RECORD_ID", CURRENT_RECORD_ID)
' chklbSql = chklbSql.ToString.Replace("@PARENTRECORD_ID", CURRENT_PARENTID)
' If LogErrorsOnly = False Then ClassLogger.Add(">> SQL CheckedListBox: " & chklbSql, False)
' 'SQL-Command vorhanden also Ausführen des SQL
' Dim DT_ListBox As DataTable = ClassDatabase.Return_Datatable(chklbSql, "LoadControlValues: CheckedListBox")
' If DT_ListBox Is Nothing = False Then
' chklbx.DataSource = DT_ListBox
' Select Case DT_ListBox.Columns.Count
' Case 2
' chklbx.DisplayMember = DT_ListBox.Columns(1).ColumnName
' chklbx.ValueMember = DT_ListBox.Columns(0).ColumnName
' Case 1
' chklbx.DisplayMember = DT_ListBox.Columns(0).ColumnName
' chklbx.ValueMember = DT_ListBox.Columns(0).ColumnName
' End Select
' ' Dim chklbSql As String = "SELECT SQL_COMMAND_1 FROM TBPMO_CONTROL WHERE GUID = " & CONTROL_ID
' ' chklbSql = ClassDatabase.Execute_Scalar(chklbSql)
' ' If Not (chklbSql Is Nothing Or chklbSql = String.Empty) Then
' ' If chklbSql.ToString.Contains("@") Then
' ' chklbSql = chklbSql.ToString.Replace("@RECORDID", CURRENT_RECORD_ID)
' ' chklbSql = chklbSql.ToString.Replace("@RECORD_ID", CURRENT_RECORD_ID)
' ' chklbSql = chklbSql.ToString.Replace("@PARENTRECORD_ID", CURRENT_PARENTID)
' ' If LogErrorsOnly = False Then ClassLogger.Add(">> SQL CheckedListBox: " & chklbSql, False)
' ' 'SQL-Command vorhanden also Ausführen des SQL
' ' Dim DT_ListBox As DataTable = ClassDatabase.Return_Datatable(chklbSql, "LoadControlValues: CheckedListBox")
' ' If DT_ListBox Is Nothing = False Then
' ' chklbx.DataSource = DT_ListBox
' ' Select Case DT_ListBox.Columns.Count
' ' Case 2
' ' chklbx.DisplayMember = DT_ListBox.Columns(1).ColumnName
' ' chklbx.ValueMember = DT_ListBox.Columns(0).ColumnName
' ' Case 1
' ' chklbx.DisplayMember = DT_ListBox.Columns(0).ColumnName
' ' chklbx.ValueMember = DT_ListBox.Columns(0).ColumnName
' ' End Select
' End If
' End If
' ' End If
' ' End If
' ElseIf (chklbSql = String.Empty) Then
' ' Wenn keine SQL Command ein leerer String ist,
' ' lade das Control ohne Datenbank, da es wahrscheinlich eine Static List ist
' chklbSql = "SELECT VALUE FROM VWPMO_VALUES WHERE CONTROL_ID = " & CONTROL_ID & " AND RECORD_ID = " & RecordID
' Dim result As String = ClassDatabase.Execute_Scalar(chklbSql)
' ' ElseIf (chklbSql = String.Empty) Then
' ' ' Wenn keine SQL Command ein leerer String ist,
' ' ' lade das Control ohne Datenbank, da es wahrscheinlich eine Static List ist
' ' chklbSql = "SELECT VALUE FROM VWPMO_VALUES WHERE CONTROL_ID = " & CONTROL_ID & " AND RECORD_ID = " & RecordID
' ' Dim result As String = ClassDatabase.Execute_Scalar(chklbSql)
' If Not IsNothing(result) Then
' If result.ToString <> String.Empty Then
' Dim entries() As String = result.Split(";")
' For Each entry As String In entries
' Dim position = chklbx.FindStringExact(entry)
' chklbx.SetItemCheckState(position, CheckState.Checked)
' Next
' End If
' End If
' ' If Not IsNothing(result) Then
' ' If result.ToString <> String.Empty Then
' ' Dim entries() As String = result.Split(";")
' ' For Each entry As String In entries
' ' Dim position = chklbx.FindStringExact(entry)
' ' chklbx.SetItemCheckState(position, CheckState.Checked)
' ' Next
' ' End If
' ' End If
' Continue For
' Else
' If LogErrorsOnly = False Then ClassLogger.Add(">> chklbSql is nothing", False)
' End If
' ' Continue For
' ' Else
' ' If LogErrorsOnly = False Then ClassLogger.Add(">> chklbSql is nothing", False)
' ' End If
' chklbx.UnCheckAll()
' 'Recorddatensätze durchlaufen und überprüfen ob angehakt??
' Dim index As Integer = 0
' For i As Integer = 0 To chklbx.ItemCount - 1
' Dim item = chklbx.GetItem(i)
' Dim row As DataRowView = CType(item, DataRowView)
' If CInt(row(0)) > 0 Then
' 'Überprüfen ob es den Record gibt
' Dim SQL = "SELECT COUNT(*) FROM TBPMO_RECORD_CONNECT WHERE RECORD1_ID = " & CURRENT_RECORD_ID & " AND RECORD2_ID = " & CInt(row(0))
' If ClassDatabase.Execute_Scalar(SQL) = 1 Then
' chklbx.SetItemChecked(i, True)
' End If
' End If
' ' chklbx.UnCheckAll()
' ' 'Recorddatensätze durchlaufen und überprüfen ob angehakt??
' ' Dim index As Integer = 0
' ' For i As Integer = 0 To chklbx.ItemCount - 1
' ' Dim item = chklbx.GetItem(i)
' ' Dim row As DataRowView = CType(item, DataRowView)
' ' If CInt(row(0)) > 0 Then
' ' 'Überprüfen ob es den Record gibt
' ' Dim SQL = "SELECT COUNT(*) FROM TBPMO_RECORD_CONNECT WHERE RECORD1_ID = " & CURRENT_RECORD_ID & " AND RECORD2_ID = " & CInt(row(0))
' ' If ClassDatabase.Execute_Scalar(SQL) = 1 Then
' ' chklbx.SetItemChecked(i, True)
' ' End If
' ' End If
' Next
'ElseIf TypeOf control Is DevExpress.XtraEditors.ListBoxControl Then
' If LogErrorsOnly = False Then ClassLogger.Add(">> control DevExpress.XtraEditors.ListBoxControl", False)
' Dim lbx As DevExpress.XtraEditors.ListBoxControl
' lbx = DirectCast(control, DevExpress.XtraEditors.ListBoxControl)
' Dim lbSql As String = "SELECT SQL_COMMAND_1 FROM TBPMO_CONTROL WHERE GUID = " & CONTROL_ID
' lbSql = ClassDatabase.Execute_Scalar(lbSql)
' If Not (lbSql Is Nothing Or lbSql = String.Empty) Then
' If lbSql.ToString.Contains("@") Then
' lbSql = lbSql.ToString.Replace("@RECORDID".ToUpper, CURRENT_RECORD_ID)
' lbSql = lbSql.ToString.Replace("@RECORD_ID".ToUpper, CURRENT_RECORD_ID)
' lbSql = lbSql.ToString.Replace("@PARENTRECORD_ID".ToUpper, CURRENT_PARENTID)
' If LogErrorsOnly = False Then ClassLogger.Add(">> SQL ListBox: " & lbSql, False)
' 'SQL-Command vorhanden also Ausführen des SQL
' Dim DT_ListBox As DataTable = ClassDatabase.Return_Datatable(lbSql, "LoadControlValues: ListBoxControl")
' If DT_ListBox Is Nothing = False Then
' lbx.DataSource = DT_ListBox
' Select Case DT_ListBox.Columns.Count
' Case 2
' lbx.DisplayMember = DT_ListBox.Columns(1).ColumnName
' lbx.ValueMember = DT_ListBox.Columns(0).ColumnName
' Case 1
' lbx.DisplayMember = DT_ListBox.Columns(0).ColumnName
' lbx.ValueMember = DT_ListBox.Columns(0).ColumnName
' End Select
' If DT_ListBox.Columns.Count > 1 Then
' ' Next
' 'ElseIf TypeOf control Is DevExpress.XtraEditors.ListBoxControl Then
' ' If LogErrorsOnly = False Then ClassLogger.Add(">> control DevExpress.XtraEditors.ListBoxControl", False)
' ' Dim lbx As DevExpress.XtraEditors.ListBoxControl
' ' lbx = DirectCast(control, DevExpress.XtraEditors.ListBoxControl)
' ' Dim lbSql As String = "SELECT SQL_COMMAND_1 FROM TBPMO_CONTROL WHERE GUID = " & CONTROL_ID
' ' lbSql = ClassDatabase.Execute_Scalar(lbSql)
' ' If Not (lbSql Is Nothing Or lbSql = String.Empty) Then
' ' If lbSql.ToString.Contains("@") Then
' ' lbSql = lbSql.ToString.Replace("@RECORDID".ToUpper, CURRENT_RECORD_ID)
' ' lbSql = lbSql.ToString.Replace("@RECORD_ID".ToUpper, CURRENT_RECORD_ID)
' ' lbSql = lbSql.ToString.Replace("@PARENTRECORD_ID".ToUpper, CURRENT_PARENTID)
' ' If LogErrorsOnly = False Then ClassLogger.Add(">> SQL ListBox: " & lbSql, False)
' ' 'SQL-Command vorhanden also Ausführen des SQL
' ' Dim DT_ListBox As DataTable = ClassDatabase.Return_Datatable(lbSql, "LoadControlValues: ListBoxControl")
' ' If DT_ListBox Is Nothing = False Then
' ' lbx.DataSource = DT_ListBox
' ' Select Case DT_ListBox.Columns.Count
' ' Case 2
' ' lbx.DisplayMember = DT_ListBox.Columns(1).ColumnName
' ' lbx.ValueMember = DT_ListBox.Columns(0).ColumnName
' ' Case 1
' ' lbx.DisplayMember = DT_ListBox.Columns(0).ColumnName
' ' lbx.ValueMember = DT_ListBox.Columns(0).ColumnName
' ' End Select
' ' If DT_ListBox.Columns.Count > 1 Then
' End If
' ' End If
' Else
' If LogErrorsOnly = False Then ClassLogger.Add(">> DT_ListBox is nothing", False)
' End If
' Else
' If LogErrorsOnly = False Then ClassLogger.Add(">> lbSql.ToString NOT Contains(@)", False)
' End If
' ElseIf (lbSql = String.Empty) Then
' ' Wenn keine SQL Command ein leerer String ist,
' ' lade das Control ohne Datenbank, da es wahrscheinlich eine Static List ist
' LoadControlValue(RecordID, CONTROL_ID, control)
' Continue For
' Else
' If LogErrorsOnly = False Then ClassLogger.Add(">> lbSql is nothing", False)
' End If
'ElseIf CONTROL_ID <> -1 Then
' 'If LogErrorsOnly = False Then ClassLogger.Add(">> LoadControlValues CONTROL_ID: " & CONTROL_ID, False)
' LoadControlValue(RecordID, CONTROL_ID, control)
'End If
Next
Catch ex As Exception
MsgBox("Unexpected Error in LoadControlValues:" & vbNewLine & ex.Message, MsgBoxStyle.Critical)
End Try
' ' Else
' ' If LogErrorsOnly = False Then ClassLogger.Add(">> DT_ListBox is nothing", False)
' ' End If
' ' Else
' ' If LogErrorsOnly = False Then ClassLogger.Add(">> lbSql.ToString NOT Contains(@)", False)
' ' End If
' ' ElseIf (lbSql = String.Empty) Then
' ' ' Wenn keine SQL Command ein leerer String ist,
' ' ' lade das Control ohne Datenbank, da es wahrscheinlich eine Static List ist
' ' LoadControlValue(RecordID, CONTROL_ID, control)
' ' Continue For
' ' Else
' ' If LogErrorsOnly = False Then ClassLogger.Add(">> lbSql is nothing", False)
' ' End If
' 'ElseIf CONTROL_ID <> -1 Then
' ' 'If LogErrorsOnly = False Then ClassLogger.Add(">> LoadControlValues CONTROL_ID: " & CONTROL_ID, False)
' ' LoadControlValue(RecordID, CONTROL_ID, control)
' 'End If
' Next
' Catch ex As Exception
' MsgBox("Unexpected Error in LoadControlValues:" & vbNewLine & ex.Message, MsgBoxStyle.Critical)
' End Try
End Sub
Public Shared Sub LoadControlValue_forControl(RecordID As Integer, FormID As Integer, control As System.Windows.Forms.Control, CONTROL_ID As Integer)
Try
'EINE CheckedListBoxControl
If TypeOf control Is DevExpress.XtraEditors.CheckedListBoxControl Then
If LogErrorsOnly = False Then ClassLogger.Add(">> control DevExpress.XtraEditors.CheckedListBoxControl", False)
Dim chklbx As DevExpress.XtraEditors.CheckedListBoxControl
chklbx = DirectCast(control, DevExpress.XtraEditors.CheckedListBoxControl)
'End Sub
'Public Shared Sub LoadControlValue_forControl(RecordID As Integer, FormID As Integer, control As System.Windows.Forms.Control, CONTROL_ID As Integer)
' Try
' 'EINE CheckedListBoxControl
' If TypeOf control Is DevExpress.XtraEditors.CheckedListBoxControl Then
' If LogErrorsOnly = False Then ClassLogger.Add(">> control DevExpress.XtraEditors.CheckedListBoxControl", False)
' Dim chklbx As DevExpress.XtraEditors.CheckedListBoxControl
' chklbx = DirectCast(control, DevExpress.XtraEditors.CheckedListBoxControl)
Dim chklbSql As String = "SELECT SQL_COMMAND_1 FROM TBPMO_CONTROL WHERE GUID = " & CONTROL_ID
chklbSql = ClassDatabase.Execute_Scalar(chklbSql)
If Not (chklbSql Is Nothing Or chklbSql = String.Empty) Then
If chklbSql.ToString.Contains("@") Then
chklbSql = chklbSql.ToString.Replace("@RECORDID", CURRENT_RECORD_ID)
chklbSql = chklbSql.ToString.Replace("@RECORD_ID", CURRENT_RECORD_ID)
chklbSql = chklbSql.ToString.Replace("@PARENTRECORD_ID", CURRENT_PARENTID)
If LogErrorsOnly = False Then ClassLogger.Add(">> SQL CheckedListBox: " & chklbSql, False)
'SQL-Command vorhanden also Ausführen des SQL
Dim DT_ListBox As DataTable = ClassDatabase.Return_Datatable(chklbSql, "LoadControlValue_forControl: CheckedListBox")
If DT_ListBox Is Nothing = False Then
chklbx.DataSource = DT_ListBox
Select Case DT_ListBox.Columns.Count
Case 2
chklbx.DisplayMember = DT_ListBox.Columns(1).ColumnName
chklbx.ValueMember = DT_ListBox.Columns(0).ColumnName
Case 1
chklbx.DisplayMember = DT_ListBox.Columns(0).ColumnName
chklbx.ValueMember = DT_ListBox.Columns(0).ColumnName
End Select
' Dim chklbSql As String = "SELECT SQL_COMMAND_1 FROM TBPMO_CONTROL WHERE GUID = " & CONTROL_ID
' chklbSql = ClassDatabase.Execute_Scalar(chklbSql)
' If Not (chklbSql Is Nothing Or chklbSql = String.Empty) Then
' If chklbSql.ToString.Contains("@") Then
' chklbSql = chklbSql.ToString.Replace("@RECORDID", CURRENT_RECORD_ID)
' chklbSql = chklbSql.ToString.Replace("@RECORD_ID", CURRENT_RECORD_ID)
' chklbSql = chklbSql.ToString.Replace("@PARENTRECORD_ID", CURRENT_PARENTID)
' If LogErrorsOnly = False Then ClassLogger.Add(">> SQL CheckedListBox: " & chklbSql, False)
' 'SQL-Command vorhanden also Ausführen des SQL
' Dim DT_ListBox As DataTable = ClassDatabase.Return_Datatable(chklbSql, "LoadControlValue_forControl: CheckedListBox")
' If DT_ListBox Is Nothing = False Then
' chklbx.DataSource = DT_ListBox
' Select Case DT_ListBox.Columns.Count
' Case 2
' chklbx.DisplayMember = DT_ListBox.Columns(1).ColumnName
' chklbx.ValueMember = DT_ListBox.Columns(0).ColumnName
' Case 1
' chklbx.DisplayMember = DT_ListBox.Columns(0).ColumnName
' chklbx.ValueMember = DT_ListBox.Columns(0).ColumnName
' End Select
End If
End If
ElseIf (chklbSql = String.Empty) Then
' Wenn keine SQL Command ein leerer String ist,
' lade das Control ohne Datenbank, da es wahrscheinlich eine Static List ist
chklbSql = "SELECT VALUE FROM VWPMO_VALUES WHERE CONTROL_ID = " & CONTROL_ID & " AND RECORD_ID = " & RecordID
Dim result As String = ClassDatabase.Execute_Scalar(chklbSql)
' End If
' End If
' ElseIf (chklbSql = String.Empty) Then
' ' Wenn keine SQL Command ein leerer String ist,
' ' lade das Control ohne Datenbank, da es wahrscheinlich eine Static List ist
' chklbSql = "SELECT VALUE FROM VWPMO_VALUES WHERE CONTROL_ID = " & CONTROL_ID & " AND RECORD_ID = " & RecordID
' Dim result As String = ClassDatabase.Execute_Scalar(chklbSql)
If Not IsNothing(result) Then
If result.ToString <> String.Empty Then
Dim entries() As String = result.Split(";")
For Each entry As String In entries
Dim position = chklbx.FindStringExact(entry)
chklbx.SetItemCheckState(position, CheckState.Checked)
Next
End If
End If
Else
If LogErrorsOnly = False Then ClassLogger.Add(">> chklbSql is nothing", False)
End If
' If Not IsNothing(result) Then
' If result.ToString <> String.Empty Then
' Dim entries() As String = result.Split(";")
' For Each entry As String In entries
' Dim position = chklbx.FindStringExact(entry)
' chklbx.SetItemCheckState(position, CheckState.Checked)
' Next
' End If
' End If
' Else
' If LogErrorsOnly = False Then ClassLogger.Add(">> chklbSql is nothing", False)
' End If
chklbx.UnCheckAll()
'Recorddatensätze durchlaufen und überprüfen ob angehakt??
Dim index As Integer = 0
For i As Integer = 0 To chklbx.ItemCount - 1
Dim item = chklbx.GetItem(i)
Dim row As DataRowView = CType(item, DataRowView)
If CInt(row(0)) > 0 Then
'Überprüfen ob es den Record gibt
Dim SQL = "SELECT COUNT(*) FROM TBPMO_RECORD_CONNECT WHERE RECORD1_ID = " & CURRENT_RECORD_ID & " AND RECORD2_ID = " & CInt(row(0))
If ClassDatabase.Execute_Scalar(SQL) = 1 Then
chklbx.SetItemChecked(i, True)
End If
End If
' chklbx.UnCheckAll()
' 'Recorddatensätze durchlaufen und überprüfen ob angehakt??
' Dim index As Integer = 0
' For i As Integer = 0 To chklbx.ItemCount - 1
' Dim item = chklbx.GetItem(i)
' Dim row As DataRowView = CType(item, DataRowView)
' If CInt(row(0)) > 0 Then
' 'Überprüfen ob es den Record gibt
' Dim SQL = "SELECT COUNT(*) FROM TBPMO_RECORD_CONNECT WHERE RECORD1_ID = " & CURRENT_RECORD_ID & " AND RECORD2_ID = " & CInt(row(0))
' If ClassDatabase.Execute_Scalar(SQL) = 1 Then
' chklbx.SetItemChecked(i, True)
' End If
' End If
Next
ElseIf TypeOf control Is DevExpress.XtraEditors.ListBoxControl Then
If LogErrorsOnly = False Then ClassLogger.Add(">> control DevExpress.XtraEditors.ListBoxControl", False)
Dim lbx As DevExpress.XtraEditors.ListBoxControl
lbx = DirectCast(control, DevExpress.XtraEditors.ListBoxControl)
Dim lbSql As String = "SELECT SQL_COMMAND_1 FROM TBPMO_CONTROL WHERE GUID = " & CONTROL_ID
lbSql = ClassDatabase.Execute_Scalar(lbSql)
If Not (lbSql Is Nothing Or lbSql = String.Empty) Then
If lbSql.ToString.Contains("@") Then
lbSql = lbSql.ToString.Replace("@RECORDID".ToUpper, CURRENT_RECORD_ID)
lbSql = lbSql.ToString.Replace("@RECORD_ID".ToUpper, CURRENT_RECORD_ID)
lbSql = lbSql.ToString.Replace("@PARENTRECORD_ID".ToUpper, CURRENT_PARENTID)
If LogErrorsOnly = False Then ClassLogger.Add(">> SQL ListBox: " & lbSql, False)
'SQL-Command vorhanden also Ausführen des SQL
Dim DT_ListBox As DataTable = ClassDatabase.Return_Datatable(lbSql, "LoadControlValue_forControl: ListBoxControl")
If DT_ListBox Is Nothing = False Then
lbx.DataSource = DT_ListBox
Select Case DT_ListBox.Columns.Count
Case 2
lbx.DisplayMember = DT_ListBox.Columns(1).ColumnName
lbx.ValueMember = DT_ListBox.Columns(0).ColumnName
Case 1
lbx.DisplayMember = DT_ListBox.Columns(0).ColumnName
lbx.ValueMember = DT_ListBox.Columns(0).ColumnName
End Select
If DT_ListBox.Columns.Count > 1 Then
' Next
' ElseIf TypeOf control Is DevExpress.XtraEditors.ListBoxControl Then
' If LogErrorsOnly = False Then ClassLogger.Add(">> control DevExpress.XtraEditors.ListBoxControl", False)
' Dim lbx As DevExpress.XtraEditors.ListBoxControl
' lbx = DirectCast(control, DevExpress.XtraEditors.ListBoxControl)
' Dim lbSql As String = "SELECT SQL_COMMAND_1 FROM TBPMO_CONTROL WHERE GUID = " & CONTROL_ID
' lbSql = ClassDatabase.Execute_Scalar(lbSql)
' If Not (lbSql Is Nothing Or lbSql = String.Empty) Then
' If lbSql.ToString.Contains("@") Then
' lbSql = lbSql.ToString.Replace("@RECORDID".ToUpper, CURRENT_RECORD_ID)
' lbSql = lbSql.ToString.Replace("@RECORD_ID".ToUpper, CURRENT_RECORD_ID)
' lbSql = lbSql.ToString.Replace("@PARENTRECORD_ID".ToUpper, CURRENT_PARENTID)
' If LogErrorsOnly = False Then ClassLogger.Add(">> SQL ListBox: " & lbSql, False)
' 'SQL-Command vorhanden also Ausführen des SQL
' Dim DT_ListBox As DataTable = ClassDatabase.Return_Datatable(lbSql, "LoadControlValue_forControl: ListBoxControl")
' If DT_ListBox Is Nothing = False Then
' lbx.DataSource = DT_ListBox
' Select Case DT_ListBox.Columns.Count
' Case 2
' lbx.DisplayMember = DT_ListBox.Columns(1).ColumnName
' lbx.ValueMember = DT_ListBox.Columns(0).ColumnName
' Case 1
' lbx.DisplayMember = DT_ListBox.Columns(0).ColumnName
' lbx.ValueMember = DT_ListBox.Columns(0).ColumnName
' End Select
' If DT_ListBox.Columns.Count > 1 Then
End If
' End If
Else
If LogErrorsOnly = False Then ClassLogger.Add(">> DT_ListBox is nothing", False)
End If
Else
If LogErrorsOnly = False Then ClassLogger.Add(">> lbSql.ToString NOT Contains(@)", False)
End If
ElseIf (lbSql = String.Empty) Then
' Wenn keine SQL Command ein leerer String ist,
' lade das Control ohne Datenbank, da es wahrscheinlich eine Static List ist
LoadControlValue(RecordID, CONTROL_ID, control)
Else
If LogErrorsOnly = False Then ClassLogger.Add(">> lbSql is nothing", False)
End If
ElseIf CONTROL_ID <> -1 Then
'If LogErrorsOnly = False Then ClassLogger.Add(">> LoadControlValue_forControl CONTROL_ID: " & CONTROL_ID, False)
LoadControlValue(RecordID, CONTROL_ID, control)
End If
' Else
' If LogErrorsOnly = False Then ClassLogger.Add(">> DT_ListBox is nothing", False)
' End If
' Else
' If LogErrorsOnly = False Then ClassLogger.Add(">> lbSql.ToString NOT Contains(@)", False)
' End If
' ElseIf (lbSql = String.Empty) Then
' ' Wenn keine SQL Command ein leerer String ist,
' ' lade das Control ohne Datenbank, da es wahrscheinlich eine Static List ist
' LoadControlValue(RecordID, CONTROL_ID, control)
' Else
' If LogErrorsOnly = False Then ClassLogger.Add(">> lbSql is nothing", False)
' End If
' ElseIf CONTROL_ID <> -1 Then
' 'If LogErrorsOnly = False Then ClassLogger.Add(">> LoadControlValue_forControl CONTROL_ID: " & CONTROL_ID, False)
' LoadControlValue(RecordID, CONTROL_ID, control)
' End If
Catch ex As Exception
MsgBox("Unexpected Error in LoadControlValue_forControl:" & vbNewLine & ex.Message, MsgBoxStyle.Critical)
End Try
' Catch ex As Exception
' MsgBox("Unexpected Error in LoadControlValue_forControl:" & vbNewLine & ex.Message, MsgBoxStyle.Critical)
' End Try
End Sub
'End Sub
Public Shared Sub LoadControlValuesList(RecordID As Integer, FormID As Integer, controls As Control.ControlCollection)
Try
If controls.Count = 0 Then
MsgBox("Control.ControlCollection is unexpected empty!", MsgBoxStyle.Exclamation)
End If
Dim SW As Stopwatch = Stopwatch.StartNew()
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 = DirectCast(Ctrl, ComboBox)
Dim SQL As String = String.Format("SELECT SQL_COMMAND_1 FROM TBPMO_CONTROL WHERE FORM_ID = {0} AND NAME = '{1}'", CURRENT_FORM_ID, Ctrl.Name)
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
Exit Sub
Continue For
End If
If SQL2.ToString.ToUpper.Contains("@") Then
SQL2 = SQL2.ToString.Replace("@RECORDID", CURRENT_RECORD_ID)
@@ -538,7 +637,7 @@ Public Class ClassControlValues
' If LogErrorsOnly = False Then ClassLogger.Add(">> SQL Combobox: " & cmbSql, False)
End If
Dim controlId As Integer = GetControlID_for_Name(Combobox.Name, FormID)
'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
@@ -573,8 +672,8 @@ Public Class ClassControlValues
Combobox.DropDownWidth = Math.Max(iWidestWidth, Combobox.Width)
End If
LoadControlValue(RecordID, controlId, Ctrl)
LoadControlValue(RecordID, ControlId, Ctrl)
'LoadControlValueNeu(RecordID, ControlId, Ctrl, "")
End If
swInner.Stop()
@@ -649,9 +748,9 @@ Public Class ClassControlValues
DirectCast(control, PictureBox).BackgroundImage = Nothing
Case "CheckedListBoxControl"
Dim chklbx As DevExpress.XtraEditors.CheckedListBoxControl = DirectCast(control, DevExpress.XtraEditors.CheckedListBoxControl)
If IsNothing(chklbx.DataSource) Then
chklbx.UnCheckAll()
End If
'If IsNothing(chklbx.DataSource) Then
chklbx.UnCheckAll()
'End If
'Case "ListBoxControl"
' Dim lbx As DevExpress.XtraEditors.ListBoxControl
' lbx = DirectCast(control, DevExpress.XtraEditors.ListBoxControl)
@@ -669,7 +768,7 @@ Public Class ClassControlValues
Dim i = 0
For Each control As Control In controls
CONTROL_ID = GetControlID_for_Name(control.Name, FormID)
CONTROL_ID = control.Tag ' GetControlID_for_Name(control.Name, FormID)
If Not (TypeOf control Is Label) Then
i += 1
End If