Public Class frmEoriLink
    Public link As String
    Dim printed As Boolean = False
    Public frmCheckliste As frmCheckliste

    Private Sub Form1_Load(sender As Object, e As EventArgs) Handles Me.Load
        Button1.Enabled = (VERAG_PROG_ALLGEMEIN.cGlobal.Aktive_SendungsID > 0)

        WebBrowser1.ScriptErrorsSuppressed = True

        If frmCheckliste.txtEori.Text <> "" Then
            WebBrowser1.Navigate(link)
            Label3.Text = frmCheckliste.txtFirma.Text
            Label4.Text = frmCheckliste.txtEori.Text
            frmCheckliste.lblEORIAbfrage.Text = ""
            frmCheckliste.picEORIAbfrage.Image = Nothing
            frmCheckliste.picEORIAbfrage.Visible = False
        Else
            MsgBox("Keine EORI-Nummer eingegeben!")
            Me.Close()
        End If

    End Sub

    Private Sub btnOK_Click(sender As Object, e As EventArgs) Handles btnOK.Click

        If Not printed Then
            Select Case MsgBox("Soll die EORI-Prüfung gedruckt werden?", vbYesNoCancel, "Drucken vergesssen?")
                Case vbYes
                    WebBrowser1.ShowPrintDialog()
                    frmCheckliste.eoriTrue()
                    Me.Close()
                Case vbNo
                    frmCheckliste.eoriTrue()
                    Me.Close()
                Case vbCancel
            End Select
        Else
            frmCheckliste.eoriTrue()
            Me.Close()
        End If

    End Sub

    Private Sub btnNO_Click(sender As Object, e As EventArgs) Handles btnNO.Click
        Me.Close()
        frmCheckliste.eoriFalse()
        MsgBox("Bitte brechen Sie die Bearbeitung ab - EORI Nummer muss korrekt sein!", vbInformation)
    End Sub

    Private Sub btnScrollDown_Click(sender As Object, e As EventArgs) Handles btnScrollDown.Click
        WebBrowser1.Navigate("javascript:window.scroll(0,document.body.scrollHeight);")
    End Sub

    Private Sub btnPrint_Click(sender As Object, e As EventArgs) Handles btnPrint.Click
        WebBrowser1.ShowPrintDialog()
        printed = True
    End Sub

    Private Sub frmEoriLink_Shown(sender As Object, e As EventArgs) Handles Me.Shown
        Me.Height = My.Computer.Screen.WorkingArea.Height
        Me.Top = 0
    End Sub

    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click

        Dim pdf = VERAG_PROG_ALLGEMEIN.cFormularManager.getPDFViaSpirePDF_FromURL(WebBrowser1.Url.AbsoluteUri.ToString)
        Process.Start(pdf)
        'frmLKW_AnhaengeDatenarchiv.
        ' saveToDS(AvisoId, fileName, sourcePath, Art, Typ, Optional ByRef da_id = -1, Optional ByRef anhId = -1, Optional ByRef destPath = "", Optional SendungsId = Nothing)
        'VERAG_PROG_ALLGEMEIN.cGlobal.Aktive_SendungsID
    End Sub
End Class