MS Module Base StringFunctions

Modules.Jibs Sichtbeleg Anpassung
This commit is contained in:
Developer01
2025-03-14 14:43:11 +01:00
parent 3d388362ec
commit 7c473b9a27
6 changed files with 166 additions and 21 deletions

View File

@@ -138,6 +138,7 @@
<Reference Include="System" />
<Reference Include="System.Configuration" />
<Reference Include="System.Data" />
<Reference Include="System.Drawing" />
<Reference Include="System.IO.Compression" />
<Reference Include="System.Runtime.Serialization" />
<Reference Include="System.ServiceModel" />

View File

@@ -30,5 +30,5 @@ Imports System.Runtime.InteropServices
' Sie können alle Werte angeben oder die standardmäßigen Build- und Revisionsnummern
' übernehmen, indem Sie "*" eingeben:
<Assembly: AssemblyVersion("2.8.1.0")>
<Assembly: AssemblyFileVersion("2.8.1.0")>
<Assembly: AssemblyVersion("2.8.3.0")>
<Assembly: AssemblyFileVersion("2.8.3.0")>

View File

@@ -5,7 +5,8 @@ Imports DigitalData.Modules.Base
Imports DigitalData.Modules.Database
Imports DigitalData.Modules.Logging
Imports GdPicture14
Imports System.Drawing
Imports System.Linq
Public Class XRechnungViewDocument
Private ReadOnly _logger As Logger
Private ReadOnly _logConfig As LogConfig
@@ -69,16 +70,23 @@ Public Class XRechnungViewDocument
MyGDPicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4)
' Dim oCurrent As Integer = MyGDPicturePDF.GetCurrentPage()
Dim yPosition As Integer = Create_PageHeader(False)
Dim yPosition As Single = Create_PageHeader(False)
Create_PageFooter()
Dim oArea As String = ""
Dim oIsPosition As Boolean = False
Dim oPosCount = 0
Dim oPosTerm As String = ""
Dim oPosDesc As String = ""
Dim oCurrencySymbol = ""
Dim oWidthLine = 200
yPosition += 5
Dim font As New Font("Helvetica", 10)
Dim xRight As Integer = 100
Dim oIndex As Integer = 0
Dim oYPlus As Integer = 0
Dim oCreateTextBox As Boolean = False
For Each oRow As DataRow In pDTItemValues.Rows
Dim Y_eq_lastrow As Boolean = CBool(oRow.Item("Y_eq_lastrow"))
Dim oRowCaption As String = oRow.Item("Row_Caption")
@@ -86,6 +94,7 @@ Public Class XRechnungViewDocument
Dim oItemValue As String = oRow.Item("ITEM_VALUE")
Dim oDisplay As Boolean = oRow.Item("Display")
Dim oAreaSwitch As Boolean = False
If oRow.Item("Area") = "INTERNAL" Then
If oItemSPECNAME = "STATIC_Y_SWITCH" Then
yPosition = oItemValue
@@ -113,6 +122,7 @@ Public Class XRechnungViewDocument
If oArea <> oRow.Item("Area") Then
'########## AREA WECHSEL ###########
oAreaSwitch = True
oCreateTextBox = False
oArea = oRow.Item("Area")
_logger.Debug($"Area-Switch to: {oArea}")
Dim oAREACaption As String
@@ -127,6 +137,7 @@ Public Class XRechnungViewDocument
oIsPosition = True
ElseIf oArea = "AMOUNT" Then
oAREACaption = "Beträge / Amounts:"
oCreateTextBox = True
ElseIf oArea = "TAXPOS" Then
oAREACaption = "Steuerbeträge / Tax amounts:"
oIsPosition = True
@@ -139,17 +150,25 @@ Public Class XRechnungViewDocument
If Not oAREACaption = String.Empty Then
'erste Area-Linie
yPosition += 5
MyGDPicturePDF.DrawLine(10, yPosition, 125, yPosition)
MyGDPicturePDF.DrawLine(10, yPosition, oWidthLine, yPosition)
'gdpicturePDF.DrawText(fontResName, 10, yPosition, XRechnungStrings.Seperator_Line)
yPosition += 5
'Area caption
MyGDPicturePDF.DrawText(fontResNameBold, 10, yPosition, oAREACaption)
yPosition += 5
If oArea = "TYPE" Then
MyGDPicturePDF.DrawLine(10, yPosition, 125, yPosition)
MyGDPicturePDF.DrawLine(10, yPosition, oWidthLine, yPosition)
' gdpicturePDF.DrawText(fontResName, 10, yPosition, XRechnungStrings.Seperator_Line)
yPosition += 5
ElseIf oArea = "POSITION" Then
'Tabellendarstellung
MyGDPicturePDF.DrawText(fontResName, 10, yPosition, "Pos#")
MyGDPicturePDF.DrawText(fontResName, 20, yPosition, "Anz./Am.")
MyGDPicturePDF.DrawText(fontResName, 38, yPosition, "Pos.-Text")
MyGDPicturePDF.DrawText(fontResName, 155, yPosition, "Steuer/Tax")
MyGDPicturePDF.DrawText(fontResName, 175, yPosition, "Betrag/Sum")
yPosition += 5
'Tabellendarstellung Ende
End If
End If
If oArea = "TYPE" Then
@@ -162,10 +181,20 @@ Public Class XRechnungViewDocument
oIsPosition = True
If oItemSPECNAME = "INVOICE_POSITION_AMOUNT" Then
oPosCount += 1
oPosTerm = $"{oPosCount}. {oItemValue} * "
oItemValue = oPosTerm
'oPosTerm = $"{oPosCount}. {oItemValue} * "
'oItemValue = oPosTerm
'Tabellendarstellung
oPosTerm = ""
MyGDPicturePDF.DrawText(fontResName, 10, yPosition, oPosCount)
'
'Dim otextBoxYPos As Integer = yPosition - 3.5
'MyGDPicturePDF.DrawTextBox(fontResName, 10, otextBoxYPos, 16, YCoo_TextBoxPlus5(otextBoxYPos),
' TextAlignment.TextAlignmentFar, TextAlignment.TextAlignmentNear,
' oPosCount)
MyGDPicturePDF.DrawText(fontResName, 20, yPosition, oItemValue)
'Tabellendarstellung Ende
oDisplay = False
yPosition -= 5
' yPosition -= 5
End If
ElseIf oArea = "TAXPOS" Then
oIsPosition = True
@@ -179,20 +208,77 @@ Public Class XRechnungViewDocument
End If
Else
'INDIVIDUELLES VERHALTEN BEI Folge-ITEMS
_logger.Debug($"FollowItem: {oItemSPECNAME} - ItemValue: {oItemValue}")
_logger.Debug($"FollowItem - Area: [{oArea}] - ItemSpecname: [{oItemSPECNAME}] - ItemValue: [{oItemValue}]")
Dim otextBoxYPos As Integer
If oArea = "POSITION" Then
If oItemSPECNAME = "INVOICE_POSITION_AMOUNT" Then
oPosCount += 1
oPosTerm = $"{oPosCount}. {oItemValue} * "
oYPlus = 0
'oPosTerm = $"{oPosCount}. {oItemValue} * "
'Tabellendarstellung
yPosition += 5
oPosTerm = ""
MyGDPicturePDF.DrawText(fontResName, 10, yPosition, oPosCount)
'otextBoxYPos = yPosition - 3.5
'MyGDPicturePDF.DrawTextBox(fontResName, 10, otextBoxYPos, 16, YCoo_TextBoxPlus5(otextBoxYPos),
' TextAlignment.TextAlignmentFar, TextAlignment.TextAlignmentNear,
' oPosCount)
MyGDPicturePDF.DrawText(fontResName, 20, yPosition, oItemValue)
'Tabellendarstellung Ende
oDisplay = False
ElseIf oItemSPECNAME = "INVOICE_POSITION_ARTICLE" Then
oPosTerm += $" {oItemValue}"
'Tabellendarstellung
oYPlus = 0
oPosDesc = ""
oPosDesc = oItemValue
Dim oYDyn As Integer = yPosition - 5
Dim oPartsNL As List(Of String) = StringFunctions.SplitTextByNewLine(oItemValue)
For Each olinepart As String In oPartsNL
Dim oParts As List(Of String) = StringFunctions.SplitText_Length(olinepart, 67)
' Durchlaufen der einzelnen Teile in einer Schleife
For Each part As String In oParts
oYDyn += 5
oYPlus += 5
MyGDPicturePDF.DrawText(fontResName, 38, oYDyn, part)
Next
Next
'Tabellendarstellung Ende
' oPosTerm += $" {oItemValue}"
oDisplay = False
ElseIf oItemSPECNAME = "INVOICE_POSITION_NOTE" Then
'Tabellendarstellung
Dim cleanedText As String = RemoveNewlinesAndTabs(oItemValue)
Dim oParts As List(Of String) = StringFunctions.SplitText_Length(cleanedText, 68)
' Durchlaufen der einzelnen Teile in einer Schleife
Dim oYDyn As Integer = yPosition
Dim oPartsNL As List(Of String) = StringFunctions.SplitTextByNewLine(oItemValue)
For Each olinepart As String In oPartsNL
Dim oPartsPN As List(Of String) = StringFunctions.SplitText_Length(olinepart, 67)
' Durchlaufen der einzelnen Teile in einer Schleife
For Each part As String In oPartsPN
oYDyn += 5
oYPlus += 5
MyGDPicturePDF.DrawText(fontResName, 38, oYDyn, part)
Next
Next
'Tabellendarstellung Ende
'oPosTerm += $" {oItemValue}"
oDisplay = False
ElseIf oItemSPECNAME = "INVOICE_TAXPOS_TAX_RATE" Or oItemSPECNAME = "INVOICE_TAXPOS_RATE" Then
oPosTerm += $" - {oItemValue} %"
'Tabellendarstellung
MyGDPicturePDF.DrawText(fontResName, 155, yPosition, $"{oItemValue} %")
'Tabellendarstellung ENDE
' oPosTerm += $" - {oItemValue} %"
oDisplay = False
ElseIf oItemSPECNAME = "INVOICE_POSITION_TAX_AMOUNT" Then
oPosTerm += $" - {oItemValue} {oCurrencySymbol}"
' oPosTerm += $" - {oItemValue} {oCurrencySymbol}"
'Tabellendarstellung
Dim oYPos = yPosition - 3.5
MyGDPicturePDF.DrawTextBox(fontResName, 175, oYPos, 193, YCoo_TextBoxPlus5(oYPos),
TextAlignment.TextAlignmentFar, TextAlignment.TextAlignmentNear,
$"{oItemValue} {oCurrencySymbol}")
' MyGDPicturePDF.DrawText(fontResName, 175, yPosition, $"{oItemValue} {oCurrencySymbol}")
'Tabellendarstellung Ende
End If
oItemValue = oPosTerm
ElseIf oArea = "HEAD" Then
@@ -210,26 +296,36 @@ Public Class XRechnungViewDocument
oPosTerm += $" {oItemValue} {oCurrencySymbol}"
oDisplay = False
ElseIf oItemSPECNAME = "INVOICE_TAXPOS_TYPE" Then
oPosTerm += $" - {oItemValue}"
oPosTerm += $" {oItemValue}"
End If
oItemValue = oPosTerm
End If
End If
If oDisplay = True Then
If oDisplay = True And Len(oItemValue) > 0 Then
If Y_eq_lastrow = False And oAreaSwitch = False Then
yPosition += 5
End If
If oArea = "AMOUNT" Then
If oItemSPECNAME = "INVOICE_TOTAL_NET" Or oItemSPECNAME = "INVOICE_TOTAL_GROSS" Then
If oItemSPECNAME = "INVOICE_TOTAL_TAX" Or oItemSPECNAME = "INVOICE_TOTAL_NET" Or oItemSPECNAME = "INVOICE_TOTAL_GROSS" Then
oItemValue += $" {oCurrencySymbol}"
End If
End If
If oRowCaption <> String.Empty Then
'Zuerst die RowCaption
MyGDPicturePDF.DrawText(fontResName, 10, yPosition, oRowCaption)
MyGDPicturePDF.DrawText(fontResName, 70, yPosition, oItemValue)
'Dann den Wert
If oCreateTextBox Then
Dim otextBoxYPos = yPosition - 3
MyGDPicturePDF.DrawTextBox(fontResName, 70, otextBoxYPos, 90, YCoo_TextBoxPlus5(otextBoxYPos),
TextAlignment.TextAlignmentFar, TextAlignment.TextAlignmentCenter,
oItemValue)
Else
MyGDPicturePDF.DrawText(fontResName, 70, yPosition, oItemValue)
End If
Else
If Y_eq_lastrow = True Then
MyGDPicturePDF.DrawText(fontResName, oRow.Item("xPosition"), yPosition, oItemValue)
@@ -256,6 +352,12 @@ Public Class XRechnungViewDocument
End If
End If
Else
'Tabellendarstellung
If oItemSPECNAME = "INVOICE_POSITION_TAX_AMOUNT" And oYPlus > 0 Then
yPosition += oYPlus - 5
End If
'Tabellendarstellung Ende
End If
oIndex += 1
Next
@@ -288,7 +390,26 @@ Public Class XRechnungViewDocument
Return Nothing
End Try
End Function
Private Function RemoveNewlinesAndTabs(ByVal text As String) As String
Return text.Replace(vbCr, " - ").Replace(vbLf, "").Replace(vbTab, " ")
End Function
Private Function YCoo_TextBoxMinus5(yPosition As Integer)
Return yPosition - 5
End Function
Private Function YCoo_TextBoxPlus5(yPosition As Integer)
Return yPosition + 5
End Function
Function SplitTextByNewLine(text As String) As List(Of String)
If String.IsNullOrEmpty(text) Then
Return New List(Of String)()
End If
' Zerlege den Text anhand von Zeilenumbrüchen
Dim lines As List(Of String) = text.Split({vbCrLf, vbLf, vbCr}, StringSplitOptions.None).ToList()
Return lines
End Function
Public Function Create_PageHeader(pFollowPage As Boolean) As Integer
'Draw content on the PDF
Dim yPosition As Integer = 15