
Imports System.Data.SqlClient
Imports System.Reflection

Public Class cUSTVAntrag

    Property UStVAn_ID As Integer
    Property UStVAn_KuNr As Object = Nothing '                   INT            Not NULL,
    Property UStVAn_Name As Object = Nothing '                   NVARCHAR(80)  NULL,
    Property UStVAn_Straße As Object = Nothing '                 NVARCHAR(40)  NULL,
    Property UStVAn_LandKz As Object = Nothing '                 NVARCHAR(3)   NULL,
    Property UStVAn_PLZ As Object = Nothing '                    NVARCHAR(7)   NULL,
    Property UStVAn_Ort As Object = Nothing '                    NVARCHAR(40)  NULL,
    Property UStVAn_Land As Object = Nothing '                   NVARCHAR(22)  NULL,
    Property UStVAn_Gewerbe As Object = Nothing '                NVARCHAR(50)  NULL,
    Property UStVAn_Steuernummer As Object = Nothing '           NVARCHAR(20)  NULL,
    Property UStVAn_ReDatVon As Object = Nothing '               DATETIME       Not NULL,
    Property UStVAn_ReDatBis As Object = Nothing '               DATETIME       Not NULL,
    Property UStVAn_Bankverbindung As Object = Nothing '         NVARCHAR(50)  NULL,
    Property UStVAn_BLZ As Object = Nothing '                    NVARCHAR(8)   NULL,
    Property UStVAn_KTO As Object = Nothing '                    NVARCHAR(12)  NULL,
    Property UStVAn_Kontoinhaber As Object = Nothing '           NVARCHAR(50)  NULL,
    Property UStVAn_BIC As Object = Nothing '                    NVARCHAR(11)  NULL,
    Property UStVAn_IBAN As Object = Nothing '                   NVARCHAR(27)  NULL,
    Property UStVAn_Anlagen As Object = Nothing '                SMALLINT       NULL,
    Property UStVAn_Rechnungen As Object = Nothing '             SMALLINT       NULL,
    Property UStVAn_Einfuhrdokumente As Object = Nothing '       SMALLINT       NULL,
    Property UStVAn_Erklärung_9_a As Object = Nothing '          NVARCHAR(50)  NULL,
    Property UStVAn_Erklärung_9_b_1 As Object = Nothing '        BIT            Default ((0)) Not NULL,
    Property UStVAn_Erklärung_9_b_2 As Object = Nothing '        BIT            Default ((0)) Not NULL,
    Property UStVAn_Erklärung_9_b_3 As Object = Nothing '        BIT            Default ((0)) Not NULL,
    Property UStVAn_Ausstellungsort As Object = Nothing '        NVARCHAR(20)  NULL,
    Property UStVAn_Ausstellungsdatum As Object = Nothing '      DATETIME       NULL,
    Property UStVAn_Unterschrift As Object = Nothing '           NVARCHAR(20)  NULL,
    Property UStVAn_LandNr As Object = Nothing '                 SMALLINT       Default ((38)) Not NULL,
    Property UStVAn_Beleganzahl As Object = Nothing '            SMALLINT       NULL,
    Property UStVAn_BeleganzahlRetourniert As Object = Nothing ' SMALLINT       NULL,
    Property UStVAn_Retournierungsgrund As Object = Nothing '    NVARCHAR(255) NULL,
    Property UStVAn_AntragEingereichtAm As Object = Nothing '    DATETIME       NULL,
    Property UStVAn_BelegeWeitergeleitetAm As Object = Nothing ' DATETIME       NULL,
    Property UStVAn_Vertreter As Object = Nothing '              INT            NULL,
    Property UStVAn_BezugsNr As Object = Nothing '               NVARCHAR(35)  NULL,
    Property UStVAn_3470 As Object = Nothing '                   MONEY          NULL,
    Property UStVAn_VZBetrag As Object = Nothing '               MONEY          NULL,
    Property UStVAn_VZDatum As Object = Nothing '                DATETIME       NULL,
    Property UStVAn_RZBetragVZ As Object = Nothing '             MONEY          NULL,
    Property UStVAn_RZDatumVZ As Object = Nothing '              DATETIME       NULL,
    Property FilialenNr As Object = Nothing '                    SMALLINT       NULL,
    Property AbfertigungsNr As Object = Nothing '                INT            NULL,
    Property UStVAn_Währungscode As Object = Nothing '           NVARCHAR(3)   NULL,
    Property UStVAn_USteuerbetrag As Object = Nothing '          MONEY          Default ((0)) NULL,
    Property UStVAn_Erstattungsbetrag As Object = Nothing '      MONEY          Default ((0)) NULL,
    Property UStVAn_USteuerbetragEUR As Object = Nothing '       MONEY          Default ((0)) NULL,
    Property UStVAn_ErstattungsbetragEUR As Object = Nothing '   MONEY          Default ((0)) NULL,
    Property UStVAn_Sachbearbeiter As Object = Nothing '         NVARCHAR(15)  NULL,
    Property UStVAn_Zeitstempel As Object = Nothing '            DATETIME       Default (getdate()) NULL,
    Property UStVAn_Status As Object = Nothing
    Property UStVAn_StatusText As Object = Nothing

    Property POSITIONEN As New List(Of cUStVPositionen) '= Nothing

    Dim SQL As New SQL

    Sub New()
    End Sub
    Sub New(UStVAn_ID)
        Me.UStVAn_ID = UStVAn_ID
        LOAD(UStVAn_ID)
    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("UStVAn_ID", UStVAn_ID,, True))
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("UStVAn_KuNr", UStVAn_KuNr)) '                   INT            Not NULL,
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("UStVAn_Name", UStVAn_Name)) '                   NVARCHAR(80)  NULL,
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("UStVAn_Straße", UStVAn_Straße)) '                 NVARCHAR(40)  NULL,
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("UStVAn_LandKz", UStVAn_LandKz)) '                 NVARCHAR(3)   NULL,
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("UStVAn_PLZ", UStVAn_PLZ)) '                    NVARCHAR(7)   NULL,
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("UStVAn_Ort", UStVAn_Ort)) '                    NVARCHAR(40)  NULL,
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("UStVAn_Land", UStVAn_Land)) '                   NVARCHAR(22)  NULL,
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("UStVAn_Gewerbe", UStVAn_Gewerbe)) '                NVARCHAR(50)  NULL,
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("UStVAn_Steuernummer", UStVAn_Steuernummer)) '           NVARCHAR(20)  NULL,
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("UStVAn_ReDatVon", UStVAn_ReDatVon)) '               DATETIME       Not NULL,
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("UStVAn_ReDatBis", UStVAn_ReDatBis)) '               DATETIME       Not NULL,
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("UStVAn_Bankverbindung", UStVAn_Bankverbindung)) '         NVARCHAR(50)  NULL,
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("UStVAn_BLZ", UStVAn_BLZ)) '                    NVARCHAR(8)   NULL,
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("UStVAn_KTO", UStVAn_KTO)) '                    NVARCHAR(12)  NULL,
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("UStVAn_Kontoinhaber", UStVAn_Kontoinhaber)) '           NVARCHAR(50)  NULL,
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("UStVAn_BIC", UStVAn_BIC)) '                    NVARCHAR(11)  NULL,
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("UStVAn_IBAN", UStVAn_IBAN)) '                   NVARCHAR(27)  NULL,
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("UStVAn_Anlagen", UStVAn_Anlagen)) '                SMALLINT       NULL,
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("UStVAn_Rechnungen", UStVAn_Rechnungen)) '             SMALLINT       NULL,
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("UStVAn_Einfuhrdokumente", UStVAn_Einfuhrdokumente)) '       SMALLINT       NULL,
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("UStVAn_Erklärung_9_a", UStVAn_Erklärung_9_a)) '          NVARCHAR(50)  NULL,
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("UStVAn_Erklärung_9_b_1", UStVAn_Erklärung_9_b_1)) '        BIT            Default ((0)) Not NULL,
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("UStVAn_Erklärung_9_b_2", UStVAn_Erklärung_9_b_2)) '        BIT            Default ((0)) Not NULL,
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("UStVAn_Erklärung_9_b_3", UStVAn_Erklärung_9_b_3)) '        BIT            Default ((0)) Not NULL,
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("UStVAn_Ausstellungsort", UStVAn_Ausstellungsort)) '        NVARCHAR(20)  NULL,
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("UStVAn_Ausstellungsdatum", UStVAn_Ausstellungsdatum)) '      DATETIME       NULL,
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("UStVAn_Unterschrift", UStVAn_Unterschrift)) '           NVARCHAR(20)  NULL,
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("UStVAn_LandNr", UStVAn_LandNr)) '                 SMALLINT       Default ((38)) Not NULL,
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("UStVAn_Beleganzahl", UStVAn_Beleganzahl)) '            SMALLINT       NULL,
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("UStVAn_BeleganzahlRetourniert", UStVAn_BeleganzahlRetourniert)) ' SMALLINT       NULL,
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("UStVAn_Retournierungsgrund", UStVAn_Retournierungsgrund)) '    NVARCHAR(255) NULL,
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("UStVAn_AntragEingereichtAm", UStVAn_AntragEingereichtAm)) '    DATETIME       NULL,
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("UStVAn_BelegeWeitergeleitetAm", UStVAn_BelegeWeitergeleitetAm)) ' DATETIME       NULL,
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("UStVAn_Vertreter", UStVAn_Vertreter)) '              INT            NULL,
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("UStVAn_BezugsNr", UStVAn_BezugsNr)) '               NVARCHAR(35)  NULL,
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("UStVAn_3470", UStVAn_3470)) '                   MONEY          NULL,
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("UStVAn_VZBetrag", UStVAn_VZBetrag)) '               MONEY          NULL,
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("UStVAn_VZDatum", UStVAn_VZDatum)) '                DATETIME       NULL,
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("UStVAn_RZBetragVZ", UStVAn_RZBetragVZ)) '             MONEY          NULL,
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("UStVAn_RZDatumVZ", UStVAn_RZDatumVZ)) '              DATETIME       NULL,
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("FilialenNr", FilialenNr)) '                    SMALLINT       NULL,
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("AbfertigungsNr", AbfertigungsNr)) '                INT            NULL,
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("UStVAn_Währungscode", UStVAn_Währungscode)) '           NVARCHAR(3)   NULL,
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("UStVAn_USteuerbetrag", UStVAn_USteuerbetrag)) '          MONEY          Default ((0)) NULL,
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("UStVAn_Erstattungsbetrag", UStVAn_Erstattungsbetrag)) '      MONEY          Default ((0)) NULL,
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("UStVAn_USteuerbetragEUR", UStVAn_USteuerbetragEUR)) '       MONEY          Default ((0)) NULL,
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("UStVAn_ErstattungsbetragEUR", UStVAn_ErstattungsbetragEUR)) '   MONEY          Default ((0)) NULL,
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("UStVAn_Sachbearbeiter", UStVAn_Sachbearbeiter)) '         NVARCHAR(15)  NULL,
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("UStVAn_Zeitstempel", UStVAn_Zeitstempel)) '            DATETIME       Default (getdate()) NULL,
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("UStVAn_Status", UStVAn_Status)) '            DATETIME       Default (getdate()) NULL,
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("UStVAn_StatusText", UStVAn_StatusText)) '            DATETIME       Default (getdate()) NULL,


        Return list
    End Function

    Public Sub LOAD(UStVAn_ID, Optional loadPos = True)
        Try
            POSITIONEN.Clear()
            Using conn As SqlConnection = SQL.GetNewOpenConnectionFMZOLL()
                Using cmd As New SqlCommand("SELECT * FROM tblUStVAntrag WHERE UStVAn_ID=@UStVAn_ID ", conn)
                    cmd.Parameters.AddWithValue("@UStVAn_ID", UStVAn_ID)
                    Dim dr = cmd.ExecuteReader()
                    If dr.Read Then
                        'Dim l As New cOfferte
                        For Each i In getParameterList()
                            Dim propInfo As PropertyInfo = Me.GetType.GetProperty(i.Scalarvariable)
                            If dr.Item(i.Text) Is DBNull.Value Then
                                propInfo.SetValue(Me, Nothing)
                            Else
                                propInfo.SetValue(Me, dr.Item(i.Text))
                            End If
                        Next
                        If loadPos Then LOAD_POSITIONEN()
                    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 Sub LOAD_POSITIONEN()
        Try
            POSITIONEN.Clear()
            Using conn As SqlConnection = SQL.GetNewOpenConnectionFMZOLL()
                Using cmd As New SqlCommand("SELECT * FROM tblUStVPositionen WHERE UStVAn_ID=@UStVAn_ID  ", conn)
                    cmd.Parameters.AddWithValue("@UStVAn_ID", Me.UStVAn_ID)
                    Dim dr = cmd.ExecuteReader()
                    While dr.Read
                        Dim l As New cUStVPositionen
                        For Each i In l.getParameterList()
                            Dim propInfo As PropertyInfo = l.GetType.GetProperty(i.Scalarvariable)
                            If dr.Item(i.Text) Is DBNull.Value Then
                                propInfo.SetValue(l, Nothing)
                            Else
                                propInfo.SetValue(l, dr.Item(i.Text))
                            End If
                        Next
                        POSITIONEN.Add(l)
                    End While
                    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 INSERT() As Boolean
        Dim list As List(Of VERAG_PROG_ALLGEMEIN.SQLVariable) = getParameterList()
        Return SQL.doSQLVarList(getInsertCmd, "FMZOLL", , list)
    End Function

    Public Function SAVE() As Boolean

        Dim sqlstr = " BEGIN TRAN IF EXISTS(SELECT * FROM tblUStVAntrag WITH(updlock,serializable) WHERE UStVAn_ID=@UStVAn_ID ) " &
                       " BEGIN " & getUpdateCmd() & " END " &
                       " Else " &
                       " BEGIN " & getInsertCmd() & " END " &
                       " commit tran "
        Dim list As List(Of VERAG_PROG_ALLGEMEIN.SQLVariable) = getParameterList()

        Return SQL.doSQLVarList(sqlstr, "FMZOLL", , list)
    End Function


    Public Function getInsertCmd() As String
        Try
            'Me.Eingegeben_am = Now
            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 tblUStVAntrag  (" & 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 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 [tblUStVAntrag] SET " & str & " WHERE UStVAn_ID=@UStVAn_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 getMaxPosNr() As Integer
        Try
            Dim maxPosNr = -1

            Return SQL.getValueTxtBySql("SELECT isnull(max([UStVPo_ID]),0)+1 FROM [tblUStVPositionen] where UStVAn_ID='" & UStVAn_ID & "'", "FMZOLL",,, "1")

        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 -1
    End Function


End Class


Public Class cUStVPositionen

    Property UStVAn_ID As Integer
    Property UStVPo_ID As Integer
    Property UStVPo_ReDat As Object = Nothing '                DATETIME       NULL,
    Property UStVPo_ReNr As Object = Nothing '                 NVARCHAR(20)  NULL,
    Property UStVPo_USteuerbetrag As Object = Nothing '        MONEY          Not NULL,
    Property UStVPo_Leistungsbezeichnung As Object = Nothing ' NVARCHAR(255) NULL,
    Property UStVPo_Leistender As Object = Nothing '           NVARCHAR(65)  NULL,
    Property UStVPo_Schnittstelle As Object = Nothing '        BIT            Default ((0)) Not NULL,
    Property UStVPo_SchnittstellenNr As Object = Nothing '     SMALLINT       Default ((0)) Not NULL,
    Property UStVPo_Umrechnungskurs As Object = Nothing '      FLOAT(53)     NULL,
    Property UStVPo_USteuerbetragEUR As Object = Nothing '     MONEY          NULL,
    Property UStVPo_Sachbearbeiter As Object = Nothing '       NVARCHAR(15)  NULL,
    Property UStVPo_Zeitstempel As Object = Nothing '          DATETIME       Default (getdate()) NULL,

    Dim SQL As New SQL

    Sub New(UStVAn_ID, UStVPo_ID)
        Me.UStVAn_ID = UStVAn_ID
        Me.UStVPo_ID = UStVPo_ID

        LOAD(UStVAn_ID, UStVPo_ID)
    End Sub
    Sub New()

    End Sub


    Public Sub LOAD(UStVAn_ID, UStVPo_ID)
        Try

            Using conn As SqlConnection = SQL.GetNewOpenConnectionFMZOLL()
                Using cmd As New SqlCommand("SELECT * FROM [tblUStVPositionen] WHERE UStVAn_ID=@UStVAn_ID AND UStVPo_ID=@UStVPo_ID ", conn)
                    cmd.Parameters.AddWithValue("@UStVAn_ID", UStVAn_ID)
                    cmd.Parameters.AddWithValue("@UStVPo_ID", UStVPo_ID)
                    Dim dr = cmd.ExecuteReader()
                    If dr.Read Then
                        'Dim l As New cOfferte
                        For Each i In getParameterList()
                            Dim propInfo As PropertyInfo = Me.GetType.GetProperty(i.Scalarvariable)
                            If dr.Item(i.Text) Is DBNull.Value Then
                                propInfo.SetValue(Me, Nothing)
                            Else
                                propInfo.SetValue(Me, dr.Item(i.Text))
                            End If
                        Next

                    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 SAVE() As Boolean
        Dim list As List(Of VERAG_PROG_ALLGEMEIN.SQLVariable) = getParameterList()

        Dim sqlstr = " BEGIN TRAN IF EXISTS(SELECT * FROM tblUStVPositionen  WHERE UStVAn_ID=@UStVAn_ID AND UStVPo_ID=@UStVPo_ID) " &
                       " BEGIN " & getUpdateCmd() & " END " &
                       " Else " &
                       " BEGIN " & getInsertCmd() & " END " &
                       " commit tran "

        Return SQL.doSQLVarList(sqlstr, "FMZOLL", , list)
    End Function

    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 [tblUStVPositionen] SET " & str & " WHERE UStVAn_ID=@UStVAn_ID AND UStVPo_ID=@UStVPo_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



    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("UStVAn_ID", UStVAn_ID))
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("UStVPo_ID", UStVPo_ID))
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("UStVPo_ReDat", UStVPo_ReDat))
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("UStVPo_ReNr", UStVPo_ReNr))
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("UStVPo_USteuerbetrag", UStVPo_USteuerbetrag))
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("UStVPo_Leistungsbezeichnung", UStVPo_Leistungsbezeichnung))
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("UStVPo_Leistender", UStVPo_Leistender))
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("UStVPo_Schnittstelle", UStVPo_Schnittstelle))
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("UStVPo_SchnittstellenNr", UStVPo_SchnittstellenNr))
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("UStVPo_Umrechnungskurs", UStVPo_Umrechnungskurs))
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("UStVPo_USteuerbetragEUR", UStVPo_USteuerbetragEUR))
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("UStVPo_Sachbearbeiter", UStVPo_Sachbearbeiter))
        list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("UStVPo_Zeitstempel", UStVPo_Zeitstempel))
        Return list
    End Function

    Public Function INSERT() As Boolean
        Dim list As List(Of VERAG_PROG_ALLGEMEIN.SQLVariable) = getParameterList()
        Return SQL.doSQLVarList(getInsertCmd, "FMZOLL", , list)
    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 tblUStVPositionen  (" & 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
