Public Class usrCntlVerpflichtungserklärungFahrer
    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 AVISOID = 0
    Dim AVISODAL As New VERAG_PROG_ALLGEMEIN.cAvisoDAL
    Public KdNR As Integer = -1
    Dim FD_ID As Integer = -1
    Dim FV_ID = -1
    Dim WithEvents timer As New Timer
    Public DS_FD As VERAG_PROG_ALLGEMEIN.cDATENSERVER = Nothing

    Public Sub ChangeKDNr(kdnr As Integer) _
       Implements FormualrInterface.ChangeKDNr
        initKdNR(kdnr)
    End Sub

    Sub New(AVISOID As Integer)

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

    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 btn_Click(sender As Object, e As EventArgs) Handles btn.Click
        Dim kdsrch As New SDL.frmKundenSuche
        'Panel1.Enabled = False
        If kdsrch.ShowDialog(Me) = System.Windows.Forms.DialogResult.OK Then
            If IsNumeric(kdsrch.kundenNrSearch.Text) Then
                initKdNR(kdsrch.kundenNrSearch.Text)
                RaiseEvent KDNR_CHANGED(KdNR)
            End If
        End If
        '  Panel1.Enabled = True
    End Sub

    Public Sub initKdNR(KdNR)
        Me.KdNR = KdNR
        If KdNR > 0 Then

            Dim KUNDE As New VERAG_PROG_ALLGEMEIN.cKunde(KdNR)
            Dim ADRESSE As New VERAG_PROG_ALLGEMEIN.cAdressen(KdNR)

            txtFirma.Text = If(ADRESSE.Name_1, "") & If(If(ADRESSE.Name_2, "") <> "", " " & ADRESSE.Name_2, "")
            'txtAdresseFahrer1.Text = If(ADRESSE.Straße, "")
            '  txtAdresseFahrer2.Text = (If(ADRESSE.LandKz, "") & " " & If(ADRESSE.PLZ, "") & " " & If(ADRESSE.Ort, "")).ToString.Trim

            '   txtAnsprechpartner.Text = If(ADRESSE.Ansprechpartner, "")
        End If

    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
        initControlsHandler()

        If VERAG_PROG_ALLGEMEIN.cAllgemein.MITARBEITER.mit_niederlassung = "SBG" Then
            cbxUeberstellungsT.Checked = True
        End If
        If KdNR > 0 Then initKdNR(KdNR)
        initAVISOID()

        If AVISOID > 0 Then
            btnDatenFurLKWSpeichern.Visible = True
            Dim FV As cFormularVorlagen = cFormularVorlagen.LOADByBemerkung(Me.GetType.ToString, AVISOID)
            If FV IsNot Nothing Then
                loadValuesFV(FV)

            End If

        End If
        '  IMPORT()
        timer.Interval = 300
        timer.Enabled = True
    End Sub


    Protected Sub DoAsyncWork()
        Threading.Thread.Sleep(500)
        IMPORT()
    End Sub


    Private Sub pic_Click(sender As Object, e As EventArgs) Handles pic.Click
        FormularManagerNEU.genPDF(Me, True)
    End Sub


    Private Sub MyTextBox1_TextChanged(sender As Object, e As EventArgs) Handles MyTextBox1.Leave
        initAVISOID()
    End Sub
    Sub initAVISOID()
        MyTextBox2.Text = ""
        btnIMPORTIEREN.Enabled = False
        If IsNumeric(MyTextBox1.Text) Then AVISOID = MyTextBox1.Text 'Wenn durch Scan, dann AVISOID schon gesetzt, text nicht numerisch

        Dim AVISO As VERAG_PROG_ALLGEMEIN.caviso = AVISODAL.LesenAviso(AVISOID, "")
        If AVISO IsNot Nothing Then
            MyTextBox2.Text = AVISO.LKW_Nr
            txtLKWKennzeichen.Text = AVISO.LKW_Nr
            txtMobilNr.Text = If(AVISO.FahrerHandy, "")
            If AVISO.Frächter_KdNr <> "" AndAlso IsNumeric(AVISO.Frächter_KdNr) AndAlso AVISO.Frächter_KdNr > 0 Then
                initKdNR(KdNR)
            Else
                If txtFirma.Text = "" Then
                    txtFirma.Text = AVISO.Frächter
                End If
            End If
            txtLKWKennzeichen.Text = AVISO.LKW_Nr

            lblfound.Visible = True
            btnIMPORTIEREN.Enabled = True
            MyTextBox1.Text = AVISOID
        End If
    End Sub
    Private Sub MyTextBox1_TextChanged_1(sender As Object, e As EventArgs) Handles MyTextBox1.TextChanged
        lblfound.Visible = False
        If MyTextBox1.Text.StartsWith("/") Then
            If MyTextBox1.Text.Length > 3 And MyTextBox1.Text.EndsWith("/") Then 'AVISO ID
                If MyTextBox1.Text.Count(Function(c As Char) c = "/") > 2 Then
                    Exit Sub
                End If
                AVISOID = MyTextBox1.Text.Replace("/", "")
                initAVISOID()
            End If
        End If
    End Sub

    Private Sub btnIMPORTIEREN_Click(sender As Object, e As EventArgs) Handles btnIMPORTIEREN.Click
        IMPORT()
    End Sub

    Sub IMPORT()
        Me.Cursor = Cursors.WaitCursor
        Try
            If AVISOID <= 0 Then Exit Sub
            Dim strManNr = "VERA"
            Dim strManNl = "SUB"
            Dim notFound = ""
            'Dim SENDUNG_LIST As New List(Of VERAG_PROG_ALLGEMEIN.cSendungen)
            For Each r As DataRow In AVISODAL.loadDataTableBySQL("SELECT tblSnd_SendungID FROM tblSendungen WHERE tblSnd_AvisoID=" & AVISOID).Rows
              
                Dim SENDUNG As New VERAG_PROG_ALLGEMEIN.cSendungen(r("tblSnd_SendungID"))
                ' MsgBox(SENDUNG.FilialenNr)
                If SENDUNG IsNot Nothing Then
                    Dim sendungOK = False
                    'Select Case SENDUNG.FilialenNr
                    '  Case "4805", "4811"
                    '  Case Else
                    Select Case SENDUNG.FilialenNr
                        Case 4803, 4809
                            strManNl = "SUB"
                        Case 4801
                            strManNl = "SUW" : sendungOK = True
                        Case 5003
                            strManNl = "SBG" 'ANDERER SERVER!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
                        Case 5103
                            strManNl = "WAI"
                    End Select
                    Select Case SENDUNG.tblSnd_Abfertigungsart_ID
                        Case "5", "6", "33", "34", "37", "28", "26" Or SENDUNG.FilialenNr = 4801 'auch Fiskal
                            sendungOK = True
                            If SENDUNG.tblSnd_Abfertigungsart_ID = "26" And Not cbxUeberstellungsT.Checked Then sendungOK = False
                            If SENDUNG.tblSnd_Abfertigungsart_ID = "28" And Not cbxUeberstellungsT.Checked Then sendungOK = False

                    End Select


                    If sendungOK Then
                        '    'Nicht mehr im KEWILL ATLAS naschschauen!!!

                        Dim notFoundTMP = SENDUNG.FilialenNr & "/" & SENDUNG.AbfertigungsNr & " " & SENDUNG.tblSnd_Empfaenger & vbNewLine


                        'Dakosy--NCTS004----------------------------------------
                        If SENDUNG.FilialenNr > 0 And SENDUNG.AbfertigungsNr > 0 Then
                            Dim DyPos = SENDUNG.AbfertigungsNr.ToString
                            If SENDUNG.AbfertigungsNr.ToString.Length >= 8 Then

                                DyPos = CInt(SENDUNG.AbfertigungsNr.ToString.Substring(2))
                            End If
                            Dim dt As DataTable = (New VERAG_PROG_ALLGEMEIN.SQL).loadDgvBySql("Select [ncts_Id] FROM [tblDakosy_NCTSOut004] WHERE (ncts_ObjectName LIKE '%" & SENDUNG.FilialenNr & "/" & SENDUNG.AbfertigungsNr & "%' OR ncts_ObjectName LIKE '%" & SENDUNG.FilialenNr & "-" & SENDUNG.AbfertigungsNr & "%' OR ncts_ObjectName LIKE '%" & SENDUNG.FilialenNr & "/" & DyPos & "' OR ncts_ObjectName LIKE '%" & SENDUNG.FilialenNr & "-" & DyPos & "' OR ncts_ObjectName='" & SENDUNG.tblSnd_DakosyRef & "') AND ncts_Status between '50' and '60' ORDER BY ncts_ObjectName", "FMZOLL")
                            '    If dt IsNot Nothing AndAlso dt.Rows.Count > 0 Then
                            For Each row As DataRow In dt.Rows
                                Dim DY As New DAKOSY_Worker.cDakosyNCTSOut004(row("ncts_Id"))
                                If DY IsNot Nothing AndAlso DY.ncts_MRN IsNot Nothing Then
                                    MyDatagridview1.Rows.Add(DY.ncts_MRN)
                                End If
                            Next
                            notFoundTMP = ""
                            '  Else
                        End If
                        'Dakosy------------------------------------------
                        If SENDUNG.FilialenNr > 0 And SENDUNG.AbfertigungsNr > 0 Then
                            Dim DyPos = SENDUNG.AbfertigungsNr.ToString
                            If SENDUNG.AbfertigungsNr.ToString.Length >= 8 Then

                                DyPos = CInt(SENDUNG.AbfertigungsNr.ToString.Substring(2))
                            End If
                            Dim dt As DataTable = (New VERAG_PROG_ALLGEMEIN.SQL).loadDgvBySql("Select [ncts_Id] FROM [tblDakosy_NCTSOut] WHERE (ncts_ObjectName LIKE '%" & SENDUNG.FilialenNr & "/" & SENDUNG.AbfertigungsNr & "%' OR ncts_ObjectName LIKE '%" & SENDUNG.FilialenNr & "-" & SENDUNG.AbfertigungsNr & "%' OR ncts_ObjectName LIKE '%" & SENDUNG.FilialenNr & "/" & DyPos & "' OR ncts_ObjectName LIKE '%" & SENDUNG.FilialenNr & "-" & DyPos & "' OR ncts_ObjectName='" & SENDUNG.tblSnd_DakosyRef & "') AND ncts_Status between '50' and '60' ORDER BY ncts_ObjectName", "FMZOLL")
                            '    If dt IsNot Nothing AndAlso dt.Rows.Count > 0 Then
                            For Each row As DataRow In dt.Rows
                                Dim DY As New DAKOSY_Worker.cDakosyNCTSOut(row("ncts_Id"))
                                If DY IsNot Nothing AndAlso DY.ncts_MRN IsNot Nothing Then
                                    MyDatagridview1.Rows.Add(DY.ncts_MRN)
                                End If
                            Next
                            notFoundTMP = ""
                            '  Else
                        End If

                        'E-ZOLL--------------------------------------
                        If SENDUNG.FilialenNr > 0 And SENDUNG.AbfertigungsNr > 0 Then

                            Dim IMPORT As New DAKOSY_Worker.cZOLL_IMPORT
                            Dim dt2 As DataTable = IMPORT.getMRNFROM_EZollNCTSDatenbereitstellungDT("%" & SENDUNG.FilialenNr & "/" & SENDUNG.AbfertigungsNr & "%")
                            If dt2 IsNot Nothing AndAlso dt2.Rows.Count > 0 Then
                                For Each row As DataRow In dt2.Rows
                                    MyDatagridview1.Rows.Add(row("CRN"))
                                Next
                                notFoundTMP = ""
                            End If

                            'For Each s In IMPORT.genBezugsNummern(SENDUNG, strManNl)
                            '    '  Dim tmp = IMPORT.getMRNFROM_AtlasNCTSDatenbereitstellung(strManNr, strManNl, s).Trim
                            '    '  If tmp <> "" Then MyDatagridview1.Rows.Add(tmp) : notFoundTMP = ""


                            '    Dim tmp2 = IMPORT.getMRNFROM_EZollNCTSDatenbereitstellung(s).Trim
                            '    If tmp2 <> "" Then MyDatagridview1.Rows.Add(tmp2) : notFoundTMP = ""
                            'Next

                            ' End If

                        End If
                        notFound &= notFoundTMP

                    End If
                End If
                '  End Select
            Next
            If notFound <> "" Then
                MsgBox("Für folgende T1 / T2 Sendungen konnten keine MRN Nummer gefunden werden (Bitte manuell ergänzen):" & vbNewLine & vbNewLine & notFound.Trim)
            End If

        Catch ex As Exception
            MsgBox(ex.Message)
        End Try
        Me.Cursor = Cursors.Default
    End Sub






    Private Sub timer_Tick(sender As Object, e As EventArgs) Handles timer.Tick
        timer.Enabled = False
        IMPORT()
    End Sub

    Private Sub Button1_Click_1(sender As Object, e As EventArgs) Handles Button1.Click
        Dim f As New frmFahrerDatenSuche
        If f.ShowDialog(Me) = DialogResult.OK Then
            FD_ID = f.dgvFD.SelectedRows(0).Cells("fd_id").Value
            txtFahrername.Text = f.dgvFD.SelectedRows(0).Cells("fd_fahrerName").Value
            txtMobilNr.Text = f.dgvFD.SelectedRows(0).Cells("fd_tel").Value
            txtAdresseFahrer.Text = f.dgvFD.SelectedRows(0).Cells("fd_wohnAdresse").Value
            txtPassnummer.Text = f.dgvFD.SelectedRows(0).Cells("fd_passNummer").Value
            Dim fd_dsId As Object = f.dgvFD.SelectedRows(0).Cells("fd_dsId").Value


            If fd_dsId IsNot Nothing AndAlso IsNumeric(fd_dsId) Then
                'DS_FD = New VERAG_PROG_ALLGEMEIN.cDATENSERVER("DOKUMENTE", "PASSKOPIEN", "FAHRER", "", "", "Fahrer_ID_" & FD_ID, 0, False)
                DS_FD = New VERAG_PROG_ALLGEMEIN.cDATENSERVER(fd_dsId)
            Else
                DS_FD = New VERAG_PROG_ALLGEMEIN.cDATENSERVER("DOKUMENTE", "PASSKOPIEN", "FAHRER", "", "", "Fahrer_ID_" & FD_ID, 0, False)
            End If

            btnDelFD.Visible = True
            lblDel.Visible = True
            lklEintragAufheben.Visible = True


            Panel1.Visible = True
        Else

        End If
        initPass()
    End Sub


    Sub initPass()
        Button2.BackgroundImage = My.Resources.passpic_sw
        LöschenToolStripMenuItem.Enabled = False
        If DS_FD Is Nothing Then
            Panel1.Visible = False
        Else
            Panel1.Visible = True
            If DS_FD.DATA_LIST.LIST.Count > 0 Then
                Button2.BackgroundImage = My.Resources.passpic
                LöschenToolStripMenuItem.Enabled = True
            End If
        End If
    End Sub

    Private Sub Button3_Click(sender As Object, e As EventArgs) Handles btnSaveFD.Click

        Dim FD As New cFahrerDaten
        FD.fd_id = FD_ID
        FD.fd_fahrerName = txtFahrername.Text
        FD.fd_tel = txtMobilNr.Text
        FD.fd_wohnAdresse = txtAdresseFahrer.Text
        FD.fd_passNummer = txtPassnummer.Text
        FD.fd_fraechter = txtFirma.Text
        FD.fd_lkw = txtLKWKennzeichen.Text

        cFahrerDaten.setData(FD, FD_ID)
        btnDelFD.Visible = True
        lblDel.Visible = True
        lklEintragAufheben.Visible = True
    End Sub

    Private Sub lklEintragAufheben_LinkClicked(sender As Object, e As LinkLabelLinkClickedEventArgs) Handles lklEintragAufheben.LinkClicked
        FD_ID = -1
        btnDelFD.Visible = False
        lblDel.Visible = False
        lklEintragAufheben.Visible = False
        Panel1.Visible = False
        DS_FD = Nothing
    End Sub

    Private Sub btnDelFD_Click(sender As Object, e As EventArgs) Handles btnDelFD.Click
        If cFahrerDaten.delData(FD_ID) Then
            FD_ID = -1
            btnDelFD.Visible = False
            lblDel.Visible = False
            lklEintragAufheben.Visible = False
        End If
    End Sub

    Private Sub DateiScannenToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles DateiScannenToolStripMenuItem.Click
        Try

            If DS_FD IsNot Nothing Then

                If KdNR < 0 Then Exit Sub
                Dim frmScan As New VERAG_PROG_ALLGEMEIN.frmScan("DirectScan")
                '   frmScan.DefaultFileName = Me._TEXT_PDF

                If frmScan.ShowDialog(Me) = DialogResult.OK Then
                    If frmScan.ReturnValue IsNot Nothing Then
                        Dim Filename = DS_FD.da_name
                        If DS_FD.uploadDataToDATENSERVER_fromBytes(frmScan.ReturnValue, Filename, ".pdf") Then
                            'If DS_FD.DATA_LIST.LIST.Count > 0 Then
                            '  Dim l As VERAG_PROG_ALLGEMEIN.cDatenarchiv_Collection = DS_FD.DATA_LIST.LIST(DS_FD.DATA_LIST.LIST.Count - 1)
                            'RaiseEvent FileAdded(l.coll_id, l.coll_pfad, l.coll_bezeichnung)
                            'End If
                        End If
                    End If
                End If
            End If
            initPass()
        Catch ex As Exception
            MsgBox("FEHLER: UserControl möglicherweise nicht initialisiert!")
        End Try
    End Sub

    Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
        If DS_FD IsNot Nothing Then
            If DS_FD.DATA_LIST.LIST.Count > 0 Then
                DS_FD.OPEN_SINGLE()
            End If
        End If
    End Sub

    Private Sub DateiHochladenToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles DateiHochladenToolStripMenuItem.Click
        If DS_FD IsNot Nothing Then
            DS_FD.uploadDataToDATENSERVERFileDialog(, ".pdf", , "PDF")
        End If
        initPass()
    End Sub

    Private Sub LöschenToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles LöschenToolStripMenuItem.Click
        If DS_FD IsNot Nothing Then
            If vbYes = MsgBox("Möchten Sie die Passkopie wirklich löschen?", vbYesNoCancel) Then DS_FD.DELETE_COMPLETE()
        End If
        initPass()
    End Sub


    Private Sub btnDatenFurLKWSpeichern_Click(sender As Object, e As EventArgs) Handles btnDatenFurLKWSpeichern.Click
        'If txtVorlage.Text = "" Then MsgBox("Bitte ein Vorlagenbezeichnung eingeben!") : Exit Sub
        Dim FV As cFormularVorlagen
        If FV_ID > -1 Then
            If MsgBox("Möchten Sie die Vorlage überschreiben?", vbYesNoCancel) <> MsgBoxResult.Yes Then Exit Sub
            FV = New cFormularVorlagen(FV_ID)
        Else
            FV = New cFormularVorlagen
            FV.tblform_art = Me.GetType.ToString
            FV.tblform_begriff = AVISOID
        End If
        FV.tblform_KundenNr = If(KdNR > 0, KdNR, Nothing)
        FV.tblform_Sachbearbeiter = VERAG_PROG_ALLGEMEIN.cAllgemein.USRKURZNAME
        FV.tblform_letzeAenderung = Now

        If FV.SAVE() Then
            getValues(FV)
            If FV.SAVE_VALUES() Then initControlsSave(FV) : Me.FindForm.Close()
        End If

    End Sub

    Sub loadValuesFV(FV As cFormularVorlagen)
        FD_ID = -1

        btnDelFD.Visible = False
        lblDel.Visible = False
        lklEintragAufheben.Visible = False
        Panel1.Visible = False
        FV_ID = FV.tblform_id
        For Each v In FV.VALUES
            If Me.Controls(v.tblfv_name) IsNot Nothing Then

                Select Case Me.Controls(v.tblfv_name).GetType.ToString
                    Case GetType(VERAG_PROG_ALLGEMEIN.MyTextBox).ToString, GetType(TextBox).ToString
                        Me.Controls(v.tblfv_name).text = v.tblfv_wert
                    Case GetType(VERAG_PROG_ALLGEMEIN.MyComboBox).ToString
                        Me.Controls(v.tblfv_name)._value = v.tblfv_wert
                    Case GetType(VERAG_PROG_ALLGEMEIN.MyRichTextBox).ToString
                        Me.Controls(v.tblfv_name).text = v.tblfv_wert
                End Select
            ElseIf v.tblfv_name = "FD_ID" Then
                FD_ID = v.tblfv_wert
                btnDelFD.Visible = True
                lblDel.Visible = True
                lklEintragAufheben.Visible = True
                Panel1.Visible = True

                Dim FD = cFahrerDaten.LOADByKdNrDate(FD_ID)
                If FD IsNot Nothing Then
                    If FD.fd_dsId IsNot Nothing AndAlso IsNumeric(FD.fd_dsId) Then
                        'DS_FD = New VERAG_PROG_ALLGEMEIN.cDATENSERVER("DOKUMENTE", "PASSKOPIEN", "FAHRER", "", "", "Fahrer_ID_" & FD_ID, 0, False)
                        DS_FD = New VERAG_PROG_ALLGEMEIN.cDATENSERVER(FD.fd_dsId)
                    Else
                        DS_FD = New VERAG_PROG_ALLGEMEIN.cDATENSERVER("DOKUMENTE", "PASSKOPIEN", "FAHRER", "", "", "Fahrer_ID_" & FD_ID, 0, False)
                    End If
                End If
                initPass()
                End If

        Next

    End Sub
    Sub getValues(ByVal FV As cFormularVorlagen)
        FV.VALUES.Clear()
        For Each c In Me.Controls
            Select Case c.GetType.ToString
                Case GetType(VERAG_PROG_ALLGEMEIN.MyTextBox).ToString, GetType(TextBox).ToString, GetType(VERAG_PROG_ALLGEMEIN.MyRichTextBox).ToString
                    FV.VALUES.Add(New cFormularVorlagenValues(FV.tblform_id, c.name, c.text))
                Case GetType(VERAG_PROG_ALLGEMEIN.MyComboBox).ToString
                    FV.VALUES.Add(New cFormularVorlagenValues(FV.tblform_id, c.name, If(c._value IsNot Nothing, c._value, "")))
            End Select
        Next
        If FD_ID > 0 Then
            FV.VALUES.Add(New cFormularVorlagenValues(FV.tblform_id, "FD_ID", FD_ID))
        End If
      
    End Sub

    Sub initControlsSave(FV As cFormularVorlagen)
        Exit Sub
        If FV IsNot Nothing Then
            Me.KdNR = If(FV.tblform_KundenNr IsNot Nothing, FV.tblform_KundenNr, -1)
            FV_ID = FV.tblform_id
            btnDelFD.Visible = True
            lklEintragAufheben.Visible = True
            ' txtVorlage.Enabled = False
        Else
            Me.KdNR = -1
            FV_ID = -1
            ' txtVorlage.Enabled = True
            ' txtVorlage.Text = ""
            btnDelFD.Visible = False
            lklEintragAufheben.Visible = False
        End If
        initPass()
    End Sub


End Class
