VERAG_CustomsDeclarations, einheitliches Datenmodell IMPORT + Rountinemanager Anpassung

This commit is contained in:
2026-01-01 00:55:46 +01:00
parent eab90bc81a
commit ff7682582d
12 changed files with 1564 additions and 304 deletions

View File

@@ -7,251 +7,352 @@ Public Class cImporter_DakosyToVERAG
' ========================================================================
' MAIN ENTRY
' ========================================================================
Public Function ImportDakosyEZA(eza As cDakosyEZA) As Boolean
Public Function ImportDakosyEZA(MRN As String, Optional overwrite As Boolean = True) As Boolean
If MRN Is Nothing Then Return False
If MRN = "" Then Return False
Dim EZA = cDakosyEZA.LOADByMRN(MRN, True)
If EZA IsNot Nothing Then Return ImportDakosyEZA(EZA)
Return False
End Function
Public Function ImportDakosyEZA(eza As cDakosyEZA, Optional overwrite As Boolean = True) As Boolean
Try
' 1) Duplikatscheck auf Kopfebene (MRN / LRN + System)
If ExistsInVERAG(eza) Then
Console.WriteLine($"Skip import (duplicate): MRN={If(eza.eza_MRN, "")} / LRN={If(eza.eza_ANR, "")}")
If eza Is Nothing Then Return False
If String.IsNullOrWhiteSpace(eza.eza_MRN) AndAlso String.IsNullOrWhiteSpace(eza.eza_ANR) Then Return False
If If(eza.eza_MRN, "") = "" AndAlso eza.eza_ANR.ToString.StartsWith("ATA") Then ' Keine finale Anmeldung!
Return False
End If
' 2) HEADER anlegen
Dim zaId = Save_Header(eza)
If zaId <= 0 Then
Console.WriteLine("Error: Header save failed")
Return False
' ================================================================
' DUPLIKATSPRÜFUNG
' ================================================================
If Not overwrite Then
If ExistsInVERAG(eza) Then Return False
End If
' 3) ITEMS speichern (alle Positionen kein eigener Duplikatscheck)
Save_Items(eza, zaId)
' ================================================================
' HEADER
' ================================================================
Dim VERAG_ZA As cVERAG_CustomsDeclarations
If If(eza.eza_MRN, If(eza.eza_ANR, "")) = "" Then
VERAG_ZA = New cVERAG_CustomsDeclarations
Else
VERAG_ZA = cVERAG_CustomsDeclarations.loadByMRN(If(eza.eza_MRN, If(eza.eza_ANR, "")), False)
End If
' 4) DUTIES speichern (aus AUFSCHUB kein eigener Duplikatscheck)
Save_Duties(eza, zaId)
VERAG_ZA.za_System = "DAKOSY"
VERAG_ZA.za_CustomsSystem = "ATLAS"
VERAG_ZA.za_REGIME = "IMPORT"
VERAG_ZA.za_CustomsSystemCountry = "DE"
VERAG_ZA.za_IsExternalSystem = False
VERAG_ZA.za_IsFinalDeclaration = True
' 5) DOCS speichern (Unterlagen auf Kopfebene kein eigener Duplikatscheck)
Save_Docs(eza, zaId)
VERAG_ZA.za_Firma = eza.eza_firma
VERAG_ZA.za_Niederlassung = eza.eza_niederlassung
Return True
VERAG_ZA.za_MRN = If(eza.eza_MRN, eza.eza_ANR)
VERAG_ZA.za_LRN = eza.eza_ObjectName
If eza.eza_Anmeldedatum IsNot Nothing AndAlso eza.eza_Anmeldedatum.ToString <> "" Then
VERAG_ZA.za_DeclarationDate = CDate(eza.eza_Anmeldedatum)
VERAG_ZA.za_ReleaseDate = CDate(eza.eza_Anmeldedatum)
Else
Dim dateumRelease As String = (New VERAG_PROG_ALLGEMEIN.SQL).DLookup("isnull(dySt_DakosyTransaktionsDatum,'')", "[tblDakosy_Statusmeldungen]", " dySt_status = 60 And dySt_dyId = '" & eza.eza_dyaAnmID & "' Order By [dySt_DakosyTransaktionsDatum] desc", "FMZOLL",)
If dateumRelease <> "" AndAlso IsDate(dateumRelease) Then
VERAG_ZA.za_DeclarationDate = CDate(dateumRelease)
VERAG_ZA.za_ReleaseDate = CDate(dateumRelease)
Else
VERAG_ZA.za_DeclarationDate = ToNullableDate(If(eza.eza_Anmeldedatum, eza.eza_LetzteBearbeitung))
VERAG_ZA.za_ReleaseDate = ToNullableDate(If(eza.eza_Anmeldedatum, eza.eza_LetzteBearbeitung))
End If
End If
VERAG_ZA.za_MainProcedure = eza.eza_VerfahrenBeantragtCode
VERAG_ZA.za_RepresentationCode = eza.eza_VertretungsVerhaeltnisCode
VERAG_ZA.za_FiscalRepFlag = ToNullableBool(eza.eza_FiskalvertretungKz)
VERAG_ZA.za_ApplicantVATNo = ToStringSafe(eza.eza_UstIdAnmelder)
VERAG_ZA.za_ApplicantTaxOffice = ToStringSafe(eza.eza_FinanzamtAnmelder)
VERAG_ZA.za_TaxDeduction = ToNullableBool(eza.eza_Vorsteuerabzug)
VERAG_ZA.za_CountryDispatch = eza.eza_VersendungsLandCode
VERAG_ZA.za_CountryDestination = eza.eza_Bestimmungsland
VERAG_ZA.za_CountryDestinationState = eza.eza_Bestimmungsbundesland
VERAG_ZA.za_ContainerNr1 = eza.eza_ContainerNr1
VERAG_ZA.za_ContainerNr2 = eza.eza_ContainerNr2
VERAG_ZA.za_ContainerNr3 = eza.eza_ContainerNr3
VERAG_ZA.za_ContainerNr4 = eza.eza_ContainerNr4
VERAG_ZA.za_ContainerNr5 = eza.eza_ContainerNr5
VERAG_ZA.za_ContainerNr6 = eza.eza_ContainerNr6
VERAG_ZA.za_ContainerNr7 = eza.eza_ContainerNr7
VERAG_ZA.za_ContainerNr8 = eza.eza_ContainerNr8
VERAG_ZA.za_ContainerNr9 = eza.eza_ContainerNr9
VERAG_ZA.za_MeansOfTransport_Vehicle = eza.eza_KennzeichenNameBefoerderungsmittelAnkunft
VERAG_ZA.za_MeansOfTransport_Nationality = eza.eza_BeförderungsmittelGrenzeStaatszugehörigkeitCode
VERAG_ZA.za_MeansOfTransport_Type = eza.eza_BeförderungsmittelGrenzeArt
VERAG_ZA.za_CountryImport = "DE"
VERAG_ZA.za_WarehouseCode = eza.eza_Warenort
VERAG_ZA.za_InvoiceAmount = eza.eza_Rechnungspreis
VERAG_ZA.za_InvoiceCurrency = eza.eza_Rechnungswaehrung
VERAG_ZA.za_DV1Flag = ToNullableBool(eza.eza_DV1Kz)
VERAG_ZA.za_PrevDocument_No = eza.eza_VorpapierNr
VERAG_ZA.za_PrevDocument_Type = eza.eza_VorpapierArtCode
VERAG_ZA.za_Incoterms = eza.eza_LieferbedingungCode
VERAG_ZA.za_IncotermsPlace = eza.eza_LieferbedingungOrt
VERAG_ZA.za_Sachbearbeiter = eza.eza_AnmeldenderBearbeiterName
Dim DY = cDakosy_Zollanmeldungen.LOADById(eza.eza_dyaAnmID)
If DY IsNot Nothing Then
VERAG_ZA.za_AvisoId = DY.dy_AvisoId
VERAG_ZA.za_SendungsId = DY.dy_SendungsId
End If
VERAG_ZA.za_TransportModeBorder = ToStringSafe(eza.eza_VerkehrszweigGrenze)
' ================================================================
' ADRESSEN
' ================================================================
If eza.eza_ADRESSEN IsNot Nothing Then
For Each p In eza.eza_ADRESSEN
Dim party As New cVERAG_CustomsDeclarations_Parties
party.zaParty_Role = p.ezaAd_AdressTyp
party.zaParty_EORI = p.ezaAd_TeilnehmerEORI
party.zaParty_EORI_NL = p.ezaAd_TeilnehmerNLNR
party.zaParty_Name = p.ezaAd_NameFirma1
party.zaParty_Street = p.ezaAd_StrasseHausNr1
party.zaParty_PostalCode = p.ezaAd_PLZ
party.zaParty_City = p.ezaAd_Ort
party.zaParty_Country = p.ezaAd_LandCode
'party.zaParty_TIN = p.
party.zaParty_VATNumber = p.ezaAd_UStIDAnmelder
party.zaParty_TaxOffice = p.ezaAd_FinanzamtIDAnmelder
If If(party.zaParty_EORI, "") <> "" Then
Dim AD As VERAG_PROG_ALLGEMEIN.cAdressen = cZOLL_IMPORT.getAdresseFromEORI(party.zaParty_EORI, "", "", True)
If AD IsNot Nothing Then
party.zaParty_Name = (If(AD.Name_1, "") & " " & If(AD.Name_2, "")).trim
party.zaParty_Country = VERAG_PROG_ALLGEMEIN.cProgramFunctions.getISO2Land(AD.LandKz)
party.zaParty_City = AD.Ort
party.zaParty_Street = AD.Straße
'party.ImporterAddressNumber = ""
party.zaParty_PostalCode = AD.PLZ
'party.ImporterEmail = AD.E_Mail
'party.ImporterPhone = AD.Telefon
End If
End If
VERAG_ZA.Parties.Add(party)
Next
End If
' ================================================================
' ABGABEN
' ================================================================
If eza.eza_AUFSCHUB IsNot Nothing Then
For Each d In eza.eza_AUFSCHUB
Dim duty As New cVERAG_CustomsDeclarations_Duty
duty.zaDuty_ApplicationType = d.ezaAfb_ArtAufschubantrag
duty.zaDuty_AccountType = d.ezaAfb_Aufschubart
duty.zaDuty_AccountHeadCustoms = d.ezaAfb_HZA
duty.zaDuty_AccountNo = d.ezaAfb_KontoNr
duty.zaDuty_AccountEORI = d.ezaAfb_AufschubnehmerEORI
duty.zaDuty_AccountHolderName = d.AufschubnehmerName
duty.zaDuty_DutyType = d.ezaAfb_AbgabeArt
duty.zaDuty_BIN = d.ezaAfb_AufschuBIN
duty.zaDuty_AmountEUR = ToNullableDecimal(d.ezaAfb_Abgabenbetrag)
duty.zaDuty_AmountForeign = ToNullableDecimal(d.ezaAfb_Abgabenbetrag)
duty.zaDuty_Currency = "EUR"
duty.zaDuty_LimitDate = ToNullableDate(d.ezaAfb_Faelligkeit)
VERAG_ZA.Duties.Add(duty)
Next
End If
' ================================================================
' HEADER-UNTERLAGEN (ItemId = NULL)
' ================================================================
If eza.eza_UNTERLAGEN IsNot Nothing Then
For Each ul In eza.eza_UNTERLAGEN
Dim doc As New cVERAG_CustomsDeclarations_Document
doc.zaDoc_Section = ul.ezaUl_Bereich
doc.zaDoc_ItemId = Nothing
doc.zaDoc_Code = ul.ezaUl_Art
doc.zaDoc_Reference = ul.ezaUl_Nummer
doc.zaDoc_Date = ul.ezaUl_DatumAusstellung
VERAG_ZA.Documents.Add(doc)
Next
End If
' ================================================================
' POSITIONEN + POSITIONS-UNTERLAGEN
' ================================================================
If eza.eza_WARENPOS IsNot Nothing Then
For Each wp In eza.eza_WARENPOS
Dim item As New cVERAG_CustomsDeclarations_Item
item.zaItem_PosNo = ToInt(wp.ezaWP_PositionsNummer)
item.zaItem_ArticleCode = wp.ezaWP_Artikelnummer
item.zaItem_HSCode = wp.ezaWP_WarennummerEZT
item.zaItem_HSAddition1 = wp.ezaWP_Warennummerzusatz1
item.zaItem_HSAddition2 = wp.ezaWP_Warennummerzusatz2
item.zaItem_HSAddCodes1 = wp.ezaWP_WarennummerZusatzCode1
item.zaItem_HSAddCodes2 = wp.ezaWP_WarennummerZusatzCode2
item.zaItem_HSAddCodes3 = wp.ezaWP_WarennummerZusatzCode3
item.zaItem_HSAddCodes4 = wp.ezaWP_WarennummerZusatzCode4
item.zaItem_HSAddCodes5 = wp.ezaWP_WarennummerZusatzCode5
item.zaItem_HSAddCodes6 = wp.ezaWP_WarennummerZusatzCode6
item.zaItem_HSAddCodes7 = wp.ezaWP_WarennummerZusatzCode7
item.zaItem_HSAddCodes8 = wp.ezaWP_WarennummerZusatzCode8
item.zaItem_HSAddCodes9 = wp.ezaWP_WarennummerZusatzCode9
item.zaItem_HSAddCodes10 = wp.ezaWP_WarennummerZusatzCode10
item.zaItem_Description = wp.ezaWP_Warenbezeichnung
item.zaItem_PrevProcedure = wp.ezaWP_VerfahrensCodeVorangegangenesVerfahren
item.zaItem_PreferentialCountry = wp.ezaWP_Praeferenzursprungsland
item.zaItem_PackageColli = (wp.ezaWP_PackstueckAnzahl)
item.zaItem_PackageType = wp.ezaWP_PackstueckArt
item.zaItem_GrossMass = ToNullableDecimal(wp.ezaWP_Rohmasse)
item.zaItem_NetMass = ToNullableDecimal(wp.ezaWP_Eigenmasse)
item.zaItem_InvoiceValueForeign = ToNullableDecimal(wp.ezaWP_Artikelpreis)
item.zaItem_InvoiceCurrency = wp.ezaWP_ArtikelpreisWaehrung
If If(wp.ezaWP_ArtikelpreisWaehrung, "") = "EUR" Then
item.zaItem_InvoiceValueEUR = ToNullableDecimal(wp.ezaWP_Artikelpreis)
End If
item.zaItem_CustomsValueEUR = ToNullableDecimal(wp.ezaWP_Zollwert)
item.zaItem_StatisticalValueEUR = ToNullableDecimal(wp.ezaWP_AHStatWert)
item.zaItem_OriginCountry = wp.ezaWP_UrsprungslandCode
item.zaItem_PreferenceCode = wp.ezaWP_BeguenstigungBenatragtCode
item.zaItem_PosAddition = If(wp.ezaWP_PositionsZusatz, "")
' -------------------------------
' POSITIONS-UNTERLAGEN
' -------------------------------
If wp.ezaWP_UNTERLAGEN IsNot Nothing Then
For Each ul In wp.ezaWP_UNTERLAGEN
Dim doc As New cVERAG_CustomsDeclarations_Document
doc.zaDoc_Section = ul.ezaWpUl_Bereich
doc.zaDoc_Code = ul.ezaWpUl_Art
doc.zaDoc_Reference = ul.ezaWpUl_Nummer
doc.zaDoc_Date = ToNullableDate(ul.ezaWpUl_DatumAusstellung)
doc.zaDoc_Presentation = ul.ezaWpUl_VorlageKz
doc.zaDoc_DepreciationAmount = (ul.ezaWpUl_AbschreibungsMenge)
doc.zaDoc_DepreciationUnitmeasurement = ul.ezaWpUl_AbschreibungsMengeMasseinheit
doc.zaDoc_DepreciationUnitmeasurementQualifier = ul.ezaWpUl_AbschreibungsMengeMasseinheitQualifier
item.Documents.Add(doc)
Next
End If
VERAG_ZA.Items.Add(item)
Next
End If
' ================================================================
' SAVE
' ================================================================
Return VERAG_ZA.SAVE()
Catch ex As Exception
VERAG_PROG_ALLGEMEIN.cErrorHandler.ERR(
ex.Message,
ex.StackTrace,
Reflection.MethodInfo.GetCurrentMethod().Name
)
cErrorHandler.ERR(ex.Message, ex.StackTrace, Reflection.MethodInfo.GetCurrentMethod.Name)
Return False
End Try
End Function
' ========================================================================
' DUPLICATE CHECK : MRN / LRN + SYSTEM
' ========================================================================
' =====================================================================
' DUPLIKATSPRÜFUNG
' =====================================================================
Private Function ExistsInVERAG(eza As cDakosyEZA) As Boolean
Dim sqlStr As String =
"SELECT TOP 1 1
FROM tblVERAG_Zollanmeldung
WHERE za_System = 'DAKOSY'
AND (
(za_MRN = @mrn AND @mrn IS NOT NULL)
OR (za_LRN = @lrn AND @lrn IS NOT NULL)
)"
Dim sql As String =
"SELECT TOP 1 1 FROM tblVERAG_CustomsDeclarations " &
"WHERE za_System='DAKOSY' " &
"AND (za_MRN=@mrn OR za_MRN=@anr)"
Dim p As New List(Of SQLVariable) From {
New SQLVariable("@mrn", If(eza.eza_MRN, DBNull.Value)),
New SQLVariable("@lrn", If(eza.eza_ANR, DBNull.Value))
}
Dim dt = SQL.loadDgvBySql_Param(sqlStr, "FMZOLL",, p)
Return (dt IsNot Nothing AndAlso dt.Rows.Count > 0)
New SQLVariable("mrn", eza.eza_MRN),
New SQLVariable("anr", eza.eza_ANR)
}
Dim dt = New SQL().loadDgvBySql_Param(sql, "VERAG", , p)
Return dt IsNot Nothing AndAlso dt.Rows.Count > 0
End Function
' =========================================================================
' Small helpers (falls du sie schon hast, kannst du diese entfernen)
' =========================================================================
Private Function ToStringSafe(v As Object) As String
If v Is Nothing Then Return Nothing
Dim s As String = TryCast(v, String)
If s IsNot Nothing Then Return s
Return Convert.ToString(v, Globalization.CultureInfo.InvariantCulture)
End Function
' ========================================================================
' HEADER SAVE
' ========================================================================
Private Function Save_Header(eza As cDakosyEZA) As Integer
Dim list As New List(Of SQLVariable)
' PK wird von SQL doSQLVarListID gesetzt
list.Add(New SQLVariable("za_Id", Nothing, , True, True))
list.Add(New SQLVariable("za_System", "DAKOSY"))
list.Add(New SQLVariable("za_MRN", eza.eza_MRN))
list.Add(New SQLVariable("za_LRN", eza.eza_ObjectName))
list.Add(New SQLVariable("za_Firma", eza.eza_firma))
list.Add(New SQLVariable("za_Zollstelle", eza.eza_AdressierteZollstelle))
list.Add(New SQLVariable("za_Sachbearbeiter", eza.eza_Bearbeiter))
' interne Zuordnungen
list.Add(New SQLVariable("AvisoId", eza.eza_dyaAnmID))
list.Add(New SQLVariable("SendungsId", Nothing))
Dim cmd As String =
"INSERT INTO tblVERAG_Zollanmeldung
(za_System,
za_MRN,
za_LRN,
za_Firma,
za_Zollstelle,
za_Sachbearbeiter,
AvisoId,
SendungsId)
VALUES
(@za_System,
@za_MRN,
@za_LRN,
@za_Firma,
@za_Zollstelle,
@za_Sachbearbeiter,
@AvisoId,
@SendungsId);
SELECT SCOPE_IDENTITY()"
Dim newId = SQL.doSQLVarListID(0, cmd, "FMZOLL", , list)
Return CInt(newId)
Private Function ToInt(v As Object) As Integer
If v Is Nothing Then Return 0
Dim s = Convert.ToString(v, Globalization.CultureInfo.InvariantCulture)
Dim i As Integer
If Integer.TryParse(s, Globalization.NumberStyles.Any, Globalization.CultureInfo.InvariantCulture, i) Then Return i
Return 0
End Function
Private Function ToNullableDecimal(v As Object) As Decimal?
If v Is Nothing Then Return Nothing
Dim s = Convert.ToString(v, Globalization.CultureInfo.InvariantCulture)
Dim d As Decimal
If Decimal.TryParse(s, Globalization.NumberStyles.Any, Globalization.CultureInfo.InvariantCulture, d) Then Return d
Return Nothing
End Function
' ========================================================================
' ITEMS SAVE (alle Positionen, kein Duplikatscheck)
' ========================================================================
Private Sub Save_Items(eza As cDakosyEZA, zaId As Integer)
Private Function ToNullableDate(v As Object) As Date?
If v Is Nothing Then Return Nothing
If TypeOf v Is Date Then Return CType(v, Date)
If eza.eza_WARENPOS Is Nothing Then Exit Sub
Dim s = Convert.ToString(v, Globalization.CultureInfo.InvariantCulture)
Dim dt As Date
If Date.TryParse(s, Globalization.CultureInfo.InvariantCulture, Globalization.DateTimeStyles.None, dt) Then Return dt
Return Nothing
End Function
For Each pos As cDakosy_EZA_Warenposition In eza.eza_WARENPOS
Dim list As New List(Of SQLVariable)
list.Add(New SQLVariable("za_Id", zaId))
' PosNr / Artikel / HS
list.Add(New SQLVariable("zaItem_PosNo", pos.ezaWP_PositionsNummer))
list.Add(New SQLVariable("zaItem_ArticleCode", pos.ezaWP_Artikelnummer))
list.Add(New SQLVariable("zaItem_HSCode", pos.ezaWP_WarennummerEZT))
' Ursprung / Origin
list.Add(New SQLVariable("zaItem_OriginCountry", pos.ezaWP_UrsprungslandCode))
' Zollwert / Statistikwert
list.Add(New SQLVariable("zaItem_CustomsValue", pos.ezaWP_Zollwert))
list.Add(New SQLVariable("zaItem_StatisticalValue", pos.ezaWP_AHStatWert))
' Begünstigungscode (Dakosy: ezaWP_BeguenstigungBenatragtCode)
list.Add(New SQLVariable("zaItem_BeguenstigungCode", pos.ezaWP_BeguenstigungBenatragtCode))
Dim cmd As String =
"INSERT INTO tblVERAG_Zollanmeldung_Items
(za_Id,
zaItem_PosNo,
zaItem_ArticleCode,
zaItem_HSCode,
zaItem_OriginCountry,
zaItem_CustomsValue,
zaItem_StatisticalValue,
zaItem_BeguenstigungCode)
VALUES
(@za_Id,
@zaItem_PosNo,
@zaItem_ArticleCode,
@zaItem_HSCode,
@zaItem_OriginCountry,
@zaItem_CustomsValue,
@zaItem_StatisticalValue,
@zaItem_BeguenstigungCode)"
SQL.doSQLVarList(cmd, "FMZOLL", , list)
Next
End Sub
' ========================================================================
' DUTIES SAVE (alle AUFSCHUB-Einträge, kein Duplikatscheck)
' ========================================================================
Private Sub Save_Duties(eza As cDakosyEZA, zaId As Integer)
If eza.eza_AUFSCHUB Is Nothing Then Exit Sub
For Each duty As cDakosy_EZA_Aufschub In eza.eza_AUFSCHUB
Dim list As New List(Of SQLVariable)
list.Add(New SQLVariable("za_Id", zaId))
' Dakosy-Aufschub Felder:
' ezaAfb_AbgabeArt -> DutyType
' ezaAfb_Abgabenbetrag -> Amount / AmountEUR
list.Add(New SQLVariable("DutyType", duty.ezaAfb_AbgabeArt))
list.Add(New SQLVariable("Amount", duty.ezaAfb_Abgabenbetrag))
' In der Aufschubtabelle gibt es keine Fremdwährungsspalte,
' i.d.R. ist der Betrag EUR -> Currency/AmountEUR entsprechend setzen
list.Add(New SQLVariable("Currency", "EUR"))
list.Add(New SQLVariable("AmountEUR", duty.ezaAfb_Abgabenbetrag))
Dim cmd As String =
"INSERT INTO tblVERAG_Zollanmeldung_Duties
(za_Id,
DutyType,
Amount,
Currency,
AmountEUR)
VALUES
(@za_Id,
@DutyType,
@Amount,
@Currency,
@AmountEUR)"
SQL.doSQLVarList(cmd, "FMZOLL", , list)
Next
End Sub
' ========================================================================
' DOCS SAVE (alle Unterlagen auf Kopfebene, kein Duplikatscheck)
' ========================================================================
Private Sub Save_Docs(eza As cDakosyEZA, zaId As Integer)
If eza.eza_UNTERLAGEN Is Nothing Then Exit Sub
For Each d As cDakosy_EZA_Unterlagen In eza.eza_UNTERLAGEN
Dim list As New List(Of SQLVariable)
list.Add(New SQLVariable("za_Id", zaId))
list.Add(New SQLVariable("Level", "H")) ' H = Header
list.Add(New SQLVariable("DocType", d.ezaUl_Art))
list.Add(New SQLVariable("DocNumber", d.ezaUl_Nummer))
Dim cmd As String =
"INSERT INTO tblVERAG_Zollanmeldung_Docs
(za_Id,
Level,
DocType,
DocNumber)
VALUES
(@za_Id,
@Level,
@DocType,
@DocNumber)"
SQL.doSQLVarList(cmd, "FMZOLL", , list)
Next
End Sub
Private Function ToNullableBool(v As Object) As Boolean?
If v Is Nothing Then Return Nothing
If TypeOf v Is Boolean Then Return CType(v, Boolean)
Dim s = Convert.ToString(v, Globalization.CultureInfo.InvariantCulture).Trim().ToLowerInvariant()
If s = "J" OrElse s = "1" OrElse s = "true" OrElse s = "y" OrElse s = "yes" Then Return True
If s = "N" OrElse s = "0" OrElse s = "false" OrElse s = "n" OrElse s = "no" Then Return False
Return Nothing
End Function
End Class