Imports VERAG_PROG_ALLGEMEIN

Public Class usrCntlModaltrans_EXIM_Allg
    Property NCTS_ART = "T-"

    'Dim NCTS As DAKOSY_Worker.cDakosyNCTSOut = Nothing
    Dim NCTS_TR As VERAG_PROG_ALLGEMEIN.cOregonNCTs_DeclarationData = Nothing



    Sub New(NCTS_TR As VERAG_PROG_ALLGEMEIN.cOregonNCTs_DeclarationData)

        ' Dieser Aufruf ist für den Designer erforderlich.
        InitializeComponent()
        Me.NCTS_TR = NCTS_TR
        ' Fügen Sie Initialisierungen nach dem InitializeComponent()-Aufruf hinzu.

    End Sub


    Private Sub usrCntlModaltrans_NCTS_Load(sender As Object, e As EventArgs) Handles MyBase.Load


        sbRoute1.initSearchBox(Me.FindForm, " [Code] ,[Description] as Land,[Code]+' - ' +[Description] as display  FROM tbl_DY_ZollDE_C0008_LaenderFull", {"Code", "Description"}, " (StartDate is null OR StartDate< GETDATE()) AND (EndDate is null OR EndDate> GETDATE()) ", "Code", "Code", "display", "FMZOLL", , 400, 200)
        sbRoute2.initSearchBox(Me.FindForm, " [Code] ,[Description] as Land,[Code]+' - ' +[Description] as display  FROM tbl_DY_ZollDE_C0008_LaenderFull", {"Code", "Description"}, " (StartDate is null OR StartDate< GETDATE()) AND (EndDate is null OR EndDate> GETDATE()) ", "Code", "Code", "display", "FMZOLL", , 400, 200)
        sbRoute3.initSearchBox(Me.FindForm, " [Code] ,[Description] as Land,[Code]+' - ' +[Description] as display  FROM tbl_DY_ZollDE_C0008_LaenderFull", {"Code", "Description"}, " (StartDate is null OR StartDate< GETDATE()) AND (EndDate is null OR EndDate> GETDATE()) ", "Code", "Code", "display", "FMZOLL", , 400, 200)
        sbRoute4.initSearchBox(Me.FindForm, " [Code] ,[Description] as Land,[Code]+' - ' +[Description] as display  FROM tbl_DY_ZollDE_C0008_LaenderFull", {"Code", "Description"}, " (StartDate is null OR StartDate< GETDATE()) AND (EndDate is null OR EndDate> GETDATE()) ", "Code", "Code", "display", "FMZOLL", , 400, 200)
        sbRoute5.initSearchBox(Me.FindForm, " [Code] ,[Description] as Land,[Code]+' - ' +[Description] as display  FROM tbl_DY_ZollDE_C0008_LaenderFull", {"Code", "Description"}, " (StartDate is null OR StartDate< GETDATE()) AND (EndDate is null OR EndDate> GETDATE()) ", "Code", "Code", "display", "FMZOLL", , 400, 200)
        sbRoute6.initSearchBox(Me.FindForm, " [Code] ,[Description] as Land,[Code]+' - ' +[Description] as display  FROM tbl_DY_ZollDE_C0008_LaenderFull", {"Code", "Description"}, " (StartDate is null OR StartDate< GETDATE()) AND (EndDate is null OR EndDate> GETDATE()) ", "Code", "Code", "display", "FMZOLL", , 400, 200)
        sbRoute7.initSearchBox(Me.FindForm, " [Code] ,[Description] as Land,[Code]+' - ' +[Description] as display  FROM tbl_DY_ZollDE_C0008_LaenderFull", {"Code", "Description"}, " (StartDate is null OR StartDate< GETDATE()) AND (EndDate is null OR EndDate> GETDATE()) ", "Code", "Code", "display", "FMZOLL", , 400, 200)
        sbRoute8.initSearchBox(Me.FindForm, " [Code] ,[Description] as Land,[Code]+' - ' +[Description] as display  FROM tbl_DY_ZollDE_C0008_LaenderFull", {"Code", "Description"}, " (StartDate is null OR StartDate< GETDATE()) AND (EndDate is null OR EndDate> GETDATE()) ", "Code", "Code", "display", "FMZOLL", , 400, 200)
        sbRoute9.initSearchBox(Me.FindForm, " [Code] ,[Description] as Land,[Code]+' - ' +[Description] as display  FROM tbl_DY_ZollDE_C0008_LaenderFull", {"Code", "Description"}, " (StartDate is null OR StartDate< GETDATE()) AND (EndDate is null OR EndDate> GETDATE()) ", "Code", "Code", "display", "FMZOLL", , 400, 200)
        sbBestimmungsland.initSearchBox(Me.FindForm, " [Code] ,[Description] as Land,[Code]+' - ' +[Description] as display   FROM tbl_DY_ZollDE_C0008_LaenderFull", {"Code", "Description"}, " (StartDate is null OR StartDate< GETDATE()) AND (EndDate is null OR EndDate> GETDATE()) ", "Code", "Code", "display", "FMZOLL", , 400, 200)
        sbVersendungsLand.initSearchBox(Me.FindForm, " [Code] ,[Description] as Land,[Code]+' - ' +[Description] as display   FROM tbl_DY_ZollDE_C0008_LaenderFull", {"Code", "Description"}, " (StartDate is null OR StartDate< GETDATE()) AND (EndDate is null OR EndDate> GETDATE()) ", "Code", "Code", "display", "FMZOLL", , 400, 200)
        sbKennzeichenGrenzeLand.initSearchBox(Me.FindForm, " [Code] ,[Description] as Land FROM tbl_DY_ZollDE_C0008_LaenderFull", {"Code", "Description"}, " (StartDate is null OR StartDate< GETDATE()) AND (EndDate is null OR EndDate> GETDATE()) ", "Code", "Code", "Code", "FMZOLL", , 400, 200)
        sbKennzeichenAbgangLand.initSearchBox(Me.FindForm, " [Code] ,[Description] as Land FROM tbl_DY_ZollDE_C0008_LaenderFull", {"Code", "Description"}, " (StartDate is null OR StartDate< GETDATE()) AND (EndDate is null OR EndDate> GETDATE()) ", "Code", "Code", "Code", "FMZOLL", , 400, 200)



        cboVerkehrszweig.Items.Clear()
        cboVerkehrszweig.Items.Add(New VERAG_PROG_ALLGEMEIN.MyListItem("", ""))
        cboVerkehrszweig.Items.Add(New VERAG_PROG_ALLGEMEIN.MyListItem("1 - Seeverkehr", "1"))
        cboVerkehrszweig.Items.Add(New VERAG_PROG_ALLGEMEIN.MyListItem("2 - Eisenbahnverkehr", "2"))
        cboVerkehrszweig.Items.Add(New VERAG_PROG_ALLGEMEIN.MyListItem("3 - Straßenverkehr", "3"))
        cboVerkehrszweig.Items.Add(New VERAG_PROG_ALLGEMEIN.MyListItem("4 - Luftverkehr", "4"))
        cboVerkehrszweig.Items.Add(New VERAG_PROG_ALLGEMEIN.MyListItem("5 - Postsendungen", "5"))
        cboVerkehrszweig.Items.Add(New VERAG_PROG_ALLGEMEIN.MyListItem("7 - Feste Transporteinrichtungen", "7"))
        cboVerkehrszweig.Items.Add(New VERAG_PROG_ALLGEMEIN.MyListItem("8 - Binnenschifffahrt", "8"))
        cboVerkehrszweig.Items.Add(New VERAG_PROG_ALLGEMEIN.MyListItem("9 - Eigener Antrieb", "9"))
        cboVerkehrszweig.Items.Add(New VERAG_PROG_ALLGEMEIN.MyListItem("10 - Seeverkehr", "10"))
        cboVerkehrszweig.Items.Add(New VERAG_PROG_ALLGEMEIN.MyListItem("12 - Waggon auf Seeschiff", "12"))
        cboVerkehrszweig.Items.Add(New VERAG_PROG_ALLGEMEIN.MyListItem("16 - Straßenfahrzeug auf Seeschiff", "16"))
        cboVerkehrszweig.Items.Add(New VERAG_PROG_ALLGEMEIN.MyListItem("17 - Anhänger/Auflieger auf Seeschiff", "17"))
        cboVerkehrszweig.Items.Add(New VERAG_PROG_ALLGEMEIN.MyListItem("18 - Binnenschiff auf Seeschiff", "18"))
        cboVerkehrszweig.Items.Add(New VERAG_PROG_ALLGEMEIN.MyListItem("20 - Eisenbahnverkehr", "20"))
        cboVerkehrszweig.Items.Add(New VERAG_PROG_ALLGEMEIN.MyListItem("23 - Straßenfahrzeug auf Eisenbahn", "23"))
        cboVerkehrszweig.Items.Add(New VERAG_PROG_ALLGEMEIN.MyListItem("30 - Straßenverkehr", "30"))
        cboVerkehrszweig.Items.Add(New VERAG_PROG_ALLGEMEIN.MyListItem("40 - Luftverkehr", "40"))
        cboVerkehrszweig.Items.Add(New VERAG_PROG_ALLGEMEIN.MyListItem("50 - Postsendungen", "50"))
        cboVerkehrszweig.Items.Add(New VERAG_PROG_ALLGEMEIN.MyListItem("70 - Feste Transporteinrichtungen", "70"))
        cboVerkehrszweig.Items.Add(New VERAG_PROG_ALLGEMEIN.MyListItem("80 - Binnenschifffahrt", "80"))
        cboVerkehrszweig.Items.Add(New VERAG_PROG_ALLGEMEIN.MyListItem("90 - Eigener Antrieb", "90"))
        cboVerkehrszweig.changeItem("3")


        cboArtGrenzUeberschreitung.Items.Clear()
        cboArtGrenzUeberschreitung.Items.Add(New VERAG_PROG_ALLGEMEIN.MyListItem("", ""))
        cboArtGrenzUeberschreitung.Items.Add(New VERAG_PROG_ALLGEMEIN.MyListItem("10 - Seeschiff", "10"))
        cboArtGrenzUeberschreitung.Items.Add(New VERAG_PROG_ALLGEMEIN.MyListItem("20 - Waggon", "20"))
        cboArtGrenzUeberschreitung.Items.Add(New VERAG_PROG_ALLGEMEIN.MyListItem("31 - Pkw", "31"))
        cboArtGrenzUeberschreitung.Items.Add(New VERAG_PROG_ALLGEMEIN.MyListItem("32 - Pkw mit Anhänger", "32"))
        cboArtGrenzUeberschreitung.Items.Add(New VERAG_PROG_ALLGEMEIN.MyListItem("33 - Lkw", "33"))
        cboArtGrenzUeberschreitung.Items.Add(New VERAG_PROG_ALLGEMEIN.MyListItem("34 - Lkw mit Anhänger", "34"))
        cboArtGrenzUeberschreitung.Items.Add(New VERAG_PROG_ALLGEMEIN.MyListItem("35 - Zugmaschine mit Auflieger ", "35"))
        cboArtGrenzUeberschreitung.Items.Add(New VERAG_PROG_ALLGEMEIN.MyListItem("40 - Flugzeug", "40"))
        cboArtGrenzUeberschreitung.Items.Add(New VERAG_PROG_ALLGEMEIN.MyListItem("50 - Binnenschiff", "50"))
        cboArtGrenzUeberschreitung.Items.Add(New VERAG_PROG_ALLGEMEIN.MyListItem("60 - Eigener Antrieb", "60"))
        cboArtGrenzUeberschreitung.Items.Add(New VERAG_PROG_ALLGEMEIN.MyListItem("70 - Feste Transporteinrichtung", "70"))
        cboArtGrenzUeberschreitung.changeItem("35")


        cboBesondereUmstaende.Items.Clear()
        cboBesondereUmstaende.Items.Add(New VERAG_PROG_ALLGEMEIN.MyListItem("", ""))
        cboBesondereUmstaende.Items.Add(New VERAG_PROG_ALLGEMEIN.MyListItem("A - Post- und Express-Sendungen", "A"))
        cboBesondereUmstaende.Items.Add(New VERAG_PROG_ALLGEMEIN.MyListItem("C - Straßentransport", "C"))
        cboBesondereUmstaende.Items.Add(New VERAG_PROG_ALLGEMEIN.MyListItem("D - Bahntransport", "D"))
        cboBesondereUmstaende.Items.Add(New VERAG_PROG_ALLGEMEIN.MyListItem("E - Zugel. Wirtschaftsbeteiligte", "E"))
        cboBesondereUmstaende.changeItem("C")


        cboZahlungsweiseBefKosten.Items.Clear()
        cboZahlungsweiseBefKosten.Items.Add(New VERAG_PROG_ALLGEMEIN.MyListItem("", ""))
        cboZahlungsweiseBefKosten.Items.Add(New VERAG_PROG_ALLGEMEIN.MyListItem("A - Barzahlung", "A"))
        cboZahlungsweiseBefKosten.Items.Add(New VERAG_PROG_ALLGEMEIN.MyListItem("B - Kreditkartenzahlung", "B"))
        cboZahlungsweiseBefKosten.Items.Add(New VERAG_PROG_ALLGEMEIN.MyListItem("C - Zahlung mit Scheck", "C"))
        cboZahlungsweiseBefKosten.Items.Add(New VERAG_PROG_ALLGEMEIN.MyListItem("D - andere", "D"))
        cboZahlungsweiseBefKosten.Items.Add(New VERAG_PROG_ALLGEMEIN.MyListItem("H - Elektr.Geldtransfer", "H"))
        cboZahlungsweiseBefKosten.Items.Add(New VERAG_PROG_ALLGEMEIN.MyListItem("Y - Kontoinhaber = Beförderer", "Y"))
        cboZahlungsweiseBefKosten.Items.Add(New VERAG_PROG_ALLGEMEIN.MyListItem("Z - nicht vorausbezahlt", "Z"))
        cboZahlungsweiseBefKosten.changeItem("D")

        'btnAllgemein_Click(btnT2, New EventArgs)

        ' setValues(NCTS)
    End Sub





    Public Sub getValues(ByRef NCTS As VERAG_PROG_ALLGEMEIN.cOregonNCTs_DeclarationData)
        NCTS.declaration_type = cProgramFunctions.isLeerNothing(NCTS_ART)


        NCTS.export_country_id = cProgramFunctions.isLeerNothing(sbVersendungsLand._value)
        NCTS.import_country_id = cProgramFunctions.isLeerNothing(sbBestimmungsland._value)

        'NCTS.ncts_SumA_KennnummerSendung = cProgramFunctions.isLeerNothing(txtKennnummer.Text)


        ''  NCTS.ncts_BeladungsOrt = cProgramFunctions.isLeerNothing(txtBeladungsort.Text)
        'NCTS.ncts_SumA_Ladeort = cProgramFunctions.isLeerNothing(txtLadeort.Text)
        'NCTS.ncts_SumA_Entladeort = cProgramFunctions.isLeerNothing(txtEntladeort.Text)
        '' NCTS.ncts_Wiedergestellungsdatum = cProgramFunctions.isLeerNothing(txtWiedergestellungsdatum._value)

        'NCTS.ncts_Befoerderungsmittel_KennzeichenAbgang = cProgramFunctions.isLeerNothing(txtKennzeichenAbgang._value)
        'NCTS.ncts_Befoerderungsmittel_SttaszugehoerigkeitAbgangCode = cProgramFunctions.isLeerNothing(sbKennzeichenAbgangLand._value)
        'NCTS.ncts_Befoerderungsmittel_KennzeichenGrenzueberschreitend = cProgramFunctions.isLeerNothing(txtKennzeichenGrenze._value)
        'NCTS.ncts_Befoerderungsmittel_StaatszugehoerigkeitGrenzueberschreitendCode = cProgramFunctions.isLeerNothing(sbKennzeichenGrenzeLand._value)

        'NCTS.ncts_Befoerderungsmittel_ArtGrenzueberschreitung = cProgramFunctions.isLeerNothing(cboArtGrenzUeberschreitung._value)
        'NCTS.ncts_Befoerderungsmittel_VerkehrszweigGrenzueberschreitent = cProgramFunctions.isLeerNothing(cboVerkehrszweig._value)
        'NCTS.ncts_SumA_BesondereUmstaende = cProgramFunctions.isLeerNothing(cboBesondereUmstaende._value)
        'NCTS.ncts_SumA_BefoerderungskostenZahlungsweise = cProgramFunctions.isLeerNothing(cboZahlungsweiseBefKosten._value)


    End Sub


    Public Sub setValues(NCTS As cOregonNCTs_DeclarationData) 'As DAKOSY_Worker.cDakosyNCTSOut)
        If NCTS Is Nothing Then Exit Sub


        sbVersendungsLand.SET_VALUE(If(NCTS.export_country_id, ""))
        sbBestimmungsland.SET_VALUE(If(NCTS.import_country_id, ""))



        Select Case NCTS_ART
            Case "EXA" : initButton(btnEXA)
            Case "EXD" : initButton(btnEXD)
            Case "IMA" : initButton(btnIMA)
            Case "IMA" : initButton(btnIMD)
        End Select


    End Sub
    Private Sub btnAllgemein_Click(sender As Object, e As EventArgs) Handles btnEXA.Click, btnIMZ.Click, btnIMD.Click, btnIMA.Click, btnEXD.Click
        initButton(sender)
    End Sub

    Sub initButton(sender As Button)
        setBtn(btnEXA, False)
        setBtn(btnEXD, False)
        setBtn(btnIMA, False)
        setBtn(btnIMD, False)
        setBtn(btnIMZ, False)

        If sender Is btnEXA Then
            NCTS_ART = "EXA" : txtArtDetail.Text = "EXA - Export Full Declaration (Arrived)"
        ElseIf sender Is btnEXD Then
            NCTS_ART = "EXD" : txtArtDetail.Text = "EXD - Export Full Declaration (Pre-Loged)"
        ElseIf sender Is btnIMA Then
            NCTS_ART = "IMA" : txtArtDetail.Text = "IMA - Full/WRD Declaratoins (Arrived)"
        ElseIf sender Is btnIMD Then
            NCTS_ART = "IMD" : txtArtDetail.Text = "IMD - Full/WRD Declaration (Pre-Loged)"
        ElseIf sender Is btnIMD Then
            NCTS_ART = "IMZ" : txtArtDetail.Text = "IMZ-LCP(import or warehouse removal) supplementary declaration(SDI/SDW)"
        End If
        setBtn(sender, True)
    End Sub

    Sub setBtn(btn As Button, value As Boolean)
        If value Then
            btn.BackColor = Color.OrangeRed
            btn.ForeColor = Color.White
        Else
            btn.BackColor = Color.White
            btn.ForeColor = Color.Black
        End If

    End Sub

    Private Sub lklRoutenauswahl_LinkClicked(sender As Object, e As LinkLabelLinkClickedEventArgs) Handles lklRoutenauswahl.LinkClicked
        Dim frmRoutenauswahl As New frmRoutenauswahl
        If frmRoutenauswahl.ShowDialog(Me) = DialogResult.OK Then
            If frmRoutenauswahl.ROUTE.Count > 0 Then sbRoute1.SET_VALUE(frmRoutenauswahl.ROUTE(0)) Else sbRoute1.SET_VALUE("")
            If frmRoutenauswahl.ROUTE.Count > 1 Then sbRoute2.SET_VALUE(frmRoutenauswahl.ROUTE(1)) Else sbRoute2.SET_VALUE("")
            If frmRoutenauswahl.ROUTE.Count > 2 Then sbRoute3.SET_VALUE(frmRoutenauswahl.ROUTE(2)) Else sbRoute3.SET_VALUE("")
            If frmRoutenauswahl.ROUTE.Count > 3 Then sbRoute4.SET_VALUE(frmRoutenauswahl.ROUTE(3)) Else sbRoute4.SET_VALUE("")
            If frmRoutenauswahl.ROUTE.Count > 4 Then sbRoute5.SET_VALUE(frmRoutenauswahl.ROUTE(4)) Else sbRoute5.SET_VALUE("")
            If frmRoutenauswahl.ROUTE.Count > 5 Then sbRoute6.SET_VALUE(frmRoutenauswahl.ROUTE(5)) Else sbRoute6.SET_VALUE("")
            If frmRoutenauswahl.ROUTE.Count > 6 Then sbRoute7.SET_VALUE(frmRoutenauswahl.ROUTE(6)) Else sbRoute7.SET_VALUE("")
            If frmRoutenauswahl.ROUTE.Count > 7 Then sbRoute8.SET_VALUE(frmRoutenauswahl.ROUTE(7)) Else sbRoute8.SET_VALUE("")
            If frmRoutenauswahl.ROUTE.Count > 8 Then sbRoute9.SET_VALUE(frmRoutenauswahl.ROUTE(8)) Else sbRoute9.SET_VALUE("")


            If frmRoutenauswahl.BESTIMMUNGSLAND <> "" Then sbBestimmungsland.SET_VALUE(frmRoutenauswahl.BESTIMMUNGSLAND)
        End If
    End Sub



    Private Sub cbxSumASicherheit_CheckedChanged(sender As Object, e As EventArgs)

        If Not txtLadeort.Enabled Then txtLadeort.Text = ""
        If Not txtEntladeort.Enabled Then txtEntladeort.Text = ""
    End Sub

    Private Sub PictureBox2_Click(sender As Object, e As EventArgs) Handles PictureBox2.Click
        txtKennzeichenGrenze.Text = txtKennzeichenAbgang.Text
    End Sub

    Private Sub PictureBox1_Click(sender As Object, e As EventArgs) Handles PictureBox1.Click
        txtKennzeichenAbgang.Text = txtKennzeichenGrenze.Text

    End Sub


    Private Sub LinkLabel1_LinkClicked(sender As Object, e As LinkLabelLinkClickedEventArgs) Handles LinkLabel1.LinkClicked
        txtKennzeichenGrenze.Text = txtKennzeichenAbgang.Text
        sbKennzeichenGrenzeLand.SET_VALUE(sbKennzeichenAbgangLand._value)
    End Sub

    Private Sub Button1_Click_1(sender As Object, e As EventArgs) Handles Button1.Click
        Dim origin = ""
        Dim destination = ""

        'If sbAbgangZollstelle._value <> "" Then
        '    origin = sbAbgangZollstelle._value.Substring(0, 2) & " " & sbAbgangZollstelle.Text
        'Else Exit Sub
        'End If

        'If sbBestimmungZollstelle._value <> "" Then
        '    destination = sbBestimmungZollstelle._value.Substring(0, 2) & " " & sbBestimmungZollstelle.Text
        'Else Exit Sub
        'End If

        Dim duration = ""
        Dim distance = ""
        Dim distanceSek = ""
        VERAG_PROG_ALLGEMEIN.cGoogleAPI.GoogleDistance(origin, destination, duration, distance, cbxWegStrecke.Checked)

        'lblWegstreckeVonNach.Text = "von: " & origin & vbNewLine
        'lblWegstreckeVonNach.Text &= "nach: " & destination


        lblWegstrecke.Text = "Wegstrecke: " & distance
        lblWegZeit.Text = "Fahrzeit: " & duration


    End Sub
End Class
