Imports System.Data.SqlClient
Imports javax.xml.bind.annotation

Public Class cSendungen
    Implements ICloneable
    Property tblSnd_SendungID As Integer = Nothing
    Property tblSnd_PosUnterNr As Integer = Nothing
    Property tblSnd_AvisoID As Integer = Nothing
    Property tblSnd_Zollsystem_Land As Object = Nothing
    Property tblSnd_Abfertigungsart_ID As Integer = Nothing
    Property tblSnd_EmpfaengerKdNr As Integer = Nothing
    Property tblSnd_Empfaenger As String = Nothing
    Property tblSnd_Ansprechperson As String = Nothing
    Property tblSnd_Bonitaet As String = Nothing
    Property tblSnd_Anmerkung As String = Nothing
    Property tblSnd_AuftraggeberKdNr As Integer = Nothing
    Property tblSnd_Auftraggeber As String = Nothing
    Property tblSnd_SpeditionsbuchEingetragen As Boolean = False
    Property FilialenNr As Integer = Nothing
    Property AbfertigungsNr As Integer = Nothing
    Property UnterNr As Integer = Nothing
    Property tblSnd_Colli As String = Nothing
    Property tblSnd_Gewicht As String = Nothing
    Property tblSnd_Warenbezeichnung As String = Nothing
    Property tblSnd_SachbearbeiterId As Integer = Nothing
    Property tblSnd_AbsenderKdNr As Integer = Nothing
    Property tblSnd_Absender As String = Nothing
    Property tblSnd_AngabeZolltarif As Integer = Nothing
    Property tblSnd_inBearbeitung As Boolean = False
    Property tblSnd_Bearbeitung_MaId As Integer = Nothing
    Property tblSnd_aufschub As String = Nothing
    Property tblSnd_anzahlHandling As Object = Nothing
    Property tblSnd_anzahlHandlingPos As Object = Nothing
    Property tblSnd_anzahlPOS As Object = Nothing
    ' Property tblSnd_bar As Object = Nothing
    '  Property tblSnd_barBeleg As Object = Nothing
    ' Property tblSnd_betrag As Object = Nothing
    Property tblSnd_Fremdspedition As Boolean = False
    Property tblSnd_FremdspeditionText As String = ""
    Property tblSnd_QS_MA As Object = Nothing
    Property tblSnd_KdAuftragsNr As Object = ""
    Property tblSnd_NCTSVerzollungsadresse As Object = ""
    Property tblSnd_NCTSVerzollungsadresseKdNr As Object = ""

    Property NCTS_Verzollungsadresse_Strasse As Object = ""
    Property NCTS_Verzollungsadresse_PLZ As Object = ""
    Property NCTS_Verzollungsadresse_Ort As Object = ""
    Property NCTS_Verzollungsadresse_Land As Object = ""
    Property NCTS_Verzollungsadresse_EORI As Object = ""
    Property NCTS_Verzollungsadresse_EORI_NL As Object = ""
    Property NCTS_ngaId As Object = Nothing


    Property NCTS_Verzollungsadresse_Ansprechpartner As Object = ""
    Property NCTS_Bestimmungszollstelle As Object = ""

    Property tblSnd_Endempfaenger As Object = ""
    Property tblSnd_EndempfaengerKdNr As Object = ""
    Property tblSnd_EUFiskalEmpfaenger As Object = ""
    Property tblSnd_EUFiskalEmpfaengerKdNr As Object = ""
    Property tblSnd_BARzuKassieren As Object = Nothing

    Property tblSnd_KdAuftragsNrAvisierer As Object = Nothing
    Property tblSnd_KdAuftragsNrEmpfaenger As Object = Nothing
    Property tblSnd_KdAuftragsNrFrachtfuehrer As Object = Nothing
    Property tblSnd_AnmerkungDispoliste As Object = Nothing
    Property tblSnd_ATANr As Object = ""
    Property tblSnd_ATCMRN_Fremd As Object = ""
    Property tblSnd_Warenwert As Object = Nothing
    Property tblSnd_WarenwertWaehrung As Object = Nothing


    Property tblSnd_Status As Integer = 0
    Property tblSnd_Vorbereitet As Object = Nothing
    Property tblSnd_Vorgeschrieben As Object = Nothing

    Property LetzterMitarbeiter As Object = Nothing
    Property LetzterMitarbeiterId As Object = Nothing
    Property tblSnd_VG_MA As Object = Nothing
    Property tblSnd_NCTSaufDISPO As Boolean = True

    Property tblSnd_AvisiererKdNr As Object = Nothing
    Property tblSnd_Avisierer As Object = Nothing
    Property tblSnd_FrachtfuehrerKdNr As Object = Nothing
    Property tblSnd_Frachtfuehrer As Object = Nothing
    Property tblSnd_DakosyRef As Object = Nothing
    Property tblSnd_TeamId As Object = Nothing
    Property tblSnd_Fakturiert As Object = Nothing
    Property VORSYSTEM As Object = Nothing
    Property VORSYSTEM_Id As Object = Nothing
    Property tblSnd_FilialeAbklaerung As Object = Nothing

    Property tblSnd_AbklaerungTR As Object = Nothing
    Property tblSnd_AbklaerungTR_MA As Object = Nothing

    Property tblSnd_ATB_Nr As Object = Nothing
    Property tblSnd_ATB_T1 As Object = Nothing
    Property tblSnd_T1_Frist As Object = Nothing

    Property tblSnd_Vorpapier As Object = Nothing
    Property tblSnd_Vorpapier_Pos As Object = Nothing
    Property tblSnd_Vorpapier2 As Object = Nothing
    Property tblSnd_Vorpapier2_Pos As Object = Nothing
    Property tblSnd_Vorpapier3 As Object = Nothing
    Property tblSnd_Vorpapier3_Pos As Object = Nothing
    Property tblSnd_Frachtkosten As Object = Nothing
    Property tblSnd_FrachtkostenNichtEU As Object = Nothing
    Property tblSnd_FrachtkostenGesamt As Object = Nothing


    Property tblSnd_AbfertigungTR As Object = Nothing
    Property tblSnd_AbfertigungTR_MA As Object = Nothing


    Property tblSnd_AbfertigungTRAnzahl As Object = Nothing
    Property tblSnd_AbfertigungTRAnzahlPos As Object = Nothing

    Property tblSnd_Firma As Object = Nothing
    Property tblSnd_Cluster As Object = Nothing
    Property tblSnd_ATBFakturieren As Object = Nothing


    Public saveSachbearbeiter As Boolean = False

    Property ABRECHNUNG As New List(Of cSendungAbrechnung)
    Property HANDLING As New List(Of cSendHandling)
    Property VORKOSTEN As New List(Of cSendVorkosten)

    'Dim cDatenbank As New cDatenbank

    Public Function Clone() As Object Implements ICloneable.Clone
        Return DirectCast(MemberwiseClone(), cSendungen)
    End Function


    Public Function CLEAR_ABRECHNUNG_NotLeistungen() As Boolean

        ABRECHNUNG.RemoveAll(Function(x) x.sndabr_abrArt = "ZOLL")
        ABRECHNUNG.RemoveAll(Function(x) x.sndabr_abrArt = "EUST")
        ABRECHNUNG.RemoveAll(Function(x) x.sndabr_abrArt = "CLEARING")
        ABRECHNUNG.RemoveAll(Function(x) x.sndabr_abrArt = "ABFKOST")

        Return True

    End Function


    Dim SQL As New SQL

    Shared Function VP_Enum(ByVal SENDUNG_LIST As List(Of cSendungen)) As List(Of String)
        Dim list = New List(Of String)
        'If SENDUNG_LIST IsNot Nothing Then
        '    For Each s In SENDUNG_LIST
        '        If If(s.tblSnd_Vorpapier, "") <> "" Then
        '            Dim found = False
        '            For Each l In list
        '                If l = s.tblSnd_Vorpapier Then found = True
        '            Next
        '            If found = False Then list.Add(s.tblSnd_Vorpapier)
        '        End If
        '    Next
        'End If

        If SENDUNG_LIST IsNot Nothing Then
            For Each s In SENDUNG_LIST
                If If(s.tblSnd_Vorpapier, "") <> "" Then
                    Dim found = False
                    For Each li In list
                        If li = s.tblSnd_Vorpapier Then found = True
                    Next
                    If found = False Then list.Add(s.tblSnd_Vorpapier)
                End If
                If If(s.tblSnd_Vorpapier2, "") <> "" Then
                    Dim found = False
                    For Each li In list
                        If li = s.tblSnd_Vorpapier2 Then found = True
                    Next
                    If found = False Then list.Add(s.tblSnd_Vorpapier2)
                End If
                If If(s.tblSnd_Vorpapier3, "") <> "" Then
                    Dim found = False
                    For Each li In list
                        If li = s.tblSnd_Vorpapier3 Then found = True
                    Next
                    If found = False Then list.Add(s.tblSnd_Vorpapier3)
                End If
            Next
        End If

        Return list
    End Function

    Shared Sub LOAD_LIST(ByRef SENDUNG_LIST As List(Of cSendungen), ByRef CURRENT_INDEX As Integer, AvisoId As Integer, Optional allowchangeCurrIndex As Boolean = True)
        If SENDUNG_LIST Is Nothing Then SENDUNG_LIST = New List(Of cSendungen)
        SENDUNG_LIST.Clear()
        Dim SQL As New SQL
        For Each r In SQL.loadDgvBySql("SELECT tblSnd_SendungID FROM tblSendungen WHERE tblSnd_AvisoID=" & AvisoId & " ORDER BY tblSnd_PosUnterNr,tblSnd_SendungID", "AVISO").Rows
            SENDUNG_LIST.Add(New VERAG_PROG_ALLGEMEIN.cSendungen(r("tblSnd_SendungID")))
        Next
        If allowchangeCurrIndex Then CURRENT_INDEX = IIf(SENDUNG_LIST.Count > 0, 0, -1)
    End Sub
    Shared Sub LOAD_LIST_VP(ByRef SENDUNG_LIST As List(Of cSendungen), ByRef CURRENT_INDEX As Integer, AvisoId As Integer, Vorpapier As String, Optional allowchangeCurrIndex As Boolean = True)
        If SENDUNG_LIST Is Nothing Then SENDUNG_LIST = New List(Of cSendungen)
        SENDUNG_LIST.Clear()
        Dim SQL As New SQL
        For Each r In SQL.loadDgvBySql("SELECT tblSnd_SendungID FROM tblSendungen WHERE tblSnd_AvisoID=" & AvisoId & " AND (tblSnd_Vorpapier='" & Vorpapier & "' OR tblSnd_Vorpapier2='" & Vorpapier & "'  OR tblSnd_Vorpapier3='" & Vorpapier & "' ) AND tblSnd_Abfertigungsart_ID not in(44) ORDER BY tblSnd_PosUnterNr,tblSnd_SendungID", "AVISO").Rows
            SENDUNG_LIST.Add(New VERAG_PROG_ALLGEMEIN.cSendungen(r("tblSnd_SendungID")))
        Next
        If allowchangeCurrIndex Then CURRENT_INDEX = IIf(SENDUNG_LIST.Count > 0, 0, -1)
    End Sub

    Shared Sub LOAD_LIST_VP_EMPTY(ByRef SENDUNG_LIST As List(Of cSendungen), ByRef CURRENT_INDEX As Integer, AvisoId As Integer, Optional allowchangeCurrIndex As Boolean = True)
        If SENDUNG_LIST Is Nothing Then SENDUNG_LIST = New List(Of cSendungen)
        SENDUNG_LIST.Clear()
        Dim SQL As New SQL
        For Each r In SQL.loadDgvBySql("SELECT tblSnd_SendungID FROM tblSendungen WHERE tblSnd_AvisoID=" & AvisoId & " AND (isnull(tblSnd_Vorpapier,'')='' AND isnull(tblSnd_Vorpapier2,'')=''  AND isnull(tblSnd_Vorpapier3,'')='' ) AND tblSnd_Abfertigungsart_ID not in(44)  ORDER BY tblSnd_PosUnterNr,tblSnd_SendungID", "AVISO").Rows
            SENDUNG_LIST.Add(New VERAG_PROG_ALLGEMEIN.cSendungen(r("tblSnd_SendungID")))
        Next
        If allowchangeCurrIndex Then CURRENT_INDEX = IIf(SENDUNG_LIST.Count > 0, 0, -1)
    End Sub

    Public Sub New(tblSnd_AvisoID, currentHisId, Optional FilialenNr = Nothing, Optional AbfertigungsNr = Nothing, Optional UnterNr = Nothing, Optional tblSnd_anzahlHandling = Nothing, Optional tblSnd_anzahlHandlingPos = Nothing)
        Me.tblSnd_SendungID = -1
        Me.tblSnd_AvisoID = tblSnd_AvisoID
        Me.tblSnd_PosUnterNr = currentHisId
        '   row.Item("tblSnd_Empfaenger") = ""
        '  row.Item("tblSnd_Ansprechperson") = ""
        'row.Item("tblSnd_Auftraggeber") = ""
        'row.Item("tblSnd_Absender") = ""
        Me.tblSnd_Anmerkung = ""
        Me.tblSnd_Gewicht = ""
        Me.tblSnd_Colli = ""

        'row.Item("tblSnd_SpeditionsbuchEingetragen") = False
        Me.tblSnd_AngabeZolltarif = 2
        Me.tblSnd_inBearbeitung = False
        Me.tblSnd_aufschub = ""

        If VERAG_PROG_ALLGEMEIN.cAllgemein.ABTEILUNG = "QS" Then
            Me.tblSnd_QS_MA = VERAG_PROG_ALLGEMEIN.cAllgemein.USRID
        End If

        Me.LetzterMitarbeiter = VERAG_PROG_ALLGEMEIN.cAllgemein.USRNAME
        Me.LetzterMitarbeiterId = VERAG_PROG_ALLGEMEIN.cAllgemein.USRID

        If FilialenNr IsNot Nothing Then Me.FilialenNr = FilialenNr
        If AbfertigungsNr IsNot Nothing Then Me.AbfertigungsNr = AbfertigungsNr
        If UnterNr IsNot Nothing Then Me.UnterNr = UnterNr
        If tblSnd_anzahlHandling IsNot Nothing Then Me.tblSnd_anzahlHandling = tblSnd_anzahlHandling
        If tblSnd_anzahlHandlingPos IsNot Nothing Then Me.tblSnd_anzahlHandlingPos = tblSnd_anzahlHandlingPos
    End Sub


    Public Sub New(tblSnd_SendungID)
        LOAD(tblSnd_SendungID)
    End Sub



    Public Function SAVE(Optional saveStatus = True) As Boolean 'obj As Object, tablename As String, where As String) As Boolean
        Dim list As List(Of VERAG_PROG_ALLGEMEIN.SQLVariable) = getParameterList(saveStatus)
        'WITH(updlock,serializable) 

        tblSnd_Firma = VERAG_PROG_ALLGEMEIN.cAllgemein.getFirmaFromFiliale2(FilialenNr,, "")
        tblSnd_Cluster = VERAG_PROG_ALLGEMEIN.cAllgemein.getClusterFromFiliale(FilialenNr,, "")

        Dim sqlstr = " BEGIN TRAN IF EXISTS(SELECT * FROM [tblSendungen] WHERE tblSnd_SendungID=@tblSnd_SendungID) " &
                       " BEGIN " & getUpdateCmd(saveStatus) & " END " &
                       " Else " &
                       " BEGIN " & getInsertCmd() & " END " &
                       " commit tran "
        ' MsgBox(sqlstr)
        Dim id = SQL.doSQLVarListID(tblSnd_SendungID, sqlstr, "AVISO", , list)
        If id > 0 Then
            tblSnd_SendungID = id : Return True
        End If
        Return False
    End Function

    'WITH(updlock,serializable) 
    Public Function DELETE() As Boolean 'obj As Object, tablename As String, where As String) As Boolean
        Dim sqlstr = " DELETE FROM [tblSendungen] WHERE tblSnd_SendungID=" & Me.tblSnd_SendungID
        Return SQL.doSQL(sqlstr, "AVISO")
    End Function

    Public Function SET_VGMA() As Boolean 'obj As Object, tablename As String, where As String) As Boolean
        Dim sqlstr = " UPDATE [tblSendungen] SET tblSnd_VG_MA='" & VERAG_PROG_ALLGEMEIN.cAllgemein.USRID & "', LetzterMitarbeiterId='" & VERAG_PROG_ALLGEMEIN.cAllgemein.USRID & "', LetzterMitarbeiter='" & VERAG_PROG_ALLGEMEIN.cAllgemein.USRNAME & "' WHERE tblSnd_SendungID=" & Me.tblSnd_SendungID
        Return SQL.doSQL(sqlstr, "AVISO")

    End Function
    Public Shared Function LOADByFilialenNrAbfertigungsNr(FilialenNr As Integer, AbfertigungsNr As Integer) As cSendungen
        Dim sql As New VERAG_PROG_ALLGEMEIN.SQL
        Dim tblSnd_SendungID = sql.getValueTxtBySql("SELECT TOP 1 tblSnd_SendungID FROM tblSendungen WHERE FilialenNr='" & FilialenNr & "' AND AbfertigungsNr='" & AbfertigungsNr & "'", "AVISO")
        If tblSnd_SendungID <> "" Then
            Return New cSendungen(tblSnd_SendungID)
        Else
            Return Nothing
        End If
    End Function
    Public Shared Function getAvisoIdSendungsIdByFilialenNrAbfertigungsNr(FilialenNr As Integer, AbfertigungsNr As Integer, ByRef AvisoID As Integer, ByRef SendungID As Integer) As Boolean
        Dim sql As New VERAG_PROG_ALLGEMEIN.SQL
        Dim dt = sql.loadDgvBySql("SELECT TOP 1 tblSnd_AvisoID, tblSnd_SendungID FROM tblSendungen WHERE FilialenNr='" & FilialenNr & "' AND AbfertigungsNr='" & AbfertigungsNr & "'", "AVISO")

        If dt IsNot Nothing AndAlso dt.Rows.Count > 0 Then
            Dim AvisopIdTmp = dt.Rows(0)("tblSnd_AvisoID")
            Dim SendungIDTmp = dt.Rows(0)("tblSnd_SendungID")
            If AvisopIdTmp IsNot DBNull.Value AndAlso IsNumeric(AvisopIdTmp) Then
                AvisoID = CInt(AvisopIdTmp)
            End If
            If SendungIDTmp IsNot DBNull.Value AndAlso IsNumeric(SendungIDTmp) Then
                SendungID = CInt(SendungIDTmp)
            End If
            Return True
        Else
            Return False
        End If
    End Function

    Public Function getKdAtrNrByEORI(EORI As String) As String
        Dim KdNR = -1
        Dim KdAtrNr = Nothing

        If Me.tblSnd_AuftraggeberKdNr > 0 Then
            Dim KdNrTmp = Me.tblSnd_AuftraggeberKdNr
            Dim KD_tmp As New VERAG_PROG_ALLGEMEIN.cKunde(KdNrTmp)
            If KD_tmp IsNot Nothing And KD_tmp.hasEntry Then
                If If(KD_tmp.EORITIN, "") = EORI Then
                    KdAtrNr = Me.tblSnd_KdAuftragsNr
                End If
            End If
        End If

        If Me.tblSnd_EmpfaengerKdNr > 0 Then
            Dim KdNrTmp = Me.tblSnd_EmpfaengerKdNr
            Dim KD_tmp As New VERAG_PROG_ALLGEMEIN.cKunde(KdNrTmp)
            If KD_tmp IsNot Nothing And KD_tmp.hasEntry Then
                If If(KD_tmp.EORITIN, "") = EORI Then
                    KdAtrNr = Me.tblSnd_KdAuftragsNrEmpfaenger
                End If
            End If
        End If



        If If(KdAtrNr, "").Trim <> String.Empty Then
            Return KdAtrNr
        Else
            Return ""
        End If
    End Function

    Public Function getKdAtrNr(art As String) As String
        Try

            ' If SND Is Nothing Then Return ""
            Dim KdNR = -1
            Dim KdAtrNr = Nothing
            Select Case art
                Case "EMPFAENGER" : KdAtrNr = Me.tblSnd_KdAuftragsNrEmpfaenger : KdNR = Me.tblSnd_EmpfaengerKdNr
                Case "AUFTRAGGEBER" : KdAtrNr = Me.tblSnd_KdAuftragsNr : KdNR = Me.tblSnd_AuftraggeberKdNr
                Case "FRAECHTER" : KdAtrNr = Me.tblSnd_KdAuftragsNrFrachtfuehrer : KdNR = Me.tblSnd_FrachtfuehrerKdNr
                Case "AVISIERER" : KdAtrNr = Me.tblSnd_KdAuftragsNrAvisierer : KdNR = Me.tblSnd_AvisiererKdNr
            End Select

            If If(KdAtrNr, "").Trim <> String.Empty Then
                Return KdAtrNr
            Else
                If Me.tblSnd_EmpfaengerKdNr = KdNR And If(Me.tblSnd_KdAuftragsNrEmpfaenger, "").Trim <> String.Empty Then Return Me.tblSnd_KdAuftragsNrEmpfaenger
                If Me.tblSnd_AuftraggeberKdNr = KdNR And If(Me.tblSnd_KdAuftragsNr, "").Trim <> String.Empty Then Return Me.tblSnd_KdAuftragsNr
                If Me.tblSnd_FrachtfuehrerKdNr = KdNR And If(Me.tblSnd_KdAuftragsNrFrachtfuehrer, "").Trim <> String.Empty Then Return Me.tblSnd_KdAuftragsNrFrachtfuehrer
                If Me.tblSnd_AvisiererKdNr = KdNR And If(Me.tblSnd_KdAuftragsNrAvisierer, "").Trim <> String.Empty Then Return Me.tblSnd_KdAuftragsNrAvisierer
            End If

        Catch ex As Exception
            VERAG_PROG_ALLGEMEIN.cErrorHandler.ERR(ex.Message, ex.StackTrace & vbNewLine & " 'cSENDUNGEN ATRNR '", System.Reflection.MethodInfo.GetCurrentMethod.Name)

        End Try
        Return ""

    End Function
    Public Sub LOAD(tblSnd_SendungID As Integer)
        Try
            Dim conn As SqlConnection = SQL.GetNewOpenConnectionAVISO()
            Using cmd As New SqlCommand("SELECT * FROM tblSendungen WHERE tblSnd_SendungID=@tblSnd_SendungID ", conn)
                cmd.Parameters.AddWithValue("@tblSnd_SendungID", tblSnd_SendungID)
                Dim dr = cmd.ExecuteReader()
                If dr.Read Then
                    Me.tblSnd_SendungID = SQL.checkNullReturnValue(dr.Item("tblSnd_SendungID"), Nothing)
                    Me.tblSnd_PosUnterNr = SQL.checkNullReturnValue(dr.Item("tblSnd_PosUnterNr"), Nothing)
                    Me.tblSnd_AvisoID = SQL.checkNullReturnValue(dr.Item("tblSnd_AvisoID"), Nothing)
                    Me.tblSnd_Zollsystem_Land = SQL.checkNullReturnValue(dr.Item("tblSnd_Zollsystem_Land"), Nothing)
                    Me.tblSnd_Abfertigungsart_ID = SQL.checkNullReturnValue(dr.Item("tblSnd_Abfertigungsart_ID"), Nothing)
                    Me.tblSnd_EmpfaengerKdNr = SQL.checkNullReturnValue(dr.Item("tblSnd_EmpfaengerKdNr"), Nothing)
                    Me.tblSnd_Empfaenger = SQL.checkNullReturnValue(dr.Item("tblSnd_Empfaenger"), Nothing)
                    Me.tblSnd_Ansprechperson = SQL.checkNullReturnValue(dr.Item("tblSnd_Ansprechperson"), Nothing)
                    Me.tblSnd_Bonitaet = SQL.checkNullReturnValue(dr.Item("tblSnd_Bonitaet"), Nothing)
                    Me.tblSnd_Anmerkung = SQL.checkNullReturnValue(dr.Item("tblSnd_Anmerkung"), Nothing)
                    Me.tblSnd_AuftraggeberKdNr = SQL.checkNullReturnValue(dr.Item("tblSnd_AuftraggeberKdNr"), Nothing)
                    Me.tblSnd_Auftraggeber = SQL.checkNullReturnValue(dr.Item("tblSnd_Auftraggeber"), Nothing)
                    Me.tblSnd_SpeditionsbuchEingetragen = SQL.checkNullReturnValue(dr.Item("tblSnd_SpeditionsbuchEingetragen"), Nothing)
                    Me.FilialenNr = SQL.checkNullReturnValue(dr.Item("FilialenNr"), Nothing)
                    Me.AbfertigungsNr = SQL.checkNullReturnValue(dr.Item("AbfertigungsNr"), Nothing)
                    Me.UnterNr = SQL.checkNullReturnValue(dr.Item("UnterNr"), Nothing)
                    Me.tblSnd_Colli = SQL.checkNullReturnValue(dr.Item("tblSnd_Colli"), Nothing)
                    Me.tblSnd_Gewicht = SQL.checkNullReturnValue(dr.Item("tblSnd_Gewicht"), Nothing)
                    Me.tblSnd_Warenbezeichnung = SQL.checkNullReturnValue(dr.Item("tblSnd_Warenbezeichnung"), Nothing)
                    Me.tblSnd_SachbearbeiterId = SQL.checkNullReturnValue(dr.Item("tblSnd_SachbearbeiterId"), Nothing)
                    Me.tblSnd_AbsenderKdNr = SQL.checkNullReturnValue(dr.Item("tblSnd_AbsenderKdNr"), Nothing)
                    Me.tblSnd_Absender = SQL.checkNullReturnValue(dr.Item("tblSnd_Absender"), Nothing)
                    Me.tblSnd_AngabeZolltarif = SQL.checkNullReturnValue(dr.Item("tblSnd_AngabeZolltarif"), Nothing)
                    Me.tblSnd_inBearbeitung = SQL.checkNullReturnValue(dr.Item("tblSnd_inBearbeitung"), Nothing)
                    Me.tblSnd_Bearbeitung_MaId = SQL.checkNullReturnValue(dr.Item("tblSnd_Bearbeitung_MaId"), Nothing)
                    Me.tblSnd_aufschub = SQL.checkNullReturnValue(dr.Item("tblSnd_aufschub"), Nothing)
                    Me.tblSnd_anzahlHandling = SQL.checkNullReturnValue(dr.Item("tblSnd_anzahlHandling"), Nothing)
                    Me.tblSnd_anzahlHandlingPos = SQL.checkNullReturnValue(dr.Item("tblSnd_anzahlHandlingPos"), Nothing)
                    Me.tblSnd_anzahlPOS = SQL.checkNullReturnValue(dr.Item("tblSnd_anzahlPOS"), Nothing)
                    '  Me.tblSnd_bar = SQL.checkNullReturnValue(dr.Item("tblSnd_bar"), Nothing)
                    ' Me.tblSnd_barBeleg = SQL.checkNullReturnValue(dr.Item("tblSnd_barBeleg"), Nothing)
                    ' Me.tblSnd_betrag = SQL.checkNullReturnValue(dr.Item("tblSnd_betrag"), Nothing)
                    Me.tblSnd_Fremdspedition = SQL.checkNullReturnValue(dr.Item("tblSnd_Fremdspedition"), False)
                    Me.tblSnd_FremdspeditionText = SQL.checkNullReturnValue(dr.Item("tblSnd_FremdspeditionText"), "")
                    Me.tblSnd_QS_MA = SQL.checkNullReturnValue(dr.Item("tblSnd_QS_MA"), Nothing)
                    Me.tblSnd_KdAuftragsNr = SQL.checkNullReturnValue(dr.Item("tblSnd_KdAuftragsNr"), "")
                    Me.tblSnd_NCTSVerzollungsadresse = SQL.checkNullReturnValue(dr.Item("tblSnd_NCTSVerzollungsadresse"), "")
                    Me.tblSnd_NCTSVerzollungsadresseKdNr = SQL.checkNullReturnValue(dr.Item("tblSnd_NCTSVerzollungsadresseKdNr"), Nothing)


                    Me.NCTS_Verzollungsadresse_Strasse = SQL.checkNullReturnValue(dr.Item("NCTS_Verzollungsadresse_Strasse"), Nothing)
                    Me.NCTS_Verzollungsadresse_PLZ = SQL.checkNullReturnValue(dr.Item("NCTS_Verzollungsadresse_PLZ"), Nothing)
                    Me.NCTS_Verzollungsadresse_Ort = SQL.checkNullReturnValue(dr.Item("NCTS_Verzollungsadresse_Ort"), Nothing)
                    Me.NCTS_Verzollungsadresse_Land = SQL.checkNullReturnValue(dr.Item("NCTS_Verzollungsadresse_Land"), Nothing)
                    Me.NCTS_Verzollungsadresse_EORI = SQL.checkNullReturnValue(dr.Item("NCTS_Verzollungsadresse_EORI"), Nothing)
                    Me.NCTS_Verzollungsadresse_EORI_NL = SQL.checkNullReturnValue(dr.Item("NCTS_Verzollungsadresse_EORI_NL"), Nothing)
                    Me.NCTS_ngaId = SQL.checkNullReturnValue(dr.Item("NCTS_ngaId"), Nothing)

                    Me.NCTS_Bestimmungszollstelle = SQL.checkNullReturnValue(dr.Item("NCTS_Bestimmungszollstelle"), Nothing)

                    Me.tblSnd_Endempfaenger = SQL.checkNullReturnValue(dr.Item("tblSnd_Endempfaenger"), Nothing)
                    Me.tblSnd_EndempfaengerKdNr = SQL.checkNullReturnValue(dr.Item("tblSnd_EndempfaengerKdNr"), Nothing)
                    Me.tblSnd_EUFiskalEmpfaenger = SQL.checkNullReturnValue(dr.Item("tblSnd_EUFiskalEmpfaenger"), Nothing)
                    Me.tblSnd_EUFiskalEmpfaengerKdNr = SQL.checkNullReturnValue(dr.Item("tblSnd_EUFiskalEmpfaengerKdNr"), Nothing)
                    Me.tblSnd_BARzuKassieren = SQL.checkNullReturnValue(dr.Item("tblSnd_BARzuKassieren"), Nothing)


                    Me.tblSnd_KdAuftragsNrAvisierer = SQL.checkNullReturnValue(dr.Item("tblSnd_KdAuftragsNrAvisierer"), Nothing)
                    Me.tblSnd_KdAuftragsNrEmpfaenger = SQL.checkNullReturnValue(dr.Item("tblSnd_KdAuftragsNrEmpfaenger"), Nothing)
                    Me.tblSnd_KdAuftragsNrFrachtfuehrer = SQL.checkNullReturnValue(dr.Item("tblSnd_KdAuftragsNrFrachtfuehrer"), Nothing)
                    Me.tblSnd_AnmerkungDispoliste = SQL.checkNullReturnValue(dr.Item("tblSnd_AnmerkungDispoliste"), Nothing)
                    Me.tblSnd_ATANr = SQL.checkNullReturnValue(dr.Item("tblSnd_ATANr"), Nothing)
                    Me.tblSnd_ATCMRN_Fremd = SQL.checkNullReturnValue(dr.Item("tblSnd_ATCMRN_Fremd"), Nothing)
                    Me.tblSnd_Warenwert = SQL.checkNullReturnValue(dr.Item("tblSnd_Warenwert"), Nothing)
                    Me.tblSnd_WarenwertWaehrung = SQL.checkNullReturnValue(dr.Item("tblSnd_WarenwertWaehrung"), Nothing)

                    Me.tblSnd_Status = SQL.checkNullReturnValue(dr.Item("tblSnd_Status"), Nothing)
                    Me.tblSnd_Vorbereitet = SQL.checkNullReturnValue(dr.Item("tblSnd_Vorbereitet"), Nothing)
                    Me.tblSnd_Vorgeschrieben = SQL.checkNullReturnValue(dr.Item("tblSnd_Vorgeschrieben"), Nothing)

                    Me.LetzterMitarbeiter = SQL.checkNullReturnValue(dr.Item("LetzterMitarbeiter"), Nothing)
                    Me.LetzterMitarbeiterId = SQL.checkNullReturnValue(dr.Item("LetzterMitarbeiterId"), Nothing)
                    Me.tblSnd_VG_MA = SQL.checkNullReturnValue(dr.Item("tblSnd_VG_MA"), Nothing)
                    Me.tblSnd_NCTSaufDISPO = SQL.checkNullReturnValue(dr.Item("tblSnd_NCTSaufDISPO"), Nothing)

                    Me.tblSnd_AvisiererKdNr = SQL.checkNullReturnValue(dr.Item("tblSnd_AvisiererKdNr"), Nothing)
                    Me.tblSnd_Avisierer = SQL.checkNullReturnValue(dr.Item("tblSnd_Avisierer"), Nothing)
                    Me.tblSnd_FrachtfuehrerKdNr = SQL.checkNullReturnValue(dr.Item("tblSnd_FrachtfuehrerKdNr"), Nothing)
                    Me.tblSnd_Frachtfuehrer = SQL.checkNullReturnValue(dr.Item("tblSnd_Frachtfuehrer"), Nothing)
                    Me.tblSnd_DakosyRef = SQL.checkNullReturnValue(dr.Item("tblSnd_DakosyRef"), Nothing)
                    Me.tblSnd_TeamId = SQL.checkNullReturnValue(dr.Item("tblSnd_TeamId"), Nothing)
                    Me.tblSnd_Fakturiert = SQL.checkNullReturnValue(dr.Item("tblSnd_Fakturiert"), Nothing)
                    Me.tblSnd_FilialeAbklaerung = SQL.checkNullReturnValue(dr.Item("tblSnd_FilialeAbklaerung"), Nothing)
                    Me.VORSYSTEM = SQL.checkNullReturnValue(dr.Item("VORSYSTEM"), Nothing)
                    Me.VORSYSTEM_Id = SQL.checkNullReturnValue(dr.Item("VORSYSTEM_Id"), Nothing)
                    Me.tblSnd_AbklaerungTR = SQL.checkNullReturnValue(dr.Item("tblSnd_AbklaerungTR"), Nothing)
                    Me.tblSnd_AbklaerungTR_MA = SQL.checkNullReturnValue(dr.Item("tblSnd_AbklaerungTR_MA"), Nothing)
                    Me.tblSnd_ATB_Nr = SQL.checkNullReturnValue(dr.Item("tblSnd_ATB_Nr"), Nothing)
                    Me.tblSnd_ATB_T1 = SQL.checkNullReturnValue(dr.Item("tblSnd_ATB_T1"), Nothing)
                    Me.tblSnd_Vorpapier = SQL.checkNullReturnValue(dr.Item("tblSnd_Vorpapier"), Nothing)
                    Me.tblSnd_Vorpapier_Pos = SQL.checkNullReturnValue(dr.Item("tblSnd_Vorpapier_Pos"), Nothing)
                    Me.tblSnd_Vorpapier2 = SQL.checkNullReturnValue(dr.Item("tblSnd_Vorpapier2"), Nothing)
                    Me.tblSnd_Vorpapier2_Pos = SQL.checkNullReturnValue(dr.Item("tblSnd_Vorpapier2_Pos"), Nothing)
                    Me.tblSnd_Vorpapier3 = SQL.checkNullReturnValue(dr.Item("tblSnd_Vorpapier3"), Nothing)
                    Me.tblSnd_Vorpapier3_Pos = SQL.checkNullReturnValue(dr.Item("tblSnd_Vorpapier3_Pos"), Nothing)
                    Me.tblSnd_Frachtkosten = SQL.checkNullReturnValue(dr.Item("tblSnd_Frachtkosten"), Nothing)
                    Me.tblSnd_FrachtkostenNichtEU = SQL.checkNullReturnValue(dr.Item("tblSnd_FrachtkostenNichtEU"), Nothing)
                    Me.tblSnd_FrachtkostenGesamt = SQL.checkNullReturnValue(dr.Item("tblSnd_FrachtkostenGesamt"), Nothing)
                    Me.tblSnd_AbfertigungTR = SQL.checkNullReturnValue(dr.Item("tblSnd_AbfertigungTR"), Nothing)
                    Me.tblSnd_AbfertigungTR_MA = SQL.checkNullReturnValue(dr.Item("tblSnd_AbfertigungTR_MA"), Nothing)
                    Me.tblSnd_AbfertigungTRAnzahl = SQL.checkNullIntegerZero(dr.Item("tblSnd_AbfertigungTRAnzahl"))
                    Me.tblSnd_AbfertigungTRAnzahlPos = SQL.checkNullIntegerZero(dr.Item("tblSnd_AbfertigungTRAnzahlPos"))
                    Me.tblSnd_Firma = SQL.checkNullReturnValue(dr.Item("tblSnd_Firma"), Nothing)
                    Me.tblSnd_Cluster = SQL.checkNullReturnValue(dr.Item("tblSnd_Cluster"), Nothing)
                    Me.tblSnd_ATBFakturieren = SQL.checkNullReturnValue(dr.Item("tblSnd_ATBFakturieren"), Nothing)
                    Me.tblSnd_T1_Frist = SQL.checkNullReturnValue(dr.Item("tblSnd_T1_Frist"), Nothing)

                End If

                dr.Close()

                ' End Using
                conn.Close()
            End Using
            'Return Nothing
        Catch ex As Exception
            VERAG_PROG_ALLGEMEIN.cErrorHandler.ERR(ex.Message, ex.StackTrace & vbNewLine & " 'cSENDUNGEN'", System.Reflection.MethodInfo.GetCurrentMethod.Name)
            '      MsgBox("Fehler in der Funktion '" & System.Reflection.MethodInfo.GetCurrentMethod.Name & "'" & vbNewLine & vbNewLine & ex.Message & vbNewLine & vbNewLine & ex.StackTrace)
        End Try
        '  Return Nothing
    End Sub

    Public Sub LOAD_ABRECHNUNG()
        Try
            Me.ABRECHNUNG.Clear()
            Dim conn As SqlConnection = SQL.GetNewOpenConnectionAVISO()
            Using cmd2 As New SqlCommand("SELECT * FROM tblSendAbrechnung WHERE sndabr_sendId=@sndabr_sendId and  sndabr_sendId>0", conn)
                cmd2.Parameters.AddWithValue("@sndabr_sendId", Me.tblSnd_SendungID)
                Dim dr2 = cmd2.ExecuteReader()

                While dr2.Read
                    Dim a As New cSendungAbrechnung(Me.tblSnd_SendungID)

                    a.sndabr_id = SQL.checkNullReturnValue(dr2.Item("sndabr_id"), Nothing)
                    'a.sndabr_sendId = SQL.checkNullReturnValue(dr2.Item("sndabr_sendId"), Nothing)
                    a.sndabr_beteiligter = SQL.checkNullReturnValue(dr2.Item("sndabr_beteiligter"), Nothing)
                    a.sndabr_abrArt = SQL.checkNullReturnValue(dr2.Item("sndabr_abrArt"), Nothing)
                    a.sndabr_wert = SQL.checkNullReturnValue(dr2.Item("sndabr_wert"), Nothing)
                    a.sndabr_bezeichnung = SQL.checkNullReturnValue(dr2.Item("sndabr_bezeichnung"), Nothing)
                    a.sndabr_anzahl = SQL.checkNullReturnValue(dr2.Item("sndabr_anzahl"), Nothing)
                    a.sndabr_einzelPreis = SQL.checkNullReturnValue(dr2.Item("sndabr_einzelPreis"), Nothing)
                    a.sndabr_preis = SQL.checkNullReturnValue(dr2.Item("sndabr_preis"), Nothing)
                    a.sndabr_LeistungsNr = SQL.checkNullReturnValue(dr2.Item("sndabr_LeistungsNr"), Nothing)

                    Me.ABRECHNUNG.Add(a)
                End While
                dr2.Close()
            End Using

            conn.Close()
            'End Using
            'Return Nothing
        Catch ex As Exception
            VERAG_PROG_ALLGEMEIN.cErrorHandler.ERR(ex.Message, ex.StackTrace & vbNewLine & " 'cSENDUNGEN'", System.Reflection.MethodInfo.GetCurrentMethod.Name)
            '  MsgBox("Fehler in der Funktion '" & System.Reflection.MethodInfo.GetCurrentMethod.Name & "'" & vbNewLine & vbNewLine & ex.Message & vbNewLine & vbNewLine & ex.StackTrace)
        End Try
        '  Return Nothing
    End Sub

    Public Sub LOAD_HANDLING()
        Try
            Me.HANDLING.Clear()
            Dim conn As SqlConnection = SQL.GetNewOpenConnectionAVISO()
            Using cmd2 As New SqlCommand("SELECT * FROM tblSendhandling WHERE sndhdg_sendId=@sndhdg_sendId ", conn)
                cmd2.Parameters.AddWithValue("@sndhdg_sendId", Me.tblSnd_SendungID)
                Dim dr2 = cmd2.ExecuteReader()

                While dr2.Read
                    Dim a As New cSendHandling(Me.tblSnd_SendungID)

                    a.sndhdg_id = SQL.checkNullReturnValue(dr2.Item("sndhdg_id"), Nothing)
                    'a.sndhdg_sendId = SQL.checkNullReturnValue(dr2.Item("sndhdg_sendId"), Nothing)
                    a.sndhdg_abrArt = SQL.checkNullReturnValue(dr2.Item("sndhdg_abrArt"), Nothing)
                    a.sndhdg_nr = SQL.checkNullReturnValue(dr2.Item("sndhdg_nr"), Nothing)

                    a.sndhdg_colli = SQL.checkNullReturnValue(dr2.Item("sndhdg_colli"), 0)
                    a.sndhdg_gewicht = SQL.checkNullReturnValue(dr2.Item("sndhdg_gewicht"), 0)
                    Me.HANDLING.Add(a)
                End While
                dr2.Close()
            End Using

            conn.Close()
            'End Using
            'Return Nothing
        Catch ex As Exception
            VERAG_PROG_ALLGEMEIN.cErrorHandler.ERR(ex.Message, ex.StackTrace & vbNewLine & " 'cSENDUNGEN'", System.Reflection.MethodInfo.GetCurrentMethod.Name)
            '  MsgBox("Fehler in der Funktion '" & System.Reflection.MethodInfo.GetCurrentMethod.Name & "'" & vbNewLine & vbNewLine & ex.Message & vbNewLine & vbNewLine & ex.StackTrace)
        End Try
        '  Return Nothing
    End Sub

    Public Sub LOAD_VORKOSTEN()
        Try
            Me.VORKOSTEN.Clear()
            Dim conn As SqlConnection = SQL.GetNewOpenConnectionAVISO()
            Using cmd2 As New SqlCommand("SELECT * FROM tblSendVorkosten WHERE sndvk_sendId=@sndvk_sendId ", conn)
                cmd2.Parameters.AddWithValue("@sndvk_sendId", Me.tblSnd_SendungID)
                Dim dr2 = cmd2.ExecuteReader()

                While dr2.Read
                    Dim a As New cSendVorkosten()

                    a.sndvk_LeistungsNr = SQL.checkNullReturnValue(dr2.Item("sndvk_LeistungsNr"), Nothing)
                    a.sndvk_sendId = SQL.checkNullReturnValue(dr2.Item("sndvk_sendId"), Nothing)
                    a.sndvk_LeistungsBez = SQL.checkNullReturnValue(dr2.Item("sndvk_LeistungsBez"), Nothing)
                    a.sndvk_Firma = SQL.checkNullReturnValue(dr2.Item("sndvk_Firma"), Nothing)

                    a.sndvk_Preis = SQL.checkNullReturnValue(dr2.Item("sndvk_Preis"), 0)

                    Me.VORKOSTEN.Add(a)
                End While
                dr2.Close()
            End Using

            conn.Close()
            'End Using
            'Return Nothing
        Catch ex As Exception
            VERAG_PROG_ALLGEMEIN.cErrorHandler.ERR(ex.Message, ex.StackTrace & vbNewLine & " 'cSENDUNGEN'", System.Reflection.MethodInfo.GetCurrentMethod.Name)
            '  MsgBox("Fehler in der Funktion '" & System.Reflection.MethodInfo.GetCurrentMethod.Name & "'" & vbNewLine & vbNewLine & ex.Message & vbNewLine & vbNewLine & ex.StackTrace)
        End Try
        '  Return Nothing
    End Sub


    Function getParameterList(Optional saveStatus = True) As List(Of VERAG_PROG_ALLGEMEIN.SQLVariable)
        Dim list As New List(Of VERAG_PROG_ALLGEMEIN.SQLVariable)
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("tblSnd_SendungID", tblSnd_SendungID, , True)) 'UPDATE INSERT ISPRIMARY!
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("tblSnd_PosUnterNr", tblSnd_PosUnterNr))
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("tblSnd_AvisoID", tblSnd_AvisoID))
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("tblSnd_Zollsystem_Land", tblSnd_Zollsystem_Land))
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("tblSnd_Abfertigungsart_ID", tblSnd_Abfertigungsart_ID))
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("tblSnd_EmpfaengerKdNr", tblSnd_EmpfaengerKdNr))
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("tblSnd_Empfaenger", tblSnd_Empfaenger))
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("tblSnd_Ansprechperson", tblSnd_Ansprechperson))
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("tblSnd_Bonitaet", tblSnd_Bonitaet))
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("tblSnd_Anmerkung", tblSnd_Anmerkung))
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("tblSnd_AuftraggeberKdNr", tblSnd_AuftraggeberKdNr))
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("tblSnd_Auftraggeber", tblSnd_Auftraggeber))
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("tblSnd_SpeditionsbuchEingetragen", tblSnd_SpeditionsbuchEingetragen))
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("FilialenNr", FilialenNr))
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("AbfertigungsNr", AbfertigungsNr))
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("UnterNr", UnterNr))
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("tblSnd_Colli", tblSnd_Colli))
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("tblSnd_Gewicht", tblSnd_Gewicht))
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("tblSnd_Warenbezeichnung", tblSnd_Warenbezeichnung))
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("tblSnd_SachbearbeiterId", tblSnd_SachbearbeiterId))
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("tblSnd_AbsenderKdNr", tblSnd_AbsenderKdNr))
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("tblSnd_Absender", tblSnd_Absender))
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("tblSnd_AngabeZolltarif", tblSnd_AngabeZolltarif))
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("tblSnd_inBearbeitung", tblSnd_inBearbeitung))
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("tblSnd_Bearbeitung_MaId", tblSnd_Bearbeitung_MaId))
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("tblSnd_aufschub", tblSnd_aufschub))
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("tblSnd_anzahlHandling", tblSnd_anzahlHandling))
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("tblSnd_anzahlHandlingPos", tblSnd_anzahlHandlingPos))
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("tblSnd_anzahlPOS", tblSnd_anzahlPOS))

        ' list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("tblSnd_bar", tblSnd_bar))
        ' list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("tblSnd_barBeleg", tblSnd_barBeleg))
        ' list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("tblSnd_betrag", tblSnd_betrag))
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("tblSnd_Fremdspedition", tblSnd_Fremdspedition))
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("tblSnd_FremdspeditionText", tblSnd_FremdspeditionText))
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("tblSnd_KdAuftragsNr", tblSnd_KdAuftragsNr))
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("tblSnd_NCTSVerzollungsadresse", tblSnd_NCTSVerzollungsadresse))
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("tblSnd_NCTSVerzollungsadresseKdNr", tblSnd_NCTSVerzollungsadresseKdNr))

        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("NCTS_Verzollungsadresse_Strasse", NCTS_Verzollungsadresse_Strasse))
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("NCTS_Verzollungsadresse_PLZ", NCTS_Verzollungsadresse_PLZ))
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("NCTS_Verzollungsadresse_Ort", NCTS_Verzollungsadresse_Ort))
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("NCTS_Verzollungsadresse_Land", NCTS_Verzollungsadresse_Land))
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("NCTS_Verzollungsadresse_EORI", NCTS_Verzollungsadresse_EORI))
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("NCTS_Verzollungsadresse_EORI_NL", NCTS_Verzollungsadresse_EORI_NL))
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("NCTS_ngaId", NCTS_ngaId))

        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("NCTS_Verzollungsadresse_Ansprechpartner", NCTS_Verzollungsadresse_Ansprechpartner))
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("NCTS_Bestimmungszollstelle", NCTS_Bestimmungszollstelle))

        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("tblSnd_Endempfaenger", tblSnd_Endempfaenger))
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("tblSnd_EndempfaengerKdNr", tblSnd_EndempfaengerKdNr))
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("tblSnd_EUFiskalEmpfaenger", tblSnd_EUFiskalEmpfaenger))
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("tblSnd_EUFiskalEmpfaengerKdNr", tblSnd_EUFiskalEmpfaengerKdNr))
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("tblSnd_BARzuKassieren", tblSnd_BARzuKassieren))
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("tblSnd_KdAuftragsNrAvisierer", tblSnd_KdAuftragsNrAvisierer))
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("tblSnd_KdAuftragsNrEmpfaenger", tblSnd_KdAuftragsNrEmpfaenger))
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("tblSnd_KdAuftragsNrFrachtfuehrer", tblSnd_KdAuftragsNrFrachtfuehrer))
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("tblSnd_AnmerkungDispoliste", tblSnd_AnmerkungDispoliste))
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("tblSnd_ATANr", tblSnd_ATANr))
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("tblSnd_ATCMRN_Fremd", tblSnd_ATCMRN_Fremd))
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("tblSnd_Warenwert", tblSnd_Warenwert))
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("tblSnd_WarenwertWaehrung", tblSnd_WarenwertWaehrung))



        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("LetzterMitarbeiter", LetzterMitarbeiter,,, Not saveSachbearbeiter))
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("LetzterMitarbeiterId", LetzterMitarbeiterId,,, Not saveSachbearbeiter))

        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("tblSnd_NCTSaufDISPO", tblSnd_NCTSaufDISPO))

        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("tblSnd_AvisiererKdNr", tblSnd_AvisiererKdNr))
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("tblSnd_Avisierer", tblSnd_Avisierer))
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("tblSnd_FrachtfuehrerKdNr", tblSnd_FrachtfuehrerKdNr))
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("tblSnd_Frachtfuehrer", tblSnd_Frachtfuehrer))
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("tblSnd_DakosyRef", tblSnd_DakosyRef))
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("tblSnd_TeamId", tblSnd_TeamId))
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("tblSnd_Fakturiert", tblSnd_Fakturiert))
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("tblSnd_FilialeAbklaerung", tblSnd_FilialeAbklaerung))
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("VORSYSTEM", VORSYSTEM))
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("VORSYSTEM_Id", VORSYSTEM_Id))
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("tblSnd_ATB_Nr", tblSnd_ATB_Nr))
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("tblSnd_ATB_T1", tblSnd_ATB_T1))
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("tblSnd_Vorpapier", tblSnd_Vorpapier))
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("tblSnd_Vorpapier_Pos", tblSnd_Vorpapier_Pos))
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("tblSnd_Vorpapier2", tblSnd_Vorpapier2))
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("tblSnd_Vorpapier2_Pos", tblSnd_Vorpapier2_Pos))
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("tblSnd_Vorpapier3", tblSnd_Vorpapier3))
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("tblSnd_Vorpapier3_Pos", tblSnd_Vorpapier3_Pos))
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("tblSnd_Frachtkosten", tblSnd_Frachtkosten))
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("tblSnd_FrachtkostenNichtEU", tblSnd_FrachtkostenNichtEU))
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("tblSnd_FrachtkostenGesamt", tblSnd_FrachtkostenGesamt))

        'If saveStatus Then --> in getUpdateCmd
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("tblSnd_Status", tblSnd_Status,,, Not saveSachbearbeiter))
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("tblSnd_QS_MA", tblSnd_QS_MA,,, Not saveSachbearbeiter))
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("tblSnd_Vorbereitet", tblSnd_Vorbereitet,,, Not saveSachbearbeiter))
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("tblSnd_Vorgeschrieben", tblSnd_Vorgeschrieben,,, Not saveSachbearbeiter))
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("tblSnd_VG_MA", tblSnd_VG_MA,,, Not saveSachbearbeiter))
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("tblSnd_AbklaerungTR", tblSnd_AbklaerungTR))
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("tblSnd_AbklaerungTR_MA", tblSnd_AbklaerungTR_MA))
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("tblSnd_AbfertigungTR", tblSnd_AbfertigungTR))
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("tblSnd_AbfertigungTR_MA", tblSnd_AbfertigungTR_MA))
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("tblSnd_AbfertigungTRAnzahl", tblSnd_AbfertigungTRAnzahl))
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("tblSnd_AbfertigungTRAnzahlPos", tblSnd_AbfertigungTRAnzahlPos))
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("tblSnd_Firma", tblSnd_Firma))
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("tblSnd_Cluster", tblSnd_Cluster))
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("tblSnd_ATBFakturieren", tblSnd_ATBFakturieren))
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("tblSnd_T1_Frist", tblSnd_T1_Frist))

        'End If
        Return list
    End Function


    Public Function getUpdateCmd(Optional saveStatus = True) 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 And Not i.isonlyForLoad Then
                    Dim jump = False

                    If Not saveStatus Then
                        If i.Text = "tblSnd_Status" Then jump = True
                        If i.Text = "tblSnd_QS_MA" Then jump = True
                        If i.Text = "tblSnd_Vorbereitet" Then jump = True
                        If i.Text = "tblSnd_Vorgeschrieben" Then jump = True
                        If i.Text = "tblSnd_VG_MA" Then jump = True
                        If i.Text = "tblSnd_AbklaerungTR" Then jump = True
                        If i.Text = "tblSnd_AbklaerungTR_MA" Then jump = True
                        If i.Text = "tblSnd_AbfertigungTR" Then jump = True
                        If i.Text = "tblSnd_AbfertigungTR_MA" Then jump = True
                        If i.Text = "tblSnd_AbfertigungTRAnzahl" Then jump = True
                        If i.Text = "tblSnd_AbfertigungTRAnzahlPos" Then jump = True
                    End If


                    If Not jump Then str &= "[" & i.Text & "] = @" & i.Text.Replace("-", "").Replace(" ", "") & ","
                End If
            Next
            str = str.Substring(0, str.Length - 1) 'wg. ','
            Return (" UPDATE [tblSendungen] SET " & str & " WHERE tblSnd_SendungID=@tblSnd_SendungID ")

        Catch ex As Exception
            VERAG_PROG_ALLGEMEIN.cErrorHandler.ERR(ex.Message, ex.StackTrace & vbNewLine & " 'cSENDUNGEN'", System.Reflection.MethodInfo.GetCurrentMethod.Name)
            '  MsgBox("Fehler in der Funktion '" & System.Reflection.MethodInfo.GetCurrentMethod.Name & "'" & vbNewLine & vbNewLine & ex.Message & vbNewLine & vbNewLine & ex.StackTrace)
        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 And Not i.isonlyForLoad Then
                    str &= "[" & i.Text & "],"
                    values &= "@" & i.Text.Replace("-", "").Replace(" ", "") & ","
                End If
            Next
            str = str.Substring(0, str.Length - 1) 'wg. ','
            values = values.Substring(0, values.Length - 1) 'wg. ','
            Return (" INSERT INTO tblSendungen  (" & str & ") VALUES(" & values & ")  ")
        Catch ex As Exception
            VERAG_PROG_ALLGEMEIN.cErrorHandler.ERR(ex.Message, ex.StackTrace & vbNewLine & " 'cSENDUNGEN'", System.Reflection.MethodInfo.GetCurrentMethod.Name)
            'MsgBox("Fehler in der Funktion '" & System.Reflection.MethodInfo.GetCurrentMethod.Name & "'" & vbNewLine & vbNewLine & ex.Message & vbNewLine & vbNewLine & ex.StackTrace)
        End Try
        Return ""
    End Function

    Public Function SAVE_Abrechnung() As Boolean 'obj As Object, tablename As String, where As String) As Boolean
        '   Dim list As List(Of VERAG_PROG_ALLGEMEIN.SQLVariable) = getParameterList()
        SAVE_Abrechnung = False
        Dim sqlstr = " DELETE FROM tblSendAbrechnung WHERE sndabr_sendId=" & Me.tblSnd_SendungID
        If SQL.doSQL(sqlstr, "AVISO") Then
            SAVE_Abrechnung = True
            For Each aa In ABRECHNUNG
                If Not aa.INSERT() Then SAVE_Abrechnung = False
            Next
        End If

        '   Return b
    End Function


    Public Function SAVE_HANDLING() As Boolean 'obj As Object, tablename As String, where As String) As Boolean
        '   Dim list As List(Of VERAG_PROG_ALLGEMEIN.SQLVariable) = getParameterList()
        SAVE_HANDLING = False
        Dim sqlstr = " DELETE FROM tblSendHandling WHERE sndhdg_sendId=" & Me.tblSnd_SendungID
        '   MsgBox(sqlstr)
        If SQL.doSQL(sqlstr, "AVISO") Then
            SAVE_HANDLING = True
            For Each aa In HANDLING
                If Not aa.INSERT() Then SAVE_HANDLING = False
            Next
        End If

        '   Return b
    End Function


    Public Function SAVE_VORKOSTEN() As Boolean 'obj As Object, tablename As String, where As String) As Boolean
        '   Dim list As List(Of VERAG_PROG_ALLGEMEIN.SQLVariable) = getParameterList()
        SAVE_VORKOSTEN = False
        Dim sqlstr = " DELETE FROM tblSendVorkosten WHERE sndvk_sendId=" & Me.tblSnd_SendungID
        '   MsgBox(sqlstr)
        If SQL.doSQL(sqlstr, "AVISO") Then
            SAVE_VORKOSTEN = True
            For Each aa In VORKOSTEN
                aa.sndvk_sendId = Me.tblSnd_SendungID
                If Not aa.INSERT() Then SAVE_VORKOSTEN = False
            Next
        End If

        '   Return b
    End Function


    Public Shared Function SET_SpedbuchEntry(tblSnd_SendungID As Integer, tblSnd_SpeditionsbuchEingetragen As Boolean) As String
        Try
            Dim SQL As New VERAG_PROG_ALLGEMEIN.SQL
            Return SQL.doSQL(" UPDATE [tblSendungen] SET tblSnd_SpeditionsbuchEingetragen=" & If(tblSnd_SpeditionsbuchEingetragen, 1, 0) & " WHERE tblSnd_SendungID=" & tblSnd_SendungID & " ", "AVISO")

        Catch ex As Exception
            VERAG_PROG_ALLGEMEIN.cErrorHandler.ERR(ex.Message, ex.StackTrace & vbNewLine & " 'cSENDUNGEN'", System.Reflection.MethodInfo.GetCurrentMethod.Name)
            '   MsgBox("Fehler in der Funktion '" & System.Reflection.MethodInfo.GetCurrentMethod.Name & "'" & vbNewLine & vbNewLine & ex.Message & vbNewLine & vbNewLine & ex.StackTrace)
        End Try
        Return ""
    End Function

    Public Function getNCTSAdress(Optional htmlOptimized As Boolean = False, Optional ansprechpartner As Boolean = True, Optional Bestimmungszollstelle As Boolean = True) As String
        Dim adresse = ""
        adresse &= If(Me.tblSnd_NCTSVerzollungsadresse, "") & vbNewLine
        adresse &= If(Me.NCTS_Verzollungsadresse_Strasse, "") & vbNewLine
        adresse &= If(Me.NCTS_Verzollungsadresse_Land, "") & " " & If(Me.NCTS_Verzollungsadresse_PLZ, "") & " " & If(Me.NCTS_Verzollungsadresse_Ort, "") & vbNewLine

        If ansprechpartner Then adresse &= If(Me.NCTS_Verzollungsadresse_Ansprechpartner, "") & vbNewLine

        If Bestimmungszollstelle And If(Me.NCTS_Bestimmungszollstelle, "") <> "" Then
            'adresse &= SQL.getValueTxtBySql("SELECT basncd_dstnr +' - ' + [basncd_name]  FROM basncd WHERE basncd_dstnr='" & Me.NCTS_Bestimmungszollstelle & "' ", "ATLAS")
            adresse &= SQL.getValueTxtBySql("SELECT Code +' - ' + [Description]  FROM tbl_DY_ZollDE_C0141_Zollstellen WHERE Code='" & Me.NCTS_Bestimmungszollstelle & "' AND  ((StartDate is null OR StartDate< GETDATE()) AND (EndDate is null OR EndDate> GETDATE()))  order by left(Code,2), Description ", "FMZOLL")
        End If

        If htmlOptimized Then adresse = adresse.Trim.Replace(vbNewLine, "<br/>")
        Return adresse.Trim
    End Function

    Public Function getNCTSATANr(Optional htmlOptimized As Boolean = False) As String
        Dim ataNr = ""
        ataNr &= If(Me.tblSnd_ATANr, "") & vbNewLine

        If htmlOptimized Then ataNr = ataNr.Trim.Replace(vbNewLine, "<br/>")
        Return ataNr.Trim
    End Function


    Public Function getEmpfaengerAdress(Optional htmlOptimized As Boolean = False, Optional ansprechpartner As Boolean = False) As String
        If tblSnd_EmpfaengerKdNr > 0 Then
            Dim AD As New cAdressen(tblSnd_EmpfaengerKdNr)
            Dim adresse = ""
            adresse &= If(AD.Name_1, "") & If(AD.Name_2, "") & vbNewLine
            If If(AD.Straße, "") <> "" Then adresse &= If(AD.Straße, "") & vbNewLine
            adresse &= If(AD.LandKz, "") & " " & If(AD.PLZ, "").ToString.ToUpper.Replace("OHNE", "") & " " & If(AD.Ort, "")

            If htmlOptimized Then adresse = adresse.Trim.Replace(vbNewLine, "<br/>")
            Return adresse.Trim
        Else
            Return tblSnd_Empfaenger
        End If

    End Function

End Class

Public Class cSendungAbrechnung
    Property sndabr_id As Integer = Nothing
    Property sndabr_sendId As Integer = Nothing
    Property sndabr_beteiligter As String = Nothing
    Property sndabr_abrArt As String = Nothing
    Property sndabr_wert As String = Nothing
    Property sndabr_bezeichnung As String = Nothing
    Property sndabr_anzahl As Integer = Nothing
    Property sndabr_einzelPreis As Object = Nothing
    Property sndabr_preis As Object = Nothing
    Property sndabr_LeistungsNr As Object = Nothing

    Dim SQL As New SQL

    Sub New(sndabr_sendId)
        Me.sndabr_sendId = sndabr_sendId
    End Sub

    Sub New(sndabr_sendId, sndabr_beteiligter, sndabr_abrArt, sndabr_wert)
        Me.sndabr_sendId = sndabr_sendId
        Me.sndabr_beteiligter = sndabr_beteiligter
        Me.sndabr_abrArt = sndabr_abrArt
        Me.sndabr_wert = sndabr_wert
    End Sub

    Sub New(sndabr_sendId, sndabr_beteiligter, sndabr_abrArt, sndabr_wert, sndabr_bezeichnung, sndabr_anzahl, sndabr_einzelPreis, sndabr_preis, sndabr_LeistungsNr)
        Me.sndabr_sendId = sndabr_sendId
        Me.sndabr_beteiligter = sndabr_beteiligter
        Me.sndabr_abrArt = sndabr_abrArt
        Me.sndabr_wert = sndabr_wert
        Me.sndabr_bezeichnung = sndabr_bezeichnung
        Me.sndabr_anzahl = sndabr_anzahl
        Me.sndabr_einzelPreis = sndabr_einzelPreis
        Me.sndabr_preis = sndabr_preis
        Me.sndabr_LeistungsNr = sndabr_LeistungsNr
    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("sndabr_id", sndabr_id, , True))
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("sndabr_sendId", sndabr_sendId))
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("sndabr_beteiligter", sndabr_beteiligter))
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("sndabr_abrArt", sndabr_abrArt))
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("sndabr_wert", sndabr_wert))
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("sndabr_bezeichnung", sndabr_bezeichnung))
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("sndabr_anzahl", sndabr_anzahl))
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("sndabr_einzelPreis", sndabr_einzelPreis))
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("sndabr_preis", sndabr_preis))
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("sndabr_LeistungsNr", sndabr_LeistungsNr))
        Return list
    End Function

    Public Function INSERT() As Boolean
        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.Text.Replace("-", "").Replace(" ", "") & ","
                End If
            Next
            str = str.Substring(0, str.Length - 1) 'wg. ','
            values = values.Substring(0, values.Length - 1) 'wg. ','
            Return SQL.doSQLVarList(" INSERT INTO [tblSendAbrechnung]  (" & str & ") VALUES(" & values & ")  ", "AVISO", , list)
        Catch ex As Exception
            VERAG_PROG_ALLGEMEIN.cErrorHandler.ERR(ex.Message, ex.StackTrace & vbNewLine & " 'cSENDUNGEN'", System.Reflection.MethodInfo.GetCurrentMethod.Name)
            '   MsgBox("Fehler in der Funktion '" & System.Reflection.MethodInfo.GetCurrentMethod.Name & "'" & vbNewLine & vbNewLine & ex.Message & vbNewLine & vbNewLine & ex.StackTrace)
        End Try
        Return False
    End Function



End Class


Public Class cSendHandling
    Property sndhdg_id As Integer = Nothing
    Property sndhdg_sendId As Integer = Nothing
    Property sndhdg_abrArt As String = Nothing
    Property sndhdg_nr As String = Nothing
    Property sndhdg_colli As Double = 0
    Property sndhdg_gewicht As Double = 0


    Dim SQL As New SQL

    Sub New(sndhdg_sendId)
        Me.sndhdg_sendId = sndhdg_sendId
    End Sub

    Sub New(sndhdg_sendId, sndabr_beteiligter, sndabr_abrArt, sndabr_wert, sndhdg_colli, sndhdg_gewicht)
        Me.sndhdg_sendId = sndhdg_sendId
        Me.sndhdg_abrArt = sndhdg_abrArt
        Me.sndhdg_nr = sndhdg_nr
        Me.sndhdg_colli = sndhdg_colli
        Me.sndhdg_gewicht = sndhdg_gewicht
    End Sub

    Sub New(sndhdg_sendId, sndhdg_abrArt, sndhdg_nr, sndhdg_colli, sndhdg_gewicht)
        Me.sndhdg_sendId = sndhdg_sendId
        Me.sndhdg_abrArt = sndhdg_abrArt
        Me.sndhdg_nr = sndhdg_nr
        Me.sndhdg_colli = sndhdg_colli
        Me.sndhdg_gewicht = sndhdg_gewicht
    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("sndhdg_id", sndhdg_id, , True))
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("sndhdg_sendId", sndhdg_sendId))
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("sndhdg_abrArt", sndhdg_abrArt))
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("sndhdg_nr", sndhdg_nr))
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("sndhdg_colli", sndhdg_colli))
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("sndhdg_gewicht", sndhdg_gewicht))
        Return list
    End Function

    Public Function INSERT() As Boolean
        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.Text.Replace("-", "").Replace(" ", "") & ","
                End If
            Next
            str = str.Substring(0, str.Length - 1) 'wg. ','
            values = values.Substring(0, values.Length - 1) 'wg. ','
            Return SQL.doSQLVarList(" INSERT INTO [tblSendHandling]  (" & str & ") VALUES(" & values & ")  ", "AVISO", , list)
        Catch ex As Exception
            VERAG_PROG_ALLGEMEIN.cErrorHandler.ERR(ex.Message, ex.StackTrace & vbNewLine & " 'cSENDUNGEN'", System.Reflection.MethodInfo.GetCurrentMethod.Name)
            '   MsgBox("Fehler in der Funktion '" & System.Reflection.MethodInfo.GetCurrentMethod.Name & "'" & vbNewLine & vbNewLine & ex.Message & vbNewLine & vbNewLine & ex.StackTrace)
        End Try
        Return False
    End Function


End Class