Imports GrapeCity.ActiveReports.SectionReportModel
Imports GrapeCity.ActiveReports
Public Class frmActiveReprotViewer
    'Public semiCert As semiCert
    Public report As String = "rptSeminatZert.rpx"
    Public Sub BefüllenSeminarZertifikat(semiCert)

        Dim d As New GrapeCity.ActiveReports.Document.SectionDocument
        For Each t As String In semiCert.teilnehmer
            Dim rpt2 As New GrapeCity.ActiveReports.SectionReport
            Dim xtr2 As New System.Xml.XmlTextReader(report)
            rpt2.LoadLayout(xtr2)
            xtr2.Close()
            rpt2 = fillParams(rpt2, t, semiCert)
            rpt2.Run()
            d.Pages.Add(rpt2.Document.Pages(0))
        Next

        Viewer1.Document = d

    End Sub

    Public Sub BefüllenSeminarZertifikatIntern(semiCert)

        Dim d As New GrapeCity.ActiveReports.Document.SectionDocument
        For Each t As String In semiCert.teilnehmer
            Dim rpt2 As New GrapeCity.ActiveReports.SectionReport
            Dim xtr2 As New System.Xml.XmlTextReader(report)
            rpt2.LoadLayout(xtr2)
            xtr2.Close()
            rpt2 = fillParamsIntern(rpt2, t, semiCert)
            rpt2.Run()
            d.Pages.Add(rpt2.Document.Pages(0))
        Next

        Viewer1.Document = d

    End Sub


    Private Sub frmActiveReprotViewer_Load(sender As Object, e As EventArgs) Handles Me.Load
        '    BefüllenSeminarZertifikat()
        '   BefüllenSeminarZertifikatIntern()
    End Sub

    Private Function createParameterValue(ByVal name As String, ByVal value As String) As Parameter
        Dim myParam1 As New Parameter()
        myParam1.Key = name
        myParam1.Type = Parameter.DataType.String
        'Set to False if you do not want input from user.
        myParam1.PromptUser = True
        myParam1.Prompt = value
        myParam1.DefaultValue = ""
        Return myParam1
        'Dim s As New GrapeCity.ActiveReports.Expressions.ExpressionObjectModel.ParameterValue
        ' s.Value = value
        ' s.Label = value
        ' Return s
    End Function

    Private Function fillParams(ByVal p As GrapeCity.ActiveReports.SectionReport, ByVal t As String, ByVal semiCert As semiCert) As GrapeCity.ActiveReports.SectionReport
        p.Parameters("name").Value = t
        p.Parameters("date").Value = semiCert.datum
        p.Parameters("titel").Value = semiCert.titel
        p.Parameters("inhalt").Value = semiCert.inhalt
        p.Parameters("inhalt2").Value = semiCert.inhalt2
        p.Parameters("referent").Value = semiCert.referent

        Return p
    End Function

    Private Function fillParamsIntern(ByVal p As GrapeCity.ActiveReports.SectionReport, ByVal t As String, ByVal semiCert As semiCert) As GrapeCity.ActiveReports.SectionReport
        p.Parameters("name").Value = t
        p.Parameters("date").Value = semiCert.datum
        p.Parameters("titel").Value = semiCert.titel
        p.Parameters("inhalt").Value = semiCert.inhalt
        '    p.Parameters("referent").Value = semiCert.referent
        If semiCert.unterzeichnender = "" Then
            Dim u As String = InputBox("Bitte geben Sie den Unterzeichnenden an:")
            p.Parameters("unterz").Value = If(u <> "", u, "Johann Luxbauer")
        Else
            p.Parameters("unterz").Value = semiCert.unterzeichnender
        End If
       
        p.Parameters("zeitraum").Value = semiCert.zeitraum
        Return p
    End Function
End Class