This commit is contained in:
Jonathan Jenne
2020-09-11 15:56:50 +02:00
parent 614b415a98
commit c9bd8da4a6
8 changed files with 228 additions and 82 deletions

View File

@@ -3,21 +3,24 @@
Private _LogConfig As LogConfig
Private _Config As ConfigManager(Of Config)
Private _Database As Database
Private _WinLine As Winline
Private CurrentVendor As Vendor = Nothing
Private CurrentGroup As ProductGroup = Nothing
Private CurrentVersion As ProductVersion = Nothing
Private Sub frmMain_Load(sender As Object, e As EventArgs) Handles MyBase.Load
_LogConfig = New LogConfig(LogPath:=LogConfig.PathType.AppData, CompanyName:="Digital Data", ProductName:="WinLineProductNumberGenerator")
_Logger = _LogConfig.GetLogger()
_Config = New ConfigManager(Of Config)(_LogConfig, Application.UserAppDataPath)
_Database = New Database(_LogConfig, _Config)
_WinLine = New Winline(_LogConfig, _Database)
listboxVendors.DataSource = Nothing
Dim oVendorDT = _Database.LoadVendors()
Dim oVendors = New List(Of Vendor)
Dim oVendors = _WinLine.GetVendors()
listboxVendors.DataSource = oVendorDT
listboxVendors.DisplayMember = "c003"
listboxVendors.ValueMember = "c229"
listboxVendors.DataSource = oVendors
End Sub
Private Sub frmMain_FormClosed(sender As Object, e As FormClosedEventArgs) Handles Me.FormClosed
@@ -25,36 +28,66 @@
End Sub
Private Sub listboxVendors_SelectedIndexChanged(sender As Object, e As EventArgs) Handles listboxVendors.SelectedIndexChanged
If listboxVendors.SelectedIndex >= 0 Then
Dim oVendor As DataRowView = listboxVendors.SelectedItem()
Dim oVendorCode = oVendor.Item("C229")
Dim oVendorId = _Database.LoadVendorIdByCode(oVendorCode)
If listboxVendors.SelectedItem IsNot Nothing Then
Dim oVendor As Vendor = listboxVendors.SelectedItem
CurrentVendor = oVendor
listboxProductGroups.DataSource = Nothing
If oVendorId Is Nothing Then
_Logger.Warn("VendorId does not match any 'Artikeluntergruppen'.")
Exit Sub
End If
Dim oGroups = _Database.LoadGroupsByVendor(oVendorId)
Dim oGroups As List(Of ProductGroup) = _WinLine.GetGroupsByVendor(oVendor.Code)
listboxProductGroups.DataSource = oGroups
listboxProductGroups.DisplayMember = "C001"
listboxProductGroups.ValueMember = "C999"
End If
End Sub
Private Sub listboxProductGroups_SelectedIndexChanged(sender As Object, e As EventArgs) Handles listboxProductGroups.SelectedIndexChanged
If listboxProductGroups.SelectedIndex >= 0 Then
Dim oVendor As DataRowView = listboxVendors.SelectedItem()
Dim oGroup As DataRowView = listboxProductGroups.SelectedItem()
If listboxProductGroups.SelectedItem IsNot Nothing Then
Dim oGroup As ProductGroup = listboxProductGroups.SelectedItem
CurrentGroup = oGroup
Dim oVendorCode = oVendor.Item("C229")
Dim oVendorId = _Database.LoadVendorIdByCode(oVendorCode)
Dim oGroupId = oGroup.Item("C999")
Dim oVersions As List(Of ProductVersion) = _WinLine.GetVersionsByVendorAndGroup(oGroup.Vendor, oGroup.Id)
Dim Versions = _Database.LoadVersionsByVendorAndGroup(oVendorId, oGroupId)
listBoxProductVersion.DataSource = oVersions
End If
End Sub
Private Sub Button4_Click(sender As Object, e As EventArgs) Handles Button4.Click
'Dim oVendor As DataRowView = listboxVendors.SelectedItem()
'Dim oGroup As DataRowView = listboxProductGroups.SelectedItem()
'Dim oVersion As DataRowView = listBoxProductVersion.SelectedItem()
'If oVendor Is Nothing Then
' MsgBox("Bitte einen Lieferanten auswählen!", MsgBoxStyle.Information, Text)
' Exit Sub
'End If
'If oGroup Is Nothing Then
' MsgBox("Bitte eine Produkt-Gruppe auswählen!", MsgBoxStyle.Information, Text)
' Exit Sub
'End If
'If oVersion Is Nothing Then
' MsgBox("Bitte eine Produkt-Version auswählen!", MsgBoxStyle.Information, Text)
' Exit Sub
'End If
'Dim oVendorId = CurrentVendor.Id
'Dim oGroupId = CurrentGroup.Id
'Dim oVersionId = CurrentVersion.Id
'Dim oRunningNumber = _WinLine.GetNextRunningNumber(oVendorId, oGroupId, oVersionId)
'MsgBox($"{oVendorId}-{oGroupId}-{oVersionId}-00000-00000")
End Sub
Private Sub listBoxProductVersion_SelectedIndexChanged(sender As Object, e As EventArgs) Handles listBoxProductVersion.SelectedIndexChanged
'If listBoxProductVersion.SelectedIndex >= 0 Then
' Dim oVersion As DataRowView = listBoxProductVersion.SelectedItem()
' Dim oVersionId As String = oVersion.Item("C999")
' Dim oVersionName As String = oVersion.Item("C001")
' CurrentVersion = New ProductVersion With {
' .Id = oVersionId,
' .Name = oVersionName
' }
'End If
End Sub
End Class