DAtabase integriert

This commit is contained in:
2023-05-22 16:55:44 +02:00
parent 2db575d944
commit c2deb54f11
114 changed files with 8526 additions and 14722 deletions

View File

@@ -157,7 +157,7 @@ Public Class ClassControlValues
'Dim SQL As String = String.Format("SELECT * FROM VWPMO_VALUES WHERE VALUE <> '' AND RECORD_ID = {0}", RecordId)
Dim SQL As String = String.Format("SELECT * FROM VWPMO_VALUES WHERE RECORD_ID = {0}", RecordId)
Dim DT_ControlValues As DataTable = ClassDatabase.Return_Datatable(SQL, True)
Dim DT_ControlValues As DataTable = MYDB_ECM.GetDatatable(SQL)
CURRENT_CONTROL_VALUES = DT_ControlValues
sw.Done()
@@ -174,7 +174,7 @@ Public Class ClassControlValues
sw = New SW("LoadControlValues2")
' Load all Hints for controls
Dim SQLHint = "SELECT * FROM VWPMO_CONTROL_HINT WHERE FORM_ID = " & FormId
Dim DT_Hints As DataTable = ClassDatabase.Return_Datatable(SQLHint, True)
Dim DT_Hints As DataTable = MYDB_ECM.GetDatatable(SQLHint)
' ' Hint in DT_Hints suchen der zur aktuellen controlId passt
For Each row As DataRow In DT_Hints.Rows
ClassControlValueCache.SaveHint(row.Item(1), row.Item(2))
@@ -214,7 +214,7 @@ Public Class ClassControlValues
Try
'Dim SQL As String = String.Format("SELECT * FROM VWPMO_VALUES WHERE VALUE <> '' AND RECORD_ID = {0}", RecordId)
Dim SQL As String = String.Format("SELECT VALUE FROM VWPMO_VALUES WHERE RECORD_ID = {0} AND CONTROL_ID = {1}", RecordId, CONTROL_ID)
Dim RESULT = ClassDatabase.Execute_Scalar(SQL, True)
Dim RESULT = MYDB_ECM.ExecuteNonQuery(SQL)
If IsNothing(RESULT) Then
Return Nothing
ElseIf RESULT = "" Then
@@ -235,7 +235,7 @@ Public Class ClassControlValues
Dim id As Integer = DirectCast(c.Tag, ClassControlMetadata).Id
Dim sql As String = String.Format("SELECT HINT FROM TBPMO_CONTROL_LANGUAGE WHERE CONTROL_SCREEN_ID = (SELECT GUID FROM TBPMO_CONTROL_SCREEN WHERE CONTROL_ID = {0} AND SCREEN_ID = 1) AND LANGUAGE_TYPE = '{1}' AND HINT IS NOT NULL", id, USER_LANGUAGE)
Dim hint = ClassDatabase.Execute_Scalar(sql)
Dim hint = MYDB_ECM.GetScalarValue(sql)
If IsNothing(hint) Then
Continue For
@@ -251,64 +251,64 @@ Public Class ClassControlValues
' Für die meisten Controls wird nur das erste Element der Liste benötigt
Dim value As String = Nothing
If values.Count > 0 Then
value = values.Item(0)
End If
Select Case control.GetType()
Case GetType(TextBox)
If CURRENT_CONTROL_ID = 272 Then
Console.WriteLine("272")
End If
Dim textbox As TextBox = DirectCast(control, TextBox)
ControlLoader.TextBox.LoadValue(textbox, recordId, parentRecordId, value, entity_ID)
If values.Count > 0 Then
value = values.Item(0)
End If
Select Case control.GetType()
Case GetType(TextBox)
If CURRENT_CONTROL_ID = 272 Then
Console.WriteLine("272")
End If
Dim textbox As TextBox = DirectCast(control, TextBox)
ControlLoader.TextBox.LoadValue(textbox, recordId, parentRecordId, value, entity_ID)
Case GetType(Label)
Dim label As Label = DirectCast(control, Label)
ControlLoader.Label.LoadValue(label, recordId, parentRecordId, value, entity_ID)
Case GetType(Label)
Dim label As Label = DirectCast(control, Label)
ControlLoader.Label.LoadValue(label, recordId, parentRecordId, value, entity_ID)
Case GetType(CustomComboBox)
Case GetType(CustomComboBox)
Dim combobox As CustomComboBox = DirectCast(control, CustomComboBox)
ControlLoader.Combobox.LoadValue(combobox, recordId, parentRecordId, value)
Dim combobox As CustomComboBox = DirectCast(control, CustomComboBox)
ControlLoader.Combobox.LoadValue(combobox, recordId, parentRecordId, value)
Case GetType(CheckBox)
Dim checkbox As CheckBox = DirectCast(control, CheckBox)
ControlLoader.Checkbox.LoadValue(checkbox, value)
Case GetType(CheckBox)
Dim checkbox As CheckBox = DirectCast(control, CheckBox)
ControlLoader.Checkbox.LoadValue(checkbox, value)
Case GetType(RadioButton)
LOGGER.Debug("Sub LoadControlValueNeu - GetType(RadioButton) ", False)
Case GetType(RadioButton)
LOGGER.Debug("Sub LoadControlValueNeu - GetType(RadioButton) ")
Dim radiobutton As RadioButton = DirectCast(control, RadioButton)
ControlLoader.RadioButton.LoadValue(radiobutton, value)
ControlLoader.RadioButton.LoadValue(radiobutton, value)
Case GetType(DevExpress.XtraEditors.DateEdit)
Dim datepicker As DevExpress.XtraEditors.DateEdit = DirectCast(control, DevExpress.XtraEditors.DateEdit)
ControlLoader.DateTimePicker.LoadValue(datepicker, value)
Case GetType(DevExpress.XtraEditors.DateEdit)
Dim datepicker As DevExpress.XtraEditors.DateEdit = DirectCast(control, DevExpress.XtraEditors.DateEdit)
ControlLoader.DateTimePicker.LoadValue(datepicker, value)
Case GetType(DevExpress.XtraEditors.ListBoxControl)
Dim listbox As DevExpress.XtraEditors.ListBoxControl = DirectCast(control, DevExpress.XtraEditors.ListBoxControl)
ControlLoader.ListBox.LoadValue(listbox, value)
Case GetType(DevExpress.XtraEditors.ListBoxControl)
Dim listbox As DevExpress.XtraEditors.ListBoxControl = DirectCast(control, DevExpress.XtraEditors.ListBoxControl)
ControlLoader.ListBox.LoadValue(listbox, value)
Case GetType(DevExpress.XtraEditors.CheckedListBoxControl)
Dim checkedlistbox As DevExpress.XtraEditors.CheckedListBoxControl = DirectCast(control, DevExpress.XtraEditors.CheckedListBoxControl)
ControlLoader.CheckedListBox.LoadValue(checkedlistbox, values)
Case GetType(DevExpress.XtraEditors.CheckedListBoxControl)
Dim checkedlistbox As DevExpress.XtraEditors.CheckedListBoxControl = DirectCast(control, DevExpress.XtraEditors.CheckedListBoxControl)
ControlLoader.CheckedListBox.LoadValue(checkedlistbox, values)
Case GetType(PictureBox)
Dim picturebox = DirectCast(control, PictureBox)
LoadImage(recordId, controlId, picturebox)
Case GetType(PictureBox)
Dim picturebox = DirectCast(control, PictureBox)
LoadImage(recordId, controlId, picturebox)
Case GetType(DataGridView)
Dim gridview = DirectCast(control, DataGridView)
ControlLoader.DataGridView.LoadValue(gridview, values)
Case GetType(DataGridView)
Dim gridview = DirectCast(control, DataGridView)
ControlLoader.DataGridView.LoadValue(gridview, values)
Case GetType(DevExpress.XtraGrid.GridControl)
Dim gridcontrol As DevExpress.XtraGrid.GridControl = DirectCast(control, DevExpress.XtraGrid.GridControl)
ControlLoader.DataGridViewCheckable.LoadValue(gridcontrol, values)
Case Else
If GetType(Control).ToString() <> "System.Windows.Forms.Control" Then
LOGGER.Warn("Sub LoadControlValue - Control-Type nicht berücksichtigt: " & GetType(Control).ToString(), False)
Case GetType(DevExpress.XtraGrid.GridControl)
Dim gridcontrol As DevExpress.XtraGrid.GridControl = DirectCast(control, DevExpress.XtraGrid.GridControl)
ControlLoader.DataGridViewCheckable.LoadValue(gridcontrol, values)
Case Else
If GetType(Control).ToString() <> "System.Windows.Forms.Control" Then
LOGGER.Warn("Sub LoadControlValue - Control-Type nicht berücksichtigt: " & GetType(Control).ToString())
End If
End Select
End Select
'Catch ex As Exception
' Logger.Warn("Unexpected Error in LoadControlValue: " & ex.Message)
' MsgBox("Error in LoadControlValue:" & vbNewLine & ex.Message)
@@ -332,7 +332,7 @@ Public Class ClassControlValues
'Dim SQL As String = String.Format("SELECT CONTROL_ID, CONTROL_CONNID_1,CONTROL_SQLCOMMAND_1 AS SQL FROM VWPMO_CONTROL_SCREEN WHERE FORM_ID = {0} AND CONTROL_SQLCOMMAND_1 NOT LIKE '%@%'", FormID)
Dim Sql = String.Format("FORM_ID = {0} AND CONTROL_SQLCOMMAND_1 NOT LIKE '%@%'", FormID)
Dim dt As DataTable = ClassHelper.FILTER_DATATABLE(DT_VWPMO_CONTROL_SCREEN, Sql, "") 'ClassDatabase.Return_Datatable(SQL, True)
Dim dt As DataTable = ClassHelper.FILTER_DATATABLE(DT_VWPMO_CONTROL_SCREEN, Sql, "")
sw.Done()
@@ -400,7 +400,7 @@ Public Class ClassControlValues
Dim commands As New List(Of String)
Dim expression As String = String.Format("FORM_ID = {0} AND CONTROL_SQLCOMMAND_1 <> '' AND CONTROL_SQLCOMMAND_1 LIKE '%@%'", FormId)
Dim dt As DataTable = ClassHelper.FILTER_DATATABLE(DT_VWPMO_CONTROL_SCREEN, expression, "") 'ClassDatabase.Return_Datatable(SQL, True)
Dim dt As DataTable = ClassHelper.FILTER_DATATABLE(DT_VWPMO_CONTROL_SCREEN, expression, "")
If dt.Rows.Count = 0 Then
Exit Sub
@@ -421,7 +421,7 @@ Public Class ClassControlValues
'eigentlich sollte eine Parent_RecordID da sein
Try
Dim _SQL = String.Format("SELECT RECORD1_ID FROM TBPMO_RECORD_CONNECT WHERE RECORD2_ID = {0}", RecordId)
Dim ParentRec = ClassDatabase.Execute_Scalar(_SQL)
Dim ParentRec = MYDB_ECM.ExecuteNonQuery(_SQL)
If Not IsNothing(ParentRec) Then
If ParentRec > 0 Then
ParentRecordId = ParentRec
@@ -482,7 +482,7 @@ Public Class ClassControlValues
& "AND LEN(SQL_COMMAND_2) > 10 AND SQL_COMMAND_2 LIKE '%@%@%'", FormId)
Dim sw As New SW("Enable_Depending_Controls")
Dim commands As New List(Of String)
Dim dt As DataTable = ClassDatabase.Return_Datatable(SQL)
Dim dt As DataTable = MYDB_ECM.GetDatatable(SQL)
If dt.Rows.Count = 0 Then
Exit Sub
@@ -491,11 +491,11 @@ Public Class ClassControlValues
' Durchlaufe alle Controls, die eine Abhängigheit haben
For Each row As DataRow In dt.Rows
Dim msg = String.Format("Working on Depending Control-ID: {0}", row.Item("GUID").ToString)
LOGGER.Debug(msg, False)
LOGGER.Debug(msg)
Dim DependingControlId As Integer = row.Item("GUID")
Dim DependingControlSQL As String = row.Item("SQL_COMMAND_2")
msg = String.Format("SQL: {0}", DependingControlSQL)
LOGGER.Debug(msg, False)
LOGGER.Debug(msg)
Dim DependingControl As Control = controls.OfType(Of Control)().Where(Function(c As Control)
Return DirectCast(c.Tag, ClassControlMetadata).Id = DependingControlId
End Function).SingleOrDefault()
@@ -526,27 +526,27 @@ Public Class ClassControlValues
Select Case otherControlType
Case "CheckBox"
msg = String.Format("CheckBox-CtrlID: {0}", otherControlId)
LOGGER.Debug(msg, False)
LOGGER.Debug(msg)
value = DirectCast(otherControl, CheckBox).Checked
Case "TextBox"
msg = String.Format("TextBox-CtrlID: {0}", otherControlId)
LOGGER.Debug(msg, False)
LOGGER.Debug(msg)
value = DirectCast(otherControl, TextBox).Text
Case "CustomComboBox"
msg = String.Format("CustomComboBox-CtrlID: {0}", otherControlId)
LOGGER.Debug(msg, False)
LOGGER.Debug(msg)
value = DirectCast(otherControl, CustomComboBox).Text
Case "DateEdit"
msg = String.Format("DateEdit-CtrlID: {0}", otherControlId)
LOGGER.Debug(msg, False)
LOGGER.Debug(msg)
value = DirectCast(otherControl, DevExpress.XtraEditors.DateEdit).EditValue
End Select
' Jetzt ersetzen wir den Platzhalter im SQL Command
DependingControlSQL = regex.Replace(DependingControlSQL, value)
msg = String.Format("DependingControlSQL: {0}", DependingControlSQL)
LOGGER.Debug(msg, False)
Dim enableDT As DataTable = ClassDatabase.Return_Datatable(DependingControlSQL)
LOGGER.Debug(msg)
Dim enableDT As DataTable = MYDB_ECM.GetDatatable(DependingControlSQL)
If IsNothing(enableDT) Then
msg = String.Format("enableDT is nothing!! CHECK SQL {0}." & vbNewLine, DependingControlSQL)
LOGGER.Warn(msg)
@@ -564,10 +564,10 @@ Public Class ClassControlValues
DependingControl.Enabled = enabled
If enabled = False Then
msg = String.Format("Control {0} will be disabled." & vbNewLine, DependingControlId.ToString)
LOGGER.Debug(msg, False)
LOGGER.Debug(msg)
Else
msg = String.Format("Control {0} will be enabled." & vbNewLine, DependingControlId.ToString)
LOGGER.Debug(msg, False)
LOGGER.Debug(msg)
End If
Else
@@ -576,7 +576,7 @@ Public Class ClassControlValues
End If
Next
sw.done
sw.Done()
Catch ex As Exception
LOGGER.Warn("Unexpected Error in Enable_Depending_Controls: " & ex.Message, True)
MsgBox("Unexpected Error in Enable_Depending_Controls:" & vbNewLine & ex.Message, MsgBoxStyle.Critical)
@@ -612,7 +612,7 @@ Public Class ClassControlValues
Public Shared Sub LoadImage(RecordID As Integer, ControlID As Integer, control As Control)
Dim picbox As PictureBox = DirectCast(control, PictureBox)
Dim SQL As String = String.Format("SELECT IMG FROM TBPMO_CONTROL_IMAGE WHERE RECORD_ID = {0} AND CONTROL_ID = {1}", RecordID, ControlID)
Dim bimage As Byte() = ClassDatabase.Execute_Scalar(SQL)
Dim bimage As Byte() = MYDB_ECM.GetScalarValue(SQL)
If Not IsNothing(bimage) Then
picbox.BackgroundImage = ByteArrayToBitmap(bimage)
@@ -713,9 +713,9 @@ Public Class ClassControlValues
ClearControlValues(controls)
' Alle Controls laden, die einen Default Value haben
Dim SQL As String = String.Format("SELECT CONTROL_ID, CONTROL_DEF_VALUE, CONTROL_NAME FROM VWPMO_CONTROL_SCREEN WHERE FORM_ID = {0} AND CONTROL_DEF_VALUE <> '' " & _
Dim SQL As String = String.Format("SELECT CONTROL_ID, CONTROL_DEF_VALUE, CONTROL_NAME FROM VWPMO_CONTROL_SCREEN WHERE FORM_ID = {0} AND CONTROL_DEF_VALUE <> '' " &
"UNION SELECT CONTROL_ID, CONTROL_SQLCOMMAND_1 AS CONTROL_DEF_VALUE, CONTROL_NAME FROM VWPMO_CONTROL_SCREEN where FORM_ID = {0} and CONTROL_SQLCOMMAND_1 <> '' AND CONTROL_SQLCOMMAND_1 NOT LIKE '%@%@%' AND CONTROL_SQLCOMMAND_1 LIKE '%@RECORD_ID%'", FormID)
Dim DEFAULT_VALUE_DT As DataTable = ClassDatabase.Return_Datatable(SQL, True)
Dim DEFAULT_VALUE_DT As DataTable = MYDB_ECM.GetDatatable(SQL)
For Each row As DataRow In DEFAULT_VALUE_DT.Rows
@@ -726,7 +726,7 @@ Public Class ClassControlValues
Try
Dim control As Control = controls.Find(controlName, False)(0)
LoadDefaultValue(controlId, RecordID, Control, parentRecordID, EntityID, defaultValue)
LoadDefaultValue(controlId, RecordID, control, parentRecordID, EntityID, defaultValue)
Catch ex As Exception
LOGGER.Warn("Unexpected Error in getting default value for control '" & controlName & " - " & ex.Message, True)
End Try
@@ -777,10 +777,10 @@ Public Class ClassControlValues
Public Shared Sub LoadDefaultValue(ControlID As Integer, RecordID As Integer, control As Control, ParentRecordId As Integer, entity_ID As Integer, defaultValue As Object)
Try
'Dim SQL = String.Format("SELECT CONTROL_DEF_VALUE FROM VWPMO_CONTROL_SCREEN WHERE CONTROL_ID = {0} and CONTROL_DEF_VALUE <> ''", ControlID)
'Dim defaultValue = ClassDatabase.Execute_Scalar(SQL)
'Dim defaultValue = MYDB_ECM.GetScalarValue(SQL)
'Dim SQL = "SELECT * FROM VWPMO_CONTROL_SCREEN WHERE CONTROL_ID = " & ControlID
'Dim DT As DataTable = ClassDatabase.Return_Datatable(SQL)
'Dim DT As DataTable = MYDB_ECM.GetDatatable(SQL)
'Dim result = DT.Rows(0).Item("CONTROL_DEF_VALUE")
Select Case control.GetType()
@@ -799,7 +799,7 @@ Public Class ClassControlValues
vorgabe = vorgabe.Replace("@RECORD_ID", CURRENT_RECORD_ID)
vorgabe = vorgabe.Replace("@RECORDID", CURRENT_RECORD_ID)
vorgabe = vorgabe.Replace("@PARENTRECORD_ID", CURRENT_PARENT_RECORD_ID)
defaultValue = ClassDatabase.Execute_Scalar(vorgabe.ToString, True)
defaultValue = MYDB_ECM.ExecuteNonQuery(vorgabe.ToString)
If IsNothing(vorgabe) Then
textbox.Text = ""
End If
@@ -850,8 +850,8 @@ Public Class ClassControlValues
datepicker.EditValue = defaultValue
Case GetType(Label)
Dim lbl As Label = DirectCast(control, Label)
Dim CONNID = ClassDatabase.Execute_Scalar(String.Format("SELECT CONNECTION_ID_1 FROM TBPMO_CONTROL WHERE GUID = {0}", ControlID))
'Dim SQL_AUTOVALUE As String = ClassDatabase.Execute_Scalar(String.Format("SELECT SQL_COMMAND_1 FROM TBPMO_CONTROL WHERE GUID = {0}", ControlID))
Dim CONNID = MYDB_ECM.ExecuteNonQuery(String.Format("SELECT CONNECTION_ID_1 FROM TBPMO_CONTROL WHERE GUID = {0}", ControlID))
defaultValue = ClassControlValues.ReplaceSqlCommandPlaceholders(defaultValue, RecordID, ParentRecordId, entity_ID)
@@ -859,12 +859,12 @@ Public Class ClassControlValues
Exit Sub
End If
If Not IsNothing(CONNID) Then
defaultValue = ClassDatabase.Execute_ScalarWithConnection(CONNID, defaultValue)
Else
defaultValue = ClassDatabase.Execute_Scalar(defaultValue, True)
End If
' AutoValue = ClassDatabase.Execute_Scalar(SQL)
'If Not IsNothing(CONNID) Then
' defaultValue = ClassDatabase.Execute_ScalarWithConnection(CONNID, defaultValue)
'Else
defaultValue = MYDB_ECM.ExecuteNonQuery(defaultValue)
'End If
' AutoValue = MYDB_ECM.GetScalarValue(SQL)
If Not IsNothing(defaultValue) And Not IsDBNull(defaultValue) Then
lbl.Text = defaultValue
@@ -882,7 +882,7 @@ Public Class ClassControlValues
Try
Dim sql = "SELECT VALUE FROM TBPMO_CONTROL_VALUE WHERE CONTROL_ID = " & Control_ID & " AND RECORD_ID = " & Record_ID
CURRENT_LAST_SQL = sql
Return ClassDatabase.Execute_Scalar(sql)
Return MYDB_ECM.GetScalarValue(sql)
Catch ex As Exception
LOGGER.Warn("Unexpected Error in GetControlValueForControlID: " & ex.Message)
MsgBox("Error in GetControlValueForControlID:" & vbNewLine & ex.Message, MsgBoxStyle.Critical)