diff --git a/WinLineArtikelnummerGenerator/ApplicationEvents.vb b/WinLineArtikelnummerGenerator/ApplicationEvents.vb index c69c9d9..bd0d434 100644 --- a/WinLineArtikelnummerGenerator/ApplicationEvents.vb +++ b/WinLineArtikelnummerGenerator/ApplicationEvents.vb @@ -8,5 +8,8 @@ Partial Friend Class MyApplication Public ConfigManager As ConfigManager(Of Config) Public LogConfig As LogConfig + Public Winline As Winline + Public EXIMDatabase As Database + Public WinlineDatabase As Database End Class End Namespace diff --git a/WinLineArtikelnummerGenerator/Config.vb b/WinLineArtikelnummerGenerator/Config.vb index 44c96fc..f9aa160 100644 --- a/WinLineArtikelnummerGenerator/Config.vb +++ b/WinLineArtikelnummerGenerator/Config.vb @@ -1,26 +1,28 @@ -Imports DigitalData.Modules.Config.ConfigAttributes - -Public Class Config - Public Property ConnectionString As String = "" - - Public Property WinLine_WebService As New WebServiceConfig - - Public Enum ActionCode - CHECK_ONLY = 0 - IMPORT = 1 - End Enum +Public Class Config + Public Property WinlineConnectionString As String = "" + Public Property EXIMConnectionString As String = "" + Public Property CompletionMacro As String = "" + Public Property ImportantNotes As List(Of String) = New List(Of String) + Public Property WebService As New WebServiceConfig Public Class WebServiceConfig Public Property Server As String = "" Public Property Username As String = "" Public Property Password As String = "" Public Property Mandator As String = "" - Public Property ActionCode As ActionCode = ActionCode.IMPORT - Public Property ArticleTemplateName As String = "" - Public Property ArticleTemplateType As Integer = 30 + Public Property ActionCode As Integer = 1 + Public Property TaxCode As Integer = 3 - Public Property PriceTemplateName As String = "" + Public Property ShapeFrom As String = "A" + Public Property ShapeTo As String = "C" + + Public Property ArticleTemplateName As String = "EXIM-Artikelnummergenerator" + Public Property ArticleTemplateType As Integer = 4 + + Public Property PriceTemplateName As String = "EXIM-Artikelnummergenerator" Public Property PriceTemplateType As Integer = 5 End Class + + End Class diff --git a/WinLineArtikelnummerGenerator/Database.vb b/WinLineArtikelnummerGenerator/Models/Database.vb similarity index 77% rename from WinLineArtikelnummerGenerator/Database.vb rename to WinLineArtikelnummerGenerator/Models/Database.vb index aac68a4..c05f517 100644 --- a/WinLineArtikelnummerGenerator/Database.vb +++ b/WinLineArtikelnummerGenerator/Models/Database.vb @@ -5,17 +5,20 @@ Public Class Database Private _LogConfig As LogConfig Private _Logger As Logger + Private _ConnectionString As String = "" + Private Const QUERY_TIMEOUT = 120000 - Public Sub New(LogConfig As LogConfig, ConfigManager As ConfigManager(Of Config)) + Public Sub New(LogConfig As LogConfig, ConfigManager As ConfigManager(Of Config), ConnectionString As String) _LogConfig = LogConfig _Logger = LogConfig.GetLogger() _Config = ConfigManager + _ConnectionString = ConnectionString End Sub #Region "Database-Access" Private Function GetSQLConnection() As SqlConnection - Return GetSQLConnection(_Config.Config.ConnectionString) + Return GetSQLConnection(_ConnectionString) End Function Private Function GetSQLConnection(ConnectionString As String) As SqlConnection @@ -84,6 +87,25 @@ Public Class Database Return Nothing End Try End Function + + Public Function ExecuteNonQuery(SQLCommand As String) As Boolean + Try + _Logger.Debug("ExecuteNonQuery: Running Query [{0}]", SQLCommand) + + Using oConnection = GetSQLConnection() + Using oSQLCOmmand = oConnection.CreateCommand() + oSQLCOmmand.CommandText = SQLCommand + oSQLCOmmand.CommandTimeout = QUERY_TIMEOUT + oSQLCOmmand.ExecuteNonQuery() + Return True + End Using + End Using + Catch ex As Exception + _Logger.Warn($"ExecuteNonQuery failed SQLCommand [{SQLCommand}] - ERROR: {ex.Message}") + + Return False + End Try + End Function #End Region End Class diff --git a/WinLineArtikelnummerGenerator/Modules/ConfigAttributes.vb b/WinLineArtikelnummerGenerator/Modules/ConfigAttributes.vb new file mode 100644 index 0000000..1a8bd04 --- /dev/null +++ b/WinLineArtikelnummerGenerator/Modules/ConfigAttributes.vb @@ -0,0 +1,22 @@ +Public Class ConfigAttributes + ''' + ''' The primary connection string. Will not be saved to userconfig. + ''' + Public Class ConnectionStringAttribute + Inherits Attribute + End Class + + ''' + ''' The test connection string. Will not be saved to userconfig. + ''' + Public Class ConnectionStringTestAttribute + Inherits Attribute + End Class + + ''' + ''' Global setting. Will not be saved to userconfig. + ''' + Public Class GlobalSettingAttribute + Inherits Attribute + End Class +End Class \ No newline at end of file diff --git a/WinLineArtikelnummerGenerator/Modules/ConfigManager.vb b/WinLineArtikelnummerGenerator/Modules/ConfigManager.vb index 7bac09d..966c991 100644 --- a/WinLineArtikelnummerGenerator/Modules/ConfigManager.vb +++ b/WinLineArtikelnummerGenerator/Modules/ConfigManager.vb @@ -1,8 +1,7 @@ Imports System.IO Imports System.Reflection Imports System.Xml.Serialization -Imports DigitalData.Modules.Logging -Imports DigitalData.Modules.Config.ConfigAttributes +Imports WinLineArtikelnummerGenerator.ConfigAttributes Public Class ConfigManager(Of T) Private Const USER_CONFIG_NAME As String = "UserConfig.xml" diff --git a/WinLineArtikelnummerGenerator/My Project/Application.Designer.vb b/WinLineArtikelnummerGenerator/My Project/Application.Designer.vb index e54e811..70c8631 100644 --- a/WinLineArtikelnummerGenerator/My Project/Application.Designer.vb +++ b/WinLineArtikelnummerGenerator/My Project/Application.Designer.vb @@ -32,7 +32,7 @@ Namespace My _ Protected Overrides Sub OnCreateMainForm() - Me.MainForm = Global.WinLineArtikelnummerGenerator.Form1 + Me.MainForm = Global.WinLineArtikelnummerGenerator.frmMain End Sub End Class End Namespace diff --git a/WinLineArtikelnummerGenerator/WinLineArtikelnummerGenerator.vbproj b/WinLineArtikelnummerGenerator/WinLineArtikelnummerGenerator.vbproj index de59acf..948e0aa 100644 --- a/WinLineArtikelnummerGenerator/WinLineArtikelnummerGenerator.vbproj +++ b/WinLineArtikelnummerGenerator/WinLineArtikelnummerGenerator.vbproj @@ -52,31 +52,6 @@ My Project\app.manifest - - - - - - - - - - - - ..\..\DDMonorepo\Modules.Config\bin\Debug\DigitalData.Modules.Config.dll - - - ..\..\DDMonorepo\Modules.Database\bin\Debug\DigitalData.Modules.Database.dll - - - ..\..\DDMonorepo\Modules.Filesystem\bin\Debug\DigitalData.Modules.Filesystem.dll - - - ..\..\DDMonorepo\Modules.Language\bin\Debug\DigitalData.Modules.Language.dll - - - ..\..\DDMonorepo\Modules.Logging\bin\Debug\DigitalData.Modules.Logging.dll - ..\packages\Newtonsoft.Json.6.0.4\lib\net45\Newtonsoft.Json.dll @@ -128,12 +103,25 @@ Form - - frmWinlineConfig.vb + + frmNewGroup.vb - + Form + + frmNewProduct.vb + + + Form + + + frmNewVendor.vb + + + Form + + True @@ -168,7 +156,7 @@ True - + @@ -178,8 +166,14 @@ frmMain.vb - - frmWinlineConfig.vb + + frmNewGroup.vb + + + frmNewProduct.vb + + + frmNewVendor.vb diff --git a/WinLineArtikelnummerGenerator/Winline.vb b/WinLineArtikelnummerGenerator/Winline.vb index 2769d46..6a6015d 100644 --- a/WinLineArtikelnummerGenerator/Winline.vb +++ b/WinLineArtikelnummerGenerator/Winline.vb @@ -1,20 +1,54 @@ -Imports System.Net +Imports System.IO +Imports System.Net +Imports System.Xml Public Class Winline Private _Logger As Logger - Private _Db As Database + Private _EXIM As Database + Private _Winline As Database + Private _Config As Config Public ReadOnly Property NO_RUNNING_NUMBER_FOUND = "NO_RUNNING_NUMBER_FOUND" + Public ReadOnly Property ARTICLE_ALREADY_EXISTS = "ARTICLE_ALREADY_EXISTS" Public ReadOnly Property UNKNOWN_ERROR = "UNKNOWN_ERROR" - Public Sub New(LogConfig As LogConfig, Database As Database) + Public Sub New(LogConfig As LogConfig, EximDatabase As Database, WinlineDatabase As Database, Config As Config) _Logger = LogConfig.GetLogger() - _Db = Database + _EXIM = EximDatabase + _Winline = WinlineDatabase + _Config = Config End Sub + Public Function GetVendorsFromWinLine() As List(Of Vendor) + Try + Dim CurrentYear = (Now.Year - 1900) * 12 + Dim CurrentMandator = _Config.WebService.Mandator + Dim oDatatable As DataTable = _Winline.GetDatatable( + $"SELECT * FROM V005 WHERE C004 = 3 AND c002 IS NOT NULL AND c003 IS NOT NULL AND " & + $"mesoyear = {CurrentYear} And mesocomp = '{CurrentMandator}'" & + "ORDER BY c003" + ) + Dim oVendors As New List(Of Vendor) + + For Each oRow As DataRow In oDatatable.Rows + Dim oVendor As New Vendor() With { + .WinlineName = oRow.Item("c003"), + .WinlineNumber = oRow.Item("c002") + } + + oVendors.Add(oVendor) + Next + + Return oVendors + Catch ex As Exception + _Logger.Error(ex) + Return Nothing + End Try + End Function + Public Function GetVendors() As List(Of Vendor) Try - Dim oDatatable As DataTable = _Db.GetDatatable("SELECT * FROM TBDD_ARTICLE_GENERATOR_VENDORS ORDER BY CODE") + Dim oDatatable As DataTable = _EXIM.GetDatatable("SELECT * FROM TBDD_ARTICLE_GENERATOR_VENDORS ORDER BY CODE") Dim oVendors As New List(Of Vendor) For Each oRow As DataRow In oDatatable.Rows @@ -38,7 +72,7 @@ Public Class Winline Public Function GetGroupsByVendor(VendorCode As String) As List(Of ProductGroup) Try - Dim oDatatable = _Db.GetDatatable($"SELECT * FROM TBDD_ARTICLE_GENERATOR_GROUPS WHERE CODE = '{VendorCode}'") + Dim oDatatable = _EXIM.GetDatatable($"SELECT * FROM TBDD_ARTICLE_GENERATOR_GROUPS WHERE CODE = '{VendorCode}'") Dim oGroups As New List(Of ProductGroup) For Each oRow As DataRow In oDatatable.Rows @@ -61,14 +95,14 @@ Public Class Winline Public Function GetVersionsByVendorAndGroup(VendorCode As String, GroupId As String) As List(Of ProductVersion) Try - Dim oDatatable = _Db.GetDatatable($"SELECT * FROM TBDD_ARTICLE_GENERATOR_PRODUCTS WHERE CODE = '{VendorCode}' AND [GROUP] = {GroupId}") + Dim oDatatable = _EXIM.GetDatatable($"SELECT * FROM TBDD_ARTICLE_GENERATOR_PRODUCTS WHERE CODE = '{VendorCode}' AND GROUP_ID = {GroupId}") Dim oVersions As New List(Of ProductVersion) For Each oRow As DataRow In oDatatable.Rows Dim oVersion As New ProductVersion() With { .Guid = oRow.Item("GUID"), .VersionId = oRow.Item("VERSION"), - .GroupId = oRow.Item("GROUP"), + .GroupId = oRow.Item("GROUP_ID"), .Name = oRow.Item("NAME"), .Code = oRow.Item("CODE") } @@ -87,7 +121,7 @@ Public Class Winline Try Dim oGroupCode As String = GroupId.ToString.PadLeft(2, "0") Dim oVersionCode As String = VersionId.ToString.PadLeft(2, "0") - Dim oDbResult = _Db.GetScalarValue($"SELECT MAX(C223) FROM v021 WHERE c010 LIKE '{VendorCode}{oGroupCode}{oVersionCode}___'") + Dim oDbResult = _Winline.GetScalarValue($"SELECT MAX(CONVERT(INT, C223)) FROM v021 WHERE c010 LIKE '{VendorCode}{oGroupCode}{oVersionCode}___'") If IsNumeric(oDbResult) Then Dim oNewRunningNumber = Integer.Parse(oDbResult) + 1 @@ -103,31 +137,168 @@ Public Class Winline End Try End Function - Public Function SendWebserviceRequest(XmlData As String) + Public Function SendWebserviceRequest(TemplateType As Integer, TemplateName As String, XmlData As String) Try - Dim oWebserviceConfig = My.Application.ConfigManager.Config.WinLine_WebService + Dim oWebserviceConfig = My.Application.ConfigManager.Config.WebService Dim oServer As String = oWebserviceConfig.Server Dim oURI = $"http://{oServer}/ewlservice/import" Dim oQuery As String = "" - oQuery &= $"User={oWebserviceConfig.Username}" - oQuery &= $"Password={oWebserviceConfig.Password}" - oQuery &= $"Company={oWebserviceConfig.Mandator}" - oQuery &= $"Type={oWebserviceConfig.ArticleTemplateType}" - oQuery &= $"Vorlage={oWebserviceConfig.ArticleTemplateName}" - oQuery &= $"Actioncode={oWebserviceConfig.ActionCode}" - oQuery &= $"byref=0" + oQuery &= $"User={oWebserviceConfig.Username}&" + oQuery &= $"Password={oWebserviceConfig.Password}&" + oQuery &= $"Company={oWebserviceConfig.Mandator}&" + oQuery &= $"Type={TemplateType}&" + oQuery &= $"Vorlage={TemplateName}&" + oQuery &= $"Actioncode={oWebserviceConfig.ActionCode}&" + oQuery &= $"byref=0&" oQuery &= $"Data={XmlData}" oURI &= $"?{oQuery}" - Dim oClient As HttpWebRequest = WebRequest.Create(oURI) - oClient.Method = "POST" - oClient.ContentType = "application/xml" - Catch ex As Exception + Dim oRequest As HttpWebRequest = WebRequest.Create(oURI) + Dim oResponse As HttpWebResponse = DirectCast(oRequest.GetResponse(), HttpWebResponse) + Dim oXmlResponse As String + Using oReader As New StreamReader(oResponse.GetResponseStream()) + oXmlResponse = oReader.ReadToEnd() + End Using + + Dim oDocument As New XmlDocument + oDocument.LoadXml(oXmlResponse) + oDocument.Save(Console.Out) + + Dim oSuccess As XmlNode = oDocument.DocumentElement.SelectSingleNode("OverallSuccess") + + If oSuccess.InnerText.ToUpper = "TRUE" Then + Return True + Else + Return False + End If + + Catch ex As Exception + _Logger.Error(ex) + Return False End Try End Function + Public Function TestArticleExists(ArticleNumber As String) As Boolean + Try + Dim oResult = _Winline.GetScalarValue($"SELECT c000 FROM v021 WHERE c002 = '{ArticleNumber}'") + + If IsNothing(oResult) Or IsDBNull(oResult) Then + Return False + Else + Return True + End If + Catch ex As Exception + Return False + End Try + End Function + + Public Function CreateArticle(ArticleNumber As String, RunningNumber As String, ArticleDescription As String, Vendor As Vendor, IsSerialnumberArticle As Boolean) + Dim oTemplateName As String = _Config.WebService.ArticleTemplateName + Dim oTemplateType As Integer = _Config.WebService.ArticleTemplateType + Dim oTaxCode As Integer = _Config.WebService.TaxCode + Dim oDescription As String = ArticleDescription + Dim oShapeFrom As String + Dim oShapeTo As String + Dim oArticleType As Integer + Dim oChargeIdentFlag As Integer + Dim oShapeFlag As Integer + Dim oUseShape As String + Dim oDefaultShape As String + Dim oMultipleShapes As String + + If IsSerialnumberArticle = True Then + oArticleType = 0 + oChargeIdentFlag = 1 + oShapeFlag = 1 + oUseShape = "true" + oShapeFrom = _Config.WebService.ShapeFrom + oShapeTo = _Config.WebService.ShapeTo + oDefaultShape = "A" + oMultipleShapes = "true" + Else + oArticleType = 0 + oChargeIdentFlag = 2 + oShapeFlag = 0 + oUseShape = "false" + oShapeFrom = String.Empty + oShapeTo = String.Empty + oDefaultShape = String.Empty + oMultipleShapes = "false" + End If + + Dim oXmlData + + oXmlData = "" + oXmlData &= $"" + oXmlData &= $"" + oXmlData &= $"<{oTemplateName}>" + ' ====================================================== + oXmlData &= $"{ArticleNumber}{RunningNumber}" + oXmlData &= $"{oDescription}" + oXmlData &= $"{oArticleType}" + oXmlData &= $"{oChargeIdentFlag}" + oXmlData &= $"{oShapeFlag}" + oXmlData &= $"{oUseShape}" + oXmlData &= $"{oShapeFrom}" + oXmlData &= $"{oShapeTo}" + oXmlData &= $"{Vendor.WinlineNumber.Trim}" + oXmlData &= $"{oTaxCode}" + oXmlData &= $"{RunningNumber}" + oXmlData &= $"{oDefaultShape}" + oXmlData &= $"{oMultipleShapes}" + ' ====================================================== + oXmlData &= $"" + oXmlData &= $"" + + Try + My.Application.Winline.SendWebserviceRequest(oTemplateType, oTemplateName, oXmlData) + Return True + Catch ex As Exception + _Logger.Error(ex) + Return False + End Try + End Function + + Public Function CreatePriceInfo(ArticleNumber As String, RunningNumber As String, VendorNumber As String) + Dim oTemplateName As String = _Config.WebService.PriceTemplateName + Dim oTemplateType As Integer = _Config.WebService.PriceTemplateType + + Dim oXmlData + + oXmlData = "" + oXmlData &= $"" + oXmlData &= $"" + oXmlData &= $"<{oTemplateName}>" + ' ====================================================== + oXmlData &= $"{ArticleNumber}{RunningNumber}" + oXmlData &= $"{VendorNumber.Trim}" + ' ====================================================== + oXmlData &= $"" + oXmlData &= $"" + + Try + My.Application.Winline.SendWebserviceRequest(oTemplateType, oTemplateName, oXmlData) + Return True + Catch ex As Exception + _Logger.Error(ex) + Return False + End Try + End Function + + Public Sub RunWinlineMacro(MacroName As String, ParamArray Parameters As Object()) + Try + Dim oCWLObject + Dim oParamArray As Object = New Runtime.InteropServices.VariantWrapper(Parameters) + + oCWLObject = CreateObject("cwlstart.application") + oCWLObject.MacroCommands.MRunMacro(MacroName, oParamArray) + Catch ex As Exception + _Logger.Error(ex) + MsgBox($"Das WinLine-Makro [{MacroName}] konnte nicht gestartet werden. Mehr Informationen im Log.", MsgBoxStyle.Critical, "WinLine") + End Try + End Sub End Class diff --git a/WinLineArtikelnummerGenerator/frmCreateArticle.Designer.vb b/WinLineArtikelnummerGenerator/frmCreateArticle.Designer.vb index b35100b..86b4aed 100644 --- a/WinLineArtikelnummerGenerator/frmCreateArticle.Designer.vb +++ b/WinLineArtikelnummerGenerator/frmCreateArticle.Designer.vb @@ -22,51 +22,58 @@ Partial Class frmCreateArticle 'Das Bearbeiten mit dem Code-Editor ist nicht möglich. _ Private Sub InitializeComponent() - Me.TextBox1 = New System.Windows.Forms.TextBox() + Me.txtArticleNumber = New System.Windows.Forms.TextBox() Me.Label1 = New System.Windows.Forms.Label() - Me.TextBox2 = New System.Windows.Forms.TextBox() + Me.txtArticleDescription = New System.Windows.Forms.TextBox() Me.Label2 = New System.Windows.Forms.Label() Me.GroupBox1 = New System.Windows.Forms.GroupBox() - Me.CheckBox1 = New System.Windows.Forms.CheckBox() + Me.lblImportantInformation = New System.Windows.Forms.Label() Me.Label3 = New System.Windows.Forms.Label() Me.Button1 = New System.Windows.Forms.Button() + Me.txtRunningNumber = New System.Windows.Forms.TextBox() + Me.Label4 = New System.Windows.Forms.Label() + Me.Button2 = New System.Windows.Forms.Button() + Me.Label5 = New System.Windows.Forms.Label() + Me.txtFinalArticleNumber = New System.Windows.Forms.TextBox() + Me.GroupBox1.SuspendLayout() Me.SuspendLayout() ' - 'TextBox1 + 'txtArticleNumber ' - Me.TextBox1.Font = New System.Drawing.Font("Segoe UI", 8.25!) - Me.TextBox1.Location = New System.Drawing.Point(12, 28) - Me.TextBox1.Name = "TextBox1" - Me.TextBox1.ReadOnly = True - Me.TextBox1.Size = New System.Drawing.Size(298, 22) - Me.TextBox1.TabIndex = 0 + Me.txtArticleNumber.Font = New System.Drawing.Font("Segoe UI", 9.75!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) + Me.txtArticleNumber.Location = New System.Drawing.Point(12, 28) + Me.txtArticleNumber.Name = "txtArticleNumber" + Me.txtArticleNumber.ReadOnly = True + Me.txtArticleNumber.Size = New System.Drawing.Size(210, 25) + Me.txtArticleNumber.TabIndex = 0 ' 'Label1 ' Me.Label1.AutoSize = True - Me.Label1.Font = New System.Drawing.Font("Segoe UI Semibold", 8.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) + Me.Label1.Font = New System.Drawing.Font("Segoe UI", 9.75!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) Me.Label1.Location = New System.Drawing.Point(12, 9) Me.Label1.Name = "Label1" - Me.Label1.Size = New System.Drawing.Size(82, 13) + Me.Label1.Size = New System.Drawing.Size(92, 17) Me.Label1.TabIndex = 1 Me.Label1.Text = "Artikelnummer" ' - 'TextBox2 + 'txtArticleDescription ' - Me.TextBox2.Font = New System.Drawing.Font("Segoe UI", 8.25!) - Me.TextBox2.Location = New System.Drawing.Point(12, 72) - Me.TextBox2.Multiline = True - Me.TextBox2.Name = "TextBox2" - Me.TextBox2.Size = New System.Drawing.Size(298, 105) - Me.TextBox2.TabIndex = 0 + Me.txtArticleDescription.Font = New System.Drawing.Font("Segoe UI", 9.75!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) + Me.txtArticleDescription.Location = New System.Drawing.Point(12, 72) + Me.txtArticleDescription.Multiline = True + Me.txtArticleDescription.Name = "txtArticleDescription" + Me.txtArticleDescription.Size = New System.Drawing.Size(298, 101) + Me.txtArticleDescription.TabIndex = 0 + Me.txtArticleDescription.Text = "Test Artikel für Artikelnummergenerator" ' 'Label2 ' Me.Label2.AutoSize = True - Me.Label2.Font = New System.Drawing.Font("Segoe UI Semibold", 8.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) + Me.Label2.Font = New System.Drawing.Font("Segoe UI", 9.75!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) Me.Label2.Location = New System.Drawing.Point(12, 53) Me.Label2.Name = "Label2" - Me.Label2.Size = New System.Drawing.Size(108, 13) + Me.Label2.Size = New System.Drawing.Size(123, 17) Me.Label2.TabIndex = 1 Me.Label2.Text = "Artikelbeschreibung" ' @@ -74,7 +81,8 @@ Partial Class frmCreateArticle ' Me.GroupBox1.Anchor = CType(((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Bottom) _ Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles) - Me.GroupBox1.Font = New System.Drawing.Font("Segoe UI Semibold", 8.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) + Me.GroupBox1.Controls.Add(Me.lblImportantInformation) + Me.GroupBox1.Font = New System.Drawing.Font("Segoe UI", 9.75!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) Me.GroupBox1.Location = New System.Drawing.Point(485, 12) Me.GroupBox1.Name = "GroupBox1" Me.GroupBox1.Size = New System.Drawing.Size(303, 426) @@ -82,30 +90,29 @@ Partial Class frmCreateArticle Me.GroupBox1.TabStop = False Me.GroupBox1.Text = "Wichtige Informationen" ' - 'CheckBox1 + 'lblImportantInformation ' - Me.CheckBox1.AutoSize = True - Me.CheckBox1.Font = New System.Drawing.Font("Segoe UI Semibold", 8.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) - Me.CheckBox1.Location = New System.Drawing.Point(15, 223) - Me.CheckBox1.Name = "CheckBox1" - Me.CheckBox1.Size = New System.Drawing.Size(172, 17) - Me.CheckBox1.TabIndex = 3 - Me.CheckBox1.Text = "Serienummer Artikel anlegen" - Me.CheckBox1.UseVisualStyleBackColor = True + Me.lblImportantInformation.Dock = System.Windows.Forms.DockStyle.Fill + Me.lblImportantInformation.Font = New System.Drawing.Font("Segoe UI", 9.75!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) + Me.lblImportantInformation.Location = New System.Drawing.Point(3, 21) + Me.lblImportantInformation.Name = "lblImportantInformation" + Me.lblImportantInformation.Size = New System.Drawing.Size(297, 402) + Me.lblImportantInformation.TabIndex = 0 + Me.lblImportantInformation.Text = "Label6" ' 'Label3 ' - Me.Label3.Font = New System.Drawing.Font("Segoe UI", 8.25!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) - Me.Label3.Location = New System.Drawing.Point(12, 180) + Me.Label3.Font = New System.Drawing.Font("Segoe UI", 9.75!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) + Me.Label3.Location = New System.Drawing.Point(12, 217) Me.Label3.Name = "Label3" - Me.Label3.Size = New System.Drawing.Size(298, 40) + Me.Label3.Size = New System.Drawing.Size(298, 77) Me.Label3.TabIndex = 4 Me.Label3.Text = "Seriennummer Artikel anlegen" & Global.Microsoft.VisualBasic.ChrW(13) & Global.Microsoft.VisualBasic.ChrW(10) & "Diese Einstellung kann, anders als beim Altsystem, " & "NICHT mehr im Nachhinein geändert werden!" ' 'Button1 ' - Me.Button1.Font = New System.Drawing.Font("Segoe UI", 8.25!) + Me.Button1.Font = New System.Drawing.Font("Segoe UI", 9.75!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) Me.Button1.Location = New System.Drawing.Point(12, 386) Me.Button1.Name = "Button1" Me.Button1.Size = New System.Drawing.Size(298, 52) @@ -113,33 +120,91 @@ Partial Class frmCreateArticle Me.Button1.Text = "Artikel anlegen!" Me.Button1.UseVisualStyleBackColor = True ' + 'txtRunningNumber + ' + Me.txtRunningNumber.Font = New System.Drawing.Font("Segoe UI", 9.75!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) + Me.txtRunningNumber.Location = New System.Drawing.Point(228, 28) + Me.txtRunningNumber.Name = "txtRunningNumber" + Me.txtRunningNumber.ReadOnly = True + Me.txtRunningNumber.Size = New System.Drawing.Size(82, 25) + Me.txtRunningNumber.TabIndex = 0 + ' + 'Label4 + ' + Me.Label4.AutoSize = True + Me.Label4.Font = New System.Drawing.Font("Segoe UI", 9.75!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) + Me.Label4.Location = New System.Drawing.Point(225, 9) + Me.Label4.Name = "Label4" + Me.Label4.Size = New System.Drawing.Size(83, 17) + Me.Label4.TabIndex = 1 + Me.Label4.Text = "Laufende Nr." + ' + 'Button2 + ' + Me.Button2.Font = New System.Drawing.Font("Segoe UI", 9.75!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) + Me.Button2.Location = New System.Drawing.Point(12, 297) + Me.Button2.Name = "Button2" + Me.Button2.Size = New System.Drawing.Size(298, 52) + Me.Button2.TabIndex = 5 + Me.Button2.Text = "Seriennummerartikel anlegen!" + Me.Button2.UseVisualStyleBackColor = True + ' + 'Label5 + ' + Me.Label5.Font = New System.Drawing.Font("Segoe UI", 9.75!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) + Me.Label5.Location = New System.Drawing.Point(12, 352) + Me.Label5.Name = "Label5" + Me.Label5.Size = New System.Drawing.Size(298, 31) + Me.Label5.TabIndex = 6 + Me.Label5.Text = "- ODER -" + Me.Label5.TextAlign = System.Drawing.ContentAlignment.MiddleCenter + ' + 'txtFinalArticleNumber + ' + Me.txtFinalArticleNumber.Font = New System.Drawing.Font("Segoe UI", 15.75!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) + Me.txtFinalArticleNumber.Location = New System.Drawing.Point(12, 179) + Me.txtFinalArticleNumber.Name = "txtFinalArticleNumber" + Me.txtFinalArticleNumber.ReadOnly = True + Me.txtFinalArticleNumber.Size = New System.Drawing.Size(298, 35) + Me.txtFinalArticleNumber.TabIndex = 7 + ' 'frmCreateArticle ' Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!) Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font Me.ClientSize = New System.Drawing.Size(800, 450) + Me.Controls.Add(Me.txtFinalArticleNumber) + Me.Controls.Add(Me.Label5) + Me.Controls.Add(Me.Button2) Me.Controls.Add(Me.Button1) Me.Controls.Add(Me.Label3) - Me.Controls.Add(Me.CheckBox1) Me.Controls.Add(Me.GroupBox1) Me.Controls.Add(Me.Label2) - Me.Controls.Add(Me.TextBox2) + Me.Controls.Add(Me.txtArticleDescription) + Me.Controls.Add(Me.Label4) Me.Controls.Add(Me.Label1) - Me.Controls.Add(Me.TextBox1) + Me.Controls.Add(Me.txtRunningNumber) + Me.Controls.Add(Me.txtArticleNumber) Me.Font = New System.Drawing.Font("Segoe UI Semibold", 8.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) Me.Name = "frmCreateArticle" - Me.Text = "frmCreateArticle" + Me.Text = "Artikel erstellen" + Me.GroupBox1.ResumeLayout(False) Me.ResumeLayout(False) Me.PerformLayout() End Sub - Friend WithEvents TextBox1 As TextBox + Friend WithEvents txtArticleNumber As TextBox Friend WithEvents Label1 As Label - Friend WithEvents TextBox2 As TextBox + Friend WithEvents txtArticleDescription As TextBox Friend WithEvents Label2 As Label Friend WithEvents GroupBox1 As GroupBox - Friend WithEvents CheckBox1 As CheckBox Friend WithEvents Label3 As Label Friend WithEvents Button1 As Button + Friend WithEvents txtRunningNumber As TextBox + Friend WithEvents Label4 As Label + Friend WithEvents Button2 As Button + Friend WithEvents Label5 As Label + Friend WithEvents txtFinalArticleNumber As TextBox + Friend WithEvents lblImportantInformation As Label End Class diff --git a/WinLineArtikelnummerGenerator/frmCreateArticle.vb b/WinLineArtikelnummerGenerator/frmCreateArticle.vb index e8d7586..befe415 100644 --- a/WinLineArtikelnummerGenerator/frmCreateArticle.vb +++ b/WinLineArtikelnummerGenerator/frmCreateArticle.vb @@ -1,3 +1,66 @@ 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 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 + + Dim oArticleResult = My.Application.Winline.CreateArticle(ArticleNumber, RunningNumber, txtArticleDescription.Text, Vendor, IsSerialNumberArticle) + 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) + 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) + End If + End Sub End Class \ No newline at end of file diff --git a/WinLineArtikelnummerGenerator/frmMain.Designer.vb b/WinLineArtikelnummerGenerator/frmMain.Designer.vb index 7d6e9d8..50c6fee 100644 --- a/WinLineArtikelnummerGenerator/frmMain.Designer.vb +++ b/WinLineArtikelnummerGenerator/frmMain.Designer.vb @@ -1,9 +1,9 @@ - _ + Partial Class frmMain Inherits System.Windows.Forms.Form 'Das Formular überschreibt den Löschvorgang, um die Komponentenliste zu bereinigen. - _ + Protected Overrides Sub Dispose(ByVal disposing As Boolean) Try If disposing AndAlso components IsNot Nothing Then @@ -20,7 +20,7 @@ Partial Class frmMain 'Hinweis: Die folgende Prozedur ist für den Windows Form-Designer erforderlich. 'Das Bearbeiten ist mit dem Windows Form-Designer möglich. 'Das Bearbeiten mit dem Code-Editor ist nicht möglich. - _ + Private Sub InitializeComponent() Me.listboxProductGroups = New System.Windows.Forms.ListBox() Me.Label1 = New System.Windows.Forms.Label() @@ -33,10 +33,6 @@ Partial Class frmMain Me.listboxVendors = New System.Windows.Forms.ListBox() Me.Button4 = New System.Windows.Forms.Button() Me.Label4 = New System.Windows.Forms.Label() - Me.MenuStrip1 = New System.Windows.Forms.MenuStrip() - Me.ToolStripMenuItem1 = New System.Windows.Forms.ToolStripMenuItem() - Me.EinstellungenToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem() - Me.MenuStrip1.SuspendLayout() Me.SuspendLayout() ' 'listboxProductGroups @@ -150,28 +146,6 @@ Partial Class frmMain Me.Label4.TabIndex = 4 Me.Label4.Text = "Aufbau: Kürzel - Markenname (Kreditorenummer | Name)" ' - 'MenuStrip1 - ' - Me.MenuStrip1.Items.AddRange(New System.Windows.Forms.ToolStripItem() {Me.ToolStripMenuItem1}) - Me.MenuStrip1.Location = New System.Drawing.Point(0, 0) - Me.MenuStrip1.Name = "MenuStrip1" - Me.MenuStrip1.Size = New System.Drawing.Size(1022, 24) - Me.MenuStrip1.TabIndex = 5 - Me.MenuStrip1.Text = "MenuStrip1" - ' - 'ToolStripMenuItem1 - ' - Me.ToolStripMenuItem1.DropDownItems.AddRange(New System.Windows.Forms.ToolStripItem() {Me.EinstellungenToolStripMenuItem}) - Me.ToolStripMenuItem1.Name = "ToolStripMenuItem1" - Me.ToolStripMenuItem1.Size = New System.Drawing.Size(46, 20) - Me.ToolStripMenuItem1.Text = "Datei" - ' - 'EinstellungenToolStripMenuItem - ' - Me.EinstellungenToolStripMenuItem.Name = "EinstellungenToolStripMenuItem" - Me.EinstellungenToolStripMenuItem.Size = New System.Drawing.Size(180, 22) - Me.EinstellungenToolStripMenuItem.Text = "Einstellungen" - ' 'frmMain ' Me.AutoScaleDimensions = New System.Drawing.SizeF(7.0!, 15.0!) @@ -188,14 +162,10 @@ Partial Class frmMain Me.Controls.Add(Me.listBoxProductVersion) Me.Controls.Add(Me.listboxProductGroups) Me.Controls.Add(Me.listboxVendors) - Me.Controls.Add(Me.MenuStrip1) Me.Font = New System.Drawing.Font("Segoe UI", 9.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) - Me.MainMenuStrip = Me.MenuStrip1 Me.Margin = New System.Windows.Forms.Padding(3, 4, 3, 4) Me.Name = "frmMain" Me.Text = "Artikelnummer Generator" - Me.MenuStrip1.ResumeLayout(False) - Me.MenuStrip1.PerformLayout() Me.ResumeLayout(False) Me.PerformLayout() @@ -211,7 +181,4 @@ Partial Class frmMain Friend WithEvents listboxVendors As ListBox Friend WithEvents Button4 As Button Friend WithEvents Label4 As Label - Friend WithEvents MenuStrip1 As MenuStrip - Friend WithEvents ToolStripMenuItem1 As ToolStripMenuItem - Friend WithEvents EinstellungenToolStripMenuItem As ToolStripMenuItem End Class diff --git a/WinLineArtikelnummerGenerator/frmMain.resx b/WinLineArtikelnummerGenerator/frmMain.resx index bb70361..1af7de1 100644 --- a/WinLineArtikelnummerGenerator/frmMain.resx +++ b/WinLineArtikelnummerGenerator/frmMain.resx @@ -117,7 +117,4 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - 17, 17 - \ No newline at end of file diff --git a/WinLineArtikelnummerGenerator/frmMain.vb b/WinLineArtikelnummerGenerator/frmMain.vb index b13d169..ec92331 100644 --- a/WinLineArtikelnummerGenerator/frmMain.vb +++ b/WinLineArtikelnummerGenerator/frmMain.vb @@ -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 \ No newline at end of file diff --git a/WinLineArtikelnummerGenerator/frmNewGroup.Designer.vb b/WinLineArtikelnummerGenerator/frmNewGroup.Designer.vb new file mode 100644 index 0000000..77172d4 --- /dev/null +++ b/WinLineArtikelnummerGenerator/frmNewGroup.Designer.vb @@ -0,0 +1,120 @@ + _ +Partial Class frmNewGroup + Inherits System.Windows.Forms.Form + + 'Das Formular überschreibt den Löschvorgang, um die Komponentenliste zu bereinigen. + _ + Protected Overrides Sub Dispose(ByVal disposing As Boolean) + Try + If disposing AndAlso components IsNot Nothing Then + components.Dispose() + End If + Finally + MyBase.Dispose(disposing) + End Try + End Sub + + 'Wird vom Windows Form-Designer benötigt. + Private components As System.ComponentModel.IContainer + + 'Hinweis: Die folgende Prozedur ist für den Windows Form-Designer erforderlich. + 'Das Bearbeiten ist mit dem Windows Form-Designer möglich. + 'Das Bearbeiten mit dem Code-Editor ist nicht möglich. + _ + Private Sub InitializeComponent() + Me.txtName = New System.Windows.Forms.TextBox() + Me.Label3 = New System.Windows.Forms.Label() + Me.Label1 = New System.Windows.Forms.Label() + Me.Label2 = New System.Windows.Forms.Label() + Me.txtNumber = New System.Windows.Forms.TextBox() + Me.Button1 = New System.Windows.Forms.Button() + Me.txtVendor = New System.Windows.Forms.TextBox() + Me.SuspendLayout() + ' + 'txtName + ' + Me.txtName.Location = New System.Drawing.Point(12, 38) + Me.txtName.Name = "txtName" + Me.txtName.Size = New System.Drawing.Size(315, 20) + Me.txtName.TabIndex = 5 + ' + 'Label3 + ' + Me.Label3.AutoSize = True + Me.Label3.Location = New System.Drawing.Point(9, 22) + Me.Label3.Name = "Label3" + Me.Label3.Size = New System.Drawing.Size(72, 13) + Me.Label3.TabIndex = 4 + Me.Label3.Text = "Beschreibung" + ' + 'Label1 + ' + Me.Label1.AutoSize = True + Me.Label1.Location = New System.Drawing.Point(9, 61) + Me.Label1.Name = "Label1" + Me.Label1.Size = New System.Drawing.Size(83, 13) + Me.Label1.TabIndex = 7 + Me.Label1.Text = "Lieferant/Marke" + ' + 'Label2 + ' + Me.Label2.AutoSize = True + Me.Label2.Font = New System.Drawing.Font("Microsoft Sans Serif", 8.25!, System.Drawing.FontStyle.Italic, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) + Me.Label2.Location = New System.Drawing.Point(9, 100) + Me.Label2.Name = "Label2" + Me.Label2.Size = New System.Drawing.Size(114, 13) + Me.Label2.TabIndex = 4 + Me.Label2.Text = "Neue Gruppennummer" + ' + 'txtNumber + ' + Me.txtNumber.Location = New System.Drawing.Point(12, 116) + Me.txtNumber.Name = "txtNumber" + Me.txtNumber.ReadOnly = True + Me.txtNumber.Size = New System.Drawing.Size(315, 20) + Me.txtNumber.TabIndex = 5 + ' + 'Button1 + ' + Me.Button1.Location = New System.Drawing.Point(12, 176) + Me.Button1.Name = "Button1" + Me.Button1.Size = New System.Drawing.Size(315, 44) + Me.Button1.TabIndex = 8 + Me.Button1.Text = "Gruppe anlegen!" + Me.Button1.UseVisualStyleBackColor = True + ' + 'txtVendor + ' + Me.txtVendor.Location = New System.Drawing.Point(12, 77) + Me.txtVendor.Name = "txtVendor" + Me.txtVendor.ReadOnly = True + Me.txtVendor.Size = New System.Drawing.Size(315, 20) + Me.txtVendor.TabIndex = 9 + ' + 'frmNewGroup + ' + Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!) + Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font + Me.ClientSize = New System.Drawing.Size(339, 232) + Me.Controls.Add(Me.txtVendor) + Me.Controls.Add(Me.Button1) + Me.Controls.Add(Me.Label1) + Me.Controls.Add(Me.txtNumber) + Me.Controls.Add(Me.Label2) + Me.Controls.Add(Me.txtName) + Me.Controls.Add(Me.Label3) + Me.Name = "frmNewGroup" + Me.Text = "Neue Gruppe" + Me.ResumeLayout(False) + Me.PerformLayout() + + End Sub + + Friend WithEvents txtName As TextBox + Friend WithEvents Label3 As Label + Friend WithEvents Label1 As Label + Friend WithEvents Label2 As Label + Friend WithEvents txtNumber As TextBox + Friend WithEvents Button1 As Button + Friend WithEvents txtVendor As TextBox +End Class diff --git a/WinLineArtikelnummerGenerator/frmWinlineConfig.resx b/WinLineArtikelnummerGenerator/frmNewGroup.resx similarity index 100% rename from WinLineArtikelnummerGenerator/frmWinlineConfig.resx rename to WinLineArtikelnummerGenerator/frmNewGroup.resx diff --git a/WinLineArtikelnummerGenerator/frmNewGroup.vb b/WinLineArtikelnummerGenerator/frmNewGroup.vb new file mode 100644 index 0000000..2da4e5a --- /dev/null +++ b/WinLineArtikelnummerGenerator/frmNewGroup.vb @@ -0,0 +1,54 @@ +Public Class frmNewGroup + Private _Logger As Logger + + Public Property Vendor As Vendor + + Private Sub frmNewGroup_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([GROUP]), 0) FROM TBDD_ARTICLE_GENERATOR_GROUPS WHERE VENDOR_ID = {Vendor.Guid}" + Dim oNumber = My.Application.EXIMDatabase.GetScalarValue(oSQL) + 1 + Dim oGroupCode As String = $"{Vendor.Code}{oNumber}" + + txtNumber.Text = oNumber + txtVendor.Text = Vendor.Name + 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 As Integer = Integer.Parse(txtNumber.Text) + Dim oGroupCode As String = $"{Vendor.Code}{oNumber.ToString.PadLeft(2)}" + + Dim oSQL = $"INSERT INTO TBDD_ARTICLE_GENERATOR_GROUPS + ([GROUP], CODE, GROUP_CODE, NAME, VENDOR_ID) + VALUES ({oNumber}, '{Vendor.Code}', '{oGroupCode}', '{oName}', {Vendor.Guid})" + Dim oResult = My.Application.EXIMDatabase.ExecuteNonQuery(oSQL) + + If oResult = True Then + MsgBox("Gruppe erstellt!", MsgBoxStyle.Information, Text) + + DialogResult = DialogResult.OK + Close() + Else + MsgBox("Fehler beim Erstellen der Gruppe. Mehr Informationen im Log.", MsgBoxStyle.Critical, Text) + End If + Catch ex As Exception + MsgBox("Fehler beim Erstellen der Gruppe: " & ex.Message, MsgBoxStyle.Critical, Text) + End Try + End If + End Sub +End Class \ No newline at end of file diff --git a/WinLineArtikelnummerGenerator/frmNewProduct.Designer.vb b/WinLineArtikelnummerGenerator/frmNewProduct.Designer.vb new file mode 100644 index 0000000..07bcb15 --- /dev/null +++ b/WinLineArtikelnummerGenerator/frmNewProduct.Designer.vb @@ -0,0 +1,143 @@ + _ +Partial Class frmNewProduct + Inherits System.Windows.Forms.Form + + 'Das Formular überschreibt den Löschvorgang, um die Komponentenliste zu bereinigen. + _ + Protected Overrides Sub Dispose(ByVal disposing As Boolean) + Try + If disposing AndAlso components IsNot Nothing Then + components.Dispose() + End If + Finally + MyBase.Dispose(disposing) + End Try + End Sub + + 'Wird vom Windows Form-Designer benötigt. + Private components As System.ComponentModel.IContainer + + 'Hinweis: Die folgende Prozedur ist für den Windows Form-Designer erforderlich. + 'Das Bearbeiten ist mit dem Windows Form-Designer möglich. + 'Das Bearbeiten mit dem Code-Editor ist nicht möglich. + _ + Private Sub InitializeComponent() + Me.txtVendor = New System.Windows.Forms.TextBox() + Me.txtName = New System.Windows.Forms.TextBox() + Me.Label3 = New System.Windows.Forms.Label() + Me.Label2 = New System.Windows.Forms.Label() + Me.Button1 = New System.Windows.Forms.Button() + Me.Label1 = New System.Windows.Forms.Label() + Me.txtGroup = New System.Windows.Forms.TextBox() + Me.Label4 = New System.Windows.Forms.Label() + Me.txtVersion = New System.Windows.Forms.TextBox() + Me.SuspendLayout() + ' + 'txtVendor + ' + Me.txtVendor.Location = New System.Drawing.Point(12, 77) + Me.txtVendor.Name = "txtVendor" + Me.txtVendor.ReadOnly = True + Me.txtVendor.Size = New System.Drawing.Size(315, 20) + Me.txtVendor.TabIndex = 6 + ' + 'txtName + ' + Me.txtName.Location = New System.Drawing.Point(12, 38) + Me.txtName.Name = "txtName" + Me.txtName.Size = New System.Drawing.Size(315, 20) + Me.txtName.TabIndex = 7 + ' + 'Label3 + ' + Me.Label3.AutoSize = True + Me.Label3.Location = New System.Drawing.Point(9, 22) + Me.Label3.Name = "Label3" + Me.Label3.Size = New System.Drawing.Size(35, 13) + Me.Label3.TabIndex = 4 + Me.Label3.Text = "Name" + ' + 'Label2 + ' + Me.Label2.AutoSize = True + Me.Label2.Location = New System.Drawing.Point(9, 61) + Me.Label2.Name = "Label2" + Me.Label2.Size = New System.Drawing.Size(48, 13) + Me.Label2.TabIndex = 5 + Me.Label2.Text = "Lieferant" + ' + 'Button1 + ' + Me.Button1.Location = New System.Drawing.Point(12, 209) + Me.Button1.Name = "Button1" + Me.Button1.Size = New System.Drawing.Size(315, 44) + Me.Button1.TabIndex = 8 + Me.Button1.Text = "Version anlegen!" + Me.Button1.UseVisualStyleBackColor = True + ' + 'Label1 + ' + Me.Label1.AutoSize = True + Me.Label1.Location = New System.Drawing.Point(9, 100) + Me.Label1.Name = "Label1" + Me.Label1.Size = New System.Drawing.Size(42, 13) + Me.Label1.TabIndex = 5 + Me.Label1.Text = "Gruppe" + ' + 'txtGroup + ' + Me.txtGroup.Location = New System.Drawing.Point(12, 116) + Me.txtGroup.Name = "txtGroup" + Me.txtGroup.ReadOnly = True + Me.txtGroup.Size = New System.Drawing.Size(315, 20) + Me.txtGroup.TabIndex = 6 + ' + 'Label4 + ' + Me.Label4.AutoSize = True + Me.Label4.Font = New System.Drawing.Font("Microsoft Sans Serif", 8.25!, System.Drawing.FontStyle.Italic, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) + Me.Label4.Location = New System.Drawing.Point(9, 139) + Me.Label4.Name = "Label4" + Me.Label4.Size = New System.Drawing.Size(71, 13) + Me.Label4.TabIndex = 5 + Me.Label4.Text = "Neue Version" + ' + 'txtVersion + ' + Me.txtVersion.Location = New System.Drawing.Point(12, 155) + Me.txtVersion.Name = "txtVersion" + Me.txtVersion.ReadOnly = True + Me.txtVersion.Size = New System.Drawing.Size(315, 20) + Me.txtVersion.TabIndex = 6 + ' + 'frmNewProduct + ' + Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!) + Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font + Me.ClientSize = New System.Drawing.Size(339, 265) + Me.Controls.Add(Me.Button1) + Me.Controls.Add(Me.txtVersion) + Me.Controls.Add(Me.txtGroup) + Me.Controls.Add(Me.txtVendor) + Me.Controls.Add(Me.txtName) + Me.Controls.Add(Me.Label3) + Me.Controls.Add(Me.Label4) + Me.Controls.Add(Me.Label1) + Me.Controls.Add(Me.Label2) + Me.Name = "frmNewProduct" + Me.Text = "Neue Version" + Me.ResumeLayout(False) + Me.PerformLayout() + + End Sub + + Friend WithEvents txtVendor As TextBox + Friend WithEvents txtName As TextBox + Friend WithEvents Label3 As Label + Friend WithEvents Label2 As Label + Friend WithEvents Button1 As Button + Friend WithEvents Label1 As Label + Friend WithEvents txtGroup As TextBox + Friend WithEvents Label4 As Label + Friend WithEvents txtVersion As TextBox +End Class diff --git a/WinLineArtikelnummerGenerator/frmNewProduct.resx b/WinLineArtikelnummerGenerator/frmNewProduct.resx new file mode 100644 index 0000000..1af7de1 --- /dev/null +++ b/WinLineArtikelnummerGenerator/frmNewProduct.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/WinLineArtikelnummerGenerator/frmNewProduct.vb b/WinLineArtikelnummerGenerator/frmNewProduct.vb new file mode 100644 index 0000000..324d1ec --- /dev/null +++ b/WinLineArtikelnummerGenerator/frmNewProduct.vb @@ -0,0 +1,55 @@ +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 \ No newline at end of file diff --git a/WinLineArtikelnummerGenerator/frmNewVendor.Designer.vb b/WinLineArtikelnummerGenerator/frmNewVendor.Designer.vb new file mode 100644 index 0000000..3726a78 --- /dev/null +++ b/WinLineArtikelnummerGenerator/frmNewVendor.Designer.vb @@ -0,0 +1,118 @@ + _ +Partial Class frmNewVendor + Inherits System.Windows.Forms.Form + + 'Das Formular überschreibt den Löschvorgang, um die Komponentenliste zu bereinigen. + _ + Protected Overrides Sub Dispose(ByVal disposing As Boolean) + Try + If disposing AndAlso components IsNot Nothing Then + components.Dispose() + End If + Finally + MyBase.Dispose(disposing) + End Try + End Sub + + 'Wird vom Windows Form-Designer benötigt. + Private components As System.ComponentModel.IContainer + + 'Hinweis: Die folgende Prozedur ist für den Windows Form-Designer erforderlich. + 'Das Bearbeiten ist mit dem Windows Form-Designer möglich. + 'Das Bearbeiten mit dem Code-Editor ist nicht möglich. + _ + Private Sub InitializeComponent() + Me.cmbWinlineVendor = New System.Windows.Forms.ComboBox() + Me.Label1 = New System.Windows.Forms.Label() + Me.Label2 = New System.Windows.Forms.Label() + Me.Label3 = New System.Windows.Forms.Label() + Me.txtName = New System.Windows.Forms.TextBox() + Me.txtCode = New System.Windows.Forms.TextBox() + Me.Button1 = New System.Windows.Forms.Button() + Me.SuspendLayout() + ' + 'cmbWinlineVendor + ' + Me.cmbWinlineVendor.FormattingEnabled = True + Me.cmbWinlineVendor.Location = New System.Drawing.Point(12, 116) + Me.cmbWinlineVendor.Name = "cmbWinlineVendor" + Me.cmbWinlineVendor.Size = New System.Drawing.Size(315, 21) + Me.cmbWinlineVendor.TabIndex = 0 + ' + 'Label1 + ' + Me.Label1.AutoSize = True + Me.Label1.Location = New System.Drawing.Point(9, 100) + Me.Label1.Name = "Label1" + Me.Label1.Size = New System.Drawing.Size(86, 13) + Me.Label1.TabIndex = 1 + Me.Label1.Text = "Winline Lieferant" + ' + 'Label2 + ' + Me.Label2.AutoSize = True + Me.Label2.Location = New System.Drawing.Point(9, 61) + Me.Label2.Name = "Label2" + Me.Label2.Size = New System.Drawing.Size(78, 13) + Me.Label2.TabIndex = 2 + Me.Label2.Text = "Code (AA - ZZ)" + ' + 'Label3 + ' + Me.Label3.AutoSize = True + Me.Label3.Location = New System.Drawing.Point(9, 22) + Me.Label3.Name = "Label3" + Me.Label3.Size = New System.Drawing.Size(106, 13) + Me.Label3.TabIndex = 2 + Me.Label3.Text = "Name (Markenname)" + ' + 'txtName + ' + Me.txtName.Location = New System.Drawing.Point(12, 38) + Me.txtName.Name = "txtName" + Me.txtName.Size = New System.Drawing.Size(315, 20) + Me.txtName.TabIndex = 3 + ' + 'txtCode + ' + Me.txtCode.Location = New System.Drawing.Point(12, 77) + Me.txtCode.Name = "txtCode" + Me.txtCode.Size = New System.Drawing.Size(315, 20) + Me.txtCode.TabIndex = 3 + ' + 'Button1 + ' + Me.Button1.Location = New System.Drawing.Point(12, 173) + Me.Button1.Name = "Button1" + Me.Button1.Size = New System.Drawing.Size(315, 44) + Me.Button1.TabIndex = 4 + Me.Button1.Text = "Lieferanten anlegen!" + Me.Button1.UseVisualStyleBackColor = True + ' + 'frmNewVendor + ' + Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!) + Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font + Me.ClientSize = New System.Drawing.Size(339, 232) + Me.Controls.Add(Me.Button1) + Me.Controls.Add(Me.txtCode) + Me.Controls.Add(Me.txtName) + Me.Controls.Add(Me.Label3) + Me.Controls.Add(Me.Label2) + Me.Controls.Add(Me.Label1) + Me.Controls.Add(Me.cmbWinlineVendor) + Me.Name = "frmNewVendor" + Me.Text = "Neuer Lieferant" + Me.ResumeLayout(False) + Me.PerformLayout() + + End Sub + + Friend WithEvents cmbWinlineVendor As ComboBox + Friend WithEvents Label1 As Label + Friend WithEvents Label2 As Label + Friend WithEvents Label3 As Label + Friend WithEvents txtName As TextBox + Friend WithEvents txtCode As TextBox + Friend WithEvents Button1 As Button +End Class diff --git a/WinLineArtikelnummerGenerator/frmNewVendor.resx b/WinLineArtikelnummerGenerator/frmNewVendor.resx new file mode 100644 index 0000000..1af7de1 --- /dev/null +++ b/WinLineArtikelnummerGenerator/frmNewVendor.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/WinLineArtikelnummerGenerator/frmNewVendor.vb b/WinLineArtikelnummerGenerator/frmNewVendor.vb new file mode 100644 index 0000000..887b13d --- /dev/null +++ b/WinLineArtikelnummerGenerator/frmNewVendor.vb @@ -0,0 +1,56 @@ +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 \ No newline at end of file diff --git a/WinLineArtikelnummerGenerator/frmWinlineConfig.Designer.vb b/WinLineArtikelnummerGenerator/frmWinlineConfig.Designer.vb deleted file mode 100644 index b7e79af..0000000 --- a/WinLineArtikelnummerGenerator/frmWinlineConfig.Designer.vb +++ /dev/null @@ -1,141 +0,0 @@ - _ -Partial Class frmWinlineConfig - Inherits System.Windows.Forms.Form - - 'Das Formular überschreibt den Löschvorgang, um die Komponentenliste zu bereinigen. - _ - Protected Overrides Sub Dispose(ByVal disposing As Boolean) - Try - If disposing AndAlso components IsNot Nothing Then - components.Dispose() - End If - Finally - MyBase.Dispose(disposing) - End Try - End Sub - - 'Wird vom Windows Form-Designer benötigt. - Private components As System.ComponentModel.IContainer - - 'Hinweis: Die folgende Prozedur ist für den Windows Form-Designer erforderlich. - 'Das Bearbeiten ist mit dem Windows Form-Designer möglich. - 'Das Bearbeiten mit dem Code-Editor ist nicht möglich. - _ - Private Sub InitializeComponent() - Me.txtServer = New System.Windows.Forms.TextBox() - Me.txtMandator = New System.Windows.Forms.TextBox() - Me.txtUsername = New System.Windows.Forms.TextBox() - Me.txtPassword = New System.Windows.Forms.TextBox() - Me.Label1 = New System.Windows.Forms.Label() - Me.Label2 = New System.Windows.Forms.Label() - Me.Label3 = New System.Windows.Forms.Label() - Me.Label4 = New System.Windows.Forms.Label() - Me.GroupBox1 = New System.Windows.Forms.GroupBox() - Me.GroupBox1.SuspendLayout() - Me.SuspendLayout() - ' - 'txtServer - ' - Me.txtServer.Location = New System.Drawing.Point(9, 32) - Me.txtServer.Name = "txtServer" - Me.txtServer.Size = New System.Drawing.Size(346, 20) - Me.txtServer.TabIndex = 0 - ' - 'txtMandator - ' - Me.txtMandator.Location = New System.Drawing.Point(9, 71) - Me.txtMandator.Name = "txtMandator" - Me.txtMandator.Size = New System.Drawing.Size(346, 20) - Me.txtMandator.TabIndex = 1 - ' - 'txtUsername - ' - Me.txtUsername.Location = New System.Drawing.Point(9, 110) - Me.txtUsername.Name = "txtUsername" - Me.txtUsername.Size = New System.Drawing.Size(346, 20) - Me.txtUsername.TabIndex = 2 - ' - 'txtPassword - ' - Me.txtPassword.Location = New System.Drawing.Point(9, 149) - Me.txtPassword.Name = "txtPassword" - Me.txtPassword.Size = New System.Drawing.Size(346, 20) - Me.txtPassword.TabIndex = 3 - ' - 'Label1 - ' - Me.Label1.AutoSize = True - Me.Label1.Location = New System.Drawing.Point(6, 16) - Me.Label1.Name = "Label1" - Me.Label1.Size = New System.Drawing.Size(79, 13) - Me.Label1.TabIndex = 4 - Me.Label1.Text = "Server-Adresse" - ' - 'Label2 - ' - Me.Label2.AutoSize = True - Me.Label2.Location = New System.Drawing.Point(6, 55) - Me.Label2.Name = "Label2" - Me.Label2.Size = New System.Drawing.Size(49, 13) - Me.Label2.TabIndex = 5 - Me.Label2.Text = "Mandant" - ' - 'Label3 - ' - Me.Label3.AutoSize = True - Me.Label3.Location = New System.Drawing.Point(6, 94) - Me.Label3.Name = "Label3" - Me.Label3.Size = New System.Drawing.Size(49, 13) - Me.Label3.TabIndex = 6 - Me.Label3.Text = "Benutzer" - ' - 'Label4 - ' - Me.Label4.AutoSize = True - Me.Label4.Location = New System.Drawing.Point(6, 133) - Me.Label4.Name = "Label4" - Me.Label4.Size = New System.Drawing.Size(50, 13) - Me.Label4.TabIndex = 7 - Me.Label4.Text = "Passwort" - ' - 'GroupBox1 - ' - Me.GroupBox1.Controls.Add(Me.Label1) - Me.GroupBox1.Controls.Add(Me.Label4) - Me.GroupBox1.Controls.Add(Me.txtServer) - Me.GroupBox1.Controls.Add(Me.Label3) - Me.GroupBox1.Controls.Add(Me.txtMandator) - Me.GroupBox1.Controls.Add(Me.Label2) - Me.GroupBox1.Controls.Add(Me.txtUsername) - Me.GroupBox1.Controls.Add(Me.txtPassword) - Me.GroupBox1.Location = New System.Drawing.Point(12, 12) - Me.GroupBox1.Name = "GroupBox1" - Me.GroupBox1.Size = New System.Drawing.Size(361, 226) - Me.GroupBox1.TabIndex = 8 - Me.GroupBox1.TabStop = False - Me.GroupBox1.Text = "WinLine WebServices" - ' - 'frmWinlineConfig - ' - Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!) - Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font - Me.ClientSize = New System.Drawing.Size(800, 450) - Me.Controls.Add(Me.GroupBox1) - Me.Name = "frmWinlineConfig" - Me.Text = "frmWinlineConfig" - Me.GroupBox1.ResumeLayout(False) - Me.GroupBox1.PerformLayout() - Me.ResumeLayout(False) - - End Sub - - Friend WithEvents txtServer As TextBox - Friend WithEvents txtMandator As TextBox - Friend WithEvents txtUsername As TextBox - Friend WithEvents txtPassword As TextBox - Friend WithEvents Label1 As Label - Friend WithEvents Label2 As Label - Friend WithEvents Label3 As Label - Friend WithEvents Label4 As Label - Friend WithEvents GroupBox1 As GroupBox -End Class diff --git a/WinLineArtikelnummerGenerator/frmWinlineConfig.vb b/WinLineArtikelnummerGenerator/frmWinlineConfig.vb deleted file mode 100644 index bff3a67..0000000 --- a/WinLineArtikelnummerGenerator/frmWinlineConfig.vb +++ /dev/null @@ -1,23 +0,0 @@ -Public Class frmWinlineConfig - Private Sub frmWinlineConfig_Load(sender As Object, e As EventArgs) Handles MyBase.Load - With My.Application.ConfigManager.Config - If .WinLine_WebService IsNot Nothing Then - .WinLine_WebService = New Config.WebServiceConfig() - End If - - txtServer.Text = .WinLine_WebService.Server - txtMandator.Text = .WinLine_WebService.Mandator - txtUsername.Text = .WinLine_WebService.Username - txtPassword.Text = .WinLine_WebService.Password - End With - End Sub - - Private Sub frmWinlineConfig_FormClosing(sender As Object, e As FormClosingEventArgs) Handles Me.FormClosing - With My.Application.ConfigManager.Config - .WinLine_WebService.Server = txtServer.Text - .WinLine_WebService.Mandator = txtMandator.Text - .WinLine_WebService.Username = txtUsername.Text - .WinLine_WebService.Password = txtPassword.Text - End With - End Sub -End Class \ No newline at end of file