Imports System.Data.SqlClient Imports System.Reflection Imports DocumentFormat.OpenXml.VariantTypes Public Class cAsfinag Public Class CLFHeader Property PKFileName As Object = Nothing Property recordType As Integer Property fileVersion As Integer Property fileNumber As Integer Property inidcator As Object = Nothing Property senderID As Object = Nothing Property receiverID As Object = Nothing Property fileCreationDate As Object = Nothing Property fileCreationTime As Object = Nothing Property ISOCountryCode As Object = Nothing Property creationName As Object = Nothing 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("inidcator", inidcator)) 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) 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 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 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 Integer Property fileVersion As Integer Property fileNumber As Integer Property cardNumber As Integer 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 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("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 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 CLFBody WHERE PKFileName=@PKFileName AND filenumber = @filenumber ", 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 [CLFBody] SET " & str & " WHERE PKFileName=@PKFileName AND filenumber = @filenumbere ") 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 CLTrailer Property PKFileName As Object = Nothing Property recordType As Integer 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 _BASE_id=@_BASE_id) " & " 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 AND filenumber = @filenumber ", 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 AND filenumber = @filenumbere ") 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 inidcator As Object = Nothing Property senderID As Object = Nothing Property receiverID As Object = Nothing Property fileCreationDate As Object = Nothing Property fileCreationTime As Object = Nothing Property ISOCountryCode As Object = Nothing 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("inidcator", inidcator)) 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)) 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) 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 Integer Property fileNumber As Integer Property cardNumber As Integer 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 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("siteId", siteId)) 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("fileCreationDate", fileCreationDate)) list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("deliveryNoteNumber", deliveryNoteNumber)) 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("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)) 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 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 TTRBody WHERE PKFileName=@PKFileName AND filenumber = @filenumber ", 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 [TTRBody] SET " & str & " WHERE PKFileName=@PKFileName AND filenumber = @filenumbere ") 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("filenumber", filenumber)) 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 _BASE_id=@_BASE_id) " & " 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 AND filenumber = @filenumber ", 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 AND filenumber = @filenumbere ") 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 End Class