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
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)
Catch ex As Exception
MyValidationLogger.Error(ex)
@@ -5304,8 +5305,8 @@ Public Class frmValidator
oValueFromSource = GetVariableValuefromSource(oSourceIndexName, oIDBTyp, oIDBOverride)
End If
If oValueFromSource Is Nothing Then
MyValidationLogger.Debug($"oMyComboBox {oMyCombobox.Name} - Indexvalue from index {oSourceIndexName}: Nothing")
If oValueFromSource Is Nothing Or IsDBNull(oValueFromSource) Then
MyValidationLogger.Debug($"oMyComboBox {oMyCombobox.Name} - Indexvalue from index {oSourceIndexName} is Nothing or DBNull")
If oDefaultValue = String.Empty Then
MyValidationLogger.Debug($"oMyComboBox {oMyCombobox.Name}-defaultValue wurde nicht gefunden")
oMyCombobox.SelectedIndex = -1
@@ -7084,13 +7085,18 @@ Public Class frmValidator
Case oControl.GetType = GetType(LookupControl3)
Try
Dim lookup As LookupControl3 = oControl
If lookup.Properties.SelectedValues.Count = 0 And oIsRequired = True And pRegularComplete Then
oMissing = True
oErrMsgMissingInput = $"Pflichtfeld: Keine Auswahl getroffen in LookupGrid '{oControl.Name}'"
MyValidationLogger.Warn($"⚠️ {oErrMsgMissingInput}")
oControl.BackColor = Color.Red
OpenfrmError(oErrMsgMissingInput)
Exit For
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
oErrMsgMissingInput = $"Pflichtfeld: Keine Auswahl getroffen in LookupGrid '{oControl.Name}'"
MyValidationLogger.Warn($"⚠️ {oErrMsgMissingInput}")
oControl.BackColor = Color.Red
OpenfrmError(oErrMsgMissingInput)
Exit For
End If
Else
If lookup.Properties.MultiSelect = True Then
Dim oLookupRows As Integer = lookup.Properties.SelectedValues.Count
@@ -7142,14 +7148,20 @@ Public Class frmValidator
End If
End If
Else
' Single-Select Lookup
oMyInput = lookup.Properties.SelectedValues.FirstOrDefault()
If IsNothing(oMyInput) And oIsRequired = True And pRegularComplete Then
oMissing = True
oErrMsgMissingInput = $"Could not get FirstOrDefault-Value of LookUpGrid! - LookUPGridName: {lookup.Name}"
MyValidationLogger.Warn(oErrMsgMissingInput)
OpenfrmError(oErrMsgMissingInput)
Exit For
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
oErrMsgMissingInput = $"Could not get FirstOrDefault-Value of LookUpGrid! - LookUPGridName: {lookup.Name}"
MyValidationLogger.Warn(oErrMsgMissingInput)
OpenfrmError(oErrMsgMissingInput)
Exit For
End If
ElseIf IsNothing(oMyInput) And oIsRequired = False Then
For Each ochangedLookub In listChangedLookup
If lookup.Name = ochangedLookub Then
@@ -7280,13 +7292,18 @@ Public Class frmValidator
Exit For
End If
If Check_Missing_Control_Value(oControl, "txt") = True And oIsRequired = True And pRegularComplete Then
oMissing = True
oErrMsgMissingInput = oWrongInputMessage & " textbox '" & oControl.Name & "'"
MyValidationLogger.Warn(oErrMsgMissingInput)
oControl.BackColor = Color.Red
frmError.ShowDialog()
Exit For
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
oErrMsgMissingInput = oWrongInputMessage & " textbox '" & oControl.Name & "'"
MyValidationLogger.Warn(oErrMsgMissingInput)
oControl.BackColor = Color.Red
frmError.ShowDialog()
Exit For
End If
Else
MyValidationLogger.Debug("Reading current value from Textbox")
Dim oTextEdit As BaseEdit = DirectCast(oControl, BaseEdit)
@@ -7410,16 +7427,21 @@ Public Class frmValidator
Try
MyValidationLogger.Debug($"Working on Combobox...")
Dim cmb As Windows.Forms.ComboBox = oControl
If cmb.SelectedIndex = -1 And oIsRequired = True And pRegularComplete Then
oMissing = True
oErrMsgMissingInput = "Please Choose an entry out of ComboBox '" & cmb.Name & "'"
MyValidationLogger.Warn(oErrMsgMissingInput)
If _FormClosing Then
MyValidationLogger.Warn("Form closing - skip error dialog")
Return False
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
oErrMsgMissingInput = "Please Choose an entry out of ComboBox '" & cmb.Name & "'"
MyValidationLogger.Warn(oErrMsgMissingInput)
If _FormClosing Then
MyValidationLogger.Warn("Form closing - skip error dialog")
Return False
End If
OpenfrmError(oErrMsgMissingInput)
Exit For
End If
OpenfrmError(oErrMsgMissingInput)
Exit For
Else
oMyInput = cmb.Text
MyValidationLogger.Debug($"inputvalue Combobox: {cmb.Text}")
@@ -7545,16 +7567,21 @@ Public Class frmValidator
Case oControl.GetType = GetType(DateTimePicker)
Try
Dim dtp As DateTimePicker = oControl
If oIsRequired = True And dtp.Value.ToString = String.Empty And pRegularComplete Then
oMissing = True
oErrMsgMissingInput = "Please Choose DateValue for field'" & dtp.Name & "'"
MyValidationLogger.Warn(oErrMsgMissingInput)
If _FormClosing Then
MyValidationLogger.Warn("Form closing - skip error dialog")
Return False
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
oErrMsgMissingInput = "Please Choose DateValue for field'" & dtp.Name & "'"
MyValidationLogger.Warn(oErrMsgMissingInput)
If _FormClosing Then
MyValidationLogger.Warn("Form closing - skip error dialog")
Return False
End If
OpenfrmError(oErrMsgMissingInput)
Exit For
End If
OpenfrmError(oErrMsgMissingInput)
Exit For
ElseIf dtp.Value.ToString <> "01.01.0001 00:00:00" Then
oMyInput = CDate(dtp.Value)
Dim oObjectValue
@@ -7641,16 +7668,21 @@ Public Class frmValidator
Dim chk As CheckBox = oControl
oMyInput = chk.Checked.ToString
If chk.CheckState = CheckState.Indeterminate And oIsRequired = True And pRegularComplete Then
oMissing = True
oErrMsgMissingInput = "Please set Checkbox value for field '" & chk.Name & "'"
MyValidationLogger.Warn(oErrMsgMissingInput)
If _FormClosing Then
MyValidationLogger.Warn("Form closing - skip error dialog")
Return False
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
oErrMsgMissingInput = "Please set Checkbox value for field '" & chk.Name & "'"
MyValidationLogger.Warn(oErrMsgMissingInput)
If _FormClosing Then
MyValidationLogger.Warn("Form closing - skip error dialog")
Return False
End If
OpenfrmError(oErrMsgMissingInput)
Exit For
End If
OpenfrmError(oErrMsgMissingInput)
Exit For
End If
Dim WertWD As String
@@ -7759,16 +7791,21 @@ Public Class frmValidator
Zeilen += 1
End If
Next
If oIsRequired = True And Zeilen = 0 And pRegularComplete Then
oMissing = True
oErrMsgMissingInput = "Fehlende Eingabe in Vektorfeld '" & dgv.Name & "'"
MyValidationLogger.Warn(oErrMsgMissingInput)
If _FormClosing Then
MyValidationLogger.Warn("Form closing - skip error dialog")
Return False
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
oErrMsgMissingInput = "Fehlende Eingabe in Vektorfeld '" & dgv.Name & "'"
MyValidationLogger.Warn(oErrMsgMissingInput)
If _FormClosing Then
MyValidationLogger.Warn("Form closing - skip error dialog")
Return False
End If
OpenfrmError(oErrMsgMissingInput)
Exit For
End If
OpenfrmError(oErrMsgMissingInput)
Exit For
ElseIf Zeilen > 0 Then
Dim ZeilenGrid As Integer = 0
Dim myVektorArr As String()