161 lines
6.3 KiB
VB.net
161 lines
6.3 KiB
VB.net
|
|
|
|
Imports System.Data.SqlClient
|
|
Imports System.Reflection
|
|
|
|
Public Class cHandlingssaetzeInternLIST
|
|
Property hs_Bezeichnung As Object = Nothing
|
|
Property hs_datum 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, hs_datum)
|
|
Me.hs_Bezeichnung = hs_Bezeichnung
|
|
Me.hs_datum = hs_datum
|
|
' Me.OffertenNr = OffertenNr
|
|
LOAD_LIST_DATUM(Me.hs_Bezeichnung, Me.hs_datum)
|
|
End Sub
|
|
|
|
Sub New(hs_Bezeichnung)
|
|
Me.hs_Bezeichnung = hs_Bezeichnung
|
|
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)
|
|
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
|
|
|
|
|
|
Public Sub LOAD_LIST_DATUM(hs_Bezeichnung, ab_datum)
|
|
|
|
Dim SQLString = ";WITH cte AS (
|
|
SELECT *,
|
|
ROW_NUMBER() OVER
|
|
(
|
|
PARTITION BY
|
|
hs_Bezeichnung,
|
|
hs_Abfertigungsart
|
|
|
|
ORDER BY
|
|
hs_gueltigAbDatum DESC
|
|
) AS rn
|
|
|
|
FROM tblHandlingssaetzeIntern
|
|
|
|
WHERE isnull(hs_gueltigAbDatum,'01-01-2021') <= @Stichtag AND hs_Bezeichnung = @hs_Bezeichnung
|
|
)
|
|
|
|
SELECT
|
|
hs_Bezeichnung,
|
|
hs_Abfertigungsart,
|
|
hs_Preis,
|
|
hs_gueltigAbDatum,
|
|
hs_RgVon,
|
|
hs_RgAn
|
|
FROM cte
|
|
WHERE rn = 1
|
|
ORDER BY
|
|
hs_Bezeichnung,
|
|
hs_Abfertigungsart desc;"
|
|
|
|
Try
|
|
LIST.Clear()
|
|
Using conn As SqlConnection = SQL.GetNewOpenConnectionFMZOLL()
|
|
Using cmd As New SqlCommand(SQLString, conn)
|
|
cmd.Parameters.AddWithValue("@hs_Bezeichnung", hs_Bezeichnung)
|
|
cmd.Parameters.AddWithValue("@Stichtag", CDate(ab_datum))
|
|
' 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
|