handle errors in sql queries for table columns

This commit is contained in:
Jonathan Jenne 2021-05-07 12:20:40 +02:00
parent 0a7cfbc35e
commit 20dc259f92

View File

@ -477,6 +477,10 @@ Public Class ClassControlCreator
Try
Dim oComboboxDataTable As DataTable = ClassDatabase.Return_Datatable_ConId(oSqlCommand, oConnectionId)
If oComboboxDataTable Is Nothing Then
LOGGER.Warn("DataTable for SQL [{0}] is nothing. Possible error on SQL Query.")
End If
GridTables.Item(oControl.Name).Add(oRow.Item("SPALTENNAME"), oComboboxDataTable)
'GridTables.Add(oRow.Item("SPALTENNAME"), oComboboxDataTable)
Catch ex As Exception
@ -503,50 +507,68 @@ Public Class ClassControlCreator
Next
AddHandler oView.CustomRowCellEdit, Sub(sender As Object, e As CustomRowCellEditEventArgs)
For Each oRow As DataRow In DT_MY_COLUMNS.Rows
If oRow.Item("SPALTENNAME") = e.Column.FieldName Then
If GridTables.Item(oControl.Name).ContainsKey(e.Column.FieldName) Then
Dim oComboboxDataTable As DataTable = GridTables.Item(oControl.Name).Item(e.Column.FieldName)
Try
For Each oRow As DataRow In DT_MY_COLUMNS.Rows
If oRow.Item("SPALTENNAME") = e.Column.FieldName Then
If GridTables.Item(oControl.Name).ContainsKey(e.Column.FieldName) Then
Dim oComboboxDataTable As DataTable = GridTables.Item(oControl.Name).Item(e.Column.FieldName)
If oRow.Item("ADVANCED_LOOKUP") Then
Dim oEditor = New RepositoryItemLookupControl3 With {
.DataSource = oComboboxDataTable,
.DisplayMember = oComboboxDataTable.Columns.Item(0).ColumnName,
.ValueMember = oComboboxDataTable.Columns.Item(0).ColumnName
}
If oComboboxDataTable Is Nothing Then
Throw New ApplicationException($"ComboboxTable for Column {e.Column.FieldName} is empty.")
End If
e.RepositoryItem = oEditor
Else
Dim oEditor = New RepositoryItemComboBox()
Dim oItems As New List(Of String)
If oRow.Item("ADVANCED_LOOKUP") And oComboboxDataTable IsNot Nothing Then
Dim oEditor = New RepositoryItemLookupControl3 With {
.DataSource = oComboboxDataTable,
.DisplayMember = oComboboxDataTable.Columns.Item(0).ColumnName,
.ValueMember = oComboboxDataTable.Columns.Item(0).ColumnName
}
AddHandler oEditor.Validating, Sub(_sender As ComboBoxEdit, _e As CancelEventArgs)
If oItems.Contains(_sender.EditValue) Then
_e.Cancel = False
Else
_e.Cancel = True
End If
End Sub
For Each oRow2 As DataRow In oComboboxDataTable.Rows
Dim oValue = oRow2.Item(0)
'AddHandler oEditor.SelectedValuesChanged, Sub(_sender As Object, _e As List(Of String))
' oView.PostEditor()
' End Sub
Try
oValue &= $" | {oRow2.Item(1)}"
Catch ex As Exception
End Try
e.RepositoryItem = oEditor
Else
Dim oEditor = New RepositoryItemComboBox()
Dim oItems As New List(Of String)
oEditor.Items.Add(oValue)
oItems.Add(oValue)
Next
AddHandler oEditor.Validating, Sub(_sender As ComboBoxEdit, _e As CancelEventArgs)
If oItems.Contains(_sender.EditValue) Then
_e.Cancel = False
Else
_e.Cancel = True
End If
e.RepositoryItem = oEditor
End Sub
For Each oRow2 As DataRow In oComboboxDataTable.Rows
Dim oValue = oRow2.Item(0)
Try
oValue &= $" | {oRow2.Item(1)}"
Catch ex As Exception
End Try
oEditor.Items.Add(oValue)
oItems.Add(oValue)
Next
e.RepositoryItem = oEditor
End If
End If
End If
End If
Next
Next
Catch ex As Exception
LOGGER.Warn("Error in CustomRowCellEdit for [{0}]", e.CellValue)
LOGGER.Error(ex)
End Try
End Sub
'AddHandler oView.CellValueChanged, Sub(sender As Object, e As CellValueChangedEventArgs)
' Console.WriteLine("")
' End Sub
AddHandler oView.ValidateRow, Sub(sender As Object, e As ValidateRowEventArgs)
Dim oRow As DataRowView = oView.GetRow(oView.FocusedRowHandle)