Imports System.Data.SqlClient Imports System.Reflection Public Class cZollTarifAtlas_LIST Property LIST As New List(Of cZollTarifAtlas) Dim SQL As New SQL Sub New() LOAD_LIST() End Sub Public Sub LOAD_LIST() Try LIST.Clear() Using conn As SqlConnection = SQL.GetNewOpenConnectionATLAS() Using cmd As New SqlCommand("SELECT * FROM [ezttxt] WHERE [ezttxt_datend] >= getdate() ORDER BY [ezttxt_code] ", conn) Dim dr = cmd.ExecuteReader() While dr.Read Dim l As New cZollTarifAtlas 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 getFullTxt(WCNR As cZollTarifAtlas) As String getFullTxt = WCNR.ezttxt_text Dim index = getIndexInList(WCNR.ezttxt_code) 'Dim hirachie = WCNR.ezttxt_hirnr For hirachie = WCNR.ezttxt_hirnr To 0 Step -1 'so oft bis alle Hirachieebenen durchgelaufen sind For i = index To 0 Step -1 If LIST(i).ezttxt_hirnr = (hirachie - 1) Then getFullTxt = WCNR.ezttxt_text & " " & getFullTxt index = i End If Next Next End Function Function getFullTxtByCode(code As String) As String Dim WCNR As cZollTarifAtlas = getFromList(code) If WCNR Is Nothing Then Return "" getFullTxtByCode = WCNR.ezttxt_text Dim index = getIndexInList(WCNR.ezttxt_code) If index < 0 Then Return "" If WCNR.ezttxt_hirnr > 0 Then For hirachie = CInt(WCNR.ezttxt_hirnr) To 0 Step -1 'so oft bis alle Hirachieebenen durchgelaufen sind For i = index To 0 Step -1 If LIST(i).ezttxt_hirnr = (hirachie - 1) Then getFullTxtByCode = LIST(i).ezttxt_text & " " & getFullTxtByCode index = i Exit For End If Next Next End If End Function Function getIndexInList(code) As Integer For Each i In LIST If i.ezttxt_code.trim = code.trim Then Return LIST.IndexOf(i) End If Next Return -1 End Function Function getFromList(code) As cZollTarifAtlas For Each i In LIST If i.ezttxt_code = code Then Return i End If Next Return Nothing End Function End Class Public Class cZollTarifAtlas Property ezttxt_code As Object = Nothing Property ezttxt_hirnr As Object = Nothing Property ezttxt_cdesid As Object = Nothing Property ezttxt_datbeg As Object = Nothing Property ezttxt_datend As Object = Nothing Property ezttxt_txtart As Object = Nothing Property ezttxt_text As Object = Nothing Property ezttxt_edat As Object = Nothing Property ezttxt_adat As Object = Nothing Property ezttxt_sb As Object = Nothing 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("ezttxt_code", ezttxt_code)) list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("ezttxt_hirnr", ezttxt_hirnr)) list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("ezttxt_cdesid", ezttxt_cdesid)) list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("ezttxt_datbeg", ezttxt_datbeg)) list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("ezttxt_datend", ezttxt_datend)) list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("ezttxt_txtart", ezttxt_txtart)) list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("ezttxt_text", ezttxt_text)) list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("ezttxt_edat", ezttxt_edat)) list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("ezttxt_adat", ezttxt_adat)) list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("ezttxt_sb", ezttxt_sb)) Return list End Function End Class