Imports System.Data.SqlClient Imports System.Reflection Imports System.Security.Cryptography Imports DocumentFormat.OpenXml.VariantTypes Public Class cAsfinag Public Class CLFHeader Property PKFileName As Object = Nothing Property recordType As String Property fileVersion As Integer Property fileNumber As Integer Property indcator As Object = Nothing Property senderID As Object = Nothing Property receiverID As Object = Nothing Property fileCreationDate As DateTime Property fileCreationTime As DateTime Property ISOCountryCode As Object = Nothing Property creationName As Object = Nothing Public hasEntry = False Dim SQL As New VERAG_PROG_ALLGEMEIN.SQL Sub New(PKFileName, fileNumber) Me.PKFileName = PKFileName Me.fileNumber = fileNumber 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("PKFileName", PKFileName)) list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("fileNumber", fileNumber)) list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("recordType", recordType)) list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("fileVersion", fileVersion)) list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("indcator", indcator)) list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("senderID", senderID)) list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("receiverID", receiverID)) list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("fileCreationDate", fileCreationDate)) list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("fileCreationTime", fileCreationTime)) list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("ISOCountryCode", ISOCountryCode)) list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("creationName", creationName)) 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 CLFHeader WHERE PKFileName=@PKFileName AND fileNumber = @fileNumber) " & " BEGIN " & getUpdateCmd() & " End " & " Else " & " BEGIN " & getInsertCmd() & " End " & " commit tran " Return SQL.doSQLVarList(sqlstr, "ASFINAG", , list) End Function Public Sub LOAD() Try hasEntry = False Using conn As SqlConnection = SQL.GetNewOpenConnectionAsfinag() Using cmd As New SqlCommand("Select * FROM CLFHeader WHERE PKFileName=@PKFileName AND fileNumber = @fileNumber", conn) cmd.Parameters.AddWithValue("@PKFileName", PKFileName) cmd.Parameters.AddWithValue("@filenumber", fileNumber) 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 [CLFHeader] SET " & str & " WHERE PKFileName=@PKFileName ") 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 CLFHeader (" & 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 Public Class CLFBody Property PKFileName As Object = Nothing Property RecordType As String Property fileVersion As Integer Property fileNumber As Integer Property cardNumber As String Property validTo As Integer Property OBUID As Object = Nothing Property vehicleLicensePlate As Object = Nothing Property nationality As Object = Nothing Property vehicleCategory As Object = Nothing Property emissionCategory As Object = Nothing Property status As Object = Nothing Property contractDate As Object = Nothing Property PKLine As Long Public hasEntry = False Dim SQL As New VERAG_PROG_ALLGEMEIN.SQL Sub New(PKFileName, PKLine) Me.PKFileName = PKFileName Me.PKLine = PKLine 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("PKFileName", PKFileName)) list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("PKLine", PKLine)) list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("RecordType", recordType)) list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("fileVersion", fileVersion)) list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("fileNumber", fileNumber)) list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("cardNumber", cardNumber)) list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("validTo", validTo)) list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("OBUID", OBUID)) list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("vehicleLicensePlate", vehicleLicensePlate)) list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("nationality", nationality)) list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("vehicleCategory", vehicleCategory)) list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("emissionCategory", emissionCategory)) list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("status", status)) list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("contractDate", contractDate)) 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 CLFBody WHERE PKFileName=@PKFileName AND PKLine = @PKLine) " & " BEGIN " & getUpdateCmd() & " End " & " Else " & " BEGIN " & getInsertCmd() & " End " & " commit tran " Return SQL.doSQLVarList(sqlstr, "ASFINAG", , list) End Function Public Sub LOAD() Try hasEntry = False Using conn As SqlConnection = SQL.GetNewOpenConnectionAsfinag() Using cmd As New SqlCommand("Select * FROM CLFBody WHERE PKFileName=@PKFileName AND PKLine = @PKLine ", conn) cmd.Parameters.AddWithValue("@PKFileName", PKFileName) cmd.Parameters.AddWithValue("@PKLine", PKLine) 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 [CLFBody] SET " & str & " WHERE PKFileName=@PKFileName AND PKLine = @PKLine ") 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 CLFBody (" & 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 Public Class CLFTrailer Property PKFileName As Object = Nothing Property recordType As String Property fileVersion As Integer Property fileNumber As Integer Property recordCount As Integer Public hasEntry = False Dim SQL As New VERAG_PROG_ALLGEMEIN.SQL Sub New(PKFileName) Me.PKFileName = PKFileName 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("PKFileName", PKFileName)) list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("recordType", recordType)) list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("fileVersion", fileVersion)) list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("fileNumber", fileNumber)) list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("recordCount", recordCount)) 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 CLFTrailer WHERE PKFileName=@PKFileName) " & " BEGIN " & getUpdateCmd() & " End " & " Else " & " BEGIN " & getInsertCmd() & " End " & " commit tran " Return SQL.doSQLVarList(sqlstr, "ASFINAG", , list) End Function Public Sub LOAD() Try hasEntry = False Using conn As SqlConnection = SQL.GetNewOpenConnectionAsfinag() Using cmd As New SqlCommand("Select * FROM CLFTrailer WHERE PKFileName=@PKFileName", conn) cmd.Parameters.AddWithValue("@PKFileName", PKFileName) 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 [CLFTrailer] SET " & str & " WHERE PKFileName=@PKFileName") 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 CLFTrailer (" & 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 Public Class TTRHeader Property PKFileName As Object = Nothing Property recordType As Integer Property fileVersion As Integer Property fileNumber As Integer Property senderID As Object = Nothing Property receiverID As Object = Nothing Property fileCreationDate As DateTime Property fileCreationTime As DateTime Property ISOCountryCode As Object = Nothing Property description As Object = Nothing Property currencyCode As Object = Nothing Public hasEntry = False Dim SQL As New VERAG_PROG_ALLGEMEIN.SQL Sub New(PKFileName, filenummer) Me.PKFileName = PKFileName Me.fileNumber = filenummer 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("PKFileName", PKFileName)) list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("recordType", recordType)) list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("fileVersion", fileVersion)) list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("fileNumber", fileNumber)) list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("senderID", senderID)) list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("receiverID", receiverID)) list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("fileCreationDate", fileCreationDate)) list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("fileCreationTime", fileCreationTime)) list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("ISOCountryCode", ISOCountryCode)) list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("description", description)) list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("currencyCode", currencyCode)) 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 TTRHeader WHERE PKFileName=@PKFileName AND fileNumber = @fileNumber) " & " BEGIN " & getUpdateCmd() & " End " & " Else " & " BEGIN " & getInsertCmd() & " End " & " commit tran " Return SQL.doSQLVarList(sqlstr, "ASFINAG", , list) End Function Public Sub LOAD() Try hasEntry = False Using conn As SqlConnection = SQL.GetNewOpenConnectionAsfinag() Using cmd As New SqlCommand("Select * FROM TTRHeader WHERE PKFileName=@PKFileName AND fileNumber = @fileNumber ", conn) cmd.Parameters.AddWithValue("@PKFileName", PKFileName) cmd.Parameters.AddWithValue("@fileNumber", fileNumber) 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 [TTRHeader] SET " & str & " WHERE PKFileName=@PKFileName AND filenumber = @filenumber") 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 TTRHeader (" & 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 Public Class TTRBody Property PKFileName As Object = Nothing Property recordType As Integer Property fileVersion As Integer Property siteId As String Property fileNumber As Integer Property cardNumber As String Property fileCreationDate As Date Property deliveryNoteNumber As Integer Property deliveryDate As Date Property deliveryTime As Date Property transactionType As Integer Property productCode As Integer Property productQuantity As Double Property amountInclVAT As Double Property VATrate As Double Property VATamount As Double Property PKLine As Integer Property km As Integer Property driverId As Integer Property receiptNumber As String Property OBUID As String Public hasEntry = False Dim SQL As New VERAG_PROG_ALLGEMEIN.SQL Sub New() End Sub Sub New(PKFileName, PKLine) Me.PKFileName = PKFileName Me.PKLine = PKLine 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("PKFileName", PKFileName)) list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("PKLine", PKLine)) list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("fileVersion", fileVersion)) list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("recordType", recordType)) list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("siteId", siteId)) list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("fileNumber", fileNumber)) list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("fileCreationDate", fileCreationDate)) list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("deliveryNoteNumber", deliveryNoteNumber)) list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("cardNumber", cardNumber)) list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("deliveryDate", deliveryDate)) list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("deliveryTime", deliveryTime)) list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("transactionType", transactionType)) list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("productCode", productCode)) list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("km", km)) list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("driverId", driverId)) list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("productQuantity", productQuantity)) list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("amountInclVAT", amountInclVAT)) list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("VATrate", VATrate)) list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("VATamount", VATamount)) list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("receiptNumber", receiptNumber)) list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("OBUID", OBUID)) 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 TTRBody WHERE PKFileName=@PKFileName AND PKLine = @PKLine) " & " BEGIN " & getUpdateCmd() & " End " & " Else " & " BEGIN " & getInsertCmd() & " End " & " commit tran " Return SQL.doSQLVarList(sqlstr, "ASFINAG", , list) End Function Public Sub LOAD() Try hasEntry = False Using conn As SqlConnection = SQL.GetNewOpenConnectionAsfinag() Using cmd As New SqlCommand("Select * FROM TTRBody WHERE PKFileName=@PKFileName AND PKLine = @PKLine ", conn) cmd.Parameters.AddWithValue("@PKFileName", PKFileName) cmd.Parameters.AddWithValue("@PKLine", PKLine) 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 [TTRBody] SET " & str & " WHERE PKFileName=@PKFileName AND PKLine = @PKLine ") 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 TTRBody (" & 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 Public Class TTRTrailer Property PKFileName As Object = Nothing Property recordType As Integer Property fileVersion As Integer Property recordCount As Integer Property checksumProductQuantity As Double Property checksumAmounntInclVAT As Double Public hasEntry = False Dim SQL As New VERAG_PROG_ALLGEMEIN.SQL Sub New(PKFileName) Me.PKFileName = PKFileName 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("PKFileName", PKFileName)) list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("recordType", recordType)) list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("fileVersion", fileVersion)) list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("recordCount", recordCount)) list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("checksumProductQuantity", checksumProductQuantity)) list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("checksumAmounntInclVAT", checksumAmounntInclVAT)) 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 TTRTrailer WHERE PKFileName=@PKFileName) " & " BEGIN " & getUpdateCmd() & " End " & " Else " & " BEGIN " & getInsertCmd() & " End " & " commit tran " Return SQL.doSQLVarList(sqlstr, "ASFINAG", , list) End Function Public Sub LOAD() Try hasEntry = False Using conn As SqlConnection = SQL.GetNewOpenConnectionAsfinag() Using cmd As New SqlCommand("Select * FROM TTRTrailer WHERE PKFileName=@PKFileName", conn) cmd.Parameters.AddWithValue("@PKFileName", PKFileName) 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 [TTRTrailer] SET " & str & " WHERE PKFileName=@PKFileName") 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 TTRTrailer (" & 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 Public Class Paramter Shared SQL As New VERAG_PROG_ALLGEMEIN.SQL Shared Function GET_PARAM_ByName(tcParam_name, TESTSYSTEM) As String Return SQL.getValueTxtBySql("SELECT TOP 1 [Param_value] FROM [tblPartnersystem_Paramter] WHERE Param_system='ASFINAG' AND [Param_name]='" & tcParam_name & "'", , , SQL.GetNewOpenConnectionFMZOLL_SYSTEM(TESTSYSTEM)) End Function End Class Shared Function fktMod10Prüfziffer(strNummer As String) As String ' Der Funktion wird im Feld strNummer der Wert ohne Prüfziffer übergeben. ' Die Funktion berechnet und liefert die Prüfziffer zurück. Dim intIX As Integer Dim intZSum As Integer Dim intSum As Integer Dim boo1 As Boolean For intIX = Len(strNummer) To 1 Step -1 intZSum = IIf(boo1, Mid(strNummer, intIX, 1) * 1, Mid(strNummer, intIX, 1) * 2) If intZSum < 10 Then intSum = intSum + intZSum Else intSum = intSum + ((intZSum Mod 10) + ((intZSum - (intZSum Mod 10)) / 10)) End If boo1 = Not boo1 Next intIX fktMod10Prüfziffer = CStr((10 - (intSum Mod 10)) Mod 10) End Function End Class