From bca0002134be49fcdc1919fd46aaeb42d78a6e1a Mon Sep 17 00:00:00 2001 From: Developer01 Date: Mon, 10 Aug 2026 14:47:26 +0200 Subject: [PATCH] Validierungslogik verbessert und Fehleranzeige zentralisiert MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Die Methode `Check_UpdateIndexe` wurde um einen optionalen Parameter `pRegularComplete` erweitert, um die Validierungslogik flexibler zu gestalten. Bedingungsprüfungen wurden angepasst, um die Validierung nur bei Bedarf durchzuführen. Fehlermeldungen für fehlende Eingaben wurden klarer formuliert. Die Methode `frmError.ShowDialog()` wurde durch `OpenfrmError(oErrMsgMissingInput)` ersetzt, um die Fehleranzeige zu zentralisieren. Der Aufruf von `Check_UpdateIndexe()` wurde angepasst, um in bestimmten Kontexten die Validierung zu deaktivieren. --- app/TaskFlow/frmValidator.vb | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/app/TaskFlow/frmValidator.vb b/app/TaskFlow/frmValidator.vb index 0433623..1b6beba 100644 --- a/app/TaskFlow/frmValidator.vb +++ b/app/TaskFlow/frmValidator.vb @@ -6994,7 +6994,7 @@ Public Class frmValidator Next Return odt End Function - Function Check_UpdateIndexe() As Boolean + Function Check_UpdateIndexe(Optional ByVal pRegularComplete As Boolean = True) As Boolean Dim oControlName Dim oControlId As String Try @@ -7084,12 +7084,12 @@ Public Class frmValidator Case oControl.GetType = GetType(LookupControl3) Try Dim lookup As LookupControl3 = oControl - If lookup.Properties.SelectedValues.Count = 0 And oIsRequired = True Then + If lookup.Properties.SelectedValues.Count = 0 And oIsRequired = True And pRegularComplete Then oMissing = True - oErrMsgMissingInput = $"Kein Auswahl getroffen in LookupGrid '{oControl.Name}'" - MyValidationLogger.Warn($"⚠️ Kein Auswahl getroffen in LookupGrid '{oControl.Name}'") + oErrMsgMissingInput = $"Pflichtfeld: Keine Auswahl getroffen in LookupGrid '{oControl.Name}'" + MyValidationLogger.Warn($"⚠️ {oErrMsgMissingInput}") oControl.BackColor = Color.Red - frmError.ShowDialog() + OpenfrmError(oErrMsgMissingInput) Exit For Else If lookup.Properties.MultiSelect = True Then @@ -7144,10 +7144,11 @@ Public Class frmValidator Else ' Single-Select Lookup oMyInput = lookup.Properties.SelectedValues.FirstOrDefault() - If IsNothing(oMyInput) And oIsRequired = True Then + 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 ElseIf IsNothing(oMyInput) And oIsRequired = False Then For Each ochangedLookub In listChangedLookup @@ -7279,7 +7280,7 @@ Public Class frmValidator Exit For End If - If Check_Missing_Control_Value(oControl, "txt") = True And oIsRequired = True Then + If Check_Missing_Control_Value(oControl, "txt") = True And oIsRequired = True And pRegularComplete Then oMissing = True oErrMsgMissingInput = oWrongInputMessage & " textbox '" & oControl.Name & "'" MyValidationLogger.Warn(oErrMsgMissingInput) @@ -7409,7 +7410,7 @@ Public Class frmValidator Try MyValidationLogger.Debug($"Working on Combobox...") Dim cmb As Windows.Forms.ComboBox = oControl - If cmb.SelectedIndex = -1 And oIsRequired = True Then + 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) @@ -7544,7 +7545,7 @@ Public Class frmValidator Case oControl.GetType = GetType(DateTimePicker) Try Dim dtp As DateTimePicker = oControl - If oIsRequired = True And dtp.Value.ToString = String.Empty Then + 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) @@ -7640,7 +7641,7 @@ Public Class frmValidator Dim chk As CheckBox = oControl oMyInput = chk.Checked.ToString - If chk.CheckState = CheckState.Indeterminate And oIsRequired = True Then + 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) @@ -7758,7 +7759,7 @@ Public Class frmValidator Zeilen += 1 End If Next - If oIsRequired = True And Zeilen = 0 Then + If oIsRequired = True And Zeilen = 0 And pRegularComplete Then oMissing = True oErrMsgMissingInput = "Fehlende Eingabe in Vektorfeld '" & dgv.Name & "'" MyValidationLogger.Warn(oErrMsgMissingInput) @@ -8701,7 +8702,7 @@ Public Class frmValidator ShowOverlaySafe() ' ✅ Overlay hier öffnen Try ' ========== FIX 2: Nur EINEN Check-Aufruf ========== - If Check_UpdateIndexe() = True Then + If Check_UpdateIndexe(False) = True Then SetStatusLabel("Data saved", "LimeGreen") MyValidationLogger.Info("Workflowdata saved manually!")