first public version
This commit is contained in:
@@ -1,21 +1,53 @@
|
||||
Public Class frmMain
|
||||
Private _Logger As Logger
|
||||
Private _Database As Database
|
||||
Private _WinLine As Winline
|
||||
|
||||
Private Sub frmMain_Load(sender As Object, e As EventArgs) Handles MyBase.Load
|
||||
My.Application.LogConfig = New LogConfig(LogPath:=LogConfig.PathType.AppData, CompanyName:="Digital Data", ProductName:="WinLineProductNumberGenerator")
|
||||
My.Application.ConfigManager = New ConfigManager(Of Config)(My.Application.LogConfig, Application.UserAppDataPath)
|
||||
Try
|
||||
My.Application.LogConfig = New LogConfig(LogPath:=LogConfig.PathType.AppData, CompanyName:="Digital Data", ProductName:="WinLineProductNumberGenerator")
|
||||
My.Application.ConfigManager = New ConfigManager(Of Config)(My.Application.LogConfig, Application.UserAppDataPath)
|
||||
_Logger = My.Application.LogConfig.GetLogger()
|
||||
Catch ex As Exception
|
||||
MsgBox("Fehler beim Initialisieren (Logging und Config):" & vbNewLine & ex.Message, MsgBoxStyle.Critical, Text)
|
||||
End Try
|
||||
|
||||
_Logger = My.Application.LogConfig.GetLogger()
|
||||
_Database = New Database(My.Application.LogConfig, My.Application.ConfigManager)
|
||||
_WinLine = New Winline(My.Application.LogConfig, _Database)
|
||||
Dim oLogConfig = My.Application.LogConfig
|
||||
Dim oConfigManager = My.Application.ConfigManager
|
||||
Dim oConfig As Config = oConfigManager.Config
|
||||
|
||||
listboxVendors.DataSource = Nothing
|
||||
If oConfig.EXIMConnectionString = String.Empty Then
|
||||
MsgBox("ConnectionString zur EXIM Datenbank ist nicht hinterlegt!", MsgBoxStyle.Critical, Text)
|
||||
Application.Exit()
|
||||
End If
|
||||
|
||||
Dim oVendors = _WinLine.GetVendors()
|
||||
If oConfig.WinlineConnectionString = String.Empty Then
|
||||
MsgBox("ConnectionString zur Winline Datenbank ist nicht hinterlegt!", MsgBoxStyle.Critical, Text)
|
||||
Application.Exit()
|
||||
End If
|
||||
|
||||
listboxVendors.DataSource = oVendors
|
||||
Try
|
||||
My.Application.EXIMDatabase = New Database(
|
||||
oLogConfig,
|
||||
oConfigManager,
|
||||
oConfigManager.Config.EXIMConnectionString)
|
||||
|
||||
My.Application.WinlineDatabase = New Database(
|
||||
oLogConfig,
|
||||
oConfigManager,
|
||||
oConfigManager.Config.WinlineConnectionString)
|
||||
|
||||
My.Application.Winline = New Winline(
|
||||
oLogConfig,
|
||||
My.Application.EXIMDatabase,
|
||||
My.Application.WinlineDatabase,
|
||||
oConfigManager.Config)
|
||||
|
||||
Dim oVendors = My.Application.Winline.GetVendors()
|
||||
listboxVendors.DataSource = oVendors
|
||||
Catch ex As Exception
|
||||
MsgBox("Fehler beim Initialisieren (Datenbank):" & vbNewLine & ex.Message, MsgBoxStyle.Critical, Text)
|
||||
_Logger.Error(ex)
|
||||
End Try
|
||||
End Sub
|
||||
|
||||
Private Sub frmMain_FormClosed(sender As Object, e As FormClosedEventArgs) Handles Me.FormClosed
|
||||
@@ -25,7 +57,7 @@
|
||||
Private Sub listboxVendors_SelectedIndexChanged(sender As Object, e As EventArgs) Handles listboxVendors.SelectedIndexChanged
|
||||
If listboxVendors.SelectedItem IsNot Nothing Then
|
||||
Dim oVendor As Vendor = listboxVendors.SelectedItem
|
||||
Dim oGroups As List(Of ProductGroup) = _WinLine.GetGroupsByVendor(oVendor.Code)
|
||||
Dim oGroups As List(Of ProductGroup) = My.Application.Winline.GetGroupsByVendor(oVendor.Code)
|
||||
|
||||
listboxProductGroups.DataSource = oGroups
|
||||
End If
|
||||
@@ -35,7 +67,7 @@
|
||||
Private Sub listboxProductGroups_SelectedIndexChanged(sender As Object, e As EventArgs) Handles listboxProductGroups.SelectedIndexChanged
|
||||
If listboxProductGroups.SelectedItem IsNot Nothing Then
|
||||
Dim oGroup As ProductGroup = listboxProductGroups.SelectedItem
|
||||
Dim oVersions As List(Of ProductVersion) = _WinLine.GetVersionsByVendorAndGroup(oGroup.Code, oGroup.GroupId)
|
||||
Dim oVersions As List(Of ProductVersion) = My.Application.Winline.GetVersionsByVendorAndGroup(oGroup.Code, oGroup.GroupId)
|
||||
|
||||
listBoxProductVersion.DataSource = oVersions
|
||||
End If
|
||||
@@ -62,24 +94,72 @@
|
||||
End If
|
||||
|
||||
Dim oArticleNumber = $"{oVendor.Code}{oGroup.GroupString}{oVersion.VersionString}"
|
||||
Dim oRunningNumber As String
|
||||
|
||||
Try
|
||||
Dim oRunningNumber = _WinLine.GetNextRunningNumber(oVendor.Code, oGroup.GroupId, oVersion.VersionId)
|
||||
MsgBox($"{oArticleNumber}{oRunningNumber}")
|
||||
Catch ex As Exception
|
||||
Select Case ex.Message
|
||||
Case _WinLine.NO_RUNNING_NUMBER_FOUND
|
||||
Dim oMessage = $"Für die Artikelnummer [{oArticleNumber}___] wurde im WinLine-System keine Laufende Nummer hinterlegt."
|
||||
oMessage &= "Diese Nummer ist für die Automatische Artikelnummer-Generierung zwingend notwendig"
|
||||
oRunningNumber = My.Application.Winline.GetNextRunningNumber(oVendor.Code, oGroup.GroupId, oVersion.VersionId)
|
||||
|
||||
MsgBox(oMessage, MsgBoxStyle.Critical, Text)
|
||||
If My.Application.Winline.TestArticleExists($"{oArticleNumber}{oRunningNumber}") Then
|
||||
Throw New ApplicationException(My.Application.Winline.ARTICLE_ALREADY_EXISTS)
|
||||
End If
|
||||
|
||||
Dim oForm As New frmCreateArticle() With {
|
||||
.ArticleNumber = oArticleNumber,
|
||||
.RunningNumber = oRunningNumber,
|
||||
.Vendor = oVendor,
|
||||
.Version = oVersion,
|
||||
.Group = oGroup
|
||||
}
|
||||
|
||||
oForm.ShowDialog()
|
||||
Catch ex As Exception
|
||||
Dim oMessage As String = ""
|
||||
|
||||
Select Case ex.Message
|
||||
Case My.Application.Winline.NO_RUNNING_NUMBER_FOUND
|
||||
oMessage = ""
|
||||
oMessage &= $"Für die Artikelnummer [{oArticleNumber}] wurde im WinLine-System keine Laufende Nummer hinterlegt."
|
||||
oMessage &= "Diese Nummer ist für die Automatische Artikelnummer-Generierung zwingend notwendig"
|
||||
Case My.Application.Winline.ARTICLE_ALREADY_EXISTS
|
||||
oMessage = ""
|
||||
oMessage &= $"Der Artikel [{oArticleNumber}{oRunningNumber}] existiert bereits und wird deshalb nicht angelegt." & vbNewLine
|
||||
oMessage &= $"Prüfen Sie, ob die Laufenden Nummern für diese Artikelversion hinterlegt korrekt hinterlegt."
|
||||
Case Else
|
||||
MsgBox("Folgender Fehler ist aufgetreten:" & vbNewLine & vbNewLine & ex.Message, MsgBoxStyle.Critical, Text)
|
||||
oMessage = ""
|
||||
oMessage &= "Folgender Fehler ist aufgetreten:" & vbNewLine & vbNewLine & ex.Message
|
||||
End Select
|
||||
|
||||
MsgBox(oMessage, MsgBoxStyle.Critical, Text)
|
||||
End Try
|
||||
End Sub
|
||||
|
||||
Private Sub EinstellungenToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles EinstellungenToolStripMenuItem.Click
|
||||
frmWinlineConfig.ShowDialog()
|
||||
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
|
||||
Dim oResult As DialogResult = frmNewVendor.ShowDialog()
|
||||
|
||||
If oResult = DialogResult.OK Then
|
||||
Dim oVendors = My.Application.Winline.GetVendors()
|
||||
listboxVendors.DataSource = oVendors
|
||||
End If
|
||||
End Sub
|
||||
|
||||
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
|
||||
Dim oForm As New frmNewGroup() With {
|
||||
.Vendor = listboxVendors.SelectedItem
|
||||
}
|
||||
|
||||
If oForm.ShowDialog = DialogResult.OK Then
|
||||
'reload groups?
|
||||
End If
|
||||
End Sub
|
||||
|
||||
Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
|
||||
Dim oForm As New frmNewProduct() With {
|
||||
.Vendor = listboxVendors.SelectedItem,
|
||||
.Group = listboxProductGroups.SelectedItem
|
||||
}
|
||||
|
||||
If oForm.ShowDialog = DialogResult.OK Then
|
||||
'reload products?
|
||||
End If
|
||||
End Sub
|
||||
End Class
|
||||
Reference in New Issue
Block a user