Verbesserung der Label-Erstellung und Fehlerbehandlung

Die Erstellung neuer Labels in `frmFormDesigner.vb` wurde überarbeitet:
- Verwendung eines SQL-Insert-Statements anstelle der Methode `cmdInsertAnlage`.
- Hinzufügen einer Fehlerbehandlung mit Log-Nachricht und `MsgBox` bei fehlgeschlagenem Insert.
- Aktivierung der Label-Eigenschaften nur bei erfolgreichem Insert.
- Erweiterung der allgemeinen Fehlerbehandlung mit einer Benutzerbenachrichtigung.

In `frmValidator.vb` wurden folgende Änderungen vorgenommen:
- Zurücksetzen des Textes eines `ComboBox`-Steuerelements auf einen leeren String.
- Korrektur der Berechnung der verbleibenden Vorgänge (`Amount_Docs2Validate`), um den Zähler korrekt anzuzeigen.
This commit is contained in:
Developer01
2026-08-10 14:24:19 +02:00
parent 5b71a9b9c2
commit 46d2a9109b
2 changed files with 19 additions and 11 deletions

View File

@@ -1163,15 +1163,22 @@ Public Class frmFormDesigner
Dim label = ControlCreator.CreateNewLabel(cursorPosition)
SetMovementHandlers(label)
TBPM_PROFILE_CONTROLSTableAdapter.cmdInsertAnlage(ProfileId, label.Name, "LBL", label.Text, label.Location.X, label.Location.Y, USER_USERNAME, label.Size.Height, label.Size.Width, label.TextAlign)
CHANGES_FORM_DESIGN = True
CurrentControl = label
CurrentControl.Tag = New ClassControlCreator.ControlMetadata() With {
.Guid = GetLastID(),
.ReadOnly = False
}
pnldesigner.Controls.Add(label)
Dim oInsert = $"INSERT INTO TBPM_PROFILE_CONTROLS
(PROFIL_ID, NAME, CTRL_TYPE, CTRL_TEXT, X_LOC, Y_LOC, ADDED_WHO, HEIGHT, WIDTH, TEXT_ALIGNMENT, DISPLAY_IN_SEPERATE_FORM)
VALUES ({ProfileId},'{label.Name}','LBL','{label.Text}','{label.Location.X}','{label.Location.Y}','{USER_USERNAME}',{label.Size.Height},{label.Size.Width},'{label.TextAlign}','')"
If DatabaseFallback.ExecuteNonQueryECM(oInsert) Then
'TBPM_PROFILE_CONTROLSTableAdapter.cmdInsertAnlage(ProfileId, label.Name, "LBL", label.Text, label.Location.X, label.Location.Y, USER_USERNAME, label.Size.Height, label.Size.Width, label.TextAlign, "")
CHANGES_FORM_DESIGN = True
CurrentControl = label
CurrentControl.Tag = New ClassControlCreator.ControlMetadata() With {
.Guid = GetLastID(),
.ReadOnly = False
}
pnldesigner.Controls.Add(label)
Else
_Logger.Info($"Error while inserting new Label Control into TBPM_PROFILE_CONTROLS: {oInsert}")
MsgBox("Fehler beim Erstellen des Labels. Bitte überprüfen Sie die Log-Datei für weitere Informationen.", MsgBoxStyle.Critical, "Fehler beim Erstellen des Labels")
End If
Case ClassControlCreator.PREFIX_TEXTBOX
Dim txt = ControlCreator.CreateNewTextBox(cursorPosition)
@@ -1304,9 +1311,9 @@ Public Class frmFormDesigner
RibPGCtrlWidth.Enabled = True
End If
Catch ex As Exception
_Logger.Error(ex)
_Logger.Info($"Error while Adding new control {NewControlSelected}:")
_Logger.Info(ex)
MsgBox($"Error while Adding new control {NewControlSelected}: {ex.Message}" & vbCrLf & "Check the log for further info", MsgBoxStyle.Critical)
End Try
Me.Cursor = Cursors.Default
NewControlSelected = ""

View File

@@ -1775,6 +1775,7 @@ Public Class frmValidator
Case Type = GetType(Windows.Forms.ComboBox)
Dim cmb As Windows.Forms.ComboBox = inctrl
cmb.SelectedIndex = -1
cmb.Text = String.Empty
Case Type = GetType(DataGridView)
Dim dgv As DataGridView = inctrl
If dgv.Rows.Count > 0 Then
@@ -4148,7 +4149,7 @@ Public Class frmValidator
End If
If Amount_Docs2Validate > 1 Then
Dim omsg = String.Format(Translation_Strings.Verbleibende_Vorgänge___0_, Amount_Docs2Validate)
Dim omsg = String.Format(Translation_Strings.Verbleibende_Vorgänge___0_, Amount_Docs2Validate - 1)
bsiInformation.Caption = omsg
bsiInformation.Caption = omsg
If RbnPgGrpActions.Visible = False Then