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
oMissing = True If pRegularComplete = False Then
oErrMsgMissingInput = $"Pflichtfeld: Keine Auswahl getroffen in LookupGrid '{oControl.Name}'" MyValidationLogger.Debug($"[CHECK_UPDATE] LookupGrid '{oControl.Name}' is required but has no selection. Skipping due to pRegularComplete=False.")
MyValidationLogger.Warn($"⚠️ {oErrMsgMissingInput}") Continue For
oControl.BackColor = Color.Red Else
OpenfrmError(oErrMsgMissingInput) oMissing = True
Exit For oErrMsgMissingInput = $"Pflichtfeld: Keine Auswahl getroffen in LookupGrid '{oControl.Name}'"
MyValidationLogger.Warn($"⚠️ {oErrMsgMissingInput}")
oControl.BackColor = Color.Red
OpenfrmError(oErrMsgMissingInput)
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
oMissing = True If pRegularComplete = False Then
oErrMsgMissingInput = $"Could not get FirstOrDefault-Value of LookUpGrid! - LookUPGridName: {lookup.Name}" MyValidationLogger.Debug($"[CHECK_UPDATE] LookupGrid(SingleSelect) '{lookup.Name}' is required but has no selection. Skipping due to pRegularComplete=False.")
MyValidationLogger.Warn(oErrMsgMissingInput) Continue For
OpenfrmError(oErrMsgMissingInput) Else
Exit For 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 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
oMissing = True If pRegularComplete = False Then
oErrMsgMissingInput = oWrongInputMessage & " textbox '" & oControl.Name & "'" MyValidationLogger.Debug($"[CHECK_UPDATE] TextEdit '{oControl.Name}' is required but has no selection. Skipping due to pRegularComplete=False.")
MyValidationLogger.Warn(oErrMsgMissingInput) Continue For
oControl.BackColor = Color.Red Else
frmError.ShowDialog() oMissing = True
Exit For oErrMsgMissingInput = oWrongInputMessage & " textbox '" & oControl.Name & "'"
MyValidationLogger.Warn(oErrMsgMissingInput)
oControl.BackColor = Color.Red
frmError.ShowDialog()
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,16 +7427,21 @@ 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
oMissing = True If pRegularComplete = False Then
oErrMsgMissingInput = "Please Choose an entry out of ComboBox '" & cmb.Name & "'" MyValidationLogger.Debug($"[CHECK_UPDATE] ComboBox '{cmb.Name}' is required but has no selection. Skipping due to pRegularComplete=False.")
MyValidationLogger.Warn(oErrMsgMissingInput) Continue For
If _FormClosing Then Else
MyValidationLogger.Warn("Form closing - skip error dialog") oMissing = True
Return False 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 End If
OpenfrmError(oErrMsgMissingInput)
Exit For
Else Else
oMyInput = cmb.Text oMyInput = cmb.Text
MyValidationLogger.Debug($"inputvalue Combobox: {cmb.Text}") MyValidationLogger.Debug($"inputvalue Combobox: {cmb.Text}")
@@ -7545,16 +7567,21 @@ 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
oMissing = True If pRegularComplete = False Then
oErrMsgMissingInput = "Please Choose DateValue for field'" & dtp.Name & "'" MyValidationLogger.Debug($"[CHECK_UPDATE] DateTimePicker '{dtp.Name}' is required but has no selection. Skipping due to pRegularComplete=False.")
MyValidationLogger.Warn(oErrMsgMissingInput) Continue For
If _FormClosing Then Else
MyValidationLogger.Warn("Form closing - skip error dialog") oMissing = True
Return False 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 End If
OpenfrmError(oErrMsgMissingInput)
Exit For
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,16 +7668,21 @@ 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
oMissing = True If pRegularComplete = False Then
oErrMsgMissingInput = "Please set Checkbox value for field '" & chk.Name & "'" MyValidationLogger.Debug($"[CHECK_UPDATE] CheckBox '{chk.Name}' is required but has no selection. Skipping due to pRegularComplete=False.")
MyValidationLogger.Warn(oErrMsgMissingInput) Continue For
If _FormClosing Then Else
MyValidationLogger.Warn("Form closing - skip error dialog") oMissing = True
Return False 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 End If
OpenfrmError(oErrMsgMissingInput)
Exit For
End If End If
Dim WertWD As String Dim WertWD As String
@@ -7759,16 +7791,21 @@ 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
oMissing = True If pRegularComplete = False Then
oErrMsgMissingInput = "Fehlende Eingabe in Vektorfeld '" & dgv.Name & "'" MyValidationLogger.Debug($"[CHECK_UPDATE] DataGridView '{dgv.Name}' is required but has no selection. Skipping due to pRegularComplete=False.")
MyValidationLogger.Warn(oErrMsgMissingInput) Continue For
If _FormClosing Then Else
MyValidationLogger.Warn("Form closing - skip error dialog") oMissing = True
Return False 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 End If
OpenfrmError(oErrMsgMissingInput)
Exit For
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()