jj_05_01_16
This commit is contained in:
@@ -1,157 +1,152 @@
|
||||
Imports DevExpress.XtraEditors.Controls
|
||||
|
||||
Public Class ClassControlValues
|
||||
Private Shared Function LoadControlAutoValue(ControlID As Integer, RecordID As Integer, control As Control) As String
|
||||
'Private Shared Function LoadControlAutoValue(ControlID As Integer, RecordID As Integer, control As Control) As String
|
||||
|
||||
If TypeOf control Is Label Then
|
||||
'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 TypeOf control Is Label Then
|
||||
' Dim SQL = "SELECT SQL_COMMAND_1 FROM TBPMO_CONTROL WHERE GUID = " & ControlID
|
||||
' Dim autoValue
|
||||
' 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
|
||||
End If
|
||||
'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
|
||||
' 'Return Nothing
|
||||
' Else
|
||||
' Return Nothing
|
||||
' End If
|
||||
|
||||
End Function
|
||||
'End Function
|
||||
|
||||
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)
|
||||
'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)
|
||||
|
||||
If Not String.IsNullOrEmpty(autoValue) Then
|
||||
control.Text = autoValue
|
||||
End If
|
||||
' If Not String.IsNullOrEmpty(autoValue) Then
|
||||
' control.Text = autoValue
|
||||
' End If
|
||||
|
||||
Exit Sub
|
||||
End If
|
||||
' Exit Sub
|
||||
' End If
|
||||
|
||||
Dim result = DT.Rows(0).Item("VALUE")
|
||||
'22.06.2015
|
||||
If Not IsDBNull(result) Then
|
||||
Select Case DT.Rows(0).Item("CONTROL_TYPE_ID")
|
||||
Case 1 'Label
|
||||
Dim label As Label = DirectCast(control, Label)
|
||||
Dim autoValue As String = LoadControlAutoValue(ControlID, RecordID, control)
|
||||
If Not IsNothing(autoValue) Then
|
||||
label.Text = autoValue
|
||||
End If
|
||||
Case 2 ' TextBox
|
||||
Dim textbox As TextBox = DirectCast(control, TextBox)
|
||||
textbox.Text = result
|
||||
Case 10 ' CheckBox
|
||||
Dim checkbox As CheckBox = DirectCast(control, CheckBox)
|
||||
checkbox.Checked = CBool(result)
|
||||
Case 11 'RadioButton
|
||||
Dim radio As RadioButton = DirectCast(control, RadioButton)
|
||||
radio.Checked = CBool(result)
|
||||
Case 3 ' ComboBox
|
||||
Dim cmbbox As ComboBox = DirectCast(control, System.Windows.Forms.ComboBox)
|
||||
cmbbox.Text = result
|
||||
'If LogErrorsOnly = False Then ClassLogger.Add(">> control ComboBox", False)
|
||||
'Dim cmbSql As String = "SELECT SQL_COMMAND_1 FROM TBPMO_CONTROL WHERE GUID = " & ControlID
|
||||
'cmbSql = ClassDatabase.Execute_Scalar(cmbSql)
|
||||
'If Not (cmbSql Is Nothing Or cmbSql = String.Empty) Then
|
||||
' If cmbSql.ToString.Contains("@") Then
|
||||
' cmbSql = cmbSql.ToString.Replace("@RECORDID", CURRENT_RECORD_ID)
|
||||
' cmbSql = cmbSql.ToString.Replace("@RECORD_ID", CURRENT_RECORD_ID)
|
||||
' cmbSql = cmbSql.ToString.Replace("@PARENTRECORD_ID", CURRENT_PARENTID)
|
||||
' If LogErrorsOnly = False Then ClassLogger.Add(">> SQL Combobox: " & cmbSql, False)
|
||||
' End If
|
||||
' If LogErrorsOnly = False Then ClassLogger.Add(">> SQL Combobox: " & cmbSql, False)
|
||||
' Dim result = DT.Rows(0).Item("VALUE")
|
||||
' '22.06.2015
|
||||
' If Not IsDBNull(result) Then
|
||||
' Select Case DT.Rows(0).Item("CONTROL_TYPE_ID")
|
||||
' Case 1 'Label
|
||||
' Dim label As Label = DirectCast(control, Label)
|
||||
' Dim autoValue As String = LoadControlAutoValue(ControlID, RecordID, control)
|
||||
' If Not IsNothing(autoValue) Then
|
||||
' label.Text = autoValue
|
||||
' End If
|
||||
' Case 2 ' TextBox
|
||||
' Dim textbox As TextBox = DirectCast(control, TextBox)
|
||||
' textbox.Text = result
|
||||
' Case 10 ' CheckBox
|
||||
' Dim checkbox As CheckBox = DirectCast(control, CheckBox)
|
||||
' checkbox.Checked = CBool(result)
|
||||
' Case 11 'RadioButton
|
||||
' Dim radio As RadioButton = DirectCast(control, RadioButton)
|
||||
' radio.Checked = CBool(result)
|
||||
' Case 3 ' ComboBox
|
||||
' Dim cmbbox As ComboBox = DirectCast(control, System.Windows.Forms.ComboBox)
|
||||
' cmbbox.Text = result
|
||||
' 'If LogErrorsOnly = False Then ClassLogger.Add(">> control ComboBox", False)
|
||||
' 'Dim cmbSql As String = "SELECT SQL_COMMAND_1 FROM TBPMO_CONTROL WHERE GUID = " & ControlID
|
||||
' 'cmbSql = ClassDatabase.Execute_Scalar(cmbSql)
|
||||
' 'If Not (cmbSql Is Nothing Or cmbSql = String.Empty) Then
|
||||
' ' If cmbSql.ToString.Contains("@") Then
|
||||
' ' cmbSql = cmbSql.ToString.Replace("@RECORDID", CURRENT_RECORD_ID)
|
||||
' ' cmbSql = cmbSql.ToString.Replace("@RECORD_ID", CURRENT_RECORD_ID)
|
||||
' ' cmbSql = cmbSql.ToString.Replace("@PARENTRECORD_ID", CURRENT_PARENTID)
|
||||
' ' If LogErrorsOnly = False Then ClassLogger.Add(">> SQL Combobox: " & cmbSql, False)
|
||||
' ' End If
|
||||
' ' If LogErrorsOnly = False Then ClassLogger.Add(">> SQL Combobox: " & cmbSql, False)
|
||||
|
||||
' 'SQL-Command vorhanden also Ausführen des SQL
|
||||
' Dim DT_ComboBox As DataTable = ClassDatabase.Return_Datatable(cmbSql, "LoadControlValues: Combobox")
|
||||
' If DT_ComboBox Is Nothing = False Then
|
||||
' cmbbox.DataSource = DT_ComboBox
|
||||
' Select Case DT_ComboBox.Columns.Count
|
||||
' Case 2
|
||||
' cmbbox.DisplayMember = DT_ComboBox.Columns(1).ColumnName
|
||||
' cmbbox.ValueMember = DT_ComboBox.Columns(0).ColumnName
|
||||
' Case 1
|
||||
' cmbbox.DisplayMember = DT_ComboBox.Columns(0).ColumnName
|
||||
' cmbbox.ValueMember = DT_ComboBox.Columns(0).ColumnName
|
||||
' End Select
|
||||
' ' 'SQL-Command vorhanden also Ausführen des SQL
|
||||
' ' Dim DT_ComboBox As DataTable = ClassDatabase.Return_Datatable(cmbSql, "LoadControlValues: Combobox")
|
||||
' ' If DT_ComboBox Is Nothing = False Then
|
||||
' ' cmbbox.DataSource = DT_ComboBox
|
||||
' ' Select Case DT_ComboBox.Columns.Count
|
||||
' ' Case 2
|
||||
' ' cmbbox.DisplayMember = DT_ComboBox.Columns(1).ColumnName
|
||||
' ' cmbbox.ValueMember = DT_ComboBox.Columns(0).ColumnName
|
||||
' ' Case 1
|
||||
' ' cmbbox.DisplayMember = DT_ComboBox.Columns(0).ColumnName
|
||||
' ' cmbbox.ValueMember = DT_ComboBox.Columns(0).ColumnName
|
||||
' ' End Select
|
||||
|
||||
' End If
|
||||
'End If
|
||||
''combobox.DataSource = Nothing
|
||||
'If cmbbox.SelectedIndex = -1 Then
|
||||
' cmbbox.DataSource = Nothing
|
||||
' cmbbox.Text = result
|
||||
'Else
|
||||
' cmbbox.SelectedIndex = cmbbox.FindStringExact(result)
|
||||
'End If
|
||||
Case 4 'DateTimePicker
|
||||
Dim datepicker As DevExpress.XtraEditors.DateEdit = DirectCast(control, DevExpress.XtraEditors.DateEdit)
|
||||
' ' End If
|
||||
' 'End If
|
||||
' ''combobox.DataSource = Nothing
|
||||
' 'If cmbbox.SelectedIndex = -1 Then
|
||||
' ' cmbbox.DataSource = Nothing
|
||||
' ' cmbbox.Text = result
|
||||
' 'Else
|
||||
' ' cmbbox.SelectedIndex = cmbbox.FindStringExact(result)
|
||||
' 'End If
|
||||
' Case 4 'DateTimePicker
|
||||
' Dim datepicker As DevExpress.XtraEditors.DateEdit = DirectCast(control, DevExpress.XtraEditors.DateEdit)
|
||||
|
||||
If result = "" Or result = "00:00:00" Then
|
||||
datepicker.DateTime = DateTime.MinValue
|
||||
Else
|
||||
datepicker.DateTime = Date.Parse(result)
|
||||
End If
|
||||
Case 13 ' Listbox
|
||||
Dim listbox As DevExpress.XtraEditors.ListBoxControl = DirectCast(control, DevExpress.XtraEditors.ListBoxControl)
|
||||
listbox.SelectedIndex = listbox.FindStringExact(result)
|
||||
Case Else
|
||||
If LogErrorsOnly = False Then ClassLogger.Add(">> Sub LoadControlValue - Control-Type nicht berücksichtigt: " & DT.Rows(0).Item("CONTROL_TYPE_ID"), False)
|
||||
'MsgBox(DT.Rows(0).Item("CONTROL_TYPE_ID"))
|
||||
End Select
|
||||
Else
|
||||
ClassLogger.Add(" >> Achtung, der Value für Control-ID: " & ControlID & " ist DBNull", False)
|
||||
End If
|
||||
' If result = "" Or result = "00:00:00" Then
|
||||
' datepicker.DateTime = DateTime.MinValue
|
||||
' Else
|
||||
' datepicker.DateTime = Date.Parse(result)
|
||||
' End If
|
||||
' Case 13 ' Listbox
|
||||
' Dim listbox As DevExpress.XtraEditors.ListBoxControl = DirectCast(control, DevExpress.XtraEditors.ListBoxControl)
|
||||
' listbox.SelectedIndex = listbox.FindStringExact(result)
|
||||
' Case Else
|
||||
' If LogErrorsOnly = False Then ClassLogger.Add(">> Sub LoadControlValue - Control-Type nicht berücksichtigt: " & DT.Rows(0).Item("CONTROL_TYPE_ID"), False)
|
||||
' 'MsgBox(DT.Rows(0).Item("CONTROL_TYPE_ID"))
|
||||
' End Select
|
||||
' Else
|
||||
' 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
|
||||
End Sub
|
||||
' Catch ex As Exception
|
||||
' MsgBox("Error in LoadControlValue:" & vbNewLine & ex.Message, MsgBoxStyle.Critical)
|
||||
' End Try
|
||||
'End Sub
|
||||
|
||||
#Region "#### ClassControlValues REWRITE ####"
|
||||
Public Shared Sub LoadControlValuesNeu(RecordId As Integer, FormId As Integer, controls As Control.ControlCollection)
|
||||
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 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
|
||||
|
||||
' Zuerst alle Controls leeren
|
||||
ClearControlValues(controls)
|
||||
|
||||
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)
|
||||
|
||||
' Wert per LINQ aus DT_ControlValues suchen der zur aktuellen controlId passt
|
||||
Dim value = (From row In DT_ControlValues.AsEnumerable()
|
||||
@@ -160,92 +155,19 @@ Public Class ClassControlValues
|
||||
|
||||
If TypeOf control Is GroupBox Then
|
||||
Dim groupbox As GroupBox = DirectCast(control, GroupBox)
|
||||
LoadControlValuesNeu(RecordId, FormId, groupbox.Controls)
|
||||
LoadControlValuesNeu(RecordId, ParentRecordId, FormId, groupbox.Controls)
|
||||
Else
|
||||
LoadControlValueNeu(RecordId, ControlId, control, value)
|
||||
LoadControlValueNeu(RecordId, ParentRecordId, 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
|
||||
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)
|
||||
Private Shared Sub LoadControlValueNeu(recordId As Integer, parentRecordId As Integer, controlId As Integer, control As Control, value As Object)
|
||||
Try
|
||||
Select Case control.GetType()
|
||||
Case GetType(TextBox)
|
||||
@@ -254,7 +176,7 @@ Public Class ClassControlValues
|
||||
|
||||
Case GetType(Label)
|
||||
Dim label As Label = DirectCast(control, Label)
|
||||
ControlLoader.Label.LoadValue(label, value)
|
||||
ControlLoader.Label.LoadValue(label, recordId, parentRecordId, value)
|
||||
|
||||
Case GetType(ComboBox)
|
||||
Dim combobox As ComboBox = DirectCast(control, ComboBox)
|
||||
@@ -291,368 +213,12 @@ Public Class ClassControlValues
|
||||
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)
|
||||
' Try
|
||||
' Dim SQL As String = String.Format("SELECT VALUE FROM VWPMO_VALUES WHERE CONTROL_ID = {0} AND RECORD_ID = {1}", controlId, recordId)
|
||||
' Dim staticList As String = ClassDatabase.Execute_Scalar(SQL)
|
||||
|
||||
' If IsNothing(staticList) Then
|
||||
' Return Nothing
|
||||
' Else
|
||||
' Return staticList
|
||||
' End If
|
||||
' Catch ex As Exception
|
||||
' MsgBox("Error in CheckForStaticList: " & vbNewLine & ex.Message)
|
||||
' End Try
|
||||
'End Function
|
||||
|
||||
'Private Shared Function CheckForSqlCommand(controlId As Integer) As DataTable
|
||||
' Try
|
||||
' Dim SQL As String = String.Format("SELECT SQL_COMMAND_1 FROM TBPMO_CONTROL WHERE GUID = {0}", controlId)
|
||||
' Dim SqlCommand As String = ClassDatabase.Execute_Scalar(SQL)
|
||||
|
||||
' If SqlCommand Is Nothing Or SqlCommand = String.Empty Then
|
||||
' Return Nothing
|
||||
' End If
|
||||
|
||||
' If SqlCommand.Contains("@") Then
|
||||
' SqlCommand = ReplaceSqlCommandPlaceholders(SqlCommand)
|
||||
' End If
|
||||
|
||||
' Return ClassDatabase.Return_Datatable(SqlCommand)
|
||||
' Catch ex As Exception
|
||||
' MsgBox("Error in CheckForSqlCommand: " & vbNewLine & ex.Message)
|
||||
' End Try
|
||||
'End Function
|
||||
|
||||
'Private Shared Function ReplaceSqlCommandPlaceholders(sqlCommand As String)
|
||||
' sqlCommand = sqlCommand.Replace("@RECORD_ID", CURRENT_RECORD_ID)
|
||||
' sqlCommand = sqlCommand.Replace("@RECORDID", CURRENT_RECORD_ID)
|
||||
' sqlCommand = sqlCommand.Replace("PARENTRECORD_ID", CURRENT_PARENTID)
|
||||
' sqlCommand = sqlCommand.Replace("PARENTRECORDID", CURRENT_PARENTID)
|
||||
|
||||
' Return sqlCommand
|
||||
'End Function
|
||||
#End Region
|
||||
|
||||
|
||||
|
||||
'Public Shared Sub LoadControlValues(RecordID As Integer, FormID As Integer, controls As Control.ControlCollection)
|
||||
' Try
|
||||
' Dim CONTROL_ID As Integer
|
||||
|
||||
' 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)
|
||||
|
||||
' ' 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
|
||||
|
||||
' ' 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 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
|
||||
|
||||
' ' 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)
|
||||
|
||||
' 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)
|
||||
|
||||
' 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
|
||||
|
||||
' 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
|
||||
|
||||
' 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
|
||||
|
||||
'End Sub
|
||||
|
||||
Public Shared Sub LoadControlValuesList(RecordID As Integer, FormID As Integer, controls As Control.ControlCollection)
|
||||
Public Shared Sub LoadControlValuesList(RecordID As Integer, ParentRecordId As Integer, FormID As Integer, controls As Control.ControlCollection)
|
||||
Try
|
||||
If controls.Count = 0 Then
|
||||
MsgBox("Control.ControlCollection is unexpected empty!", MsgBoxStyle.Exclamation)
|
||||
@@ -683,7 +249,7 @@ Public Class ClassControlValues
|
||||
'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)
|
||||
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)
|
||||
@@ -695,7 +261,7 @@ Public Class ClassControlValues
|
||||
Combobox.DisplayMember = DT_Combobox.Columns(1).ColumnName
|
||||
Combobox.ValueMember = DT_Combobox.Columns(0).ColumnName
|
||||
|
||||
ClassControlValueCache.SaveToCache(FormID, controlId, DT_Combobox)
|
||||
ClassControlValueCache.SaveToCache(FormID, ControlId, DT_Combobox)
|
||||
End If
|
||||
|
||||
Dim iWidestWidth As Integer = 300
|
||||
@@ -714,8 +280,8 @@ Public Class ClassControlValues
|
||||
Combobox.DropDownWidth = Math.Max(iWidestWidth, Combobox.Width)
|
||||
End If
|
||||
|
||||
LoadControlValue(RecordID, ControlId, Ctrl)
|
||||
'LoadControlValueNeu(RecordID, ControlId, Ctrl, "")
|
||||
'LoadControlValue(RecordID, ControlId, Ctrl)
|
||||
LoadControlValueNeu(RecordID, ParentRecordId, ControlId, Ctrl, "")
|
||||
End If
|
||||
|
||||
swInner.Stop()
|
||||
@@ -759,6 +325,7 @@ Public Class ClassControlValues
|
||||
End If
|
||||
End Sub
|
||||
|
||||
#Region "ClearControlValue"
|
||||
Public Shared Sub ClearControlValues(controls As Control.ControlCollection)
|
||||
For Each control In controls
|
||||
If control.GetType().Name = "GroupBox" Then
|
||||
@@ -771,60 +338,58 @@ Public Class ClassControlValues
|
||||
End Sub
|
||||
|
||||
Public Shared Sub ClearControlValue(control As Control)
|
||||
Dim type = control.GetType().Name
|
||||
|
||||
Select Case type
|
||||
Case "TextBox"
|
||||
Select Case control.GetType()
|
||||
Case GetType(TextBox)
|
||||
DirectCast(control, TextBox).Text = String.Empty
|
||||
Case "ComboBox"
|
||||
|
||||
Case GetType(ComboBox)
|
||||
Dim combo As ComboBox = DirectCast(control, ComboBox)
|
||||
combo.SelectedIndex = -1
|
||||
combo.Text = String.Empty
|
||||
Case "CheckBox"
|
||||
|
||||
Case GetType(CheckBox)
|
||||
DirectCast(control, CheckBox).Checked = False
|
||||
Case "RadioButton"
|
||||
|
||||
Case GetType(RadioButton)
|
||||
DirectCast(control, RadioButton).Checked = False
|
||||
Case "DateEdit"
|
||||
|
||||
Case GetType(DevExpress.XtraEditors.DateEdit)
|
||||
DirectCast(control, DevExpress.XtraEditors.DateEdit).DateTime = Now
|
||||
Case "PictureBox"
|
||||
|
||||
Case GetType(PictureBox)
|
||||
DirectCast(control, PictureBox).BackgroundImage = Nothing
|
||||
Case "CheckedListBoxControl"
|
||||
|
||||
Case GetType(DevExpress.XtraEditors.CheckedListBoxControl)
|
||||
Dim chklbx As DevExpress.XtraEditors.CheckedListBoxControl = DirectCast(control, DevExpress.XtraEditors.CheckedListBoxControl)
|
||||
'If IsNothing(chklbx.DataSource) Then
|
||||
chklbx.UnCheckAll()
|
||||
'End If
|
||||
'Case "ListBoxControl"
|
||||
' Dim lbx As DevExpress.XtraEditors.ListBoxControl
|
||||
' lbx = DirectCast(control, DevExpress.XtraEditors.ListBoxControl)
|
||||
' lbx.DataSource = Nothing
|
||||
Case Else
|
||||
|
||||
Case GetType(DevExpress.XtraEditors.ListBoxControl)
|
||||
Dim lb As DevExpress.XtraEditors.ListBoxControl = DirectCast(control, DevExpress.XtraEditors.ListBoxControl)
|
||||
lb.SelectedIndex = -1
|
||||
|
||||
End Select
|
||||
End Sub
|
||||
#End Region
|
||||
|
||||
#Region "LoadDefaultValue"
|
||||
Public Shared Sub LoadDefaultValues(FormID As Integer, RecordID As Integer, controls As Control.ControlCollection)
|
||||
Dim CONTROL_ID As Integer
|
||||
'' Zuerst alle Controls leeren
|
||||
'ClearControlValues(controls)
|
||||
|
||||
' Zuerst alle Controls leeren
|
||||
ClearControlValues(controls)
|
||||
Dim i = 0
|
||||
For Each control As Control In controls
|
||||
|
||||
CONTROL_ID = control.Tag ' GetControlID_for_Name(control.Name, FormID)
|
||||
Dim CONTROL_ID = control.Tag ' GetControlID_for_Name(control.Name, FormID)
|
||||
If Not (TypeOf control Is Label) Then
|
||||
i += 1
|
||||
End If
|
||||
|
||||
If TypeOf control Is GroupBox Then
|
||||
LoadDefaultValues(FormID, RecordID, DirectCast(control, GroupBox).Controls)
|
||||
ElseIf TypeOf control Is DevExpress.XtraEditors.CheckedListBoxControl Then
|
||||
Dim chklbx As DevExpress.XtraEditors.CheckedListBoxControl
|
||||
chklbx = DirectCast(control, DevExpress.XtraEditors.CheckedListBoxControl)
|
||||
chklbx.UnCheckAll()
|
||||
End If
|
||||
|
||||
If CONTROL_ID <> -1 Then
|
||||
LoadDefaultValue(CONTROL_ID, RecordID, control)
|
||||
End If
|
||||
LoadDefaultValue(CONTROL_ID, RecordID, control)
|
||||
|
||||
'Den Focus auf das erste Steuerelement setzen
|
||||
If i = 1 Then
|
||||
control.Focus()
|
||||
@@ -835,57 +400,64 @@ Public Class ClassControlValues
|
||||
|
||||
Public Shared Sub LoadDefaultValue(ControlID As Integer, RecordID As Integer, control As Control)
|
||||
Try
|
||||
Dim SQL = "SELECT * FROM VWPMO_CONTROL_SCREEN WHERE CONTROL_ID = " & ControlID
|
||||
Dim DT As DataTable = ClassDatabase.Return_Datatable(SQL)
|
||||
Dim result = DT.Rows(0).Item("CONTROL_DEF_VALUE")
|
||||
Dim SQL = String.Format("SELECT CONTROL_DEF_VALUE FROM VWPMO_CONTROL_SCREEN WHERE CONTROL_ID = {0}", ControlID)
|
||||
Dim autoValue = ClassDatabase.Execute_Scalar(SQL)
|
||||
|
||||
Select Case DT.Rows(0).Item("CTRLTYPE_ID")
|
||||
Case 2 ' TextBox
|
||||
'Dim SQL = "SELECT * FROM VWPMO_CONTROL_SCREEN WHERE CONTROL_ID = " & ControlID
|
||||
'Dim DT As DataTable = ClassDatabase.Return_Datatable(SQL)
|
||||
'Dim result = DT.Rows(0).Item("CONTROL_DEF_VALUE")
|
||||
|
||||
Select Case control.GetType()
|
||||
Case GetType(TextBox)
|
||||
Dim textbox As TextBox = DirectCast(control, TextBox)
|
||||
If IsDBNull(result) Then
|
||||
If IsDBNull(autoValue) Then
|
||||
textbox.Text = ""
|
||||
Else
|
||||
Dim vorgabe = result
|
||||
Dim vorgabe = autoValue
|
||||
'Wenn der Default Wert über einen Select kommt
|
||||
If vorgabe.ToString.ToLower.StartsWith("select") Then
|
||||
vorgabe = result.Replace("@FORM_ID", CURRENT_FORM_ID)
|
||||
vorgabe = autoValue.Replace("@FORM_ID", CURRENT_FORM_ID)
|
||||
vorgabe = vorgabe.Replace("@RECORD_ID", CURRENT_RECORD_ID)
|
||||
vorgabe = vorgabe.Replace("@RECORDID", CURRENT_RECORD_ID)
|
||||
vorgabe = vorgabe.Replace("@PARENTRECORD_ID", CURRENT_PARENTID)
|
||||
result = ClassDatabase.Execute_Scalar(vorgabe.ToString, True)
|
||||
autoValue = ClassDatabase.Execute_Scalar(vorgabe.ToString, True)
|
||||
If IsNothing(vorgabe) Then
|
||||
textbox.Text = ""
|
||||
End If
|
||||
End If
|
||||
textbox.Text = result
|
||||
|
||||
textbox.Text = autoValue
|
||||
End If
|
||||
Case 10 ' CheckBox
|
||||
|
||||
Case GetType(CheckBox)
|
||||
Dim checkbox As CheckBox = DirectCast(control, CheckBox)
|
||||
checkbox.Checked = StrToBool(result)
|
||||
Case 11 'RadioButton
|
||||
checkbox.Checked = StrToBool(autoValue)
|
||||
|
||||
Case GetType(RadioButton)
|
||||
Dim radio As RadioButton = DirectCast(control, RadioButton)
|
||||
radio.Checked = StrToBool(result)
|
||||
Case 3 ' ComboBox
|
||||
radio.Checked = StrToBool(autoValue)
|
||||
|
||||
Case GetType(ComboBox)
|
||||
Dim combobox As ComboBox = DirectCast(control, ComboBox)
|
||||
If IsDBNull(result) Then
|
||||
If IsDBNull(autoValue) Then
|
||||
combobox.SelectedIndex = -1
|
||||
Else
|
||||
combobox.SelectedIndex = combobox.FindStringExact(result)
|
||||
combobox.SelectedIndex = combobox.FindStringExact(autoValue)
|
||||
End If
|
||||
Case 4 'DateTimePicker
|
||||
Case GetType(DevExpress.XtraEditors.DateEdit)
|
||||
Dim datepicker As DevExpress.XtraEditors.DateEdit = DirectCast(control, DevExpress.XtraEditors.DateEdit)
|
||||
If IsDBNull(result) OrElse result = "" OrElse result = "False" Then
|
||||
result = Now
|
||||
If IsDBNull(autoValue) OrElse autoValue = "" OrElse autoValue = "False" Then
|
||||
autoValue = Now
|
||||
End If
|
||||
|
||||
datepicker.DateTime = result
|
||||
datepicker.DateTime = autoValue
|
||||
End Select
|
||||
|
||||
Catch ex As Exception
|
||||
MsgBox("Unexpected Error in LoadDefaultValue:" & vbNewLine & ex.Message, MsgBoxStyle.Critical)
|
||||
End Try
|
||||
End Sub
|
||||
#End Region
|
||||
|
||||
|
||||
Public Shared Function Get_Control_Value_for_ID(Control_ID As Integer, Record_ID As Integer)
|
||||
Try
|
||||
Return ClassDatabase.Execute_Scalar("SELECT VALUE FROM TBPMO_CONTROL_VALUE WHERE CONTROL_ID = " & Control_ID & " AND RECORD_ID = " & Record_ID, True)
|
||||
|
||||
Reference in New Issue
Block a user