Public Class frmNewProduct Public Property Vendor As Vendor Public Property Group As ProductGroup Private _Logger As Logger Private Sub frmNewProduct_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([VERSION]), 0) FROM [TBDD_ARTICLE_GENERATOR_PRODUCTS] WHERE VENDOR_ID = {Vendor.Guid} AND GROUP_ID = {Group.GroupId}" Dim oNumber = My.Application.EXIMDatabase.GetScalarValue(oSQL) + 1 Dim oGroupCode As String = $"{Vendor.Code}{oNumber}" txtVendor.Text = Vendor.Name txtGroup.Text = Group.Name txtVersion.Text = oNumber 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 = Integer.Parse(txtVersion.Text) Dim oSQL = $"INSERT INTO TBDD_ARTICLE_GENERATOR_PRODUCTS ([VERSION], NAME, VENDOR_ID, CODE, GROUP_ID) VALUES ({oNumber}, '{oName}', {Vendor.Guid}, '{Vendor.Code}', {Group.GroupId})" Dim oResult = My.Application.EXIMDatabase.ExecuteNonQuery(oSQL) If oResult = True Then MsgBox("Version erstellt!", MsgBoxStyle.Information, Text) DialogResult = DialogResult.OK Close() Else MsgBox("Fehler beim Erstellen der Version. Mehr Informationen im Log.", MsgBoxStyle.Critical, Text) End If Catch ex As Exception MsgBox("Fehler beim Erstellen der Version: " & ex.Message, MsgBoxStyle.Critical, Text) End Try End If End Sub End Class