Imports GrapeCity.ActiveReports 
Imports GrapeCity.ActiveReports.Document

Public Class subRptLaufzettelZollDE_Vorpapier

    Dim VP As New List(Of VERAG_PROG_ALLGEMEIN.cAvisoVorpapier)
    Dim SQL As New VERAG_PROG_ALLGEMEIN.SQL
    Dim cnt = 1
    Sub New(VP As List(Of VERAG_PROG_ALLGEMEIN.cAvisoVorpapier))

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

    End Sub

    Private Sub Detail_Format(sender As Object, e As EventArgs) Handles Detail.Format
        txtATAMRN.Text = ""
        If Me.DataSource IsNot Nothing AndAlso Me.Fields IsNot Nothing AndAlso Me.Fields.Item("MRN").Value IsNot Nothing Then
            Dim ATAMRN As String = Me.Fields.Item("MRN").Value
            ATAMRN = ATAMRN.Replace(" ", "")
            ATAMRN = ATAMRN.Replace("/", "")
            ATAMRN = ATAMRN.Replace("-", "")
            ATAMRN = ATAMRN.Replace("XXXX", "")

            picBarcodeMRN.Image = Nothing
            picBarcodeMRN.Visible = False
            Try
                If ATAMRN.Length > 10 And ATAMRN.Length < 50 Then
                    Dim barcodeATA As Image = Code128Rendering.MakeBarcodeImage(ATAMRN, 1, True, 20)
                    picBarcodeMRN.Image = barcodeATA
                    picBarcodeMRN.Visible = True
                End If

                If ATAMRN <> "" Then
                    '  Dim ATB = SQL.DLookup("tblSnd_ATB_Nr", "tblSendungen", "'" & ATAMRN.Trim & "' IN (tblSnd_Vorpapier,tblSnd_Vorpapier2,tblSnd_Vorpapier3) and tblSnd_Abfertigungsart_ID=44", "AVISO", "")
                    Dim ATB = SQL.DLookup("tblSnd_ATB_Nr", "tblSendungen", " tblSnd_ATB_T1= '" & ATAMRN.Trim & "'  and tblSnd_Abfertigungsart_ID=44", "AVISO", "")

                    If ATB <> "" Then
                        TextBox1.Text = ATB

                        'Überschreiben mit ATB-Barcode
                        Dim barcodeATB As Image = Code128Rendering.MakeBarcodeImage(ATB, 1, True, 20)
                        picBarcodeMRN.Image = barcodeATB
                        picBarcodeMRN.Visible = True
                        picBarcodeMRN.Location = New PointF(picBarcodeMRN.Location.X - 0.5, picBarcodeMRN.Location.Y)

                        ATAMRN = "(" & ATAMRN & ")"
                        txtATAMRN.Font = New GrapeCity.ActiveReports.Document.Drawing.Font("Microsoft Sans Serif", 10, GrapeCity.ActiveReports.Document.Drawing.FontStyle.Regular) ' kleiner schreiben


                    End If
                End If
            Catch ex As Exception
                MsgBox(ex.Message & ex.StackTrace)
            End Try

            txtATAMRN.Text = ATAMRN



            txtNr.Text = cnt
            cnt += 1
        End If
    End Sub
    Private Sub rptAuswertung_ReportStart(sender As System.Object, e As System.EventArgs) Handles MyBase.ReportStart
        Dim dt As New DataTable
        dt.Columns.Add("MRN", System.Type.GetType("System.String"))
        For Each s In VP
            dt.Rows.Add({s.vp_Nr})
        Next
        Me.DataSource = dt
    End Sub

End Class
