Public Class frmCreateArticle Public Property Vendor As Vendor Public Property Group As ProductGroup Public Property Version As ProductVersion Public Property ArticleNumber As String Public Property RunningNumber As String Private ReadOnly Config As Config = My.Application.ConfigManager.Config Private ReadOnly Logger As Logger = My.Application.LogConfig.GetLogger Private Const TEMPLATE_NUMBER_NORMAL_ARTICLE = 45 Private Const TEMPLATE_NUMBER_SERIAL_ARTICLE = 46 Private Const CUSTOM_WINDOW_ID = 529 Private Sub frmCreateArticle_Load(sender As Object, e As EventArgs) Handles MyBase.Load txtRunningNumber.Text = RunningNumber txtArticleNumber.Text = ArticleNumber lblImportantInformation.Text = String.Join(vbNewLine, Config.ImportantNotes) End Sub Private Function StartArticleCreation(IsSerialNumberArticle As Boolean) As String Try If My.Application.Winline.TestArticleExists($"{ArticleNumber}{RunningNumber}") Then MsgBox($"Der Artikel '{ArticleNumber}{RunningNumber}' kann nicht angelegt werden, da er bereits existiert") Return Nothing End If txtFinalArticleNumber.Text = String.Empty Logger.Info("Creating Article..") Dim oArticleResult = My.Application.Winline.CreateArticle(ArticleNumber, RunningNumber, txtArticleDescription.Text, Vendor, IsSerialNumberArticle) Logger.Info("Creating Price Info..") Dim oPriceResult = My.Application.Winline.CreatePriceInfo(ArticleNumber, RunningNumber, Vendor.WinlineNumber) If oArticleResult And oPriceResult Then MsgBox("Artikel erfolgreich angelegt!", MsgBoxStyle.Information, Text) txtFinalArticleNumber.Text = $"{ArticleNumber}{RunningNumber}" Return $"{ArticleNumber}{RunningNumber}" Else MsgBox("Artikel konnte nicht angelegt werden!", MsgBoxStyle.Critical, Text) Return Nothing End If Catch ex As Exception MsgBox("Fehler bei Artikelanlage: " & vbNewLine & ex.Message, MsgBoxStyle.Critical, Text) Return Nothing End Try End Function Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click Dim oResult = MsgBox("Wollen Sie einen Seriennummer-Artikel anlegen?" & vbNewLine & vbNewLine & "Diese Einstellung kann, anders als beim Altsystem, NICHT mehr im Nachhinein geändert werden!", MsgBoxStyle.Question Or vbYesNo, Text) If oResult = MsgBoxResult.Yes Then Dim oArticle = StartArticleCreation(True) If oArticle IsNot Nothing Then My.Computer.Clipboard.SetText(oArticle) My.Application.Winline.RunWinlineMacro(My.Application.ConfigManager.Config.CompletionMacro, oArticle, CUSTOM_WINDOW_ID, TEMPLATE_NUMBER_SERIAL_ARTICLE) End If End If End Sub Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click Dim oArticle = StartArticleCreation(False) If oArticle IsNot Nothing Then My.Computer.Clipboard.SetText(oArticle) My.Application.Winline.RunWinlineMacro(My.Application.ConfigManager.Config.CompletionMacro, oArticle, CUSTOM_WINDOW_ID, TEMPLATE_NUMBER_NORMAL_ARTICLE) End If End Sub End Class