Fakturierung Prüfung bereits fakt.; EUST separieren; Spire PDF

This commit is contained in:
2023-07-18 09:26:21 +02:00
parent d0657deda8
commit 2c562c6adb
13 changed files with 434 additions and 291 deletions

View File

@@ -6,6 +6,7 @@ Imports Ghostscript.NET.Processor
Imports System.Runtime.InteropServices
Imports System.Windows.Forms
Imports System.Drawing
Imports Spire.Pdf.Print
Public Class cDATENSERVER
@@ -36,7 +37,8 @@ Public Class cDATENSERVER
LOADById()
End Sub
Sub New(da_kategorie, da_ordner, da_uOrdner1, da_uOrdner2, da_uOrdner3, da_name, Optional da_KundenNr = 0)
Me.rootDir = DATENVERVER_OPTIONS.initRootDir()
@@ -51,7 +53,7 @@ Public Class cDATENSERVER
LOAD()
End Sub
Sub New(da_kategorie, da_ordner, da_uOrdner1, da_uOrdner2, da_uOrdner3, da_name, da_KundenNr, da_multifiles)
Me.rootDir = DATENVERVER_OPTIONS.initRootDir()
Me.da_KundenNr = da_KundenNr
@@ -104,7 +106,7 @@ Public Class cDATENSERVER
Using conn As SqlConnection = SQL.GetNewOpenConnectionFMZOLL()
'MsgBox("SELECT * FROM tblDatenarchiv WHERE da_KundenNr = '" & Me.da_KundenNr & "' And da_kategorie = '" & Me.da_kategorie & "' And da_ordner ='" & Me.da_ordner & "' AND da_uOrdner1= '" & Me.da_uOrdner1 & "' AND da_uOrdner2= '" & Me.da_uOrdner2 & "' AND da_uOrdner3= '" & Me.da_uOrdner3 & "' AND da_name='" & Me.da_name & "' ")
Using cmd As New SqlCommand("SELECT * FROM tblDatenarchiv WHERE da_KundenNr = @da_KundenNr AND da_kategorie = @da_kategorie AND da_ordner=@da_ordner AND da_uOrdner1= @da_uOrdner1 AND da_uOrdner2= @da_uOrdner2 AND da_uOrdner3= @da_uOrdner3 AND da_name=@da_name ", conn)
cmd.Parameters.AddWithValue("@da_KundenNr", Me.da_KundenNr)
cmd.Parameters.AddWithValue("@da_KundenNr", Me.da_KundenNr)
' cmd.Parameters.AddWithValue("@da_vorlage", Me.da_vorlage)
cmd.Parameters.AddWithValue("@da_kategorie", Me.da_kategorie)
cmd.Parameters.AddWithValue("@da_ordner", Me.da_ordner)
@@ -1102,13 +1104,13 @@ Public Class cFormularManager
Dim sPrinters As ArrayList
If VERAG_PROG_ALLGEMEIN.cAllgemein.PRINTER_LIST IsNot Nothing Then
sPrinters = VERAG_PROG_ALLGEMEIN.cAllgemein.PRINTER_LIST
Else
sPrinters = New ArrayList
For Each sPrinter As String In System.Drawing.Printing.PrinterSettings.InstalledPrinters
sPrinters.Add(sPrinter)
Next
End If
sPrinters = VERAG_PROG_ALLGEMEIN.cAllgemein.PRINTER_LIST
Else
sPrinters = New ArrayList
For Each sPrinter As String In System.Drawing.Printing.PrinterSettings.InstalledPrinters
sPrinters.Add(sPrinter)
Next
End If
If VERAG_PROG_ALLGEMEIN.cAllgemein.PRINTER_STANDARD <> String.Empty Then
@@ -1135,11 +1137,18 @@ Public Class cFormularManager
Dim doc As New Spire.Pdf.PdfDocument(pdfPath)
doc.PageSettings.Size = Spire.Pdf.PdfPageSize.A4
doc.PrintDocument.DefaultPageSettings.Landscape = True
doc.PageScaling = Spire.Pdf.PdfPrintPageScaling.FitSize
doc.PrinterName = printerName
doc.PrintDocument.Print()
doc.PageSettings.Orientation = Spire.Pdf.PdfPageOrientation.Landscape
doc.PrintSettings.SelectSinglePageLayout(PdfSinglePageScalingMode.FitSize, True)
doc.PrintSettings.PrinterName = printerName
doc.Print()
'doc.PrintDocument.DefaultPageSettings.Landscape = True
'doc.PageScaling = Spire.Pdf.PdfPrintPageScaling.FitSize
'doc.PrinterName = printerName
'doc.PrintDocument.Print()
'Dim doc As New Spire.Pdf.PdfDocument
@@ -1231,10 +1240,16 @@ Public Class cFormularManager
Dim doc As Spire.Pdf.PdfDocument = New Spire.Pdf.PdfDocument(stream)
If doc IsNot Nothing Then
doc.PageSettings.Size = Spire.Pdf.PdfPageSize.A4
doc.PrintDocument.DefaultPageSettings.Landscape = True
doc.PageScaling = Spire.Pdf.PdfPrintPageScaling.FitSize
doc.PrinterName = printerName
doc.PrintDocument.Print()
'doc.PrintDocument.DefaultPageSettings.Landscape = True
'doc.PageScaling = Spire.Pdf.PdfPrintPageScaling.FitSize
'doc.PrinterName = printerName
'doc.PrintDocument.Print()
doc.PageSettings.Orientation = Spire.Pdf.PdfPageOrientation.Landscape
doc.PrintSettings.SelectSinglePageLayout(PdfSinglePageScalingMode.FitSize, True)
doc.PrintSettings.PrinterName = printerName
doc.Print()
End If
End Using
End Using
@@ -1266,8 +1281,11 @@ Public Class cFormularManager
doc.LoadFromHTML(URL, True, True, True)
If doc IsNot Nothing Then
doc.PageSettings.Size = Spire.Pdf.PdfPageSize.A4
doc.PrintDocument.DefaultPageSettings.Landscape = True
doc.PageScaling = Spire.Pdf.PdfPrintPageScaling.FitSize
' doc.PrintDocument.DefaultPageSettings.Landscape = True
'doc.PageScaling = Spire.Pdf.PdfPrintPageScaling.FitSize
doc.PageSettings.Orientation = Spire.Pdf.PdfPageOrientation.Landscape
doc.PrintSettings.SelectSinglePageLayout(PdfSinglePageScalingMode.FitSize, True)
' doc.PrinterName = printerName
' doc.PrintDocument.Print()
doc.SaveToFile(targetPath)
@@ -1724,7 +1742,7 @@ Public Class DATENVERVER_OPTIONS
TMP_PATH = Path.GetTempPath() & "\VERAG\DatenTMP\"
End If
' If Not IO.Directory.Exists(TMP_PATH) Then IO.Directory.CreateDirectory(TMP_PATH)
' If Not IO.Directory.Exists(TMP_PATH) Then IO.Directory.CreateDirectory(TMP_PATH)
Dim TMP_PATH2 = TMP_PATH & If(unterOrdner <> "", "\" & unterOrdner & "\", "")
TMP_PATH2 = TMP_PATH2.replace("\\", "\")
@@ -1873,72 +1891,64 @@ Public Class DATENVERVER_OPTIONS
Try
If kdnr Is Nothing Then MsgBox("Keine Kundennummer angegeben!") : Return ""
If ordner Is Nothing Then MsgBox("Kein Ordner angegeben!") : Return ""
Dim dateiName = ""
If Not onlyordner Then
If bezeichnung Is Nothing Then MsgBox("Keine Bezeichnung angegeben!") : Return ""
dateiName = Now.ToString("yyyyMMdd_HHmmss_") & bezeichnung
End If
Dim dateiName = ""
If Not onlyordner Then
If bezeichnung Is Nothing Then MsgBox("Keine Bezeichnung angegeben!") : Return ""
dateiName = Now.ToString("yyyyMMdd_HHmmss_") & bezeichnung
End If
Dim kdnr_path = ""
If kdnr IsNot Nothing AndAlso IsNumeric(kdnr) AndAlso kdnr > 0 Then
kdnr_path = kdnr
End If
If kdnr IsNot Nothing AndAlso IsNumeric(kdnr) AndAlso kdnr > 0 Then
kdnr_path = kdnr
End If
If kategorie <> "" Then
Dim dir = ""
dir &= rootDir
dir &= kategorie & "\"
dir &= If(ordner IsNot Nothing AndAlso ordner <> "", ordner & "\", "")
dir &= If(kdnr_path <> "", kdnr_path & "\", "")
dir &= If(da_uOrdner1 IsNot Nothing AndAlso da_uOrdner1 <> "", da_uOrdner1 & "\", "")
dir &= If(da_uOrdner2 IsNot Nothing AndAlso da_uOrdner2 <> "", da_uOrdner2 & "\", "")
dir &= If(da_uOrdner3 IsNot Nothing AndAlso da_uOrdner3 <> "", da_uOrdner3 & "\", "")
If Not onlyordner Then
Dim dir = ""
dir &= rootDir
dir &= kategorie & "\"
dir &= If(ordner IsNot Nothing AndAlso ordner <> "", ordner & "\", "")
dir &= If(kdnr_path <> "", kdnr_path & "\", "")
dir &= If(da_uOrdner1 IsNot Nothing AndAlso da_uOrdner1 <> "", da_uOrdner1 & "\", "")
dir &= If(da_uOrdner2 IsNot Nothing AndAlso da_uOrdner2 <> "", da_uOrdner2 & "\", "")
dir &= If(da_uOrdner3 IsNot Nothing AndAlso da_uOrdner3 <> "", da_uOrdner3 & "\", "")
If Not onlyordner Then
If Not IO.Directory.Exists(dir) Then
IO.Directory.CreateDirectory(dir)
End If
Dim zusatz = "" : Dim zusatzcnt = 1
While IO.File.Exists(dir & dateiName & zusatz & If(bezeichnung.ToString.EndsWith(endung), "", endung))
zusatz = "_" & zusatzcnt
zusatzcnt += 1
End While
While IO.File.Exists(dir & dateiName & zusatz & If(bezeichnung.ToString.EndsWith(endung), "", endung))
zusatz = "_" & zusatzcnt
zusatzcnt += 1
End While
dir &= dateiName & zusatz & If(bezeichnung.ToString.EndsWith(endung), "", endung)
End If
End If
Return dir
Else
If Not onlyordner Then
If Not IO.Directory.Exists(rootDir & "DOKUMENTE\KEINE_ZUORDNUNG\" & kdnr_path & "\") Then IO.Directory.CreateDirectory(rootDir & "DOKUMENTE\KEINE_ZUORDNUNG\" & kdnr_path & "\")
Else
If Not onlyordner Then
If Not IO.Directory.Exists(rootDir & "DOKUMENTE\KEINE_ZUORDNUNG\" & kdnr_path & "\") Then IO.Directory.CreateDirectory(rootDir & "DOKUMENTE\KEINE_ZUORDNUNG\" & kdnr_path & "\")
End If
Return rootDir & "DOKUMENTE\KEINE_ZUORDNUNG\" & kdnr_path & "\" & dateiName
End If
Return rootDir & "DOKUMENTE\KEINE_ZUORDNUNG\" & kdnr_path & "\" & dateiName
End If
Catch ex As Exception
VERAG_PROG_ALLGEMEIN.cErrorHandler.ERR(ex.Message, "Fehler in der Funktion '" & System.Reflection.MethodInfo.GetCurrentMethod.Name & "'" & vbNewLine & vbNewLine & ex.Message & vbNewLine & vbNewLine & ex.StackTrace, System.Reflection.MethodInfo.GetCurrentMethod.Name)
Return ""
VERAG_PROG_ALLGEMEIN.cErrorHandler.ERR(ex.Message, "Fehler in der Funktion '" & System.Reflection.MethodInfo.GetCurrentMethod.Name & "'" & vbNewLine & vbNewLine & ex.Message & vbNewLine & vbNewLine & ex.StackTrace, System.Reflection.MethodInfo.GetCurrentMethod.Name)
Return ""
End Try
End Function
Shared Function OPEN_PATH(path As String) As Boolean
Try
If Not IO.File.Exists(path) Then MsgBox("Die Datei existiert nicht") : Return False
Dim fi As New IO.DirectoryInfo(path)
Dim destPath = DATENVERVER_OPTIONS.getTMPPath(fi.Name, fi.Extension, , False)
IO.File.Copy(path, destPath, True)
Process.Start(destPath)
Return True
Catch ex As Exception
MsgBox(ex.Message & ex.StackTrace)
Return False
End Try
End Function
Public Shared Function getPDFViaSpirePDF_FromFile(File As String, Optional targetPath As String = "") As String
Try
If targetPath = "" Then targetPath = TMP_PATH
@@ -1949,8 +1959,10 @@ Public Class DATENVERVER_OPTIONS
'doc.LoadFromFile(File)
If doc IsNot Nothing Then
doc.PageSettings.Size = Spire.Pdf.PdfPageSize.A4
doc.PrintDocument.DefaultPageSettings.Landscape = True
doc.PageScaling = Spire.Pdf.PdfPrintPageScaling.FitSize
' doc.PrintDocument.DefaultPageSettings.Landscape = True
' doc.PageScaling = Spire.Pdf.PdfPrintPageScaling.FitSize
doc.PageSettings.Orientation = Spire.Pdf.PdfPageOrientation.Landscape
doc.PrintSettings.SelectSinglePageLayout(PdfSinglePageScalingMode.FitSize, True)
' doc.PrinterName = printerName
' doc.PrintDocument.Print()
doc.SaveToFile(targetPath)