Imports System.Data.SqlClient
Imports System.Reflection

Public Class cTelotec_Anmeldung
    Property telanm_id As Object = Nothing '                       INT             Not NULL,
    Property telanm_ART As Object = Nothing '                      VARCHAR(50)    Not NULL,
    Property telanm_BezugsNr As Object = Nothing '                 VARCHAR(50)    Not NULL,
    Property telanm_Status As Object = Nothing '                   INT             Not NULL,
    Property telanm_Status_KEWILL_Equivalent As Object = Nothing ' INT             Not NULL,
    Property telanm_AvisoId As Object = Nothing '                  INT             NULL,
    Property telanm_SendungsId As Object = Nothing '               INT             NULL,
    Property telanm_Steuerbescheid_dsId As Object = Nothing '      INT             NULL,
    Property telanm_VBD_dsId As Object = Nothing '                 INT             NULL,
    Property telanm_LNR As Object = Nothing '                      VARCHAR(35)    NULL,
    Property telanm_CRN As Object = Nothing '                      VARCHAR(35)    NULL,
    Property telanm_Erstellung As Object = Nothing '               DATETIME        Default (getdate()) Not NULL,
    Property telanm_Erstellung_SB As Object = Nothing '            INT             NULL,
    Property telanm_LetzteBearbeitung As Object = Nothing '        DATETIME        Default (getdate()) Not NULL,
    Property telanm_LetzteBearbeitung_SB As Object = Nothing '     INT             NULL,
    Property telanm_firma As Object = Nothing '                    VARCHAR(10)    NULL,
    Property telanm_niederlassung As Object = Nothing '            VARCHAR(10)    NULL,
    Property Mandant_ID As Object = Nothing '                      VARCHAR(6)     Not NULL,
    Property Bereich_ID As Object = Nothing '                      VARCHAR(6)     Not NULL,
    Property Referenz_ID As Object = Nothing '                     VARCHAR(36)    Not NULL,
    Property ComIndicator As Object = Nothing '                    BIT             Not NULL,
    Property TransferStatus As Object = Nothing '                  VARCHAR(4)     NULL,
    Property MsgType As Object = Nothing '                         VARCHAR(10)    NULL,
    Property dec_ProzessArt As Object = Nothing '                  VARCHAR(4)     Not NULL,
    Property dec_Anmelde_ID As Object = Nothing '                  INT             NULL,
    Property dec_Template_ID As Object = Nothing '                 INT             NULL,
    Property dec_Lager_ID As Object = Nothing '                    VARCHAR(6)     NULL,
    Property dec_Lag_IND As Object = Nothing '                     BIT             NULL,
    Property dec_CreateDate As Object = Nothing '                  DATETIME        Not NULL,
    Property dec_CreatePersonalID As Object = Nothing '            VARCHAR(12)    NULL,
    Property dec_PreDec_IND As Object = Nothing '                  BIT             NULL,
    Property dec_TotNet As Object = Nothing '                      Decimal (14, 3) NULL,
    Property dec_TotNetSplit_IND As Object = Nothing '             BIT             NULL,
    Property dec_FillPackList_IND As Object = Nothing '            BIT             NULL,
    Property dec_Memo As Object = Nothing '                        VARCHAR(1000)  NULL,
    Property Refs_LRN As Object = Nothing '                        VARCHAR(22)    Not NULL,
    Property Refs_CRN As Object = Nothing '                        VARCHAR(21)    NULL,
    Property Refs_CSRN As Object = Nothing '                       VARCHAR(21)    NULL,
    Property Refs_ERN As Object = Nothing '                        VARCHAR(21)    NULL,
    Property Refs_FRN As Object = Nothing '                        VARCHAR(21)    NULL,
    Property Refs_Stat As Object = Nothing '                       VARCHAR(2)     NULL,
    Property Hea_DecTy As Object = Nothing '                       VARCHAR(9)     Not NULL,
    Property Hea_TotItem As Object = Nothing '                     INT             Not NULL,
    Property Hea_TotPack As Object = Nothing '                     INT             NULL,
    Property Hea_TotGross As Object = Nothing '                    Decimal (14, 3) NULL,
    Property Hea_DepLNG As Object = Nothing '                      VARCHAR(2)     NULL,
    Property Hea_DestLNG As Object = Nothing '                     VARCHAR(2)     NULL,
    Property Hea_PayTy As Object = Nothing '                       VARCHAR(1)     NULL,
    Property Hea_DefPayRef As Object = Nothing '                   INT             NULL,
    Property Hea_PerPayRef As Object = Nothing '                   INT             NULL,
    Property Hea_PayMet As Object = Nothing '                      INT             NULL,
    Property Hea_AExpRef As Object = Nothing '                     BIT             NULL,
    Property Hea_Fin As Object = Nothing '                         VARCHAR(2)     NULL,
    Property Hea_Simp As Boolean = False '                        BIT             Not NULL,
    Property Hea_IssD As Object = Nothing '                        Date            NULL,
    Property Hea_AuthID As Object = Nothing '                      VARCHAR(17)    NULL,
    Property Hea_TransDat As Object = Nothing '                    BIT             NULL,
    Property Hea_WoffD As Object = Nothing '                       Date            NULL,
    Property Hea_DecDT As Object = Nothing '                       Date            Not NULL,
    Property Hea_DecPlc As Object = Nothing '                      VARCHAR(35)    Not NULL,
    Property Hea_AccDT As Object = Nothing '                       DATETIME        NULL,
    Property Hea_SecInd As Object = Nothing '                      BIT             NULL,
    Property Hea_ComRef As Object = Nothing '                      VARCHAR(70)    NULL,
    Property Hea_ProArrDT As Object = Nothing '                    DATETIME        NULL,
    Property Hea_PlaDepDT As Object = Nothing '                    DATETIME        NULL,
    Property Locs_TradCtry As Object = Nothing '                   VARCHAR(2)     NULL,
    Property Locs_Disp As Object = Nothing '                       VARCHAR(2)     NULL,
    Property Locs_Dest As Object = Nothing '                       VARCHAR(2)     NULL,
    Property Locs_GdsLocCd As Object = Nothing '                   VARCHAR(17)    NULL,
    Property Locs_GdsLoc As Object = Nothing '                     VARCHAR(35)    NULL,
    Property Locs_GdsLocAuth As Object = Nothing '                 VARCHAR(17)    NULL,
    Property Locs_LoadPlcCd As Object = Nothing '                  VARCHAR(17)    NULL,
    Property Locs_LoadPlc As Object = Nothing '                    VARCHAR(35)    NULL,
    Property Locs_CustPlc As Object = Nothing '                    VARCHAR(17)    NULL,
    Property Locs_ArrLocCd As Object = Nothing '                   VARCHAR(17)    NULL,
    Property Locs_ArrLoc As Object = Nothing '                     VARCHAR(35)    NULL,
    Property Locs_ArrLocAuth As Object = Nothing '                 VARCHAR(17)    NULL,
    Property Locs_WarTy As Object = Nothing '                      VARCHAR(1)     NULL,
    Property Locs_WarCtry As Object = Nothing '                    VARCHAR(2)     NULL,
    Property Locs_War As Object = Nothing '                        VARCHAR(17)    NULL,
    Property Transp_InMo As Object = Nothing '                     INT             NULL,
    Property Transp_BordMo As Object = Nothing '                   INT             NULL,
    Property Transp_DepTy As Object = Nothing '                    INT             NULL,
    Property Transp_DepIdnt As Object = Nothing '                  VARCHAR(27)    NULL,
    Property Transp_DepNat As Object = Nothing '                   VARCHAR(2)     NULL,
    Property Transp_CrossTy As Object = Nothing '                  INT             NULL,
    Property Transp_CrossIdnt As Object = Nothing '                VARCHAR(27)    NULL,
    Property Transp_CrossIdntNat As Object = Nothing '             VARCHAR(2)     NULL,
    Property Transp_ContInd As Boolean = False '                  BIT             NULL,
    Property ValData_TermDelCd As Object = Nothing '               VARCHAR(3)     NULL,
    Property ValData_TermDelPlc As Object = Nothing '              VARCHAR(35)    NULL,
    Property ValData_TermDelSit As Object = Nothing '              VARCHAR(1)     NULL,
    Property ValData_InvCurr As Object = Nothing '                 VARCHAR(3)     NULL,
    Property ValData_ExRa As Object = Nothing '                    Decimal (20, 7) NULL,
    Property ValData_InvVal As Object = Nothing '                  Decimal (18, 2) NULL,
    Property ValData_TransacCd As Object = Nothing '               INT             NULL,
    Property ConorTra_Na As Object = Nothing '                     VARCHAR(35)    NULL,
    Property ConorTra_Strt As Object = Nothing '                   VARCHAR(35)    NULL,
    Property ConorTra_Pst As Object = Nothing '                    VARCHAR(9)     NULL,
    Property ConorTra_Cty As Object = Nothing '                    VARCHAR(35)    NULL,
    Property ConorTra_Ctry As Object = Nothing '                   VARCHAR(2)     NULL,
    Property ConorTra_TIN As Object = Nothing '                    VARCHAR(17)    NULL,
    Property ConorTra_UIDCtry As Object = Nothing '                VARCHAR(2)     NULL,
    Property ConorTra_UID As Object = Nothing '                    VARCHAR(20)    NULL,
    Property ConeeTra_Na As Object = Nothing '                     VARCHAR(35)    NULL,
    Property ConeeTra_Strt As Object = Nothing '                   VARCHAR(35)    NULL,
    Property ConeeTra_Pst As Object = Nothing '                    VARCHAR(9)     NULL,
    Property ConeeTra_Cty As Object = Nothing '                    VARCHAR(35)    NULL,
    Property ConeeTra_Ctry As Object = Nothing '                   VARCHAR(2)     NULL,
    Property ConeeTra_TIN As Object = Nothing '                    VARCHAR(17)    NULL,
    Property ConeeTra_UIDCtry As Object = Nothing '                VARCHAR(2)     NULL,
    Property ConeeTra_UID As Object = Nothing '                    VARCHAR(20)    NULL,
    Property ExpTra_Na As Object = Nothing '                       VARCHAR(35)    NULL,
    Property ExpTra_Strt As Object = Nothing '                     VARCHAR(35)    NULL,
    Property ExpTra_Pst As Object = Nothing '                      VARCHAR(9)     NULL,
    Property ExpTra_Cty As Object = Nothing '                      VARCHAR(35)    NULL,
    Property ExpTra_Ctry As Object = Nothing '                     VARCHAR(2)     NULL,
    Property ExpTra_TIN As Object = Nothing '                      VARCHAR(17)    NULL,
    Property ExpTra_UIDCtry As Object = Nothing '                  VARCHAR(2)     NULL,
    Property ExpTra_UID As Object = Nothing '                      VARCHAR(20)    NULL,
    Property Declarant_Na As Object = Nothing '                    VARCHAR(35)    NULL,
    Property Declarant_Strt As Object = Nothing '                  VARCHAR(35)    NULL,
    Property Declarant_Pst As Object = Nothing '                   VARCHAR(9)     NULL,
    Property Declarant_Cty As Object = Nothing '                   VARCHAR(35)    NULL,
    Property Declarant_Ctry As Object = Nothing '                  VARCHAR(2)     NULL,
    Property Declarant_TIN As Object = Nothing '                   VARCHAR(17)    NULL,
    Property Declarant_UIDCtry As Object = Nothing '               VARCHAR(2)     NULL,
    Property Declarant_UID As Object = Nothing '                   VARCHAR(20)    NULL,
    Property Declarant_DecRep As Object = Nothing '                INT             NULL,
    Property Represent_RIN As Object = Nothing '                   VARCHAR(17)    NULL,
    Property Represent_Na As Object = Nothing '                    VARCHAR(35)    NULL,
    Property EntryCO_Ref As Object = Nothing '                     VARCHAR(8)     NULL,
    Property ExitCO_Ref As Object = Nothing '                      VARCHAR(8)     NULL,
    Property SurvCO_Ref As Object = Nothing '                      VARCHAR(8)     NULL,
    Property DestCO_Ref As Object = Nothing '                      VARCHAR(8)     NULL,
    Property PresCO_Ref As Object = Nothing '                      VARCHAR(8)     NULL,
    Property DepCO_Ref As Object = Nothing '                       VARCHAR(8)     NULL,
    Property CtrlRslt_ResCd As Object = Nothing '                  VARCHAR(2)     NULL,
    Property CtrlRslt_DLimit As Object = Nothing '                 DATETIME        NULL, 
    Property telnam_aktuellsteNachricht As Boolean = False


    Property POSITIONSDATEN As New List(Of cTelotec_Positionsdaten)
    Property SICHERHEIT As New List(Of cTelotec_Sicherheit)
    Property ABGABEN As New List(Of cTelotec_Abgaben)

    Dim SQL As New VERAG_PROG_ALLGEMEIN.SQL

    'Sub New()
    ' End Sub

    Sub New(telanm_ART, telanm_BezugsNr, telanm_AvisoId, telanm_SendungsId)
        Me.telanm_ART = telanm_ART
        Me.telanm_BezugsNr = telanm_BezugsNr
        Me.telanm_AvisoId = telanm_AvisoId
        Me.telanm_SendungsId = telanm_SendungsId
        Me.telanm_Erstellung_SB = VERAG_PROG_ALLGEMEIN.cAllgemein.USRID
        Me.telanm_LetzteBearbeitung_SB = VERAG_PROG_ALLGEMEIN.cAllgemein.USRID
        SAVE()
    End Sub

    Sub New()
    End Sub


    Sub New(telanm_Id)
        Me.telanm_id = telanm_Id
        LOAD()
    End Sub


    Sub initData()
        Me.telanm_Status = "00"
        Me.telanm_Status_KEWILL_Equivalent = "00"
        Me.telanm_Erstellung = Now
        Me.telanm_Erstellung_SB = VERAG_PROG_ALLGEMEIN.cAllgemein.USRID
        Me.telanm_LetzteBearbeitung = Now
        Me.telanm_LetzteBearbeitung_SB = VERAG_PROG_ALLGEMEIN.cAllgemein.USRID
        Select Case VERAG_PROG_ALLGEMEIN.cAllgemein.FIRMA
            Case "IMEX"
                Me.[Mandant_ID] = "IMEX"
            Case "ATILLA"
                Me.[Mandant_ID] = "Atilla"
            Case Else
                Me.[Mandant_ID] = "VERCUS"
        End Select

        Me.[Bereich_ID] = 0
        Me.[Referenz_ID] = 0 '"TC_IMP_" & Now.ToShortDateString("ddMMyyyy_HHmmssfff ")
        Me.[ComIndicator] = 1

        Me.[dec_ProzessArt] = "TA"

        Me.[dec_CreateDate] = Now


        Me.[Refs_LRN] = Me.telanm_BezugsNr


        Me.[Hea_DecTy] = "IMA" '??
        Me.[Hea_TotItem] = 0

        Me.[Hea_Simp] = 0
        Me.[Hea_DecDT] = CDate(Now.ToShortDateString)
        Me.[Hea_DecPlc] = "Suben"

    End Sub

    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("telanm_id", telanm_id, , True, True))

        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("telanm_ART", telanm_ART)) '                      VARCHAR(50)    Not NULL,
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("telanm_BezugsNr", telanm_BezugsNr)) '                 VARCHAR(50)    Not NULL,
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("telanm_Status", telanm_Status)) '                   INT             Not NULL,
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("telanm_Status_KEWILL_Equivalent", telanm_Status_KEWILL_Equivalent)) ' INT             Not NULL,
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("telanm_AvisoId", telanm_AvisoId)) '                  INT             NULL,
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("telanm_SendungsId", telanm_SendungsId)) '               INT             NULL,
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("telanm_Steuerbescheid_dsId", telanm_Steuerbescheid_dsId)) '      INT             NULL,
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("telanm_VBD_dsId", telanm_VBD_dsId)) '                 INT             NULL,
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("telanm_LNR", telanm_LNR)) '                      VARCHAR(35)    NULL,
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("telanm_CRN", telanm_CRN)) '                      VARCHAR(35)    NULL,
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("telanm_Erstellung", telanm_Erstellung)) '               DATETIME        Default (getdate()) Not NULL,
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("telanm_Erstellung_SB", telanm_Erstellung_SB)) '            INT             NULL,
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("telanm_LetzteBearbeitung", telanm_LetzteBearbeitung)) '        DATETIME        Default (getdate()) Not NULL,
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("telanm_LetzteBearbeitung_SB", telanm_LetzteBearbeitung_SB)) '     INT             NULL,
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("telanm_firma", telanm_firma)) '                    VARCHAR(10)    NULL,
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("telanm_niederlassung", telanm_niederlassung)) '            VARCHAR(10)    NULL,
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("Mandant_ID", Mandant_ID)) '                      VARCHAR(6)     Not NULL,
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("Bereich_ID", Bereich_ID)) '                      VARCHAR(6)     Not NULL,
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("Referenz_ID", Referenz_ID)) '                     VARCHAR(36)    Not NULL,
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("ComIndicator", ComIndicator)) '                    BIT             Not NULL,
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("TransferStatus", TransferStatus)) '                  VARCHAR(4)     NULL,
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("MsgType", MsgType)) '                         VARCHAR(10)    NULL,
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("dec_ProzessArt", dec_ProzessArt)) '                  VARCHAR(4)     Not NULL,
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("dec_Anmelde_ID", dec_Anmelde_ID)) '                  INT             NULL,
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("dec_Template_ID", dec_Template_ID)) '                 INT             NULL,
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("dec_Lager_ID", dec_Lager_ID)) '                    VARCHAR(6)     NULL,
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("dec_Lag_IND", dec_Lag_IND)) '                     BIT             NULL,
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("dec_CreateDate", dec_CreateDate)) '                  DATETIME        Not NULL,
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("dec_CreatePersonalID", dec_CreatePersonalID)) '            VARCHAR(12)    NULL,
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("dec_PreDec_IND", dec_PreDec_IND)) '                  BIT             NULL,
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("dec_TotNet", dec_TotNet)) '                      Decimal (14, 3) NULL,
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("dec_TotNetSplit_IND", dec_TotNetSplit_IND)) '             BIT             NULL,
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("dec_FillPackList_IND", dec_FillPackList_IND)) '            BIT             NULL,
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("dec_Memo", dec_Memo)) '                        VARCHAR(1000)  NULL,
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("Refs_LRN", Refs_LRN)) '                        VARCHAR(22)    Not NULL,
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("Refs_CRN", Refs_CRN)) '                        VARCHAR(21)    NULL,
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("Refs_CSRN", Refs_CSRN)) '                       VARCHAR(21)    NULL,
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("Refs_ERN", Refs_ERN)) '                        VARCHAR(21)    NULL,
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("Refs_FRN", Refs_FRN)) '                        VARCHAR(21)    NULL,
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("Refs_Stat", Refs_Stat)) '                       VARCHAR(2)     NULL,
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("Hea_DecTy", Hea_DecTy)) '                       VARCHAR(9)     Not NULL,
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("Hea_TotItem", Hea_TotItem)) '                     INT             Not NULL,
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("Hea_TotPack", Hea_TotPack)) '                     INT             NULL,
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("Hea_TotGross", Hea_TotGross)) '                    Decimal (14, 3) NULL,
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("Hea_DepLNG", Hea_DepLNG)) '                      VARCHAR(2)     NULL,
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("Hea_DestLNG", Hea_DestLNG)) '                     VARCHAR(2)     NULL,
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("Hea_PayTy", Hea_PayTy)) '                       VARCHAR(1)     NULL,
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("Hea_DefPayRef", Hea_DefPayRef)) '                   INT             NULL,
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("Hea_PerPayRef", Hea_PerPayRef)) '                   INT             NULL,
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("Hea_PayMet", Hea_PayMet)) '                      INT             NULL,
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("Hea_AExpRef", Hea_AExpRef)) '                     BIT             NULL,
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("Hea_Fin", Hea_Fin)) '                         VARCHAR(2)     NULL,
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("Hea_Simp", Hea_Simp)) '                        BIT             Not NULL,
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("Hea_IssD", Hea_IssD)) '                        Date            NULL,
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("Hea_AuthID", Hea_AuthID)) '                      VARCHAR(17)    NULL,
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("Hea_TransDat", Hea_TransDat)) '                    BIT             NULL,
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("Hea_WoffD", Hea_WoffD)) '                       Date            NULL,
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("Hea_DecDT", Hea_DecDT)) '                       Date            Not NULL,
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("Hea_DecPlc", Hea_DecPlc)) '                      VARCHAR(35)    Not NULL,
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("Hea_AccDT", Hea_AccDT)) '                       DATETIME        NULL,
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("Hea_SecInd", Hea_SecInd)) '                      BIT             NULL,
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("Hea_ComRef", Hea_ComRef)) '                      VARCHAR(70)    NULL,
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("Hea_ProArrDT", Hea_ProArrDT)) '                    DATETIME        NULL,
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("Hea_PlaDepDT", Hea_PlaDepDT)) '                    DATETIME        NULL,
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("Locs_TradCtry", Locs_TradCtry)) '                   VARCHAR(2)     NULL,
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("Locs_Disp", Locs_Disp)) '                       VARCHAR(2)     NULL,
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("Locs_Dest", Locs_Dest)) '                       VARCHAR(2)     NULL,
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("Locs_GdsLocCd", Locs_GdsLocCd)) '                   VARCHAR(17)    NULL,
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("Locs_GdsLoc", Locs_GdsLoc)) '                     VARCHAR(35)    NULL,
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("Locs_GdsLocAuth", Locs_GdsLocAuth)) '                 VARCHAR(17)    NULL,
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("Locs_LoadPlcCd", Locs_LoadPlcCd)) '                  VARCHAR(17)    NULL,
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("Locs_LoadPlc", Locs_LoadPlc)) '                    VARCHAR(35)    NULL,
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("Locs_CustPlc", Locs_CustPlc)) '                    VARCHAR(17)    NULL,
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("Locs_ArrLocCd", Locs_ArrLocCd)) '                   VARCHAR(17)    NULL,
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("Locs_ArrLoc", Locs_ArrLoc)) '                     VARCHAR(35)    NULL,
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("Locs_ArrLocAuth", Locs_ArrLocAuth)) '                 VARCHAR(17)    NULL,
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("Locs_WarTy", Locs_WarTy)) '                      VARCHAR(1)     NULL,
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("Locs_WarCtry", Locs_WarCtry)) '                    VARCHAR(2)     NULL,
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("Locs_War", Locs_War)) '                        VARCHAR(17)    NULL,
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("Transp_InMo", Transp_InMo)) '                     INT             NULL,
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("Transp_BordMo", Transp_BordMo)) '                   INT             NULL,
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("Transp_DepTy", Transp_DepTy)) '                    INT             NULL,
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("Transp_DepIdnt", Transp_DepIdnt)) '                  VARCHAR(27)    NULL,
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("Transp_DepNat", Transp_DepNat)) '                   VARCHAR(2)     NULL,
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("Transp_CrossTy", Transp_CrossTy)) '                  INT             NULL,
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("Transp_CrossIdnt", Transp_CrossIdnt)) '                VARCHAR(27)    NULL,
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("Transp_CrossIdntNat", Transp_CrossIdntNat)) '             VARCHAR(2)     NULL,
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("Transp_ContInd", Transp_ContInd)) '                  BIT             NULL,
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("ValData_TermDelCd", ValData_TermDelCd)) '               VARCHAR(3)     NULL,
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("ValData_TermDelPlc", ValData_TermDelPlc)) '              VARCHAR(35)    NULL,
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("ValData_TermDelSit", ValData_TermDelSit)) '              VARCHAR(1)     NULL,
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("ValData_InvCurr", ValData_InvCurr)) '                 VARCHAR(3)     NULL,
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("ValData_ExRa", ValData_ExRa)) '                    Decimal (20, 7) NULL,
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("ValData_InvVal", ValData_InvVal)) '                  Decimal (18, 2) NULL,
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("ValData_TransacCd", ValData_TransacCd)) '               INT             NULL,
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("ConorTra_Na", ConorTra_Na)) '                     VARCHAR(35)    NULL,
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("ConorTra_Strt", ConorTra_Strt)) '                   VARCHAR(35)    NULL,
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("ConorTra_Pst", ConorTra_Pst)) '                    VARCHAR(9)     NULL,
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("ConorTra_Cty", ConorTra_Cty)) '                    VARCHAR(35)    NULL,
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("ConorTra_Ctry", ConorTra_Ctry)) '                   VARCHAR(2)     NULL,
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("ConorTra_TIN", ConorTra_TIN)) '                    VARCHAR(17)    NULL,
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("ConorTra_UIDCtry", ConorTra_UIDCtry)) '                VARCHAR(2)     NULL,
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("ConorTra_UID", ConorTra_UID)) '                    VARCHAR(20)    NULL,
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("ConeeTra_Na", ConeeTra_Na)) '                     VARCHAR(35)    NULL,
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("ConeeTra_Strt", ConeeTra_Strt)) '                   VARCHAR(35)    NULL,
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("ConeeTra_Pst", ConeeTra_Pst)) '                    VARCHAR(9)     NULL,
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("ConeeTra_Cty", ConeeTra_Cty)) '                    VARCHAR(35)    NULL,
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("ConeeTra_Ctry", ConeeTra_Ctry)) '                   VARCHAR(2)     NULL,
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("ConeeTra_TIN", ConeeTra_TIN)) '                    VARCHAR(17)    NULL,
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("ConeeTra_UIDCtry", ConeeTra_UIDCtry)) '                VARCHAR(2)     NULL,
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("ConeeTra_UID", ConeeTra_UID)) '                    VARCHAR(20)    NULL,
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("ExpTra_Na", ExpTra_Na)) '                       VARCHAR(35)    NULL,
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("ExpTra_Strt", ExpTra_Strt)) '                     VARCHAR(35)    NULL,
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("ExpTra_Pst", ExpTra_Pst)) '                      VARCHAR(9)     NULL,
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("ExpTra_Cty", ExpTra_Cty)) '                      VARCHAR(35)    NULL,
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("ExpTra_Ctry", ExpTra_Ctry)) '                     VARCHAR(2)     NULL,
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("ExpTra_TIN", ExpTra_TIN)) '                      VARCHAR(17)    NULL,
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("ExpTra_UIDCtry", ExpTra_UIDCtry)) '                  VARCHAR(2)     NULL,
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("ExpTra_UID", ExpTra_UID)) '                      VARCHAR(20)    NULL,
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("Declarant_Na", Declarant_Na)) '                    VARCHAR(35)    NULL,
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("Declarant_Strt", Declarant_Strt)) '                  VARCHAR(35)    NULL,
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("Declarant_Pst", Declarant_Pst)) '                   VARCHAR(9)     NULL,
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("Declarant_Cty", Declarant_Cty)) '                   VARCHAR(35)    NULL,
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("Declarant_Ctry", Declarant_Ctry)) '                  VARCHAR(2)     NULL,
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("Declarant_TIN", Declarant_TIN)) '                   VARCHAR(17)    NULL,
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("Declarant_UIDCtry", Declarant_UIDCtry)) '               VARCHAR(2)     NULL,
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("Declarant_UID", Declarant_UID)) '                   VARCHAR(20)    NULL,
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("Declarant_DecRep", Declarant_DecRep)) '                INT             NULL,
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("Represent_RIN", Represent_RIN)) '                   VARCHAR(17)    NULL,
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("Represent_Na", Represent_Na)) '                    VARCHAR(35)    NULL,
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("EntryCO_Ref", EntryCO_Ref)) '                     VARCHAR(8)     NULL,
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("ExitCO_Ref", ExitCO_Ref)) '                      VARCHAR(8)     NULL,
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("SurvCO_Ref", SurvCO_Ref)) '                      VARCHAR(8)     NULL,
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("DestCO_Ref", DestCO_Ref)) '                      VARCHAR(8)     NULL,
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("PresCO_Ref", PresCO_Ref)) '                      VARCHAR(8)     NULL,
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("DepCO_Ref", DepCO_Ref)) '                       VARCHAR(8)     NULL,
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("CtrlRslt_ResCd", CtrlRslt_ResCd)) '                  VARCHAR(2)     NULL,
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("CtrlRslt_DLimit", CtrlRslt_DLimit)) '                 DATETIME        NULL, 
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("telnam_aktuellsteNachricht", telnam_aktuellsteNachricht)) '                 DATETIME        NULL, 

        Return list
    End Function



    Public Function SAVE(Optional saveAll = True) As Boolean
        Dim list As List(Of VERAG_PROG_ALLGEMEIN.SQLVariable) = getParameterList()

        Dim sqlstr = " BEGIN TRAN IF EXISTS(SELECT * FROM tblTelotec_Anmeldung WITH(updlock,serializable) WHERE telanm_id=@telanm_id) " &
                       " BEGIN " & getUpdateCmd() & " End " &
                       " Else " &
                       " BEGIN " & getInsertCmd() & " End " &
                       " commit tran "

        telanm_id = SQL.doSQLVarListID(telanm_id, sqlstr, "FMZOLL", , list)
        If telanm_id > 0 And saveAll Then
            SAVE_Positionsdaten()
            SAVE_Sicherheit()
            SAVE_Abgaben()

        End If

        Return telanm_id > 0
    End Function



    Public Sub SAVE_ME_AKTUELLSTE_NACHRICHT(Optional saveAll = True)
        ''''Aktuellste Nachricht
        If Me.Refs_LRN <> "" Then

            SQL.doSQL(" UPDATE [tblTelotec_Anmeldung] SET telnam_aktuellsteNachricht = 0 WHERE Refs_LRN='" & Me.Refs_LRN & "' ", "FMZOLL")

            Me.telnam_aktuellsteNachricht = 1
            Me.SAVE(False) 'nur die Nachricht speichern

        End If
    End Sub




    Shared Sub Update_Anmeldedatum(Refs_LRN As String, Anmeldedatum As Date)
        ''''Aktuellste Nachricht
        If Refs_LRN <> "" Then
            Dim sql As New VERAG_PROG_ALLGEMEIN.SQL
            sql.doSQL(" UPDATE [tblTelotec_Anmeldung] SET telanm_Erstellung='" & Anmeldedatum.ToShortDateString & "'  , dec_CreateDate='" & Anmeldedatum.ToShortDateString & "'   WHERE Refs_LRN='" & Refs_LRN & "' ", "FMZOLL")

        End If
    End Sub





    Shared Sub Update_Status_LRN(Refs_LRN As String, status As String)
        ''''Aktuellste Nachricht
        If Refs_LRN <> "" Then
            Dim sql As New VERAG_PROG_ALLGEMEIN.SQL

            sql.doSQL(" UPDATE [tblTelotec_Anmeldung] SET telanm_status='" & status & "'  , telanm_Status_KEWILL_Equivalent='" & status & "'   WHERE Refs_LRN='" & Refs_LRN & "' AND [telnam_aktuellsteNachricht]=1 ", "FMZOLL")

        End If
    End Sub


    Shared Sub Update_writeOffDate(Refs_LRN As String, writeOffDate As Date)
        ''''Aktuellste Nachricht

        If Refs_LRN <> "" Then
            Dim sql As New VERAG_PROG_ALLGEMEIN.SQL
            sql.doSQL(" UPDATE [tblTelotec_Anmeldung] SET Hea_WoffD='" & writeOffDate.ToShortDateString & "'  , Hea_DecDT='" & writeOffDate.ToShortDateString & "'   WHERE Refs_LRN='" & Refs_LRN & "' ", "FMZOLL")

        End If
    End Sub






    Public Function tryFindAviso() As Boolean
        Dim srchStrFiliale = ""
        Dim srchStrAbf = ""
        If Me.telanm_BezugsNr.Contains("/") Then
            Dim split = Me.telanm_BezugsNr.Split("/")
            If split.Length >= 2 Then
                srchStrFiliale = split(0)
                srchStrAbf = split(1)
                ' ElseIf  Then
                '      srchStrAbf = split(X)
            Else
                Return False
            End If

        End If
        If Not IsNumeric(srchStrFiliale) Or Not IsNumeric(srchStrAbf) Then Return False
        If srchStrFiliale.Length <> 4 Then Return False
        'If srchStrAbf.Length > 8 Then srchStrAbf = srchStrAbf.Substring(0, 8)

        If srchStrAbf.Length < 8 Then
            If Me.telanm_Erstellung IsNot Nothing Then
                srchStrAbf = CDate(Me.telanm_Erstellung).ToString("yy") & CInt(srchStrAbf).ToString("000000")
            Else
                srchStrAbf = Now.ToString("yy") & CInt(srchStrAbf).ToString("000000")
            End If

        End If


        Dim sqlstr = " Select [tblSnd_SendungID],[tblSnd_AvisoID]  FROM [tblSendungen] where '" & srchStrAbf & "' like ('%' + cast(AbfertigungsNr as varchar(10))+ '%') and FilialenNr ='" & srchStrFiliale & "' and AbfertigungsNr >0"

        Dim dt As DataTable = SQL.loadDgvBySql(sqlstr, "AVISO")
        If dt IsNot Nothing AndAlso dt.Rows.Count > 0 Then
            Me.telanm_SendungsId = dt.Rows(0)("tblSnd_SendungID")
            Me.telanm_AvisoId = dt.Rows(0)("tblSnd_AvisoID")
            Return True
        End If

        Return False
    End Function


    Public Sub LOAD(Optional loadALL = True)
        Try
            If loadALL Then
                POSITIONSDATEN.Clear()
                SICHERHEIT.Clear()
                ABGABEN.Clear()
            End If
            Using conn As SqlConnection = SQL.GetNewOpenConnectionFMZOLL()
                Using cmd As New SqlCommand("SELECT * FROM tblTelotec_Anmeldung WHERE telanm_id=@telanm_id  ", conn)
                    cmd.Parameters.AddWithValue("@telanm_id", telanm_id)
                    Dim dr = cmd.ExecuteReader()
                    If dr.Read Then
                        For Each l In getParameterList()
                            Dim propInfo As PropertyInfo = Me.GetType.GetProperty(l.Scalarvariable)

                            If dr.Item(l.Text) Is DBNull.Value Then
                                propInfo.SetValue(Me, Nothing)
                            Else
                                propInfo.SetValue(Me, dr.Item(l.Text))
                            End If

                        Next
                        If loadALL Then
                            LOAD_Positionsdaten()
                            LOAD_Sicherheit()
                            LOAD_Abgaben()
                        End If
                    End If
                    dr.Close()
                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

    Public Shared Function LOAD_ByBezugsNr(BezugsNr, Optional loadALL = True) As cTelotec_Anmeldung
        Try
            Dim SQL As New VERAG_PROG_ALLGEMEIN.SQL
            Dim TC As New cTelotec_Anmeldung
            TC.POSITIONSDATEN.Clear()
            TC.SICHERHEIT.Clear()
            TC.ABGABEN.Clear()

            Using conn As SqlConnection = SQL.GetNewOpenConnectionFMZOLL()
                Using cmd As New SqlCommand("SELECT * FROM tblTelotec_Anmeldung WHERE telanm_BezugsNr=@BezugsNr AND [telnam_aktuellsteNachricht]=1 ", conn)
                    cmd.Parameters.AddWithValue("@BezugsNr", BezugsNr)
                    Dim dr = cmd.ExecuteReader()
                    If dr.Read Then
                        For Each l In TC.getParameterList()
                            Dim propInfo As PropertyInfo = TC.GetType.GetProperty(l.Scalarvariable)

                            If dr.Item(l.Text) Is DBNull.Value Then
                                propInfo.SetValue(TC, Nothing)
                            Else
                                propInfo.SetValue(TC, dr.Item(l.Text))
                            End If

                        Next
                        If loadALL Then
                            TC.LOAD_Positionsdaten()
                            TC.LOAD_Sicherheit()
                            TC.LOAD_Abgaben()
                        End If
                        Return TC
                    End If
                    dr.Close()
                End Using
            End Using
        Catch ex As Exception
            VERAG_PROG_ALLGEMEIN.cErrorHandler.ERR(ex.Message, ex.StackTrace, System.Reflection.MethodInfo.GetCurrentMethod.Name)
        End Try
        Return Nothing
    End Function


    Public Function UPDATE_Status(status As Integer) As String
        If telanm_id > 0 Then
            Try
                Dim list As New List(Of VERAG_PROG_ALLGEMEIN.SQLVariable)
                list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("telanm_id", telanm_id, , True))
                list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("telanm_Status_KEWILL_Equivalent", status, , True))
                list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("telanm_Status", status, , True))
                telanm_Status_KEWILL_Equivalent = status
                telanm_Status = status

                Return SQL.doSQLVarList(" UPDATE [tblTelotec_Anmeldung] SET telanm_Status_KEWILL_Equivalent=@telanm_Status_KEWILL_Equivalent,telanm_Status=@telanm_Status WHERE telanm_id=@telanm_id ", "FMZOLL", , list)

            Catch ex As Exception
                VERAG_PROG_ALLGEMEIN.cErrorHandler.ERR(ex.Message, ex.StackTrace, System.Reflection.MethodInfo.GetCurrentMethod.Name)
            End Try
        End If
        Return ""
    End Function


    Shared Function UPDATE_StatusById(telanm_id As Integer, status As Integer) As String
        If telanm_id > 0 Then
            Try
                Dim list As New List(Of VERAG_PROG_ALLGEMEIN.SQLVariable)
                list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("telanm_id", telanm_id, , True))
                list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("telanm_Status_KEWILL_Equivalent", status, , True))
                list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("telanm_Status", status, , True))
                'telanm_Status_KEWILL_Equivalent = status
                'telanm_Status = status
                Dim SQL As New VERAG_PROG_ALLGEMEIN.SQL

                Return SQL.doSQLVarList(" UPDATE [tblTelotec_Anmeldung] SET telanm_Status_KEWILL_Equivalent=@telanm_Status_KEWILL_Equivalent,telanm_Status=@telanm_Status WHERE telanm_id=@telanm_id ", "FMZOLL", , list)

            Catch ex As Exception
                VERAG_PROG_ALLGEMEIN.cErrorHandler.ERR(ex.Message, ex.StackTrace, System.Reflection.MethodInfo.GetCurrentMethod.Name)
            End Try
        End If
        Return ""
    End Function



    Shared Function LOADById(telanm_id As String, Optional loadALL As Boolean = True) As cTelotec_Anmeldung
        Try
            Dim NCTS As New cTelotec_Anmeldung
            Dim SQL As New VERAG_PROG_ALLGEMEIN.SQL
            If loadALL Then
                NCTS.POSITIONSDATEN.Clear()
                NCTS.SICHERHEIT.Clear()
                NCTS.ABGABEN.Clear()
            End If
            Using conn As SqlConnection = SQL.GetNewOpenConnectionFMZOLL()
                Using cmd As New SqlCommand("SELECT TOP 1 * FROM tblTelotec_Anmeldung WHERE telanm_id=@telanm_id  ", conn)
                    cmd.Parameters.AddWithValue("@telanm_id", telanm_id)
                    Dim dr = cmd.ExecuteReader()
                    If dr.Read Then
                        For Each l In NCTS.getParameterList()
                            Dim propInfo As PropertyInfo = NCTS.GetType.GetProperty(l.Scalarvariable)

                            If dr.Item(l.Text) Is DBNull.Value Then
                                propInfo.SetValue(NCTS, Nothing)
                            Else
                                propInfo.SetValue(NCTS, dr.Item(l.Text))
                            End If

                        Next
                        If loadALL Then
                            NCTS.LOAD_Positionsdaten()
                            NCTS.LOAD_Sicherheit()
                            NCTS.LOAD_Abgaben()
                        End If
                        dr.Close()
                        Return NCTS
                    End If
                    dr.Close()
                End Using
            End Using
        Catch ex As Exception
            VERAG_PROG_ALLGEMEIN.cErrorHandler.ERR(ex.Message, ex.StackTrace, System.Reflection.MethodInfo.GetCurrentMethod.Name)
        End Try
        Return Nothing
    End Function



    Shared Function LOADByCRN(telanm_CRN As String, Optional loadALL As Boolean = True) As cTelotec_Anmeldung
        Try
            Dim NCTS As New cTelotec_Anmeldung
            Dim SQL As New VERAG_PROG_ALLGEMEIN.SQL
            If loadALL Then
                NCTS.POSITIONSDATEN.Clear()
                NCTS.SICHERHEIT.Clear()
                NCTS.ABGABEN.Clear()
            End If
            Using conn As SqlConnection = SQL.GetNewOpenConnectionFMZOLL()
                Using cmd As New SqlCommand("SELECT TOP 1 * FROM tblTelotec_Anmeldung WHERE telanm_CRN=@telanm_CRN  ", conn)
                    cmd.Parameters.AddWithValue("@telanm_CRN", telanm_CRN)
                    Dim dr = cmd.ExecuteReader()
                    If dr.Read Then
                        For Each l In NCTS.getParameterList()
                            Dim propInfo As PropertyInfo = NCTS.GetType.GetProperty(l.Scalarvariable)

                            If dr.Item(l.Text) Is DBNull.Value Then
                                propInfo.SetValue(NCTS, Nothing)
                            Else
                                propInfo.SetValue(NCTS, dr.Item(l.Text))
                            End If

                        Next
                        If loadALL Then
                            NCTS.LOAD_Positionsdaten()
                            NCTS.LOAD_Sicherheit()
                            NCTS.LOAD_Abgaben()
                        End If
                        dr.Close()
                        Return NCTS
                    End If
                    dr.Close()
                End Using
            End Using
        Catch ex As Exception
            VERAG_PROG_ALLGEMEIN.cErrorHandler.ERR(ex.Message, ex.StackTrace, System.Reflection.MethodInfo.GetCurrentMethod.Name)
        End Try
        Return Nothing
    End Function

    Shared Function LOADByBezugsNr(bezugsNr As String, Optional MsgType As String = "", Optional loadALL As Boolean = True) As cTelotec_Anmeldung
        Try
            Dim NCTS As New cTelotec_Anmeldung
            Dim SQL As New VERAG_PROG_ALLGEMEIN.SQL
            If bezugsNr = "" Then Return Nothing
            If loadALL Then
                NCTS.POSITIONSDATEN.Clear()
                NCTS.SICHERHEIT.Clear()
                NCTS.ABGABEN.Clear()
            End If
            Using conn As SqlConnection = SQL.GetNewOpenConnectionFMZOLL()
                Using cmd As New SqlCommand("SELECT TOP 1 * FROM tblTelotec_Anmeldung WHERE telanm_BezugsNr=@bezugsNr  " & If(MsgType <> "", " AND MsgType=@MsgType ", ""), conn)
                    cmd.Parameters.AddWithValue("@bezugsNr", bezugsNr)
                    cmd.Parameters.AddWithValue("@MsgType", MsgType)
                    Dim dr = cmd.ExecuteReader()
                    If dr.Read Then
                        For Each l In NCTS.getParameterList()
                            Dim propInfo As PropertyInfo = NCTS.GetType.GetProperty(l.Scalarvariable)

                            If dr.Item(l.Text) Is DBNull.Value Then
                                propInfo.SetValue(NCTS, Nothing)
                            Else
                                propInfo.SetValue(NCTS, dr.Item(l.Text))
                            End If

                        Next
                        If loadALL Then
                            NCTS.LOAD_Positionsdaten()
                            NCTS.LOAD_Sicherheit()
                            NCTS.LOAD_Abgaben()
                        End If
                        dr.Close()
                        Return NCTS
                    End If
                    dr.Close()
                End Using
            End Using
        Catch ex As Exception
            ' VERAG_PROG_ALLGEMEIN.cErrorHandler.ERR(ex.Message, ex.StackTrace, System.Reflection.MethodInfo.GetCurrentMethod.Name)
            VERAG_PROG_ALLGEMEIN.cErrorHandler.ERR(ex.Message, ex.StackTrace, System.Reflection.MethodInfo.GetCurrentMethod.Name)

        End Try
        Return Nothing
    End Function

    Shared Function ExistsBezugsNr(bezugsNr As String) As Boolean
        Try
            Dim NCTS As New cTelotec_Anmeldung
            Dim SQL As New VERAG_PROG_ALLGEMEIN.SQL

            Using conn As SqlConnection = SQL.GetNewOpenConnectionFMZOLL()
                Using cmd As New SqlCommand("SELECT TOP 1 telanm_id FROM tblTelotec_Anmeldung WHERE telanm_BezugsNr=@bezugsNr  ", conn)
                    cmd.Parameters.AddWithValue("@bezugsNr", bezugsNr)
                    Dim dr = cmd.ExecuteReader()
                    If dr.Read Then
                        Return True
                    End If
                    dr.Close()
                End Using
            End Using
        Catch ex As Exception
            VERAG_PROG_ALLGEMEIN.cErrorHandler.ERR(ex.Message, ex.StackTrace, System.Reflection.MethodInfo.GetCurrentMethod.Name)
        End Try
        Return False
    End Function


    Public Sub UPDATE_DATA()
        Try
            'Me.dy_BezugsNr = Dakosy_NCTSOut.ncts_ObjectName
            'Me.dy_Status = Dakosy_NCTSOut.ncts_Status
            'Me.dy_Status_KEWILL_Equivalent = Dakosy_NCTSOut.ncts_Status_KEWILL_Equivalent
            'Me.dy_Erstellung = Dakosy_NCTSOut.ncts_Erstellung
            'Me.dy_Erstellung_SB = Dakosy_NCTSOut.ncts_Erstellung_SB
            'Me.dy_LetzteBearbeitung = Dakosy_NCTSOut.ncts_LetzteBearbeitung
            'Me.dy_LetzteBearbeitung_SB = Dakosy_NCTSOut.ncts_LetzteBearbeitung_SB


        Catch ex As Exception
            VERAG_PROG_ALLGEMEIN.cErrorHandler.ERR(ex.Message, ex.StackTrace, System.Reflection.MethodInfo.GetCurrentMethod.Name)
        End Try
    End Sub



    Public Function getUpdateCmd() As String
        Try
            Dim list As List(Of VERAG_PROG_ALLGEMEIN.SQLVariable) = getParameterList()

            Dim str As String = ""
            For Each i In list
                If Not i.isPrimaryParam Then
                    str &= "[" & i.Text & "] = @" & i.Scalarvariable & "," '.Replace("-", "").Replace(" ", "") & ","
                End If
            Next
            str = str.Substring(0, str.Length - 1) 'wg. ','
            Return (" UPDATE [tblTelotec_Anmeldung] SET " & str & " WHERE telanm_id=@telanm_id ")

        Catch ex As Exception
            VERAG_PROG_ALLGEMEIN.cErrorHandler.ERR(ex.Message, ex.StackTrace, System.Reflection.MethodInfo.GetCurrentMethod.Name)
        End Try
        Return ""
    End Function


    Public Function getInsertCmd() As String
        Try
            Dim list As List(Of VERAG_PROG_ALLGEMEIN.SQLVariable) = getParameterList()
            Dim str As String = ""
            Dim values As String = ""
            For Each i In list
                If Not i.isPrimaryParam Then
                    str &= "[" & i.Text & "],"
                    values &= "@" & i.Scalarvariable & "," '.Replace("-", "").Replace(" ", "") & ","
                End If
            Next
            str = str.Substring(0, str.Length - 1) 'wg. ','
            values = values.Substring(0, values.Length - 1) 'wg. ','
            Return (" INSERT INTO tblTelotec_Anmeldung  (" & str & ") VALUES(" & values & ")  ")
        Catch ex As Exception
            VERAG_PROG_ALLGEMEIN.cErrorHandler.ERR(ex.Message, ex.StackTrace, System.Reflection.MethodInfo.GetCurrentMethod.Name)
        End Try
        Return ""
    End Function



    Shared Function getBezugnNr_ByMRN(MRN As String) As String
        Dim SQL As New VERAG_PROG_ALLGEMEIN.SQL
        Return SQL.getValueTxtBySql("SELECT TOP 1 telanm_BezugsNr FROM tblTelotec_Anmeldung  WHERE telanm_CRN = '" & MRN & "' ORDER BY telanm_LetzteBearbeitung DESC", "FMZOLL")
    End Function



    Public Shared Sub TELOTECDatenbereitstellung(ByVal SPEDITIONSBUCH As VERAG_PROG_ALLGEMEIN.cSpeditionsbuch, telanm_Nr As String, ByRef notFound As Boolean, ByVal art As String, ByRef PosAnzahl As Integer)
        Dim DY As cTelotec_Anmeldung = cTelotec_Anmeldung.LOADByBezugsNr(telanm_Nr)
        If DY Is Nothing Then
            notFound = True
            Exit Sub
        End If
        notFound = False
        TELOTECDatenbereitstellung(SPEDITIONSBUCH, DY, notFound, art, PosAnzahl)

    End Sub

    Public Shared Sub TELOTECDatenbereitstellung(ByRef SPEDITIONSBUCH As VERAG_PROG_ALLGEMEIN.cSpeditionsbuch, DY As cTelotec_Anmeldung, ByRef notFound As Boolean, ByVal art As String, ByRef PosAnzahl As Integer)
        Dim SQL As New VERAG_PROG_ALLGEMEIN.SQL

        notFound = False
        Select Case art
            Case "EZA", "EUA" : TELOTECDatenbereitstellung_EZA(SPEDITIONSBUCH, DY, notFound, PosAnzahl)
            Case Else : TELOTECDatenbereitstellung_NCTS(SPEDITIONSBUCH, DY, notFound, PosAnzahl)
        End Select

        'Personal Abfertigung:
        'Try
        '    If DY.telanm_Bearbeiter IsNot Nothing Then
        '        Dim p = SQL.getValueTxtBySql("SELECT  ISNULL(CASE WHEN [mit_FMZollPersIDKasseIsnotSpedBuch]=1 THEN [mit_FMZollPersIDSpedBuch] ELSE [mit_FMZollPersID] END ,-1) as [mit_FMZollPersID]  FROM [ADMIN].[dbo].[tblMitarbeiter] WHERE [mit_DAKOSY_SB]='" & DY.telanm_Bearbeiter & "'", "ADMIN")
        '        SPEDITIONSBUCH.Personalnummer = If(IsNumeric(p), p, Nothing)
        '    End If
        'Catch ex As Exception
        '    MsgBox("Fehler DAKOSY Personal: " & vbNewLine & ex.Message & vbNewLine & ex.StackTrace)
        'End Try

    End Sub

    Public Shared Sub TELOTECDatenbereitstellung_EZA(ByVal SPEDITIONSBUCH As VERAG_PROG_ALLGEMEIN.cSpeditionsbuch, DY As cTelotec_Anmeldung, ByRef notFound As Boolean, ByRef PosAnzahl As Integer)
        Dim SQL As New VERAG_PROG_ALLGEMEIN.SQL

        notFound = False

        Try

            If SPEDITIONSBUCH.Abfertigungsdatum Is Nothing Then SPEDITIONSBUCH.Abfertigungsdatum = Now 'CDate(DY.eza_Trans_DatumZeit).ToShortDateString

            SPEDITIONSBUCH.Abfertigungsart = "1" 'FISKAL !!!!!????

            SPEDITIONSBUCH.Versendungsland = DY.Locs_Disp
            SPEDITIONSBUCH.Bestimmungsland = DY.Locs_Dest
            SPEDITIONSBUCH.LKW_Kennzeichen = DY.Transp_DepIdnt 'Transp_BordMo	

            SPEDITIONSBUCH.BelegNr = DY.Refs_CRN
            If DY.ValData_InvCurr IsNot Nothing Then
                SPEDITIONSBUCH.Währungsschlüssel = If(DY.ValData_InvCurr = "EUR", "900", getWaehr(DY.ValData_InvCurr, SQL))
            End If


            'Versender            'Verkäufer
            If If(DY.ConorTra_Na, "") <> "" Or If(DY.ConorTra_TIN, "") <> "" Then
                Dim AD = getAdresseFromEORI(DY.ConorTra_TIN, "", SQL, DY.telanm_firma)
                If AD IsNot Nothing Then
                    SPEDITIONSBUCH.AbsenderKundenNr = AD.AdressenNr
                    SPEDITIONSBUCH.Absender = AD.Ordnungsbegriff
                End If
                If If(SPEDITIONSBUCH.Absender, "").Trim = String.Empty Then
                    SPEDITIONSBUCH.Absender = If(DY.ConorTra_Na, "")
                    SPEDITIONSBUCH.Absender &= ", " & If(DY.ConorTra_Ctry, "")
                    SPEDITIONSBUCH.Absender &= " " & If(DY.ConorTra_Pst, "")
                    SPEDITIONSBUCH.Absender &= " " & If(DY.ConorTra_Cty, "")
                    SPEDITIONSBUCH.Absender = SPEDITIONSBUCH.Absender.Trim
                    If SPEDITIONSBUCH.Absender.Length > 50 Then
                        SPEDITIONSBUCH.Absender = SPEDITIONSBUCH.Absender.Substring(0, 50)
                    End If
                End If
                If If(SPEDITIONSBUCH.Absender, "").Trim = String.Empty Then SPEDITIONSBUCH.Absender &= " " & If(DY.ConorTra_TIN, "")
            End If


            'Empfänger
            If If(DY.ConeeTra_Na, "") <> "" Or If(DY.ConeeTra_TIN, "") <> "" Then
                Dim AD = getAdresseFromEORI(DY.ConeeTra_TIN, "", SQL, DY.telanm_firma)
                If AD IsNot Nothing Then
                    SPEDITIONSBUCH.EmpfängerKundenNr = AD.AdressenNr
                    SPEDITIONSBUCH.Empfänger = AD.Ordnungsbegriff
                End If
                If If(SPEDITIONSBUCH.Empfänger, "").Trim = String.Empty Then
                    SPEDITIONSBUCH.Empfänger = If(DY.ConeeTra_Na, "")
                    SPEDITIONSBUCH.Empfänger &= ", " & If(DY.ConeeTra_Ctry, "")
                    SPEDITIONSBUCH.Empfänger &= " " & If(DY.ConeeTra_Pst, "")
                    SPEDITIONSBUCH.Empfänger &= " " & If(DY.ConeeTra_Cty, "")
                    SPEDITIONSBUCH.Empfänger = SPEDITIONSBUCH.Empfänger.Trim
                    If SPEDITIONSBUCH.Empfänger.Length > 50 Then
                        SPEDITIONSBUCH.Empfänger = SPEDITIONSBUCH.Empfänger.Substring(0, 50)
                    End If
                End If
                If If(SPEDITIONSBUCH.Empfänger, "").Trim = String.Empty Then SPEDITIONSBUCH.Empfänger &= " " & If(DY.ConeeTra_TIN, "")
            End If




            'If If(SPEDITIONSBUCH.Abfertigungsart, 0) < 1 Then
            '    If DY.eza_FiskalvertretungKz Then
            '        SPEDITIONSBUCH.Abfertigungsart = 28
            '    Else
            '        SPEDITIONSBUCH.Abfertigungsart = 1
            '    End If
            'End If


            SPEDITIONSBUCH.Rechnungsbetrag = DY.ValData_InvVal
            ' SPEDITIONSBUCH.Umrechnungskurs = DY.eza_Rechnungswaehrung
            If DY.Hea_TotGross IsNot Nothing Then
                SPEDITIONSBUCH.Rohmasse = CDbl(DY.Hea_TotGross)
            End If

            'Anhang
            If If(DY.Refs_CRN, "") <> String.Empty Then
                getStbFromAnmId(DY.Refs_CRN, SPEDITIONSBUCH.DokumentId_Steuerbeleg, SPEDITIONSBUCH.DokumentId_Mitteilung)
            End If

            'Personal Abfertigung:
            Try
                If DY.Represent_Na IsNot Nothing Then
                    Dim p = SQL.getValueTxtBySql("SELECT  ISNULL(CASE WHEN [mit_FMZollPersIDKasseIsnotSpedBuch]=1 THEN [mit_FMZollPersIDSpedBuch] ELSE [mit_FMZollPersID] END ,-1) as [mit_FMZollPersID]  FROM [ADMIN].[dbo].[tblMitarbeiter] WHERE [mit_TELOTEC_SB]='" & DY.Represent_Na & "'", "ADMIN")
                    SPEDITIONSBUCH.Personalnummer = If(IsNumeric(p), p, Nothing)
                End If
            Catch ex As Exception
                MsgBox("Fehler TELOTEC Personal: " & vbNewLine & ex.Message & vbNewLine & ex.StackTrace)
            End Try


            'Dim PackstAnz As Integer = 0
            'Dim cnt = 0
            'Dim rohmasseTmp As Double = 0
            'Dim rechnungspreisTmp As Double = 0
            'Dim packst As String = ""
            'For Each p In DY.eza_WARENPOS
            '    If p.ezaWP_PackstueckAnzahl IsNot Nothing AndAlso IsNumeric(p.ezaWP_PackstueckAnzahl) Then
            '        PackstAnz += p.ezaWP_PackstueckAnzahl
            '        packst &= p.ezaWP_PackstueckAnzahl & " "
            '    End If
            '    If p.ezaWP_PackstueckArt IsNot Nothing Then
            '        packst &= p.ezaWP_PackstueckArt & " "
            '    End If
            '    packst &= If(p.ezaWP_Warenbezeichnung, "") & vbNewLine
            '    rohmasseTmp += If(p.ezaWP_Rohmasse, 0)
            '    rechnungspreisTmp += If(p.ezaWP_Artikelpreis, 0)
            '    If cnt = 0 Then

            '    End If
            '    cnt += 1
            'Next
            'packst = packst.Trim
            'PosAnzahl = DY.eza_WARENPOS.Count
            'SPEDITIONSBUCH.Packstücke = packst

            'If If(SPEDITIONSBUCH.Rohmasse, 0) = 0 AndAlso rohmasseTmp > 0 Then SPEDITIONSBUCH.Rohmasse = CInt(rohmasseTmp)
            'If If(SPEDITIONSBUCH.Rechnungsbetrag, 0) = 0 AndAlso rechnungspreisTmp > 0 Then SPEDITIONSBUCH.Rechnungsbetrag = (rechnungspreisTmp)


        Catch ex As Exception
            MsgBox("ERR: " & ex.Message & ex.StackTrace)
        End Try

    End Sub

    Shared Function getStbFromAnmId(LRN, ByRef StbId, ByRef MittId) As Boolean
        Try

            Dim SQL As New VERAG_PROG_ALLGEMEIN.SQL
            If StbId Is Nothing OrElse StbId.ToString = String.Empty Then StbId = SQL.getValueTxtBySql("SELECT telanm_Steuerbescheid_dsId FROM [tblTelotec_Anmeldung] where Refs_crn='" & LRN & "'  ", "FMZOLL",,, Nothing)
            If MittId Is Nothing OrElse MittId.ToString = String.Empty Then MittId = SQL.getValueTxtBySql("SELECT [telanm_Mitteilung_dsId] FROM [tblTelotec_Anmeldung] where Refs_crn='" & LRN & "'  ", "FMZOLL",,, Nothing)

            Return True
        Catch : End Try
        Return False
    End Function


    Shared Function getVdbFromAnmId(LRN, ByRef VdbId) As Boolean
        Try
            Dim SQL As New VERAG_PROG_ALLGEMEIN.SQL
            If VdbId Is Nothing OrElse VdbId.ToString = String.Empty Then VdbId = SQL.getValueTxtBySql("SELECT [telanm_VBD_dsId] FROM [tblTelotec_Anmeldung] where Refs_crn='" & LRN & "'  ", "FMZOLL",,, Nothing)
            Return True
        Catch : End Try
        Return False
    End Function

    Public Shared Sub TELOTECDatenbereitstellung_NCTS(ByRef SPEDITIONSBUCH As VERAG_PROG_ALLGEMEIN.cSpeditionsbuch, DY As cTelotec_Anmeldung, ByRef notFound As Boolean, ByRef PosAnzahl As Integer)
        Dim SQL As New VERAG_PROG_ALLGEMEIN.SQL

        notFound = False

        Try

            If SPEDITIONSBUCH.Abfertigungsdatum Is Nothing Then SPEDITIONSBUCH.Abfertigungsdatum = Now 'CDate(DY.eza_Trans_DatumZeit).ToShortDateString
            SPEDITIONSBUCH.Zollsystem_Land = "AT"
            SPEDITIONSBUCH.Versendungsland = DY.Locs_Disp
            SPEDITIONSBUCH.Bestimmungsland = DY.Locs_Dest
            SPEDITIONSBUCH.LKW_Kennzeichen = DY.Transp_DepIdnt 'Transp_BordMo	

            Select Case DY.Hea_DecTy
                Case "T2", "T2L" : SPEDITIONSBUCH.Abfertigungsart = "6"
                Case "T1" : SPEDITIONSBUCH.Abfertigungsart = "5"
            End Select
            SPEDITIONSBUCH.BelegNr = DY.Refs_CRN
            If DY.ValData_InvCurr IsNot Nothing Then
                SPEDITIONSBUCH.Währungsschlüssel = If(DY.ValData_InvCurr = "EUR", "900", getWaehr(DY.ValData_InvCurr, SQL))
            End If


            'Versender            'Verkäufer
            If If(DY.ConorTra_Na, "") <> "" Or If(DY.ConorTra_TIN, "") <> "" Then
                Dim AD = getAdresseFromEORI(DY.ConorTra_TIN, "", SQL, DY.telanm_firma)
                If AD IsNot Nothing Then
                    SPEDITIONSBUCH.AbsenderKundenNr = AD.AdressenNr
                    SPEDITIONSBUCH.Absender = AD.Ordnungsbegriff
                End If
                If If(SPEDITIONSBUCH.Absender, "").Trim = String.Empty Then
                    SPEDITIONSBUCH.Absender = If(DY.ConorTra_Na, "")
                    SPEDITIONSBUCH.Absender &= ", " & If(DY.ConorTra_Ctry, "")
                    SPEDITIONSBUCH.Absender &= " " & If(DY.ConorTra_Pst, "")
                    SPEDITIONSBUCH.Absender &= " " & If(DY.ConorTra_Cty, "")
                    SPEDITIONSBUCH.Absender = SPEDITIONSBUCH.Absender.Trim
                    If SPEDITIONSBUCH.Absender.Length > 50 Then
                        SPEDITIONSBUCH.Absender = SPEDITIONSBUCH.Absender.Substring(0, 50)
                    End If
                End If
                If If(SPEDITIONSBUCH.Absender, "").Trim = String.Empty Then SPEDITIONSBUCH.Absender &= " " & If(DY.ConorTra_TIN, "")
            End If


            'Empfänger
            If If(DY.ConeeTra_Na, "") <> "" Or If(DY.ConeeTra_TIN, "") <> "" Then
                Dim AD = getAdresseFromEORI(DY.ConeeTra_TIN, "", SQL, DY.telanm_firma)
                If AD IsNot Nothing Then
                    SPEDITIONSBUCH.EmpfängerKundenNr = AD.AdressenNr
                    SPEDITIONSBUCH.Empfänger = AD.Ordnungsbegriff
                End If
                If If(SPEDITIONSBUCH.Empfänger, "").Trim = String.Empty Then
                    SPEDITIONSBUCH.Empfänger = If(DY.ConeeTra_Na, "")
                    SPEDITIONSBUCH.Empfänger &= ", " & If(DY.ConeeTra_Ctry, "")
                    SPEDITIONSBUCH.Empfänger &= " " & If(DY.ConeeTra_Pst, "")
                    SPEDITIONSBUCH.Empfänger &= " " & If(DY.ConeeTra_Cty, "")
                    SPEDITIONSBUCH.Empfänger = SPEDITIONSBUCH.Empfänger.Trim
                    If SPEDITIONSBUCH.Empfänger.Length > 50 Then
                        SPEDITIONSBUCH.Empfänger = SPEDITIONSBUCH.Empfänger.Substring(0, 50)
                    End If
                End If
                If If(SPEDITIONSBUCH.Empfänger, "").Trim = String.Empty Then SPEDITIONSBUCH.Empfänger &= " " & If(DY.ConeeTra_TIN, "")
            End If




            'If If(SPEDITIONSBUCH.Abfertigungsart, 0) < 1 Then
            '    If DY.eza_FiskalvertretungKz Then
            '        SPEDITIONSBUCH.Abfertigungsart = 28
            '    Else
            '        SPEDITIONSBUCH.Abfertigungsart = 1
            '    End If
            'End If


            SPEDITIONSBUCH.Rechnungsbetrag = DY.ValData_InvVal
            ' SPEDITIONSBUCH.Umrechnungskurs = DY.eza_Rechnungswaehrung
            SPEDITIONSBUCH.Rohmasse = DY.Hea_TotGross

            MsgBox(SPEDITIONSBUCH.Rohmasse)
            MsgBox(DY.Hea_TotGross)
            'Personal Abfertigung:
            Try
                If If(DY.dec_CreatePersonalID, DY.Represent_Na) IsNot Nothing Then
                    Dim p = SQL.getValueTxtBySql("SELECT  ISNULL(CASE WHEN [mit_FMZollPersIDKasseIsnotSpedBuch]=1 THEN [mit_FMZollPersIDSpedBuch] ELSE [mit_FMZollPersID] END ,-1) as [mit_FMZollPersID]  FROM [ADMIN].[dbo].[tblMitarbeiter] WHERE [mit_TELOTEC_SB]='" & If(DY.dec_CreatePersonalID, DY.Represent_Na) & "'", "ADMIN")
                    SPEDITIONSBUCH.Personalnummer = If(IsNumeric(p), p, Nothing)
                End If
            Catch ex As Exception
                MsgBox("Fehler TELOTEC Personal: " & vbNewLine & ex.Message & vbNewLine & ex.StackTrace)
            End Try


            Dim PackstAnz As Integer = 0
            Dim cnt = 0
            Dim rohmasseTmp As Double = 0
            Dim rechnungspreisTmp As Double = 0
            Dim packst As String = ""
            Dim packstArt As String = ""
            For Each p In DY.POSITIONSDATEN
                For Each pk In p.PACKSTUECKE
                    PackstAnz += pk.Pack_Nr
                    packstArt = If(pk.Pack_Kind, "")
                    '       If pk.packst Then &= p.ezaWP_PackstueckArt & " "
                Next
                'If p.ezaWP_PackstueckAnzahl IsNot Nothing AndAlso IsNumeric(p.ezaWP_PackstueckAnzahl) Then
                '    PackstAnz += p.ezaWP_PackstueckAnzahl
                '    packst &= p.ezaWP_PackstueckAnzahl & " "
                'End If
                'If p.ezaWP_PackstueckArt IsNot Nothing Then
                '    packst &= p.ezaWP_PackstueckArt & " "
                'End If
                packst &= PackstAnz & " " & packstArt & " " & If(p.Item_GdsDes, "") & vbNewLine
                rohmasseTmp += If(p.Item_Gross, 0)
                rechnungspreisTmp += If(p.Item_ItVal, 0)
                If cnt = 0 Then

                End If
                cnt += 1
            Next
            packst = packst.Trim
            PosAnzahl = DY.POSITIONSDATEN.Count
            SPEDITIONSBUCH.Packstücke = packst

            If If(SPEDITIONSBUCH.Rohmasse, 0) = 0 AndAlso rohmasseTmp > 0 Then SPEDITIONSBUCH.Rohmasse = CInt(rohmasseTmp)
            If If(SPEDITIONSBUCH.Rechnungsbetrag, 0) = 0 AndAlso rechnungspreisTmp > 0 Then SPEDITIONSBUCH.Rechnungsbetrag = (rechnungspreisTmp)


            'Anhang
            If If(DY.Refs_CRN, "") <> String.Empty Then
                getVdbFromAnmId(DY.Refs_CRN, SPEDITIONSBUCH.DokumentId_VBD)
            End If

        Catch ex As Exception
            MsgBox("ERR: " & ex.Message & ex.StackTrace)
        End Try

    End Sub

    Shared Function getWaehr(s As String, SQL As VERAG_PROG_ALLGEMEIN.SQL) As String
        'Return KDSQL.getValueTxtBySql("SELECT TOP 1 isnull([LandNr],-1) FROM [Länderverzeichnis für die Außenhandelsstatistik] WHERE [Währungscode]='" & s & "'", "FMZOLL")
        s = s.Replace("TRY", "TRL") ' Türkische Lira
        Return SQL.getValueTxtBySql("SELECT TOP 1 isnull([Währungsschlüssel],-1) FROM [Währungstabelle] WHERE [Währungscode]='" & s & "'", "FMZOLL")

    End Function

    Shared Function getAdresseFromEORI(EORI As String, EORI_NL As String, SQL As VERAG_PROG_ALLGEMEIN.SQL, Firma As String)
        If EORI Is Nothing Then Return Nothing
        If If(EORI, "") <> "" Then
            Dim kdNrTmp = SQL.getFMZOLLKdNrFromEORI(EORI, EORI_NL, Firma)
            If IsNumeric(kdNrTmp) Then
                Dim ADRESSE As New VERAG_PROG_ALLGEMEIN.cAdressen(kdNrTmp)
                Return ADRESSE
            End If
        End If
        Return Nothing
    End Function



    Public Sub LOAD_Positionsdaten()
        Try
            POSITIONSDATEN.Clear()
            Using conn As SqlConnection = SQL.GetNewOpenConnectionFMZOLL()
                Using cmd As New SqlCommand("SELECT * FROM tblTelotec_Positionsdaten WHERE telpos_telanmId=@telanm_id  ", conn)
                    cmd.Parameters.AddWithValue("@telanm_id", Me.telanm_id)
                    Dim dr = cmd.ExecuteReader()
                    While dr.Read
                        Dim l As New cTelotec_Positionsdaten
                        For Each i In l.getParameterList()
                            Dim propInfo As PropertyInfo = l.GetType.GetProperty(i.Scalarvariable)
                            If dr.Item(i.Text) Is DBNull.Value Then
                                propInfo.SetValue(l, Nothing)
                            Else
                                propInfo.SetValue(l, dr.Item(i.Text))
                            End If
                        Next
                        l.LOAD_Packstücke()
                        l.LOAD_Abgaben()
                        POSITIONSDATEN.Add(l)
                    End While
                    dr.Close()
                End Using
            End Using
        Catch ex As Exception
            MsgBox("Fehler in der Funktion '" & System.Reflection.MethodInfo.GetCurrentMethod.Name & "'" & vbNewLine & vbNewLine & ex.Message & vbNewLine & vbNewLine & ex.StackTrace)
        End Try
    End Sub



    Public Sub LOAD_Sicherheit()
        Try
            SICHERHEIT.Clear()
            Using conn As SqlConnection = SQL.GetNewOpenConnectionFMZOLL()
                Using cmd As New SqlCommand("SELECT * FROM tblTelotec_Sicherheit WHERE telgrt_telanmId=@telanm_id  ", conn)
                    cmd.Parameters.AddWithValue("@telanm_id", Me.telanm_id)
                    Dim dr = cmd.ExecuteReader()
                    While dr.Read
                        Dim l As New cTelotec_Sicherheit
                        For Each i In l.getParameterList()
                            Dim propInfo As PropertyInfo = l.GetType.GetProperty(i.Scalarvariable)
                            If dr.Item(i.Text) Is DBNull.Value Then
                                propInfo.SetValue(l, Nothing)
                            Else
                                propInfo.SetValue(l, dr.Item(i.Text))
                            End If
                        Next
                        SICHERHEIT.Add(l)
                    End While
                    dr.Close()
                End Using
            End Using
        Catch ex As Exception
            MsgBox("Fehler in der Funktion '" & System.Reflection.MethodInfo.GetCurrentMethod.Name & "'" & vbNewLine & vbNewLine & ex.Message & vbNewLine & vbNewLine & ex.StackTrace)
        End Try
    End Sub



    Public Sub LOAD_Abgaben()
        Try
            ABGABEN.Clear()
            Using conn As SqlConnection = SQL.GetNewOpenConnectionFMZOLL()
                Using cmd As New SqlCommand("SELECT * FROM tblTelotec_Abgaben WHERE telAbg_telanmId=@telanm_id  ", conn)
                    cmd.Parameters.AddWithValue("@telanm_id", Me.telanm_id)
                    Dim dr = cmd.ExecuteReader()
                    While dr.Read
                        Dim l As New cTelotec_Abgaben
                        For Each i In l.getParameterList()
                            Dim propInfo As PropertyInfo = l.GetType.GetProperty(i.Scalarvariable)
                            If dr.Item(i.Text) Is DBNull.Value Then
                                propInfo.SetValue(l, Nothing)
                            Else
                                propInfo.SetValue(l, dr.Item(i.Text))
                            End If
                        Next
                        ABGABEN.Add(l)
                    End While
                    dr.Close()
                End Using
            End Using
        Catch ex As Exception
            MsgBox("Fehler in der Funktion '" & System.Reflection.MethodInfo.GetCurrentMethod.Name & "'" & vbNewLine & vbNewLine & ex.Message & vbNewLine & vbNewLine & ex.StackTrace)
        End Try
    End Sub


    Function DELETE_Packstücke() As Boolean 'obj As Object, tablename As String, where As String) As Boolean
        Dim sqlstr = " DELETE FROM [tblTelotec_Packstuecke] WHERE telpospk_telanmId =" & Me.telanm_id & " "
        Return SQL.doSQL(sqlstr, "FMZOLL")
    End Function

    Function DELETE_PositionsdatenAbgaben() As Boolean 'obj As Object, tablename As String, where As String) As Boolean
        Dim sqlstr = " DELETE FROM [tblTelotec_PositionsdatenAbgaben] WHERE telposAbg_telanmId =" & Me.telanm_id & " "
        Return SQL.doSQL(sqlstr, "FMZOLL")
    End Function
    Function DELETE_PositionsdatenDokumente() As Boolean 'obj As Object, tablename As String, where As String) As Boolean
        Dim sqlstr = " DELETE FROM [tblTelotec_PositionsdatenDokumente] WHERE telposAbg_telanmId =" & Me.telanm_id & " "
        Return SQL.doSQL(sqlstr, "FMZOLL")
    End Function
    Function DELETE_PositionsdatenMasseinheiten() As Boolean 'obj As Object, tablename As String, where As String) As Boolean
        Dim sqlstr = " DELETE FROM [tblTelotec_PositionsdatenMasseinheiten] WHERE telposMass_telanmId =" & Me.telanm_id & " "
        Return SQL.doSQL(sqlstr, "FMZOLL")
    End Function

    Function DELETE_Positionsdaten() As Boolean 'obj As Object, tablename As String, where As String) As Boolean
        Dim sqlstr = " DELETE FROM [tblTelotec_Positionsdaten] WHERE telpos_telanmId =" & Me.telanm_id & " "
        Return SQL.doSQL(sqlstr, "FMZOLL")
    End Function

    Function DELETE_Sicherheit() As Boolean 'obj As Object, tablename As String, where As String) As Boolean
        Dim sqlstr = " DELETE FROM [tblTelotec_Sicherheit] WHERE telgrt_telanmId =" & Me.telanm_id & " "
        Return SQL.doSQL(sqlstr, "FMZOLL")
    End Function
    Function DELETE_Abgaben() As Boolean 'obj As Object, tablename As String, where As String) As Boolean
        Dim sqlstr = " DELETE FROM [tblTelotec_Abgaben] WHERE telAbg_telanmId =" & Me.telanm_id & " "
        Return SQL.doSQL(sqlstr, "FMZOLL")
    End Function

    Public Function SAVE_Sicherheit() As Boolean
        'Zuserst alle OffertenPos von dem Offert löschen
        If DELETE_Sicherheit() Then 'And DELETE_SicherheitUnterlagen() And DELETE_SicherheitVerbrauchssteuer() Then
            'jetzt die Standartofferten  einfügen
            For Each p In SICHERHEIT
                p.telgrt_telanmId = telanm_id
                If p.INSERT() Then
                Else
                    Return False
                End If
            Next
        Else
            Return False
        End If

        Return True
    End Function
    Public Function SAVE_Abgaben() As Boolean
        'Zuserst alle OffertenPos von dem Offert löschen
        If DELETE_Abgaben() Then 'And DELETE_SicherheitUnterlagen() And DELETE_SicherheitVerbrauchssteuer() Then
            'jetzt die Standartofferten  einfügen
            For Each p In ABGABEN
                p.telAbg_telanmId = telanm_id
                If p.INSERT() Then
                Else
                    Return False
                End If
            Next
        Else
            Return False
        End If

        Return True
    End Function


    Public Function SAVE_Positionsdaten() As Boolean
        'Zuserst alle OffertenPos von dem Offert löschen
        If DELETE_Positionsdaten() And DELETE_Packstücke() And DELETE_PositionsdatenAbgaben() And DELETE_PositionsdatenDokumente() And DELETE_PositionsdatenMasseinheiten() Then 'And DELETE_PositionsdatenUnterlagen() And DELETE_PositionsdatenVerbrauchssteuer() Then
            'jetzt die Standartofferten  einfügen
            For Each p In POSITIONSDATEN
                p.telpos_telanmId = telanm_id
                p.Mandant_ID = Mandant_ID
                p.Bereich_ID = Bereich_ID
                p.Referenz_ID = Referenz_ID
                p.ComIndicator = ComIndicator
                ' POS.Pos_ID = cnt

                If p.INSERT() Then
                    p.INSERT_Packstücke(p.telpos_id, Me.telanm_id)
                    p.INSERT_Abgaben(p.telpos_id, Me.telanm_id)
                    p.INSERT_Dokumente(p.telpos_id, Me.telanm_id)
                    p.INSERT_Masseinheiten(p.telpos_id, Me.telanm_id)
                    'p.INSERT_PositionsdatenUnterlagen(p.ezaWP_Id, Me.eza_Id)
                    'p.INSERT_PositionsdatenVerbrauchssteuer(p.ezaWP_Id, Me.eza_Id)
                Else
                    Return False
                End If
            Next
        Else
            Return False
        End If

        Return True
    End Function



    Public Shared Function ConvertTAMessageToTelotec(msg As VERAG_PROG_ALLGEMEIN.cTelotecAPI.TAMessage) As cTelotec_Anmeldung
        Dim telotec As New cTelotec_Anmeldung()

        With msg
            If .declarationContent IsNot Nothing Then
                Dim decl = .declarationContent
                telotec.initData()

                telotec.telanm_ART = "TA"
                telotec.telanm_BezugsNr = .lrn
                telotec.telanm_CRN = .mrn
                telotec.MsgType = .msgType

                Select Case .msgType
                    Case "CC029C" : telotec.telanm_Status = "50"
                    'Case "CC045C" : telotec.status = "53"
                    Case "CC045C" : telotec.telanm_Status = "60"
                End Select
                telotec.telanm_Status_KEWILL_Equivalent = telotec.telanm_Status

                telotec.Refs_LRN = .lrn
                telotec.Refs_CRN = .mrn


                telotec.Represent_Na = decl.erstellPersonalID
                telotec.Mandant_ID = decl.mandant_ID
                telotec.Referenz_ID = decl.interfaceReferenceId
                telotec.dec_CreatePersonalID = decl.erstellPersonalID
                telotec.dec_CreateDate = decl.anmeldedatum
                telotec.dec_Template_ID = decl.template_ID
                telotec.dec_TotNet = decl.totNet
                telotec.dec_TotNetSplit_IND = decl.totNetSplit_IND
                telotec.dec_FillPackList_IND = decl.fillPackList_IND
                telotec.dec_Memo = decl.memo

                telotec.Hea_DecTy = decl.declarationType
                telotec.Hea_Simp = decl.reducedDatasetIndicator
                telotec.Hea_DecDT = decl.declarationAcceptanceDate
                telotec.Hea_WoffD = decl.writeOffDate 'Gestetellt am...
                telotec.Hea_AccDT = decl.declarationAcceptanceDate
                telotec.Hea_ProArrDT = decl.presentationOfTheGoodsDateAndTime
                telotec.Hea_PlaDepDT = decl.presentationOfTheGoodsDateAndTime
                telotec.Hea_TotGross = decl.grossMass
                ' telotec.Hea_PayMet = decl.methodOfPayment int erw
                telotec.Hea_SecInd = decl.security
                telotec.Hea_DestLNG = decl.countryOfDestination
                telotec.Hea_DepLNG = decl.countryOfDispatch
                telotec.Transp_InMo = decl.inlandModeOfTransport
                telotec.Transp_BordMo = decl.modeOfTransportAtTheBorder
                telotec.Transp_ContInd = decl.containerIndicator

                If decl.activeBorderTransportMeans IsNot Nothing AndAlso decl.activeBorderTransportMeans.Count > 0 Then
                    telotec.Transp_CrossIdnt = decl.activeBorderTransportMeans(0).identificationNumber
                    telotec.Transp_CrossIdntNat = decl.activeBorderTransportMeans(0).nationality

                    telotec.Transp_DepIdnt = decl.activeBorderTransportMeans(0).identificationNumber
                    telotec.Transp_DepNat = decl.activeBorderTransportMeans(0).nationality

                End If

                ' Consignor/Consignee
                telotec.ConorTra_Na = SafeGetName(decl.consignor)
                'telotec.ConorTra_Strt = decl.consignor.streetAndNumber
                'telotec.ConorTra_Pst = decl.consignor?.postcode
                'telotec.ConorTra_Cty = decl.consignor?.city
                'telotec.ConorTra_Ctry = decl.consignor?.country
                telotec.ConorTra_TIN = decl.consignor?.identificationNumber

                telotec.ConeeTra_Na = SafeGetName(decl.consignee)
                telotec.ConeeTra_Strt = decl.consignee?.streetAndNumber
                telotec.ConeeTra_Pst = decl.consignee?.postcode
                telotec.ConeeTra_Cty = decl.consignee?.city
                telotec.ConeeTra_Ctry = decl.consignee?.country
                telotec.ConeeTra_TIN = decl.consignee?.identificationNumber

                'telotec.Represent_Na = decl.representative?.contactPersonName
                telotec.Represent_RIN = decl.representative?.identificationNumber

                telotec.Locs_Disp = decl.countryOfDispatch
                telotec.Locs_Dest = decl.countryOfDestination
                telotec.Locs_GdsLoc = decl.locationOfGoods_PlaceOfGoods
                telotec.Locs_GdsLocCd = decl.locationOfGoods_CustomsOffice
                telotec.CtrlRslt_DLimit = decl.limitDate




                If decl.guarantee IsNot Nothing Then
                    telotec.SICHERHEIT = New List(Of cTelotec_Sicherheit)

                    Dim TC_GRT As New cTelotec_Sicherheit()
                    TC_GRT.GVal = 0
                    TC_GRT.Mandant_ID = telotec.Mandant_ID
                    TC_GRT.Bereich_ID = If(telotec.Bereich_ID, "")
                    TC_GRT.Referenz_ID = If(telotec.Referenz_ID, "")
                    TC_GRT.ComIndicator = If(telotec.ComIndicator, "0")

                    For Each grt In decl.guarantee
                        TC_GRT.GrteeRef_GTy = grt.guaranteeType
                        For Each hc In grt.guaranteeReference
                            TC_GRT.GRN = hc.grn
                            TC_GRT.Curr = hc.currency
                            TC_GRT.Acc = hc.accessCode
                            TC_GRT.GVal += CDbl(hc.amountToBeCovered)
                        Next

                        telotec.SICHERHEIT.Add(TC_GRT)
                    Next
                End If


                ' HouseConsignments inkl. ConsignmentItems und Packaging
                'If decl.houseConsignment IsNot Nothing Then
                '    telotec.HouseConsignments = New List(Of cTelotec_Positionsdaten)()
                '    For Each hc In decl.houseConsignment
                '        Dim newHc As New cTelotec_HouseConsignment()
                '        newHc.CountryOfDispatch = hc.countryOfDispatch
                '        newHc.CountryOfDestination = hc.countryOfDestination
                '        newHc.GrossMass = hc.grossMass
                '        newHc.ReferenceNumberUCR = hc.referenceNumberUCR
                '        newHc.MethodOfPayment = hc.methodOfPayment

                '        If hc.consignmentItem IsNot Nothing Then
                '            newHc.ConsignmentItems = New List(Of cTelotec_ConsignmentItem)()
                '            For Each item In hc.consignmentItem
                '                Dim newItem As New cTelotec_ConsignmentItem()
                '                newItem.GoodsItemNumber = item.goodsItemNumber
                '                newItem.DeclarationGoodsItemNumber = item.declarationGoodsItemNumber
                '                newItem.DeclarationType = item.declarationType
                '                newItem.CountryOfDispatch = item.countryOfDispatch
                '                newItem.CountryOfDestination = item.countryOfDestination
                '                newItem.DescriptionOfGoods = item.descriptionOfGoods
                '                newItem.GrossMass = item.grossMass
                '                newItem.NetMass = item.netMass
                '                newItem.MethodOfPayment = item.methodOfPayment
                '                newItem.ReferenceNumberUCR = item.referenceNumberUCR

                '                If item.packaging IsNot Nothing Then
                '                    newItem.Packaging = New List(Of cTelotec_Packaging)()
                '                    For Each pack In item.packaging
                '                        Dim newPack As New cTelotec_Packaging()
                '                        newPack.TypeOfPackages = pack.typeOfPackages
                '                        newPack.NumberOfPackages = pack.numberOfPackages
                '                        newPack.ShippingMarks = pack.shippingMarks
                '                        newItem.Packaging.Add(newPack)
                '                    Next
                '                End If

                '                newHc.ConsignmentItems.Add(newItem)
                '            Next
                '        End If

                '        telotec.HouseConsignments.Add(newHc)
                '    Next
                'End If
            End If
        End With

        telotec.telanm_LetzteBearbeitung = Now
        telotec.telanm_Erstellung = Now
        telotec.telanm_Erstellung_SB = VERAG_PROG_ALLGEMEIN.cAllgemein.USRID
        telotec.telanm_LetzteBearbeitung_SB = VERAG_PROG_ALLGEMEIN.cAllgemein.USRID
        telotec.ComIndicator = True


        Return telotec
    End Function

    Private Shared Function SafeFirst(Of T, R)(list As List(Of T), selector As Func(Of T, R)) As R
        If list Is Nothing OrElse list.Count = 0 Then Return Nothing
        Return selector(list(0))
    End Function

    Private Shared Function SafeGetName(party As Object) As String
        If party Is Nothing Then Return Nothing
        Return If(party?.consignorName, party?.consigneeName, "")
    End Function

End Class



Public Class cTelotec_Positionsdaten

    Property telpos_id As Integer
    Property telpos_telanmId As Integer
    Property Mandant_ID As Object = Nothing
    Property Bereich_ID As Object = Nothing
    Property Referenz_ID As Object = Nothing
    Property ComIndicator As Object = Nothing
    Property Pos_ID As Integer
    Property Item_Status As Object = Nothing
    Property Item_ComCd As Object = Nothing
    Property Item_GdsDes As Object = Nothing
    Property Item_Gross As Object = Nothing
    Property Item_Net As Object = Nothing
    Property Item_Orig As Object = Nothing
    Property Item_ProcCd As Object = Nothing
    Property Item_ProcAddCd As Object = Nothing
    Property Item_ItVal As Object = Nothing
    Property Item_Pref As Object = Nothing
    Property Item_Quota As Object = Nothing
    Property Item_ValMet As Object = Nothing
    Property Item_VATInd As Object = Nothing
    Property Item_StatVal As Object = Nothing
    Property SurvCO_Ref As Object = Nothing
    Property Telo_Artikel_ID As Object = Nothing
    Property Telo_Artikelmenge As Object = Nothing
    Property Telo_ArtikelMEH As Object = Nothing

    Property PACKSTUECKE As New List(Of cTelotec_Packstuecke)
    Property ABGABEN As New List(Of cTelotec_PositionsdatenAbgaben)
    Property DOC_CERTS As New List(Of cTelotec_PositionsdatenDokumente)
    Property MASSEINHEITEN As New List(Of cTelotec_PositionsdatenMasseinheiten)

    Dim SQL As New VERAG_PROG_ALLGEMEIN.SQL

    Sub New()
    End Sub


    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("telpos_id", telpos_id, , True, True))

        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("telpos_telanmId", telpos_telanmId))
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("Mandant_ID", Mandant_ID))
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("Bereich_ID", Bereich_ID))
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("Referenz_ID", Referenz_ID))
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("ComIndicator", ComIndicator))
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("Pos_ID", Pos_ID))
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("Item_Status", Item_Status))
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("Item_ComCd", Item_ComCd))
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("Item_GdsDes", Item_GdsDes))
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("Item_Gross", Item_Gross))
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("Item_Net", Item_Net))
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("Item_Orig", Item_Orig))
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("Item_ProcCd", Item_ProcCd))
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("Item_ProcAddCd", Item_ProcAddCd))
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("Item_ItVal", Item_ItVal))
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("Item_Pref", Item_Pref))
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("Item_Quota", Item_Quota))
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("Item_ValMet", Item_ValMet))
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("Item_VATInd", Item_VATInd))
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("Item_StatVal", Item_StatVal))
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("SurvCO_Ref", SurvCO_Ref))
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("Telo_Artikel_ID", Telo_Artikel_ID))
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("Telo_Artikelmenge", Telo_Artikelmenge))
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("Telo_ArtikelMEH", Telo_ArtikelMEH))

        Return list
    End Function


    Public Function INSERT() As Boolean
        Dim list As List(Of VERAG_PROG_ALLGEMEIN.SQLVariable) = getParameterList()
        'Return SQL.doSQLVarList(getInsertCmd, "FMZOLL", , list)
        telpos_id = SQL.doSQLVarListID(telpos_id, getInsertCmd, "FMZOLL", , list)
        Return telpos_id > 0
    End Function

    Public Function INSERT_Packstücke(telpos_id, telanm_id) As Boolean
        For Each p In PACKSTUECKE
            p.telpospk_telanmId = telanm_id
            p.telpospk_telposId = telpos_id
            If Not p.INSERT() Then Return False
        Next
        Return True
    End Function

    Public Sub LOAD_Packstücke()
        Try
            PACKSTUECKE.Clear()
            Using conn As SqlConnection = SQL.GetNewOpenConnectionFMZOLL()
                Using cmd As New SqlCommand("SELECT * FROM tblTelotec_Packstuecke WHERE telpospk_telposId=@telpos_id  ", conn)
                    cmd.Parameters.AddWithValue("@telpos_id", Me.telpos_id)
                    Dim dr = cmd.ExecuteReader()
                    While dr.Read
                        Dim l As New cTelotec_Packstuecke
                        For Each i In l.getParameterList()
                            Dim propInfo As PropertyInfo = l.GetType.GetProperty(i.Scalarvariable)
                            If dr.Item(i.Text) Is DBNull.Value Then
                                propInfo.SetValue(l, Nothing)
                            Else
                                propInfo.SetValue(l, dr.Item(i.Text))
                            End If
                        Next
                        PACKSTUECKE.Add(l)
                    End While
                    dr.Close()
                End Using
            End Using
        Catch ex As Exception
            MsgBox("Fehler in der Funktion '" & System.Reflection.MethodInfo.GetCurrentMethod.Name & "'" & vbNewLine & vbNewLine & ex.Message & vbNewLine & vbNewLine & ex.StackTrace)
        End Try
    End Sub

    Public Function INSERT_Abgaben(telpos_id, telanm_id) As Boolean
        For Each p In ABGABEN
            p.telposAbg_telanmId = telanm_id
            p.telposAbg_telposId = telpos_id
            If Not p.INSERT() Then Return False
        Next
        Return True
    End Function
    Public Function INSERT_Dokumente(telpos_id, telanm_id) As Boolean
        For Each p In DOC_CERTS
            p.telposAbg_telanmId = telanm_id
            p.telposAbg_telposId = telpos_id
            If Not p.INSERT() Then Return False
        Next
        Return True
    End Function
    Public Function INSERT_Masseinheiten(telpos_id, telanm_id) As Boolean
        For Each p In MASSEINHEITEN
            p.telposMass_telanmId = telanm_id
            p.telposMass_telposId = telpos_id
            If Not p.INSERT() Then Return False
        Next
        Return True
    End Function

    Public Sub LOAD_Abgaben()
        Try
            ABGABEN.Clear()
            Using conn As SqlConnection = SQL.GetNewOpenConnectionFMZOLL()
                Using cmd As New SqlCommand("SELECT * FROM tblTelotec_PositionsdatenAbgaben WHERE telposabg_telposId=@telpos_id  ", conn)
                    cmd.Parameters.AddWithValue("@telpos_id", Me.telpos_id)
                    Dim dr = cmd.ExecuteReader()
                    While dr.Read
                        Dim l As New cTelotec_PositionsdatenAbgaben
                        For Each i In l.getParameterList()
                            Dim propInfo As PropertyInfo = l.GetType.GetProperty(i.Scalarvariable)
                            If dr.Item(i.Text) Is DBNull.Value Then
                                propInfo.SetValue(l, Nothing)
                            Else
                                propInfo.SetValue(l, dr.Item(i.Text))
                            End If
                        Next
                        ABGABEN.Add(l)
                    End While
                    dr.Close()
                End Using
            End Using
        Catch ex As Exception
            MsgBox("Fehler in der Funktion '" & System.Reflection.MethodInfo.GetCurrentMethod.Name & "'" & vbNewLine & vbNewLine & ex.Message & vbNewLine & vbNewLine & ex.StackTrace)
        End Try
    End Sub
    Public Sub LOAD_Dokumente()
        Try
            DOC_CERTS.Clear()
            Using conn As SqlConnection = SQL.GetNewOpenConnectionFMZOLL()
                Using cmd As New SqlCommand("SELECT * FROM tblTelotec_PositionsdatenDokumente WHERE telposabg_telposId=@telpos_id  ", conn)
                    cmd.Parameters.AddWithValue("@telpos_id", Me.telpos_id)
                    Dim dr = cmd.ExecuteReader()
                    While dr.Read
                        Dim l As New cTelotec_PositionsdatenDokumente
                        For Each i In l.getParameterList()
                            Dim propInfo As PropertyInfo = l.GetType.GetProperty(i.Scalarvariable)
                            If dr.Item(i.Text) Is DBNull.Value Then
                                propInfo.SetValue(l, Nothing)
                            Else
                                propInfo.SetValue(l, dr.Item(i.Text))
                            End If
                        Next
                        DOC_CERTS.Add(l)
                    End While
                    dr.Close()
                End Using
            End Using
        Catch ex As Exception
            MsgBox("Fehler in der Funktion '" & System.Reflection.MethodInfo.GetCurrentMethod.Name & "'" & vbNewLine & vbNewLine & ex.Message & vbNewLine & vbNewLine & ex.StackTrace)
        End Try
    End Sub
    Public Sub LOAD_Masseinheiten()
        Try
            MASSEINHEITEN.Clear()
            Using conn As SqlConnection = SQL.GetNewOpenConnectionFMZOLL()
                Using cmd As New SqlCommand("SELECT * FROM tblTelotec_PositionsdatenMasseinheiten WHERE telposMass_telposId=@telpos_id  ", conn)
                    cmd.Parameters.AddWithValue("@telpos_id", Me.telpos_id)
                    Dim dr = cmd.ExecuteReader()
                    While dr.Read
                        Dim l As New cTelotec_PositionsdatenMasseinheiten
                        For Each i In l.getParameterList()
                            Dim propInfo As PropertyInfo = l.GetType.GetProperty(i.Scalarvariable)
                            If dr.Item(i.Text) Is DBNull.Value Then
                                propInfo.SetValue(l, Nothing)
                            Else
                                propInfo.SetValue(l, dr.Item(i.Text))
                            End If
                        Next
                        MASSEINHEITEN.Add(l)
                    End While
                    dr.Close()
                End Using
            End Using
        Catch ex As Exception
            MsgBox("Fehler in der Funktion '" & System.Reflection.MethodInfo.GetCurrentMethod.Name & "'" & vbNewLine & vbNewLine & ex.Message & vbNewLine & vbNewLine & ex.StackTrace)
        End Try
    End Sub

    Public Function getInsertCmd() As String
        Try
            Dim list As List(Of VERAG_PROG_ALLGEMEIN.SQLVariable) = getParameterList()
            Dim str As String = ""
            Dim values As String = ""
            For Each i In list
                If Not i.isPrimaryParam Then
                    str &= "[" & i.Text & "],"
                    values &= "@" & i.Scalarvariable & "," '.Replace("-", "").Replace(" ", "") & ","
                End If
            Next
            str = str.Substring(0, str.Length - 1) 'wg. ','
            values = values.Substring(0, values.Length - 1) 'wg. ','
            Return (" INSERT INTO tblTelotec_Positionsdaten  (" & str & ") VALUES(" & values & ")  ")
        Catch ex As Exception
            MsgBox("Fehler In der Funktion '" & System.Reflection.MethodInfo.GetCurrentMethod.Name & "'" & vbNewLine & vbNewLine & ex.Message & vbNewLine & vbNewLine & ex.StackTrace)
        End Try
        Return ""
    End Function

End Class





Public Class cTelotec_Packstuecke

    Property telpospk_id As Integer
    Property telpospk_telanmId As Integer
    Property telpospk_telposId As Integer
    Property Mandant_ID As Object = Nothing
    Property Bereich_ID As Object = Nothing
    Property Referenz_ID As Object = Nothing
    Property ComIndicator As Boolean
    Property Pos_ID As Integer
    Property Pack_ID As Integer
    Property Pack_Mark As Object = Nothing
    Property Pack_Kind As Object = Nothing
    Property Pack_Nr As Object = Nothing
    Property Pack_Piec As Object = Nothing
    Property Telo_Gross As Object = Nothing


    Dim SQL As New VERAG_PROG_ALLGEMEIN.SQL

    Sub New()
    End Sub


    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("telpospk_id", telpospk_id, , True, True))
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("telpospk_telanmId", telpospk_telanmId))
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("telpospk_telposId", telpospk_telposId))
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("Mandant_ID", Mandant_ID))
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("Bereich_ID", Bereich_ID))
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("Referenz_ID", Referenz_ID))
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("ComIndicator", ComIndicator))
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("Pos_ID", Pos_ID))
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("Pack_ID", Pack_ID))
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("Pack_Mark", Pack_Mark))
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("Pack_Kind", Pack_Kind))
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("Pack_Nr", Pack_Nr))
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("Pack_Piec", Pack_Piec))
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("Telo_Gross", Telo_Gross))

        Return list
    End Function

    Public Function INSERT() As Boolean
        Dim list As List(Of VERAG_PROG_ALLGEMEIN.SQLVariable) = getParameterList()
        telpospk_id = SQL.doSQLVarListID(telpospk_id, getInsertCmd, "FMZOLL", , list)
        Return telpospk_id > 0
    End Function

    Public Function getInsertCmd() As String
        Try
            Dim list As List(Of VERAG_PROG_ALLGEMEIN.SQLVariable) = getParameterList()
            Dim str As String = ""
            Dim values As String = ""
            For Each i In list
                If Not i.isPrimaryParam Then
                    str &= "[" & i.Text & "],"
                    values &= "@" & i.Scalarvariable & "," '.Replace("-", "").Replace(" ", "") & ","
                End If
            Next
            str = str.Substring(0, str.Length - 1) 'wg. ','
            values = values.Substring(0, values.Length - 1) 'wg. ','
            Return (" INSERT INTO tblTelotec_Packstuecke  (" & str & ") VALUES(" & values & ")  ")
        Catch ex As Exception
            MsgBox("Fehler In der Funktion '" & System.Reflection.MethodInfo.GetCurrentMethod.Name & "'" & vbNewLine & vbNewLine & ex.Message & vbNewLine & vbNewLine & ex.StackTrace)
        End Try
        Return ""
    End Function

End Class





Public Class cTelotec_Sicherheit


    Property telgrt_id As Integer
    Property telgrt_telanmId As Integer
    Property Mandant_ID As Object = Nothing
    Property Bereich_ID As Object = Nothing
    Property Referenz_ID As Object = Nothing
    Property ComIndicator As Boolean
    Property GrteeRef_ID As Integer
    Property GrteeRef_GTy As Object = Nothing
    Property GRN As Object = Nothing
    Property OGR As Object = Nothing
    Property Acc As Object = Nothing
    Property GTIN As Object = Nothing
    Property GVal As Object = Nothing
    Property Curr As Object = Nothing



    Dim SQL As New VERAG_PROG_ALLGEMEIN.SQL

    Sub New()
    End Sub


    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("telgrt_id", telgrt_id, , True, True))

        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("telgrt_telanmId", telgrt_telanmId))
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("Mandant_ID", Mandant_ID))
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("Bereich_ID", Bereich_ID))
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("Referenz_ID", Referenz_ID))
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("ComIndicator", ComIndicator))
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("GrteeRef_ID", GrteeRef_ID))
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("GrteeRef_GTy", GrteeRef_GTy))
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("GRN", GRN))
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("OGR", OGR))
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("Acc", Acc))
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("GTIN", GTIN))
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("GVal", GVal))
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("Curr", Curr))
        Return list
    End Function


    Public Function INSERT() As Boolean
        Dim list As List(Of VERAG_PROG_ALLGEMEIN.SQLVariable) = getParameterList()
        'Return SQL.doSQLVarList(getInsertCmd, "FMZOLL", , list)
        telgrt_id = SQL.doSQLVarListID(telgrt_id, getInsertCmd, "FMZOLL", , list)
        Return telgrt_id > 0
    End Function




    Public Function getInsertCmd() As String
        Try
            Dim list As List(Of VERAG_PROG_ALLGEMEIN.SQLVariable) = getParameterList()
            Dim str As String = ""
            Dim values As String = ""
            For Each i In list
                If Not i.isPrimaryParam Then
                    str &= "[" & i.Text & "],"
                    values &= "@" & i.Scalarvariable & "," '.Replace("-", "").Replace(" ", "") & ","
                End If
            Next
            str = str.Substring(0, str.Length - 1) 'wg. ','
            values = values.Substring(0, values.Length - 1) 'wg. ','
            Return (" INSERT INTO tblTelotec_Sicherheit  (" & str & ") VALUES(" & values & ")  ")
        Catch ex As Exception
            MsgBox("Fehler In der Funktion '" & System.Reflection.MethodInfo.GetCurrentMethod.Name & "'" & vbNewLine & vbNewLine & ex.Message & vbNewLine & vbNewLine & ex.StackTrace)
        End Try
        Return ""
    End Function

End Class



Public Class cTelotec_Abgaben


    Property telAbg_id As Integer
    Property telAbg_telanmId As Integer
    Property Mandant_ID As Object = Nothing
    Property Bereich_ID As Object = Nothing
    Property Referenz_ID As Object = Nothing
    Property ComIndicator As Boolean
    Property TotDuties_ID As Integer
    Property Ty As Object = Nothing
    Property Amnt As Object = Nothing
    Property TyInd As Object = Nothing
    Property Erstelldatum As Object = Nothing



    Dim SQL As New VERAG_PROG_ALLGEMEIN.SQL

    Sub New()
    End Sub


    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("telAbg_id", telAbg_id, , True, True))

        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("telAbg_telanmId", telAbg_telanmId))
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("Mandant_ID", Mandant_ID))
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("Bereich_ID", Bereich_ID))
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("Referenz_ID", Referenz_ID))
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("ComIndicator", ComIndicator))
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("TotDuties_ID", TotDuties_ID))
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("Ty", Ty))
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("Amnt", Amnt))
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("TyInd", TyInd))
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("Erstelldatum", Erstelldatum))
        Return list
    End Function


    Public Function INSERT() As Boolean
        Dim list As List(Of VERAG_PROG_ALLGEMEIN.SQLVariable) = getParameterList()
        'Return SQL.doSQLVarList(getInsertCmd, "FMZOLL", , list)
        telAbg_id = SQL.doSQLVarListID(telAbg_id, getInsertCmd, "FMZOLL", , list)
        Return telAbg_id > 0
    End Function




    Public Function getInsertCmd() As String
        Try
            Dim list As List(Of VERAG_PROG_ALLGEMEIN.SQLVariable) = getParameterList()
            Dim str As String = ""
            Dim values As String = ""
            For Each i In list
                If Not i.isPrimaryParam Then
                    str &= "[" & i.Text & "],"
                    values &= "@" & i.Scalarvariable & "," '.Replace("-", "").Replace(" ", "") & ","
                End If
            Next
            str = str.Substring(0, str.Length - 1) 'wg. ','
            values = values.Substring(0, values.Length - 1) 'wg. ','
            Return (" INSERT INTO tblTelotec_Abgaben  (" & str & ") VALUES(" & values & ")  ")
        Catch ex As Exception
            MsgBox("Fehler In der Funktion '" & System.Reflection.MethodInfo.GetCurrentMethod.Name & "'" & vbNewLine & vbNewLine & ex.Message & vbNewLine & vbNewLine & ex.StackTrace)
        End Try
        Return ""
    End Function

End Class

Public Class cTelotec_PositionsdatenAbgaben


    Property telposAbg_id As Integer
    Property telposAbg_telposId As Integer
    Property telposAbg_telanmId As Integer
    Property Mandant_ID As Object = Nothing
    Property Bereich_ID As Object = Nothing
    Property Referenz_ID As Object = Nothing
    Property ComIndicator As Boolean
    Property Pos_ID As Integer
    Property DutyCalc_ID As Object = Nothing
    Property Ty As Object = Nothing
    Property BaseD As Object = Nothing
    Property Curr As Object = Nothing
    Property Unit As Object = Nothing
    Property Base As Object = Nothing
    Property Rate As Object = Nothing
    Property RateUsed As Object = Nothing
    Property Amnt As Object = Nothing
    Property MeaID As Object = Nothing
    Property TyInd As Object = Nothing


    Dim SQL As New VERAG_PROG_ALLGEMEIN.SQL

    Sub New()
    End Sub


    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("telposAbg_id", telposAbg_id, , True, True))

        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("telposAbg_telposId", telposAbg_telposId))
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("telposAbg_telanmId", telposAbg_telanmId))

        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("Mandant_ID", Mandant_ID))
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("Bereich_ID", Bereich_ID))
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("Referenz_ID", Referenz_ID))
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("ComIndicator", ComIndicator))
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("Pos_ID", Pos_ID))
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("DutyCalc_ID", DutyCalc_ID))
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("Ty", Ty))
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("BaseD", BaseD))
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("Curr", Curr))
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("Unit", Unit))
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("Base", Base))
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("Rate", Rate))
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("RateUsed", RateUsed))
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("Amnt", Amnt))
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("MeaID", MeaID))
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("TyInd", TyInd))
        Return list
    End Function


    Public Function INSERT() As Boolean
        Dim list As List(Of VERAG_PROG_ALLGEMEIN.SQLVariable) = getParameterList()
        'Return SQL.doSQLVarList(getInsertCmd, "FMZOLL", , list)
        telposAbg_id = SQL.doSQLVarListID(telposAbg_id, getInsertCmd, "FMZOLL", , list)
        Return telposAbg_id > 0
    End Function




    Public Function getInsertCmd() As String
        Try
            Dim list As List(Of VERAG_PROG_ALLGEMEIN.SQLVariable) = getParameterList()
            Dim str As String = ""
            Dim values As String = ""
            For Each i In list
                If Not i.isPrimaryParam Then
                    str &= "[" & i.Text & "],"
                    values &= "@" & i.Scalarvariable & "," '.Replace("-", "").Replace(" ", "") & ","
                End If
            Next
            str = str.Substring(0, str.Length - 1) 'wg. ','
            values = values.Substring(0, values.Length - 1) 'wg. ','
            Return (" INSERT INTO tblTelotec_PositionsdatenAbgaben  (" & str & ") VALUES(" & values & ")  ")
        Catch ex As Exception
            MsgBox("Fehler In der Funktion '" & System.Reflection.MethodInfo.GetCurrentMethod.Name & "'" & vbNewLine & vbNewLine & ex.Message & vbNewLine & vbNewLine & ex.StackTrace)
        End Try
        Return ""
    End Function

End Class



Public Class cTelotec_PositionsdatenMasseinheiten


    Property telposMass_id As Integer
    Property telposMass_telposId As Integer
    Property telposMass_telanmId As Integer
    Property Mandant_ID As Object = Nothing
    Property Bereich_ID As Object = Nothing
    Property Referenz_ID As Object = Nothing
    Property ComIndicator As Boolean
    Property Pos_ID As Integer

    Property SupplUnt_ID As Object = Nothing
    Property SupplUnt_Unit As Object = Nothing
    Property SupplUnt_SUQuant As Object = Nothing
    Dim SQL As New VERAG_PROG_ALLGEMEIN.SQL

    Sub New()
    End Sub


    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("telposMass_id", telposMass_id, , True, True))

        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("telposMass_telposId", telposMass_telposId))
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("telposMass_telanmId", telposMass_telanmId))

        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("Mandant_ID", Mandant_ID))
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("Bereich_ID", Bereich_ID))
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("Referenz_ID", Referenz_ID))
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("ComIndicator", ComIndicator))
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("Pos_ID", Pos_ID))
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("SupplUnt_ID", SupplUnt_ID))
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("SupplUnt_Unit", SupplUnt_Unit))
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("SupplUnt_SUQuant", SupplUnt_SUQuant))
        Return list
    End Function


    Public Function INSERT() As Boolean
        Dim list As List(Of VERAG_PROG_ALLGEMEIN.SQLVariable) = getParameterList()
        'Return SQL.doSQLVarList(getInsertCmd, "FMZOLL", , list)
        telposMass_id = SQL.doSQLVarListID(telposMass_id, getInsertCmd, "FMZOLL", , list)
        Return telposMass_id > 0
    End Function




    Public Function getInsertCmd() As String
        Try
            Dim list As List(Of VERAG_PROG_ALLGEMEIN.SQLVariable) = getParameterList()
            Dim str As String = ""
            Dim values As String = ""
            For Each i In list
                If Not i.isPrimaryParam Then
                    str &= "[" & i.Text & "],"
                    values &= "@" & i.Scalarvariable & "," '.Replace("-", "").Replace(" ", "") & ","
                End If
            Next
            str = str.Substring(0, str.Length - 1) 'wg. ','
            values = values.Substring(0, values.Length - 1) 'wg. ','
            Return (" INSERT INTO tblTelotec_Positionsdaten_Masseinheiten  (" & str & ") VALUES(" & values & ")  ")
        Catch ex As Exception
            MsgBox("Fehler In der Funktion '" & System.Reflection.MethodInfo.GetCurrentMethod.Name & "'" & vbNewLine & vbNewLine & ex.Message & vbNewLine & vbNewLine & ex.StackTrace)
        End Try
        Return ""
    End Function

End Class



Public Class cTelotec_PositionsdatenDokumente


    Property telposAbg_id As Integer
    Property telposAbg_telposId As Integer
    Property telposAbg_telanmId As Integer
    Property Mandant_ID As Object = Nothing
    Property Bereich_ID As Object = Nothing
    Property Referenz_ID As Object = Nothing
    Property ComIndicator As Boolean
    Property Pos_ID As Integer

    Property DocCerts_ID As Object = Nothing
    Property DocCerts_DocCd As Object = Nothing
    Property DocCerts_DTy As Object = Nothing
    Property DocCerts_DRef As Object = Nothing
    Property DocCerts_IssD As Object = Nothing
    Property DocCerts_IssCtry As Object = Nothing
    Property DocCerts_DTIN As Object = Nothing
    Property DocCerts_UidVid As Object = Nothing
    Property DocCerts_ValD As Object = Nothing

    Dim SQL As New VERAG_PROG_ALLGEMEIN.SQL

    Sub New()
    End Sub


    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("telposAbg_id", telposAbg_id, , True, True))

        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("telposAbg_telposId", telposAbg_telposId))
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("telposAbg_telanmId", telposAbg_telanmId))

        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("Mandant_ID", Mandant_ID))
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("Bereich_ID", Bereich_ID))
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("Referenz_ID", Referenz_ID))
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("ComIndicator", ComIndicator))
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("Pos_ID", Pos_ID))
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("DocCerts_ID", DocCerts_ID))
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("DocCerts_DocCd", DocCerts_DocCd))
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("DocCerts_DTy", DocCerts_DTy))
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("DocCerts_DRef", DocCerts_DRef))
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("DocCerts_IssD", DocCerts_IssD))
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("DocCerts_IssCtry", DocCerts_IssD))
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("DocCerts_DTIN", DocCerts_IssD))
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("DocCerts_UidVid", DocCerts_IssD))
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("DocCerts_ValD", DocCerts_IssD))
        Return list
    End Function


    Public Function INSERT() As Boolean
        Dim list As List(Of VERAG_PROG_ALLGEMEIN.SQLVariable) = getParameterList()
        'Return SQL.doSQLVarList(getInsertCmd, "FMZOLL", , list)
        telposAbg_id = SQL.doSQLVarListID(telposAbg_id, getInsertCmd, "FMZOLL", , list)
        Return telposAbg_id > 0
    End Function




    Public Function getInsertCmd() As String
        Try
            Dim list As List(Of VERAG_PROG_ALLGEMEIN.SQLVariable) = getParameterList()
            Dim str As String = ""
            Dim values As String = ""
            For Each i In list
                If Not i.isPrimaryParam Then
                    str &= "[" & i.Text & "],"
                    values &= "@" & i.Scalarvariable & "," '.Replace("-", "").Replace(" ", "") & ","
                End If
            Next
            str = str.Substring(0, str.Length - 1) 'wg. ','
            values = values.Substring(0, values.Length - 1) 'wg. ','
            Return (" INSERT INTO tblTelotec_PositionsdatenDokumente  (" & str & ") VALUES(" & values & ")  ")
        Catch ex As Exception
            MsgBox("Fehler In der Funktion '" & System.Reflection.MethodInfo.GetCurrentMethod.Name & "'" & vbNewLine & vbNewLine & ex.Message & vbNewLine & vbNewLine & ex.StackTrace)
        End Try
        Return ""
    End Function



End Class

