102 lines
3.9 KiB
VB.net
102 lines
3.9 KiB
VB.net
Imports System.Data.SqlClient
|
|
Imports System.Reflection
|
|
|
|
Public Class cAsfinagMaut
|
|
|
|
Property cardnumber As Object = Nothing
|
|
Property licenceplate As Object = Nothing
|
|
Property turnoverdate As Object = Nothing
|
|
Property contractPartner As Object = Nothing
|
|
Property netAmount As Object = Nothing
|
|
Property VATamount As Object = Nothing
|
|
Property totalAmount As Object = Nothing
|
|
Property additionalData As Object = Nothing
|
|
Property receiptnumber As Object = Nothing
|
|
|
|
|
|
Public hasEntry = False
|
|
|
|
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("cardnumber", cardnumber))
|
|
list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("licenceplate", licenceplate))
|
|
list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("turnoverdate", turnoverdate))
|
|
list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("contractPartner", contractPartner))
|
|
list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("netAmount", netAmount))
|
|
list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("VATamount", VATamount))
|
|
list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("totalAmount", totalAmount))
|
|
list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("additionalData", additionalData))
|
|
list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("receiptnumber", receiptnumber))
|
|
Return list
|
|
End Function
|
|
|
|
|
|
|
|
Public Function SAVE() As Boolean
|
|
Dim list As List(Of VERAG_PROG_ALLGEMEIN.SQLVariable) = getParameterList()
|
|
|
|
Dim sqlstr = " BEGIN TRAN " &
|
|
" 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 tblAsfinagMaut WHERE cardnumber=@cardnumber ", conn)
|
|
cmd.Parameters.AddWithValue("@cardnumber", cardnumber)
|
|
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
|
|
VERAG_PROG_ALLGEMEIN.cErrorHandler.ERR(ex.Message, ex.StackTrace, System.Reflection.MethodInfo.GetCurrentMethod.Name)
|
|
End Try
|
|
End Sub
|
|
|
|
|
|
|
|
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 tblAsfinagMaut (" & str & ") VALUES(" & values & ") ")
|
|
Catch ex As Exception
|
|
VERAG_PROG_ALLGEMEIN.cErrorHandler.ERR(ex.Message, ex.StackTrace, System.Reflection.MethodInfo.GetCurrentMethod.Name)
|
|
End Try
|
|
Return ""
|
|
End Function
|
|
|
|
|
|
End Class
|