Imports GrapeCity.ActiveReports 
Imports GrapeCity.ActiveReports.Document
Imports sun.misc
Imports VERAG_PROG_ALLGEMEIN

Public Class rptFiskalkunde

    Dim FiskalId As Integer
    Dim Firma = "1"
    Dim KdNr As Integer
    Dim VM As cKundenVollmachten
    Dim BR As cBonitaetsauskunft
    Dim EORI As cEORIPruefung
    Dim UID As cUIDPruefung
    Dim UVM As cKundenVollmachten
    Dim VMOriginal As Boolean = False
    Dim unterlagenliste As List(Of String)

    Sub New(KdNr As Integer, FiskalId As Integer, VM As cKundenVollmachten, BR As cBonitaetsauskunft, EORI As cEORIPruefung, UID As cUIDPruefung, UVM As cKundenVollmachten, VMOriginal As Boolean, unterlagenliste As List(Of String), Optional Firma As String = "VERAG")

        ' Dieser Aufruf ist für den Designer erforderlich.
        InitializeComponent()

        Me.KdNr = KdNr
        Me.FiskalId = FiskalId
        Me.Firma = Firma
        Me.VM = VM
        Me.BR = BR
        Me.EORI = EORI
        Me.UID = UID
        Me.UVM = UVM
        Me.unterlagenliste = unterlagenliste

        ' Fügen Sie Initialisierungen nach dem InitializeComponent()-Aufruf hinzu.

    End Sub

    Private Sub rptKundeUebersicht_ReportStart(sender As Object, e As EventArgs) Handles Me.ReportStart
        Dim KD As New VERAG_PROG_ALLGEMEIN.cKunde(KdNr)
        Dim AD As New VERAG_PROG_ALLGEMEIN.cAdressen(KdNr)
        Dim KD_ERW As New VERAG_PROG_ALLGEMEIN.cKundenErweitert(KdNr)
        Dim FK As New VERAG_PROG_ALLGEMEIN.cFiskalkunden(FiskalId)

        lblUeberschrift.Text = "Checkliste für " & FK.FK_Art & "-Fiskal Kunden"

        If FK.FK_Art = "DE" Then
            picVeragAG.Visible = True
        Else
            picVeragCS.Visible = True
        End If

        txtKdNr.Text = AD.AdressenNr
        txtFirma.Text = AD.Name_1 & " " & AD.Name_2
        txtEMail.Text = AD.E_Mail

        If VM IsNot Nothing Then

            If VM.kdvm_emailId > 0 Then
                txtVM.Text = " Vollmacht per Mail erhalten "
                txtVMJa.Text = "X"
            ElseIf VM.kdvm_datenarchivId > 0 Then
                txtVM.Text = " Vollmacht liegt vor "
                txtVMJa.Text = "X"
            Else
                txtVM.Text = " Vollmacht liegt NICHT vor "
                txtVMNein.Text = "X"
            End If

            If IsDate(VM.kdvm_erhalten_Datum) Then txtVM.Text &= CDate(VM.kdvm_erhalten_Datum).ToShortDateString

            If VMOriginal Then txtVM.Text &= " (Original vorhanden)"
        Else
            txtVMNein.Text = "X"
        End If

        If UVM IsNot Nothing Then

            If UVM.kdvm_emailId > 0 Then
                txtUVM.Text = " Untervollmacht per Mail erhalten "
                txtUVMJa.Text = "X"
            ElseIf VM.kdvm_datenarchivId > 0 Then
                txtUVM.Text = " Untervollmacht liegt vor "
                txtUVMJa.Text = "X"
            Else
                txtUVM.Text = " Untervollmacht liegt NICHT vor "
                txtUVMNein.Text = "X"
            End If

            If IsDate(UVM.kdvm_erhalten_Datum) Then txtUVM.Text &= CDate(UVM.kdvm_erhalten_Datum).ToShortDateString
        Else
            txtUVMNein.Text = "X"
        End If


        If BR IsNot Nothing Then

            txtBon.Text = "Bonitätsscore: "
            txtBon.Text &= If(BR.ba_CreditSaveBonitaetsScore, "") & IIf(BR.ba_CreditSaveBonitaetsScore IsNot Nothing AndAlso BR.ba_CreditSaveRisikoklasse IsNot Nothing, "/", "") & If(BR.ba_CreditSaveRisikoklasse, "")
            txtBONja.Text = "X"

            If IsDate(BR.ba_Datum) Then txtBon.Text &= " - " & CDate(BR.ba_Datum).ToShortDateString

        Else
            txtBONnein.Text = "X"
        End If

        txtUmsatz.Text = ""


        If IsNumeric(FK.FK_KreditMax) Then txtKredit.Text = CDbl(FK.FK_KreditMax)
        If IsNumeric(FK.FK_Umsatz) Then txtUmsatz.Text = CDbl(FK.FK_Umsatz)
        If IsNumeric(FK.FK_AnzahlMitarbeiter) Then txtAnzMA.Text = CDbl(FK.FK_AnzahlMitarbeiter)
        If IsDate(FK.FK_Gruendungsdatum) Then txtGJ.Text = CDate(FK.FK_Gruendungsdatum).ToShortDateString
        txtImport.Text = IIf(FK.FK_Waren <> "", FK.FK_Waren, "")
        txtSteuerberater.Text = IIf(FK.FK_Steuerberater <> "", FK.FK_Steuerberater, "")
        If FK.FK_Website_URL <> "" Then
            txtWebsite.Text = FK.FK_Website_URL
            txtWSja.Text = "X"
        Else
            txtWebsite.Text = ""
            txtWSnein.Text = "X"
        End If

        If unterlagenliste.Contains("HR") Or unterlagenliste.Contains("GW-Anmeldung") Then
            txtHRja.Text = "X"
        Else
            txtHRnein.Text = "X"
        End If

        For Each c In unterlagenliste
            txtSonstiges.Text &= c.ToString & ", "
        Next


        txtGZ.Text = IIf(FK.FK_Geschaeftszweck <> "", FK.FK_Geschaeftszweck, "")
        txtGF.Text = IIf(FK.FK_Geschaeftsfuehrer <> "", FK.FK_Geschaeftsfuehrer, "")

        If IsDate(KD.Eingegeben_am) Then txtKundeSeit.Text = CDate(KD.Eingegeben_am).ToShortDateString
        If FK.FK_locked Then

            Dim mit = New VERAG_PROG_ALLGEMEIN.cMitarbeiter(FK.FK_MaId)
            lblKontrolle.Text = "kontrolliert: " & mit.Fullname & ", " & FK.FK_Abschlussdatum

        End If

        lblDat.Text = Now.ToString("dddd, dd.MM.yyyy")


        Select Case Firma
            Case "IMEX" : Me.picVeragAG.Image = My.Resources.IMEX_LOGO_simple : Me.Label28.Text = "IMEX Customs Service GmbH"
            Case "ATILLA" : Me.picVeragAG.Image = My.Resources.Atilla : Me.Label28.Text = "ATILLA Spedition"
            Case "UNISPED" : Me.picVeragAG.Image = My.Resources.Unisped_logo : Me.Label28.Text = "UNISPED Speditions GmbH"
            Case Else
        End Select
        txtAnsprechpartner.Text = AD.Ansprechpartner


    End Sub
End Class