jj_04_01_16
This commit is contained in:
@@ -142,103 +142,100 @@ Public Class ClassControlValues
|
||||
|
||||
#Region "#### ClassControlValues REWRITE ####"
|
||||
Public Shared Sub LoadControlValuesNeu(RecordId As Integer, FormId As Integer, controls As Control.ControlCollection)
|
||||
|
||||
ClearControlValues(controls)
|
||||
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")
|
||||
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)
|
||||
'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)
|
||||
|
||||
'' 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()
|
||||
' 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 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
|
||||
If TypeOf control Is GroupBox Then
|
||||
Dim groupbox As GroupBox = DirectCast(control, GroupBox)
|
||||
LoadControlValuesNeu(RecordId, FormId, groupbox.Controls)
|
||||
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
|
||||
LoadControlValueNeu(RecordId, ControlId, control, value)
|
||||
End If
|
||||
|
||||
'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
|
||||
@@ -253,55 +250,100 @@ Public Class ClassControlValues
|
||||
Select Case control.GetType()
|
||||
Case GetType(TextBox)
|
||||
Dim textbox As TextBox = DirectCast(control, TextBox)
|
||||
textbox.Text = value
|
||||
ControlLoader.TextBox.LoadValue(textbox, value)
|
||||
|
||||
Case GetType(Label)
|
||||
Dim label As Label = DirectCast(control, Label)
|
||||
Dim autoValue As String = LoadControlAutoValue(controlId, recordId, control)
|
||||
ControlLoader.Label.LoadValue(label, value)
|
||||
|
||||
If IsNothing(autoValue) Then
|
||||
label.Text = value
|
||||
Else
|
||||
label.Text = autoValue
|
||||
End If
|
||||
Case GetType(ComboBox)
|
||||
Dim combobox As ComboBox = DirectCast(control, ComboBox)
|
||||
combobox.Text = value
|
||||
ControlLoader.Combobox.LoadValue(combobox, value)
|
||||
|
||||
Case GetType(CheckBox)
|
||||
Dim checkbox As CheckBox = DirectCast(control, CheckBox)
|
||||
checkbox.Checked = Boolean.Parse(value)
|
||||
ControlLoader.Checkbox.LoadValue(checkbox, value)
|
||||
|
||||
Case GetType(RadioButton)
|
||||
Dim radiobutton As RadioButton = DirectCast(control, RadioButton)
|
||||
radiobutton.Checked = Boolean.Parse(value)
|
||||
ControlLoader.RadioButton.LoadValue(radiobutton, value)
|
||||
|
||||
Case GetType(DevExpress.XtraEditors.DateEdit)
|
||||
Dim datepicker As DevExpress.XtraEditors.DateEdit = DirectCast(control, DevExpress.XtraEditors.DateEdit)
|
||||
If value = String.Empty Or value = "00:00:00" Then
|
||||
datepicker.DateTime = DateTime.MinValue
|
||||
Else
|
||||
datepicker.DateTime = DateTime.Parse(value)
|
||||
End If
|
||||
ControlLoader.DateTimePicker.LoadValue(datepicker, value)
|
||||
|
||||
Case GetType(DevExpress.XtraEditors.ListBoxControl)
|
||||
Dim listbox As DevExpress.XtraEditors.ListBoxControl = DirectCast(control, DevExpress.XtraEditors.ListBoxControl)
|
||||
listbox.SelectedIndex = listbox.FindStringExact(value)
|
||||
Case GetType(PictureBox)
|
||||
LoadImage(recordId, controlId, control)
|
||||
ControlLoader.ListBox.LoadValue(listbox, value)
|
||||
|
||||
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
|
||||
Dim checkedlistbox As DevExpress.XtraEditors.CheckedListBoxControl = DirectCast(control, DevExpress.XtraEditors.CheckedListBoxControl)
|
||||
ControlLoader.CheckedListBox.LoadValue(checkedlistbox, value)
|
||||
|
||||
Case GetType(PictureBox)
|
||||
Dim picturebox = DirectCast(control, PictureBox)
|
||||
LoadImage(recordId, controlId, picturebox)
|
||||
|
||||
Case Else
|
||||
If LogErrorsOnly = False Then ClassLogger.Add(">> Sub LoadControlValueNeu - Control-Type is not being worked: " & GetType(Control).ToString(), False)
|
||||
If LogErrorsOnly = False Then ClassLogger.Add(">> Sub LoadControlValue - Control-Type nicht berücksichtigt: " & GetType(Control).ToString(), False)
|
||||
End Select
|
||||
Catch ex As Exception
|
||||
MsgBox("Error in LoadControlValueNeu:" & vbNewLine & ex.Message)
|
||||
MsgBox("Error in LoadControlValue:" & vbNewLine & ex.Message)
|
||||
End Try
|
||||
|
||||
'Try
|
||||
' Select Case control.GetType()
|
||||
' Case GetType(TextBox)
|
||||
' Dim textbox As TextBox = DirectCast(control, TextBox)
|
||||
' textbox.Text = value
|
||||
' Case GetType(Label)
|
||||
' Dim label As Label = DirectCast(control, Label)
|
||||
' Dim autoValue As String = LoadControlAutoValue(controlId, recordId, control)
|
||||
|
||||
' If IsNothing(autoValue) Then
|
||||
' label.Text = value
|
||||
' Else
|
||||
' label.Text = autoValue
|
||||
' End If
|
||||
' Case GetType(ComboBox)
|
||||
' Dim combobox As ComboBox = DirectCast(control, ComboBox)
|
||||
' combobox.Text = value
|
||||
' Case GetType(CheckBox)
|
||||
' Dim checkbox As CheckBox = DirectCast(control, CheckBox)
|
||||
' checkbox.Checked = Boolean.Parse(value)
|
||||
' Case GetType(RadioButton)
|
||||
' Dim radiobutton As RadioButton = DirectCast(control, RadioButton)
|
||||
' radiobutton.Checked = Boolean.Parse(value)
|
||||
' Case GetType(DevExpress.XtraEditors.DateEdit)
|
||||
' Dim datepicker As DevExpress.XtraEditors.DateEdit = DirectCast(control, DevExpress.XtraEditors.DateEdit)
|
||||
' If value = String.Empty Or value = "00:00:00" Then
|
||||
' datepicker.DateTime = DateTime.MinValue
|
||||
' Else
|
||||
' datepicker.DateTime = DateTime.Parse(value)
|
||||
' End If
|
||||
' Case GetType(DevExpress.XtraEditors.ListBoxControl)
|
||||
' Dim listbox As DevExpress.XtraEditors.ListBoxControl = DirectCast(control, DevExpress.XtraEditors.ListBoxControl)
|
||||
' 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 LoadControlValueNeu - Control-Type is not being worked: " & GetType(Control).ToString(), False)
|
||||
' End Select
|
||||
'Catch ex As Exception
|
||||
' MsgBox("Error in LoadControlValueNeu:" & vbNewLine & ex.Message)
|
||||
'End Try
|
||||
End Sub
|
||||
|
||||
'Private Shared Function CheckForStaticList(controlId As Integer, recordId As Integer)
|
||||
|
||||
Reference in New Issue
Block a user