Files
SDL/SDL/Classes/cRKSV_POS.vb
2024-10-02 08:59:41 +00:00

172 lines
7.3 KiB
VB.net

Imports System.Data.SqlClient
Imports System.Reflection
Public Class cRKSV_POS
Dim SQL As New VERAG_PROG_ALLGEMEIN.SQL
Property pos_Id As Integer
Property pos_bezeichnung As String
Property pos_aktiv As Object = Nothing
Property pos_kasse As Object = Nothing
Property pos_kassennr As Object = Nothing
Property pos_com As Object = Nothing
Property pos_baudrate As Object = Nothing
Property pos_comspeed As Object = Nothing
Property pos_comstop As Object = Nothing
Property pos_ip As Object = Nothing
Property pos_port As Object = Nothing
Property pos_typ As Object = Nothing
Property pos_lizenz As Object = Nothing
Property pos_kassendruck As Object = Nothing
Property pos_demoausdruck As Object = Nothing
Property pos_demodummyausdruck As Object = Nothing
Property pos_pin As Object = Nothing
Property pos_händerbeleg_drucken As Object = Nothing
Property pos_storno As Object = Nothing
Property pos_wartezeit As Object = Nothing
Property pos_FIBU As Object = Nothing
Property pos_XML As Object = Nothing
Property pos_Protokollpfad As Object = Nothing
Public hasEntry = False
Public Sub New(pos_Id, pos_kasse)
Me.pos_Id = pos_Id
Me.pos_kasse = pos_kasse
LOAD()
End Sub
Public Sub New(pos_bezeichnung As String, pos_kasse As Integer, pos_aktiv As Boolean)
Me.pos_bezeichnung = pos_bezeichnung
Me.pos_kasse = pos_kasse
Me.pos_aktiv = pos_aktiv
SAVE()
End Sub
Public Sub New(pos_bezeichnung As String)
Me.pos_bezeichnung = pos_bezeichnung
LOAD()
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("pos_Id", pos_Id,, True))
list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("pos_bezeichnung", pos_bezeichnung))
list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("pos_aktiv", pos_aktiv))
list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("pos_kasse", pos_kasse))
list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("pos_kassennr", pos_kassennr))
list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("pos_com", pos_com))
list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("pos_baudrate", pos_baudrate))
list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("pos_comspeed", pos_comspeed))
list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("pos_comstop", pos_comstop))
list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("pos_ip", pos_ip))
list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("pos_port", pos_port))
list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("pos_typ", pos_typ))
list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("pos_lizenz", pos_lizenz))
list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("pos_kassendruck", pos_kassendruck))
list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("pos_demoausdruck", pos_demoausdruck))
list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("pos_demodummyausdruck", pos_demodummyausdruck))
list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("pos_pin", pos_pin))
list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("pos_händerbeleg_drucken", pos_händerbeleg_drucken))
list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("pos_storno", pos_storno))
list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("pos_wartezeit", pos_wartezeit))
list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("pos_FIBU", pos_FIBU))
list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("pos_XML", pos_XML))
list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("pos_Protokollpfad", pos_Protokollpfad))
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 tblRKSV_POS WHERE pos_Id=@pos_Id) " &
" 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 tblRKSV_POS WHERE pos_Id=@pos_Id ", conn)
cmd.Parameters.AddWithValue("@pos_Id", pos_Id)
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 [tblRKSV_POS] SET " & str & " WHERE pos_Id=@pos_Id ")
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 tblRKSV_POS (" & 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
Public Sub delete()
SQL.doSQL("delete from [tblRKSV_POS] where pos_Id = '" & pos_Id & "' ", "FMZOLL")
End Sub
End Class