Public Class frmTCZollanmeldung

    Dim ART As String = ""
    Dim AVISO As VERAG_PROG_ALLGEMEIN.cAviso
    Dim SENDUNG As VERAG_PROG_ALLGEMEIN.cSendungen
    Dim FilialenNr As Integer
    Dim AbfertigungsNr As Integer
    Dim JAHR As Integer = Now.ToString("yy")

    Public isSTAMMREF As Boolean = False
    Public STAMMREF As String = ""
    Public CopyFromZA_Id As Integer = -1
    '  Dim NCTS As TELOTEC_Worker.cDakosyNCTSOut = Nothing
    '   Dim AES As TELOTEC_Worker.cDakosyAES = Nothing

    Dim FIRMA_DY = ""

    Dim DY As TELOTEC_Worker.cTelotec_Anmeldung = Nothing


    Sub New(ART As String, DY As TELOTEC_Worker.cTelotec_Anmeldung) ', JAHR As Integer) ', Optional ZA = Nothing)

        ' Dieser Aufruf ist für den Designer erforderlich.
        InitializeComponent()
        ' If DY Is Nothing Then DY = New TELOTEC_Worker.cDakosy_Zollanmeldungen

        Me.DY = DY
        If DY.telanm_AvisoId IsNot Nothing AndAlso DY.telanm_AvisoId > 0 Then
            Dim AV As New VERAG_PROG_ALLGEMEIN.cAvisoDAL
            Me.AVISO = AV.LesenAviso(DY.telanm_AvisoId, "")
        End If
        Me.ART = ART
        If DY.telanm_SendungsId IsNot Nothing AndAlso DY.telanm_SendungsId > 0 Then
            Me.SENDUNG = New VERAG_PROG_ALLGEMEIN.cSendungen(DY.telanm_SendungsId)
            Me.FilialenNr = SENDUNG.FilialenNr
            Me.AbfertigungsNr = SENDUNG.AbfertigungsNr
        End If
        Me.JAHR = JAHR

    End Sub

    Sub New(ART As String, DY As TELOTEC_Worker.cTelotec_Anmeldung, AVISO As VERAG_PROG_ALLGEMEIN.cAviso, SENDUNG As VERAG_PROG_ALLGEMEIN.cSendungen, JAHR As Integer) ', Optional ZA = Nothing)

        ' Dieser Aufruf ist für den Designer erforderlich.
        InitializeComponent()
        '  If DY Is Nothing Then DY = New TELOTEC_Worker.cDakosy_Zollanmeldungen

        Me.DY = DY
        Me.AVISO = AVISO
        Me.ART = ART
        Me.SENDUNG = SENDUNG
        Me.JAHR = JAHR

        If SENDUNG IsNot Nothing Then
            Me.FilialenNr = SENDUNG.FilialenNr
            Me.AbfertigungsNr = SENDUNG.AbfertigungsNr
        End If
        ' If ZA IsNot Nothing Then
        'Select Case ZA.GetType.ToString
        '     Case GetType(TELOTEC_Worker.cDakosyNCTSOut).ToString : NCTS = ZA
        '      Case GetType(TELOTEC_Worker.cDakosyAES).ToString : AES = ZA
        '  End Select
        '   End If


        ' Fügen Sie Initialisierungen nach dem InitializeComponent()-Aufruf hinzu.

    End Sub


    Private Sub frmZollanmeldung_Load(sender As Object, e As EventArgs) Handles Me.Load
        If VERAG_PROG_ALLGEMEIN.cBerechtignunen.CHECK_BERECHTIGUNG_bool("AVISO_IMEX", "AVISO") And FilialenNr = 5501 Then
            FIRMA_DY = "IMEX"
        Else
            If VERAG_PROG_ALLGEMEIN.cAllgemein.FIRMA = "FRONTOFFICE" Then

                If DY Is Nothing Then
                    '       '  FIRMA_DY = DY.
                    '   Else

                    Dim f As New frmDakosy_SelFirma
                    If f.ShowDialog(Me) = DialogResult.OK Then
                        FIRMA_DY = f.FIMRA_DY
                    Else
                        Me.Close()
                    End If
                End If
            End If
        End If

        Select Case ART
            'Case "T1", "T2", "NCTS", "ÜT"
            '    If Me.DY Is Nothing Then
            '        Dim usrcntl As New usrCntlATLAS_NCTS(ART, AVISO, SENDUNG, JAHR, , isSTAMMREF, STAMMREF, FIRMA_DY)
            '        usrcntl.Dock = DockStyle.Fill
            '        Me.pnl.Controls.Add(usrcntl)

            '    Else
            '        Dim usrcntl As New usrCntlATLAS_NCTS(DY, AVISO, SENDUNG, JAHR, , isSTAMMREF, STAMMREF)
            '        usrcntl.Dock = DockStyle.Fill
            '        Me.pnl.Controls.Add(usrcntl)

            '    End If

            'Case "AES", "EX", "EU", "CO"
            '    If Me.DY Is Nothing Then
            '        Dim usrcntl As New usrCntlATLAS_AES(ART, AVISO, SENDUNG, JAHR, , isSTAMMREF, STAMMREF)
            '        usrcntl.Dock = DockStyle.Fill
            '        Me.pnl.Controls.Add(usrcntl)
            '    Else
            '        Dim usrcntl As New usrCntlATLAS_AES(DY, AVISO, SENDUNG, JAHR, , isSTAMMREF, STAMMREF)
            '        usrcntl.Dock = DockStyle.Fill
            '        Me.pnl.Controls.Add(usrcntl)

            '    End If

            Case "EZA", "VZA"

                If Me.DY Is Nothing Then
                    Dim usrcntl As New usrCntlTCeZOLL_EZA(ART, AVISO, SENDUNG, JAHR, , isSTAMMREF, STAMMREF, FIRMA_DY)
                    usrcntl.Dock = DockStyle.Fill
                    Me.pnl.Controls.Add(usrcntl)

                Else
                    Dim usrcntl As New usrCntlTCeZOLL_EZA(DY, AVISO, SENDUNG, JAHR, , isSTAMMREF, STAMMREF)
                    usrcntl.Dock = DockStyle.Fill
                    Me.pnl.Controls.Add(usrcntl)

                End If

        End Select
    End Sub



    Shared Sub setZollstelle(ByRef zst As String, AVISO As VERAG_PROG_ALLGEMEIN.cAviso)
        Try
            If AVISO Is Nothing Then Exit Sub
            If AVISO.Grenzstelle.Replace("???", "") = "" Then
                zst = AVISO.Zollstelle
            Else
                Select Case AVISO.Grenzstelle
                    Case "SUB" : zst = "DE007701"'Suben Autobahngrenze
                    Case "SBG" : zst = "DE007458" 'Bad Reichenhall-Autobahn
                    Case "WAI" : zst = "DE008904" 'Weiden-Waidhaus
                    Case "NEU" : zst = "DE007703" 'Passau
                        ' Case "SFD" : zst = Asd ....DAKOS DE -.-
                End Select
            End If
        Catch ex As Exception
            MsgBox(ex.Message & ex.StackTrace)
        End Try
    End Sub

End Class