Files
SDL/SDL/kunden/usrCntlCBAM.vb

1847 lines
90 KiB
VB.net

Imports DAKOSY_Worker
Imports DocumentFormat.OpenXml.Spreadsheet
Imports VERAG_PROG_ALLGEMEIN
Public Class usrCntlCBAM
Dim SQL As New VERAG_PROG_ALLGEMEIN.SQL
Public kdnr As Integer = -1
Dim AD As VERAG_PROG_ALLGEMEIN.cAdressen = Nothing
Dim KD As VERAG_PROG_ALLGEMEIN.cKunde = Nothing
Sub New()
InitializeComponent()
End Sub
Sub New(kdNr)
InitializeComponent()
Me.kdnr = kdNr
End Sub
Private Sub btnCBAMPruef_DAKOSY_Click(sender As Object, e As EventArgs) Handles btnCBAMPruef_DAKOSY.Click
txtCBAMPruef_DAKOSY.Text = "-"
Try
Dim EORI = txtEori.Text
If cbxVERAG.Checked Then EORI = "VERAG"
If EORI = "" Then MsgBox("EORI eingeben!") : Exit Sub
If txtVon._value = "" Then MsgBox("Datum von eingeben!") : Exit Sub
If txtBis._value = "" Then MsgBox("Datum bis eingeben!") : Exit Sub
Me.Cursor = Cursors.WaitCursor
Dim SQLSTR_WHERE_FIRMEN = ""
If cbxVERAG.Checked Then SQLSTR_WHERE_FIRMEN &= "'SUB','WAI','SBG','NKD','NEU','AMBWO','AMB','IRU','EXP','SUW','DUR'"
If cbxIMEX.Checked Then SQLSTR_WHERE_FIRMEN &= IIf(SQLSTR_WHERE_FIRMEN <> "", ", ", "") & "'IME'"
If cbxUNISPED.Checked Then SQLSTR_WHERE_FIRMEN &= IIf(SQLSTR_WHERE_FIRMEN <> "", ", ", "") & "'ATSPED'" '???
'isnull( eza_anmeldedatum, eza_Trans_DatumZeit)
Dim SQLSTR = "
SELECT COUNT(distinct(Registriernummer_MRN)) FROM [tbl_DY_Zollmeldungen_Import]
where Überlassungsdatum between '" & txtVon._value & "' and '" & txtBis._value & "'
and
(
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 7205 and 7229
OR left(Warentarifnummer,4) between 7603 and 7614
OR Warentarifnummer like '25070080%'
OR Warentarifnummer like '283421%'
OR Warentarifnummer like '260112%'
OR Warentarifnummer like '720211%'
OR Warentarifnummer like '720219%'
OR Warentarifnummer like '720241%'
OR Warentarifnummer like '720249%'
OR Warentarifnummer like '720260%'
OR Warentarifnummer like '280410%'
)
and Warentarifnummer not like '310560%'
"
If SQLSTR_WHERE_FIRMEN <> "" Then
SQLSTR &= " and Teilnehmer in ( " & SQLSTR_WHERE_FIRMEN & ")"
SQLSTR &= "
and left(Art_der_Vertretung,1) IN (2)
"
Else
'Die Unterabfrage hat mehr als einen Wert zurückgegeben. Das ist nicht zulässig, wenn die Unterabfrage auf =, !=, <, <=, > oder >= folgt oder als Ausdruck verwendet wird.
'SQLSTR &= "
' and (select isnull([ezaAd_NameFirma1],[ezaAd_TeilnehmerEORI]) FROM tblDakosy_EZA_Adressen WHERE ezaAd_EZAId=eza_Id and [ezaAd_AdressTyp]='CN')='" & EORI & "'
' "
'korrigierte Query:
SQLSTR &= "
and Empfänger_CN_EORI ='" & EORI & "'
"
End If
Dim dt = SQL.loadDgvBySql(SQLSTR, "AVISO", 600)
If dt IsNot Nothing AndAlso dt.Rows.Count > 0 Then
txtCBAMPruef_DAKOSY.Text = dt.Rows(0)(0) & " Einträge"
Me.Cursor = Cursors.Default
Exit Sub
End If
txtCBAMPruef_DAKOSY.Text = "0"
Catch ex As Exception
VERAG_PROG_ALLGEMEIN.cErrorHandler.ERR(ex.Message, ex.StackTrace, System.Reflection.MethodInfo.GetCurrentMethod.Name)
End Try
Me.Cursor = Cursors.Default
End Sub
'Private Sub btnCBAMPruef_DAKOSY_Click(sender As Object, e As EventArgs) Handles btnCBAMPruef_DAKOSY.Click
' txtCBAMPruef_DAKOSY.Text = "-"
' Try
' Dim EORI = txtEori.Text
' If cbxVERAG.Checked Then EORI = "VERAG"
' If EORI = "" Then MsgBox("EORI eingeben!") : Exit Sub
' If txtVon._value = "" Then MsgBox("Datum von eingeben!") : Exit Sub
' If txtBis._value = "" Then MsgBox("Datum bis eingeben!") : Exit Sub
' Me.Cursor = Cursors.WaitCursor
' 'isnull( eza_anmeldedatum, eza_Trans_DatumZeit)
' Dim SQLSTR = "
' SELECT COUNT(*) FROM [tblDakosy_EZA] inner join tblDakosy_EZA_Warenposition on ezaWP_EzaId=eza_Id
' where eza_anmeldedatum between '" & txtVon._value & "' and '" & txtBis._value & "'
' and
' (
' 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 7205 and 7229
' OR left(ezaWP_WarennummerEZT,4) between 7603 and 7614
' OR ezaWP_WarennummerEZT like '25070080%'
' OR ezaWP_WarennummerEZT like '283421%'
' OR ezaWP_WarennummerEZT like '260112%'
' OR ezaWP_WarennummerEZT like '720211%'
' OR ezaWP_WarennummerEZT like '720219%'
' OR ezaWP_WarennummerEZT like '720241%'
' OR ezaWP_WarennummerEZT like '720249%'
' OR ezaWP_WarennummerEZT like '720260%'
' OR ezaWP_WarennummerEZT like '280410%'
' )
' and ezaWP_WarennummerEZT not like '310560%'
' and (eza_status between 50 and 60 or [eza_ANR] LIKE 'ATC%')
' "
' If cbxVERAG.Checked Then
' SQLSTR &= "
' and eza_VertretungsVerhaeltnisCode=2
' "
' Else
' 'Die Unterabfrage hat mehr als einen Wert zurückgegeben. Das ist nicht zulässig, wenn die Unterabfrage auf =, !=, <, <=, > oder >= folgt oder als Ausdruck verwendet wird.
' 'SQLSTR &= "
' ' and (select isnull([ezaAd_NameFirma1],[ezaAd_TeilnehmerEORI]) FROM tblDakosy_EZA_Adressen WHERE ezaAd_EZAId=eza_Id and [ezaAd_AdressTyp]='CN')='" & EORI & "'
' ' "
' 'korrigierte Query:
' SQLSTR &= "
' and EXISTS (SELECT 1 FROM tblDakosy_EZA_Adressen WHERE ezaAd_EZAId = eza_Id AND [ezaAd_AdressTyp] = 'CN' AND isnull([ezaAd_NameFirma1], [ezaAd_TeilnehmerEORI]) ='" & EORI & "')
' "
' End If
' Dim dt = SQL.loadDgvBySql(SQLSTR, "FMZOLL", 600)
' If dt IsNot Nothing AndAlso dt.Rows.Count > 0 Then
' txtCBAMPruef_DAKOSY.Text = dt.Rows(0)(0) & " Einträge"
' Me.Cursor = Cursors.Default
' Exit Sub
' End If
' txtCBAMPruef_DAKOSY.Text = "0"
' Catch ex As Exception
' VERAG_PROG_ALLGEMEIN.cErrorHandler.ERR(ex.Message, ex.StackTrace, System.Reflection.MethodInfo.GetCurrentMethod.Name)
' End Try
' Me.Cursor = Cursors.Default
'End Sub
Private Sub btnCBAMPruef_ALLE_Click(sender As Object, e As EventArgs) Handles btnCBAMPruef_ALLE.Click
btnCBAMPruef_DAKOSY.PerformClick()
btnCBAMPruef_DHF_VERAG.PerformClick()
btnCBAMPruef_DHF_UNISPED.PerformClick()
btnCBAMPruef_TELOTEC.PerformClick()
End Sub
Private Sub btnCBAMPruef_DHF_VERAG_Click(sender As Object, e As EventArgs) Handles btnCBAMPruef_DHF_VERAG.Click
txtCBAMPruef_DHF_VERAG.Text = "-"
Try
Dim EORI = txtEori.Text
If cbxVERAG.Checked Or cbxUNISPED.Checked Or cbxIMEX.Checked Then EORI = "VERAG"
If EORI = "" Then MsgBox("EORI eingeben!") : Exit Sub
If txtVon._value = "" Then MsgBox("Datum von eingeben!") : Exit Sub
If txtBis._value = "" Then MsgBox("Datum bis eingeben!") : Exit Sub
Me.Cursor = Cursors.WaitCursor
Dim SQLSTR = "
select COUNT(*) from zsAnmRefs
inner join zsAnmDHFRefs on zsAnmRefs.LizenzNr=zsAnmDHFRefs.LizenzNr and zsAnmRefs.AnmID=zsAnmDHFRefs.AnmID and zsAnmRefs.VorgangID=zsAnmDHFRefs.VorgangID and zsAnmRefs.OperatorID=zsAnmDHFRefs.OperatorID
inner join zsAnmGdsitem on zsAnmRefs.LizenzNr=zsAnmGdsitem.LizenzNr and zsAnmRefs.AnmID=zsAnmGdsitem.AnmID and zsAnmRefs.VorgangID=zsAnmGdsitem.VorgangID and zsAnmRefs.OperatorID=zsAnmGdsitem.OperatorID
inner join zsAnmHea on zsAnmHea.LizenzNr=zsAnmGdsitem.LizenzNr and zsAnmHea.AnmID=zsAnmGdsitem.AnmID and zsAnmHea.VorgangID=zsAnmGdsitem.VorgangID and zsAnmHea.OperatorID=zsAnmGdsitem.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
where DecDT between '" & txtVon._value & "' and '" & txtBis._value & "'
and
(
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 7205 and 7229
OR left(ComCd,4) between 7603 and 7614
OR ComCd like '25070080%'
OR ComCd like '283421%'
OR ComCd like '260112%'
OR ComCd like '720211%'
OR ComCd like '720219%'
OR ComCd like '720241%'
OR ComCd like '720249%'
OR ComCd like '720260%'
OR ComCd like '280410%'
)
and ComCd not like '310560%'
and crn is not null
and zsAnmDHFRefs.ErledigungsTypID like 'F%'
"
If cbxVERAG.Checked Then
SQLSTR &= "
and DecRep IN(3)
"
Else
SQLSTR &= "
and (SELECT TIN FROM zsAnmConeeTra WHERE (zsAnmConeeTra.LizenzNr = zsAnmHea.LizenzNr ) And (zsAnmConeeTra.OperatorID =zsAnmHea.OperatorID ) And (zsAnmConeeTra.VorgangID = zsAnmHea.VorgangID ) And (zsAnmConeeTra.AnmID = zsAnmHea.AnmID )) = '" & EORI & "'
"
End If
Dim dt = SQL.loadDgvBySql(SQLSTR, "EZOLL", 600)
If dt IsNot Nothing AndAlso dt.Rows.Count > 0 Then
txtCBAMPruef_DHF_VERAG.Text = dt.Rows(0)(0) & " Einträge"
Me.Cursor = Cursors.Default
Exit Sub
End If
txtCBAMPruef_DHF_VERAG.Text = "0"
Catch ex As Exception
VERAG_PROG_ALLGEMEIN.cErrorHandler.ERR(ex.Message, ex.StackTrace, System.Reflection.MethodInfo.GetCurrentMethod.Name)
End Try
Me.Cursor = Cursors.Default
End Sub
Private Sub btnCBAMPruef_DHF_UNISPED_Click(sender As Object, e As EventArgs) Handles btnCBAMPruef_DHF_UNISPED.Click
txtCBAMPruef_DHF_UNISPED.Text = "-"
Try
Dim EORI = txtEori.Text
If cbxVERAG.Checked Or cbxUNISPED.Checked Or cbxIMEX.Checked Then EORI = "VERAG"
If EORI = "" Then MsgBox("EORI eingeben!") : Exit Sub
If txtVon._value = "" Then MsgBox("Datum von eingeben!") : Exit Sub
If txtBis._value = "" Then MsgBox("Datum bis eingeben!") : Exit Sub
Me.Cursor = Cursors.WaitCursor
Dim SQLSTR = "
select COUNT(*) from zsAnmRefs
inner join zsAnmDHFRefs on zsAnmRefs.LizenzNr=zsAnmDHFRefs.LizenzNr and zsAnmRefs.AnmID=zsAnmDHFRefs.AnmID and zsAnmRefs.VorgangID=zsAnmDHFRefs.VorgangID and zsAnmRefs.OperatorID=zsAnmDHFRefs.OperatorID
inner join zsAnmGdsitem on zsAnmRefs.LizenzNr=zsAnmGdsitem.LizenzNr and zsAnmRefs.AnmID=zsAnmGdsitem.AnmID and zsAnmRefs.VorgangID=zsAnmGdsitem.VorgangID and zsAnmRefs.OperatorID=zsAnmGdsitem.OperatorID
inner join zsAnmHea on zsAnmHea.LizenzNr=zsAnmGdsitem.LizenzNr and zsAnmHea.AnmID=zsAnmGdsitem.AnmID and zsAnmHea.VorgangID=zsAnmGdsitem.VorgangID and zsAnmHea.OperatorID=zsAnmGdsitem.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
where DecDT between '" & txtVon._value & "' and '" & txtBis._value & "'
and
(
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 7205 and 7229
OR left(ComCd,4) between 7603 and 7614
OR ComCd like '25070080%'
OR ComCd like '283421%'
OR ComCd like '260112%'
OR ComCd like '720211%'
OR ComCd like '720219%'
OR ComCd like '720241%'
OR ComCd like '720249%'
OR ComCd like '720260%'
OR ComCd like '280410%'
)
and ComCd not like '310560%'
and crn is not null
and zsAnmDHFRefs.ErledigungsTypID like 'F%'
"
If cbxUNISPED.Checked Then
SQLSTR &= "
and DecRep IN(3)
"
Else
SQLSTR &= "
and (SELECT TIN FROM zsAnmConeeTra WHERE (zsAnmConeeTra.LizenzNr = zsAnmHea.LizenzNr ) And (zsAnmConeeTra.OperatorID =zsAnmHea.OperatorID ) And (zsAnmConeeTra.VorgangID = zsAnmHea.VorgangID ) And (zsAnmConeeTra.AnmID = zsAnmHea.AnmID )) = '" & EORI & "'
"
End If
Dim dt = SQL.loadDgvBySql(SQLSTR, "EZOLL_UNISPED", 600)
If dt IsNot Nothing AndAlso dt.Rows.Count > 0 Then
txtCBAMPruef_DHF_UNISPED.Text = dt.Rows(0)(0) & " Einträge"
Me.Cursor = Cursors.Default
Exit Sub
End If
txtCBAMPruef_DHF_UNISPED.Text = "0"
Catch ex As Exception
VERAG_PROG_ALLGEMEIN.cErrorHandler.ERR(ex.Message, ex.StackTrace, System.Reflection.MethodInfo.GetCurrentMethod.Name)
End Try
Me.Cursor = Cursors.Default
End Sub
Private Sub btnCBAMPruef_TELOTEC_Click(sender As Object, e As EventArgs) Handles btnCBAMPruef_TELOTEC.Click
txtCBAMPruef_TELOTEC.Text = "-"
Dim SQLSTR_WHERE_FIRMEN = ""
If cbxVERAG.Checked Then SQLSTR_WHERE_FIRMEN &= "'VERAG'"
If cbxIMEX.Checked Then SQLSTR_WHERE_FIRMEN &= IIf(SQLSTR_WHERE_FIRMEN <> "", ", ", "") & "'IMEX'"
If cbxUNISPED.Checked Then SQLSTR_WHERE_FIRMEN &= IIf(SQLSTR_WHERE_FIRMEN <> "", ", ", "") & "'UNISPED'"
Try
Dim EORI = txtEori.Text
If cbxVERAG.Checked Or cbxUNISPED.Checked Or cbxIMEX.Checked Then EORI = "VERAG"
If EORI = "" Then MsgBox("EORI eingeben!") : Exit Sub
Me.Cursor = Cursors.WaitCursor
Dim SQLSTR = "
SELECT count (*)
FROM [VERAG].[dbo].[tblTelotec_Anmeldung]
inner join tblTelotec_Positionsdaten on telpos_telanmId=telanm_id
where 1=1
and
(
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 7205 and 7229
OR left(Item_ComCd,4) between 7603 and 7614
OR Item_ComCd like '25070080%'
OR Item_ComCd like '283421%'
OR Item_ComCd like '260112%'
OR Item_ComCd like '720211%'
OR Item_ComCd like '720219%'
OR Item_ComCd like '720241%'
OR Item_ComCd like '720249%'
OR Item_ComCd like '720260%'
OR Item_ComCd like '280410%'
)
and Item_ComCd not like '310560%'
and telnam_aktuellsteNachricht=1
and telanm_ART ='EUA'
and dec_CreateDate between '" & txtVon._value & "' and '" & txtBis._value & "'"
If SQLSTR_WHERE_FIRMEN <> "" Then
SQLSTR &= " and telanm_firma in ( " & SQLSTR_WHERE_FIRMEN & ")" 'nur IMEX????
Else
SQLSTR &= " and ConeeTra_TIN IN ( '" & EORI & "')"
End If
Dim dt = SQL.loadDgvBySql(SQLSTR, "FMZOLL", 600)
If dt IsNot Nothing AndAlso dt.Rows.Count > 0 Then
txtCBAMPruef_TELOTEC.Text = dt.Rows(0)(0) & " Einträge"
Me.Cursor = Cursors.Default
Exit Sub
End If
txtCBAMPruef_TELOTEC.Text = "0"
Catch ex As Exception
VERAG_PROG_ALLGEMEIN.cErrorHandler.ERR(ex.Message, ex.StackTrace, System.Reflection.MethodInfo.GetCurrentMethod.Name)
End Try
Me.Cursor = Cursors.Default
End Sub
Private Sub usrCntlCBAM_Load(sender As Object, e As EventArgs) Handles Me.Load
txtJahr.Text = Now.Year
If Now.Month < 3 Then
txtJahr.Text = Now.Year - 1
cboQuartal.Text = "Q4"
ElseIf Now.Month < 6 Then : cboQuartal.Text = "Q1"
ElseIf Now.Month < 9 Then : cboQuartal.Text = "Q2"
ElseIf Now.Month < 12 Then : cboQuartal.Text = "Q3"
End If
If kdnr > 0 Then
AD = New VERAG_PROG_ALLGEMEIN.cAdressen(kdnr)
KD = New VERAG_PROG_ALLGEMEIN.cKunde(kdnr)
End If
If KD IsNot Nothing Then
txtEori.Text = KD.EORITIN
End If
End Sub
Private Sub cboQuartal_SelectedIndexChanged(sender As Object, e As EventArgs) Handles cboQuartal.SelectedIndexChanged
If cboQuartal.Text <> "" And IsNumeric(txtJahr.Text) AndAlso txtJahr.Text.Length = 4 Then
Select Case cboQuartal.Text
Case "Q1" : txtVon._value = CDate("01.01." & txtJahr.Text) : txtBis._value = CDate(txtVon._value).AddMonths(3).AddDays(-1)
Case "Q2" : txtVon._value = CDate("01.04." & txtJahr.Text) : txtBis._value = CDate(txtVon._value).AddMonths(3).AddDays(-1)
Case "Q3" : txtVon._value = CDate("01.07." & txtJahr.Text) : txtBis._value = CDate(txtVon._value).AddMonths(3).AddDays(-1)
Case "Q4" : txtVon._value = CDate("01.10." & txtJahr.Text) : txtBis._value = CDate(txtVon._value).AddMonths(3).AddDays(-1)
End Select
End If
End Sub
Private Sub btnCBAM_DS_DAKOSY_Click(sender As Object, e As EventArgs) Handles btnCBAM_DS_DAKOSY.Click
btnCBAM_DS_DAKOSY_Detail.Enabled = False
btnCBAM_DS_DAKOSY_Copy.Enabled = False
btnCBAM_DS_DAKOSY_Spedb.Enabled = False
btnCBAM_DS_DAKOSY_GP.Enabled = False
btnCBAM_DS_DAKOSY_Detail.Tag = ""
btnCBAM_DS_DAKOSY_Spedb.Tag = ""
btnCBAM_DS_DAKOSY_GP.Tag = ""
Dim SQLSTR_WHERE_FIRMEN = ""
If cbxVERAG.Checked Then SQLSTR_WHERE_FIRMEN &= "'SUB','WAI','SBG','NKD','NEU','AMBWO','AMB','IRU','EXP','SUW','DUR'"
If cbxIMEX.Checked Then SQLSTR_WHERE_FIRMEN &= IIf(SQLSTR_WHERE_FIRMEN <> "", ", ", "") & "'IME'"
If cbxUNISPED.Checked Then SQLSTR_WHERE_FIRMEN &= IIf(SQLSTR_WHERE_FIRMEN <> "", ", ", "") & "'ATSPED'" '???
Try
Dim EORI = txtEori.Text
If cbxVERAG.Checked Then EORI = "VERAG"
If EORI = "" Then MsgBox("EORI eingeben!") : Exit Sub
If txtVon._value = "" Then MsgBox("Datum von eingeben!") : Exit Sub
If txtBis._value = "" Then MsgBox("Datum bis eingeben!") : Exit Sub
Me.Cursor = Cursors.WaitCursor
Dim SQL_DAKOSY = ""
Dim SQL_GP = ""
getDY_Detail_SQL(SQLSTR_WHERE_FIRMEN, EORI, SQL_DAKOSY, SQL_GP) '--> Aufbau SQL String
Dim dt = SQL.loadDgvBySql(SQL_DAKOSY, "AVISO", 600)
Dim dtGP = SQL.loadDgvBySql(SQL_GP, "AVISO", 600)
Dim MRNNr As String = ""
Dim SQLWhereMRN As String = ""
Dim counter = 0
Dim displayView = New DataView(dt, "", "RegistriernummerATLAS", DataViewRowState.CurrentRows)
Dim distinctDT_MRN As DataTable = displayView.ToTable(True, "RegistriernummerATLAS")
For Each r As DataRow In distinctDT_MRN.Rows
MRNNr &= "'" & r.Item("RegistriernummerATLAS") & "'"
counter += 1
If (distinctDT_MRN.Rows.Count <> 0 And counter <> distinctDT_MRN.Rows.Count) Then MRNNr &= ","
Next
SQLWhereMRN &= " AND BelegNr not in (" & MRNNr & ")"
Dim sqlNew = "select Speditionsbuch.[FilialenNr],[AbfertigungsNr],[UnterNr],[Abfertigungsdatum],[Bar],[Fakturiert],[BelegNr],[ErfassungsNr],[LKW Kennzeichen],[AbsenderKundenNr],[Absender],[AbsenderOffertenNr],[EmpfängerKundenNr],[Empfänger],[EmpfängerOffertenNr],[VermittlerKundenNr],[Vermittler],[VermittlerOffertenNr],[FrachtführerKundenNr],[Frachtführer],[AnzahlZA],[AnzahlZAFremd],[AnzahlZnV],[AnzahlZnVFremd],[AnzahlT1],[AnzahlT2],[AnzahlAE] from Speditionsbuch
inner join Kunden on Speditionsbuch.[VermittlerKundenNr] = Kunden.KundenNr OR Speditionsbuch.[EmpfängerKundenNr]= Kunden.KundenNr OR Speditionsbuch.[VermittlerKundenNr] = Kunden.KundenNr OR Speditionsbuch.[EmpfängerKundenNr] = Kunden.KundenNr
where 1 = 1 AND Kunden.EORITIN = '" & EORI & "' AND BelegNr <> '' AND (Speditionsbuch.[Abfertigungsdatum] BETWEEN '" & txtVon._value & "' and '" & txtBis._value & "' )" & IIf(MRNNr <> "", SQLWhereMRN, "")
Dim ReDaten As New DataTable
If MRNNr <> "" Then
ReDaten = SQL.loadDgvBySql("SELECT Positionsunterlagenart, Positionsunterlagennummer, Positionsunterlagendatum,Registriernummer_MRN FROM [tbl_DY_Zollmeldungen_Import] WHERE [Positionsunterlagenart] in ('N380','N325') and Registriernummer_MRN IN (" & MRNNr & ")", "AVISO", 600)
End If
If ReDaten.Rows.Count > 0 Then
dt.Columns("Rechnungsdatum").ReadOnly = False
dt.Columns("Rechnungsnummer").ReadOnly = False
dt.Columns("Rechnungsdatum").MaxLength = -1
dt.Columns("Rechnungsnummer").MaxLength = -1
End If
If dt IsNot Nothing AndAlso dt.Rows.Count > 0 Then
For Each r As DataRow In dt.Rows
Dim MDN_NR As String = r("RegistriernummerATLAS")
' Look for matching row in dt2
Dim found() As DataRow = ReDaten.Select("Registriernummer_MRN = '" & MDN_NR & "'")
If found.Length > 0 Then
Dim rechnugnsdatum As String = found(0)("Positionsunterlagendatum")
If rechnugnsdatum <> "" Then rechnugnsdatum.Replace("00:00:00", "")
r("Rechnungsdatum") = rechnugnsdatum
r("Rechnungsnummer") = found(0)("Positionsunterlagennummer")
Else
r("Rechnungsdatum") = "-"
r("Rechnungsnummer") = "-"
End If
Next
Dim path = VERAG_PROG_ALLGEMEIN.cProgramFunctions.genExcelFromDT_NEW(dt,,,,, False, EORI & "_Detailbericht_" & txtVon._value & "-" & txtBis._value)
btnCBAM_DS_DAKOSY_Detail.Tag = path
btnCBAM_DS_DAKOSY_Detail.Enabled = True
btnCBAM_DS_DAKOSY_Copy.Enabled = True
End If
If dtGP IsNot Nothing AndAlso dt.Rows.Count > 0 Then
If ReDaten.Rows.Count > 0 Then
dtGP.Columns("invoice date").ReadOnly = False
dtGP.Columns("invoice numbers").ReadOnly = False
dtGP.Columns("invoice date").MaxLength = -1
dtGP.Columns("invoice numbers").MaxLength = -1
End If
For Each r As DataRow In dtGP.Rows
Dim MDN_NR As String = r("declaration no")
' Look for matching row in dt2
Dim found() As DataRow = ReDaten.Select("Registriernummer_MRN = '" & MDN_NR & "'")
If found.Length > 0 Then
Dim rechnugnsdatum As String = found(0)("Positionsunterlagendatum")
If rechnugnsdatum <> "" Then rechnugnsdatum.Replace("00:00:00", "")
r("invoice date") = rechnugnsdatum
r("invoice numbers") = found(0)("Positionsunterlagennummer")
Else
r("invoice date") = "-"
r("invoice numbers") = "-"
End If
Next
btnCBAM_DS_DAKOSY_GP.Tag = ""
btnCBAM_DS_DAKOSY_GP.Tag = createExcelForGreenPulse(dtGP, EORI, IIf(AD.Ort <> "", AD.Ort, ""))
btnCBAM_DS_DAKOSY_GP.Enabled = True
End If
Dim dtNew = SQL.loadDgvBySql(sqlNew, "FMZOLL", 600)
If dtNew IsNot Nothing AndAlso dtNew.Rows.Count > 0 Then
If dtNew.Columns.Contains("Packstücke") Then dtNew.Columns.Remove("Packstücke")
Dim path = VERAG_PROG_ALLGEMEIN.cProgramFunctions.genExcelFromDT_NEW(dtNew,,,,, False, EORI & "_Unterschiede zum Sped-Buch_" & txtVon._value & "-" & txtBis._value)
btnCBAM_DS_DAKOSY_Spedb.Enabled = True
btnCBAM_DS_DAKOSY_Spedb.Tag = path
Me.Cursor = Cursors.Default
End If
Catch ex As Exception
VERAG_PROG_ALLGEMEIN.cErrorHandler.ERR(ex.Message, ex.StackTrace, System.Reflection.MethodInfo.GetCurrentMethod.Name)
End Try
Me.Cursor = Cursors.Default
'-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
btnCBAM_DS_DAKOSY_Summe.Enabled = False
btnCBAM_DS_DAKOSY_Summe.Tag = ""
Try
Dim EORI = txtEori.Text
If cbxVERAG.Checked Then EORI = "VERAG"
If EORI = "" Then MsgBox("EORI eingeben!") : Exit Sub
If txtVon._value = "" Then MsgBox("Datum von eingeben!") : Exit Sub
If txtBis._value = "" Then MsgBox("Datum bis eingeben!") : Exit Sub
Me.Cursor = Cursors.WaitCursor
Dim SQLSTR = "
SELECT
left(Tarifnummer,8) Tarifnummer,sum(Eigenmasse)Eigenmasse,sum(Rohmasse)Rohmasse,sum(Rechnungspreis)Rechnungspreis,VersendungsLand VersendungsLand ,isnull(LEFT(Verfahren2,2),'') Verfahren,isnull(right(left(Verfahren2,4),2),'') VorangegangenesVerfahren
FROM (
SELECT
[Registriernummer_MRN] RegistriernummerATLAS
,PositionNo PositionsNummer
,max(Überlassungsdatum) Anmeldedatum
,max([Bezugsnummer_LRN]) BezugsNr
,max([Art_der_Vertretung]) VertretungsVerhaeltnis
,max(Warentarifnummer) Tarifnummer
,max(Eigenmasse) Eigenmasse
,max([VersendungsLand]) VersendungsLand
,'DE' Bestimmungsland
,max([Rechnungsbetrag])Rechnungspreis
,max([Rechnungswährung]) Rechnungswaehrung
,isnull(max(Empfänger_CN_EORI),'') as EmpfängerEORI
,isnull(max(CZ_Name), '') as Empfänger
,isnull(max(Versender_CZ_EORI),'') as AbsenderEORI
,isnull(max(CN_Name), '') as Absender
,max(Rohmasse)Rohmasse
,max(Verfahren2)Verfahren2
FROM [tbl_DY_Zollmeldungen_Import]
where
Überlassungsdatum between '" & txtVon._value & "' and '" & txtBis._value & "'
and
(
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 7205 and 7229
OR left(Warentarifnummer,4) between 7603 and 7614
OR Warentarifnummer like '25070080%'
OR Warentarifnummer like '283421%'
OR Warentarifnummer like '260112%'
OR Warentarifnummer like '720211%'
OR Warentarifnummer like '720219%'
OR Warentarifnummer like '720241%'
OR Warentarifnummer like '720249%'
OR Warentarifnummer like '720260%'
OR Warentarifnummer like '280410%'
)
and Warentarifnummer not like '310560%'
"
If SQLSTR_WHERE_FIRMEN <> "" Then
SQLSTR &= " and Teilnehmer in ( " & SQLSTR_WHERE_FIRMEN & ")"
SQLSTR &= "
and left(Art_der_Vertretung,1) IN (2)
"
Else
'Die Unterabfrage hat mehr als einen Wert zurückgegeben. Das ist nicht zulässig, wenn die Unterabfrage auf =, !=, <, <=, > oder >= folgt oder als Ausdruck verwendet wird.
'SQLSTR &= "
' and (select isnull([ezaAd_NameFirma1],[ezaAd_TeilnehmerEORI]) FROM tblDakosy_EZA_Adressen WHERE ezaAd_EZAId=eza_Id and [ezaAd_AdressTyp]='CN')='" & EORI & "'
' "
SQLSTR &= "
and Empfänger_CN_EORI='" & EORI & "'
"
End If
SQLSTR &= " group by Registriernummer_MRN,PositionNo
) as T1 group by VersendungsLand,left(Tarifnummer,8),Verfahren2 "
Dim dt = SQL.loadDgvBySql(SQLSTR, "AVISO", 600)
If dt IsNot Nothing AndAlso dt.Rows.Count > 0 Then
Dim path = VERAG_PROG_ALLGEMEIN.cProgramFunctions.genExcelFromDT_NEW(dt,,,,, False, EORI & "_Summenbericht_" & txtVon._value & "-" & txtBis._value)
btnCBAM_DS_DAKOSY_Summe.Tag = path
btnCBAM_DS_DAKOSY_Summe.Enabled = True
btnCBAM_DS_DAKOSY_Copy.Enabled = True
Me.Cursor = Cursors.Default
End If
''----- XML ----------------------------------------------------------------------------------------------------------------------------------------
'btnCBAM_DS_DAKOSY_XML.Enabled = False
'btnCBAM_DS_DAKOSY_XML.Tag = ""
'If dt IsNot Nothing AndAlso dt.Rows.Count > 0 Then
' '---------------------------------------------------------------------------------------------------------------------------------------------
' doCBAM_XML(dt, EORI)
' '---------------------------------------------------------------------------------------------------------------------------------------------
'End If
''---------------------------------------------------------------------------------------------------------------------------------------------
Catch ex As Exception
VERAG_PROG_ALLGEMEIN.cErrorHandler.ERR(ex.Message, ex.StackTrace, System.Reflection.MethodInfo.GetCurrentMethod.Name)
End Try
Me.Cursor = Cursors.Default
End Sub
Sub getDY_Detail_SQL(SQLSTR_WHERE_FIRMEN, EORI, ByRef SQL_DAKOSY, ByRef SQL_GP)
SQL_GP = "SELECT [Registriernummer_MRN] as 'declaration no'
,max(Überlassungsdatum) as 'declaration date'
,isnull(max(Empfänger_CN_EORI),'') as 'importer identification number'
,'' as 'exporter identification number'
, max(Warentarifnummer) as 'commodity code'
,max([VersendungsLand]) as 'origin country code'
,Left(max(Verfahren2),2) as 'requested procedure'
,'' as 'previous procedure'
,(max(Eigenmasse) / 1000) as 'net mass'
,'TONNES' as 'type of measurement unit'
,'' as 'invoice numbers'
,'' as 'invoice date'
,'' as 'member state auth'
,'' as 'discharge bill waiver'
,'' as 'authorisation'
,'' as 'start time'
,'' as 'end time'
,'' as 'deadline'
,isnull(max(Empfänger_CN_EORI),'') as 'reporting declarant EORI number'
,'' as 'type of representation'
,isnull(max(CN_Name), '') as 'importer title'
,'' as 'importer email'
,'' as 'importer phone'
,isnull(max(CN_Ländercode), '') as 'importer country code or member state'
,'' as 'importer subdivision'
,'' as 'importer city'
,'' as 'importer street'
,'' as 'importer street additional'
,'' as 'importer address number'
,'' as 'importer post code'
,'' as 'importer po box'
,'' as 'importer coordinate longitude (x)'
,'' as 'importer coordinate latitude (y)'
,isnull(max(CZ_Name), '') as 'exporter title'
,isnull(max(CZ_Ländercode), '') as 'exporter country code or member state'
,'' as 'exporter street'
,'' as 'exporter street additional'"
SQL_DAKOSY = "SELECT
[Registriernummer_MRN] RegistriernummerATLAS
,PositionNo PositionsNummer
,max(Überlassungsdatum) Anmeldedatum
,max([Bezugsnummer_LRN]) BezugsNr
,max([Art_der_Vertretung]) VertretungsVerhaeltnis
,max(Warentarifnummer) Tarifnummer
,max(Eigenmasse) Eigenmasse
,max([VersendungsLand]) VersendungsLand
,'DE' Bestimmungsland
,max([DV1Rechnungsbetrag])Rechnungspreis
,max([Rechnungswährung]) Rechnungswaehrung
,isnull(max(Empfänger_CN_EORI),'') as EmpfängerEORI
,isnull(max(CN_Name), '') as Empfänger
,isnull(max(Versender_CZ_EORI),'') as AbsenderEORI
,isnull(max(CZ_Name), '') as Absender
,'' as 'Rechnungsnummer'
,'' as 'Rechnungsdatum'"
Dim SQLSTR = " FROM [tbl_DY_Zollmeldungen_Import]
where
Überlassungsdatum between '" & txtVon._value & "' and '" & txtBis._value & "'
AND (
LEFT(Warentarifnummer,4) IN (2523,2716,2808,2814,2803,2818,3102,3103,3104,3105,
7201,7202,7203,7204,7325,7318,7326,7601,7602)
OR LEFT(Warentarifnummer,4) BETWEEN 7205 AND 7229
OR LEFT(Warentarifnummer,4) BETWEEN 7301 AND 7311
OR LEFT(Warentarifnummer,4) BETWEEN 7603 AND 7614
OR Warentarifnummer LIKE '25070080%'
OR Warentarifnummer LIKE '260112%'
OR Warentarifnummer LIKE '260300%'
OR Warentarifnummer LIKE '260600%'
OR Warentarifnummer LIKE '283421%'
OR Warentarifnummer LIKE '720211%'
OR Warentarifnummer LIKE '720219%'
OR Warentarifnummer LIKE '720241%'
OR Warentarifnummer LIKE '720249%'
OR Warentarifnummer LIKE '720260%'
OR Warentarifnummer LIKE '280410%'
)
AND Warentarifnummer NOT LIKE '310560%'
"
If SQLSTR_WHERE_FIRMEN <> "" Then
SQLSTR &= " and Teilnehmer in ( " & SQLSTR_WHERE_FIRMEN & ")"
SQLSTR &= "
and left(Art_der_Vertretung,1) IN (2)
"
Else
'Das ist nicht zulässig, wenn die Unterabfrage auf =, !=, <, <=, > oder >= folgt oder als Ausdruck verwendet wird.
'SQLSTR &= "
' and (select isnull([ezaAd_NameFirma1],[ezaAd_TeilnehmerEORI]) FROM tblDakosy_EZA_Adressen WHERE ezaAd_EZAId=eza_Id and [ezaAd_AdressTyp]='CN')='" & EORI & "'
' "
SQLSTR &= "
and Empfänger_CN_EORI='" & EORI & "'
"
End If
SQLSTR &= " group by Registriernummer_MRN,PositionNo"
SQLSTR &= " order by isnull(max(CZ_Name), ''), Registriernummer_MRN, PositionNo"
SQL_GP &= SQLSTR
SQL_DAKOSY &= SQLSTR
End Sub
'Private Sub btnCBAM_DS_DAKOSY_Click(sender As Object, e As EventArgs) Handles btnCBAM_DS_DAKOSY.Click
' btnCBAM_DS_DAKOSY_Deteil.Enabled = False
' btnCBAM_DS_DAKOSY_Copy.Enabled = False
' btnCBAM_DS_DAKOSY_Deteil.Tag = ""
' Dim SQLSTR_WHERE_FIRMEN = ""
' If cbxVERAG.Checked Then SQLSTR_WHERE_FIRMEN &= "'VERAG'"
' If cbxIMEX.Checked Then SQLSTR_WHERE_FIRMEN &= IIf(SQLSTR_WHERE_FIRMEN <> "", ", ", "") & "'IMEX'"
' If cbxUNISPED.Checked Then SQLSTR_WHERE_FIRMEN &= IIf(SQLSTR_WHERE_FIRMEN <> "", ", ", "") & "'UNISPED'"
' Try
' Dim EORI = txtEori.Text
' If cbxVERAG.Checked Then EORI = "VERAG"
' If EORI = "" Then MsgBox("EORI eingeben!") : Exit Sub
' If txtVon._value = "" Then MsgBox("Datum von eingeben!") : Exit Sub
' If txtBis._value = "" Then MsgBox("Datum bis eingeben!") : Exit Sub
' Me.Cursor = Cursors.WaitCursor
' Dim SQLSTR = "
' SELECT
' [eza_ANR] RegistriernummerATLAS
' ,ezaWP_PositionsNummer PositionsNummer
' ,isnull( eza_anmeldedatum, eza_Trans_DatumZeit) Anmeldedatum
' ,[eza_ObjectName] BezugsNr
' ,[eza_VertretungsVerhaeltnisCode] VertretungsVerhaeltnis
' ,ezaWP_WarennummerEZT Tarifnummer
' ,ezaWP_Eigenmasse Eigenmasse
' ,[eza_VersendungsLandCode] VersendungsLand
' ,[eza_Bestimmungsland] Bestimmungsland
' ,[ezaWP_Artikelpreis]Rechnungspreis
' ,[ezaWP_ArtikelpreisWaehrung] Rechnungswaehrung
' ,(select isnull([ezaAd_NameFirma1],[ezaAd_TeilnehmerEORI]) FROM tblDakosy_EZA_Adressen WHERE ezaAd_EZAId=eza_Id and [ezaAd_AdressTyp]='CN') as Empfänger
' ,(select isnull([ezaAd_NameFirma1],[ezaAd_TeilnehmerEORI]) FROM tblDakosy_EZA_Adressen WHERE ezaAd_EZAId=eza_Id and [ezaAd_AdressTyp]='CZ') as Absender
' FROM [VERAG].[dbo].[tblDakosy_EZA]
' inner join tblDakosy_EZA_Warenposition on ezaWP_EzaId=eza_Id
' where
' eza_anmeldedatum between '" & txtVon._value & "' and '" & txtBis._value & "'
' and
' (
' 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 7205 and 7229
' OR left(ezaWP_WarennummerEZT,4) between 7603 and 7614
' OR ezaWP_WarennummerEZT like '25070080%'
' OR ezaWP_WarennummerEZT like '283421%'
' OR ezaWP_WarennummerEZT like '260112%'
' OR ezaWP_WarennummerEZT like '720211%'
' OR ezaWP_WarennummerEZT like '720219%'
' OR ezaWP_WarennummerEZT like '720241%'
' OR ezaWP_WarennummerEZT like '720249%'
' OR ezaWP_WarennummerEZT like '720260%'
' OR ezaWP_WarennummerEZT like '280410%'
' )
' and ezaWP_WarennummerEZT not like '310560%'
' and (eza_status between 50 and 60 or [eza_ANR] LIKE 'ATC%')
' "
' If cbxVERAG.Checked Or cbxIMEX.Checked Or cbxUNISPED.Checked Then
' SQLSTR &= "
' and eza_VertretungsVerhaeltnisCode=2
' "
' Else
' 'Das ist nicht zulässig, wenn die Unterabfrage auf =, !=, <, <=, > oder >= folgt oder als Ausdruck verwendet wird.
' 'SQLSTR &= "
' ' and (select isnull([ezaAd_NameFirma1],[ezaAd_TeilnehmerEORI]) FROM tblDakosy_EZA_Adressen WHERE ezaAd_EZAId=eza_Id and [ezaAd_AdressTyp]='CN')='" & EORI & "'
' ' "
' SQLSTR &= "
' and EXISTS (select 1 FROM tblDakosy_EZA_Adressen WHERE ezaAd_EZAId=eza_Id and [ezaAd_AdressTyp]='CN' AND isnull([ezaAd_NameFirma1],[ezaAd_TeilnehmerEORI])='" & EORI & "')
' "
' End If
' If SQLSTR_WHERE_FIRMEN <> "" Then SQLSTR &= " and EZA_firma in ( " & SQLSTR_WHERE_FIRMEN & ")"
' SQLSTR &= " order by Absender,eza_ANR, tblDakosy_EZA_Warenposition.ezaWP_PositionsNummer"
' Dim dt = SQL.loadDgvBySql(SQLSTR, "FMZOLL", 600)
' MsgBox(SQLSTR)
' If dt IsNot Nothing AndAlso dt.Rows.Count > 0 Then
' Dim path = VERAG_PROG_ALLGEMEIN.cProgramFunctions.genExcelFromDT_NEW(dt,,,,, False, EORI & "_Detailbericht_" & txtVon._value & "-" & txtBis._value)
' btnCBAM_DS_DAKOSY_Deteil.Tag = path
' btnCBAM_DS_DAKOSY_Deteil.Enabled = True
' btnCBAM_DS_DAKOSY_Copy.Enabled = True
' Me.Cursor = Cursors.Default
' End If
' Catch ex As Exception
' VERAG_PROG_ALLGEMEIN.cErrorHandler.ERR(ex.Message, ex.StackTrace, System.Reflection.MethodInfo.GetCurrentMethod.Name)
' End Try
' Me.Cursor = Cursors.Default
' '-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
' btnCBAM_DS_DAKOSY_Summe.Enabled = False
' btnCBAM_DS_DAKOSY_Summe.Tag = ""
' Try
' Dim EORI = txtEori.Text
' If cbxVERAG.Checked Then EORI = "VERAG"
' If EORI = "" Then MsgBox("EORI eingeben!") : Exit Sub
' If txtVon._value = "" Then MsgBox("Datum von eingeben!") : Exit Sub
' If txtBis._value = "" Then MsgBox("Datum bis eingeben!") : Exit Sub
' Me.Cursor = Cursors.WaitCursor
' Dim SQLSTR = "
' SELECT
' left(ezaWP_WarennummerEZT,8) Tarifnummer,sum(ezaWP_Eigenmasse)Eigenmasse,sum(ezaWP_Rohmasse)Rohmasse,sum(ezaWP_Artikelpreis)Rechnungspreis,eza_VersendungsLandCode VersendungsLand ,isnull(ezaWP_AnmeldeVErfahren,'') Verfahren,isnull([ezaWP_VerfahrensCodeVorangegangenesVerfahren],'') VorangegangenesVerfahren
' FROM [VERAG].[dbo].[tblDakosy_EZA]
' inner join tblDakosy_EZA_Warenposition on ezaWP_EzaId=eza_Id
' where
' eza_anmeldedatum between '" & txtVon._value & "' and '" & txtBis._value & "'
' and
' (
' 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 7205 and 7229
' OR left(ezaWP_WarennummerEZT,4) between 7603 and 7614
' OR ezaWP_WarennummerEZT like '25070080%'
' OR ezaWP_WarennummerEZT like '283421%'
' OR ezaWP_WarennummerEZT like '260112%'
' OR ezaWP_WarennummerEZT like '720211%'
' OR ezaWP_WarennummerEZT like '720219%'
' OR ezaWP_WarennummerEZT like '720241%'
' OR ezaWP_WarennummerEZT like '720249%'
' OR ezaWP_WarennummerEZT like '720260%'
' OR ezaWP_WarennummerEZT like '280410%'
' )
' and ezaWP_WarennummerEZT not like '310560%'
' and (eza_status between 50 and 60 or [eza_ANR] LIKE 'ATC%')
' "
' If cbxVERAG.Checked Or cbxIMEX.Checked Or cbxUNISPED.Checked Then
' SQLSTR &= "
' and eza_VertretungsVerhaeltnisCode=2
' "
' Else
' 'Die Unterabfrage hat mehr als einen Wert zurückgegeben. Das ist nicht zulässig, wenn die Unterabfrage auf =, !=, <, <=, > oder >= folgt oder als Ausdruck verwendet wird.
' 'SQLSTR &= "
' ' and (select isnull([ezaAd_NameFirma1],[ezaAd_TeilnehmerEORI]) FROM tblDakosy_EZA_Adressen WHERE ezaAd_EZAId=eza_Id and [ezaAd_AdressTyp]='CN')='" & EORI & "'
' ' "
' SQLSTR &= "
' and EXISTS (select 1 FROM tblDakosy_EZA_Adressen WHERE ezaAd_EZAId=eza_Id and [ezaAd_AdressTyp]='CN' and isnull([ezaAd_NameFirma1],[ezaAd_TeilnehmerEORI])='" & EORI & "')
' "
' End If
' If SQLSTR_WHERE_FIRMEN <> "" Then SQLSTR &= " and EZA_firma in ( " & SQLSTR_WHERE_FIRMEN & ")"
' SQLSTR &= " group by eza_VersendungsLandCode,left(ezaWP_WarennummerEZT,8),ezaWP_AnmeldeVErfahren,ezaWP_VerfahrensCodeVorangegangenesVerfahren"
' Dim dt = SQL.loadDgvBySql(SQLSTR, "FMZOLL", 600)
' If dt IsNot Nothing AndAlso dt.Rows.Count > 0 Then
' Dim path = VERAG_PROG_ALLGEMEIN.cProgramFunctions.genExcelFromDT_NEW(dt,,,,, False, EORI & "_Summenbericht_" & txtVon._value & "-" & txtBis._value)
' btnCBAM_DS_DAKOSY_Summe.Tag = path
' btnCBAM_DS_DAKOSY_Summe.Enabled = True
' btnCBAM_DS_DAKOSY_Copy.Enabled = True
' Me.Cursor = Cursors.Default
' End If
' ''----- XML ----------------------------------------------------------------------------------------------------------------------------------------
' 'btnCBAM_DS_DAKOSY_XML.Enabled = False
' 'btnCBAM_DS_DAKOSY_XML.Tag = ""
' 'If dt IsNot Nothing AndAlso dt.Rows.Count > 0 Then
' ' '---------------------------------------------------------------------------------------------------------------------------------------------
' ' doCBAM_XML(dt, EORI)
' ' '---------------------------------------------------------------------------------------------------------------------------------------------
' 'End If
' ''---------------------------------------------------------------------------------------------------------------------------------------------
' Catch ex As Exception
' VERAG_PROG_ALLGEMEIN.cErrorHandler.ERR(ex.Message, ex.StackTrace, System.Reflection.MethodInfo.GetCurrentMethod.Name)
' End Try
' Me.Cursor = Cursors.Default
'End Sub
Private Sub ButtonXML_Click(sender As Object, e As EventArgs) Handles Button1.Click
If sender Is Button1 Then
Button2.Enabled = False
btnCBAM_DS_DAKOSY_XML.Enabled = False
btnCBAM_DS_DAKOSY_XML.Tag = ""
End If
'-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Try
Dim EORI = txtEori.Text
If cbxVERAG.Checked Then EORI = "VERAG"
If EORI = "" Then MsgBox("EORI eingeben!") : Exit Sub
If txtVon._value = "" Then MsgBox("Datum von eingeben!") : Exit Sub
If txtBis._value = "" Then MsgBox("Datum bis eingeben!") : Exit Sub
Me.Cursor = Cursors.WaitCursor
Dim SQLSTR = "
SELECT
left(ezaWP_WarennummerEZT,8) Tarifnummer,sum(ezaWP_Eigenmasse)Eigenmasse,sum(ezaWP_Rohmasse)Rohmasse,sum(ezaWP_Artikelpreis)Rechnungspreis,eza_VersendungsLandCode VersendungsLand ,isnull(ezaWP_AnmeldeVErfahren,'') Verfahren,isnull([ezaWP_VerfahrensCodeVorangegangenesVerfahren],'') VorangegangenesVerfahren
,isnull(ezaAd_NameFirma1,'') as Empfänger,isnull(ezaAd_TeilnehmerEORI,'') as EmpfängerEORI
FROM [VERAG].[dbo].[tblDakosy_EZA]
inner join tblDakosy_EZA_Warenposition on ezaWP_EzaId=eza_Id
inner join tblDakosy_EZA_Adressen on ezaAd_EZAId=eza_Id and [ezaAd_AdressTyp]='CN'
where
eza_anmeldedatum between '" & txtVon._value & "' and '" & txtBis._value & "'
and
(
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 7205 and 7229
OR left(ezaWP_WarennummerEZT,4) between 7603 and 7614
OR ezaWP_WarennummerEZT like '25070080%'
OR ezaWP_WarennummerEZT like '283421%'
OR ezaWP_WarennummerEZT like '260112%'
OR ezaWP_WarennummerEZT like '720211%'
OR ezaWP_WarennummerEZT like '720219%'
OR ezaWP_WarennummerEZT like '720241%'
OR ezaWP_WarennummerEZT like '720249%'
OR ezaWP_WarennummerEZT like '720260%'
OR ezaWP_WarennummerEZT like '280410%'
)
and ezaWP_WarennummerEZT not like '310560%'
and (eza_status between 50 and 60 or [eza_ANR] LIKE 'ATC%')
"
If cbxVERAG.Checked Then
SQLSTR &= "
and eza_VertretungsVerhaeltnisCode=2
"
Else
''Die Unterabfrage hat mehr als einen Wert zurückgegeben. Das ist nicht zulässig, wenn die Unterabfrage auf =, !=, <, <=, > oder >= folgt oder als Ausdruck verwendet wird.
'SQLSTR &= "
' and (select isnull([ezaAd_NameFirma1],[ezaAd_TeilnehmerEORI]) FROM tblDakosy_EZA_Adressen WHERE ezaAd_EZAId=eza_Id and [ezaAd_AdressTyp]='CN')='" & EORI & "'
' "
SQLSTR &= "
and EXISTS(select 1 FROM tblDakosy_EZA_Adressen WHERE ezaAd_EZAId=eza_Id and [ezaAd_AdressTyp]='CN' AND isnull([ezaAd_NameFirma1],[ezaAd_TeilnehmerEORI])='" & EORI & "')
"
End If
SQLSTR &= " group by ezaAd_NameFirma1,ezaAd_TeilnehmerEORI,eza_VersendungsLandCode,left(ezaWP_WarennummerEZT,8),ezaWP_AnmeldeVErfahren,ezaWP_VerfahrensCodeVorangegangenesVerfahren"
Dim dt = SQL.loadDgvBySql(SQLSTR, "FMZOLL", 600)
'----- XML ----------------------------------------------------------------------------------------------------------------------------------------
If dt IsNot Nothing AndAlso dt.Rows.Count > 0 Then
'---------------------------------------------------------------------------------------------------------------------------------------------
doCBAM_XML(dt, EORI)
'---------------------------------------------------------------------------------------------------------------------------------------------
Button2.Enabled = True
btnCBAM_DS_DAKOSY_XML.Enabled = True
End If
'---------------------------------------------------------------------------------------------------------------------------------------------
Catch ex As Exception
VERAG_PROG_ALLGEMEIN.cErrorHandler.ERR(ex.Message, ex.StackTrace, System.Reflection.MethodInfo.GetCurrentMethod.Name)
End Try
Me.Cursor = Cursors.Default
End Sub
Private Sub Button3gp_Click(sender As Object, e As EventArgs) Handles Button3.Click
'-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Try
Dim EORI = txtEori.Text
If cbxVERAG.Checked Then EORI = "VERAG"
If EORI = "" Then MsgBox("EORI eingeben!") : Exit Sub
If txtVon._value = "" Then MsgBox("Datum von eingeben!") : Exit Sub
If txtBis._value = "" Then MsgBox("Datum bis eingeben!") : Exit Sub
Me.Cursor = Cursors.WaitCursor
Dim SQLSTR_WHERE_FIRMEN = ""
If cbxVERAG.Checked Then SQLSTR_WHERE_FIRMEN &= "'SUB','WAI','SBG','NKD','NEU','AMBWO','AMB','IRU','EXP','SUW','DUR'"
If cbxIMEX.Checked Then SQLSTR_WHERE_FIRMEN &= IIf(SQLSTR_WHERE_FIRMEN <> "", ", ", "") & "'IME'"
If cbxUNISPED.Checked Then SQLSTR_WHERE_FIRMEN &= IIf(SQLSTR_WHERE_FIRMEN <> "", ", ", "") & "'ATSPED'" '???
Dim SQL_DAKOSY = ""
getDY_Detail_SQL(SQLSTR_WHERE_FIRMEN, EORI, SQL_DAKOSY, "") '--> Aufbau SQL String
Dim dt = SQL.loadDgvBySql(SQL_DAKOSY, "AVISO", 600)
lblKafkaCnt.Text = "-"
'----- kafka / Greenpulse ----------------------------------------------------------------------------------------------------------------------------------------
If dt IsNot Nothing AndAlso dt.Rows.Count > 0 Then
lblKafkaCnt.Text = "0/" & dt.Rows.Count
doCBAM_KafkaFromDakosy(dt)
End If
'---------------------------------------------------------------------------------------------------------------------------------------------
Catch ex As Exception
VERAG_PROG_ALLGEMEIN.cErrorHandler.ERR(ex.Message, ex.StackTrace, System.Reflection.MethodInfo.GetCurrentMethod.Name)
End Try
Me.Cursor = Cursors.Default
End Sub
Private Sub doCBAM_KafkaFromDakosy(dt As DataTable)
Try
Dim cnt = 1
For Each g In dt.Rows
lblKafkaCnt.Text = cnt & "/" & dt.Rows.Count
Me.Refresh()
cnt += 1
Dim mrn As String = g("RegistriernummerATLAS")
Dim EZA = cDakosyEZA.LOADByMRN(mrn, True)
' Objekt
Dim rec = cDakosyEZA_Greenpulse.BuildByMrn(EZA)
' Dim rec = cATEZ_Greenpulse_KafkaDecs.BuildDemo()
'' JSON (schön formatiert)
'Dim json As String = cATEZ_Greenpulse_KafkaDecsBuilder_DAKOSY.BuildJsonByMrn(mrn, pretty:=True)
'Console.WriteLine(json)
Dim key = cATEZ_Greenpulse_KafkaDecs.GetUniqueKey_Pipe("DE", "DAKOSY", mrn)
Dim dr = cATEZ_Greenpulse_KafkaDecs.InsertOrUpdateToKafkaSync_Bool(rec, key, 30000)
' MessageBox.Show($"OK: {dr.Status} @ {dr.TopicPartitionOffset}")
Next
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
End Sub
Private Sub doCBAM_XML(dt As DataTable, EORI As String)
Dim CBAM_XML As New VERAG_PROG_ALLGEMEIN.CBAM_QReport_17.QReportType
CBAM_XML.Year = txtJahr.Text
CBAM_XML.ReportingPeriod = cboQuartal._value
EORI = txtEori.Text ' Sont VERAG problem..
If cbxVERAG.Checked Then ' VERAG--> Indirect Representative
CBAM_XML.Representative.IdentificationNumber = EORI
Dim AD As VERAG_PROG_ALLGEMEIN.cAdressen = Nothing
Select Case EORI
Case "DE4824105"
AD = New VERAG_PROG_ALLGEMEIN.cAdressen(712255) 'VERAG GmbH (DE)
Case "ATEOS1000000199"
AD = New VERAG_PROG_ALLGEMEIN.cAdressen(711104) 'VERAG AG (AT)
Case "ATEOS1000059121"
AD = New VERAG_PROG_ALLGEMEIN.cAdressen(600006) 'VERAG Customs Service GmbH (AT)
End Select
If AD IsNot Nothing Then
CBAM_XML.Representative.Name = AD.Name_1
If If(AD.Name_2, "") <> "" Then CBAM_XML.Representative.Name &= " " & AD.Name_2
If AD.LandKz <> "" Then CBAM_XML.Representative.RepresentativeAddress.Country = VERAG_PROG_ALLGEMEIN.cProgramFunctions.getISO2Land(AD.LandKz)
CBAM_XML.Representative.RepresentativeAddress.Street = If(AD.Straße, "")
CBAM_XML.Representative.RepresentativeAddress.Postcode = If(AD.PLZ, "")
End If
End If
'Dim KD_IMP = VERAG_PROG_ALLGEMEIN.cKunde.LOAD_ByEORI(EORI)
'If KD_IMP.hasEntry Then
' Dim A_IMP As New VERAG_PROG_ALLGEMEIN.cAdressen(KD_IMP.KundenNrZentrale)
' If A_IMP IsNot Nothing AndAlso A_IMP.hasEntry Then
' CBAM_XML.Importer.Name = A_IMP.Name_1
' If If(A_IMP.Name_2, "") <> "" Then CBAM_XML.Importer.Name &= " " & A_IMP.Name_2
' If A_IMP.LandKz <> "" Then CBAM_XML.Importer.ImporterAddress.Country = VERAG_PROG_ALLGEMEIN.cProgramFunctions.getISO2Land(A_IMP.LandKz)
' CBAM_XML.Importer.ImporterAddress.Street = If(A_IMP.Straße, "")
' CBAM_XML.Importer.ImporterAddress.Postcode = If(A_IMP.PLZ, "")
' End If
'End If
For Each g In dt.Rows
Dim GOODS As New VERAG_PROG_ALLGEMEIN.CBAM_QReport_17.ImportedGoodType
GOODS.CommodityCode.HsCode = g("Tarifnummer").ToString.Substring(0, 6)
GOODS.CommodityCode.CnCode = g("Tarifnummer").ToString.Substring(6, 2)
GOODS.OriginCountry.Country = g("VersendungsLand")
GOODS.MeasureImported.NetMass = g("Eigenmasse")
GOODS.MeasureImported.MeasurementUnit = "KG"
' ezaAd_NameFirma1, ezaAd_TeilnehmerEORI,
If g("EmpfängerEORI") <> "" Then
Dim KD_IMP = VERAG_PROG_ALLGEMEIN.cKunde.LOAD_ByEORI(g("EmpfängerEORI"))
If KD_IMP.hasEntry Then
Dim A_IMP As New VERAG_PROG_ALLGEMEIN.cAdressen(KD_IMP.KundenNrZentrale)
If A_IMP IsNot Nothing AndAlso A_IMP.hasEntry Then
GOODS.Importer.Name = A_IMP.Name_1
If If(A_IMP.Name_2, "") <> "" Then GOODS.Importer.Name &= " " & A_IMP.Name_2
If A_IMP.LandKz <> "" Then GOODS.Importer.ImporterAddress.Country = VERAG_PROG_ALLGEMEIN.cProgramFunctions.getISO2Land(A_IMP.LandKz)
GOODS.Importer.ImporterAddress.Street = If(A_IMP.Straße, "")
GOODS.Importer.ImporterAddress.Postcode = If(A_IMP.PLZ, "")
End If
End If
Else
GOODS.Importer.Name = g("Empfänger")
End If
Dim IQ As New VERAG_PROG_ALLGEMEIN.CBAM_QReport_17.ImportedQuantityType
If g("Verfahren") <> "" Then IQ.Procedure.RequestedProc = g("Verfahren").ToString.Substring(0, 2)
If g("VorangegangenesVerfahren") <> "" Then IQ.Procedure.PreviousProc = g("VorangegangenesVerfahren").ToString.Substring(0, 2)
GOODS.ImportedQuantity.Add(IQ)
CBAM_XML.ImportedGood.Add(GOODS)
Next
Dim optFileName = EORI & "_XML_" & txtVon._value & "-" & txtBis._value
Dim sPath As String = Environment.GetFolderPath(Environment.SpecialFolder.Personal) & "\VERAG\SDL\tmp\" ' My.Computer.FileSystem.GetTempFileName
If Not My.Computer.FileSystem.DirectoryExists(sPath) Then
My.Computer.FileSystem.CreateDirectory(sPath)
End If
Dim filename = sPath & optFileName & ".xml"
While System.IO.File.Exists(filename)
filename = sPath & optFileName & Now.ToString("ddMMyyyyHHmmss") & ".xml"
End While
CBAM_XML.SaveToFile(filename)
btnCBAM_DS_DAKOSY_XML.Tag = filename
btnCBAM_DS_DAKOSY_XML.Enabled = True
'Me.Cursor = Cursors.WaitCursor
End Sub
Private Sub btnCBAM_DS_DAKOSY_Deteil_Click(sender As Object, e As EventArgs) Handles btnCBAM_DS_DAKOSY_Detail.Click, btnCBAM_DS_DAKOSY_Summe.Click, btnCBAM_DS_DHF_VERAG_Detail.Click,
btnCBAM_DS_DHF_VERAG_Summe.Click, btnCBAM_DS_DHF_UNISPED_Detail.Click, btnCBAM_DS_DHF_UNISPED_Summe.Click, btnCBAM_DS_TELOTEC_Detail.Click, btnCBAM_DS_TELOTEC_Summe.Click,
btnCBAM_DS_DAKOSY_XML.Click, btnCBAM_DS_DAKOSY_Spedb.Click, btnCBAM_DS_DAKOSY_GP.Click, btnCBAM_DS_DHF_UNISPED_GP.Click, btnCBAM_DS_DHF_VERAG_GP.Click, btnCBAM_DS_TELOTEC_GP.Click
If sender.tag <> "" Then
Try : Process.Start(sender.tag) : Catch : End Try
End If
End Sub
Private Sub btnCBAM_DS_DAKOSY_Copy_Click(sender As Object, e As EventArgs) Handles btnCBAM_DS_DAKOSY_Copy.Click
Dim f As New List(Of String)
If btnCBAM_DS_DAKOSY_Detail.Tag <> "" Then f.Add(btnCBAM_DS_DAKOSY_Detail.Tag)
If btnCBAM_DS_DAKOSY_Summe.Tag <> "" Then f.Add(btnCBAM_DS_DAKOSY_Summe.Tag)
If btnCBAM_DS_DAKOSY_GP.Tag <> "" Then f.Add(btnCBAM_DS_DAKOSY_GP.Tag)
If f.Count > 0 Then
'Zwischenablage
Clipboard.Clear()
Dim d As New DataObject(DataFormats.FileDrop, f.ToArray)
Clipboard.SetDataObject(d, True)
End If
End Sub
Private Sub btnCBAM_DS_DHF_VERAG_Copy_Click(sender As Object, e As EventArgs) Handles btnCBAM_DS_DHF_VERAG_Copy.Click
Dim f As New List(Of String)
If btnCBAM_DS_DHF_VERAG_Detail.Tag <> "" Then f.Add(btnCBAM_DS_DHF_VERAG_Detail.Tag)
If btnCBAM_DS_DHF_VERAG_Summe.Tag <> "" Then f.Add(btnCBAM_DS_DHF_VERAG_Summe.Tag)
If f.Count > 0 Then
'Zwischenablage
Clipboard.Clear()
Dim d As New DataObject(DataFormats.FileDrop, f.ToArray)
Clipboard.SetDataObject(d, True)
End If
End Sub
Private Sub btnCBAM_DS_DHF_UNISPED_Copy_Click(sender As Object, e As EventArgs) Handles btnCBAM_DS_DHF_UNISPED_Copy.Click
Dim f As New List(Of String)
If btnCBAM_DS_DHF_UNISPED_Detail.Tag <> "" Then f.Add(btnCBAM_DS_DHF_UNISPED_Detail.Tag)
If btnCBAM_DS_DHF_UNISPED_Summe.Tag <> "" Then f.Add(btnCBAM_DS_DHF_UNISPED_Summe.Tag)
If f.Count > 0 Then
'Zwischenablage
Clipboard.Clear()
Dim d As New DataObject(DataFormats.FileDrop, f.ToArray)
Clipboard.SetDataObject(d, True)
End If
End Sub
Private Sub btnCBAM_DS_TELOTEC_Copy_Click(sender As Object, e As EventArgs) Handles btnCBAM_DS_TELOTEC_Copy.Click
Dim f As New List(Of String)
If btnCBAM_DS_TELOTEC_Detail.Tag <> "" Then f.Add(btnCBAM_DS_TELOTEC_Detail.Tag)
If btnCBAM_DS_TELOTEC_Summe.Tag <> "" Then f.Add(btnCBAM_DS_TELOTEC_Summe.Tag)
If f.Count > 0 Then
'Zwischenablage
Clipboard.Clear()
Dim d As New DataObject(DataFormats.FileDrop, f.ToArray)
Clipboard.SetDataObject(d, True)
End If
End Sub
Private Sub btnCBAM_DS_DHF_VERAG_Click(sender As Object, e As EventArgs) Handles btnCBAM_DS_DHF_VERAG.Click, btnCBAM_DS_DHF_UNISPED.Click
Dim EZOLL_SQL = "EZOLL"
If sender Is btnCBAM_DS_DHF_VERAG Then
btnCBAM_DS_DHF_VERAG_Detail.Enabled = False
btnCBAM_DS_DHF_VERAG_Copy.Enabled = False
btnCBAM_DS_DHF_VERAG_Detail.Tag = ""
End If
If sender Is btnCBAM_DS_DHF_UNISPED Then
btnCBAM_DS_DHF_UNISPED_Detail.Enabled = False
btnCBAM_DS_DHF_UNISPED_Copy.Enabled = False
btnCBAM_DS_DHF_UNISPED_Detail.Tag = ""
EZOLL_SQL = "EZOLL_UNISPED"
End If
Try
Dim EORI = txtEori.Text
If cbxVERAG.Checked Then EORI = "VERAG"
If EORI = "" Then MsgBox("EORI eingeben!") : Exit Sub
If txtVon._value = "" Then MsgBox("Datum von eingeben!") : Exit Sub
If txtBis._value = "" Then MsgBox("Datum bis eingeben!") : Exit Sub
Me.Cursor = Cursors.WaitCursor
Dim SQLSTR = "
select CRN Zollbelegnummer,cast(DecDT as date) Anmeldedatum,LRN,zsAnmGdsitem.ComCd Tarifnummer,Net Eigenmasse,ItVal Rechnungspreis
, Orig Ursprungsland
, isnull((SELECT TIN FROM zsAnmConorTra WHERE (zsAnmConorTra.LizenzNr = zsAnmHea.LizenzNr ) And (zsAnmConorTra.OperatorID =zsAnmHea.OperatorID ) And (zsAnmConorTra.VorgangID = zsAnmHea.VorgangID ) And (zsAnmConorTra.AnmID = zsAnmHea.AnmID )),'') EORI_Absender
, isnull((SELECT Na FROM zsAnmConorTra WHERE (zsAnmConorTra.LizenzNr = zsAnmHea.LizenzNr ) And (zsAnmConorTra.OperatorID =zsAnmHea.OperatorID ) And (zsAnmConorTra.VorgangID = zsAnmHea.VorgangID ) And (zsAnmConorTra.AnmID = zsAnmHea.AnmID )),'') Absender
, isnull((SELECT TIN FROM zsAnmConeeTra WHERE (zsAnmConeeTra.LizenzNr = zsAnmHea.LizenzNr ) And (zsAnmConeeTra.OperatorID =zsAnmHea.OperatorID ) And (zsAnmConeeTra.VorgangID = zsAnmHea.VorgangID ) And (zsAnmConeeTra.AnmID = zsAnmHea.AnmID )),'')EORI_Empfänger
, isnull((SELECT Na FROM zsAnmConeeTra WHERE (zsAnmConeeTra.LizenzNr = zsAnmHea.LizenzNr ) And (zsAnmConeeTra.OperatorID =zsAnmHea.OperatorID ) And (zsAnmConeeTra.VorgangID = zsAnmHea.VorgangID ) And (zsAnmConeeTra.AnmID = zsAnmHea.AnmID )),'')Empfänger
from zsAnmRefs
inner join zsAnmDHFRefs on zsAnmRefs.LizenzNr=zsAnmDHFRefs.LizenzNr and zsAnmRefs.AnmID=zsAnmDHFRefs.AnmID and zsAnmRefs.VorgangID=zsAnmDHFRefs.VorgangID and zsAnmRefs.OperatorID=zsAnmDHFRefs.OperatorID
inner join zsAnmGdsitem on zsAnmRefs.LizenzNr=zsAnmGdsitem.LizenzNr and zsAnmRefs.AnmID=zsAnmGdsitem.AnmID and zsAnmRefs.VorgangID=zsAnmGdsitem.VorgangID and zsAnmRefs.OperatorID=zsAnmGdsitem.OperatorID
inner join zsAnmHea on zsAnmHea.LizenzNr=zsAnmGdsitem.LizenzNr and zsAnmHea.AnmID=zsAnmGdsitem.AnmID and zsAnmHea.VorgangID=zsAnmGdsitem.VorgangID and zsAnmHea.OperatorID=zsAnmGdsitem.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
where DecDT between '" & txtVon._value & "' and '" & txtBis._value & "'
and
(
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 7205 and 7229
OR left(ComCd,4) between 7603 and 7614
OR ComCd like '25070080%'
OR ComCd like '283421%'
OR ComCd like '260112%'
OR ComCd like '720211%'
OR ComCd like '720219%'
OR ComCd like '720241%'
OR ComCd like '720249%'
OR ComCd like '720260%'
OR ComCd like '280410%'
)
and ComCd not like '310560%'
and crn is not null
and zsAnmDHFRefs.ErledigungsTypID like 'F%'
"
If cbxVERAG.Checked Or cbxIMEX.Checked Or cbxUNISPED.Checked Then
SQLSTR &= "
and DecRep IN(3)
"
Else
SQLSTR &= "
and (SELECT TIN FROM zsAnmConeeTra WHERE (zsAnmConeeTra.LizenzNr = zsAnmHea.LizenzNr ) And (zsAnmConeeTra.OperatorID =zsAnmHea.OperatorID ) And (zsAnmConeeTra.VorgangID = zsAnmHea.VorgangID ) And (zsAnmConeeTra.AnmID = zsAnmHea.AnmID )) LIKE '" & EORI & "'
"
End If
SQLSTR &= " order by Absender"
Dim dt = SQL.loadDgvBySql(SQLSTR, EZOLL_SQL, 600)
If dt IsNot Nothing AndAlso dt.Rows.Count > 0 Then
Dim path = VERAG_PROG_ALLGEMEIN.cProgramFunctions.genExcelFromDT_NEW(dt,,,,, False, EORI & "_Detailbericht_" & txtVon._value & "-" & txtBis._value)
If sender Is btnCBAM_DS_DHF_VERAG Then
btnCBAM_DS_DHF_VERAG_Detail.Tag = path
btnCBAM_DS_DHF_VERAG_Detail.Enabled = True
btnCBAM_DS_DHF_VERAG_Copy.Enabled = True
End If
If sender Is btnCBAM_DS_DHF_UNISPED Then
btnCBAM_DS_DHF_UNISPED_Detail.Tag = path
btnCBAM_DS_DHF_UNISPED_Detail.Enabled = True
btnCBAM_DS_DHF_UNISPED_Copy.Enabled = True
End If
Me.Cursor = Cursors.Default
End If
Catch ex As Exception
VERAG_PROG_ALLGEMEIN.cErrorHandler.ERR(ex.Message, ex.StackTrace, System.Reflection.MethodInfo.GetCurrentMethod.Name)
End Try
Me.Cursor = Cursors.Default
'-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
If sender Is btnCBAM_DS_DHF_VERAG Then
btnCBAM_DS_DHF_VERAG_Summe.Enabled = False
btnCBAM_DS_DHF_VERAG_Summe.Tag = ""
End If
If sender Is btnCBAM_DS_DHF_UNISPED Then
btnCBAM_DS_DHF_UNISPED_Summe.Enabled = False
btnCBAM_DS_DHF_UNISPED_Summe.Tag = ""
End If
Try
Dim EORI = txtEori.Text
If cbxVERAG.Checked Then EORI = "VERAG"
If EORI = "" Then MsgBox("EORI eingeben!") : Exit Sub
If txtVon._value = "" Then MsgBox("Datum von eingeben!") : Exit Sub
If txtBis._value = "" Then MsgBox("Datum bis eingeben!") : Exit Sub
Me.Cursor = Cursors.WaitCursor
Dim SQLSTR = "
select left(zsAnmGdsitem.ComCd,8) Tarifnummer, sum(Net)Eigenmasse, sum(ItVal)Rechnungspreis,Orig
from zsAnmRefs
inner join zsAnmDHFRefs on zsAnmRefs.LizenzNr=zsAnmDHFRefs.LizenzNr and zsAnmRefs.AnmID=zsAnmDHFRefs.AnmID and zsAnmRefs.VorgangID=zsAnmDHFRefs.VorgangID and zsAnmRefs.OperatorID=zsAnmDHFRefs.OperatorID
inner join zsAnmGdsitem on zsAnmRefs.LizenzNr=zsAnmGdsitem.LizenzNr and zsAnmRefs.AnmID=zsAnmGdsitem.AnmID and zsAnmRefs.VorgangID=zsAnmGdsitem.VorgangID and zsAnmRefs.OperatorID=zsAnmGdsitem.OperatorID
inner join zsAnmHea on zsAnmHea.LizenzNr=zsAnmGdsitem.LizenzNr and zsAnmHea.AnmID=zsAnmGdsitem.AnmID and zsAnmHea.VorgangID=zsAnmGdsitem.VorgangID and zsAnmHea.OperatorID=zsAnmGdsitem.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
where DecDT between '" & txtVon._value & "' and '" & txtBis._value & "'
and
(
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 7205 and 7229
OR left(ComCd,4) between 7603 and 7614
OR ComCd like '25070080%'
OR ComCd like '283421%'
OR ComCd like '260112%'
OR ComCd like '720211%'
OR ComCd like '720219%'
OR ComCd like '720241%'
OR ComCd like '720249%'
OR ComCd like '720260%'
OR ComCd like '280410%'
)
and ComCd not like '310560%'
and crn is not null
and zsAnmDHFRefs.ErledigungsTypID like 'F%'
"
If cbxVERAG.Checked Then
SQLSTR &= "
and DecRep IN(3)
"
Else
SQLSTR &= "
and (SELECT TIN FROM zsAnmConeeTra WHERE (zsAnmConeeTra.LizenzNr = zsAnmHea.LizenzNr ) And (zsAnmConeeTra.OperatorID =zsAnmHea.OperatorID ) And (zsAnmConeeTra.VorgangID = zsAnmHea.VorgangID ) And (zsAnmConeeTra.AnmID = zsAnmHea.AnmID )) LIKE '" & EORI & "'
"
End If
SQLSTR &= " GROUP BY Orig,left(zsAnmGdsitem.ComCd,8) "
Dim dt = SQL.loadDgvBySql(SQLSTR, EZOLL_SQL, 600)
If dt IsNot Nothing AndAlso dt.Rows.Count > 0 Then
Dim path = VERAG_PROG_ALLGEMEIN.cProgramFunctions.genExcelFromDT_NEW(dt,,,,, False, EORI & "_Summenbericht_" & txtVon._value & "-" & txtBis._value)
If sender Is btnCBAM_DS_DHF_VERAG Then
btnCBAM_DS_DHF_VERAG_Summe.Tag = path
btnCBAM_DS_DHF_VERAG_Summe.Enabled = True
btnCBAM_DS_DHF_VERAG_Copy.Enabled = True
End If
If sender Is btnCBAM_DS_DHF_UNISPED Then
btnCBAM_DS_DHF_UNISPED_Summe.Tag = path
btnCBAM_DS_DHF_UNISPED_Summe.Enabled = True
btnCBAM_DS_DHF_UNISPED_Copy.Enabled = True
End If
Me.Cursor = Cursors.Default
End If
Catch ex As Exception
VERAG_PROG_ALLGEMEIN.cErrorHandler.ERR(ex.Message, ex.StackTrace, System.Reflection.MethodInfo.GetCurrentMethod.Name)
End Try
Me.Cursor = Cursors.Default
End Sub
Private Sub CheckBox1_CheckedChanged(sender As Object, e As EventArgs) Handles cbxVERAG.CheckedChanged, cbxUNISPED.CheckedChanged, cbxIMEX.CheckedChanged
txtEori.Enabled = Not (cbxVERAG.Checked Or cbxUNISPED.Checked Or cbxIMEX.Checked)
End Sub
Private Sub btnCBAM_DS_DAKOSY_XML_Click(sender As Object, e As EventArgs) Handles btnCBAM_DS_DAKOSY_XML.Click
End Sub
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
End Sub
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
Dim f As New List(Of String)
If btnCBAM_DS_DAKOSY_XML.Tag <> "" Then f.Add(btnCBAM_DS_DAKOSY_XML.Tag)
If f.Count > 0 Then
'Zwischenablage
Clipboard.Clear()
Dim d As New DataObject(DataFormats.FileDrop, f.ToArray)
Clipboard.SetDataObject(d, True)
End If
End Sub
Private Sub Button3_Click(sender As Object, e As EventArgs)
Dim f As New List(Of String)
If btnCBAM_DS_DAKOSY_Detail.Tag <> "" Then f.Add(btnCBAM_DS_DAKOSY_Detail.Tag)
If btnCBAM_DS_DAKOSY_Summe.Tag <> "" Then f.Add(btnCBAM_DS_DAKOSY_Summe.Tag)
If btnCBAM_DS_DAKOSY_XML.Tag <> "" Then f.Add(btnCBAM_DS_DAKOSY_XML.Tag)
If f.Count > 0 Then
'Zwischenablage
Clipboard.Clear()
Dim d As New DataObject(DataFormats.FileDrop, f.ToArray)
Clipboard.SetDataObject(d, True)
End If
End Sub
Private Sub btnCBAM_DS_TELOTEC_Click(sender As Object, e As EventArgs) Handles btnCBAM_DS_TELOTEC.Click
btnCBAM_DS_TELOTEC_Detail.Enabled = False
btnCBAM_DS_TELOTEC_Copy.Enabled = False
btnCBAM_DS_TELOTEC_Detail.Tag = ""
Try
Dim EORI = txtEori.Text
If cbxVERAG.Checked Then EORI = "VERAG"
If EORI = "" Then MsgBox("EORI eingeben!") : Exit Sub
If txtVon._value = "" Then MsgBox("Datum von eingeben!") : Exit Sub
If txtBis._value = "" Then MsgBox("Datum bis eingeben!") : Exit Sub
Me.Cursor = Cursors.WaitCursor
Dim SQLSTR = "
SELECT
telanm_CRN Registriernummer
,Pos_ID PositionsNummer
,dec_CreateDate Anmeldedatum
,telanm_BezugsNr BezugsNr
,Declarant_DecRep VertretungsVerhaeltnis
,Item_ComCd Tarifnummer
,dec_TotNet Eigenmasse
,Locs_Disp VersendungsLand
, Locs_Dest Bestimmungsland
,Item_ItVal Rechnungspreis
,ValData_InvCurr Rechnungswaehrung
,ConeeTra_TIN as Empfänger
,ConeeTra_Na as Empfänger_
,ConorTra_TIN as Absender
,ConorTra_Na as Absender_
FROM [VERAG].[dbo].[tblTelotec_Anmeldung]
inner join tblTelotec_Positionsdaten on telpos_telanmId=telanm_id
where 1=1
and
(
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 7205 and 7229
OR left(Item_ComCd,4) between 7603 and 7614
OR Item_ComCd like '25070080%'
OR Item_ComCd like '283421%'
OR Item_ComCd like '260112%'
OR Item_ComCd like '720211%'
OR Item_ComCd like '720219%'
OR Item_ComCd like '720241%'
OR Item_ComCd like '720249%'
OR Item_ComCd like '720260%'
OR Item_ComCd like '280410%'
)
and Item_ComCd not like '310560%'
and telnam_aktuellsteNachricht=1
and telanm_ART ='EUA'
and dec_CreateDate between '" & txtVon._value & "' and '" & txtBis._value & "'
"
If cbxVERAG.Checked Or cbxIMEX.Checked Or cbxUNISPED.Checked Then
SQLSTR &= "
and Declarant_DecRep IN(1,3,5,7)
"
Else
SQLSTR &= "
and ConeeTra_TIN='" & EORI & "' /*and Declarant_DecRep NOT IN(1,3,5,7)*/
"
End If
SQLSTR &= " order by Absender,telanm_CRN "
Dim dt = SQL.loadDgvBySql(SQLSTR, "FMZOLL", 600)
If dt IsNot Nothing AndAlso dt.Rows.Count > 0 Then
Dim path = VERAG_PROG_ALLGEMEIN.cProgramFunctions.genExcelFromDT_NEW(dt,,,,, False, EORI & "_Detailbericht_" & txtVon._value & "-" & txtBis._value,, False)
btnCBAM_DS_TELOTEC_Detail.Tag = path
btnCBAM_DS_TELOTEC_Detail.Enabled = True
btnCBAM_DS_TELOTEC_Copy.Enabled = True
Me.Cursor = Cursors.Default
End If
Catch ex As Exception
VERAG_PROG_ALLGEMEIN.cErrorHandler.ERR(ex.Message, ex.StackTrace, System.Reflection.MethodInfo.GetCurrentMethod.Name)
End Try
Me.Cursor = Cursors.Default
'-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
'btnCBAM_DS_DAKOSY_Summe.Enabled = False
'btnCBAM_DS_DAKOSY_Summe.Tag = ""
'Try
' Dim EORI = txtEori.Text
' If cbxVERAG.Checked Then EORI = "VERAG"
' If EORI = "" Then MsgBox("EORI eingeben!") : Exit Sub
' If txtVon._value = "" Then MsgBox("Datum von eingeben!") : Exit Sub
' If txtBis._value = "" Then MsgBox("Datum bis eingeben!") : Exit Sub
' Me.Cursor = Cursors.WaitCursor
' Dim SQLSTR = "
' SELECT
' left(ezaWP_WarennummerEZT,8) Tarifnummer,sum(ezaWP_Eigenmasse)Eigenmasse,sum(ezaWP_Rohmasse)Rohmasse,sum(ezaWP_Artikelpreis)Rechnungspreis,eza_VersendungsLandCode VersendungsLand ,isnull(ezaWP_AnmeldeVErfahren,'') Verfahren,isnull([ezaWP_VerfahrensCodeVorangegangenesVerfahren],'') VorangegangenesVerfahren
' FROM [VERAG].[dbo].[tblDakosy_EZA]
' inner join tblDakosy_EZA_Warenposition on ezaWP_EzaId=eza_Id
' where
' eza_anmeldedatum between '" & txtVon._value & "' and '" & txtBis._value & "'
' and
' (
' 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 7205 and 7229
' OR left(ezaWP_WarennummerEZT,4) between 7603 and 7614
' OR ezaWP_WarennummerEZT like '25070080%'
' OR ezaWP_WarennummerEZT like '283421%'
' OR ezaWP_WarennummerEZT like '260112%'
' OR ezaWP_WarennummerEZT like '720211%'
' OR ezaWP_WarennummerEZT like '720219%'
' OR ezaWP_WarennummerEZT like '720241%'
' OR ezaWP_WarennummerEZT like '720249%'
' OR ezaWP_WarennummerEZT like '720260%'
' OR ezaWP_WarennummerEZT like '280410%'
' )
' and ezaWP_WarennummerEZT not like '310560%'
' and (eza_status between 50 and 60 or [eza_ANR] LIKE 'ATC%')
' "
' If cbxVERAG.Checked Then
' SQLSTR &= "
' and eza_VertretungsVerhaeltnisCode=2
' "
' Else
' SQLSTR &= "
' and (select isnull([ezaAd_NameFirma1],[ezaAd_TeilnehmerEORI]) FROM tblDakosy_EZA_Adressen WHERE ezaAd_EZAId=eza_Id and [ezaAd_AdressTyp]='CN')='" & EORI & "'
' "
' End If
' SQLSTR &= " group by eza_VersendungsLandCode,left(ezaWP_WarennummerEZT,8),ezaWP_AnmeldeVErfahren,ezaWP_VerfahrensCodeVorangegangenesVerfahren"
' Dim dt = SQL.loadDgvBySql(SQLSTR, "FMZOLL", 600)
' If dt IsNot Nothing AndAlso dt.Rows.Count > 0 Then
' Dim path = VERAG_PROG_ALLGEMEIN.cProgramFunctions.genExcelFromDT_NEW(dt,,,,, False, EORI & "_Summenbericht_" & txtVon._value & "-" & txtBis._value)
' btnCBAM_DS_DAKOSY_Summe.Tag = path
' btnCBAM_DS_DAKOSY_Summe.Enabled = True
' btnCBAM_DS_DAKOSY_Copy.Enabled = True
' Me.Cursor = Cursors.Default
' End If
''----- XML ----------------------------------------------------------------------------------------------------------------------------------------
'btnCBAM_DS_DAKOSY_XML.Enabled = False
'btnCBAM_DS_DAKOSY_XML.Tag = ""
'If dt IsNot Nothing AndAlso dt.Rows.Count > 0 Then
' '---------------------------------------------------------------------------------------------------------------------------------------------
' doCBAM_XML(dt, EORI)
' '---------------------------------------------------------------------------------------------------------------------------------------------
'End If
''---------------------------------------------------------------------------------------------------------------------------------------------
'Catch ex As Exception
' VERAG_PROG_ALLGEMEIN.cErrorHandler.ERR(ex.Message, ex.StackTrace, System.Reflection.MethodInfo.GetCurrentMethod.Name)
'End Try
Me.Cursor = Cursors.Default
End Sub
Public Function createExcelForGreenPulse(dt As DataTable, EORI As String, Importer_City As String)
Dim EORI_Ort As String = ""
If AD IsNot Nothing Then
EORI_Ort = AD.Ort
End If
Dim Path_GP = ""
Dim sPath As String = Environment.GetFolderPath(Environment.SpecialFolder.Personal) & "\VERAG\SR\"
If Not My.Computer.FileSystem.DirectoryExists(sPath) Then
My.Computer.FileSystem.CreateDirectory(sPath)
End If
Dim exclApp As Object 'as Application
Dim Datei As Object 'Workbook
Dim Blatt As Object 'Microsoft.Office.Interop.Excel.Worksheet 'As Object 'as Worksheet
exclApp = CreateObject("Excel.Application")
With exclApp
.Visible = False
Try
Path_GP = sPath & EORI & "_Detailbericht_GP_" & txtVon._value & "-" & txtBis._value & " .xlsx"
While System.IO.File.Exists(Path_GP)
Path_GP = sPath & EORI & "_Detailbericht_GP_" & txtVon._value & "-" & txtBis._value & Now.ToString("ddMMyyyyHHmmss") & ".xlsx"
End While
My.Computer.FileSystem.WriteAllBytes(Path_GP, My.Resources.CBAM_Auswertung_GP, False)
System.Threading.Thread.Sleep(200)
GC.Collect()
GC.WaitForPendingFinalizers()
Catch ex As System.Exception
' MsgBox(ex.Message)
MsgBox("ERROR 01: " & ex.Message & vbNewLine & ex.StackTrace)
Me.Cursor = Cursors.Default
Return ""
End Try
Datei = .Workbooks.Open(Path_GP)
Blatt = Datei.Worksheets(1)
Dim cnt = 3
Dim rowcounter As Integer = 0
For Each row As DataRow In dt.Rows
Blatt.Range("A" & cnt).Value = row("declaration no")
Blatt.Range("B" & cnt).Value = row("declaration date")
Blatt.Range("C" & cnt).Value = row("importer identification number")
Blatt.Range("D" & cnt).Value = row("exporter identification number")
Blatt.Range("E" & cnt).Value = row("commodity code")
Blatt.Range("F" & cnt).Value = row("origin country code")
Blatt.Range("G" & cnt).Value = row("requested procedure")
Blatt.Range("H" & cnt).Value = row("previous procedure")
Blatt.Range("I" & cnt).Value = row("net mass")
Blatt.Range("J" & cnt).Value = row("type of measurement unit")
Blatt.Range("K" & cnt).Value = row("invoice numbers")
Blatt.Range("L" & cnt).Value = row("invoice date")
Blatt.Range("M" & cnt).Value = row("member state auth")
Blatt.Range("N" & cnt).Value = row("discharge bill waiver")
Blatt.Range("O" & cnt).Value = row("authorisation")
Blatt.Range("P" & cnt).Value = row("start time")
Blatt.Range("Q" & cnt).Value = row("end time")
Blatt.Range("R" & cnt).Value = row("deadline")
Blatt.Range("S" & cnt).Value = row("reporting declarant EORI number")
Blatt.Range("T" & cnt).Value = row("type of representation")
Blatt.Range("U" & cnt).Value = row("importer title")
Blatt.Range("V" & cnt).Value = row("importer email")
Blatt.Range("W" & cnt).Value = row("importer phone")
Blatt.Range("X" & cnt).Value = row("importer country code or member state")
Blatt.Range("Y" & cnt).Value = row("importer subdivision")
Blatt.Range("Z" & cnt).Value = IIf(Importer_City <> "", Importer_City, row("importer city"))
Blatt.Range("AA" & cnt).Value = row("importer street")
Blatt.Range("AB" & cnt).Value = row("importer street additional")
Blatt.Range("AC" & cnt).Value = row("importer address number")
Blatt.Range("AD" & cnt).Value = row("importer post code")
Blatt.Range("AE" & cnt).Value = row("importer po box")
Blatt.Range("AF" & cnt).Value = row("importer coordinate longitude (x)")
Blatt.Range("AG" & cnt).Value = row("importer coordinate latitude (y)")
Blatt.Range("AH" & cnt).Value = row("exporter title")
Blatt.Range("AI" & cnt).Value = row("exporter country code or member state")
Blatt.Range("AJ" & cnt).Value = row("exporter street")
Blatt.Range("AK" & cnt).Value = row("exporter street additional")
cnt += 1
rowcounter += 1
Next
Datei.Save()
Datei.Close(SaveChanges:=True)
Datei = Nothing
End With
exclApp.Quit()
exclApp = Nothing
Return Path_GP
End Function
End Class