Feature_SDL_Klassen angepasst.

This commit is contained in:
2022-10-19 08:07:37 +02:00
parent d801077830
commit ca38d26017
2 changed files with 16 additions and 5 deletions

View File

@@ -0,0 +1,141 @@
Imports System.Data.SqlClient
Imports System.Reflection
Public Class cGesamtsicherheitsPositionen
Property gsp_gspPosId As Integer
Property gsp_gsId As Object = Nothing
Property gsp_warenwert As Object = Nothing
Property gsp_sicherheitsbetrag As Object = Nothing
Property gsp_freitext As Object = Nothing
Property gsp_art As Object = Nothing
Property gsp_avisoId As Object = Nothing
Property gsp_ust As Object = Nothing
Property gsp_filialenNr As Object = Nothing
Property gsp_abfertigungsNr As Object = Nothing
Property gsp_ATCNr As Object = Nothing
Property gsp_MRNNr As Object = Nothing
Public hasEntry = False
Dim SQL As New SQL
Sub New(gsp_gspPosId)
Me.gsp_gspPosId = gsp_gspPosId
LOAD()
End Sub
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("gsp_gspPosId", gsp_gspPosId,, True))
list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("gsp_gsId", gsp_gsId))
list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("gsp_warenwert", gsp_warenwert))
list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("gsp_sicherheitsbetrag", gsp_sicherheitsbetrag))
list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("gsp_freitext", gsp_freitext))
list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("gsp_art", gsp_art))
list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("gsp_avisoId", gsp_avisoId))
list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("gsp_ust", gsp_ust))
list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("gsp_filialenNr", gsp_filialenNr))
list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("gsp_abfertigungsNr", gsp_abfertigungsNr))
list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("gsp_ATCNr", gsp_ATCNr))
list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("gsp_MRNNr", gsp_MRNNr))
Return list
End Function
Public Function SAVE() As Boolean
Dim list As List(Of VERAG_PROG_ALLGEMEIN.SQLVariable) = getParameterList()
Dim sqlstr = " BEGIN TRAN IF EXISTS(SELECT * FROM [tblGesamtsicherheitsPositionen] WHERE gsp_gspPosId=@gsp_gspPosId AND gsp_gsId=@gsp_gsId ) " &
" BEGIN " & getUpdateCmd() & " END " &
" Else " &
" BEGIN " & getInsertCmd() & " END " &
" commit tran "
Return SQL.doSQLVarList(sqlstr, "FMZOLL", , list)
End Function
Public Sub LOAD()
Try
hasEntry = False
Using conn As SqlConnection = SQL.GetNewOpenConnectionFMZOLL()
Using cmd As New SqlCommand("SELECT * FROM [tblGesamtsicherheitsPositionen] WHERE gsp_gspPosId=@gsp_gspPosId AND gsp_gsId=@gsp_gsId ", conn)
cmd.Parameters.AddWithValue("@gsp_gspPosId", gsp_gspPosId)
cmd.Parameters.AddWithValue("@gsp_gsId", gsp_gsId)
Dim dr = cmd.ExecuteReader()
If dr.Read Then
For Each li In getParameterList()
Dim propInfo As PropertyInfo = Me.GetType.GetProperty(li.Scalarvariable)
If dr.Item(li.Text) Is DBNull.Value Then
propInfo.SetValue(Me, Nothing)
Else
propInfo.SetValue(Me, dr.Item(li.Text))
End If
Next
hasEntry = True
End If
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 getUpdateCmd() As String
Try
Dim list As List(Of VERAG_PROG_ALLGEMEIN.SQLVariable) = getParameterList()
Dim str As String = ""
For Each i In list
If Not i.isPrimaryParam Then
str &= "[" & i.Text & "] = @" & i.Scalarvariable & "," '.Replace("-", "").Replace(" ", "") & ","
End If
Next
str = str.Substring(0, str.Length - 1) 'wg. ','
Return (" UPDATE [[tblGesamtsicherheitsPositionen]] SET " & str & " WHERE gsp_gspPosId=@gsp_gspPosId AND gsp_gsId=@gsp_gsId")
Catch ex As Exception
MsgBox("Fehler in der Funktion '" & System.Reflection.MethodInfo.GetCurrentMethod.Name & "'" & vbNewLine & vbNewLine & ex.Message & vbNewLine & vbNewLine & ex.StackTrace)
End Try
Return ""
End Function
Public Function getInsertCmd() As String
Try
Dim list As List(Of VERAG_PROG_ALLGEMEIN.SQLVariable) = getParameterList()
Dim str As String = ""
Dim values As String = ""
For Each i In list
If Not i.isPrimaryParam Then
str &= "[" & i.Text & "],"
values &= "@" & i.Scalarvariable & "," '.Replace("-", "").Replace(" ", "") & ","
End If
Next
str = str.Substring(0, str.Length - 1) 'wg. ','
values = values.Substring(0, values.Length - 1) 'wg. ','
Return (" INSERT INTO [tblGesamtsicherheitsPositionen] (" & str & ") VALUES(" & values & ") ")
Catch ex As Exception
MsgBox("Fehler in der Funktion '" & System.Reflection.MethodInfo.GetCurrentMethod.Name & "'" & vbNewLine & vbNewLine & ex.Message & vbNewLine & vbNewLine & ex.StackTrace)
End Try
Return ""
End Function
End Class