Load table in mass validator

This commit is contained in:
Jonathan Jenne
2019-05-22 13:59:48 +02:00
parent 22e570c032
commit 7476639397
4 changed files with 244 additions and 196 deletions

View File

@@ -54,7 +54,7 @@ Public Class frmMassValidator
Size = My.Settings.frmMassValidatorSize
End If
Try
DT_PROFILE_CONTROLS = ClassDatabase.Return_Datatable("SELECT * FROM TBPM_PROFILE_CONTROLS WHERE CTRL_TYPE <> 'TABLE' AND SQL_UEBERPRUEFUNG NOT LIKE '%WMI%' AND PROFIL_ID = " & CURRENT_ProfilGUID)
DT_PROFILE_CONTROLS = ClassDatabase.Return_Datatable("SELECT * FROM TBPM_PROFILE_CONTROLS WHERE SQL_UEBERPRUEFUNG NOT LIKE '%WMI%' AND PROFIL_ID = " & CURRENT_ProfilGUID)
LOGGER.Debug("Profile Data geladen")
Catch ex As Exception
LOGGER.Error(ex)
@@ -125,214 +125,209 @@ Public Class frmMassValidator
End Sub
Sub Load_Controls()
' Try
'Try
pnldesigner.Controls.Clear()
'Dim dt As DataTable = DD_DMSLiteDataSet.VWPM_CONTROL_INDEX
For Each oControlRow As DataRow In DT_PROFILE_CONTROLS.Rows
Dim ctrl As Control
Select Case oControlRow.Item("CTRL_TYPE").ToString.ToUpper
Case "TXT"
LOGGER.Debug("Versuch TXT zu laden")
Dim txt As TextBox = ClassControlCreator.CreateExistingTextbox(oControlRow, False)
For Each dr As DataRow In DT_PROFILE_CONTROLS.Rows
Dim ctrl As Control
AddHandler txt.GotFocus, AddressOf OnTextBoxFocus
AddHandler txt.LostFocus, AddressOf OnTextBoxLostFocus
AddHandler txt.KeyUp, AddressOf OnTextBoxKeyUp
Select Case dr.Item("CTRL_TYPE").ToString.ToUpper
Case "TXT"
LOGGER.Debug("Versuch TXT zu laden")
Dim txt As TextBox = ClassControlCreator.CreateExistingTextbox(dr, False)
ctrl = txt
Case "LBL"
LOGGER.Debug("Versuch LBL zu laden")
ctrl = ClassControlCreator.CreateExistingLabel(oControlRow, False)
Case "CMB"
LOGGER.Debug("Versuch CMB zu laden")
AddHandler txt.GotFocus, AddressOf OnTextBoxFocus
AddHandler txt.LostFocus, AddressOf OnTextBoxLostFocus
AddHandler txt.KeyUp, AddressOf OnTextBoxKeyUp
Dim cmb = ClassControlCreator.CreateExistingCombobox(oControlRow, False)
ctrl = txt
Case "LBL"
LOGGER.Debug("Versuch LBL zu laden")
ctrl = ClassControlCreator.CreateExistingLabel(dr, False)
Case "CMB"
LOGGER.Debug("Versuch CMB zu laden")
Dim cmb = ClassControlCreator.CreateExistingCombobox(dr, False)
AddHandler cmb.SelectedValueChanged, AddressOf OnCmbselectedIndex
AddHandler cmb.SelectedValueChanged, AddressOf OnCmbselectedIndex
#Region "CONTROL LIST"
If ClassControlCreator.GET_CONTROL_PROPERTIES(DT_PROFILE_CONTROLS, cmb.Name) = 0 Then
MsgBox("Unexpected Error in getting control-properties (CMB load) - Check the log and inform Your sysadmin!", MsgBoxStyle.Critical)
Exit Sub
End If
Dim CURR_SQL_PROVIDER As String
If CURRENT_CONTROL_ID > 0 Then
If CURR_CON_ID > 0 Then
Dim commandsql = CURR_SELECT_CONTROL
If commandsql <> "" Then
LOGGER.Debug("ConID > 0 And commandsql <> ''")
Dim connectionString As String
If ClassControlCreator.GET_CONTROL_PROPERTIES(DT_PROFILE_CONTROLS, cmb.Name) = 0 Then
MsgBox("Unexpected Error in getting control-properties (CMB load) - Check the log and inform Your sysadmin!", MsgBoxStyle.Critical)
Exit Sub
End If
Dim CURR_SQL_PROVIDER As String
If CURRENT_CONTROL_ID > 0 Then
If CURR_CON_ID > 0 Then
Dim commandsql = CURR_SELECT_CONTROL
If commandsql <> "" Then
LOGGER.Debug("ConID > 0 And commandsql <> ''")
Dim connectionString As String
Dim ConRow As DataRow() = ClassControlCreator.GET_CONNECTION_INFO(CURR_CON_ID)
If ConRow Is Nothing Then
MsgBox("Unexpected Error in getting Coninfo (CMB load) - Check the log and inform Your sysadmin!", MsgBoxStyle.Critical)
Exit Sub
End If
Dim ConRow As DataRow() = ClassControlCreator.GET_CONNECTION_INFO(CURR_CON_ID)
If ConRow Is Nothing Then
MsgBox("Unexpected Error in getting Coninfo (CMB load) - Check the log and inform Your sysadmin!", MsgBoxStyle.Critical)
Exit Sub
End If
For Each row As DataRow In ConRow
Select Case row("SQL_PROVIDER").ToString.ToLower
Case "ms-sql"
CURR_SQL_PROVIDER = "ms-sql"
If row("USERNAME") = "WINAUTH" Then
connectionString = "Data Source=" & row("SERVER") & ";Initial Catalog=" & row("DATENBANK") & ";Trusted_Connection=True;"
Else
connectionString = "Data Source=" & row("SERVER") & ";Initial Catalog= " & row("DATENBANK") & ";User Id=" & row("USERNAME") & ";Password=" & row("PASSWORD") & ";"
For Each row As DataRow In ConRow
Select Case row("SQL_PROVIDER").ToString.ToLower
Case "ms-sql"
CURR_SQL_PROVIDER = "ms-sql"
If row("USERNAME") = "WINAUTH" Then
connectionString = "Data Source=" & row("SERVER") & ";Initial Catalog=" & row("DATENBANK") & ";Trusted_Connection=True;"
Else
connectionString = "Data Source=" & row("SERVER") & ";Initial Catalog= " & row("DATENBANK") & ";User Id=" & row("USERNAME") & ";Password=" & row("PASSWORD") & ";"
End If
LOGGER.Debug("ConnString Sql-Server: " & connectionString)
Case "oracle"
CURR_SQL_PROVIDER = "oracle"
Dim conn As New OracleConnectionStringBuilder
Dim connstr As String
If row("SERVER") <> "" And row("DATENBANK").GetType.ToString <> "system.dbnull" Then
connstr = "Data Source=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=" & row("SERVER") & ")(PORT=1521)))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=" &
row("DATENBANK") & ")));User Id=" & row("USERNAME") & ";Password=" & row("PASSWORD") & ";"
Else
conn.DataSource = row("SERVER")
conn.UserID = row("USERNAME")
conn.Password = row("PASSWORD")
conn.PersistSecurityInfo = True
conn.ConnectionTimeout = 120
connstr = conn.ConnectionString
End If
connectionString = connstr
Case Else
LOGGER.Info("ConnectionString-Type not integrated")
MsgBox("ConnectionString-Type not integrated", MsgBoxStyle.Critical)
Exit Sub
End Select
Next
If connectionString Is Nothing = False And CURR_SQL_PROVIDER = "ms-sql" Then
Try
Dim sqlCnn As SqlClient.SqlConnection
Dim sqlCmd As SqlClient.SqlCommand
Dim adapter As New SqlClient.SqlDataAdapter
Dim NewDataset As New DataSet
Dim i As Integer
'sql = ClassPatterns.ReplaceAllValues(sql, pnldesigner, aktivesDokument)
If clsPatterns.HasOnlySimplePatterns(CURR_SELECT_CONTROL) Then
CURR_SELECT_CONTROL = clsPatterns.ReplaceInternalValues(CURR_SELECT_CONTROL)
CURR_SELECT_CONTROL = clsPatterns.ReplaceControlValues(CURR_SELECT_CONTROL, pnldesigner)
sqlCnn = New SqlClient.SqlConnection(connectionString)
' Try
sqlCnn.Open()
sqlCmd = New SqlClient.SqlCommand(CURR_SELECT_CONTROL, sqlCnn)
adapter.SelectCommand = sqlCmd
adapter.Fill(NewDataset)
For i = 0 To NewDataset.Tables(0).Rows.Count - 1
cmb.Items.Add(NewDataset.Tables(0).Rows(i).Item(0))
Next
adapter.Dispose()
sqlCmd.Dispose()
sqlCnn.Close()
End If
LOGGER.Debug("ConnString Sql-Server: " & connectionString)
Case "oracle"
CURR_SQL_PROVIDER = "oracle"
Dim conn As New OracleConnectionStringBuilder
Dim connstr As String
If row("SERVER") <> "" And row("DATENBANK").GetType.ToString <> "system.dbnull" Then
connstr = "Data Source=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=" & row("SERVER") & ")(PORT=1521)))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=" &
row("DATENBANK") & ")));User Id=" & row("USERNAME") & ";Password=" & row("PASSWORD") & ";"
Else
conn.DataSource = row("SERVER")
conn.UserID = row("USERNAME")
conn.Password = row("PASSWORD")
conn.PersistSecurityInfo = True
conn.ConnectionTimeout = 120
connstr = conn.ConnectionString
End If
connectionString = connstr
Case Else
LOGGER.Info("ConnectionString-Type not integrated")
MsgBox("ConnectionString-Type not integrated", MsgBoxStyle.Critical)
Exit Sub
End Select
Next
If connectionString Is Nothing = False And CURR_SQL_PROVIDER = "ms-sql" Then
Try
Dim sqlCnn As SqlClient.SqlConnection
Dim sqlCmd As SqlClient.SqlCommand
Dim adapter As New SqlClient.SqlDataAdapter
Dim NewDataset As New DataSet
Dim i As Integer
'sql = ClassPatterns.ReplaceAllValues(sql, pnldesigner, aktivesDokument)
If clsPatterns.HasOnlySimplePatterns(CURR_SELECT_CONTROL) Then
CURR_SELECT_CONTROL = clsPatterns.ReplaceInternalValues(CURR_SELECT_CONTROL)
CURR_SELECT_CONTROL = clsPatterns.ReplaceControlValues(CURR_SELECT_CONTROL, pnldesigner)
sqlCnn = New SqlClient.SqlConnection(connectionString)
' Try
sqlCnn.Open()
sqlCmd = New SqlClient.SqlCommand(CURR_SELECT_CONTROL, sqlCnn)
adapter.SelectCommand = sqlCmd
adapter.Fill(NewDataset)
For i = 0 To NewDataset.Tables(0).Rows.Count - 1
cmb.Items.Add(NewDataset.Tables(0).Rows(i).Item(0))
Next
adapter.Dispose()
sqlCmd.Dispose()
sqlCnn.Close()
End If
Catch ex As Exception
LOGGER.Error(ex)
LOGGER.Info("Unexpected Error in running depending sql-command: " & ex.Message)
Clipboard.SetText("Error: " & ex.Message & vbNewLine & "SQL: " & CURR_SELECT_CONTROL)
MsgBox(ex.Message, MsgBoxStyle.Critical, "Unexpected Error in running depending sql-command:")
End Try
Catch ex As Exception
LOGGER.Error(ex)
LOGGER.Info("Unexpected Error in running depending sql-command: " & ex.Message)
Clipboard.SetText("Error: " & ex.Message & vbNewLine & "SQL: " & CURR_SELECT_CONTROL)
MsgBox(ex.Message, MsgBoxStyle.Critical, "Unexpected Error in running depending sql-command:")
End Try
End If
Else
LOGGER.Debug("Else Row 571")
End If
Else
LOGGER.Debug("Else Row 571")
End If
Else
If CURR_CHOICE_LIST <> "" Then
LOGGER.Debug("In add_ComboBox - AListe: " & CURR_CHOICE_LIST)
Dim liste = WINDREAM.GetValuesfromAuswahlliste(CURR_CHOICE_LIST)
If liste IsNot Nothing Then
cmb.Items.Add("")
For Each index As String In liste
cmb.Items.Add(index)
Next
cmb.SelectedIndex = -1
Else
MsgBox("Resultliste windream is nothing!", MsgBoxStyle.Exclamation, CURR_CHOICE_LIST)
If CURR_CHOICE_LIST <> "" Then
LOGGER.Debug("In add_ComboBox - AListe: " & CURR_CHOICE_LIST)
Dim liste = WINDREAM.GetValuesfromAuswahlliste(CURR_CHOICE_LIST)
If liste IsNot Nothing Then
cmb.Items.Add("")
For Each index As String In liste
cmb.Items.Add(index)
Next
cmb.SelectedIndex = -1
Else
MsgBox("Resultliste windream is nothing!", MsgBoxStyle.Exclamation, CURR_CHOICE_LIST)
End If
End If
End If
End If
End If
#End Region
Dim maxWith As Integer = cmb.Width
Using g As Graphics = Me.CreateGraphics
For Each oItem As Object In cmb.Items 'Für alle Einträge...
Dim g1 As Graphics = cmb.CreateGraphics
If g1.MeasureString(Text, cmb.Font).Width + 30 > maxWith Then
maxWith = g1.MeasureString(Text, cmb.Font).Width + 30
End If
g1.Dispose()
Next oItem
End Using
cmb.DropDownWidth = maxWith
Dim maxWith As Integer = cmb.Width
Using g As Graphics = Me.CreateGraphics
For Each oItem As Object In cmb.Items 'Für alle Einträge...
Dim g1 As Graphics = cmb.CreateGraphics
If g1.MeasureString(Text, cmb.Font).Width + 30 > maxWith Then
maxWith = g1.MeasureString(Text, cmb.Font).Width + 30
End If
g1.Dispose()
Next oItem
End Using
cmb.DropDownWidth = maxWith
ctrl = cmb
Case "DTP"
LOGGER.Debug("Versuch DTP zu laden")
ctrl = ClassControlCreator.CreateExistingDatepicker(dr, False)
Case "DGV"
LOGGER.Debug("Versuch DGV zu laden")
Dim dgv = ClassControlCreator.CreateExistingDataGridView(dr, False)
ctrl = cmb
Case "DTP"
LOGGER.Debug("Versuch DTP zu laden")
ctrl = ClassControlCreator.CreateExistingDatepicker(oControlRow, False)
Case "DGV"
LOGGER.Debug("Versuch DGV zu laden")
Dim dgv = ClassControlCreator.CreateExistingDataGridView(oControlRow, False)
AddHandler dgv.RowValidating, AddressOf onDGVRowValidating
AddHandler dgv.RowValidating, AddressOf onDGVRowValidating
ctrl = dgv
Case "CHK"
LOGGER.Debug("Versuch Checkbox zu laden")
ctrl = ClassControlCreator.CreateExisingCheckbox(dr, False)
'Case "TABLE"
' If LogErrorsOnly = False Then LOGGER.Info(" >> Versuch Tabelle zu laden")
' For Each c As DataColumn In DT_PROFILE_CONTROLS.Columns
' '... = c.ColumnName
' Next
' Dim columns As List(Of DD_DMSLiteDataSet.TBPM_CONTROL_TABLERow) = (From r As DD_DMSLiteDataSet.TBPM_CONTROL_TABLERow In DT_PROFILE_CONTROLS
' Where r.CONTROL_ID = dr.Item("GUID")
' Select r).ToList()
' ctrl = ClassControlCreator.CreateExistingTable(dr, columns)
ctrl = dgv
Case "CHK"
LOGGER.Debug("Versuch Checkbox zu laden")
ctrl = ClassControlCreator.CreateExisingCheckbox(oControlRow, False)
Case "LINE"
LOGGER.Debug("Versuch Linie zu laden")
LOGGER.Debug("Versuch Linie zu laden")
ctrl = ClassControlCreator.CreateExistingLine(dr, False)
Case "LOOKUP"
ctrl = ClassControlCreator.CreateExistingLookupControl(dr, False)
End Select
ctrl = ClassControlCreator.CreateExistingLine(oControlRow, False)
Case "LOOKUP"
ctrl = ClassControlCreator.CreateExistingLookupControl(oControlRow, False)
Case "TABLE"
LOGGER.Debug("Versuch Tabelle zu laden")
If TypeOf ctrl IsNot Label Then
' If first_control Is Nothing Then
'first_control = ctrl
'End If
'last_control = ctrl
End If
TBPM_CONTROL_TABLETableAdapter.Connection.ConnectionString = CONNECTION_STRING
TBPM_CONTROL_TABLETableAdapter.Fill(DD_DMSLiteDataSet.TBPM_CONTROL_TABLE, oControlRow.Item("GUID"))
pnldesigner.Controls.Add(ctrl)
Dim columns As List(Of DD_DMSLiteDataSet.TBPM_CONTROL_TABLERow) = (From r As DD_DMSLiteDataSet.TBPM_CONTROL_TABLERow In DD_DMSLiteDataSet.TBPM_CONTROL_TABLE
Where r.CONTROL_ID = oControlRow.Item("GUID")
Select r).ToList()
ctrl = ClassControlCreator.CreateExistingTable(oControlRow, columns, False)
End Select
If TypeOf ctrl IsNot Label Then
' If first_control Is Nothing Then
'first_control = ctrl
'End If
'last_control = ctrl
End If
pnldesigner.Controls.Add(ctrl)
Next
LOGGER.Debug("Controls geladen")
LOGGER.Info("")
CTRLS_Loaded = True
FillIndexValues()
For Each oControl As Control In pnldesigner.Controls
LoadSimpleData(oControl, oControl.Tag)
Next
Next
LOGGER.Debug("Controls geladen")
LOGGER.Info("")
CTRLS_Loaded = True
FillIndexValues()
For Each oControl As Control In pnldesigner.Controls
LoadSimpleData(oControl, oControl.Tag)
Next
'Catch ex As Exception
' If LogErrorsOnly = False Then MsgBox("Error Load_Controls: " & ex.Message, MsgBoxStyle.Critical, "Attention error:")
' ' allgFunk.Insert_LogEntry(CURRENT_ProfilGUID, "Error Load_Controls: " & ex.Message, Environment.UserName)
' allgFunk.Insert_LogEntry(CURRENT_ProfilGUID, "Error Load_Controls: " & ex.Message, Environment.UserName)
' LOGGER.Info("Unvorhergesehener Fehler bei Load_Controls:" & ex.Message)
' LOGGER.Info("")
@@ -1692,5 +1687,4 @@ Public Class frmMassValidator
' KillU_Viewer()
'End If
End Sub
End Class