Files
SDL/_VERAG_PROG_ALLGEMEIN/Classes/cParameter.vb

106 lines
3.7 KiB
VB.net

Imports System.Data.SqlClient
Imports System.Reflection
Public Class cParameterList
Property ProgId As Object = Nothing
Property firma As Object = Nothing
' Property OffertenNr As Object = Nothing
Public LIST As New List(Of cParameter)
Dim SQL As New SQL
'Dim listTodelete As New List(Of cOfferte)
Sub New(ProgId)
Me.ProgId = ProgId
' Me.OffertenNr = OffertenNr
LOAD_LIST(Me.ProgId)
End Sub
Sub New(ProgId, firma)
Me.ProgId = ProgId
Me.firma = firma
' Me.OffertenNr = OffertenNr
LOAD_LIST(Me.ProgId, Me.firma)
End Sub
Public Sub CLEAR()
LIST.Clear()
End Sub
Public Sub ADD(eb_EMail As String, Optional cc As Boolean = False, Optional bcc As Boolean = False)
' Dim l As New cOfferte
'l.eb_bcc = bcc
'LIST.Add(l)
End Sub
Public Sub LOAD_LIST(KundenNr, Optional firma = Nothing)
Try
LIST.Clear()
Using conn As SqlConnection = SQL.GetNewOpenConnectionADMIN
Using cmd As New SqlCommand("SELECT * FROM [tblParameter] WHERE progId IN (0,@ProgId) " & If(firma IsNot Nothing, " AND firma=@firma", ""), conn)
cmd.Parameters.AddWithValue("@ProgId", ProgId)
cmd.Parameters.AddWithValue("@firma", firma)
' cmd.Parameters.AddWithValue("@OffertenNr", OffertenNr)
Dim dr = cmd.ExecuteReader()
While dr.Read
Dim l As New cParameter
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
Public Function GET_PARAMETER_VALUE(param As String) As String
For Each p In LIST
If p.bezeichnung = param Then
Return p.wert
End If
Next
Return ""
End Function
Public Function GET_PARAMETER_VALUE_BOOL(param As String) As Boolean
For Each p In LIST
If p.bezeichnung = param Then
Return (p.wert = "1" Or p.wert = "true")
End If
Next
Return False
End Function
End Class
Public Class cParameter
Property Id As Integer
Property bezeichnung As String
Property wert As String
Property firma As Object = Nothing
Property beschreibung As Object = Nothing
Property progId 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("Id", Id,, True, True))
list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("bezeichnung", bezeichnung))
list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("wert", wert))
list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("firma", firma))
list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("beschreibung", beschreibung))
list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("progId", progId))
Return list
End Function
End Class