This commit is contained in:
2024-06-07 13:34:29 +02:00
parent 45969993fb
commit b8f878be4c
6 changed files with 94 additions and 60 deletions

View File

@@ -3,6 +3,9 @@ Imports System.Globalization
Imports System.IO
Imports System.Reflection
Imports System.Text.RegularExpressions
Imports DocumentFormat.OpenXml.Bibliography
Imports DocumentFormat.OpenXml.EMMA
Imports DocumentFormat.OpenXml.VariantTypes
Imports VERAG_PROG_ALLGEMEIN
Public Class cUTA
@@ -11,9 +14,20 @@ Public Class cUTA
Public Function clearimporttable() As Boolean
If Not SQL.doSQL("DELETE tblUTAImport.* FROM tblUTAImport") Then Return False
Return SQL.doSQL("DELETE FROM tblUTAImport", "FMZOLL")
End Function
Public Function importUTALeistungen() As Boolean
'Einträge in tblUTALeistungen machen, wenn Fakturierwarenart und Lieferland noch nicht in der Tabelle enthalten sind.
Dim query = "INSERT INTO tblUTALeistungen (Fakturierwarenart, Lieferland, VERAG_OffertenNr, VERAG_LeistungsNr )
Select Case tblUTAImport.Fakturierwarenart, tblUTAImport.Lieferland, tblUTAFakturierwarenarten.VERAG_OffertenNr, tblUTAFakturierwarenarten.VERAG_LeistungsNr
From tblUTAImport INNER Join tblUTAFakturierwarenarten On tblUTAImport.Fakturierwarenart = tblUTAFakturierwarenarten.Fakturierwarenart
Group By tblUTAImport.Fakturierwarenart, tblUTAImport.Lieferland, tblUTAFakturierwarenarten.VERAG_OffertenNr, tblUTAFakturierwarenarten.VERAG_LeistungsNr
HAVING((((SELECT tblUTALeistungen.Fakturierwarenart FROM tblUTALeistungen WHERE tblUTALeistungen.Fakturierwarenart=tblUTAImport.Fakturierwarenart And tblUTALeistungen.Lieferland=tblUTAImport.Lieferland)) Is Null))"
Return SQL.doSQL(query, "FMZOLL")
End Function
@@ -219,7 +233,7 @@ Public Class cUTA
Property Akzeptanz_Medium As String
Property Steuerkategorie As String
Property UTA_Beleg_ID As String
Property UTA_Normalbeleg_ID As Integer
Property UTA_Normalbeleg_ID As String
Property Gebühren_Bescheinigung_von As DateTime
Property Gebühren_Bescheinigung_bis As DateTime
Property Herausgeber_Nutzer_Nummer As String
@@ -290,7 +304,6 @@ Public Class cUTA
list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("Informationsbeleg", Informationsbeleg))
list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("Belegherkunft", Belegherkunft))
list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("Filler_Feld_46", Filler_Feld_46))
list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("Darstellwährung_ISO", Darstellwährung_ISO))
list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("Einzelpreis_Brutto_in_Lieferlandwährung_mit_4_Nachkommastellen", Einzelpreis_Brutto_in_Lieferlandwährung_mit_4_Nachkommastellen))
list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("Einzelpreis_Netto_in_Lieferlandwährung_mit_4_Nachkommastellen", Einzelpreis_Netto_in_Lieferlandwährung_mit_4_Nachkommastellen))
list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("Rechnungsdatum", Rechnungsdatum))
@@ -418,10 +431,6 @@ Public Class cUTA
Return ""
End Function
End Class
Public Class UTAArchiv
@@ -502,8 +511,8 @@ Public Class cUTA
Property Filler_Feld_72 As String
Property Akzeptanz_Medium As String
Property Steuerkategorie As String
Property UTA_Beleg_ID As Integer
Property UTA_Normalbeleg_ID As Integer
Property UTA_Beleg_ID As String
Property UTA_Normalbeleg_ID As String
Property Gebühren_Bescheinigung_von As DateTime
Property Gebühren_Bescheinigung_bis As DateTime
Property Herausgeber_Nutzer_Nummer As String
@@ -513,16 +522,16 @@ Public Class cUTA
Property Steuerliches_Lieferland As String
Property Steuerliche_Produktgruppe As String
Property Leistungsort_verlagerbar As Char
Property UStVAn_ID As Integer
Property UStVAn_ID As String
Public hasEntry = False
Dim SQL As New VERAG_PROG_ALLGEMEIN.SQL
Sub New(Belegdatum, UStVAn_ID)
Sub New(Belegdatum, UTA_Beleg_ID)
Me.Belegdatum = Belegdatum
Me.UStVAn_ID = UStVAn_ID
Me.UTA_Beleg_ID = UTA_Beleg_ID
LOAD()
End Sub
Function getParameterList() As List(Of VERAG_PROG_ALLGEMEIN.SQLVariable)
@@ -574,7 +583,6 @@ Public Class cUTA
list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("Informationsbeleg", Informationsbeleg))
list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("Belegherkunft", Belegherkunft))
list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("Filler_Feld_46", Filler_Feld_46))
list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("Darstellwährung_ISO", Darstellwährung_ISO))
list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("Einzelpreis_Brutto_in_Lieferlandwährung_mit_4_Nachkommastellen", Einzelpreis_Brutto_in_Lieferlandwährung_mit_4_Nachkommastellen))
list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("Einzelpreis_Netto_in_Lieferlandwährung_mit_4_Nachkommastellen", Einzelpreis_Netto_in_Lieferlandwährung_mit_4_Nachkommastellen))
list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("Rechnungsdatum", Rechnungsdatum))
@@ -623,7 +631,7 @@ Public Class cUTA
Dim list As List(Of VERAG_PROG_ALLGEMEIN.SQLVariable) = getParameterList()
'Dim sqlstr = " BEGIN TRAN If EXISTS(Select * FROM CLFArchiv WHERE PKFileName=@PKFileName AND OBUID = @OBUID) " &
Dim sqlstr = " BEGIN TRAN If EXISTS(Select * FROM tblUTAArchiv WHERE UStVAn_ID = @UStVAn_ID AND Belegdatum = @Belegdatum) " &
Dim sqlstr = " BEGIN TRAN If EXISTS(Select * FROM tblUTAArchiv WHERE UTA_Beleg_ID = @UTA_Beleg_ID AND Belegdatum = @Belegdatum) " &
" BEGIN " & getUpdateCmd() & " End " &
" Else " &
" BEGIN " & getInsertCmd() & " End " &
@@ -636,8 +644,8 @@ Public Class cUTA
Try
hasEntry = False
Using conn As SqlConnection = SQL.GetNewOpenConnectionFMZOLL()
Using cmd As New SqlCommand("Select * FROM tblUTAArchiv WHERE UStVAn_ID = @UStVAn_ID AND Belegdatum = @Belegdatum ", conn)
cmd.Parameters.AddWithValue("@UStVAn_ID", UStVAn_ID)
Using cmd As New SqlCommand("Select * FROM tblUTAArchiv WHERE UTA_Beleg_ID = @UTA_Beleg_ID AND Belegdatum = @Belegdatum ", conn)
cmd.Parameters.AddWithValue("@UTA_Beleg_ID", UTA_Beleg_ID)
cmd.Parameters.AddWithValue("@Belegdatum", Belegdatum)
Dim dr = cmd.ExecuteReader()
If dr.Read Then
@@ -674,7 +682,7 @@ Public Class cUTA
End If
Next
str = str.Substring(0, str.Length - 1) 'wg. ','
Return (" UPDATE [tblUTAArchiv] SET " & str & " WHERE UStVAn_ID = @UStVAn_ID AND Belegdatum = @Belegdatum")
Return (" UPDATE [tblUTAArchiv] SET " & str & " WHERE UTA_Beleg_ID = @UTA_Beleg_ID AND Belegdatum = @Belegdatum")
Catch ex As Exception
VERAG_PROG_ALLGEMEIN.cErrorHandler.ERR(ex.Message, ex.StackTrace, System.Reflection.MethodBase.GetCurrentMethod.Name)
@@ -737,20 +745,20 @@ Public Class cUTA
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 Übertragungsnummer=@Übertragungsnummer AND ErstellDatumUhrzeit=@ErstellDatumUhrzeit) " &
Dim sqlstr = " BEGIN TRAN If EXISTS(Select * FROM tblUTATrailer WHERE Übertragungsnummer=@Übertragungsnummer AND ErstellDatumUhrzeit=@ErstellDatumUhrzeit) " &
" BEGIN " & getUpdateCmd() & " End " &
" Else " &
" BEGIN " & getInsertCmd() & " End " &
" commit tran "
Return SQL.doSQLVarList(sqlstr, "FMZoll", , list)
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 CLFTrailer WHERE Übertragungsnummer=@Übertragungsnummer AND ErstellDatumUhrzeit=@ErstellDatumUhrzeit", conn)
Using cmd As New SqlCommand("Select * FROM tblUTATrailer WHERE Übertragungsnummer=@Übertragungsnummer AND ErstellDatumUhrzeit=@ErstellDatumUhrzeit", conn)
cmd.Parameters.AddWithValue("@Übertragungsnummer", Übertragungsnummer)
cmd.Parameters.AddWithValue("@ErstellDatumUhrzeit", ErstellDatumUhrzeit)
Dim dr = cmd.ExecuteReader()
@@ -788,7 +796,7 @@ Public Class cUTA
End If
Next
str = str.Substring(0, str.Length - 1) 'wg. ','
Return (" UPDATE [UTATrailer] SET " & str & " WHERE Übertragungsnummer=@Übertragungsnummer AND ErstellDatumUhrzeit=@ErstellDatumUhrzeit")
Return (" UPDATE [tblUTATrailer] SET " & str & " WHERE Übertragungsnummer=@Übertragungsnummer AND ErstellDatumUhrzeit=@ErstellDatumUhrzeit")
Catch ex As Exception
VERAG_PROG_ALLGEMEIN.cErrorHandler.ERR(ex.Message, ex.StackTrace, System.Reflection.MethodBase.GetCurrentMethod.Name)
@@ -810,7 +818,7 @@ Public Class cUTA
Next
str = str.Substring(0, str.Length - 1) 'wg. ','
values = values.Substring(0, values.Length - 1) 'wg. ','
Return (" INSERT INTO CLFTrailer (" & str & ") VALUES(" & values & ") ")
Return (" INSERT INTO tblUTATrailer (" & str & ") VALUES(" & values & ") ")
Catch ex As Exception
VERAG_PROG_ALLGEMEIN.cErrorHandler.ERR(ex.Message, ex.StackTrace, System.Reflection.MethodBase.GetCurrentMethod.Name)
End Try
@@ -831,17 +839,17 @@ Public Class cUTA
SERVERPath = Me.FTP_PFAD
Dim catchedFiles As Boolean = False
For Each f In io.Directory.GetFiles(SERVERPath)
Dim fi As New io.FileInfo(f)
For Each f In IO.Directory.GetFiles(SERVERPath)
Dim fi As New IO.FileInfo(f)
If fi.Name.ToUpper.Contains(fileType) Then
If Not fi.Name.StartsWith(".") Then
Dim zielPfad = VERARBEITUNG_PFAD & "\" & fi.Name
While io.File.Exists(zielPfad)
While IO.File.Exists(zielPfad)
zielPfad = VERARBEITUNG_PFAD & "\" & "DOPPELT" & "\" & fi.Name.Replace(fi.Extension, "") & fi.Extension & Now.ToString("_yyyyMMdd_HHmmss")
End While
io.File.Copy(f, zielPfad)
If io.File.Exists(zielPfad) Then
io.File.Delete(f)
IO.File.Copy(f, zielPfad)
If IO.File.Exists(zielPfad) Then
IO.File.Delete(f)
catchedFiles = True
End If
@@ -1181,13 +1189,12 @@ Public Class cUTA
Case "90"
If curChecksumme < 0 Then
curChecksumme = 0 - curChecksumme
End If
If Trim(Mid(strZeile, 16, 18) / 100) <> curChecksumme Then
MsgBox("Checksumme: " & Trim(Mid(strZeile, 16, 18) / 100) & vbCrLf & "Prüfsumme: " & curChecksumme & vbCrLf & "Datei kann wegen Prüfsummenfehler nicht verarbeitet werden")
Return False
'Return False
End If
@@ -1210,12 +1217,10 @@ Public Class cUTA
Loop
objFileRead.Close()
Return True
End Function
Public VERARBEITUNG_PFAD
Public ARCHIV_PFAD
Public ERROR_PFAD