
Imports System.Data.SqlClient
Imports System.Reflection




Public Class cSDLLeistung
    Property KundenNr As Integer
    Property KfzKennzeichen As String = ""
    Property SDLNr As Integer
    Property History As Integer


    Public LIST As New List(Of VERAG_PROG_ALLGEMEIN.cSDL)
    Dim SQL As New SQL
    'Dim listTodelete As New List(Of cOfferte)

    Sub New(KundenNr, KfzKennzeichen, SDLNr)
        Me.KundenNr = KundenNr
        Me.KfzKennzeichen = KfzKennzeichen
        Me.SDLNr = SDLNr

        LOAD_LIST()
    End Sub
    Public Sub CLEAR()
        LIST.Clear()
    End Sub


    Public Sub LOAD_LIST()
        Try
            LIST.Clear()
            Using conn As SqlConnection = cSqlDb.GetNewOpenConnection()
                Using cmd As New SqlCommand("SELECT * FROM SDL WHERE KundenNr=@KundenNr AND KfzKennzeichen=@KfzKennzeichen AND SDLNr=@SDLNr AND  AND History=@History ", conn)
                    cmd.Parameters.AddWithValue("@KundenNr", KundenNr)
                    cmd.Parameters.AddWithValue("@KfzKennzeichen", KfzKennzeichen)
                    cmd.Parameters.AddWithValue("@SDLNr", SDLNr)
                    Dim dr = cmd.ExecuteReader()
                    While dr.Read
                        Dim l As New VERAG_PROG_ALLGEMEIN.cSDL(dr.Item("KundenNr"), dr.Item("KfzKennzeichen"), dr.Item("SDLNr"), dr.Item("History"))
                        LIST.Add(l)
                    End While
                    dr.Close()
                End Using
            End Using
        Catch ex As Exception
            MsgBox("Fehler in der Funktion '" & System.Reflection.MethodInfo.GetCurrentMethod.Name & "'" & vbNewLine & vbNewLine & ex.Message & vbNewLine & vbNewLine & ex.StackTrace)
        End Try
    End Sub

    Function SAVE() As Boolean
        SAVE = True
        For Each l In LIST
            If Not l.SAVE() Then SAVE = False
        Next
    End Function
    'Function SAVE()
    '    If SQL.doSQLVarList("DELETE FROM tblEmailBenachrichtigung WHERE eb_KundenNr=" & Me.eb_KundenNr & " and eb_ebartId=" & Me.eb_ebartId & " ", "SDL") Then
    '        For Each l In LIST
    '            If Not l.INSERT() Then Return False
    '        Next
    '       Return True
    '    Else
    '       Return False
    '   End If
    'End Function
End Class

