diff --git a/SDL/ZOLLSYSTEM/DAKOSY/ATLAS/EZA/usrCntlATLAS_EZA.Designer.vb b/SDL/ZOLLSYSTEM/DAKOSY/ATLAS/EZA/usrCntlATLAS_EZA.Designer.vb index 7d2722ed..72449c04 100644 --- a/SDL/ZOLLSYSTEM/DAKOSY/ATLAS/EZA/usrCntlATLAS_EZA.Designer.vb +++ b/SDL/ZOLLSYSTEM/DAKOSY/ATLAS/EZA/usrCntlATLAS_EZA.Designer.vb @@ -24,17 +24,8 @@ Partial Class usrCntlATLAS_EZA Private Sub InitializeComponent() Me.components = New System.ComponentModel.Container() Me.SplitContainer = New System.Windows.Forms.SplitContainer() - Me.MyFlowLayoutPanel1 = New VERAG_PROG_ALLGEMEIN.MyFlowLayoutPanel(Me.components) - Me.btnAllgemein = New System.Windows.Forms.Button() - Me.btnAdressen = New System.Windows.Forms.Button() - Me.btnAktiveVeredelung = New System.Windows.Forms.Button() - Me.btnPositionen = New System.Windows.Forms.Button() - Me.btnDV1 = New System.Windows.Forms.Button() - Me.Button5 = New System.Windows.Forms.Button() Me.pnl = New System.Windows.Forms.Panel() Me.Label6 = New System.Windows.Forms.Label() - Me.cboDakosyAction = New VERAG_PROG_ALLGEMEIN.MyComboBox() - Me.cboStammreferenz = New VERAG_PROG_ALLGEMEIN.MyComboBox() Me.Button1 = New System.Windows.Forms.Button() Me.Label4 = New System.Windows.Forms.Label() Me.Label5 = New System.Windows.Forms.Label() @@ -56,17 +47,27 @@ Partial Class usrCntlATLAS_EZA Me.DateiimportToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem() Me.DynamicAutomotiveXLSToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem() Me.GEZEXLSXToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem() + Me.MEYLEXLSXToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem() Me.ToolStripMenuItem1 = New System.Windows.Forms.ToolStripMenuItem() Me.EZAIDToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem() - Me.MEYLEXLSXToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem() + Me.FressnapToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem() + Me.MyFlowLayoutPanel1 = New VERAG_PROG_ALLGEMEIN.MyFlowLayoutPanel(Me.components) + Me.btnAllgemein = New System.Windows.Forms.Button() + Me.btnAdressen = New System.Windows.Forms.Button() + Me.btnAktiveVeredelung = New System.Windows.Forms.Button() + Me.btnPositionen = New System.Windows.Forms.Button() + Me.btnDV1 = New System.Windows.Forms.Button() + Me.Button5 = New System.Windows.Forms.Button() + Me.cboDakosyAction = New VERAG_PROG_ALLGEMEIN.MyComboBox() + Me.cboStammreferenz = New VERAG_PROG_ALLGEMEIN.MyComboBox() CType(Me.SplitContainer, System.ComponentModel.ISupportInitialize).BeginInit() Me.SplitContainer.Panel1.SuspendLayout() Me.SplitContainer.SuspendLayout() - Me.MyFlowLayoutPanel1.SuspendLayout() Me.pnl.SuspendLayout() Me.cntxtBezugsnr.SuspendLayout() Me.Panel1.SuspendLayout() Me.MenuStrip.SuspendLayout() + Me.MyFlowLayoutPanel1.SuspendLayout() Me.SuspendLayout() ' 'SplitContainer @@ -92,128 +93,6 @@ Partial Class usrCntlATLAS_EZA Me.SplitContainer.SplitterWidth = 1 Me.SplitContainer.TabIndex = 0 ' - 'MyFlowLayoutPanel1 - ' - Me.MyFlowLayoutPanel1.BackColor = System.Drawing.Color.WhiteSmoke - Me.MyFlowLayoutPanel1.Controls.Add(Me.btnAllgemein) - Me.MyFlowLayoutPanel1.Controls.Add(Me.btnAdressen) - Me.MyFlowLayoutPanel1.Controls.Add(Me.btnAktiveVeredelung) - Me.MyFlowLayoutPanel1.Controls.Add(Me.btnPositionen) - Me.MyFlowLayoutPanel1.Controls.Add(Me.btnDV1) - Me.MyFlowLayoutPanel1.Controls.Add(Me.Button5) - Me.MyFlowLayoutPanel1.Dock = System.Windows.Forms.DockStyle.Fill - Me.MyFlowLayoutPanel1.Location = New System.Drawing.Point(0, 0) - Me.MyFlowLayoutPanel1.Margin = New System.Windows.Forms.Padding(1) - Me.MyFlowLayoutPanel1.Name = "MyFlowLayoutPanel1" - Me.MyFlowLayoutPanel1.Size = New System.Drawing.Size(573, 72) - Me.MyFlowLayoutPanel1.TabIndex = 0 - ' - 'btnAllgemein - ' - Me.btnAllgemein.BackColor = System.Drawing.Color.SteelBlue - Me.btnAllgemein.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Center - Me.btnAllgemein.FlatStyle = System.Windows.Forms.FlatStyle.Flat - Me.btnAllgemein.ForeColor = System.Drawing.SystemColors.ControlLightLight - Me.btnAllgemein.Image = Global.SDL.My.Resources.Resources.android_note12 - Me.btnAllgemein.ImageAlign = System.Drawing.ContentAlignment.TopCenter - Me.btnAllgemein.Location = New System.Drawing.Point(2, 2) - Me.btnAllgemein.Margin = New System.Windows.Forms.Padding(2) - Me.btnAllgemein.Name = "btnAllgemein" - Me.btnAllgemein.Padding = New System.Windows.Forms.Padding(0, 12, 0, 3) - Me.btnAllgemein.Size = New System.Drawing.Size(75, 67) - Me.btnAllgemein.TabIndex = 0 - Me.btnAllgemein.Text = "Allgemein" - Me.btnAllgemein.TextAlign = System.Drawing.ContentAlignment.BottomCenter - Me.btnAllgemein.UseVisualStyleBackColor = False - ' - 'btnAdressen - ' - Me.btnAdressen.BackColor = System.Drawing.Color.White - Me.btnAdressen.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Center - Me.btnAdressen.FlatStyle = System.Windows.Forms.FlatStyle.Flat - Me.btnAdressen.Image = Global.SDL.My.Resources.Resources.house1 - Me.btnAdressen.ImageAlign = System.Drawing.ContentAlignment.TopCenter - Me.btnAdressen.Location = New System.Drawing.Point(81, 2) - Me.btnAdressen.Margin = New System.Windows.Forms.Padding(2) - Me.btnAdressen.Name = "btnAdressen" - Me.btnAdressen.Padding = New System.Windows.Forms.Padding(0, 0, 0, 3) - Me.btnAdressen.Size = New System.Drawing.Size(75, 67) - Me.btnAdressen.TabIndex = 1 - Me.btnAdressen.Text = "Adressen" - Me.btnAdressen.TextAlign = System.Drawing.ContentAlignment.BottomCenter - Me.btnAdressen.UseVisualStyleBackColor = False - ' - 'btnAktiveVeredelung - ' - Me.btnAktiveVeredelung.BackColor = System.Drawing.Color.White - Me.btnAktiveVeredelung.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Center - Me.btnAktiveVeredelung.FlatStyle = System.Windows.Forms.FlatStyle.Flat - Me.btnAktiveVeredelung.Image = Global.SDL.My.Resources.Resources.aktiveVeredelung1 - Me.btnAktiveVeredelung.ImageAlign = System.Drawing.ContentAlignment.TopCenter - Me.btnAktiveVeredelung.Location = New System.Drawing.Point(160, 2) - Me.btnAktiveVeredelung.Margin = New System.Windows.Forms.Padding(2) - Me.btnAktiveVeredelung.Name = "btnAktiveVeredelung" - Me.btnAktiveVeredelung.Padding = New System.Windows.Forms.Padding(0, 6, 0, 3) - Me.btnAktiveVeredelung.Size = New System.Drawing.Size(94, 67) - Me.btnAktiveVeredelung.TabIndex = 3 - Me.btnAktiveVeredelung.Text = "Pass. Veredel." - Me.btnAktiveVeredelung.TextAlign = System.Drawing.ContentAlignment.BottomCenter - Me.btnAktiveVeredelung.UseVisualStyleBackColor = False - Me.btnAktiveVeredelung.Visible = False - ' - 'btnPositionen - ' - Me.btnPositionen.BackColor = System.Drawing.Color.White - Me.btnPositionen.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Center - Me.btnPositionen.FlatStyle = System.Windows.Forms.FlatStyle.Flat - Me.btnPositionen.Image = Global.SDL.My.Resources.Resources.list_new_small2 - Me.btnPositionen.ImageAlign = System.Drawing.ContentAlignment.TopCenter - Me.btnPositionen.Location = New System.Drawing.Point(258, 2) - Me.btnPositionen.Margin = New System.Windows.Forms.Padding(2) - Me.btnPositionen.Name = "btnPositionen" - Me.btnPositionen.Padding = New System.Windows.Forms.Padding(0, 0, 0, 3) - Me.btnPositionen.Size = New System.Drawing.Size(81, 67) - Me.btnPositionen.TabIndex = 4 - Me.btnPositionen.Text = "Positionen" - Me.btnPositionen.TextAlign = System.Drawing.ContentAlignment.BottomCenter - Me.btnPositionen.UseVisualStyleBackColor = False - ' - 'btnDV1 - ' - Me.btnDV1.BackColor = System.Drawing.Color.White - Me.btnDV1.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Center - Me.btnDV1.FlatStyle = System.Windows.Forms.FlatStyle.Flat - Me.btnDV1.Image = Global.SDL.My.Resources.Resources.moneybag1 - Me.btnDV1.ImageAlign = System.Drawing.ContentAlignment.TopCenter - Me.btnDV1.Location = New System.Drawing.Point(343, 2) - Me.btnDV1.Margin = New System.Windows.Forms.Padding(2) - Me.btnDV1.Name = "btnDV1" - Me.btnDV1.Padding = New System.Windows.Forms.Padding(0, 2, 0, 3) - Me.btnDV1.Size = New System.Drawing.Size(94, 67) - Me.btnDV1.TabIndex = 6 - Me.btnDV1.Text = "D.V.1" - Me.btnDV1.TextAlign = System.Drawing.ContentAlignment.BottomCenter - Me.btnDV1.UseVisualStyleBackColor = False - Me.btnDV1.Visible = False - ' - 'Button5 - ' - Me.Button5.BackColor = System.Drawing.Color.White - Me.Button5.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Center - Me.Button5.FlatStyle = System.Windows.Forms.FlatStyle.Flat - Me.Button5.Image = Global.SDL.My.Resources.Resources.android_note12 - Me.Button5.ImageAlign = System.Drawing.ContentAlignment.TopCenter - Me.Button5.Location = New System.Drawing.Point(441, 2) - Me.Button5.Margin = New System.Windows.Forms.Padding(2) - Me.Button5.Name = "Button5" - Me.Button5.Padding = New System.Windows.Forms.Padding(0, 12, 0, 3) - Me.Button5.Size = New System.Drawing.Size(81, 67) - Me.Button5.TabIndex = 5 - Me.Button5.Text = "Referenzen" - Me.Button5.TextAlign = System.Drawing.ContentAlignment.BottomCenter - Me.Button5.UseVisualStyleBackColor = False - Me.Button5.Visible = False - ' 'pnl ' Me.pnl.BackColor = System.Drawing.Color.WhiteSmoke @@ -242,35 +121,6 @@ Partial Class usrCntlATLAS_EZA Me.Label6.Text = "Stammref.:" Me.Label6.TextAlign = System.Drawing.ContentAlignment.TopRight ' - 'cboDakosyAction - ' - Me.cboDakosyAction._allowedValuesFreiText = Nothing - Me.cboDakosyAction._allowFreiText = False - Me.cboDakosyAction._value = "" - Me.cboDakosyAction.Anchor = CType((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles) - Me.cboDakosyAction.BackColor = System.Drawing.Color.FromArgb(CType(CType(224, Byte), Integer), CType(CType(224, Byte), Integer), CType(CType(224, Byte), Integer)) - Me.cboDakosyAction.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList - Me.cboDakosyAction.FlatStyle = System.Windows.Forms.FlatStyle.Flat - Me.cboDakosyAction.FormattingEnabled = True - Me.cboDakosyAction.Location = New System.Drawing.Point(200, 48) - Me.cboDakosyAction.Name = "cboDakosyAction" - Me.cboDakosyAction.Size = New System.Drawing.Size(158, 21) - Me.cboDakosyAction.TabIndex = 1 - ' - 'cboStammreferenz - ' - Me.cboStammreferenz._allowedValuesFreiText = Nothing - Me.cboStammreferenz._allowFreiText = True - Me.cboStammreferenz._value = "" - Me.cboStammreferenz.BackColor = System.Drawing.Color.FromArgb(CType(CType(224, Byte), Integer), CType(CType(224, Byte), Integer), CType(CType(224, Byte), Integer)) - Me.cboStammreferenz.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList - Me.cboStammreferenz.FlatStyle = System.Windows.Forms.FlatStyle.Flat - Me.cboStammreferenz.FormattingEnabled = True - Me.cboStammreferenz.Location = New System.Drawing.Point(71, 48) - Me.cboStammreferenz.Name = "cboStammreferenz" - Me.cboStammreferenz.Size = New System.Drawing.Size(129, 21) - Me.cboStammreferenz.TabIndex = 13 - ' 'Button1 ' Me.Button1.Anchor = CType((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles) @@ -445,7 +295,7 @@ Partial Class usrCntlATLAS_EZA ' 'DateiimportToolStripMenuItem ' - Me.DateiimportToolStripMenuItem.DropDownItems.AddRange(New System.Windows.Forms.ToolStripItem() {Me.DynamicAutomotiveXLSToolStripMenuItem, Me.GEZEXLSXToolStripMenuItem, Me.MEYLEXLSXToolStripMenuItem}) + Me.DateiimportToolStripMenuItem.DropDownItems.AddRange(New System.Windows.Forms.ToolStripItem() {Me.DynamicAutomotiveXLSToolStripMenuItem, Me.GEZEXLSXToolStripMenuItem, Me.MEYLEXLSXToolStripMenuItem, Me.FressnapToolStripMenuItem}) Me.DateiimportToolStripMenuItem.Name = "DateiimportToolStripMenuItem" Me.DateiimportToolStripMenuItem.Size = New System.Drawing.Size(87, 20) Me.DateiimportToolStripMenuItem.Text = "Datei-Import" @@ -462,6 +312,12 @@ Partial Class usrCntlATLAS_EZA Me.GEZEXLSXToolStripMenuItem.Size = New System.Drawing.Size(224, 22) Me.GEZEXLSXToolStripMenuItem.Text = "GEZE (XLSX)" ' + 'MEYLEXLSXToolStripMenuItem + ' + Me.MEYLEXLSXToolStripMenuItem.Name = "MEYLEXLSXToolStripMenuItem" + Me.MEYLEXLSXToolStripMenuItem.Size = New System.Drawing.Size(224, 22) + Me.MEYLEXLSXToolStripMenuItem.Text = "MEYLE (XLSX)" + ' 'ToolStripMenuItem1 ' Me.ToolStripMenuItem1.DropDownItems.AddRange(New System.Windows.Forms.ToolStripItem() {Me.EZAIDToolStripMenuItem}) @@ -475,11 +331,162 @@ Partial Class usrCntlATLAS_EZA Me.EZAIDToolStripMenuItem.Size = New System.Drawing.Size(109, 22) Me.EZAIDToolStripMenuItem.Text = "EZA ID" ' - 'MEYLEXLSXToolStripMenuItem + 'FressnapToolStripMenuItem ' - Me.MEYLEXLSXToolStripMenuItem.Name = "MEYLEXLSXToolStripMenuItem" - Me.MEYLEXLSXToolStripMenuItem.Size = New System.Drawing.Size(224, 22) - Me.MEYLEXLSXToolStripMenuItem.Text = "MEYLE (XLSX)" + Me.FressnapToolStripMenuItem.Name = "FressnapToolStripMenuItem" + Me.FressnapToolStripMenuItem.Size = New System.Drawing.Size(224, 22) + Me.FressnapToolStripMenuItem.Text = "Fressnapf (XLSX)" + ' + 'MyFlowLayoutPanel1 + ' + Me.MyFlowLayoutPanel1.BackColor = System.Drawing.Color.WhiteSmoke + Me.MyFlowLayoutPanel1.Controls.Add(Me.btnAllgemein) + Me.MyFlowLayoutPanel1.Controls.Add(Me.btnAdressen) + Me.MyFlowLayoutPanel1.Controls.Add(Me.btnAktiveVeredelung) + Me.MyFlowLayoutPanel1.Controls.Add(Me.btnPositionen) + Me.MyFlowLayoutPanel1.Controls.Add(Me.btnDV1) + Me.MyFlowLayoutPanel1.Controls.Add(Me.Button5) + Me.MyFlowLayoutPanel1.Dock = System.Windows.Forms.DockStyle.Fill + Me.MyFlowLayoutPanel1.Location = New System.Drawing.Point(0, 0) + Me.MyFlowLayoutPanel1.Margin = New System.Windows.Forms.Padding(1) + Me.MyFlowLayoutPanel1.Name = "MyFlowLayoutPanel1" + Me.MyFlowLayoutPanel1.Size = New System.Drawing.Size(573, 72) + Me.MyFlowLayoutPanel1.TabIndex = 0 + ' + 'btnAllgemein + ' + Me.btnAllgemein.BackColor = System.Drawing.Color.SteelBlue + Me.btnAllgemein.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Center + Me.btnAllgemein.FlatStyle = System.Windows.Forms.FlatStyle.Flat + Me.btnAllgemein.ForeColor = System.Drawing.SystemColors.ControlLightLight + Me.btnAllgemein.Image = Global.SDL.My.Resources.Resources.android_note12 + Me.btnAllgemein.ImageAlign = System.Drawing.ContentAlignment.TopCenter + Me.btnAllgemein.Location = New System.Drawing.Point(2, 2) + Me.btnAllgemein.Margin = New System.Windows.Forms.Padding(2) + Me.btnAllgemein.Name = "btnAllgemein" + Me.btnAllgemein.Padding = New System.Windows.Forms.Padding(0, 12, 0, 3) + Me.btnAllgemein.Size = New System.Drawing.Size(75, 67) + Me.btnAllgemein.TabIndex = 0 + Me.btnAllgemein.Text = "Allgemein" + Me.btnAllgemein.TextAlign = System.Drawing.ContentAlignment.BottomCenter + Me.btnAllgemein.UseVisualStyleBackColor = False + ' + 'btnAdressen + ' + Me.btnAdressen.BackColor = System.Drawing.Color.White + Me.btnAdressen.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Center + Me.btnAdressen.FlatStyle = System.Windows.Forms.FlatStyle.Flat + Me.btnAdressen.Image = Global.SDL.My.Resources.Resources.house1 + Me.btnAdressen.ImageAlign = System.Drawing.ContentAlignment.TopCenter + Me.btnAdressen.Location = New System.Drawing.Point(81, 2) + Me.btnAdressen.Margin = New System.Windows.Forms.Padding(2) + Me.btnAdressen.Name = "btnAdressen" + Me.btnAdressen.Padding = New System.Windows.Forms.Padding(0, 0, 0, 3) + Me.btnAdressen.Size = New System.Drawing.Size(75, 67) + Me.btnAdressen.TabIndex = 1 + Me.btnAdressen.Text = "Adressen" + Me.btnAdressen.TextAlign = System.Drawing.ContentAlignment.BottomCenter + Me.btnAdressen.UseVisualStyleBackColor = False + ' + 'btnAktiveVeredelung + ' + Me.btnAktiveVeredelung.BackColor = System.Drawing.Color.White + Me.btnAktiveVeredelung.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Center + Me.btnAktiveVeredelung.FlatStyle = System.Windows.Forms.FlatStyle.Flat + Me.btnAktiveVeredelung.Image = Global.SDL.My.Resources.Resources.aktiveVeredelung1 + Me.btnAktiveVeredelung.ImageAlign = System.Drawing.ContentAlignment.TopCenter + Me.btnAktiveVeredelung.Location = New System.Drawing.Point(160, 2) + Me.btnAktiveVeredelung.Margin = New System.Windows.Forms.Padding(2) + Me.btnAktiveVeredelung.Name = "btnAktiveVeredelung" + Me.btnAktiveVeredelung.Padding = New System.Windows.Forms.Padding(0, 6, 0, 3) + Me.btnAktiveVeredelung.Size = New System.Drawing.Size(94, 67) + Me.btnAktiveVeredelung.TabIndex = 3 + Me.btnAktiveVeredelung.Text = "Pass. Veredel." + Me.btnAktiveVeredelung.TextAlign = System.Drawing.ContentAlignment.BottomCenter + Me.btnAktiveVeredelung.UseVisualStyleBackColor = False + Me.btnAktiveVeredelung.Visible = False + ' + 'btnPositionen + ' + Me.btnPositionen.BackColor = System.Drawing.Color.White + Me.btnPositionen.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Center + Me.btnPositionen.FlatStyle = System.Windows.Forms.FlatStyle.Flat + Me.btnPositionen.Image = Global.SDL.My.Resources.Resources.list_new_small2 + Me.btnPositionen.ImageAlign = System.Drawing.ContentAlignment.TopCenter + Me.btnPositionen.Location = New System.Drawing.Point(258, 2) + Me.btnPositionen.Margin = New System.Windows.Forms.Padding(2) + Me.btnPositionen.Name = "btnPositionen" + Me.btnPositionen.Padding = New System.Windows.Forms.Padding(0, 0, 0, 3) + Me.btnPositionen.Size = New System.Drawing.Size(81, 67) + Me.btnPositionen.TabIndex = 4 + Me.btnPositionen.Text = "Positionen" + Me.btnPositionen.TextAlign = System.Drawing.ContentAlignment.BottomCenter + Me.btnPositionen.UseVisualStyleBackColor = False + ' + 'btnDV1 + ' + Me.btnDV1.BackColor = System.Drawing.Color.White + Me.btnDV1.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Center + Me.btnDV1.FlatStyle = System.Windows.Forms.FlatStyle.Flat + Me.btnDV1.Image = Global.SDL.My.Resources.Resources.moneybag1 + Me.btnDV1.ImageAlign = System.Drawing.ContentAlignment.TopCenter + Me.btnDV1.Location = New System.Drawing.Point(343, 2) + Me.btnDV1.Margin = New System.Windows.Forms.Padding(2) + Me.btnDV1.Name = "btnDV1" + Me.btnDV1.Padding = New System.Windows.Forms.Padding(0, 2, 0, 3) + Me.btnDV1.Size = New System.Drawing.Size(94, 67) + Me.btnDV1.TabIndex = 6 + Me.btnDV1.Text = "D.V.1" + Me.btnDV1.TextAlign = System.Drawing.ContentAlignment.BottomCenter + Me.btnDV1.UseVisualStyleBackColor = False + Me.btnDV1.Visible = False + ' + 'Button5 + ' + Me.Button5.BackColor = System.Drawing.Color.White + Me.Button5.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Center + Me.Button5.FlatStyle = System.Windows.Forms.FlatStyle.Flat + Me.Button5.Image = Global.SDL.My.Resources.Resources.android_note12 + Me.Button5.ImageAlign = System.Drawing.ContentAlignment.TopCenter + Me.Button5.Location = New System.Drawing.Point(441, 2) + Me.Button5.Margin = New System.Windows.Forms.Padding(2) + Me.Button5.Name = "Button5" + Me.Button5.Padding = New System.Windows.Forms.Padding(0, 12, 0, 3) + Me.Button5.Size = New System.Drawing.Size(81, 67) + Me.Button5.TabIndex = 5 + Me.Button5.Text = "Referenzen" + Me.Button5.TextAlign = System.Drawing.ContentAlignment.BottomCenter + Me.Button5.UseVisualStyleBackColor = False + Me.Button5.Visible = False + ' + 'cboDakosyAction + ' + Me.cboDakosyAction._allowedValuesFreiText = Nothing + Me.cboDakosyAction._allowFreiText = False + Me.cboDakosyAction._value = "" + Me.cboDakosyAction.Anchor = CType((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles) + Me.cboDakosyAction.BackColor = System.Drawing.Color.FromArgb(CType(CType(224, Byte), Integer), CType(CType(224, Byte), Integer), CType(CType(224, Byte), Integer)) + Me.cboDakosyAction.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList + Me.cboDakosyAction.FlatStyle = System.Windows.Forms.FlatStyle.Flat + Me.cboDakosyAction.FormattingEnabled = True + Me.cboDakosyAction.Location = New System.Drawing.Point(200, 48) + Me.cboDakosyAction.Name = "cboDakosyAction" + Me.cboDakosyAction.Size = New System.Drawing.Size(158, 21) + Me.cboDakosyAction.TabIndex = 1 + ' + 'cboStammreferenz + ' + Me.cboStammreferenz._allowedValuesFreiText = Nothing + Me.cboStammreferenz._allowFreiText = True + Me.cboStammreferenz._value = "" + Me.cboStammreferenz.BackColor = System.Drawing.Color.FromArgb(CType(CType(224, Byte), Integer), CType(CType(224, Byte), Integer), CType(CType(224, Byte), Integer)) + Me.cboStammreferenz.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList + Me.cboStammreferenz.FlatStyle = System.Windows.Forms.FlatStyle.Flat + Me.cboStammreferenz.FormattingEnabled = True + Me.cboStammreferenz.Location = New System.Drawing.Point(71, 48) + Me.cboStammreferenz.Name = "cboStammreferenz" + Me.cboStammreferenz.Size = New System.Drawing.Size(129, 21) + Me.cboStammreferenz.TabIndex = 13 ' 'usrCntlATLAS_EZA ' @@ -493,7 +500,6 @@ Partial Class usrCntlATLAS_EZA Me.SplitContainer.Panel1.ResumeLayout(False) CType(Me.SplitContainer, System.ComponentModel.ISupportInitialize).EndInit() Me.SplitContainer.ResumeLayout(False) - Me.MyFlowLayoutPanel1.ResumeLayout(False) Me.pnl.ResumeLayout(False) Me.pnl.PerformLayout() Me.cntxtBezugsnr.ResumeLayout(False) @@ -501,6 +507,7 @@ Partial Class usrCntlATLAS_EZA Me.Panel1.PerformLayout() Me.MenuStrip.ResumeLayout(False) Me.MenuStrip.PerformLayout() + Me.MyFlowLayoutPanel1.ResumeLayout(False) Me.ResumeLayout(False) End Sub @@ -540,4 +547,5 @@ Partial Class usrCntlATLAS_EZA Friend WithEvents XMLExampleToolStripMenuItem As ToolStripMenuItem Friend WithEvents GEZEXLSXToolStripMenuItem As ToolStripMenuItem Friend WithEvents MEYLEXLSXToolStripMenuItem As ToolStripMenuItem + Friend WithEvents FressnapToolStripMenuItem As ToolStripMenuItem End Class diff --git a/SDL/ZOLLSYSTEM/DAKOSY/ATLAS/EZA/usrCntlATLAS_EZA.vb b/SDL/ZOLLSYSTEM/DAKOSY/ATLAS/EZA/usrCntlATLAS_EZA.vb index 1475f9a7..ec4b8681 100644 --- a/SDL/ZOLLSYSTEM/DAKOSY/ATLAS/EZA/usrCntlATLAS_EZA.vb +++ b/SDL/ZOLLSYSTEM/DAKOSY/ATLAS/EZA/usrCntlATLAS_EZA.vb @@ -1428,24 +1428,7 @@ Public Class usrCntlATLAS_EZA End Function - Private Function ToDoubleSafe(o As Object) As Double - If o Is Nothing OrElse IsDBNull(o) Then Return 0 - ' Direkte Numerik - If TypeOf o Is Double Then Return DirectCast(o, Double) - If TypeOf o Is Decimal Then Return Convert.ToDouble(o) - If TypeOf o Is Integer OrElse TypeOf o Is Int64 OrElse TypeOf o Is Int16 Then Return Convert.ToDouble(o) - - ' String-Fälle (leer, deutsch, englisch) - Dim s = o.ToString().Trim() - If s = "" Then Return 0 - - Dim v As Double - If Double.TryParse(s, NumberStyles.Any, CultureInfo.CurrentCulture, v) Then Return v - If Double.TryParse(s, NumberStyles.Any, CultureInfo.InvariantCulture, v) Then Return v - - Return 0 ' Notfalls 0 - End Function Private Sub pnl_Paint_1(sender As Object, e As PaintEventArgs) Handles pnl.Paint @@ -1497,5 +1480,309 @@ Public Class usrCntlATLAS_EZA Private Sub MEYLEXLSXToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles MEYLEXLSXToolStripMenuItem.Click importExcel_MEYLE() End Sub + + Private Sub FressnapToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles FressnapToolStripMenuItem.Click + + importExcel_Fressnapf() + End Sub + + Private Function importExcel_Fressnapf() As Boolean + Dim fd As New OpenFileDialog With { + .Filter = "Excel Dateien|*.xls;*.xlsx", + .Multiselect = True, + .Title = "Bitte eine oder mehrere Excel-Dateien auswählen" + } + + If fd.ShowDialog() <> DialogResult.OK Then + Me.Cursor = Cursors.Default + MsgBox("Keine Datei ausgewählt!") + Return False + End If + + Dim cnt As Integer = 0 + + If EZA.eza_WARENPOS.Count > 0 Then + If vbYes = MsgBox("Sollten die aktuellen Einträge gelöscht werden?", vbYesNo) Then + EZA.eza_WARENPOS.Clear() + End If + End If + + Me.Cursor = Cursors.WaitCursor + + For Each filePath As String In fd.FileNames + If Not (filePath.ToLower().EndsWith(".xls") OrElse filePath.ToLower().EndsWith(".xlsx")) Then + Continue For + End If + + Dim exclApp As Excel.Application = Nothing + Dim Datei As Excel.Workbook = Nothing + Dim Blatt As Excel.Worksheet = Nothing + + Try + exclApp = New Excel.Application With { + .CutCopyMode = False, + .DisplayAlerts = False + } + + Datei = exclApp.Workbooks.Open(filePath) + Blatt = CType(Datei.Worksheets(1), Excel.Worksheet) + Datei.Activate() + + Try : Blatt.ShowAllData() : Catch : End Try + + ' --- Prüfe, ob Kopfzeile in Zeile 17 existiert + If Not checkExcelHeader_Fressnapf(Blatt) Then + Throw New ApplicationException("Excel-Struktur entspricht nicht dem erwarteten Layout (Header-Zeile 17).") + End If + + ' --- Spalten dynamisch per Header ermitteln (Zeile 17) + Dim colDesc = FindHeaderColumn(Blatt, 17, {"warenbeschreibung"}) + Dim colImpCode = FindHeaderColumn(Blatt, 17, {"importcodenummer", "warentarifnummer", "eztnummer", "ezt-nummer"}) + Dim colOrigin = FindHeaderColumn(Blatt, 17, {"ursprungsland", "ursprungslandcode"}) + Dim colCurrency = FindHeaderColumn(Blatt, 17, {"währung", "waehrung", "currency"}) + Dim colNetMass = FindHeaderColumn(Blatt, 17, {"nettomasse", "nettomas­se", "nettomasse kg", "eigenmasse"}) + Dim colQty = FindHeaderColumn(Blatt, 17, {"menge", "quantity", "qty"}) + Dim colValue = FindHeaderColumn(Blatt, 17, {"warenwert", "invoice value", "value"}) + + ' Minimal erforderliche Spalten prüfen + If colDesc = -1 OrElse colImpCode = -1 OrElse colOrigin = -1 OrElse colCurrency = -1 OrElse colValue = -1 Then + Throw New ApplicationException("Nicht alle erforderlichen Spaltenköpfe gefunden (Beschreibung/Warentarifnummer/Ursprungsland/Währung/Warenwert).") + End If + + ' --- Datenbereich bestimmen: ab Zeile 18 bis erste Leerzeile in Spalte A (Pos.) + Dim startRows As Integer = 18 + Dim endRows As Integer = startRows + Dim usedRows As Integer = Blatt.UsedRange.Rows.Count + + Do While endRows <= usedRows + Dim val = Blatt.Range("A" & endRows).Value + If val Is Nothing OrElse val.ToString().Trim() = "" Then Exit Do + endRows += 1 + Loop + endRows -= 1 + + If endRows < startRows Then + Throw New ApplicationException("Keine Positionsdaten im Excel gefunden.") + End If + + ' --- Spaltenanzahl mindestens so groß wie letzte genutzte Spalte + Dim colCount As Integer = Math.Max(Blatt.UsedRange.Columns.Count, Math.Max(Math.Max(Math.Max(colDesc, colImpCode), Math.Max(colOrigin, colCurrency)), Math.Max(colValue, If(colNetMass < 0, 0, colNetMass))) + 1) + If colCount < 19 Then colCount = 19 ' typischerweise A..S + + ' --- Rohdaten in DataTable übernehmen + Dim DATA As New DataTable() + For c As Integer = 1 To colCount + DATA.Columns.Add("Spalte" & c, GetType(String)) + Next + + For r As Integer = startRows To endRows + Dim newRow As DataRow = DATA.NewRow() + For c As Integer = 1 To colCount + Dim value = Blatt.Cells(r, c).Value + newRow(c - 1) = If(value IsNot Nothing, value.ToString(), "") + Next + ' Normalisierung für Gruppierung + If colCurrency >= 0 Then newRow(colCurrency) = newRow(colCurrency).ToString().Trim().ToUpper() + If colOrigin >= 0 Then newRow(colOrigin) = newRow(colOrigin).ToString().Trim().ToUpper() + DATA.Rows.Add(newRow) + Next + + ' --- Nur numerische Pos.-Zeilen behalten (Spalte A / Index 0) + For i As Integer = DATA.Rows.Count - 1 To 0 Step -1 + Dim posTxt As String = DATA.Rows(i)(0).ToString().Trim() + Dim posNum As Integer + If Not Integer.TryParse(posTxt, posNum) Then + DATA.Rows.RemoveAt(i) + End If + Next + + ' --- Gruppieren nach: Beschreibung, Warentarifnummer, Ursprungsland, Währung + Dim resultDATA As DataTable = DATA.Clone() + + Dim groups = From row In DATA.AsEnumerable() + Group row By + keyDesc = row(colDesc), + keyTariff = row(colImpCode), + keyOrigin = row(colOrigin), + keyCurr = row(colCurrency) + Into grp = Group + Select keyDesc, keyTariff, keyOrigin, keyCurr, grp + + For Each g In groups + Dim newRow As DataRow = resultDATA.NewRow() + + newRow(colDesc) = g.keyDesc + newRow(colImpCode) = g.keyTariff + newRow(colOrigin) = g.keyOrigin + newRow(colCurrency) = g.keyCurr + + ' Summenfelder (nur wenn vorhanden) + If colQty >= 0 Then newRow(colQty) = g.grp.Sum(Function(r) ToDoubleSafe(r(colQty))).ToString() + If colNetMass >= 0 Then newRow(colNetMass) = g.grp.Sum(Function(r) ToDoubleSafe(r(colNetMass))).ToString() + newRow(colValue) = g.grp.Sum(Function(r) ToDoubleSafe(r(colValue))).ToString() + + resultDATA.Rows.Add(newRow) + Next + + ' --- Kopfwerte optional (z. B. Belegnummer) + Dim HandlesRgNr As String = "" + Try + If Blatt.Range("A8") IsNot Nothing AndAlso Blatt.Range("A8").Value IsNot Nothing Then + HandlesRgNr = Blatt.Range("A8").Value.ToString().Trim() + End If + Catch + End Try + + ' --- Ergebniszeilen in EZA schreiben + For Each row As DataRow In resultDATA.Rows + Dim tariff As String = row(colImpCode).ToString().Trim() + Dim desc As String = row(colDesc).ToString().Trim() + If tariff = "" AndAlso desc = "" Then Continue For + + Dim POSITION As New DAKOSY_Worker.cDakosy_EZA_Warenposition + + ' *** WAREN­TARIFNUMMER *** + POSITION.ezaWP_WarennummerEZT = tariff + + ' Packstücke (nicht aus Excel, Standardwerte) + POSITION.ezaWP_PackstueckAnzahl = "0" + POSITION.ezaWP_PackstueckArt = "PK" + + ' *** ARTIKELPREIS (Warenwert) *** + Dim warenwert As Double = ToDoubleSafe(row(colValue)) + POSITION.ezaWP_Artikelpreis = warenwert.ToString("N2") + + ' *** WÄHRUNG *** + POSITION.ezaWP_ArtikelpreisWaehrung = row(colCurrency).ToString() + + ' *** BESCHREIBUNG *** + POSITION.ezaWP_Warenbezeichnung = desc + + ' *** EIGENMASSE (aus Nettomasse, wenn vorhanden) *** + If colNetMass >= 0 Then + Dim netto As Double = ToDoubleSafe(row(colNetMass)) + POSITION.ezaWP_Eigenmasse = netto.ToString("N1") + Else + POSITION.ezaWP_Eigenmasse = "0.0" + End If + + ' *** URSPRUNGS­LAND (2-stellig) *** + Dim ursprung As String = row(colOrigin).ToString().Trim().ToUpper() + If ursprung.Length >= 2 Then POSITION.ezaWP_UrsprungslandCode = ursprung.Substring(0, 2) + + ' Unterlagen (optional) + If Not String.IsNullOrWhiteSpace(HandlesRgNr) Then + POSITION.ezaWP_UNTERLAGEN.Add(New DAKOSY_Worker.cDakosy_EZA_WarenpositionVorgelegteUnterlagen With { + .ezaWpUl_Art = "N380", + .ezaWpUl_Bereich = "4", + .ezaWpUl_VorlageKz = "J", + .ezaWpUl_Nummer = HandlesRgNr, + .ezaWpUl_DatumAusstellung = Nothing + }) + End If + + EZA.eza_WARENPOS.Add(POSITION) + cnt += 1 + Next + + Catch ex As Exception + Me.Cursor = Cursors.Default + MsgBox("FEHLER beim Einlesen: " & vbCrLf & ex.Message) + Finally + ' Ressourcen sauber freigeben + Try + If Datei IsNot Nothing Then Datei.Close(False) + Catch + End Try + Try + If exclApp IsNot Nothing Then exclApp.Quit() + Catch + End Try + Try + If Blatt IsNot Nothing Then System.Runtime.InteropServices.Marshal.FinalReleaseComObject(Blatt) + Catch + End Try + Try + If Datei IsNot Nothing Then System.Runtime.InteropServices.Marshal.FinalReleaseComObject(Datei) + Catch + End Try + Try + If exclApp IsNot Nothing Then System.Runtime.InteropServices.Marshal.FinalReleaseComObject(exclApp) + Catch + End Try + Blatt = Nothing : Datei = Nothing : exclApp = Nothing + GC.Collect() + GC.WaitForPendingFinalizers() + End Try + + Console.WriteLine("Verarbeite Datei: " & filePath) + Next + + Me.FindForm.SuspendLayout() + POSITIONEN.setValues(EZA, True) + btnPositionen.PerformClick() + Me.FindForm.ResumeLayout() + + MsgBox(cnt & " Datensätze wurden eingelesen.") + Me.Cursor = Cursors.Default + Return True + End Function + + ' Liefert die 0-basierte Spaltennummer (DataTable-Index) anhand eines Header-Texts in rowIdx. + ' Gibt -1 zurück, wenn keine der gesuchten Varianten gefunden wird. + Private Function FindHeaderColumn(ws As Excel.Worksheet, rowIdx As Integer, headerVariants As IEnumerable(Of String)) As Integer + Dim maxScanCols As Integer = 35 ' etwas Puffer + For c As Integer = 1 To maxScanCols + Dim cell = ws.Cells(rowIdx, c).Value + If cell Is Nothing Then Continue For + Dim norm = cell.ToString().Trim().ToLower() + For Each hv In headerVariants + If norm.Contains(hv.ToLower()) Then + Return c - 1 ' DataTable ist 0-basiert + End If + Next + Next + Return -1 + End Function + + Private Function ToDoubleSafe(obj As Object) As Double + If obj Is Nothing Then Return 0 + Dim s As String = obj.ToString().Trim() + If s = "" Then Return 0 + ' Komma/Punkt robust behandeln, kulturinvariant parsen + Dim d As Double + ' Erst alle Tausenderpunkte/Kommas vereinheitlichen + s = s.Replace(" ", "") + ' Häufigster Fall: deutsches Komma + If s.Contains(",") AndAlso Not s.Contains(".") Then + s = s.Replace(".", "") + s = s.Replace(",", ".") + ElseIf s.Contains(".") AndAlso s.Contains(",") Then + ' Entferne Tausender-Trenner, behalte Dezimaltrennzeichen als Punkt + s = s.Replace(".", "") + s = s.Replace(",", ".") + End If + If Double.TryParse(s, Globalization.NumberStyles.Any, Globalization.CultureInfo.InvariantCulture, d) Then + Return d + End If + Return 0 + End Function + + ' Prüft Kopfzeile in Zeile 17: + ' A17="Pos.", D17 beginnt mit "Warenbeschreibung", + ' P17 beginnt mit "Importcodenummer", R17 beginnt mit "Ursprungsland" + Private Function checkExcelHeader_Fressnapf(ws As Excel.Worksheet) As Boolean + Try + Dim a = CStr(ws.Range("A17").Value) + Dim d = CStr(ws.Range("D17").Value) + If a Is Nothing OrElse d Is Nothing Then Return False + Return a.Trim().ToLower() = "pos." AndAlso + d.Trim().ToLower().StartsWith("warenbeschreibung") + Catch + Return False + End Try + End Function + + End Class diff --git a/VERAG_PROG_ALLGEMEIN/AuditFlow/Classes/cAuditFlow.vb b/VERAG_PROG_ALLGEMEIN/AuditFlow/Classes/cAuditFlow.vb index 67662905..9efec880 100644 --- a/VERAG_PROG_ALLGEMEIN/AuditFlow/Classes/cAuditFlow.vb +++ b/VERAG_PROG_ALLGEMEIN/AuditFlow/Classes/cAuditFlow.vb @@ -160,7 +160,7 @@ Public Class cAuditFlow pruefung.wartPruef_Erledigung_Datum = Date.Now pruefung.wartPruef_Erledigung = True pruefung.wartPruef_Anhaenge_daId = dsId - pruefung.wartPruef_Bemerkung = dsId + pruefung.wartPruef_Bemerkung = Bemerkung ' 3. Speichern Return pruefung.SAVE() diff --git a/VERAG_PROG_ALLGEMEIN/Schnittstellen/DHF/cDHF_Import.vb b/VERAG_PROG_ALLGEMEIN/Schnittstellen/DHF/cDHF_Import.vb new file mode 100644 index 00000000..b9d9a16f --- /dev/null +++ b/VERAG_PROG_ALLGEMEIN/Schnittstellen/DHF/cDHF_Import.vb @@ -0,0 +1,729 @@ +Imports System.Data.SqlClient +Imports System.Reflection + + +' =========================================================== +' =============== KOPF (imDHFAnm) ====================== +' =========================================================== +Public Class cDHF_Import + ' ====== Primärschlüssel (zusammengesetzt) ====== + + Public LizenzNr As String = "S01122" + Public Property OperatorID As String + Public Property VorgangID As String + Public Property AnmID As String + Public Property Kennung As String + + ' ====== Datenfelder Kopf imDHFAnm (wie geliefert) ====== + Public Property DatenKomplett As Object + Public Property LRN As Object + Public Property TotPack As Object + Public Property TotGross As Object + Public Property Dest As Object + Public Property InMo As Object + Public Property BordMo As Object + Public Property DepIdnt As Object + Public Property DepNat As Object + Public Property CrossIdnt As Object + Public Property CrossIdntNat As Object + Public Property TermDelCd As Object + Public Property TermDelSit As Object + Public Property InvCurr As Object + Public Property InvVal As Object + Public Property ConeeTraNa As Object + Public Property ConeeTraStrt As Object + Public Property ConeeTraPst As Object + Public Property ConeeTraCty As Object + Public Property ConeeTraCtry As Object + Public Property ConeeTraFremdAdressID As Object + Public Property ExitCORef As Object + Public Property RechnungsNr As Object + Public Property RechnungsDatum As Object + Public Property DecTy As Object + Public Property Disp As Object + Public Property ArrLocAuth As Object + Public Property ContInd As Object + Public Property TransacCd As Object + Public Property ConorTraNa As Object + Public Property ConorTraStrt As Object + Public Property ConorTraPst As Object + Public Property ConorTraCty As Object + Public Property ConorTraCtry As Object + Public Property ConorTraFremdAdressID As Object + Public Property KzPool As Object + Public Property ConeeTraUIDCtry As Object + Public Property ConeeTraUID As Object + Public Property EntryCORef As Object + Public Property SendungsDatum As Object + Public Property PDTy As Object + Public Property DRef As Object + Public Property CInf As Object + Public Property Cat As Object + Public Property InfoText As Object + Public Property SendungsNr As Object + Public Property ConorTraUIDCtry As Object + Public Property ConorTraUID As Object + Public Property AnschreibeNr As Object + Public Property RIN As Object + Public Property KzAutomatik As Object + Public Property SecInd As Object + Public Property SpecCirc As Object + Public Property TransPayTy As Object + Public Property ComRef As Object + Public Property LodCoRef As Object + Public Property ResCd As Object + Public Property DLimit As Object + Public Property Route As Object + Public Property SNr As Object + Public Property KzEigenmassenaufteilung As Object + Public Property MusterName As Object + Public Property ConvRef As Object + Public Property ProArrDT As Object + Public Property LoadPlc As Object + Public Property UnloadPlcCd As Object + Public Property UnloadPlc As Object + Public Property FirEntryCoRef As Object + Public Property CarrTraNa As Object + Public Property CarrTraStrt As Object + Public Property CarrTraPst As Object + Public Property CarrTraCty As Object + Public Property CarrTraCtry As Object + Public Property CarrTraFremdAdressID As Object + Public Property NotifyTraNa As Object + Public Property NotifyTraStrt As Object + Public Property NotifyTraPst As Object + Public Property NotifyTraCty As Object + Public Property NotifyTraCtry As Object + Public Property NotifyTraFremdAdressID As Object + Public Property RepTraFremdAdressID As Object + Public Property SumDecTraFremdAdressID As Object + Public Property DecPlc As Object + Public Property DecDT As Object + Public Property RelationsID As Object + Public Property SSt_LizenzNr As Object + Public Property SSt_ID As Object + Public Property SSt_ArtID As Object + Public Property SSt_ProtokollKopfID As Object + Public Property KzPredeclaration As Object + Public Property AccDT As Object + Public Property PayTy As Object + Public Property DepoCd As Object + Public Property WarTy As Object + Public Property WarCtry As Object + Public Property War As Object + Public Property ZLID As Object + Public Property TermDelCtry As Object + Public Property TermDelPlc As Object + + ' ====== Navigation / Unterobjekte ====== + Public Property GdsItems As New List(Of cDHF_Import_GdsItem) + + Private Const TBL As String = "imDHFAnm" + Private ReadOnly SQL As New SQL + + ' ---- Konstruktor (Leeres Objekt) ---- + Public Sub New() + End Sub + + ' ---- Konstruktor mit Schlüssel + Auto-Load ---- + Public Sub New(lizenzNr As String, operatorId As String, vorgangId As String, anmId As String, kennung As String) + Me.LizenzNr = lizenzNr : Me.OperatorID = operatorId : Me.VorgangID = vorgangId : Me.AnmID = anmId : Me.Kennung = kennung + Load() + End Sub + + ' ---- Parameterliste dynamisch erzeugen (PK markiert) ---- + Private Function GetVarList(Optional includePK As Boolean = True) As List(Of VERAG_PROG_ALLGEMEIN.SQLVariable) + Dim l As New List(Of VERAG_PROG_ALLGEMEIN.SQLVariable) + + ' PK + If includePK Then + l.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("LizenzNr", LizenzNr, "LizenzNr", True)) + l.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("OperatorID", OperatorID, "OperatorID", True)) + l.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("VorgangID", VorgangID, "VorgangID", True)) + l.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("AnmID", AnmID, "AnmID", True)) + l.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("Kennung", Kennung, "Kennung", True)) + End If + + ' Alle Felder (Non-PK) + Dim allProps = Me.GetType().GetProperties(BindingFlags.Public Or BindingFlags.Instance). + Where(Function(p) p.CanRead AndAlso p.CanWrite AndAlso p.Name <> NameOf(GdsItems)) + For Each p In allProps + If {"LizenzNr", "OperatorID", "VorgangID", "AnmID", "Kennung"}.Contains(p.Name) Then Continue For + l.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable(p.Name, p.GetValue(Me), p.Name, False)) + Next + Return l + End Function + + ' ---- Save: Upsert + Kinder in Transaktion ---- + Public Function Save() As Boolean + Using conn As SqlConnection = SQL.GetNewOpenConnectionFMZOLL() + Using tr = conn.BeginTransaction() + Try + ' Upsert Kopf + Dim vars = GetVarList(includePK:=True) + Dim wherePk = "WHERE [LizenzNr]=@LizenzNr AND [OperatorID]=@OperatorID AND [VorgangID]=@VorgangID AND [AnmID]=@AnmID AND [Kennung]=@Kennung" + Dim sqlCheck = $"IF EXISTS(SELECT 1 FROM [{TBL}] {wherePk}) BEGIN {_SqlDyn.BuildUpdateCmd(TBL, vars)} END ELSE BEGIN {_SqlDyn.BuildInsertCmd(TBL, vars)} END" + + Using cmd As New SqlCommand(sqlCheck, conn, tr) + _SqlDyn.AddParams(cmd, vars) + cmd.ExecuteNonQuery() + End Using + + ' Kinder neu schreiben: erst löschen, dann einfügen (vereinfachte Konsistenz) + DeleteChildren(conn, tr) + + ' Positionen + Unterpositionen schreiben + For Each it In GdsItems + it.LizenzNr = Me.LizenzNr + it.OperatorID = Me.OperatorID + it.VorgangID = Me.VorgangID + it.AnmID = Me.AnmID + it.Kennung = Me.Kennung + it.Save(conn, tr) + Next + + tr.Commit() + Return True + Catch ex As Exception + tr.Rollback() + VERAG_PROG_ALLGEMEIN.cErrorHandler.ERR(ex.Message, ex.StackTrace, MethodBase.GetCurrentMethod().Name) + Return False + End Try + End Using + End Using + End Function + + Private Sub DeleteChildren(conn As SqlConnection, tr As SqlTransaction) + ' Löscht alle abhängigen Einträge (DocCerts + Pack zuerst, dann GdsItems) + Dim pkWhere = "WHERE [LizenzNr]=@LizenzNr AND [OperatorID]=@OperatorID AND [VorgangID]=@VorgangID AND [AnmID]=@AnmID AND [Kennung]=@Kennung" + Dim delDoc = $"DELETE d FROM [imDHFAnmGdsItemDocCerts] d INNER JOIN [imDHFAnmGdsItem] i ON d.LizenzNr=i.LizenzNr AND d.OperatorID=i.OperatorID AND d.VorgangID=i.VorgangID AND d.AnmID=i.AnmID AND d.Kennung=i.Kennung AND d.GdsItemID=i.GdsItemID {pkWhere.Replace("WHERE", "WHERE i.")}" + Dim delPack = $"DELETE p FROM [imDHFAnmGdsItemPack] p INNER JOIN [imDHFAnmGdsItem] i ON p.LizenzNr=i.LizenzNr AND p.OperatorID=i.OperatorID AND p.VorgangID=i.VorgangID AND p.AnmID=i.AnmID AND p.Kennung=i.Kennung AND p.GdsItemID=i.GdsItemID {pkWhere.Replace("WHERE", "WHERE i.")}" + Dim delIt = $"DELETE FROM [imDHFAnmGdsItem] {pkWhere}" + + Dim pars As New List(Of VERAG_PROG_ALLGEMEIN.SQLVariable) From { + New VERAG_PROG_ALLGEMEIN.SQLVariable("LizenzNr", LizenzNr, "LizenzNr", True), + New VERAG_PROG_ALLGEMEIN.SQLVariable("OperatorID", OperatorID, "OperatorID", True), + New VERAG_PROG_ALLGEMEIN.SQLVariable("VorgangID", VorgangID, "VorgangID", True), + New VERAG_PROG_ALLGEMEIN.SQLVariable("AnmID", AnmID, "AnmID", True), + New VERAG_PROG_ALLGEMEIN.SQLVariable("Kennung", Kennung, "Kennung", True) + } + + For Each s In {delDoc, delPack, delIt} + Using cmd As New SqlCommand(s, conn, tr) + _SqlDyn.AddParams(cmd, pars) + cmd.ExecuteNonQuery() + End Using + Next + End Sub + + ' ---- Load: Kopf + Kinder ---- + Public Sub Load() + Using conn As SqlConnection = SQL.GetNewOpenConnectionFMZOLL() + ' Kopf + Dim selectHead = $"SELECT * FROM [{TBL}] WHERE [LizenzNr]=@LizenzNr AND [OperatorID]=@OperatorID AND [VorgangID]=@VorgangID AND [AnmID]=@AnmID AND [Kennung]=@Kennung" + Using cmd As New SqlCommand(selectHead, conn) + cmd.Parameters.AddWithValue("@LizenzNr", LizenzNr) + cmd.Parameters.AddWithValue("@OperatorID", OperatorID) + cmd.Parameters.AddWithValue("@VorgangID", VorgangID) + cmd.Parameters.AddWithValue("@AnmID", AnmID) + cmd.Parameters.AddWithValue("@Kennung", Kennung) + Using dr = cmd.ExecuteReader() + If dr.Read() Then + _SqlDyn.DataReaderToObject(dr, Me, GetVarList(includePK:=False)) + End If + End Using + End Using + + ' Kinder laden + Me.GdsItems.Clear() + Dim selectIt = "SELECT * FROM [imDHFAnmGdsItem] WHERE [LizenzNr]=@LizenzNr AND [OperatorID]=@OperatorID AND [VorgangID]=@VorgangID AND [AnmID]=@AnmID AND [Kennung]=@Kennung ORDER BY ItNr" + Using cmd As New SqlCommand(selectIt, conn) + cmd.Parameters.AddWithValue("@LizenzNr", LizenzNr) + cmd.Parameters.AddWithValue("@OperatorID", OperatorID) + cmd.Parameters.AddWithValue("@VorgangID", VorgangID) + cmd.Parameters.AddWithValue("@AnmID", AnmID) + cmd.Parameters.AddWithValue("@Kennung", Kennung) + Using dr = cmd.ExecuteReader() + While dr.Read() + Dim it As New cDHF_Import_GdsItem() With { + .LizenzNr = dr("LizenzNr").ToString(), + .OperatorID = dr("OperatorID").ToString(), + .VorgangID = dr("VorgangID").ToString(), + .AnmID = dr("AnmID").ToString(), + .Kennung = dr("Kennung").ToString(), + .GdsItemID = dr("GdsItemID").ToString() + } + it.FillFromReader(dr) + GdsItems.Add(it) + End While + End Using + End Using + + ' Unterobjekte je Position laden + For Each it In GdsItems + it.LoadChildren(conn) + Next + End Using + End Sub +End Class + +' =========================================================== +' =============== POSITION (imDHFAnmGdsItem) =========== +' =========================================================== +Public Class cDHF_Import_GdsItem + ' ====== FK/PK-Teil (Kopfbezug + pos-ID) ====== + Public Property LizenzNr As String + Public Property OperatorID As String + Public Property VorgangID As String + Public Property AnmID As String + Public Property Kennung As String + Public Property GdsItemID As String + + ' ====== Positionsfelder ====== + Public Property ItNr As Object + Public Property ComCd As Object + Public Property GdsDes As Object + Public Property Gross As Object + Public Property Net As Object + Public Property ProcCd As Object + Public Property ProcAddCd As Object + Public Property ItVal As Object + Public Property Orig As Object + Public Property Pref As Object + Public Property Quota As Object + Public Property ValMet As Object + Public Property VATInd As Object + Public Property ArtikelCode As Object + Public Property InfoText As Object + Public Property ArtikelMenge As Object + Public Property ArtikelMengenEH As Object + Public Property RezOrt As Object + Public Property SNr As Object + Public Property ProcTxt As Object + Public Property ComplPer As Object + Public Property ProsYield As Object + Public Property SpecMod As Object + Public Property RecCd As Object + Public Property SurvCORef As Object + Public Property EndCORef As Object + Public Property ComRef As Object + Public Property UNDangCd As Object + Public Property GlobCd As Object + Public Property GlobPer As Object + Public Property CondCd As Object + Public Property TransPayTy As Object + Public Property ConorTraNa As Object + Public Property ConorTraStrt As Object + Public Property ConorTraPst As Object + Public Property ConorTraCty As Object + Public Property ConorTraCtry As Object + Public Property ConorTraTIN As Object + Public Property ConorTraAdressIDDHF As Object + Public Property ConeeTraNa As Object + Public Property ConeeTraStrt As Object + Public Property ConeeTraPst As Object + Public Property ConeeTraCty As Object + Public Property ConeeTraCtry As Object + Public Property ConeeTraTIN As Object + Public Property ConeeTraAdressIDDHF As Object + Public Property ExtraDEBundesland As Object + + ' ====== Unterlisten ====== + Public Property DocCerts As New List(Of cDHF_Import_GdsItemDocCerts) + Public Property Packs As New List(Of cDHF_Import_GdsItemPack) + + Private Const TBL As String = "imDHFAnmGdsItem" + + Friend Sub FillFromReader(dr As SqlDataReader) + Dim props = Me.GetType().GetProperties(BindingFlags.Public Or BindingFlags.Instance). + Where(Function(p) p.CanRead AndAlso p.CanWrite AndAlso p.Name <> NameOf(DocCerts) AndAlso p.Name <> NameOf(Packs)) + For Each p In props + If dr.GetSchemaTable().Rows.Cast(Of DataRow)().Any(Function(r) r("ColumnName").ToString() = p.Name) Then + If dr.IsDBNull(dr.GetOrdinal(p.Name)) Then + p.SetValue(Me, Nothing) + Else + p.SetValue(Me, dr(p.Name)) + End If + End If + Next + End Sub + + Private Function GetVarList(Optional includePK As Boolean = True) As List(Of VERAG_PROG_ALLGEMEIN.SQLVariable) + Dim l As New List(Of VERAG_PROG_ALLGEMEIN.SQLVariable) + If includePK Then + l.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("LizenzNr", LizenzNr, "LizenzNr", True)) + l.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("OperatorID", OperatorID, "OperatorID", True)) + l.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("VorgangID", VorgangID, "VorgangID", True)) + l.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("AnmID", AnmID, "AnmID", True)) + l.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("Kennung", Kennung, "Kennung", True)) + l.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("GdsItemID", GdsItemID, "GdsItemID", True)) + End If + + Dim skip = New HashSet(Of String)(StringComparer.OrdinalIgnoreCase) From { + "LizenzNr", "OperatorID", "VorgangID", "AnmID", "Kennung", "GdsItemID", + NameOf(DocCerts), NameOf(Packs) + } + For Each p In Me.GetType().GetProperties(BindingFlags.Public Or BindingFlags.Instance) + If Not p.CanRead OrElse Not p.CanWrite OrElse skip.Contains(p.Name) Then Continue For + l.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable(p.Name, p.GetValue(Me), p.Name, False)) + Next + Return l + End Function + + Friend Sub Save(conn As SqlConnection, tr As SqlTransaction) + ' Upsert Position + Dim vars = GetVarList(includePK:=True) + Dim wherePk = "WHERE [LizenzNr]=@LizenzNr AND [OperatorID]=@OperatorID AND [VorgangID]=@VorgangID AND [AnmID]=@AnmID AND [Kennung]=@Kennung AND [GdsItemID]=@GdsItemID" + Dim sqlCheck = $"IF EXISTS(SELECT 1 FROM [{TBL}] {wherePk}) BEGIN {_SqlDyn.BuildUpdateCmd(TBL, vars)} END ELSE BEGIN {_SqlDyn.BuildInsertCmd(TBL, vars)} END" + Using cmd As New SqlCommand(sqlCheck, conn, tr) + _SqlDyn.AddParams(cmd, vars) + cmd.ExecuteNonQuery() + End Using + + ' Kinder neu schreiben (DocCerts, Packs): delete + insert + DeleteChildren(conn, tr) + + For Each d In DocCerts + d.LizenzNr = LizenzNr : d.OperatorID = OperatorID : d.VorgangID = VorgangID : d.AnmID = AnmID : d.Kennung = Kennung + d.GdsItemID = GdsItemID + d.Save(conn, tr) + Next + For Each p In Packs + p.LizenzNr = LizenzNr : p.OperatorID = OperatorID : p.VorgangID = VorgangID : p.AnmID = AnmID : p.Kennung = Kennung + p.GdsItemID = GdsItemID + p.Save(conn, tr) + Next + End Sub + + Private Sub DeleteChildren(conn As SqlConnection, tr As SqlTransaction) + Dim wherePk = "WHERE [LizenzNr]=@LizenzNr AND [OperatorID]=@OperatorID AND [VorgangID]=@VorgangID AND [AnmID]=@AnmID AND [Kennung]=@Kennung AND [GdsItemID]=@GdsItemID" + For Each ttt In {"imDHFAnmGdsItemDocCerts", "imDHFAnmGdsItemPack"} + Using cmd As New SqlCommand($"DELETE FROM [{ttt}] {wherePk}", conn, tr) + cmd.Parameters.AddWithValue("@LizenzNr", LizenzNr) + cmd.Parameters.AddWithValue("@OperatorID", OperatorID) + cmd.Parameters.AddWithValue("@VorgangID", VorgangID) + cmd.Parameters.AddWithValue("@AnmID", AnmID) + cmd.Parameters.AddWithValue("@Kennung", Kennung) + cmd.Parameters.AddWithValue("@GdsItemID", GdsItemID) + cmd.ExecuteNonQuery() + End Using + Next + End Sub + + Friend Sub LoadChildren(conn As SqlConnection) + ' DocCerts + DocCerts.Clear() + Dim sDoc = "SELECT * FROM [imDHFAnmGdsItemDocCerts] WHERE [LizenzNr]=@LizenzNr AND [OperatorID]=@OperatorID AND [VorgangID]=@VorgangID AND [AnmID]=@AnmID AND [Kennung]=@Kennung AND [GdsItemID]=@GdsItemID ORDER BY DocCertsID" + Using cmd As New SqlCommand(sDoc, conn) + cmd.Parameters.AddWithValue("@LizenzNr", LizenzNr) + cmd.Parameters.AddWithValue("@OperatorID", OperatorID) + cmd.Parameters.AddWithValue("@VorgangID", VorgangID) + cmd.Parameters.AddWithValue("@AnmID", AnmID) + cmd.Parameters.AddWithValue("@Kennung", Kennung) + cmd.Parameters.AddWithValue("@GdsItemID", GdsItemID) + Using dr = cmd.ExecuteReader() + While dr.Read() + Dim d As New cDHF_Import_GdsItemDocCerts() With { + .LizenzNr = LizenzNr, .OperatorID = OperatorID, .VorgangID = VorgangID, + .AnmID = AnmID, .Kennung = Kennung, .GdsItemID = GdsItemID, + .DocCertsID = dr("DocCertsID").ToString() + } + d.FillFromReader(dr) + DocCerts.Add(d) + End While + End Using + End Using + + ' Packs + Packs.Clear() + Dim sPack = "SELECT * FROM [imDHFAnmGdsItemPack] WHERE [LizenzNr]=@LizenzNr AND [OperatorID]=@OperatorID AND [VorgangID]=@VorgangID AND [AnmID]=@AnmID AND [Kennung]=@Kennung AND [GdsItemID]=@GdsItemID ORDER BY PackID" + Using cmd As New SqlCommand(sPack, conn) + cmd.Parameters.AddWithValue("@LizenzNr", LizenzNr) + cmd.Parameters.AddWithValue("@OperatorID", OperatorID) + cmd.Parameters.AddWithValue("@VorgangID", VorgangID) + cmd.Parameters.AddWithValue("@AnmID", AnmID) + cmd.Parameters.AddWithValue("@Kennung", Kennung) + cmd.Parameters.AddWithValue("@GdsItemID", GdsItemID) + Using dr = cmd.ExecuteReader() + While dr.Read() + Dim p As New cDHF_Import_GdsItemPack() With { + .LizenzNr = LizenzNr, .OperatorID = OperatorID, .VorgangID = VorgangID, + .AnmID = AnmID, .Kennung = Kennung, .GdsItemID = GdsItemID, + .PackID = dr("PackID").ToString() + } + p.FillFromReader(dr) + Packs.Add(p) + End While + End Using + End Using + End Sub +End Class + +' =========================================================== +' ============ DOC/CERTS (imDHFAnmGdsItemDocCerts) ===== +' =========================================================== +Public Class cDHF_Import_GdsItemDocCerts + ' FK/PK + Public Property LizenzNr As String + Public Property OperatorID As String + Public Property VorgangID As String + Public Property AnmID As String + Public Property Kennung As String + Public Property GdsItemID As String + Public Property DocCertsID As String + + ' Felder + Public Property DocCd As Object + Public Property DTy As Object + Public Property DRef As Object + Public Property IssD As Object + Public Property IssCtry As Object + Public Property DTIN As Object + Public Property Curr As Object + Public Property Avail As Object + Public Property UidVid As Object + Public Property IssAdm As Object + Public Property ValD As Object + Public Property MaxValD As Object + Public Property CInf As Object + Public Property InfoLNG As Object + Public Property Unit As Object + Public Property Quant As Object + Public Property MaxQuant As Object + Public Property WOUnit As Object + Public Property WOoUnit As Object + Public Property WOCurr As Object + Public Property WOInQuant As Object + Public Property WOQuant As Object + Public Property WORemQunat As Object + Public Property CRefTy As Object + Public Property CRefRef As Object + Public Property CRefIt As Object + Public Property CRefLNG As Object + Public Property AvailDT As Object + Public Property AdressIDDHF As Object + Public Property Na As Object + Public Property Strt As Object + Public Property Pst As Object + Public Property Cty As Object + Public Property Ctry As Object + Public Property LNG As Object + + Private Const TBL As String = "imDHFAnmGdsItemDocCerts" + + Private Function GetVarList(Optional includePK As Boolean = True) As List(Of VERAG_PROG_ALLGEMEIN.SQLVariable) + Dim l As New List(Of VERAG_PROG_ALLGEMEIN.SQLVariable) + If includePK Then + l.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("LizenzNr", LizenzNr, "LizenzNr", True)) + l.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("OperatorID", OperatorID, "OperatorID", True)) + l.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("VorgangID", VorgangID, "VorgangID", True)) + l.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("AnmID", AnmID, "AnmID", True)) + l.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("Kennung", Kennung, "Kennung", True)) + l.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("GdsItemID", GdsItemID, "GdsItemID", True)) + l.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("DocCertsID", DocCertsID, "DocCertsID", True)) + End If + + Dim skip = New HashSet(Of String)(StringComparer.OrdinalIgnoreCase) From { + "LizenzNr", "OperatorID", "VorgangID", "AnmID", "Kennung", "GdsItemID", "DocCertsID" + } + For Each p In Me.GetType().GetProperties(BindingFlags.Public Or BindingFlags.Instance) + If Not p.CanRead OrElse Not p.CanWrite OrElse skip.Contains(p.Name) Then Continue For + l.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable(p.Name, p.GetValue(Me), p.Name, False)) + Next + Return l + End Function + + Friend Sub Save(conn As SqlConnection, tr As SqlTransaction) + Dim vars = GetVarList(includePK:=True) + Dim wherePk = "WHERE [LizenzNr]=@LizenzNr AND [OperatorID]=@OperatorID AND [VorgangID]=@VorgangID AND [AnmID]=@AnmID AND [Kennung]=@Kennung AND [GdsItemID]=@GdsItemID AND [DocCertsID]=@DocCertsID" + Dim sqlCheck = $"IF EXISTS(SELECT 1 FROM [{TBL}] {wherePk}) BEGIN {_SqlDyn.BuildUpdateCmd(TBL, vars)} END ELSE BEGIN {_SqlDyn.BuildInsertCmd(TBL, vars)} END" + Using cmd As New SqlCommand(sqlCheck, conn, tr) + _SqlDyn.AddParams(cmd, vars) + cmd.ExecuteNonQuery() + End Using + End Sub + + Friend Sub FillFromReader(dr As SqlDataReader) + Dim props = Me.GetType().GetProperties(BindingFlags.Public Or BindingFlags.Instance) + For Each p In props + If {"LizenzNr", "OperatorID", "VorgangID", "AnmID", "Kennung", "GdsItemID", "DocCertsID"}.Contains(p.Name) Then Continue For + If dr.GetSchemaTable().Rows.Cast(Of DataRow)().Any(Function(r) r("ColumnName").ToString() = p.Name) Then + If dr.IsDBNull(dr.GetOrdinal(p.Name)) Then + p.SetValue(Me, Nothing) + Else + p.SetValue(Me, dr(p.Name)) + End If + End If + Next + End Sub +End Class + +' =========================================================== +' ================ PACK (imDHFAnmGdsItemPack) ========== +' =========================================================== +Public Class cDHF_Import_GdsItemPack + ' FK/PK + Public Property LizenzNr As String + Public Property OperatorID As String + Public Property VorgangID As String + Public Property AnmID As String + Public Property Kennung As String + Public Property GdsItemID As String + Public Property PackID As String + + ' Felder + Public Property Mark As Object + Public Property Kind As Object + Public Property Nr As Object + Public Property Piec As Object + + Private Const TBL As String = "imDHFAnmGdsItemPack" + + Private Function GetVarList(Optional includePK As Boolean = True) As List(Of VERAG_PROG_ALLGEMEIN.SQLVariable) + Dim l As New List(Of VERAG_PROG_ALLGEMEIN.SQLVariable) + If includePK Then + l.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("LizenzNr", LizenzNr, "LizenzNr", True)) + l.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("OperatorID", OperatorID, "OperatorID", True)) + l.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("VorgangID", VorgangID, "VorgangID", True)) + l.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("AnmID", AnmID, "AnmID", True)) + l.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("Kennung", Kennung, "Kennung", True)) + l.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("GdsItemID", GdsItemID, "GdsItemID", True)) + l.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("PackID", PackID, "PackID", True)) + End If + + Dim skip = New HashSet(Of String)(StringComparer.OrdinalIgnoreCase) From { + "LizenzNr", "OperatorID", "VorgangID", "AnmID", "Kennung", "GdsItemID", "PackID" + } + For Each p In Me.GetType().GetProperties(BindingFlags.Public Or BindingFlags.Instance) + If Not p.CanRead OrElse Not p.CanWrite OrElse skip.Contains(p.Name) Then Continue For + l.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable(p.Name, p.GetValue(Me), p.Name, False)) + Next + Return l + End Function + + Friend Sub Save(conn As SqlConnection, tr As SqlTransaction) + Dim vars = GetVarList(includePK:=True) + Dim wherePk = "WHERE [LizenzNr]=@LizenzNr AND [OperatorID]=@OperatorID AND [VorgangID]=@VorgangID AND [AnmID]=@AnmID AND [Kennung]=@Kennung AND [GdsItemID]=@GdsItemID AND [PackID]=@PackID" + Dim sqlCheck = $"IF EXISTS(SELECT 1 FROM [{TBL}] {wherePk}) BEGIN {_SqlDyn.BuildUpdateCmd(TBL, vars)} END ELSE BEGIN {_SqlDyn.BuildInsertCmd(TBL, vars)} END" + Using cmd As New SqlCommand(sqlCheck, conn, tr) + _SqlDyn.AddParams(cmd, vars) + cmd.ExecuteNonQuery() + End Using + End Sub + + Friend Sub FillFromReader(dr As SqlDataReader) + Dim props = Me.GetType().GetProperties(BindingFlags.Public Or BindingFlags.Instance) + For Each p In props + If {"LizenzNr", "OperatorID", "VorgangID", "AnmID", "Kennung", "GdsItemID", "PackID"}.Contains(p.Name) Then Continue For + If dr.GetSchemaTable().Rows.Cast(Of DataRow)().Any(Function(r) r("ColumnName").ToString() = p.Name) Then + If dr.IsDBNull(dr.GetOrdinal(p.Name)) Then + p.SetValue(Me, Nothing) + Else + p.SetValue(Me, dr(p.Name)) + End If + End If + Next + End Sub + + +End Class + + +' ----------------------------------------------- +' Gemeinsame Utilities für dynamische SQLs nach dem Muster aus _BASE +' ----------------------------------------------- +Friend Module _SqlDyn + Friend Function BuildUpdateCmd(tableName As String, vars As List(Of VERAG_PROG_ALLGEMEIN.SQLVariable)) As String + Dim sets As New List(Of String) + Dim wheres As New List(Of String) + For Each v In vars + If v.isPrimaryParam Then + wheres.Add("[" & v.Text & "] = @" & v.Scalarvariable) + Else + sets.Add("[" & v.Text & "] = @" & v.Scalarvariable) + End If + Next + If sets.Count = 0 Then Throw New Exception("Keine Non-PK-Spalten für UPDATE.") + Return $"UPDATE [{tableName}] SET {String.Join(",", sets)} WHERE {String.Join(" AND ", wheres)}" + End Function + + Friend Function BuildInsertCmd(tableName As String, vars As List(Of VERAG_PROG_ALLGEMEIN.SQLVariable)) As String + Dim cols As New List(Of String) + Dim pars As New List(Of String) + For Each v In vars + If Not v.isPrimaryParam Then + cols.Add("[" & v.Text & "]") + pars.Add("@" & v.Scalarvariable) + Else + ' PK-Spalten oft ebenfalls explizit spaltenseitig – hier mit aufnehmen, + ' sofern in DB nicht als IDENTITY definiert: + cols.Add("[" & v.Text & "]") + pars.Add("@" & v.Scalarvariable) + End If + Next + Return $"INSERT INTO [{tableName}] ({String.Join(",", cols)}) VALUES({String.Join(",", pars)})" + End Function + + Friend Sub AddParams(cmd As SqlCommand, vars As List(Of VERAG_PROG_ALLGEMEIN.SQLVariable)) + For Each v In vars + cmd.Parameters.AddWithValue("@" & v.Scalarvariable, If(v.Value, DBNull.Value)) + Next + End Sub + + Friend Sub DataReaderToObject(dr As SqlDataReader, target As Object, vars As List(Of VERAG_PROG_ALLGEMEIN.SQLVariable)) + Dim t = target.GetType() + For Each v In vars + Dim pi = t.GetProperty(v.Text) + If pi IsNot Nothing AndAlso Not dr.IsDBNull(dr.GetOrdinal(v.Text)) Then + pi.SetValue(target, dr(v.Text)) + ElseIf pi IsNot Nothing Then + pi.SetValue(target, Nothing) + End If + Next + End Sub + + + Sub test() + + '' Verwendung(Beispiel) + + ' Kopf anlegen + Dim imp As New cDHF_Import("LIC", "OP", "VORG", "ANM", "KENN") + imp.RechnungsNr = "INV-2025-001" + imp.InvCurr = "EUR" + imp.InvVal = 12345D + + ' Position hinzufügen + Dim it = New cDHF_Import_GdsItem() With { + .GdsItemID = "1", + .ItNr = 1, + .ComCd = "85044030", + .GdsDes = "Power Supply", + .Net = 12.34D, + .ItVal = 999D + } + ' Doc/Certs + it.DocCerts.Add(New cDHF_Import_GdsItemDocCerts() With { + .DocCertsID = "1", + .DocCd = "N380", + .DRef = "REF-123", + .Avail = 1 + }) + ' Packstücke + it.Packs.Add(New cDHF_Import_GdsItemPack() With { + .PackID = "1", + .Kind = "PK", + .Piec = 3 + }) + + imp.GdsItems.Add(it) + + ' Speichern -> speichert Kopf + Position + Unterzeilen in einer Transaktion + Dim ok = imp.Save() + + ' Laden + Dim imp2 As New cDHF_Import("S01122", "1", "VORG", "ANM", "KENN") + ' -> imp2 ist nun inkl. GdsItems, DocCerts und Packs befüllt + + End Sub +End Module diff --git a/VERAG_PROG_ALLGEMEIN/VERAG_PROG_ALLGEMEIN.vbproj b/VERAG_PROG_ALLGEMEIN/VERAG_PROG_ALLGEMEIN.vbproj index 40ee4b14..7f3feeb3 100644 --- a/VERAG_PROG_ALLGEMEIN/VERAG_PROG_ALLGEMEIN.vbproj +++ b/VERAG_PROG_ALLGEMEIN/VERAG_PROG_ALLGEMEIN.vbproj @@ -396,6 +396,7 @@ +