Imports GrapeCity.ActiveReports 
Imports GrapeCity.ActiveReports.Document

Public Class rptSDLAbrechnungsblatt
    Public sdlNr As Integer = -1
    Public sdlText As String = ""
    Public KdNr As Integer = -1
    Public fahrer As Boolean = False
    Public KUNDE As cKundenFMZOLL
    Public cSqlDb As New cSqlDb
    Public datum As Date = Now
    Public sachbearbeiter As String
    Public Sprache As String = "DE"
    Public ds = Nothing
    Private Sub rptAuswertung_ReportStart(sender As System.Object, e As System.EventArgs) Handles MyBase.ReportStart
        If KdNr <= 0 Then MsgBox("Keine Kunden-Nr angegeben!") : Exit Sub
        ' If sdlNr <= 0 Then Exit Sub

        Dim kundenSQL As New kundenSQL
        Dim sqlStr As String = " SELECT  [KfzKennzeichen] ,SDLNr, " &
                              "  cast(CASE [SDLNr] " &
                              "       WHEN '207'      THEN 'FREJUS'   " &
                              "       WHEN '100'      THEN 'IDS'" &
                              "       WHEN '202'      THEN 'IT'  " &
                              "       WHEN '208'      THEN 'MSE' " &
                              "       WHEN '211'      THEN 'MULTI' " &
                              "       WHEN '210'      THEN 'SI' " &
                              "       WHEN '212'      THEN 'UTA' " &
                              "       WHEN '213'      THEN 'HUGO' " &
                              "       Else '-' " &
                              "   END /*+ '  ' + isnull([OBUID],'')*/ as VARCHAR(300)) AS KARTEBOX " &
                              " ,[KartenNr],[PIN] " &
                      " FROM [SDL] " &
                      " WHERE KundenNr = " & KdNr & " AND SDLNr = " & sdlNr &
                      "    and Bestelldatum = '" & datum.ToShortDateString & "'"


        Dim order As String = " ORDER BY KfzKennzeichen,SDLNr, Bestelldatum, BestellNr,Ausstellungsdatum,KartenNr,OBUID"



        Me.DataSource = kundenSQL.loadSQLDataAdapterBySqlWithoutReadonlyProblem(sqlStr & order, "SDL")


        KUNDE = kundenSQL.getKundeFMZOLLByKdNr(KdNr)

        lblFirma.Text = KUNDE.Name_1 & vbNewLine &
                        IIf(KUNDE.Name_2 <> "", KUNDE.Name_2 & vbNewLine, "") &
                        KUNDE.Straße & vbNewLine & vbNewLine &
                        KUNDE.LandKz & " " & KUNDE.PLZ & " " & KUNDE.Ort

        lblKdNr.Text = KUNDE.KundenNr
        Label12.Text = sachbearbeiter
        Label7.Text = Me.DataSource.Rows.Count & " Karten"

    End Sub



    Dim dummycount As Integer = 0
    Private Sub Detail1_Format(sender As System.Object, e As System.EventArgs) Handles Detail.Format
        dummycount += 1

        lblKennzeichen.Text = cSqlDb.checkNullStr(Fields.Item("KfzKennzeichen").Value)
        lblKarteBox.Text = cSqlDb.checkNullStr(Fields.Item("KARTEBOX").Value)


        'Abwechselnd grauen und weißen Hintergrund
        If (dummycount Mod 2) = 0 Then
            Shape.BackColor = System.Drawing.Color.White
        Else
            Shape.BackColor = System.Drawing.Color.WhiteSmoke
        End If
    End Sub



End Class
