

Imports System.Data.SqlClient
    Imports System.Reflection

Public Class cHandlingssaetzeInternLIST
    Property hs_Bezeichnung As Object = Nothing
    ' Property OffertenNr As Object = Nothing
    Public LIST As New List(Of cHandlingssaetzeIntern)
    Dim SQL As New SQL
    'Dim listTodelete As New List(Of cHandlingssaetzeIntern)

    Sub New(hs_Bezeichnung)
        Me.hs_Bezeichnung = hs_Bezeichnung
        '  Me.OffertenNr = OffertenNr
        LOAD_LIST(Me.hs_Bezeichnung)
    End Sub
    Public Sub CLEAR()
        LIST.Clear()
    End Sub


    Public Sub LOAD_LIST(hs_Bezeichnung)
        Try
            LIST.Clear()
            Using conn As SqlConnection = SQL.GetNewOpenConnectionFMZOLL()
                Using cmd As New SqlCommand("SELECT * FROM tblHandlingssaetzeIntern WHERE hs_Bezeichnung=@hs_Bezeichnung ", conn)
                    cmd.Parameters.AddWithValue("@hs_Bezeichnung", hs_Bezeichnung)
                    '  cmd.Parameters.AddWithValue("@OffertenNr", OffertenNr)
                    Dim dr = cmd.ExecuteReader()
                    While dr.Read
                        Dim l As New cHandlingssaetzeIntern
                        For Each i In l.getParameterList()
                            Dim propInfo As PropertyInfo = l.GetType.GetProperty(i.Scalarvariable)
                            If dr.Item(i.Text) Is DBNull.Value Then
                                propInfo.SetValue(l, Nothing)
                            Else
                                propInfo.SetValue(l, dr.Item(i.Text))
                            End If
                        Next

                        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()
    '    If SQL.doSQLVarList("DELETE FROM tblEmailBenachrichtigung WHERE eb_KundenNr=" & Me.eb_KundenNr & " and eb_ebartId=" & Me.eb_ebartId & " ", "FMZOLL") 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

Public Class cHandlingssaetzeIntern

    Property hs_Bezeichnung As Object = Nothing
    Property hs_RgVon As Object = Nothing
    Property hs_RgAn As Object = Nothing
    Property hs_Abfertigungsart As Object = Nothing
    Property hs_Preis As Object = Nothing

    Dim SQL As New SQL

    Sub New()
    End Sub

    Function getParameterList() As List(Of VERAG_PROG_ALLGEMEIN.SQLVariable)
        Dim list As New List(Of VERAG_PROG_ALLGEMEIN.SQLVariable)
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("hs_Bezeichnung", hs_Bezeichnung))
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("hs_RgVon", hs_RgVon))
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("hs_RgAn", hs_RgAn))
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("hs_Abfertigungsart", hs_Abfertigungsart))
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("hs_Preis", hs_Preis))
        Return list
    End Function


End Class
