2020-09-22 10:50:20 +02:00

56 lines
2.2 KiB
VB.net

Public Class frmNewVendor
Public Property Vendor As Vendor
Private Sub frmNewVendor_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Try
Dim oVendors As List(Of Vendor) = My.Application.Winline.GetVendorsFromWinLine()
cmbWinlineVendor.DataSource = oVendors
cmbWinlineVendor.DisplayMember = "WinlineName"
cmbWinlineVendor.ValueMember = "WinlineNumber"
Catch ex As Exception
MsgBox("Fehler beim Laden der Lieferanten: " & ex.Message, MsgBoxStyle.Critical, Text)
End Try
End Sub
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Try
Dim oName As String = txtName.Text
Dim oCode As String = txtCode.Text
Dim oVendor As Vendor = cmbWinlineVendor.SelectedItem
If oName.Length = 0 Then
MsgBox("Bitte tragen Sie einen Namen ein!", MsgBoxStyle.Critical, Text)
txtName.Focus()
Exit Sub
End If
If oCode.Length = 0 Then
MsgBox("Bitte tragen Sie einen Code ein!", MsgBoxStyle.Critical, Text)
txtCode.Focus()
Exit Sub
End If
If IsNothing(oVendor) Then
MsgBox("Bitte wählen Sie einen Lieferanten aus!", MsgBoxStyle.Critical, Text)
End If
Dim oSQL As String = "INSERT INTO TBDD_ARTICLE_GENERATOR_VENDORS " &
"(CODE, NAME, WINLINE_NAME, WINLINE_NUMBER) " &
$"VALUES ('{oCode}', '{oName}', '{oVendor.WinlineName}', '{oVendor.WinlineNumber}')"
Dim oResult = My.Application.EXIMDatabase.ExecuteNonQuery(oSQL)
If oResult = True Then
MsgBox("Lieferant erstellt!", MsgBoxStyle.Information, Text)
DialogResult = DialogResult.OK
Close()
Else
MsgBox("Fehler beim Erstellen des Lieferanten. Mehr Informationen im Log.", MsgBoxStyle.Critical, Text)
End If
Catch ex As Exception
MsgBox("Fehler beim Erstellen des Lieferanten: " & ex.Message, MsgBoxStyle.Critical, Text)
End Try
End Sub
End Class