Public Class usrCntlATLAS_ncts_SicherheitPos
    Property ncts_ART = "T-"
    Public Event CHANGED()
    Dim FIRMA_DY = VERAG_PROG_ALLGEMEIN.cAllgemein.FIRMA
    Sub New(FIRMA_DY)

        ' Dieser Aufruf ist für den Designer erforderlich.
        InitializeComponent()
        cboArtSicherheit.Items.Clear()
        For Each l In (New cDakosy_Sicherheitsarten).LIST
            cboArtSicherheit.Items.Add(New VERAG_PROG_ALLGEMEIN.MyListItem(l.Text, l.Value))
        Next
        Me.FIRMA_DY = FIRMA_DY
        ' Fügen Sie Initialisierungen nach dem InitializeComponent()-Aufruf hinzu.

    End Sub
    Private Sub usrCntlATLAS_ncts_Load(sender As Object, e As EventArgs) Handles Me.Load
        'MySearchBox1.initSearchBox(Me.FindForm, "AdressenNr, [Name 1] FROM Adressen", {"[Name 1]", "Ort", "PLZ"}, "", "[Name 1]", "AdressenNr", "AdressenNr")
        ' btnAllgemein_Click(btnBrgSonstige, New EventArgs)
        '    initbuttons("")

        '  cboArtSicherheit.Items.Clear()
        ' For Each l In (New cDakosy_Sicherheitsarten).LIST
        'cboArtSicherheit.Items.Add(New VERAG_PROG_ALLGEMEIN.MyListItem(l.Text, l.Value))
        ' Next

        Select Case FIRMA_DY
            Case "UNISPED"
                btnBrgUNISPED_AT.Visible = True
                btnBrgUNISPED_DE.Visible = True
                btnBrgVERAG_AT.Visible = False
                btnBrgVERAG_DE.Visible = False
        End Select
    End Sub



    Public Sub loadBrg(SA As DAKOSY_Worker.cDakosy_NCTSOut_Sicherheitsangaben)
        Exit Sub
        '  ncts_ART = "TOBB" : txtArtDetail.Text = "Sicherheit der Firma TOBB"
        setBtn(btnBrgVERAG_AT, False)
        setBtn(btnBrgVERAG_DE, False)
        setBtn(btnBrgUNISPED_DE, False)
        setBtn(btnBrgUNISPED_DE, False)
        setBtn(btnBrgTOBB, False)
        setBtn(btnBrgSGS, False)
        setBtn(btnMars, False)
        setBtn(btnEKOL, False)
        setBtn(btnBrgSonstige, False)

        Select Case If(SA.nctsSA_GRN, "")
            Case "05AT510000G000FP7" : setBtn(btnBrgVERAG_AT, True)
            Case "17DE0000000071678" : setBtn(btnBrgVERAG_DE, True)
            Case "05AT500000G000EU9" : setBtn(btnBrgUNISPED_AT, True)
            Case "17DE0000000071270" : setBtn(btnBrgUNISPED_DE, True)
            Case Else : setBtn(btnBrgSonstige, True)
        End Select


        cboArtSicherheit.changeItem(If(SA.nctsSA_ArtCode, "")) 'Gesamtbürgschaft
        txtGRN.Text = If(SA.nctsSA_GRN, "")
        txtEORI_TIN.Text = If(SA.nctsSA_TIN, "")
        txtZugriffscode.Text = If(SA.nctsSA_Zugriffcode, "")
        txtAbgabenbetrag._value = If(SA.nctsSA_AbgabenBetrag, "")
        txtBezeichnung._value = If(SA.nctsSA_BezeichnungBescheinigun, "")
        'txtEORI_TIN.Text = If(SA.nctsSA_TIN, "")

    End Sub


    Private Sub btnAllgemein_Click(sender As Object, e As EventArgs) Handles btnBrgVERAG_AT.Click, btnBrgVERAG_DE.Click, btnBrgTOBB.Click, btnBrgSGS.Click, btnMars.Click, btnEKOL.Click, btnBrgSonstige.Click, btnBrgUNISPED_AT.Click, btnBrgUNISPED_DE.Click

        initbuttons(sender)

    End Sub

    Sub initbuttons(sender) ', Optional resetControls = False)

        setBtn(btnBrgVERAG_AT, False)
        setBtn(btnBrgVERAG_DE, False)
        setBtn(btnBrgTOBB, False)
        setBtn(btnBrgSGS, False)
        setBtn(btnMars, False)
        setBtn(btnEKOL, False)
        setBtn(btnBrgSonstige, False)
        setBtn(btnBrgUNISPED_AT, False)
        setBtn(btnBrgUNISPED_DE, False)

        'If resetControls Then
        cboArtSicherheit.changeItem("")
        txtGRN.Text = ""
        txtEORI_TIN.Text = ""
        txtZugriffscode.Text = ""
        txtAbgabenbetrag._value = ""
        txtEORI_TIN.Text = ""
        ' End If


        If sender Is btnBrgVERAG_AT Then
            txtGRN.Text = "05AT510000G000FP7"
            txtEORI_TIN.Text = "ATEOS1000000199"
            txtZugriffscode.Text = "" '"0000"
            ncts_ART = "VERAG_AT" : txtArtDetail.Text = "Bürgschaft VERAG Spedition AG (Österreich)" & vbNewLine & "05AT510000G000FP7"
            cboArtSicherheit.changeItem("1") 'Gesamtbürgschaft
            setBtn(btnBrgVERAG_AT, True)
        ElseIf sender Is btnBrgVERAG_DE Then
            txtGRN.Text = "17DE0000000071678"
            txtEORI_TIN.Text = "DE4824105"
            txtZugriffscode.Text = "NCLJ"
            ncts_ART = "VERAG_DE" : txtArtDetail.Text = "Bürgschaft VERAG Spedition GmbH (Deutschland)" & vbNewLine & "17DE0000000071678"

            cboArtSicherheit.changeItem("0") 'Befreiung
            setBtn(btnBrgVERAG_DE, True)
        ElseIf sender Is btnBrgTOBB Then
            txtGRN.Text = "21TR0004000079552" '"12TR0004000004665" '"15TR0004000020917"
            txtEORI_TIN.Text = "ITTR0000000000152"
            txtZugriffscode.Text = "2023"
            ncts_ART = "TOBB" : txtArtDetail.Text = "Sicherheit der Firma TOBB"
            cboArtSicherheit.changeItem("1") 'Gesamtbürgschaft
            setBtn(btnBrgTOBB, True)
        ElseIf sender Is btnBrgSGS Then
            txtGRN.Text = "16DE0000000068410"
            txtEORI_TIN.Text = "DE3331326"
            txtZugriffscode.Text = "UEJZ"

            ncts_ART = "SGS" : txtArtDetail.Text = "Sicherheit der Firma SGS"
            cboArtSicherheit.changeItem("1") 'Gesamtbürgschaft
            setBtn(btnBrgSGS, True)
        ElseIf sender Is btnMars Then
            txtGRN.Text = "TR0004000020908"
            txtEORI_TIN.Text = "BGKTR6120538808Z8"
            txtZugriffscode.Text = "UEJZ"

            ncts_ART = "MARS" : txtArtDetail.Text = "Sicherheit der Firma MARS"
            cboArtSicherheit.changeItem("1") 'Gesamtbürgschaft
            setBtn(btnMars, True)
        ElseIf sender Is btnEKOL Then
            txtGRN.Text = "13TR0004000005094"
            txtEORI_TIN.Text = "BGKTR3300012602Z8"
            txtZugriffscode.Text = "2015"
            ncts_ART = "EKOL" : txtArtDetail.Text = "Sicherheit der Firma EKOL"
            cboArtSicherheit.changeItem("1") 'Gesamtbürgschaft
            setBtn(btnEKOL, True)

            ' ElseIf sender Is btnKOEKNAR Then
            '      txtGRN.Text = "15TR0004000017715"
            '    txtEORI_TIN.Text = "ATEOS1000066891"
            '    txtZugriffscode.Text = "4747"
            '  ncts_ART = "KOEKNAR" : txtArtDetail.Text = "Sicherheit der Firma KÖKNAR"
            '  cboArtSicherheit.changeItem("1") 'Gesamtbürgschaft
            ' setBtn(btnEKOL, True)


        ElseIf sender Is btnBrgUNISPED_AT Then
            txtGRN.Text = "05AT500000G000EU9"
            txtEORI_TIN.Text = "ATEOS1000000088"
            txtZugriffscode.Text = ""
            ncts_ART = "UNISPED_AT" : txtArtDetail.Text = "Bürgschaft Unisped Speditions GmbH (Österreich)" & vbNewLine & "05AT500000G000EU9"
            cboArtSicherheit.changeItem("1") 'Gesamtbürgschaft
            setBtn(btnEKOL, True)
        ElseIf sender Is btnBrgUNISPED_de Then
            txtGRN.Text = "17DE0000000071270"
            txtEORI_TIN.Text = "DE7467540"
            txtZugriffscode.Text = "HOWE"
            ncts_ART = "UNISPED_DE" : txtArtDetail.Text = "Bürgschaft Unisped Speditions GmbH (Deutschland)" & vbNewLine & "17DE0000000071270"
            cboArtSicherheit.changeItem("0") 'Gesamtbürgschaft
            setBtn(btnEKOL, True)
        Else
            ncts_ART = "Sonstige" : txtArtDetail.Text = "Sonstige Sicherheit"
            cboArtSicherheit.changeItem("") 'Gesamtbürgschaft
            setBtn(btnBrgSonstige, True)
        End If



    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 cboArtSicherheit_SelectedIndexChanged(sender As Object, e As EventArgs) Handles cboArtSicherheit.SelectedIndexChanged
        RaiseEvent CHANGED()
    End Sub





    Public Function getValues() As DAKOSY_Worker.cDakosy_NCTSOut_Sicherheitsangaben
        Dim SA = New DAKOSY_Worker.cDakosy_NCTSOut_Sicherheitsangaben
        SA.nctsSA_AbgabenBetrag = cProgramFunctions.isLeerNothing(txtAbgabenbetrag._value)
        SA.nctsSA_BezeichnungBescheinigun = cProgramFunctions.isLeerNothing(txtBezeichnung._value)
        SA.nctsSA_ArtCode = cProgramFunctions.isLeerNothing(cboArtSicherheit._value)
        SA.nctsSA_GRN = cProgramFunctions.isLeerNothing(txtGRN._value)
        SA.nctsSA_Zugriffcode = cProgramFunctions.isLeerNothing(txtZugriffscode._value)
        SA.nctsSA_TIN = cProgramFunctions.isLeerNothing(txtEORI_TIN._value)
        If SA.nctsSA_AbgabenBetrag Is Nothing Then SA.nctsSA_AbgabenBetrag = 0
        Return SA
    End Function


    Public Sub setValues(SA As DAKOSY_Worker.cDakosy_NCTSOut_Sicherheitsangaben)
        setBtn(btnBrgVERAG_AT, False)
        setBtn(btnBrgVERAG_DE, False)
        setBtn(btnBrgTOBB, False)
        setBtn(btnBrgSGS, False)
        setBtn(btnMars, False)
        setBtn(btnEKOL, False)
        setBtn(btnBrgSonstige, False)

        Select Case If(SA.nctsSA_GRN, "")
            Case "05AT510000G000FP7" : setBtn(btnBrgVERAG_AT, True)
            Case "17DE0000000071678" : setBtn(btnBrgVERAG_DE, True)
            Case Else : setBtn(btnBrgSonstige, True)
        End Select


        cboArtSicherheit.changeItem(If(SA.nctsSA_ArtCode, "")) 'Gesamtbürgschaft
        txtGRN.Text = If(SA.nctsSA_GRN, "")
        txtEORI_TIN.Text = If(SA.nctsSA_TIN, "")
        txtZugriffscode.Text = If(SA.nctsSA_Zugriffcode, "")
        txtAbgabenbetrag._value = If(SA.nctsSA_AbgabenBetrag, "")
        'txtEORI_TIN.Text = If(SA.nctsSA_TIN, "")

    End Sub


    Public Function getValues_TR() As VERAG_PROG_ALLGEMEIN.cNCTS_TR_Sicherheitsangaben
        Dim SA = New VERAG_PROG_ALLGEMEIN.cNCTS_TR_Sicherheitsangaben
        SA.nctsSA_AbgabenBetrag = cProgramFunctions.isLeerNothing(txtAbgabenbetrag._value)
        SA.nctsSA_BezeichnungBescheinigun = cProgramFunctions.isLeerNothing(txtBezeichnung._value)
        SA.nctsSA_ArtCode = cProgramFunctions.isLeerNothing(cboArtSicherheit._value)
        SA.nctsSA_GRN = cProgramFunctions.isLeerNothing(txtGRN._value)
        SA.nctsSA_Zugriffcode = cProgramFunctions.isLeerNothing(txtZugriffscode._value)
        SA.nctsSA_TIN = cProgramFunctions.isLeerNothing(txtEORI_TIN._value)
        If SA.nctsSA_AbgabenBetrag Is Nothing Then SA.nctsSA_AbgabenBetrag = 0
        Return SA
    End Function


    Public Sub setValues_TR(SA As VERAG_PROG_ALLGEMEIN.cNCTS_TR_Sicherheitsangaben)
        setBtn(btnBrgVERAG_AT, False)
        setBtn(btnBrgVERAG_DE, False)
        setBtn(btnBrgTOBB, False)
        setBtn(btnBrgSGS, False)
        setBtn(btnMars, False)
        setBtn(btnEKOL, False)
        setBtn(btnBrgSonstige, False)

        Select Case If(SA.nctsSA_GRN, "")
            Case "05AT510000G000FP7" : setBtn(btnBrgVERAG_AT, True)
            Case "17DE0000000071678" : setBtn(btnBrgVERAG_DE, True)
            Case Else : setBtn(btnBrgSonstige, True)
        End Select


        cboArtSicherheit.changeItem(If(SA.nctsSA_ArtCode, "")) 'Gesamtbürgschaft
        txtGRN.Text = If(SA.nctsSA_GRN, "")
        txtEORI_TIN.Text = If(SA.nctsSA_TIN, "")
        txtZugriffscode.Text = If(SA.nctsSA_Zugriffcode, "")
        txtAbgabenbetrag._value = If(SA.nctsSA_AbgabenBetrag, "")
        'txtEORI_TIN.Text = If(SA.nctsSA_TIN, "")

    End Sub

End Class
