Public Class usrcntlVerzollungsunterlagen_Verbringsungsnachweis
    Implements FormualrInterface

    Public Event CHANGED(name, value)
    Public Event KDNR_CHANGED(kdnr)
    Public Event DELETE(c As Control)
    Public Event MOVE_UP(c As Control)
    Public Event MOVE_DOWN(c As Control)

    Public KdNR As Integer = -1
    Public Path As String = ""
    Public VBNr As Integer = -1
    Public Sub ChangeKDNr(kdnr As Integer) _
       Implements FormualrInterface.ChangeKDNr
        'initKdNR(kdnr)
        txtFirma.KdNr = kdnr
    End Sub

    'Dim KdNR As Integer = -1
    Sub initControlsHandler()
        For Each c In Me.Controls
            Select Case c.GetType.ToString
                Case GetType(VERAG_PROG_ALLGEMEIN.MyTextBox).ToString
                    AddHandler DirectCast(c, VERAG_PROG_ALLGEMEIN.MyTextBox).Leave, Sub()
                                                                                        RaiseEvent CHANGED(c.name, c.text)
                                                                                    End Sub
                Case GetType(VERAG_PROG_ALLGEMEIN.MyComboBox).ToString
                    AddHandler DirectCast(c, VERAG_PROG_ALLGEMEIN.MyComboBox).SelectedIndexChanged, Sub()
                                                                                                        RaiseEvent CHANGED(c.name, c._value)
                                                                                                    End Sub
                Case GetType(TextBox).ToString
                    AddHandler DirectCast(c, TextBox).Leave, Sub()
                                                                 RaiseEvent CHANGED(c.name, c.text)
                                                             End Sub
            End Select
        Next
    End Sub





    Private Sub btnDel_Click(sender As Object, e As EventArgs) Handles btnDel.Click
        RaiseEvent DELETE(Me)
    End Sub

    Private Sub btnup_Click(sender As Object, e As EventArgs) Handles btnUp.Click
        RaiseEvent MOVE_UP(Me)
    End Sub

    Private Sub btnDown_Click(sender As Object, e As EventArgs) Handles btnDown.Click
        RaiseEvent MOVE_DOWN(Me)
    End Sub

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

    End Sub

    Private Sub usrcntlVollmacht_AT_Load(sender As Object, e As EventArgs) Handles Me.Load

        txtFirma.initKdBox(Me.FindForm)
        AddHandler txtFirma.PropertyChanged, Sub()
                                                 Me.KdNR = txtFirma.KdNr_value
                                                 If txtFirma.KdNr_value > 0 Then
                                                     If txtFirma.KdData_ADRESSEN IsNot Nothing Then
                                                         Dim ADRESSE = txtFirma.KdData_ADRESSEN
                                                         txtFirma.Text = If(ADRESSE.Name_1, ADRESSE.Ordnungsbegriff)
                                                         txtAdresse1.Text = (If(ADRESSE.LandKz, "") & " " & If(ADRESSE.PLZ, "") & " " & If(ADRESSE.Ort, "")).ToString.Trim
                                                     End If
                                                 End If
                                                 RaiseEvent KDNR_CHANGED(KdNR)
                                             End Sub
        initControlsHandler()

        If KdNR > 0 Then txtFirma.KdNr = KdNR
        If VBNr > 0 Then txtvbnr.Text = VBNr

        cboTEXT.Items.Add(New VERAG_PROG_ALLGEMEIN.MyListItem("", ""))
        cboTEXT.Items.Add(New VERAG_PROG_ALLGEMEIN.MyListItem("AT Fiskal (direkt)", "AT_FISKAL_DIREKT"))
        cboTEXT.Items.Add(New VERAG_PROG_ALLGEMEIN.MyListItem("AT Fiskal (indirekt)", "AT_FISKAL_INDIREKT"))
        cboTEXT.Items.Add(New VERAG_PROG_ALLGEMEIN.MyListItem("DE Fiskal (GB)", "DE_FISKAL_GB"))
        cboTEXT.Items.Add(New VERAG_PROG_ALLGEMEIN.MyListItem("DE Fiskal (FR)", "DE_FISKAL_FR"))
        cboTEXT.Items.Add(New VERAG_PROG_ALLGEMEIN.MyListItem("DE Fiskal (TR)", "DE_FISKAL_TR"))


    End Sub


    Private Sub pic_Click(sender As Object, e As EventArgs) Handles pic.Click
        Process.Start(Path)
    End Sub



    Private Sub PictureBox1_Click(sender As Object, e As EventArgs)
        FormularManagerNEU.genPDF(Me, , , , True)
    End Sub


    Sub loadAdressen(KdNr)
        Me.KdNR = KdNr
        If KdNr IsNot Nothing AndAlso IsNumeric(KdNr) AndAlso KdNr > 0 Then
            Dim AD As New VERAG_PROG_ALLGEMEIN.cAdressen(KdNr)
            txtFirma.Text = If(AD.Name_1, "")
            '   txtFirma2.Text = If(AD.Name_2, "")
            txtAdresse1.Text = If(AD.LandKz, "") & " " & If(AD.PLZ, "") & " " & If(AD.Ort, "")

        Else
            txtFirma.Text = ""
            '   txtFirma2.Text = ""
            txtAdresse1.Text = ""
        End If



    End Sub


    Sub loadData()
        Dim Spedbuch As New VERAG_PROG_ALLGEMEIN.cSpeditionsbuch()
    End Sub



End Class
