CBAM, VERAG CustomsDec

This commit is contained in:
2026-01-01 11:12:58 +01:00
parent ddb99e931d
commit 2187035214
6 changed files with 1051 additions and 892 deletions

View File

@@ -68,6 +68,8 @@ Partial Class usrCntlCBAM
Me.Button3 = New System.Windows.Forms.Button() Me.Button3 = New System.Windows.Forms.Button()
Me.lblKafkaCnt = New System.Windows.Forms.Label() Me.lblKafkaCnt = New System.Windows.Forms.Label()
Me.Panel1 = New System.Windows.Forms.Panel() Me.Panel1 = New System.Windows.Forms.Panel()
Me.txtBenchmark = New VERAG_PROG_ALLGEMEIN.MyTextBox()
Me.Label12 = New System.Windows.Forms.Label()
Me.txtCalcLand = New VERAG_PROG_ALLGEMEIN.MyTextBox() Me.txtCalcLand = New VERAG_PROG_ALLGEMEIN.MyTextBox()
Me.txtCalcErg = New VERAG_PROG_ALLGEMEIN.MyTextBox() Me.txtCalcErg = New VERAG_PROG_ALLGEMEIN.MyTextBox()
Me.Button4 = New System.Windows.Forms.Button() Me.Button4 = New System.Windows.Forms.Button()
@@ -89,8 +91,7 @@ Partial Class usrCntlCBAM
Me.txtVon = New VERAG_PROG_ALLGEMEIN.MyTextBox() Me.txtVon = New VERAG_PROG_ALLGEMEIN.MyTextBox()
Me.txtBis = New VERAG_PROG_ALLGEMEIN.MyTextBox() Me.txtBis = New VERAG_PROG_ALLGEMEIN.MyTextBox()
Me.txtEori = New VERAG_PROG_ALLGEMEIN.MyTextBox() Me.txtEori = New VERAG_PROG_ALLGEMEIN.MyTextBox()
Me.txtBenchmark = New VERAG_PROG_ALLGEMEIN.MyTextBox() Me.Button5 = New System.Windows.Forms.Button()
Me.Label12 = New System.Windows.Forms.Label()
Me.cntxtAddSdl.SuspendLayout() Me.cntxtAddSdl.SuspendLayout()
Me.Panel1.SuspendLayout() Me.Panel1.SuspendLayout()
Me.MyPanel1.SuspendLayout() Me.MyPanel1.SuspendLayout()
@@ -631,6 +632,39 @@ Partial Class usrCntlCBAM
Me.Panel1.Size = New System.Drawing.Size(223, 331) Me.Panel1.Size = New System.Drawing.Size(223, 331)
Me.Panel1.TabIndex = 52 Me.Panel1.TabIndex = 52
' '
'txtBenchmark
'
Me.txtBenchmark._DateTimeOnly = False
Me.txtBenchmark._numbersOnly = True
Me.txtBenchmark._numbersOnlyKommastellen = ""
Me.txtBenchmark._numbersOnlyTrennzeichen = True
Me.txtBenchmark._Prozent = False
Me.txtBenchmark._ShortDateNew = False
Me.txtBenchmark._ShortDateOnly = False
Me.txtBenchmark._TimeOnly = False
Me.txtBenchmark._TimeOnly_Seconds = False
Me.txtBenchmark._value = ""
Me.txtBenchmark._Waehrung = False
Me.txtBenchmark._WaehrungZeichen = True
Me.txtBenchmark.ForeColor = System.Drawing.Color.Black
Me.txtBenchmark.Location = New System.Drawing.Point(73, 82)
Me.txtBenchmark.MaxLength = 10
Me.txtBenchmark.MaxLineLength = -1
Me.txtBenchmark.MaxLines_Warning = ""
Me.txtBenchmark.MaxLines_Warning_Label = Nothing
Me.txtBenchmark.Name = "txtBenchmark"
Me.txtBenchmark.Size = New System.Drawing.Size(147, 20)
Me.txtBenchmark.TabIndex = 66
'
'Label12
'
Me.Label12.AutoSize = True
Me.Label12.Location = New System.Drawing.Point(3, 85)
Me.Label12.Name = "Label12"
Me.Label12.Size = New System.Drawing.Size(67, 13)
Me.Label12.TabIndex = 67
Me.Label12.Text = "(Benchmark)"
'
'txtCalcLand 'txtCalcLand
' '
Me.txtCalcLand._DateTimeOnly = False Me.txtCalcLand._DateTimeOnly = False
@@ -982,44 +1016,22 @@ Partial Class usrCntlCBAM
Me.txtEori.Size = New System.Drawing.Size(341, 20) Me.txtEori.Size = New System.Drawing.Size(341, 20)
Me.txtEori.TabIndex = 1 Me.txtEori.TabIndex = 1
' '
'txtBenchmark 'Button5
' '
Me.txtBenchmark._DateTimeOnly = False Me.Button5.FlatStyle = System.Windows.Forms.FlatStyle.Flat
Me.txtBenchmark._numbersOnly = True Me.Button5.Location = New System.Drawing.Point(32, 90)
Me.txtBenchmark._numbersOnlyKommastellen = "" Me.Button5.Name = "Button5"
Me.txtBenchmark._numbersOnlyTrennzeichen = True Me.Button5.Size = New System.Drawing.Size(68, 37)
Me.txtBenchmark._Prozent = False Me.Button5.TabIndex = 53
Me.txtBenchmark._ShortDateNew = False Me.Button5.Text = "test"
Me.txtBenchmark._ShortDateOnly = False Me.Button5.UseVisualStyleBackColor = True
Me.txtBenchmark._TimeOnly = False
Me.txtBenchmark._TimeOnly_Seconds = False
Me.txtBenchmark._value = ""
Me.txtBenchmark._Waehrung = False
Me.txtBenchmark._WaehrungZeichen = True
Me.txtBenchmark.ForeColor = System.Drawing.Color.Black
Me.txtBenchmark.Location = New System.Drawing.Point(73, 82)
Me.txtBenchmark.MaxLength = 10
Me.txtBenchmark.MaxLineLength = -1
Me.txtBenchmark.MaxLines_Warning = ""
Me.txtBenchmark.MaxLines_Warning_Label = Nothing
Me.txtBenchmark.Name = "txtBenchmark"
Me.txtBenchmark.Size = New System.Drawing.Size(147, 20)
Me.txtBenchmark.TabIndex = 66
'
'Label12
'
Me.Label12.AutoSize = True
Me.Label12.Location = New System.Drawing.Point(3, 85)
Me.Label12.Name = "Label12"
Me.Label12.Size = New System.Drawing.Size(67, 13)
Me.Label12.TabIndex = 67
Me.Label12.Text = "(Benchmark)"
' '
'usrCntlCBAM 'usrCntlCBAM
' '
Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!) Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!)
Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
Me.BackColor = System.Drawing.Color.White Me.BackColor = System.Drawing.Color.White
Me.Controls.Add(Me.Button5)
Me.Controls.Add(Me.Panel1) Me.Controls.Add(Me.Panel1)
Me.Controls.Add(Me.lblKafkaCnt) Me.Controls.Add(Me.lblKafkaCnt)
Me.Controls.Add(Me.Button3) Me.Controls.Add(Me.Button3)
@@ -1149,4 +1161,5 @@ Partial Class usrCntlCBAM
Friend WithEvents txtCalcLand As VERAG_PROG_ALLGEMEIN.MyTextBox Friend WithEvents txtCalcLand As VERAG_PROG_ALLGEMEIN.MyTextBox
Friend WithEvents txtBenchmark As VERAG_PROG_ALLGEMEIN.MyTextBox Friend WithEvents txtBenchmark As VERAG_PROG_ALLGEMEIN.MyTextBox
Friend WithEvents Label12 As Label Friend WithEvents Label12 As Label
Friend WithEvents Button5 As Button
End Class End Class

View File

@@ -18,6 +18,57 @@ Public Class usrCntlCBAM
Me.kdnr = kdNr Me.kdnr = kdNr
End Sub End Sub
Public Function CountCBAMTariffNumbersBySystemAndEORI(systemName As String, eori As String, dateFrom As Date, dateTo As Date) As Integer
' ------------------------------------------------------------
' CBAM-Pattern WHERE-Clause (HSCode)
' ------------------------------------------------------------
Dim cbamWhere As String =
VERAG_PROG_ALLGEMEIN.cGreendeal_CBAM_Trn.BuildCBAMPatternWhereClause("i.zaItem_HSCode")
' ------------------------------------------------------------
' SQL
' ------------------------------------------------------------
Dim sql As String =
"SELECT COUNT(distinct(z.Za_MRN)) AS Cnt " &
"FROM VERAG.dbo.tblVERAG_CustomsDeclarations z " &
"INNER JOIN VERAG.dbo.tblVERAG_CustomsDeclarations_Items i " &
" ON z.za_Id = i.zaItem_zaId " &
"INNER JOIN VERAG.dbo.tblVERAG_CustomsDeclarations_Parties p " &
" ON z.za_Id = p.zaParty_zaId " &
"WHERE z.za_System = @sys " &
" AND z.za_REGIME = 'IMPORT' " &
" AND z.za_IsFinalDeclaration = 1 " &
" AND z.za_DeclarationDate >= @dateFrom " &
" AND z.za_DeclarationDate <= @dateTo " &
" AND p.zaParty_EORI = @eori " &
" AND " & cbamWhere
' ------------------------------------------------------------
' Parameter
' ------------------------------------------------------------
Dim p As New List(Of VERAG_PROG_ALLGEMEIN.SQLVariable) From {
New VERAG_PROG_ALLGEMEIN.SQLVariable("sys", systemName),
New VERAG_PROG_ALLGEMEIN.SQLVariable("eori", eori),
New VERAG_PROG_ALLGEMEIN.SQLVariable("dateFrom", dateFrom),
New VERAG_PROG_ALLGEMEIN.SQLVariable("dateTo", dateTo)
}
' ------------------------------------------------------------
' Execute
' ------------------------------------------------------------
Dim dt As DataTable =
New VERAG_PROG_ALLGEMEIN.SQL().
loadDgvBySql_Param(sql, "VERAG", , p)
If dt Is Nothing OrElse dt.Rows.Count = 0 OrElse IsDBNull(dt.Rows(0)("Cnt")) Then
Return 0
End If
Return Convert.ToInt32(dt.Rows(0)("Cnt"))
End Function
Private Sub btnCBAMPruef_DAKOSY_Click(sender As Object, e As EventArgs) Handles btnCBAMPruef_DAKOSY.Click Private Sub btnCBAMPruef_DAKOSY_Click(sender As Object, e As EventArgs) Handles btnCBAMPruef_DAKOSY.Click
txtCBAMPruef_DAKOSY.Text = "-" txtCBAMPruef_DAKOSY.Text = "-"
@@ -36,8 +87,8 @@ Public Class usrCntlCBAM
Dim SQLSTR = " Dim SQLSTR = "
SELECT COUNT(distinct(Registriernummer_MRN)) FROM [tbl_DY_Zollmeldungen_Import] SELECT COUNT(distinct(Registriernummer_MRN)) FROM [tbl_DY_Zollmeldungen_Import]
where Überlassungsdatum between '" & txtVon._value & "' and '" & txtBis._value & "' where Überlassungsdatum between '" & txtVon._value & "' and '" & txtBis._value & "'
and and " & VERAG_PROG_ALLGEMEIN.cGreendeal_CBAM_Trn.BuildCBAMPatternWhereClause("Warentarifnummer") & "
( /* (
left(Warentarifnummer,4) IN (2523,2716,2808,2814,3102,3105,7201,7203,7318,7326,7601,7616) left(Warentarifnummer,4) IN (2523,2716,2808,2814,3102,3105,7201,7203,7318,7326,7601,7616)
OR left(Warentarifnummer,4) between 7301 and 7311 OR left(Warentarifnummer,4) between 7301 and 7311
OR left(Warentarifnummer,4) between 7205 and 7229 OR left(Warentarifnummer,4) between 7205 and 7229
@@ -52,7 +103,7 @@ Public Class usrCntlCBAM
OR Warentarifnummer like '720260%' OR Warentarifnummer like '720260%'
OR Warentarifnummer like '280410%' OR Warentarifnummer like '280410%'
) )
and Warentarifnummer not like '310560%' and Warentarifnummer not like '310560%'*/
" "
@@ -181,8 +232,8 @@ Public Class usrCntlCBAM
inner join zsAnmDeclarant on zsAnmHea.LizenzNr=zsAnmDeclarant.LizenzNr and zsAnmHea.AnmID=zsAnmDeclarant.AnmID and zsAnmHea.VorgangID=zsAnmDeclarant.VorgangID and zsAnmHea.OperatorID=zsAnmDeclarant.OperatorID inner join zsAnmDeclarant on zsAnmHea.LizenzNr=zsAnmDeclarant.LizenzNr and zsAnmHea.AnmID=zsAnmDeclarant.AnmID and zsAnmHea.VorgangID=zsAnmDeclarant.VorgangID and zsAnmHea.OperatorID=zsAnmDeclarant.OperatorID
inner join zsAnmTransp on zsAnmHea.LizenzNr=zsAnmTransp.LizenzNr and zsAnmHea.AnmID=zsAnmTransp.AnmID and zsAnmHea.VorgangID=zsAnmTransp.VorgangID and zsAnmHea.OperatorID=zsAnmTransp.OperatorID inner join zsAnmTransp on zsAnmHea.LizenzNr=zsAnmTransp.LizenzNr and zsAnmHea.AnmID=zsAnmTransp.AnmID and zsAnmHea.VorgangID=zsAnmTransp.VorgangID and zsAnmHea.OperatorID=zsAnmTransp.OperatorID
where DecDT between '" & txtVon._value & "' and '" & txtBis._value & "' where DecDT between '" & txtVon._value & "' and '" & txtBis._value & "'
and and " & VERAG_PROG_ALLGEMEIN.cGreendeal_CBAM_Trn.BuildCBAMPatternWhereClause("ComCd") & "
( /* (
left(ComCd,4) IN (2523,2716,2808,2814,3102,3105,7201,7203,7318,7326,7601,7616) left(ComCd,4) IN (2523,2716,2808,2814,3102,3105,7201,7203,7318,7326,7601,7616)
OR left(ComCd,4) between 7301 and 7311 OR left(ComCd,4) between 7301 and 7311
OR left(ComCd,4) between 7205 and 7229 OR left(ComCd,4) between 7205 and 7229
@@ -197,7 +248,7 @@ Public Class usrCntlCBAM
OR ComCd like '720260%' OR ComCd like '720260%'
OR ComCd like '280410%' OR ComCd like '280410%'
) )
and ComCd not like '310560%' and ComCd not like '310560%' */
and crn is not null and crn is not null
and zsAnmDHFRefs.ErledigungsTypID like 'F%' and zsAnmDHFRefs.ErledigungsTypID like 'F%'
" "
@@ -246,8 +297,8 @@ Public Class usrCntlCBAM
inner join zsAnmDeclarant on zsAnmHea.LizenzNr=zsAnmDeclarant.LizenzNr and zsAnmHea.AnmID=zsAnmDeclarant.AnmID and zsAnmHea.VorgangID=zsAnmDeclarant.VorgangID and zsAnmHea.OperatorID=zsAnmDeclarant.OperatorID inner join zsAnmDeclarant on zsAnmHea.LizenzNr=zsAnmDeclarant.LizenzNr and zsAnmHea.AnmID=zsAnmDeclarant.AnmID and zsAnmHea.VorgangID=zsAnmDeclarant.VorgangID and zsAnmHea.OperatorID=zsAnmDeclarant.OperatorID
inner join zsAnmTransp on zsAnmHea.LizenzNr=zsAnmTransp.LizenzNr and zsAnmHea.AnmID=zsAnmTransp.AnmID and zsAnmHea.VorgangID=zsAnmTransp.VorgangID and zsAnmHea.OperatorID=zsAnmTransp.OperatorID inner join zsAnmTransp on zsAnmHea.LizenzNr=zsAnmTransp.LizenzNr and zsAnmHea.AnmID=zsAnmTransp.AnmID and zsAnmHea.VorgangID=zsAnmTransp.VorgangID and zsAnmHea.OperatorID=zsAnmTransp.OperatorID
where DecDT between '" & txtVon._value & "' and '" & txtBis._value & "' where DecDT between '" & txtVon._value & "' and '" & txtBis._value & "'
and and " & VERAG_PROG_ALLGEMEIN.cGreendeal_CBAM_Trn.BuildCBAMPatternWhereClause("ComCd") & "
( /*(
left(ComCd,4) IN (2523,2716,2808,2814,3102,3105,7201,7203,7318,7326,7601,7616) left(ComCd,4) IN (2523,2716,2808,2814,3102,3105,7201,7203,7318,7326,7601,7616)
OR left(ComCd,4) between 7301 and 7311 OR left(ComCd,4) between 7301 and 7311
OR left(ComCd,4) between 7205 and 7229 OR left(ComCd,4) between 7205 and 7229
@@ -262,7 +313,7 @@ Public Class usrCntlCBAM
OR ComCd like '720260%' OR ComCd like '720260%'
OR ComCd like '280410%' OR ComCd like '280410%'
) )
and ComCd not like '310560%' and ComCd not like '310560%' */
and crn is not null and crn is not null
and zsAnmDHFRefs.ErledigungsTypID like 'F%' and zsAnmDHFRefs.ErledigungsTypID like 'F%'
" "
@@ -316,8 +367,8 @@ Public Class usrCntlCBAM
where 1=1 where 1=1
and and " & VERAG_PROG_ALLGEMEIN.cGreendeal_CBAM_Trn.BuildCBAMPatternWhereClause("Item_ComCd") & "
( /* (
left(Item_ComCd,4) IN (2523,2716,2808,2814,3102,3105,7201,7203,7318,7326,7601,7616) left(Item_ComCd,4) IN (2523,2716,2808,2814,3102,3105,7201,7203,7318,7326,7601,7616)
OR left(Item_ComCd,4) between 7301 and 7311 OR left(Item_ComCd,4) between 7301 and 7311
OR left(Item_ComCd,4) between 7205 and 7229 OR left(Item_ComCd,4) between 7205 and 7229
@@ -332,7 +383,7 @@ Public Class usrCntlCBAM
OR Item_ComCd like '720260%' OR Item_ComCd like '720260%'
OR Item_ComCd like '280410%' OR Item_ComCd like '280410%'
) )
and Item_ComCd not like '310560%' and Item_ComCd not like '310560%' */
and telnam_aktuellsteNachricht=1 and telnam_aktuellsteNachricht=1
@@ -587,8 +638,8 @@ Public Class usrCntlCBAM
FROM [tbl_DY_Zollmeldungen_Import] FROM [tbl_DY_Zollmeldungen_Import]
where where
Überlassungsdatum between '" & txtVon._value & "' and '" & txtBis._value & "' Überlassungsdatum between '" & txtVon._value & "' and '" & txtBis._value & "'
and and " & VERAG_PROG_ALLGEMEIN.cGreendeal_CBAM_Trn.BuildCBAMPatternWhereClause("Warentarifnummer") & "
( /* (
left(Warentarifnummer,4) IN (2523,2716,2808,2814,3102,3105,7201,7203,7318,7326,7601,7616) left(Warentarifnummer,4) IN (2523,2716,2808,2814,3102,3105,7201,7203,7318,7326,7601,7616)
OR left(Warentarifnummer,4) between 7301 and 7311 OR left(Warentarifnummer,4) between 7301 and 7311
OR left(Warentarifnummer,4) between 7205 and 7229 OR left(Warentarifnummer,4) between 7205 and 7229
@@ -603,7 +654,7 @@ Public Class usrCntlCBAM
OR Warentarifnummer like '720260%' OR Warentarifnummer like '720260%'
OR Warentarifnummer like '280410%' OR Warentarifnummer like '280410%'
) )
and Warentarifnummer not like '310560%' and Warentarifnummer not like '310560%' */
" "
@@ -733,7 +784,8 @@ Public Class usrCntlCBAM
Dim SQLSTR = " FROM [tbl_DY_Zollmeldungen_Import] Dim SQLSTR = " FROM [tbl_DY_Zollmeldungen_Import]
where where
Überlassungsdatum between '" & txtVon._value & "' and '" & txtBis._value & "' Überlassungsdatum between '" & txtVon._value & "' and '" & txtBis._value & "'
AND ( and " & VERAG_PROG_ALLGEMEIN.cGreendeal_CBAM_Trn.BuildCBAMPatternWhereClause("Warentarifnummer") & "
/* AND (
LEFT(Warentarifnummer,4) IN (2523,2716,2808,2814,2803,2818,3102,3103,3104,3105, LEFT(Warentarifnummer,4) IN (2523,2716,2808,2814,2803,2818,3102,3103,3104,3105,
7201,7202,7203,7204,7325,7318,7326,7601,7602) 7201,7202,7203,7204,7325,7318,7326,7601,7602)
OR LEFT(Warentarifnummer,4) BETWEEN 7205 AND 7229 OR LEFT(Warentarifnummer,4) BETWEEN 7205 AND 7229
@@ -751,7 +803,7 @@ Public Class usrCntlCBAM
OR Warentarifnummer LIKE '720260%' OR Warentarifnummer LIKE '720260%'
OR Warentarifnummer LIKE '280410%' OR Warentarifnummer LIKE '280410%'
) )
AND Warentarifnummer NOT LIKE '310560%' AND Warentarifnummer NOT LIKE '310560%'*/
" "
@@ -841,8 +893,8 @@ Public Class usrCntlCBAM
inner join zsAnmDeclarant on zsAnmHea.LizenzNr=zsAnmDeclarant.LizenzNr and zsAnmHea.AnmID=zsAnmDeclarant.AnmID and zsAnmHea.VorgangID=zsAnmDeclarant.VorgangID and zsAnmHea.OperatorID=zsAnmDeclarant.OperatorID inner join zsAnmDeclarant on zsAnmHea.LizenzNr=zsAnmDeclarant.LizenzNr and zsAnmHea.AnmID=zsAnmDeclarant.AnmID and zsAnmHea.VorgangID=zsAnmDeclarant.VorgangID and zsAnmHea.OperatorID=zsAnmDeclarant.OperatorID
inner join zsAnmTransp on zsAnmHea.LizenzNr=zsAnmTransp.LizenzNr and zsAnmHea.AnmID=zsAnmTransp.AnmID and zsAnmHea.VorgangID=zsAnmTransp.VorgangID and zsAnmHea.OperatorID=zsAnmTransp.OperatorID inner join zsAnmTransp on zsAnmHea.LizenzNr=zsAnmTransp.LizenzNr and zsAnmHea.AnmID=zsAnmTransp.AnmID and zsAnmHea.VorgangID=zsAnmTransp.VorgangID and zsAnmHea.OperatorID=zsAnmTransp.OperatorID
where DecDT between '" & txtVon._value & "' and '" & txtBis._value & "' where DecDT between '" & txtVon._value & "' and '" & txtBis._value & "'
and and " & VERAG_PROG_ALLGEMEIN.cGreendeal_CBAM_Trn.BuildCBAMPatternWhereClause("ComCd") & "
( /* (
left(ComCd,4) IN (2523,2716,2808,2814,3102,3105,7201,7203,7318,7326,7601,7616) left(ComCd,4) IN (2523,2716,2808,2814,3102,3105,7201,7203,7318,7326,7601,7616)
OR left(ComCd,4) between 7301 and 7311 OR left(ComCd,4) between 7301 and 7311
OR left(ComCd,4) between 7205 and 7229 OR left(ComCd,4) between 7205 and 7229
@@ -857,7 +909,7 @@ Public Class usrCntlCBAM
OR ComCd like '720260%' OR ComCd like '720260%'
OR ComCd like '280410%' OR ComCd like '280410%'
) )
and ComCd not like '310560%' and ComCd not like '310560%' */
and crn is not null and crn is not null
and zsAnmDHFRefs.ErledigungsTypID like 'F%'" and zsAnmDHFRefs.ErledigungsTypID like 'F%'"
@@ -946,7 +998,8 @@ Public Class usrCntlCBAM
where 1=1 where 1=1
and and " & VERAG_PROG_ALLGEMEIN.cGreendeal_CBAM_Trn.BuildCBAMPatternWhereClause("Item_ComCd") & "
/*
( (
left(Item_ComCd,4) IN (2523,2716,2808,2814,3102,3105,7201,7203,7318,7326,7601,7616) left(Item_ComCd,4) IN (2523,2716,2808,2814,3102,3105,7201,7203,7318,7326,7601,7616)
OR left(Item_ComCd,4) between 7301 and 7311 OR left(Item_ComCd,4) between 7301 and 7311
@@ -962,7 +1015,7 @@ Public Class usrCntlCBAM
OR Item_ComCd like '720260%' OR Item_ComCd like '720260%'
OR Item_ComCd like '280410%' OR Item_ComCd like '280410%'
) )
and Item_ComCd not like '310560%' and Item_ComCd not like '310560%' */
and telnam_aktuellsteNachricht=1 and telnam_aktuellsteNachricht=1
@@ -1231,8 +1284,8 @@ Public Class usrCntlCBAM
inner join tblDakosy_EZA_Adressen on ezaAd_EZAId=eza_Id and [ezaAd_AdressTyp]='CN' inner join tblDakosy_EZA_Adressen on ezaAd_EZAId=eza_Id and [ezaAd_AdressTyp]='CN'
where where
eza_anmeldedatum between '" & txtVon._value & "' and '" & txtBis._value & "' eza_anmeldedatum between '" & txtVon._value & "' and '" & txtBis._value & "'
and and " & VERAG_PROG_ALLGEMEIN.cGreendeal_CBAM_Trn.BuildCBAMPatternWhereClause("ezaWP_WarennummerEZT") & "
( /* (
left(ezaWP_WarennummerEZT,4) IN (2523,2716,2808,2814,3102,3105,7201,7203,7318,7326,7601,7616) left(ezaWP_WarennummerEZT,4) IN (2523,2716,2808,2814,3102,3105,7201,7203,7318,7326,7601,7616)
OR left(ezaWP_WarennummerEZT,4) between 7301 and 7311 OR left(ezaWP_WarennummerEZT,4) between 7301 and 7311
OR left(ezaWP_WarennummerEZT,4) between 7205 and 7229 OR left(ezaWP_WarennummerEZT,4) between 7205 and 7229
@@ -1248,7 +1301,7 @@ Public Class usrCntlCBAM
OR ezaWP_WarennummerEZT like '280410%' OR ezaWP_WarennummerEZT like '280410%'
) )
and ezaWP_WarennummerEZT not like '310560%' and ezaWP_WarennummerEZT not like '310560%'*/
and (eza_status between 50 and 60 or [eza_ANR] LIKE 'ATC%') and (eza_status between 50 and 60 or [eza_ANR] LIKE 'ATC%')
" "
@@ -1678,8 +1731,8 @@ Public Class usrCntlCBAM
inner join zsAnmDeclarant on zsAnmHea.LizenzNr=zsAnmDeclarant.LizenzNr and zsAnmHea.AnmID=zsAnmDeclarant.AnmID and zsAnmHea.VorgangID=zsAnmDeclarant.VorgangID and zsAnmHea.OperatorID=zsAnmDeclarant.OperatorID inner join zsAnmDeclarant on zsAnmHea.LizenzNr=zsAnmDeclarant.LizenzNr and zsAnmHea.AnmID=zsAnmDeclarant.AnmID and zsAnmHea.VorgangID=zsAnmDeclarant.VorgangID and zsAnmHea.OperatorID=zsAnmDeclarant.OperatorID
inner join zsAnmTransp on zsAnmHea.LizenzNr=zsAnmTransp.LizenzNr and zsAnmHea.AnmID=zsAnmTransp.AnmID and zsAnmHea.VorgangID=zsAnmTransp.VorgangID and zsAnmHea.OperatorID=zsAnmTransp.OperatorID inner join zsAnmTransp on zsAnmHea.LizenzNr=zsAnmTransp.LizenzNr and zsAnmHea.AnmID=zsAnmTransp.AnmID and zsAnmHea.VorgangID=zsAnmTransp.VorgangID and zsAnmHea.OperatorID=zsAnmTransp.OperatorID
where DecDT between '" & txtVon._value & "' and '" & txtBis._value & "' where DecDT between '" & txtVon._value & "' and '" & txtBis._value & "'
and and " & VERAG_PROG_ALLGEMEIN.cGreendeal_CBAM_Trn.BuildCBAMPatternWhereClause("ComCd") & "
( /* (
left(ComCd,4) IN (2523,2716,2808,2814,3102,3105,7201,7203,7318,7326,7601,7616) left(ComCd,4) IN (2523,2716,2808,2814,3102,3105,7201,7203,7318,7326,7601,7616)
OR left(ComCd,4) between 7301 and 7311 OR left(ComCd,4) between 7301 and 7311
OR left(ComCd,4) between 7205 and 7229 OR left(ComCd,4) between 7205 and 7229
@@ -1694,7 +1747,7 @@ Public Class usrCntlCBAM
OR ComCd like '720260%' OR ComCd like '720260%'
OR ComCd like '280410%' OR ComCd like '280410%'
) )
and ComCd not like '310560%' and ComCd not like '310560%' */
and crn is not null and crn is not null
and zsAnmDHFRefs.ErledigungsTypID like 'F%' and zsAnmDHFRefs.ErledigungsTypID like 'F%'
" "
@@ -2032,4 +2085,9 @@ Public Class usrCntlCBAM
Private Sub Button4_Click(sender As Object, e As EventArgs) Handles Button4.Click Private Sub Button4_Click(sender As Object, e As EventArgs) Handles Button4.Click
txtCalcErg.Text = cATEZ_Greenpulse_CBAM_CostCalculation.calcCBAM(txtCalcKN8._value, txtCalcGewicht._value, txtCalcLand._value, txtCalcEmission._value, txtCalcJahr._value, txtBenchmark._value) txtCalcErg.Text = cATEZ_Greenpulse_CBAM_CostCalculation.calcCBAM(txtCalcKN8._value, txtCalcGewicht._value, txtCalcLand._value, txtCalcEmission._value, txtCalcJahr._value, txtBenchmark._value)
End Sub End Sub
Private Sub Button5_Click(sender As Object, e As EventArgs) Handles Button5.Click
MsgBox(CountCBAMTariffNumbersBySystemAndEORI("DAKOSY", txtEori.Text, txtVon._value, txtBis._value))
MsgBox(CountCBAMTariffNumbersBySystemAndEORI("DHF", txtEori.Text, txtVon._value, txtBis._value))
End Sub
End Class End Class

View File

@@ -0,0 +1,230 @@
Imports System.Data.SqlClient
Imports System.Reflection
Public Class cGreendeal_CBAM_Trn
' =====================================================
' Properties = Spalten tblGreendeal_CBAM_Trn
' =====================================================
Public Property cbam_Id As Integer
Public Property trnPattern As String
Public Property ware As String
Public Property sektor As String
Public Property hinweis As String
Public Property is_exclusion As Boolean?
Public Property is_active As Boolean?
Public Property start_date As Date?
Public Property end_date As Date?
Public Property hasEntry As Boolean = False
Private SQL As New SQL
' =====================================================
' Konstruktor
' =====================================================
Sub New()
End Sub
Sub New(cbam_Id As Integer)
Me.cbam_Id = cbam_Id
LOAD()
End Sub
' =====================================================
' Parameterliste (Mapping Property <-> SQL)
' =====================================================
Public Function getParameterList() As List(Of VERAG_PROG_ALLGEMEIN.SQLVariable)
Dim list As New List(Of VERAG_PROG_ALLGEMEIN.SQLVariable)
list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("cbam_Id", cbam_Id,, True))
list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("trnPattern", trnPattern))
list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("ware", ware))
list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("sektor", sektor))
list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("hinweis", hinweis))
list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("is_exclusion", is_exclusion))
list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("is_active", is_active))
list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("start_date", start_date))
list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("end_date", end_date))
Return list
End Function
' =====================================================
' SAVE (Insert / Update)
' =====================================================
Public Function SAVE() As Boolean
Dim list As List(Of VERAG_PROG_ALLGEMEIN.SQLVariable) = getParameterList()
Dim sqlstr As String =
" BEGIN TRAN " &
" IF EXISTS (SELECT 1 FROM tblGreendeal_CBAM_Trn WHERE cbam_Id=@cbam_Id) " &
" BEGIN " & getUpdateCmd() & " END " &
" ELSE " &
" BEGIN " & getInsertCmd() & " END " &
" COMMIT TRAN "
Return SQL.doSQLVarList(sqlstr, "VERAG", , list)
End Function
' =====================================================
' LOAD
' =====================================================
Public Sub LOAD()
Try
hasEntry = False
Using conn As SqlConnection = SQL.GetNewOpenConnectionFMZOLL()
Using cmd As New SqlCommand(
"SELECT * FROM tblGreendeal_CBAM_Trn WHERE cbam_Id=@cbam_Id", conn)
cmd.Parameters.AddWithValue("@cbam_Id", cbam_Id)
Using dr = cmd.ExecuteReader()
If dr.Read Then
For Each li In getParameterList()
Dim pi As PropertyInfo =
Me.GetType.GetProperty(li.Scalarvariable)
If pi IsNot Nothing Then
If dr.Item(li.Text) Is DBNull.Value Then
pi.SetValue(Me, Nothing)
Else
pi.SetValue(Me, dr.Item(li.Text))
End If
End If
Next
hasEntry = True
End If
End Using
End Using
End Using
Catch ex As Exception
VERAG_PROG_ALLGEMEIN.cErrorHandler.ERR(
ex.Message,
ex.StackTrace,
System.Reflection.MethodInfo.GetCurrentMethod.Name)
End Try
End Sub
' =====================================================
' UPDATE Command
' =====================================================
Private Function getUpdateCmd() As String
Try
Dim list = getParameterList()
Dim str As String = ""
For Each i In list
If Not i.isPrimaryParam Then
str &= "[" & i.Text & "] = @" & i.Scalarvariable & ","
End If
Next
str = str.Substring(0, str.Length - 1)
Return " UPDATE tblGreendeal_CBAM_Trn SET " & str &
" WHERE cbam_Id=@cbam_Id "
Catch ex As Exception
VERAG_PROG_ALLGEMEIN.cErrorHandler.ERR(
ex.Message,
ex.StackTrace,
System.Reflection.MethodInfo.GetCurrentMethod.Name)
End Try
Return ""
End Function
' =====================================================
' INSERT Command
' =====================================================
Private Function getInsertCmd() As String
Try
Dim list = getParameterList()
Dim cols As String = ""
Dim vals As String = ""
For Each i In list
If Not i.isPrimaryParam Then
cols &= "[" & i.Text & "],"
vals &= "@" & i.Scalarvariable & ","
End If
Next
cols = cols.Substring(0, cols.Length - 1)
vals = vals.Substring(0, vals.Length - 1)
Return " INSERT INTO tblGreendeal_CBAM_Trn (" & cols & ") VALUES (" & vals & ") "
Catch ex As Exception
VERAG_PROG_ALLGEMEIN.cErrorHandler.ERR(
ex.Message,
ex.StackTrace,
System.Reflection.MethodInfo.GetCurrentMethod.Name)
End Try
Return ""
End Function
Public Shared Function BuildCBAMPatternWhereClause(columnName As String, Optional onlyActive As Boolean = True, Optional includeExclusions As Boolean = False) As String
Dim sql As String =
"SELECT trnPattern " &
" FROM VERAG.dbo.tblGreendeal_CBAM_Trn " &
" WHERE trnPattern IS NOT NULL " &
" AND LTRIM(RTRIM(trnPattern)) <> '' "
If onlyActive Then
sql &= " AND is_active = 1 " &
" AND (start_date IS NULL OR start_date <= GETDATE()) " &
" AND (end_date IS NULL OR end_date >= GETDATE()) "
End If
If Not includeExclusions Then
sql &= " AND ISNULL(is_exclusion,0) = 0 "
End If
Dim dt As DataTable = (New VERAG_PROG_ALLGEMEIN.SQL).loadDgvBySql(sql, "FMZOLL")
If dt Is Nothing OrElse dt.Rows.Count = 0 Then
Return "1=0" ' bewusst: keine Patterns → kein Treffer
End If
Dim conditions As New List(Of String)
For Each r As DataRow In dt.Rows
Dim pattern As String = r("trnPattern").ToString().Trim()
' einfache SQL-Escaping-Sicherheit
pattern = pattern.Replace("'", "''")
conditions.Add($"{columnName} LIKE '{pattern}'")
Next
Return "(" & String.Join(" OR ", conditions) & ")"
End Function
Public Shared Function DELETE_ALL() As Boolean
Try
Dim sqlstr As String = " DELETE FROM tblGreendeal_CBAM_Trn "
Return (New VERAG_PROG_ALLGEMEIN.SQL).doSQL(sqlstr, "VERAG", , Nothing)
Catch ex As Exception
VERAG_PROG_ALLGEMEIN.cErrorHandler.ERR(
ex.Message,
ex.StackTrace,
System.Reflection.MethodInfo.GetCurrentMethod.Name)
End Try
Return False
End Function
End Class

View File

@@ -33,7 +33,6 @@ Public Class cATEZ_Greenpulse_CBAM_CostCalculation
json.Load(resp.BodyStr) json.Load(resp.BodyStr)
Dim r As New cCBAM_CnCode_Response With {.success = json.BoolOf("success")} Dim r As New cCBAM_CnCode_Response With {.success = json.BoolOf("success")}
If r.success Then If r.success Then
r.data = New List(Of cCBAM_CnCode) r.data = New List(Of cCBAM_CnCode)
Dim a = json.ArrayOf("data") Dim a = json.ArrayOf("data")
@@ -51,6 +50,27 @@ Public Class cATEZ_Greenpulse_CBAM_CostCalculation
Return r Return r
End Function End Function
Public Function insertinto_Greendeal_CBAM_Trn(cCBAM_CnCode_Response As cCBAM_CnCode_Response) As Boolean
VERAG_PROG_ALLGEMEIN.cGreendeal_CBAM_Trn.DELETE_ALL()
For Each CN In cCBAM_CnCode_Response.data
Dim CBAM As New VERAG_PROG_ALLGEMEIN.cGreendeal_CBAM_Trn
CBAM.trnPattern = CN.cn_code & "%"
CBAM.sektor = ""
CBAM.ware = CN.cn_description
CBAM.is_exclusion = False
CBAM.is_active = True
CBAM.start_date = "01.10.2023"
CBAM.end_date = Nothing
CBAM.SAVE()
Next
Return True
End Function
' ------------------------------------------------------------------------ ' ------------------------------------------------------------------------
' GET /carbon-cost/cn-code-defaults ' GET /carbon-cost/cn-code-defaults
' ------------------------------------------------------------------------ ' ------------------------------------------------------------------------

View File

@@ -385,6 +385,7 @@
<Compile Include="Classes\cGesamtsicherheitsPositionen.vb" /> <Compile Include="Classes\cGesamtsicherheitsPositionen.vb" />
<Compile Include="Classes\cGestellungsgarantien.vb" /> <Compile Include="Classes\cGestellungsgarantien.vb" />
<Compile Include="Classes\cGestellungsmitteilung.vb" /> <Compile Include="Classes\cGestellungsmitteilung.vb" />
<Compile Include="Classes\cGreendeal_CBAM_Trn.vb" />
<Compile Include="Classes\cGrenzstelle.vb" /> <Compile Include="Classes\cGrenzstelle.vb" />
<Compile Include="Classes\cGruppeKundenNr.vb" /> <Compile Include="Classes\cGruppeKundenNr.vb" />
<Compile Include="Classes\cGVMS.vb" /> <Compile Include="Classes\cGVMS.vb" />