Public Class frmNewGroup Private _Logger As Logger Public Property Vendor As Vendor Private Sub frmNewGroup_Load(sender As Object, e As EventArgs) Handles MyBase.Load Try _Logger = My.Application.LogConfig.GetLogger() If Not IsNothing(Vendor) Then Dim oSQL As String = $"SELECT ISNULL(MAX([GROUP]), 0) FROM TBDD_ARTICLE_GENERATOR_GROUPS WHERE VENDOR_ID = {Vendor.Guid}" Dim oNumber = My.Application.EXIMDatabase.GetScalarValue(oSQL) + 1 Dim oGroupCode As String = $"{Vendor.Code}{oNumber}" txtNumber.Text = oNumber txtVendor.Text = Vendor.Name End If Catch ex As Exception _Logger.Error(ex) End Try End Sub Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click Dim oName As String = Trim(txtName.Text) If oName = String.Empty Then MsgBox("Bitte füllen Sie das Feld 'Name' aus!", MsgBoxStyle.Exclamation, Text) Exit Sub End If If Not IsNothing(Vendor) Then Try Dim oNumber As Integer = Integer.Parse(txtNumber.Text) Dim oGroupCode As String = $"{Vendor.Code}{oNumber.ToString.PadLeft(2)}" Dim oSQL = $"INSERT INTO TBDD_ARTICLE_GENERATOR_GROUPS ([GROUP], CODE, GROUP_CODE, NAME, VENDOR_ID) VALUES ({oNumber}, '{Vendor.Code}', '{oGroupCode}', '{oName}', {Vendor.Guid})" Dim oResult = My.Application.EXIMDatabase.ExecuteNonQuery(oSQL) If oResult = True Then MsgBox("Gruppe erstellt!", MsgBoxStyle.Information, Text) DialogResult = DialogResult.OK Close() Else MsgBox("Fehler beim Erstellen der Gruppe. Mehr Informationen im Log.", MsgBoxStyle.Critical, Text) End If Catch ex As Exception MsgBox("Fehler beim Erstellen der Gruppe: " & ex.Message, MsgBoxStyle.Critical, Text) End Try End If End Sub End Class