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,18 +507,28 @@ Public Class ClassControlCreator
Next
AddHandler oView.CustomRowCellEdit, Sub(sender As Object, e As CustomRowCellEditEventArgs)
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
If oComboboxDataTable Is Nothing Then
Throw New ApplicationException($"ComboboxTable for Column {e.Column.FieldName} is empty.")
End If
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.SelectedValuesChanged, Sub(_sender As Object, _e As List(Of String))
' oView.PostEditor()
' End Sub
e.RepositoryItem = oEditor
Else
Dim oEditor = New RepositoryItemComboBox()
@ -545,8 +559,16 @@ Public Class ClassControlCreator
End If
End If
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)