Validierungslogik optimiert und Debug-Logs erweitert

Die Validierungslogik wurde flexibler gestaltet, indem die Bedingung
`pRegularComplete` eingeführt wurde. Wenn diese `False` ist, werden
bestimmte Validierungen übersprungen, und Debug-Nachrichten dokumentieren
das Verhalten.

- SQL-Löschoperationen erweitert, um zusätzliche Tabellen zu berücksichtigen.
- Prüfung auf `DBNull`-Werte bei `oValueFromSource` hinzugefügt.
- Validierungen für `LookupControl3`, Textboxen, ComboBoxen,
  DateTimePicker, CheckBoxen und DataGridViews angepasst.
- Debug-Logs in allen Validierungsfällen verbessert, um die Nachvollziehbarkeit
  zu erhöhen und unnötige Fehlermeldungen zu reduzieren.
This commit is contained in:
Developer01
2026-08-10 16:04:20 +02:00
parent 8d6a5500a9
commit ffa97402ff

View File

@@ -813,7 +813,8 @@ Public Class frmValidator
Try Try
Dim oSQL As String Dim oSQL As String
oSQL = $"DELETE FROM TBPM_DOCWALKOVER WHERE UserID = {USER_ID};" oSQL = $"DELETE FROM TBPM_DOCWALKOVER WHERE UserID = {USER_ID};" & vbCrLf &
$"DELETE FROM TBPM_VALIDATION_PROFILE_GROUP_USER WHERE UserID = {USER_ID};"
DatabaseFallback.ExecuteNonQueryECM(oSQL) DatabaseFallback.ExecuteNonQueryECM(oSQL)
Catch ex As Exception Catch ex As Exception
MyValidationLogger.Error(ex) MyValidationLogger.Error(ex)
@@ -5304,8 +5305,8 @@ Public Class frmValidator
oValueFromSource = GetVariableValuefromSource(oSourceIndexName, oIDBTyp, oIDBOverride) oValueFromSource = GetVariableValuefromSource(oSourceIndexName, oIDBTyp, oIDBOverride)
End If End If
If oValueFromSource Is Nothing Then If oValueFromSource Is Nothing Or IsDBNull(oValueFromSource) Then
MyValidationLogger.Debug($"oMyComboBox {oMyCombobox.Name} - Indexvalue from index {oSourceIndexName}: Nothing") MyValidationLogger.Debug($"oMyComboBox {oMyCombobox.Name} - Indexvalue from index {oSourceIndexName} is Nothing or DBNull")
If oDefaultValue = String.Empty Then If oDefaultValue = String.Empty Then
MyValidationLogger.Debug($"oMyComboBox {oMyCombobox.Name}-defaultValue wurde nicht gefunden") MyValidationLogger.Debug($"oMyComboBox {oMyCombobox.Name}-defaultValue wurde nicht gefunden")
oMyCombobox.SelectedIndex = -1 oMyCombobox.SelectedIndex = -1
@@ -7084,13 +7085,18 @@ Public Class frmValidator
Case oControl.GetType = GetType(LookupControl3) Case oControl.GetType = GetType(LookupControl3)
Try Try
Dim lookup As LookupControl3 = oControl Dim lookup As LookupControl3 = oControl
If lookup.Properties.SelectedValues.Count = 0 And oIsRequired = True And pRegularComplete Then If lookup.Properties.SelectedValues.Count = 0 And oIsRequired = True Then
If pRegularComplete = False Then
MyValidationLogger.Debug($"[CHECK_UPDATE] LookupGrid '{oControl.Name}' is required but has no selection. Skipping due to pRegularComplete=False.")
Continue For
Else
oMissing = True oMissing = True
oErrMsgMissingInput = $"Pflichtfeld: Keine Auswahl getroffen in LookupGrid '{oControl.Name}'" oErrMsgMissingInput = $"Pflichtfeld: Keine Auswahl getroffen in LookupGrid '{oControl.Name}'"
MyValidationLogger.Warn($"⚠️ {oErrMsgMissingInput}") MyValidationLogger.Warn($"⚠️ {oErrMsgMissingInput}")
oControl.BackColor = Color.Red oControl.BackColor = Color.Red
OpenfrmError(oErrMsgMissingInput) OpenfrmError(oErrMsgMissingInput)
Exit For Exit For
End If
Else Else
If lookup.Properties.MultiSelect = True Then If lookup.Properties.MultiSelect = True Then
Dim oLookupRows As Integer = lookup.Properties.SelectedValues.Count Dim oLookupRows As Integer = lookup.Properties.SelectedValues.Count
@@ -7142,14 +7148,20 @@ Public Class frmValidator
End If End If
End If End If
Else Else
' Single-Select Lookup ' Single-Select Lookup
oMyInput = lookup.Properties.SelectedValues.FirstOrDefault() oMyInput = lookup.Properties.SelectedValues.FirstOrDefault()
If IsNothing(oMyInput) And oIsRequired = True And pRegularComplete Then If IsNothing(oMyInput) And oIsRequired = True Then
If pRegularComplete = False Then
MyValidationLogger.Debug($"[CHECK_UPDATE] LookupGrid(SingleSelect) '{lookup.Name}' is required but has no selection. Skipping due to pRegularComplete=False.")
Continue For
Else
oMissing = True oMissing = True
oErrMsgMissingInput = $"Could not get FirstOrDefault-Value of LookUpGrid! - LookUPGridName: {lookup.Name}" oErrMsgMissingInput = $"Could not get FirstOrDefault-Value of LookUpGrid! - LookUPGridName: {lookup.Name}"
MyValidationLogger.Warn(oErrMsgMissingInput) MyValidationLogger.Warn(oErrMsgMissingInput)
OpenfrmError(oErrMsgMissingInput) OpenfrmError(oErrMsgMissingInput)
Exit For Exit For
End If
ElseIf IsNothing(oMyInput) And oIsRequired = False Then ElseIf IsNothing(oMyInput) And oIsRequired = False Then
For Each ochangedLookub In listChangedLookup For Each ochangedLookub In listChangedLookup
If lookup.Name = ochangedLookub Then If lookup.Name = ochangedLookub Then
@@ -7280,13 +7292,18 @@ Public Class frmValidator
Exit For Exit For
End If End If
If Check_Missing_Control_Value(oControl, "txt") = True And oIsRequired = True And pRegularComplete Then If Check_Missing_Control_Value(oControl, "txt") = True And oIsRequired = True Then
If pRegularComplete = False Then
MyValidationLogger.Debug($"[CHECK_UPDATE] TextEdit '{oControl.Name}' is required but has no selection. Skipping due to pRegularComplete=False.")
Continue For
Else
oMissing = True oMissing = True
oErrMsgMissingInput = oWrongInputMessage & " textbox '" & oControl.Name & "'" oErrMsgMissingInput = oWrongInputMessage & " textbox '" & oControl.Name & "'"
MyValidationLogger.Warn(oErrMsgMissingInput) MyValidationLogger.Warn(oErrMsgMissingInput)
oControl.BackColor = Color.Red oControl.BackColor = Color.Red
frmError.ShowDialog() frmError.ShowDialog()
Exit For Exit For
End If
Else Else
MyValidationLogger.Debug("Reading current value from Textbox") MyValidationLogger.Debug("Reading current value from Textbox")
Dim oTextEdit As BaseEdit = DirectCast(oControl, BaseEdit) Dim oTextEdit As BaseEdit = DirectCast(oControl, BaseEdit)
@@ -7410,7 +7427,11 @@ Public Class frmValidator
Try Try
MyValidationLogger.Debug($"Working on Combobox...") MyValidationLogger.Debug($"Working on Combobox...")
Dim cmb As Windows.Forms.ComboBox = oControl Dim cmb As Windows.Forms.ComboBox = oControl
If cmb.SelectedIndex = -1 And oIsRequired = True And pRegularComplete Then If cmb.SelectedIndex = -1 And oIsRequired = True Then
If pRegularComplete = False Then
MyValidationLogger.Debug($"[CHECK_UPDATE] ComboBox '{cmb.Name}' is required but has no selection. Skipping due to pRegularComplete=False.")
Continue For
Else
oMissing = True oMissing = True
oErrMsgMissingInput = "Please Choose an entry out of ComboBox '" & cmb.Name & "'" oErrMsgMissingInput = "Please Choose an entry out of ComboBox '" & cmb.Name & "'"
MyValidationLogger.Warn(oErrMsgMissingInput) MyValidationLogger.Warn(oErrMsgMissingInput)
@@ -7420,6 +7441,7 @@ Public Class frmValidator
End If End If
OpenfrmError(oErrMsgMissingInput) OpenfrmError(oErrMsgMissingInput)
Exit For Exit For
End If
Else Else
oMyInput = cmb.Text oMyInput = cmb.Text
MyValidationLogger.Debug($"inputvalue Combobox: {cmb.Text}") MyValidationLogger.Debug($"inputvalue Combobox: {cmb.Text}")
@@ -7545,7 +7567,11 @@ Public Class frmValidator
Case oControl.GetType = GetType(DateTimePicker) Case oControl.GetType = GetType(DateTimePicker)
Try Try
Dim dtp As DateTimePicker = oControl Dim dtp As DateTimePicker = oControl
If oIsRequired = True And dtp.Value.ToString = String.Empty And pRegularComplete Then If oIsRequired = True And dtp.Value.ToString = String.Empty Then
If pRegularComplete = False Then
MyValidationLogger.Debug($"[CHECK_UPDATE] DateTimePicker '{dtp.Name}' is required but has no selection. Skipping due to pRegularComplete=False.")
Continue For
Else
oMissing = True oMissing = True
oErrMsgMissingInput = "Please Choose DateValue for field'" & dtp.Name & "'" oErrMsgMissingInput = "Please Choose DateValue for field'" & dtp.Name & "'"
MyValidationLogger.Warn(oErrMsgMissingInput) MyValidationLogger.Warn(oErrMsgMissingInput)
@@ -7555,6 +7581,7 @@ Public Class frmValidator
End If End If
OpenfrmError(oErrMsgMissingInput) OpenfrmError(oErrMsgMissingInput)
Exit For Exit For
End If
ElseIf dtp.Value.ToString <> "01.01.0001 00:00:00" Then ElseIf dtp.Value.ToString <> "01.01.0001 00:00:00" Then
oMyInput = CDate(dtp.Value) oMyInput = CDate(dtp.Value)
Dim oObjectValue Dim oObjectValue
@@ -7641,7 +7668,11 @@ Public Class frmValidator
Dim chk As CheckBox = oControl Dim chk As CheckBox = oControl
oMyInput = chk.Checked.ToString oMyInput = chk.Checked.ToString
If chk.CheckState = CheckState.Indeterminate And oIsRequired = True And pRegularComplete Then If chk.CheckState = CheckState.Indeterminate And oIsRequired = True Then
If pRegularComplete = False Then
MyValidationLogger.Debug($"[CHECK_UPDATE] CheckBox '{chk.Name}' is required but has no selection. Skipping due to pRegularComplete=False.")
Continue For
Else
oMissing = True oMissing = True
oErrMsgMissingInput = "Please set Checkbox value for field '" & chk.Name & "'" oErrMsgMissingInput = "Please set Checkbox value for field '" & chk.Name & "'"
MyValidationLogger.Warn(oErrMsgMissingInput) MyValidationLogger.Warn(oErrMsgMissingInput)
@@ -7652,6 +7683,7 @@ Public Class frmValidator
OpenfrmError(oErrMsgMissingInput) OpenfrmError(oErrMsgMissingInput)
Exit For Exit For
End If End If
End If
Dim WertWD As String Dim WertWD As String
Dim oBoolValue As Boolean Dim oBoolValue As Boolean
@@ -7759,7 +7791,11 @@ Public Class frmValidator
Zeilen += 1 Zeilen += 1
End If End If
Next Next
If oIsRequired = True And Zeilen = 0 And pRegularComplete Then If oIsRequired = True And Zeilen = 0 Then
If pRegularComplete = False Then
MyValidationLogger.Debug($"[CHECK_UPDATE] DataGridView '{dgv.Name}' is required but has no selection. Skipping due to pRegularComplete=False.")
Continue For
Else
oMissing = True oMissing = True
oErrMsgMissingInput = "Fehlende Eingabe in Vektorfeld '" & dgv.Name & "'" oErrMsgMissingInput = "Fehlende Eingabe in Vektorfeld '" & dgv.Name & "'"
MyValidationLogger.Warn(oErrMsgMissingInput) MyValidationLogger.Warn(oErrMsgMissingInput)
@@ -7769,6 +7805,7 @@ Public Class frmValidator
End If End If
OpenfrmError(oErrMsgMissingInput) OpenfrmError(oErrMsgMissingInput)
Exit For Exit For
End If
ElseIf Zeilen > 0 Then ElseIf Zeilen > 0 Then
Dim ZeilenGrid As Integer = 0 Dim ZeilenGrid As Integer = 0
Dim myVektorArr As String() Dim myVektorArr As String()