jj 15_12
This commit is contained in:
@@ -134,6 +134,126 @@ Public Class ClassControlValues
|
||||
End Try
|
||||
End Sub
|
||||
|
||||
#Region "#### ClassControlValues REWRITE ####"
|
||||
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
|
||||
End If
|
||||
|
||||
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
|
||||
|
||||
Next
|
||||
End Sub
|
||||
|
||||
Private Shared Sub LoadControlValueNeu(recordId As Integer, controlId As Integer, control As Control, value As Object)
|
||||
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 Else
|
||||
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 LoadControlValue:" & 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
|
||||
@@ -275,7 +395,7 @@ Public Class ClassControlValues
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user