Untitled

 avatar
unknown
plain_text
a year ago
206 kB
7
Indexable
Include "Pcfk.int"			'Schnittstelle zur Faktura
Include "fkeasy.lsf"			'Vereinfachungen der Schreibweise
Include "pcfkvar5.lsf"		'Variablenliste Faktura

' In diesem Abschnitt sind alle Einstellungsmöglichkeiten dieses Formulars
' aufgelistet.

' Schalter für Erzeugung verschiedener Formularvarianten
' durch Setzten der verschiedenen Schalter und "Speichern unter..." werden die Unterarten der Formulare erzeugt
' Bei den Tabellen wird zwischen zwei Typen unterschieden :
' 1.	Tabellen für Lieferscheine
' 2.	Tabellen für die restlichen Aufträge, wie Angebote, Auftragsbestätigungen, Rechnungen, Gutschriften, Bestellungen, Sammelrechnungen
'		Dabei erfolgt noch noch eine Unterscheidung ob für Brutto-oder Nettoaufträge


'////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
'----------------------------------------------Formularbeschreibungen-----------------------------------------------------

'Seitenorientierung Hoch = PAGE_PORTRAIT, Quer = PAGE_LANDSCAPE
Description page_orientation as PAGE_PORTRAIT
Description form_description as "Standard Auftrag"
Description form_code as "Auftrag layout"				' Neues Define, damit Auswahl als Brutto und Nettoformular in Faktura möglich ist
Description Form_Version as "27.04.00.0222"

'////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
'-------------------------------------------Formularkonstanten (Textersatz für Werte)------------------------------------
Dim b13Umsatzsteuer as bool = FALSE
Dim strText13bUstG as string = ""
Dim strText13bUstGSo as string = ""
strText13bUstG = "Bei den vorgenannten Leistungen handelt es sich um eine sog. Bauleistung,\nfür die der Übergang der Steuerschuldnerschaft gem. § 13b UStG gilt. \nDie Umsatzsteuer ist somit vom Leistungsempfänger beim Finanzamt anzumelden und abzuführen.\nEs gilt die Steuerschuldnerschaft des Leistungsempfängers."
strText13bUstGSo = "Bei den vorgenannten Leistungen handelt es sich um sonstige Leistungen EG\nnach §13b UStG. Der Leistungsempfänger schuldet die Umsatzsteuer.\nEs gilt die Steuerschuldnerschaft des Leistungsempfängers (Reverse-Charge)."
Dim strTextPrivat as string = ""
Dim sGrundstfrei as string = ""

Dim nSteuerSatz as Numeric = 0
dim  nAnzahlSt as numeric = 0
dim  nAnzahlStNeben as numeric = 0
Dim bDruckeSteuerImmer as bool = TRUE

' Konstanten für Tabellentypen
Const KEINE_TABELLE				AS 0
Const TABELLE_AUFTRAG			AS 1
Const TABELLE_LIEFERSCHEIN	AS 2

' Konstanten für Tabellen
Const TABELLE_1					AS 0
Const TABELLE_2					AS 1
Const TABELLE_3					AS 2
Const TABELLE_4					AS 3
Const TABELLE_5					AS 4
Const TABELLE_6					AS 5
Const TABELLE_7					AS 6
Const TABELLE_8					AS 7
Const TABELLE_9					AS 8
Const TABELLE_10				AS 9
Const TABELLE_11				AS 10
Const TABELLE_12				AS 11

' Brutto/Netto Formular
Const AUFTRAG_NETTO				AS 1
Const AUFTRAG_BRUTTO			AS 2

' Textausrichtung
Const LINKS							AS 0
Const RECHTS						AS 1
Const MITTE						AS 2

' Layout des Formulars mit Programmwerte überschreiben JA/NEIN
Const LAYOUT_DURCH_PROGRAMM			as JA

'////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
'-------------------------------------------Formularvariablen mit Initialisierung---------------------------------------
'/////////////////////////////////////////////////////////////////////////////////////////
' Variablen für die Formulargestaltung, werden über das Programm Faktura gesetzt. Das Überschreiben dieser Defaultwerte
' erfolgt durch include von pcfkini.lsf ( siehe oben Define LAYOUT_VON_PROGRAMM )

'Allgemeine Einstellungen einer DIN A4 Seite
Dim nSeitenHoehe		as numeric = 29.70 cm
Dim nSeitenBreite	as numeric = 21.00 cm
'Dimensionierung der Ränder
DIM nRandLinks		as numeric = 1.80 cm
if is(DV_FREIMACHUNG) And (nRandLinks < nPostelleRandLinks) then
	'Poststelle: Mindest-Größe für linken Rand
	nRandLinks = nPostelleRandLinks
end if
DIM nRandOben			as numeric = 1.50 cm
DIM nRandRechts		as numeric = 1.50 cm
DIM nRandUnten		as numeric = 1.20 cm

' Ist Auftrag ein Lieferschein ? JA/NEIN
Dim bIstLieferschein as bool = NEIN
' Ist Formular ein Bruttoformular ? JA/NEIN
Dim bIstAuftragBrutto as bool = NEIN
' Ausführung der Tabelle im Formular (Auftrag)
Dim nTabelle as Numeric = TABELLE_1
' Ausführung der Tabelle im Formular (Lieferschein)
Dim nLieferTabelle as Numeric = TABELLE_1

' Mit Nachkommastellen bei Menge
Dim bMitNachKommaBeiMenge as bool = NEIN
' Tabellenbreite an Seitenbreite anpassen
Dim bTabelleAutoFormat as bool = JA


' Typ der Tabelle im Formular (KEINE_TABELLE, TABELLE_AUFTRAG, TABELLE_LIEFERSCHEIN)
'Dim nTypTabelle as Numeric = TABELLE_AUFTRAG
' Typ des Formulars (AUFTRAG_BRUTTO, AUFTRAG_NETTO)
'Dim nTypAuftrag as Numeric = AUFTRAG_NETTO

'Position Tabelle oben auf Seite 1
Dim nTabelleObenAufSeite1	as Numeric	= 9 cm
'Position Tabelle oben ab Seite 2
Dim nTabelleObenAbSeite2	as Numeric	= 9 cm
'Position Tabelle links auf Seite 1
Dim nTabelleLinksAufSeite1	as Numeric	= nRandLinks
'Position Tabelle oben ab Seite 2
Dim nTabelleLinksAbSeite2	as Numeric	= nRandLinks
'Position Tabelle oben auf Seite 1 automatisch setzen (ab Version 1.20.01.0726)
'ist dieser Schalter gesetzt, dann wird der Wert nTabelleObenAufSeite1 ignoriert und die Tabelle
'beginnt immer unterhalb der Auftragsbeschreibung
Dim bTabelleObenAufSeite1Auto	as bool	= JA
' Abstand von der letzten Zeile der Auftragsbeschreibung
Dim bTabelleObenAufSeite1AutoAbstand	as numeric	= 0 cm
'Tabelle mit Kopfzeile darstellen JA/NEIN
dim bTabelleMitKopf as bool = JA
'Spalte USt.steuer statt Rabattspalte, wird in Abhängigkeit vom Tabellentyp gesetzt
dim bSteuerStattRabatt as bool = NEIN

' Spaltenbreiten (max. 7 Spalten möglich) für Auftrag
Dim nBreiteSpalte_1 as Numeric = 0.8 cm
Dim nBreiteSpalte_2 as Numeric = 3.0 cm
Dim nBreiteSpalte_3 as Numeric = 2.0 cm
Dim nBreiteSpalte_8 as Numeric = 0.0 cm 'Gewicht eingeschoben
Dim nBreiteSpalte_4 as Numeric = 2.0 cm
Dim nBreiteSpalte_5 as Numeric = 2.0 cm
Dim nBreiteSpalte_6 as Numeric = 2.0 cm
Dim nBreiteSpalte_6a as Numeric = 2.0 cm 'USt.
Dim nBreiteSpalte_7 as Numeric = 2.0 cm
'Dim nBreiteSpalte_8 as Numeric = 2.0 cm
' Bezeichnung der Spalten für Auftrag
Dim sTextSpalte_1 as String = "Pos"
Dim sTextSpalte_2 as String = "Menge"
Dim sTextSpalte_3 as String = "Art.-Nr."
Dim sTextSpalte_8 as String = "Gewicht\n" 'Gewicht eingeschoben
Dim sTextSpalte_4 as String = "Text"
Dim sTextSpalte_5 as String = "Einzelpreis\n"
Dim sTextSpalte_6 as String = "Rabatt\n"
Dim sTextSpalte_6a as String = "USt.\n"		'USt.
Dim sTextSpalte_7 as String = "Gesamtpreis\n"
' in Betragsspalten Währung anzeigen
Dim bMitWaehrung as bool = NEIN
' Breite der Tabelle
Dim nBreiteTabelle as Numeric = nBreiteSpalte_1 + nBreiteSpalte_2 + nBreiteSpalte_3 + nBreiteSpalte_4
	nBreiteTabelle = nBreiteTabelle + nBreiteSpalte_5 + nBreiteSpalte_6 + nBreiteSpalte_6a + nBreiteSpalte_7 + nBreiteSpalte_8

' Spaltenbreiten (max. 7 Spalten möglich) für Lieferschein
Dim nLieferBreiteSpalte_1 as Numeric = 0.80 cm
Dim nLieferBreiteSpalte_2 as Numeric = 3.00 cm
Dim nLieferBreiteSpalte_3 as Numeric = 2.00 cm
Dim nLieferBreiteSpalte_4 as Numeric = 3.00 cm
Dim nLieferBreiteSpalte_5 as Numeric = 3.00 cm
Dim nLieferBreiteSpalte_6 as Numeric = 2.00 cm
Dim nLieferBreiteSpalte_7 as Numeric = 2.00 cm
Dim nLieferBreiteSpalte_8 as Numeric = 2.00 cm ' Ust
'Dim nLieferBreiteSpalte_8 as Numeric = 2.00 cm
' Bezeichnung der Spalten für Lieferschein
Dim sLieferTextSpalte_1 as String = "Pos"
Dim sLieferTextSpalte_2 as String = "Menge"
Dim sLieferTextSpalte_3 as String = "Art.-Nr."
Dim sLieferTextSpalte_4 as String = "Gewicht\nkg"
Dim sLieferTextSpalte_5 as String = "Text"
Dim sLieferTextSpalte_6	as String = "Einzelpreis"
Dim sLieferTextSpalte_7	as String = "Gesamtpreis"
Dim sLieferTextSpalte_8	as String = "Ust."

'Schriftparameter der Spaltenbeschriftungen
Dim SchriftFontSpaltenKopf as String		= "Arial"
Dim SchriftGroesseSpaltenKopf as numeric	= 9
Dim SchriftTypSpaltenKopf as numeric		= FONT_NORMAL
Dim SchriftFarbeSpaltenKopf as numeric	= COLOR_BLACK
'Schriftart der Spaltenbeschriftungen
Dim SchriftArtSpaltenKopf as FontType		= CreateFont(SchriftFontSpaltenKopf, SchriftGroesseSpaltenKopf, SchriftTypSpaltenKopf, SchriftFarbeSpaltenKopf)
'Dim SchriftArtSpaltenKopf as FontType = CreateFont("Arial", 9, FONT_BOLD, GetNumeric("X", 19))

'Schriftparameter für Standardschriftart
Dim SchriftFontStandard as String		= "Arial"
Dim SchriftGroesseStandard as numeric	= 9
Dim SchriftTypStandard as numeric		= FONT_NORMAL
Dim SchriftFarbeStandard as numeric	= COLOR_BLACK
'Standardschriftart
Dim SchriftArtStandard as FontType		= CreateFont(SchriftFontStandard, SchriftGroesseStandard, SchriftTypStandard, SchriftFarbeStandard)
' Schriftart für die Darstellung des Gesamtbetrags
dim SchriftArtGesamtbetrag as FontType	= CreateFont(SchriftFontStandard, SchriftGroesseStandard, FONT_BOLD, SchriftFarbeStandard)


'Kopfzeile auf Seite 1 anzeigen JA/NEIN
Dim bMitKopfzeileAufSeite1 as bool			= JA
'Kopfzeile ab Seite2 anzeigen JA/NEIN
Dim bMitKopfzeileAbSeite2 as bool			= JA

'Kopfzeile Ausrichtung Text
Dim nKopfzeileTextOrientation as Numeric	= LINKS
'Schriftparameter für Kopfzeilenbereich
Dim SchriftFontKopfzeile as String			= "Arial"
Dim SchriftGroesseKopfzeile as numeric	= 9
Dim SchriftTypKopfzeile as numeric			= FONT_NORMAL
Dim SchriftFarbeKopfzeile as numeric		= COLOR_BLACK
'Schriftart für Kopfzeilenbereich
Dim SchriftArtKopfzeile as FontType		= CreateFont(SchriftFontKopfzeile, SchriftGroesseKopfzeile, SchriftTypKopfzeile, SchriftFarbeKopfzeile)
'Schriftart gilt nur für die 1.Zeile JA/NEIN
'bei JA werden alle nachfolgenden Zeile der Kopfzeile in der Standardschriftart dargestellt
'bei NEIN werden alle Zeilen der Kopfzeile in der gewählten Schriftart dargestellt
Dim bSchriftArtNurZeile1 as bool			= NEIN

'Fußzeile auf Seite 1 anzeigen JA/NEIN
Dim bMitFusszeileAufSeite1 as bool			= JA
'Fußzeile ab Seite2 anzeigen JA/NEIN
Dim bMitFusszeileAbSeite2	as bool			= JA
'Fußzeile Hoehe
Dim nFusszeileHoehe			as Numeric		= 2.5 cm
'Schriftparameter für Fusszeilenbereich
Dim SchriftFontFusszeile	as String		= "Arial"
Dim SchriftGroesseFusszeile	as numeric	= 9
Dim SchriftTypFusszeile	as numeric		= FONT_NORMAL
Dim SchriftFarbeFusszeile	as numeric		= COLOR_BLACK
'Schriftart für Fusszeilenbereich
Dim SchriftArtFusszeile as FontType = CreateFont(SchriftFontFusszeile, SchriftGroesseFusszeile, SchriftTypFusszeile, SchriftFarbeFusszeile)
'zusätzlicher Text für Fusszeile
Dim sFusszeileText1		as String			= ""
'zusätzlicher Text für Fusszeile
Dim sFusszeileText2		as String			= ""
'zusätzlicher Text für Fusszeile
Dim sFusszeileText3		as String			= ""

'Absender auf Seite 1 anzeigen Ja/Nein
Dim bMitAbsenderAufSeite1 as bool = JA
'Absender ab Seite 2 anzeigen Ja/Nein
Dim bMitAbsenderAbSeite2 as bool = JA
'Position Absender links
Dim nAbsenderLinks as Numeric = nRandLinks
'Position Absender oben
Dim nAbsenderOben as Numeric = nRandOben + 3 cm
'Schriftparameter für Absender
Dim SchriftFontAbsender as String		= "Arial"
Dim SchriftGroesseAbsender as numeric  = 9
Dim SchriftTypAbsender as numeric		= FONT_NORMAL
Dim SchriftFarbeAbsender as numeric	= COLOR_BLACK
'Schriftart für Absender
Dim SchriftArtAbsender as FontType = CreateFont(SchriftFontAbsender, SchriftGroesseAbsender, SchriftTypAbsender, SchriftFarbeAbsender)

'Sichtfenster auf Seite 1 anzeigen Ja/Nein
Dim bMitSichtfensterAufSeite1 as bool = JA
'Sichtfenster ab Seite 2 anzeigen Ja/Nein
Dim bMitSichtfensterAbSeite2 as bool = JA
'Position Sichtfenster links
Dim nSichtfensterLinks as Numeric = nRandLinks
'Position Sichtfenster oben
Dim nSichtfensterOben as Numeric = nRandOben + 4 cm
'Ansprechpartner im  Sichtfeld anzeigen
Dim bSichtfensterMitAnsprechpartner as bool = JA   'ersetzen durch "NEIN" falls Ansprechpartner
																	'in Adreßfeld nicht gedruckt werden soll
'Schriftparameter für Sichtfenster
Dim SchriftFontSichtfenster as String		= "Arial"
Dim SchriftGroesseSichtfenster as numeric  = 9
Dim SchriftTypSichtfenster as numeric		= FONT_NORMAL
Dim SchriftFarbeSichtfenster as numeric	= COLOR_BLACK
'Schriftart für Sichtfenster
Dim SchriftArtSichtfenster as FontType = CreateFont(SchriftFontSichtfenster, SchriftGroesseSichtfenster, SchriftTypSichtfenster, SchriftFarbeSichtfenster)

' Betrefftext auf Seite 1 anzeigen JA/NEIN
Dim bMitBetrefftextAufSeite1 as bool = JA
' Betrefftext ab Seite 2 anzeigen JA/NEIN
Dim bMitBetrefftextAbSeite2 as bool = JA
'Position Betrefftext links
Dim nBetrefftextLinks as Numeric = nRandLinks
'Position Betrefftext oben
Dim nBetrefftextOben as Numeric = nRandOben + 7 cm
'Schriftparameter für 1. Betrefftext
Dim SchriftFontBetrefftext1 as String		= "Arial"
Dim SchriftGroesseBetrefftext1 as numeric = 14
Dim SchriftTypBetrefftext1 as numeric		= FONT_NORMAL
Dim SchriftFarbeBetrefftext1 as numeric	= COLOR_BLACK
'1. Schriftart für Betrefftext
Dim SchriftArtBetrefftext1 as FontType = CreateFont(SchriftFontBetrefftext1, SchriftGroesseBetrefftext1, SchriftTypBetrefftext1, SchriftFarbeBetrefftext1)
'2. Schriftart für Betrefftext
Dim SchriftArtBetrefftext2 as FontType = ARIAL_9

'Infofeld auf Seite 1 anzeigen Ja/Nein
Dim bMitInfofeldAufSeite1 as bool = JA
'Infofeld ab Seite 2 anzeigen Ja/Nein
Dim bMitInfofeldAbSeite2 as bool = JA
'Position InfoBlock links
Dim nInfoFeldLinks As Numeric = nRandLinks + 12 cm
'Position InfoBlock oben
Dim nInfoFeldOben As Numeric = nRandOben + 6 cm
'Breite Infofeld
Dim nInfoFeldBreite as Numeric = 5 cm
'Schriftparameter für Infoblock
Dim SchriftFontInfofeld as String		= "Arial"
Dim SchriftGroesseInfofeld as numeric  = 9
Dim SchriftTypInfofeld as numeric		= FONT_NORMAL
Dim SchriftFarbeInfofeld as numeric	= COLOR_BLACK
'Schriftart für Infoblock
Dim SchriftArtInfofeld as FontType = CreateFont(SchriftFontInfofeld, SchriftGroesseInfofeld, SchriftTypInfofeld, SchriftFarbeInfofeld)
'Seitennummer im Infoblock anzeigen Ja/Nein
Dim nInfoFeldMitSeitennummer	as bool = JA

' Parameter für den Ausdruck einer Infozeile statt des Infoblocks
Dim bInfoZeileStattInfoBlockAbSeite2 As bool = true
'Position InfoZeile oben
Dim nInfoZeileOben As Numeric
'Schriftparameter für Infozeile
Dim SchriftFontInfozeile as String		= "Arial"
Dim SchriftGroesseInfozeile as numeric  = 9
Dim SchriftTypInfozeile as numeric		= FONT_NORMAL
Dim SchriftFarbeInfozeile as numeric	= COLOR_BLACK

'Firmenlogo auf Seite 1 anzeigen JA/NEIN
Dim bMitLogoAufSeite1 as bool = JA
'Firmenlogo ab Seite 2 anzeigen JA/NEIN
Dim bMitLogoAbSeite2 as bool = JA
'Quelle Firmenlogo für Formular
Dim sFirmenLogoQuelle as String = ""
'Position Firmenlogo links
Dim nFirmenLogoLinks as Numeric = nRandLinks + 12 cm
'Position Firmenlogo oben
Dim nFirmenLogoOben as Numeric = nRandOben + 3 cm
'Breite Firmenlogo
Dim nFirmenLogoBreite as Numeric = 5 cm
'Höhe Firmenlogo
Dim nFirmenLogoHoehe as Numeric = 2.5 cm

'Zahlungsbedingungen anzeigen JA/NEIN
Dim bMitZahlungsbedingungen as bool = JA
'Zahlungsbedingungen anzeigen JA/NEIN
Dim bMitLieferart as bool				= JA
'Nachbemerkungen anzeigen JA/NEIN
Dim bMitNachbemerkungen as bool		= JA

' freies Textfeld für jedes Formular, wird am Ende des Formulars angehängt
'Freies Textfeld im Formular anzeigen JA/NEIN
Dim bMitZusatzText				as bool		= JA
'ZusatzText
Dim sZusatzText					as String	= ""
'Schriftparameter für Zusatztext
Dim SchriftFontZusatztext		as String	= "Arial"
Dim SchriftGroesseZusatztext	as numeric	= 9
Dim SchriftTypZusatztext		as numeric	= FONT_NORMAL
Dim SchriftFarbeZusatztext	as numeric	= COLOR_BLACK
'Schriftart für Infoblock
Dim SchriftArtZusatztext		as FontType = CreateFont(SchriftFontZusatztext, SchriftGroesseZusatztext, SchriftTypZusatztext, SchriftFarbeZusatztext)


' werden bereits aus Programm gesteuert
'Schraffur setzen oder nicht JA/NEIN
Dim bMitSchraffur as Bool				= NEIN
'Farbe der Schraffur im Kopf
Dim nSchraffurFarbeKopf as Numeric	= COLOR_TRANSPARENT
'Farbe der Schraffur allgemein
Dim nSchraffurFarbe as Numeric		= COLOR_TRANSPARENT
'Linienart der horizontalen Linien
Dim HorzLinienArt as PenType			= PEN_SOLID
'Linienart der vertikalen Linien
Dim VertLinienArt as PenType			= PEN_SOLID
'Farbe der vertikalen Linien
Dim nFarbe as Numeric					= COLOR_BLACK

' Optionen
' Währung als Text darstellen JA/NEIN
' wenn NEIN, wird Symbol dargestellt
' Symbol			Text
' DM				DM
' €				EUR
dim bWaehrungAlsText as bool	= NEIN
' der Text für die Darstellung der Ust
dim sUstText as string			= "Ust."
dim sNullBetrag as string		= "0,00"
'nCurrencyFormatDefault = CURRENCY_SYMBOL_HIDE 'Ohne Nullbetrag
dim strRabatt as string			= ""
strRabatt = Get(LAY_OPT_RABTEXT)


Dim strnameLiefer as string

'////////////////////////////////////////////////////////////////////////////////////////////////////
' die Breiten in Abhängigkeit von Tabellentyp (Auftrag oder Lieferschein), sowie der Tabellennummer
' setzen

	' Tabelle_1 mit Pos, Menge, Art.Nr., Text, Einzelpreis, Rabatt, Gesamtpreis
	if nTabelle = TABELLE_1 then
		bSteuerStattRabatt = NEIN
		' wenn anderen Spaltenbreiten für diesen Tabellentyp gewünscht, dann können die Werte hier
		' überschrieben werden, einfach Kommentar entfernen und neue Breite eingeben
		'nBreiteSpalte_1 = 0.80 cm			'Pos
		'nBreiteSpalte_2 = 3.00	cm			'Menge
		'nBreiteSpalte_3 = 2.00	cm			'Art.-Nr
		nBreiteSpalte_8 = 0.00	cm			'Gewicht (eingeschoben)
		'nBreiteSpalte_5 = 2.00	cm			'Einzelpreis
		'nBreiteSpalte_6 = 2.00	cm			'Rabatt
		'nBreiteSpalte_7 = 2.00	cm			'Gesamtpreis
		' wenn Autoformat, dann Breite der Textspalte anpassen
		if bTabelleAutoFormat then
			nBreiteSpalte_4 = nSeitenBreite - nRandLinks - nRandRechts - nBreiteSpalte_1 - nBreiteSpalte_2 - nBreiteSpalte_3
			nBreiteSpalte_4 = nBreiteSpalte_4 - nBreiteSpalte_5 - nBreiteSpalte_6 - nBreiteSpalte_6a - nBreiteSpalte_7 - nBreiteSpalte_8 - 5
		end if
	end if
	' Tabelle_2 mit Pos, Menge, Text, Einzelpreis, Rabatt, Gesamtpreis
	' Art.-Nr entfällt, indem Spaltenbreite auf 0 gesetzt wird
	if nTabelle = TABELLE_2 then
		bSteuerStattRabatt = NEIN
		' wenn anderen Spaltenbreiten für diesen Tabellentyp gewünscht, dann können die Werte hier
		' überschrieben werden, einfach Kommentar entfernen und neue Breite eingeben
		'nBreiteSpalte_1 = 0.80 cm			'Pos
		'nBreiteSpalte_2 = 3.00	cm			'Menge
		nBreiteSpalte_3 = 0.00	cm			'Art.-Nr
		nBreiteSpalte_8 = 0.00	cm			'Gewicht (eingeschoben)
		'nBreiteSpalte_5 = 2.00	cm			'Einzelpreis
		'nBreiteSpalte_6 = 2.00	cm			'Rabatt
		'nBreiteSpalte_7 = 2.00	cm			'Gesamtpreis
		' wenn Autoformat, dann Breite der Textspalte anpassen
		if bTabelleAutoFormat then
			nBreiteSpalte_4 = nSeitenBreite - nRandLinks - nRandRechts - nBreiteSpalte_1 - nBreiteSpalte_2 - nBreiteSpalte_3
			nBreiteSpalte_4 = nBreiteSpalte_4 - nBreiteSpalte_5 - nBreiteSpalte_6 - nBreiteSpalte_6a - nBreiteSpalte_7 - nBreiteSpalte_8 - 5
		end if
	end if
	' Tabelle_3 mit Pos, Menge, Art.Nr., Text, Einzelpreis, Gesamtpreis
	' Rabatt entfällt, indem Spaltenbreite auf 0 gesetzt wird
	if nTabelle = TABELLE_3 then
		bSteuerStattRabatt = NEIN
		' wenn anderen Spaltenbreiten für diesen Tabellentyp gewünscht, dann können die Werte hier
		' überschrieben werden, einfach Kommentar entfernen und neue Breite eingeben
		'nBreiteSpalte_1 = 0.80 cm			'Pos
		'nBreiteSpalte_2 = 3.00	cm			'Menge
		'nBreiteSpalte_3 = 2.00	cm			'Art.-Nr
		nBreiteSpalte_8 = 0.00	cm			'Gewicht (eingeschoben)
		'nBreiteSpalte_5 = 2.00	cm			'Einzelpreis
		nBreiteSpalte_6 = 0.00	cm			'Rabatt
		'nBreiteSpalte_7 = 2.00	cm			'Gesamtpreis
		' wenn Autoformat, dann Breite der Textspalte anpassen
		if bTabelleAutoFormat then
			nBreiteSpalte_4 = nSeitenBreite - nRandLinks - nRandRechts - nBreiteSpalte_1 - nBreiteSpalte_2 - nBreiteSpalte_3
			nBreiteSpalte_4 = nBreiteSpalte_4 - nBreiteSpalte_5 - nBreiteSpalte_6 - nBreiteSpalte_6a - nBreiteSpalte_7 - nBreiteSpalte_8 - 5
		end if
	end if
	' Tabelle_4 mit Menge, Text, Einzelpreis, Rabatt, Gesamtpreis
	' Pos und Art.-Nr entfallen, indem Spaltenbreiten auf 0 gesetzt werden
	if nTabelle = TABELLE_4 then
		bSteuerStattRabatt = NEIN
		' wenn anderen Spaltenbreiten für einen Tabellentyp gewünscht, dann können die Werte hier
		' überschrieben werden, einfach Kommentar entfernen und neue Breite eingeben
		nBreiteSpalte_1 = 0.00 cm			'Pos
		'nBreiteSpalte_2 = 3.00	cm			'Menge
		nBreiteSpalte_3 = 0.00 cm			'Art.-Nr
		nBreiteSpalte_8 = 0.00	cm			'Gewicht (eingeschoben)
		'nBreiteSpalte_5 = 2.00	cm			'Einzelpreis
		'nBreiteSpalte_6 = 2.00	cm			'Rabatt
		'nBreiteSpalte_7 = 2.00	cm			'Gesamtpreis
		' wenn Autoformat, dann Breite der Textspalte anpassen
		if bTabelleAutoFormat then
			nBreiteSpalte_4 = nSeitenBreite - nRandLinks - nRandRechts - nBreiteSpalte_1 - nBreiteSpalte_2 - nBreiteSpalte_3
			nBreiteSpalte_4 = nBreiteSpalte_4 - nBreiteSpalte_5 - nBreiteSpalte_6 - nBreiteSpalte_6a - nBreiteSpalte_7 - nBreiteSpalte_8 - 5
		end if
	end if
	' Tabelle_5 mit Pos, Menge, Text, Einzelpreis, Gesamtpreis
	' Art.-Nr und Rabatt entfallen, indem Spaltenbreiten auf 0 gesetzt werden
	if nTabelle = TABELLE_5 then
		bSteuerStattRabatt = NEIN
		' wenn anderen Spaltenbreiten für diesen Tabellentyp gewünscht, dann können die Werte hier
		' überschrieben werden, einfach Kommentar entfernen und neue Breite eingeben
		'nBreiteSpalte_1 = 0.80 cm			'Pos
		'nBreiteSpalte_2 = 3.00	cm			'Menge
		nBreiteSpalte_3 = 0.00 cm			'Art.-Nr
		nBreiteSpalte_8 = 0.00	cm			'Gewicht (eingeschoben)
		'nBreiteSpalte_5 = 2.00	cm			'Einzelpreis
		nBreiteSpalte_6 = 0.00 cm			'Rabatt
		'nBreiteSpalte_7 = 2.00	cm			'Gesamtpreis
		' wenn Autoformat, dann Breite der Textspalte anpassen
		if bTabelleAutoFormat then
			nBreiteSpalte_4 = nSeitenBreite - nRandLinks - nRandRechts - nBreiteSpalte_1 - nBreiteSpalte_2 - nBreiteSpalte_3
			nBreiteSpalte_4 = nBreiteSpalte_4 - nBreiteSpalte_5 - nBreiteSpalte_6 - nBreiteSpalte_6a - nBreiteSpalte_7 - nBreiteSpalte_8 - 5
		end if
	end if
	' Tabelle_6 mit Menge, Text, Einzelpreis, Gesamtpreis
	' Pos, Art.-Nr und Rabatt entfallen, indem Spaltenbreiten auf 0 gesetzt werden
	if nTabelle = TABELLE_6 then
		bSteuerStattRabatt = NEIN
		' wenn anderen Spaltenbreiten für diesen Tabellentyp gewünscht, dann können die Werte hier
		' überschrieben werden, einfach Kommentar entfernen und neue Breite eingeben
		nBreiteSpalte_1 = 0.00 cm			'Pos
		'nBreiteSpalte_2 = 3.00	cm			'Menge
		nBreiteSpalte_3 = 0.00	cm			'Art.-Nr
		nBreiteSpalte_8 = 0.00	cm			'Gewicht (eingeschoben)
		'nBreiteSpalte_5 = 2.00	cm			'Einzelpreis
		nBreiteSpalte_6 = 0.00	cm			'Rabatt
		'nBreiteSpalte_7 = 2.00	cm			'Gesamtpreis
		' wenn Autoformat, dann Breite der Textspalte anpassen
		if bTabelleAutoFormat then
			nBreiteSpalte_4 = nSeitenBreite - nRandLinks - nRandRechts - nBreiteSpalte_1 - nBreiteSpalte_2 - nBreiteSpalte_3
			nBreiteSpalte_4 = nBreiteSpalte_4 - nBreiteSpalte_5 - nBreiteSpalte_6 - nBreiteSpalte_6a - nBreiteSpalte_7 - nBreiteSpalte_8 - 5
		end if
	end if
	' Tabelle_1 mit Pos, Menge, Art.Nr., Text, Einzelpreis, USt., Gesamtpreis
	if nTabelle = TABELLE_7 then
		bSteuerStattRabatt = JA
		' wenn anderen Spaltenbreiten für diesen Tabellentyp gewünscht, dann können die Werte hier
		' überschrieben werden, einfach Kommentar entfernen und neue Breite eingeben
		'nBreiteSpalte_1 = 0.80 cm			'Pos
		'nBreiteSpalte_2 = 3.00	cm			'Menge
		'nBreiteSpalte_3 = 2.00	cm			'Art.-Nr
		nBreiteSpalte_8 = 0.00	cm			'Gewicht (eingeschoben)
		'nBreiteSpalte_5 = 2.00	cm			'Einzelpreis
		'nBreiteSpalte_6 = 2.00	cm			'Rabatt
		'nBreiteSpalte_7 = 2.00	cm			'Gesamtpreis
		' wenn Autoformat, dann Breite der Textspalte anpassen
		if bTabelleAutoFormat then
			nBreiteSpalte_4 = nSeitenBreite - nRandLinks - nRandRechts - nBreiteSpalte_1 - nBreiteSpalte_2 - nBreiteSpalte_3
			nBreiteSpalte_4 = nBreiteSpalte_4 - nBreiteSpalte_5 - nBreiteSpalte_6 - nBreiteSpalte_6a - nBreiteSpalte_7 - nBreiteSpalte_8 - 5
		end if
	end if
	' Tabelle_8 mit Pos, Menge, Text, Einzelpreis, Ust., Gesamtpreis
	' Art.-Nr entfällt, indem Spaltenbreite auf 0 gesetzt wird
	if nTabelle = TABELLE_8 then
		bSteuerStattRabatt = JA
		' wenn anderen Spaltenbreiten für diesen Tabellentyp gewünscht, dann können die Werte hier
		' überschrieben werden, einfach Kommentar entfernen und neue Breite eingeben
		'nBreiteSpalte_1 = 0.80 cm			'Pos
		'nBreiteSpalte_2 = 3.00	cm			'Menge
		nBreiteSpalte_3 = 0.00	cm			'Art.-Nr
		nBreiteSpalte_8 = 0.00	cm			'Gewicht (eingeschoben)
		'nBreiteSpalte_5 = 2.00	cm			'Einzelpreis
		'nBreiteSpalte_6 = 2.00	cm			'Rabatt
		'nBreiteSpalte_7 = 2.00	cm			'Gesamtpreis
		' wenn Autoformat, dann Breite der Textspalte anpassen
		if bTabelleAutoFormat then
			nBreiteSpalte_4 = nSeitenBreite - nRandLinks - nRandRechts - nBreiteSpalte_1 - nBreiteSpalte_2 - nBreiteSpalte_3
			nBreiteSpalte_4 = nBreiteSpalte_4 - nBreiteSpalte_5 - nBreiteSpalte_6 - nBreiteSpalte_6a - nBreiteSpalte_7 - nBreiteSpalte_8 - 5
		end if
	end if
	' Tabelle_9 mit Menge, Text, Einzelpreis, Ust., Gesamtpreis
	' Pos und Art.-Nr entfallen, indem Spaltenbreiten auf 0 gesetzt werden
	if nTabelle = TABELLE_9 then
		bSteuerStattRabatt = JA
		' wenn anderen Spaltenbreiten für einen Tabellentyp gewünscht, dann können die Werte hier
		' überschrieben werden, einfach Kommentar entfernen und neue Breite eingeben
		nBreiteSpalte_1 = 0.00 cm			'Pos
		'nBreiteSpalte_2 = 3.00	cm			'Menge
		nBreiteSpalte_3 = 0.00 cm			'Art.-Nr
		nBreiteSpalte_8 = 0.00	cm			'Gewicht (eingeschoben)
		'nBreiteSpalte_5 = 2.00	cm			'Einzelpreis
		'nBreiteSpalte_6 = 2.00	cm			'Rabatt
		'nBreiteSpalte_7 = 2.00	cm			'Gesamtpreis
		' wenn Autoformat, dann Breite der Textspalte anpassen
		if bTabelleAutoFormat then
			nBreiteSpalte_4 = nSeitenBreite - nRandLinks - nRandRechts - nBreiteSpalte_1 - nBreiteSpalte_2 - nBreiteSpalte_3
			nBreiteSpalte_4 = nBreiteSpalte_4 - nBreiteSpalte_5 - nBreiteSpalte_6 - nBreiteSpalte_6a- nBreiteSpalte_7 - nBreiteSpalte_8 - 5
		end if
	end if

	' Tabelle_10 mit Pos, Menge, Art.Nr., Text, Einzelpreis, Rabatt, USt., Gesamtpreis
	if nTabelle = TABELLE_10 then
		bSteuerStattRabatt = NEIN

		' wenn anderen Spaltenbreiten für diesen Tabellentyp gewünscht, dann können die Werte hier
		' überschrieben werden, einfach Kommentar entfernen und neue Breite eingeben
		'nBreiteSpalte_1 = 0.80 cm			'Pos
		'nBreiteSpalte_2 = 3.00	cm			'Menge
		'nBreiteSpalte_3 = 2.00	cm			'Art.-Nr
		nBreiteSpalte_8 = 0.00	cm			'Gewicht (eingeschoben)
		'nBreiteSpalte_5 = 2.00	cm			'Einzelpreis
		'nBreiteSpalte_6 = 2.00	cm			'Rabatt
		'nBreiteSpalte_6a = 2.00cm			'USt.
		'nBreiteSpalte_7 = 2.00	cm			'Gesamtpreis
		' wenn Autoformat, dann Breite der Textspalte anpassen
		if bTabelleAutoFormat then
			nBreiteSpalte_4 = nSeitenBreite - nRandLinks - nRandRechts - nBreiteSpalte_1 - nBreiteSpalte_2 - nBreiteSpalte_3
			nBreiteSpalte_4 = nBreiteSpalte_4 - nBreiteSpalte_5 - nBreiteSpalte_6 - nBreiteSpalte_6a - nBreiteSpalte_7 - nBreiteSpalte_8 - 5
		end if
	end if
	' Tabelle_11 mit Pos, Menge, Text, Einzelpreis, Rabatt, Ust., Gesamtpreis
	' Art.-Nr entfällt, indem Spaltenbreite auf 0 gesetzt wird
	if nTabelle = TABELLE_11 then
		bSteuerStattRabatt = NEIN
		' wenn anderen Spaltenbreiten für diesen Tabellentyp gewünscht, dann können die Werte hier
		' überschrieben werden, einfach Kommentar entfernen und neue Breite eingeben
		'nBreiteSpalte_1 = 0.80 cm			'Pos
		'nBreiteSpalte_2 = 3.00	cm			'Menge
		nBreiteSpalte_3 = 0.00	cm			'Art.-Nr
		nBreiteSpalte_8 = 0.00	cm			'Gewicht (eingeschoben)
		'nBreiteSpalte_5 = 2.00	cm			'Einzelpreis
		'nBreiteSpalte_6 = 2.00	cm			'Rabatt
		'nBreiteSpalte_6a = 2.00	cm		'USt.
		'nBreiteSpalte_7 = 2.00	cm			'Gesamtpreis
		' wenn Autoformat, dann Breite der Textspalte anpassen
		if bTabelleAutoFormat then
			nBreiteSpalte_4 = nSeitenBreite - nRandLinks - nRandRechts - nBreiteSpalte_1 - nBreiteSpalte_2 - nBreiteSpalte_3
			nBreiteSpalte_4 = nBreiteSpalte_4 - nBreiteSpalte_5 - nBreiteSpalte_6 - nBreiteSpalte_6a - nBreiteSpalte_7 - nBreiteSpalte_8 - 5
		end if
	end if
	' Tabelle_12 mit Menge, Text, Einzelpreis, Rabatt, Ust., Gesamtpreis
	' Pos und Art.-Nr entfallen, indem Spaltenbreiten auf 0 gesetzt werden
	if nTabelle = TABELLE_12 then
		bSteuerStattRabatt = NEIN
		' wenn anderen Spaltenbreiten für einen Tabellentyp gewünscht, dann können die Werte hier
		' überschrieben werden, einfach Kommentar entfernen und neue Breite eingeben
		nBreiteSpalte_1 = 0.00 cm			'Pos
		'nBreiteSpalte_2 = 3.00	cm			'Menge
		nBreiteSpalte_3 = 0.00 cm			'Art.-Nr
		nBreiteSpalte_8 = 0.00	cm			'Gewicht (eingeschoben)
		'nBreiteSpalte_5 = 2.00	cm			'Einzelpreis
		'nBreiteSpalte_6 = 2.00	cm			'Rabatt
		'nBreiteSpalte_6a = 2.00 cm			'USt.
		'nBreiteSpalte_7 = 2.00	cm			'Gesamtpreis
		' wenn Autoformat, dann Breite der Textspalte anpassen
		if bTabelleAutoFormat then
			nBreiteSpalte_4 = nSeitenBreite - nRandLinks - nRandRechts - nBreiteSpalte_1 - nBreiteSpalte_2 - nBreiteSpalte_3
			nBreiteSpalte_4 = nBreiteSpalte_4 - nBreiteSpalte_5 - nBreiteSpalte_6 - nBreiteSpalte_6a - nBreiteSpalte_7 - nBreiteSpalte_8 - 5
		end if
	end if

	' Lieferscheintabellen
	' Tabelle_1 mit Pos, Menge, Art.Nr., Gewicht(kg), Text
	if nLieferTabelle = TABELLE_1 then
		' wenn anderen Spaltenbreiten für diesen Tabellentyp gewünscht, dann können die Werte hier
		' überschrieben werden, einfach Kommentar entfernen und neue Breite eingeben
		'nLieferBreiteSpalte_1 = 0.80 cm		'Pos
		'nLieferBreiteSpalte_2 = 3.00 cm		'Menge
		'nLieferBreiteSpalte_3 = 2.00 cm		'Art.Nr.
		'nLieferBreiteSpalte_4 = 3.00 cm		'Gewicht
		nLieferBreiteSpalte_6 = 0.00 cm		'Einzelpreis
		nLieferBreiteSpalte_7 = 0.00 cm		'Gesamtpreis
		if bTabelleAutoFormat then
			nLieferBreiteSpalte_5 = nSeitenBreite - nRandLinks - nRandRechts - nLieferBreiteSpalte_1 - nLieferBreiteSpalte_2 - nLieferBreiteSpalte_3
											- nLieferBreiteSpalte_4 - nLieferBreiteSpalte_6 - nLieferBreiteSpalte_7 - 5
		end if
	end if
	' Tabelle_2 mit Pos, Menge, Gewicht(kg), Text
	' Art.-Nr entfällt, indem Spaltenbreite auf 0 gesetzt wird
	if nLieferTabelle = TABELLE_2 then
		' wenn anderen Spaltenbreiten für diesen Tabellentyp gewünscht, dann können die Werte hier
		' überschrieben werden, einfach Kommentar entfernen und neue Breite eingeben
		'nLieferBreiteSpalte_1 = 0.80 cm		'Pos
		'nLieferBreiteSpalte_2 = 3.00 cm		'Menge
		nLieferBreiteSpalte_3 = 0.00 cm		'Art.Nr.
		'nLieferBreiteSpalte_4 = 3.00 cm		'Gewicht
		nLieferBreiteSpalte_6 = 0.00 cm		'Einzelpreis
		nLieferBreiteSpalte_7 = 0.00 cm		'Gesamtpreis
		if bTabelleAutoFormat then
			nLieferBreiteSpalte_5 = nSeitenBreite - nRandLinks - nRandRechts - nLieferBreiteSpalte_1 - nLieferBreiteSpalte_2 - nLieferBreiteSpalte_3
											- nLieferBreiteSpalte_4 - nLieferBreiteSpalte_6 - nLieferBreiteSpalte_7 - 5
		end if
	end if
	' Tabelle_3 mit Menge, Gewicht(kg), Text
	' Art.-Nr und Menge entfallen, indem Spaltenbreiten auf 0 gesetzt werden
	if nLieferTabelle = TABELLE_3 then
		' wenn anderen Spaltenbreiten für diesen Tabellentyp gewünscht, dann können die Werte hier
		' überschrieben werden, einfach Kommentar entfernen und neue Breite eingeben
		nLieferBreiteSpalte_1 = 0.00 cm		'Pos
		'nLieferBreiteSpalte_2 = 3.00 cm		'Menge
		nLieferBreiteSpalte_3 = 0.00 cm		'Art.Nr.
		'nLieferBreiteSpalte_4 = 3.00 cm		'Gewicht
		nLieferBreiteSpalte_6 = 0.00 cm		'Einzelpreis
		nLieferBreiteSpalte_7 = 0.00 cm		'Gesamtpreis
		if bTabelleAutoFormat then
			nLieferBreiteSpalte_5 = nSeitenBreite - nRandLinks - nRandRechts - nLieferBreiteSpalte_1 - nLieferBreiteSpalte_2 - nLieferBreiteSpalte_3
											- nLieferBreiteSpalte_4 - nLieferBreiteSpalte_6 - nLieferBreiteSpalte_7 - 5
		end if
	end if
	' Tabelle_4 mit Position, Menge, Art.nr, Text
	' Art.-Nr und Menge entfallen, indem Spaltenbreiten auf 0 gesetzt werden
	if nLieferTabelle = TABELLE_4 then
		' wenn anderen Spaltenbreiten für diesen Tabellentyp gewünscht, dann können die Werte hier
		' überschrieben werden, einfach Kommentar entfernen und neue Breite eingeben
		'nLieferBreiteSpalte_1 = 0.80 cm		'Pos
		'nLieferBreiteSpalte_2 = 3.00 cm		'Menge
		'nLieferBreiteSpalte_3 = 2.00 cm		'Art.Nr.
		nLieferBreiteSpalte_4 = 0.00 cm		'Gewicht
		nLieferBreiteSpalte_6 = 0.00 cm		'Einzelpreis
		nLieferBreiteSpalte_7 = 0.00 cm		'Gesamtpreis
		if bTabelleAutoFormat then
			nLieferBreiteSpalte_5 = nSeitenBreite - nRandLinks - nRandRechts - nLieferBreiteSpalte_1 - nLieferBreiteSpalte_2 - nLieferBreiteSpalte_3
											- nLieferBreiteSpalte_4 - nLieferBreiteSpalte_6 - nLieferBreiteSpalte_7 - 5
		end if
	end if
	' Tabelle_5 mit Position, Menge, Text
	' Art.-Nr und Menge entfallen, indem Spaltenbreiten auf 0 gesetzt werden
	if nLieferTabelle = TABELLE_5 then
		' wenn anderen Spaltenbreiten für diesen Tabellentyp gewünscht, dann können die Werte hier
		' überschrieben werden, einfach Kommentar entfernen und neue Breite eingeben
		'nLieferBreiteSpalte_1 = 0.80 cm		'Pos
		'nLieferBreiteSpalte_2 = 3.00 cm		'Menge
		nLieferBreiteSpalte_3 = 0.00 cm		'Art.Nr.
		nLieferBreiteSpalte_4 = 0.00 cm		'Gewicht
		nLieferBreiteSpalte_6 = 0.00 cm		'Einzelpreis
		nLieferBreiteSpalte_7 = 0.00 cm		'Gesamtpreis
		if bTabelleAutoFormat then
			nLieferBreiteSpalte_5 = nSeitenBreite - nRandLinks - nRandRechts - nLieferBreiteSpalte_1 - nLieferBreiteSpalte_2 - nLieferBreiteSpalte_3
											- nLieferBreiteSpalte_4 - nLieferBreiteSpalte_6 - nLieferBreiteSpalte_7 - 5
		end if
	end if


'///////////////////////////////////////////////////////////////////////////////////////
'Hilfsvariablen für die Formulargestaltung

Dim KopfLinien as PenType
' die Stärke der Linie
Dim nRand as Numeric
Dim nGewicht as Numeric
Dim nGewichtSumme as Numeric
Dim n as Numeric
Dim Formulartitel as String

Dim FormatMenge as String
Dim strPuffer as String
Dim strTemp as string
dim strUstForderung	as numeric
dim nTemp1	as numeric
dim nTemp2	as numeric

dim nTemp1x	as numeric
dim nTemp2x	as numeric
dim strTemp2x	as string = ""
dim strUstAbschlag	as numeric

Dim nPosition as Numeric
Dim i as Numeric
Dim Feld as Numeric
Dim strArtikelNummer as String
Dim strFirmenanschrift as String
Dim strTelFax as string
Dim Result_P as Bool
Dim Result_R as Bool
Dim Result_G as Bool

Dim nBetrag as Numeric
Dim nSumme as Numeric
Dim nBreite as Numeric
Dim nBreite1 as Numeric

Dim strGewicht as String
Dim strProzent as String

Dim nLinienPos as Numeric
Dim Steuern as Bool
Dim Nebenleistung as Bool = False

' Hilfsvariablen für die Ausgabe der Steuern
Dim nNetTeilsum as Numeric
Dim nBrutTeilsum as Numeric
Dim nUstsum as Numeric
Dim nUstsatz as Numeric

' aktuelle Seite, wenn Druck Auftragsliste
Dim nAuftragPage as numeric = 0
Dim fResetPage as Bool = false
' aktuelle interne Auftragsnummer
Dim nAuftragNr as numeric = -1
Dim sAuftrag	as string = ""


'///////////////////////////////////////////////////////////////////////////////////
'Variablen für die Tabellen

'Definition der Überschriftenzeile der Tabelle
Dim C_H_Head as CellType

'Die erste Zeile der Überschriftenzeile
Dim C_H_Zeile		as CellType
Dim C_HU_Zeile		as CellType

'Die Zellen der Überschriftenzeile
Dim C_H_Spalte_1	as Celltype
Dim C_H_Spalte_2	as Celltype
Dim C_H_Spalte_3	as Celltype
Dim C_H_Spalte_8	as Celltype 'Gewicht eingeschoben
Dim C_H_Spalte_4	as Celltype
Dim C_H_Spalte_5	as Celltype
Dim C_H_Spalte_6	as CellType
Dim C_H_Spalte_6a	as CellType
Dim C_H_Spalte_7	as Celltype

'Definiton der Zelle des Tabellenkörpers
Dim C_Zeile			as CellType
Dim C_Zeile_s		as CellType

'Definition der Zellen in einer Tabellenzeile
Dim C_Spalte_1	as CellType
Dim C_Spalte_2	as CellType
Dim C_Spalte_3	as CellType
Dim C_Spalte_4	as CellType
Dim C_Spalte_9	as CellType	'Gewicht eingeschoben
Dim C_Spalte_5	as CellType
Dim C_Spalte_6	as CellType
Dim C_Spalte_7	as CellType
Dim C_Spalte_7a	as CellType
Dim C_Spalte_8	as CellType

'Definition der Spalten für die Stücklistenartikel
Dim C_Spalte_1s	as CellType
Dim C_Spalte_2s	as CellType
Dim C_Spalte_3s	as CellType
Dim C_Spalte_4s	as CellType
Dim C_Spalte_9s	as CellType	'Gewicht eingeschoben
Dim C_Spalte_5s	as CellType
Dim C_Spalte_6s	as CellType
Dim C_Spalte_7s	as CellType
Dim C_Spalte_7sa	as CellType
Dim C_Spalte_8s	as CellType

'Definition der Summenzeile
Dim C_S_Zeile  	as CellType
Dim C_S_Gesamt		as CellType
Dim C_S_Noetig	as CellType
Dim C_S_Abschlag	as CellType
Dim C_S_Forder		as CellType

Dim C_S_SteuerBruttoText as CellType
Dim C_S_Steuerbrutto	as CellType

Dim C_S_Not_Spalte_1 as CellType
Dim C_S_Not_Spalte_2 as CellType

'Definiton der Zellen in der  Summenzeile

Dim C_S_SteuerBruttoText_1 as CellType

Dim C_S_Steuerbrutto_1	as CellType
Dim C_S_Steuerbrutto_2	as CellType
Dim C_S_Steuerbrutto_3	as CellType
Dim C_S_Steuerbrutto_4	as CellType
Dim C_S_Steuerbrutto_5	as CellType
Dim C_S_Steuerbrutto_6	as CellType

Dim C_S_Spalte_1		as CellType
Dim C_S_Spalte_1a	as CellType
Dim C_S_Spalte_1b	as CellType
Dim C_S_Spalte_1x	as CellType
Dim C_S_Spalte_1y	as CellType
Dim C_S_Spalte_2		as CellType
Dim C_S_Spalte_3		as CellType
Dim C_S_Spalte_4		as CellType
Dim C_S_Text			as CellType
Dim C_S_Text_2			as CellType
Dim C_S_Text_3			as CellType
Dim C_S_Text_4			as CellType

Dim C_S_Forder_1	as CellType
Dim C_S_Forder_2	as CellType
Dim C_S_Forder_3	as CellType
Dim C_S_Forder_4	as CellType


'Definition der Zellen für den Übertrag
Dim C_HU_Spalte_1	as CellType
Dim C_HU_Spalte_2	as CellType

Dim C_S_Bottom  	as CellType
Dim C_S_TOP  	as CellType

' Hilfsvariablen für die Ausgabe der Steuern
Dim C_S_Steuern as CellType
Dim C_S_St_Spalte_1	as CellType
Dim C_S_St_Spalte_1a as CellType
Dim C_S_St_Spalte_2	as CellType
Dim C_S_St_Spalte_3	as CellType
Dim C_S_St_Spalte_4	as CellType
Dim C_S_St_Spalte_5	as CellType
Dim C_S_St_Spalte_6  as CellType

' Hilfsvariablen für die Ausgabe der Steuern Brutto
Dim C_S_SteuernBrutto as CellType
Dim C_S_St_Spalte_1b as CellType
Dim C_S_St_Spalte_2b as CellType
Dim C_S_St_Spalte_3b as CellType
Dim C_S_St_Spalte_4b as CellType
Dim C_S_St_Spalte_5b as CellType
Dim C_S_St_Spalte_6b as CellType

Dim nBreit_1	as Numeric
Dim nBreit_1a	as Numeric
Dim nBreit_2	as Numeric
Dim nBreit_3	as Numeric
Dim nBreit_4	as Numeric
Dim nBreit_5	as Numeric
Dim Betrag		as Numeric


'///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
'-------------------------------------- Variablen Init------------------------------------------

' überschreibt Standardvorgaben für die Formulargestaltung mit Programmwerten aus der Faktura
if LAYOUT_DURCH_PROGRAMM then
	Include "pcfkini.lsf"
end if

Include "GiroCode_common.inc.lsf"

' In der Tabelle Währung direkt an Betrag anhängen
Dim nCurrencySymbol as numeric = CURRENCY_SYMBOL_HIDE
Dim nCurrencyFormat as numeric

if is(DV_FREIMACHUNG) then
	'Schriftart für Absender und Sichtfenster setzen
	SchriftArtAbsender = CreateFont("Arial", 9, FONT_NORMAL, COLOR_BLACK)

	'keine Marken am linken Rand
	bFalzmarkeOben = False
	bFalzmarkeUnten = False
	bLochmarke = False
end if

'Schriftart für Infoblock
Dim SchriftArtInfozeile as FontType = CreateFont(SchriftFontInfozeile, SchriftGroesseInfozeile, SchriftTypInfozeile, SchriftFarbeInfozeile)

Include "SepaPreNotification.lsf"
Include "layout.inc.lsf"

'Nachkommastellen bei Mengenangaben setzen
if	(bMitNachKommaBeiMenge) then
	FormatMenge = "%." + FormatNumeric("%1.0f", GetNumeric(FA_NACHKOMMAST_MENGE)) + "f"
else
	FormatMenge = "%.0f"
End if

' wenn die Faktura nicht mit einem Formularassi arbeiten, oder es keine LayoutInit durch das Programm gibt,
' dann müssen diese Werte aus einem anderen Bereich von der Faktura geholt werden
if IS("L", 300) = FALSE or LAYOUT_DURCH_PROGRAMM = NEIN then
	'Farbe der Schraffur im Kopf
	nSchraffurFarbeKopf = GetNumeric(ALLG_TABKOPF_HINTER_FARBE)
	'Schraffur setzen oder nicht JA/NEIN
	bMitSchraffur 		= IS(ALLG_MIT_SCHRAFFUR)
	'Farbe der  Schraffur
	If bMitSchraffur Then
		nSchraffurFarbe = GetNumeric(ALLG_SCHRAFFUR_FARBE)
	else
		nSchraffurFarbe = COLOR_TRANSPARENT
	End If
	If nSchraffurFarbe = COLOR_WHITE Then
		nSchraffurFarbe = COLOR_TRANSPARENT
	End If
	'Linienart der horizontalen Linien
	If is(ALLG_MIT_HORZ_LINIEN) Then
		HorzLinienArt = GetNumeric(ALLG_HORZ_LINIENART)
	else
		HorzLinienArt = PEN_NULL
	End If
	'Linienart der vertikalen Linien
	If is(ALLG_MIT_VERT_LINIEN) Then
		VertLinienArt = GetNumeric(ALLG_VERT_LINIENART)
		nFarbe = COLOR_BLACK
	else
		VertLinienArt = PEN_NULL
		nFarbe = COLOR_TRANSPARENT
	End If
	' Schriftart Spaltenkopf
	SchriftFontSpaltenKopf 		= "Arial"
	SchriftGroesseSpaltenKopf		= 9
	SchriftTypSpaltenKopf			= FONT_BOLD
	SchriftFarbeSpaltenKopf		= GetNumeric(ALLG_TABKOPF_TEXT_FARBE)
	SchriftArtSpaltenKopf = CreateFont(SchriftFontSpaltenKopf, SchriftGroesseSpaltenKopf, SchriftTypSpaltenKopf, SchriftFarbeSpaltenKopf)
end if

'////////////////////////////////////////////////////////////////////////////////////
'Funktion - PrintSichtfenster
'Sichtfenster formatieren und ausgeben
'/////////////////////////////////////////////////////////////
Include "Sichtfenster.inc.lsf"

'////////////////////////////////////////////////////////////////////////////////////
'Funktion - PrintBetreffText
'BetreffText formatieren und ausgeben
'/////////////////////////////////////////////////////////////
dim Status as numeric

Function PrintBetreffText(Schriftart1 as FontType, Schriftart2 as FontType)
	' Text für die Auftragsart
'	dim sAuftrag	as string = ""
	' überprüfen, ob Absender noch auf erste Seite passt
	Dim MaximaleHoehe as numeric = GetAreaLength() - 4 cm
	if	nBetrefftextOben > MaximaleHoehe then
		nBetrefftextOben = MaximaleHoehe
	end if
	'Position bezogen auf Seitenmaße
	if is(DV_FREIMACHUNG) then
		'Poststelle: Betreffzeile hat Mindestabstand von oben!
		if  nBetrefftextOben < nPostelleBetreffTextOben then
			nBetrefftextOben = nPostelleBetreffTextOben
		end if
		if nBetrefftextLinks < nRandLinks then
			nBetrefftextLinks = nRandLinks
		end if
	end if

	SetPos(nBetrefftextLinks-nRandLinks, nBetrefftextOben-nRandOben)

	sAuftrag = Get(AUFTR_AUFTRAG_TEXT)

	SelectFont(Schriftart1)
	Status = GetNumeric("R",27)
	if bBetreffMitAuftrnummer then
		if bStatusGedruckt then
			if GetFlag( 0x0008, Status )  then
				TL(sAuftrag + " Nr. " + FormatNumeric("%.0f", GetNumeric(AUFTR_BELEG_NR)) + sTextGedruckt)
			else
				TL(sAuftrag + " Nr. " + FormatNumeric("%.0f", GetNumeric(AUFTR_BELEG_NR)))
			end if
		else
			TL(sAuftrag + " Nr. " + FormatNumeric("%.0f", GetNumeric(AUFTR_BELEG_NR)))
		end if
	else
		if bStatusGedruckt then
			if GetFlag( 0x0008, Status )  then
				TL(sAuftrag + sTextGedruckt)
			else
				TL(sAuftrag)
			end if
		else
			TL(sAuftrag)
		end if
	end if

	PrintBetreffWeitergefuehrt(Schriftart2)
	SetWordWrap(TRUE)

	if nAuftragPage = 1 then
		SelectFont(Schriftart2)
		PrintBetreffLeistungsDatumZeitraum()
	end if

	' Ausgabe der Auftragsbeschreibung nur auf der 1. Seite
	if nAuftragPage = 1 then
		SelectFont(Schriftart2)
		LF
		if bBetreffMitLieferadresse and is(AUFTR_IST_STORNO) = false then
			if is(AUFTR_IST_LS) = false Then
				LieferadresseAusgeben()
			else
				RechnungsadresseAusgeben()
			end if
		end if

'///////////////////////////////////////////////////////////////////////////////////////////////////7
		'aus Auftragsfreifelder
		If (IS(MIT_AFREIFELD1)) AND (GetNumeric(LAY_COMBO_FF1) = 1) AND (Get(AUFTR_FREIFELD1 ) <> "")  then
			If Get(TEXT_AFREIFELD1 ) <> "" then
				TL(Get(TEXT_AFREIFELD1 ) + ": " + Get(AUFTR_FREIFELD1))
			else
				TL(Get(AUFTR_FREIFELD1))
			end if
		end if
		If (IS(MIT_AFREIFELD2)) AND (GetNumeric(LAY_COMBO_FF2) = 1) AND (Get(AUFTR_FREIFELD2 ) <> "") then
			If Get(TEXT_AFREIFELD2 ) <> "" then
				TL(Get(TEXT_AFREIFELD2 ) + ": " + Get(AUFTR_FREIFELD2))
			else
				TL(Get(AUFTR_FREIFELD2))
			end if
		end if
		If (IS(MIT_AFREIFELD3)) AND (GetNumeric(LAY_COMBO_FF3) = 1) AND (Get(AUFTR_FREIFELD3 ) <> "")  then
			If Get(TEXT_AFREIFELD3) <> "" then
				TL(Get(TEXT_AFREIFELD3 ) + ": " + Get(AUFTR_FREIFELD3))
			else
				TL(Get(AUFTR_FREIFELD3))
			end if
		end if
			If (IS(MIT_AFREIFELD4)) AND (GetNumeric(LAY_COMBO_FF10) = 1) AND (Get(AUFTR_FREIFELD4 ) <> "")  then
			If Get(TEXT_AFREIFELD4 ) <> "" then
				TL(Get(TEXT_AFREIFELD4 ) + ": " + Get(AUFTR_FREIFELD4))
			else
				TL(Get(AUFTR_FREIFELD4))
			end if
		end if
		If (IS(MIT_AFREIFELD5)) AND (GetNumeric(LAY_COMBO_FF11) = 1) AND (Get(AUFTR_FREIFELD5 ) <> "") then
			If Get(TEXT_AFREIFELD5 ) <> "" then
				TL(Get(TEXT_AFREIFELD5 ) + ": " + Get(AUFTR_FREIFELD5))
			else
				TL(Get(AUFTR_FREIFELD5))
			end if
		end if
		If (IS(MIT_AFREIFELD6)) AND (GetNumeric(LAY_COMBO_FF12) = 1) AND (Get(AUFTR_FREIFELD6 ) <> "")  then
			If Get(TEXT_AFREIFELD6) <> "" then
				TL(Get(TEXT_AFREIFELD6 ) + ": " + Get(AUFTR_FREIFELD6))
			else
				TL(Get(AUFTR_FREIFELD6))
			end if
		end if
		if GetNumeric("K", 37) = 0 then
			'aus Kundendaten
			If (IS(MIT_KFREIFELD1)) AND (GetNumeric(LAY_COMBO_FF4) = 1) AND (Get(KD_FREIFELD1 ) <> "")  then
				If Get(TEXT_KFREIFELD1 ) <> "" then
					TL(Get(TEXT_KFREIFELD1 ) + ": " + Get(KD_FREIFELD1))
				else
					TL(Get(KD_FREIFELD1))
				end if
			end if
			If (IS(MIT_KFREIFELD2)) AND (GetNumeric(LAY_COMBO_FF5) = 1) AND (Get(KD_FREIFELD2 ) <> "")  then
				If Get(TEXT_KFREIFELD2 ) <> "" then
					TL(Get(TEXT_KFREIFELD2 ) + ": " + Get(KD_FREIFELD2))
				else
					TL(Get(KD_FREIFELD2))
				end if
			end if
			If (IS(MIT_KFREIFELD3)) AND (GetNumeric(LAY_COMBO_FF6) = 1)AND (Get(KD_FREIFELD3 ) <> "") then
				if Get(TEXT_KFREIFELD3 ) <> "" then
					TL(Get(TEXT_KFREIFELD3 ) + ": " + Get(KD_FREIFELD3))
				else
					TL(Get(KD_FREIFELD3))
				end if
			end if
			If (IS(MIT_KFREIFELD4)) AND (GetNumeric(LAY_COMBO_FF13) = 1) AND (Get(KD_FREIFELD4 ) <> "")  then
				If Get(TEXT_KFREIFELD4 ) <> "" then
					TL(Get(TEXT_KFREIFELD4 ) + ": " + Get(KD_FREIFELD4))
				else
					TL(Get(KD_FREIFELD4))
				end if
			end if
			If (IS(MIT_KFREIFELD5)) AND (GetNumeric(LAY_COMBO_FF14) = 1) AND (Get(KD_FREIFELD5 ) <> "")  then
				If Get(TEXT_KFREIFELD5 ) <> "" then
					TL(Get(TEXT_KFREIFELD5 ) + ": " + Get(KD_FREIFELD5))
				else
					TL(Get(KD_FREIFELD5))
				end if
			end if
			If (IS(MIT_KFREIFELD6)) AND (GetNumeric(LAY_COMBO_FF15) = 1)AND (Get(KD_FREIFELD6 ) <> "") then
				if Get(TEXT_KFREIFELD6 ) <> "" then
					TL(Get(TEXT_KFREIFELD6 ) + ": " + Get(KD_FREIFELD6))
				else
					TL(Get(KD_FREIFELD6))
				end if
			end if
		else
			'aus Lieferantendaten
'///////////////////////////
			If (IS(MIT_LFREIFELD1)) AND (GetNumeric(LAY_COMBO_FF7) = 1) AND (Get(KD_FREIFELD1 ) <> "") then
				if Get(TEXT_LFREIFELD1 ) <> "" then
					TL(Get(TEXT_LFREIFELD1 ) + ": "  + Get(KD_FREIFELD1))
				else
					TL(Get(KD_FREIFELD1))
				end if
			end if
			If (IS(MIT_LFREIFELD2))AND (GetNumeric(LAY_COMBO_FF8) = 1) AND (Get(KD_FREIFELD2 ) <> "")then
				if Get(TEXT_LFREIFELD2 ) <> "" then
					TL(Get(TEXT_LFREIFELD2 ) + ": "  + Get(KD_FREIFELD2))
				else
					TL(Get(KD_FREIFELD2))
				end if
			end if
			If (IS(MIT_LFREIFELD3))AND(GetNumeric(LAY_COMBO_FF9) = 1) AND (Get(KD_FREIFELD3 ) <> "")then
				if Get(TEXT_LFREIFELD3 ) <> "" then
					TL(Get(TEXT_LFREIFELD3 ) + ": "  + Get(KD_FREIFELD3))
				else
					TL(Get(KD_FREIFELD3))
				end if
			end if
			If (IS(MIT_LFREIFELD4)) AND (GetNumeric(LAY_COMBO_FF16) = 1) AND (Get(KD_FREIFELD4 ) <> "") then
				if Get(TEXT_LFREIFELD4 ) <> "" then
					TL(Get(TEXT_LFREIFELD4 ) + ": "  + Get(KD_FREIFELD4))
				else
					TL(Get(KD_FREIFELD4))
				end if
			end if
			If (IS(MIT_LFREIFELD5))AND (GetNumeric(LAY_COMBO_FF17) = 1) AND (Get(KD_FREIFELD5 ) <> "")then
				if Get(TEXT_LFREIFELD5 ) <> "" then
					TL(Get(TEXT_LFREIFELD5 ) + ": "  + Get(KD_FREIFELD5))
				else
					TL(Get(KD_FREIFELD5))
				end if
			end if
			If (IS(MIT_LFREIFELD6))AND(GetNumeric(LAY_COMBO_FF18) = 1) AND (Get(KD_FREIFELD6 ) <> "")then
				if Get(TEXT_LFREIFELD6 ) <> "" then
					TL(Get(TEXT_LFREIFELD6 ) + ": "  + Get(KD_FREIFELD6))
				else
					TL(Get(KD_FREIFELD6))
				end if
			end if
		end if
'//////////////////////////////////////

		TL(Get(AUFTR_BESCHR_ALL))
		LF
	end if
	' wieder Standardschriftart
	SelectFont(SchriftArtStandard)
End Function

'////////////////////////////////////////////////////////////////////////////////////
'Funktion - SteuernAusgabeNetto
'Hilfsfunktion für die Ausgabe der Steuern
'/////////////////////////////////////////////////////////////
Function SteuernAusgabe(n1 as Numeric, n2 as Numeric, n3 as Numeric, Gesamt as Numeric, nBreit_6 as Numeric, Font as FontType, VertLinie as PenType, Summe ref Numeric)
	C_S_Steuern = CreateCell(0, 0, CELL_TYPE_DYNHORZ + CELL_TYPE_DYNVERT + CELL_TYPE_HORZ)
	HandleLayout(C_S_Steuern, False, COLOR_TRANSPARENT, Font, PEN_NULL, VertLinie, 0)

	' Immer wie Einzelpreis
	nBreit_2 = 250
	' Immer wie Gesamtpreis
	nBreit_3 = nBreiteSpalte_7
	' Breite der Spalte 1 entspricht immer der Gesamtbreite abzüglich Einzelpreis und Gesamtpreis
	nBreit_1 = Gesamt - nBreit_3 - nBreit_2

	C_S_St_Spalte_1 = GetFormatCell(nBreit_1, 0, C_S_Steuern, C_C_S_SPALTE)
	SetCellStandard(C_S_St_Spalte_1, Font, CELL_TEXT_LEFT, -1)
	C_S_St_Spalte_2 = GetFormatCell(nBreit_2, 0, C_S_Steuern, C_C_S_SPALTE)
	SetCellStandard(C_S_St_Spalte_2, Font, CELL_TEXT_RIGHT, -1)
	C_S_St_Spalte_3 = GetFormatCell(nBreit_3, 0, C_S_Steuern, C_C_S_SPALTE)
	SetCellStandard(C_S_St_Spalte_3, Font, CELL_TEXT_RIGHT, -1)
	SetCellBorder(C_S_St_Spalte_3, CELL_BORDER_LEFT, 0, VertLinie, COLOR_BLACK)

	dim szTemp as string = "zzgl. " + FormatNumeric("%.2f", GetNumeric("R", n1)) + " % " + sUstText + " auf"
	if n1 > 80 Then
		szTemp = szTemp + " Nebenleistungen"
	End if
	SetCellText(C_S_St_Spalte_1, szTemp )
	If n2 <> 0 Then
		'if nBreiteSpalte_5 > 0 Then
		SetCellText(C_S_St_Spalte_2, HCS(GetCurrencyFormat("R", n2, CC_ORG, nCurrencyFormatDefault)))
		'end if
	End If
	SetCellText(C_S_St_Spalte_3, HCS(GetCurrencyFormatValue("R", n3, CC_ORG, nCurrencyFormatDefault, Betrag)))
	Summe = Summe + Betrag
	DrawCell(C_S_Steuern, true)
End Function

'////////////////////////////////////////////////////////////////////////////////////
'Funktion - SteuerfreiNetto
'Hilfsfunktion für die Ausgabe von steuerfreien Leistungen
'/////////////////////////////////////////////////////////////
Function Steuerfrei(n1 as Numeric, Gesamt as Numeric, nBreit_6 as Numeric, Font as FontType, VertLinie as PenType)
	' Immer wie Einzelpreisspalte
	nBreit_4 = 250
	' Breite der Spalte 5 ist nur zum Formatieren, immer wie Rabattspalte und Einzelpreis
	nBreit_5 = 450
	' Immer wie Gesamtpreis
	nBreit_6 = nBreiteSpalte_7
	' was übrigbleibt
	nBreit_1 = Gesamt - nBreit_4 - nBreit_5 - nBreit_6

	C_S_Steuern = CreateCell(0, 0, CELL_TYPE_DYNHORZ + CELL_TYPE_DYNVERT + CELL_TYPE_HORZ)
	HandleLayout(C_S_Steuern, False, COLOR_TRANSPARENT, Font, PEN_NULL, VertLinie, 0)
	C_S_St_Spalte_1 = GetFormatCell(nBreit_1, 0, C_S_Steuern, C_C_S_SPALTE)
	SetCellStandard(C_S_St_Spalte_1, Font, CELL_TEXT_LEFT, -1)
	C_S_St_Spalte_4 = GetFormatCell(nBreit_4, 0, C_S_Steuern, C_C_S_SPALTE)
	C_S_St_Spalte_5 = GetFormatCell(nBreit_5, 0, C_S_Steuern, C_C_S_SPALTE)
	SetCellStandard(C_S_St_Spalte_5, Font, CELL_TEXT_RIGHT, -1)
	C_S_St_Spalte_6 = GetFormatCell(nBreit_6, 0, C_S_Steuern, C_C_S_SPALTE)
	SetCellBorder(C_S_ST_Spalte_6, CELL_BORDER_LEFT, 0, VertLinie, COLOR_BLACK)
	SetCellStandard(C_S_St_Spalte_4, Font, CELL_TEXT_RIGHT, -1)
	If n1 > 100 Then
		SetCellText(C_S_St_Spalte_1, "steuerfreie Nebenleistungen" + sGrundstfrei  )
	Else
		If n1 <> 0 Then
			SetCellText(C_S_St_Spalte_1, "steuerfrei" + sGrundstfrei  )
		Else
			SetCellText(C_S_ST_Spalte_1, "Gesamt steuerfrei" + sGrundstfrei  )
		End If
	End If
	'if nBreiteSpalte_5 > 0 Then
	SetCellText(C_S_St_Spalte_5, HCS(GetCurrencyFormat("R",  n1, CC_ORG, nCurrencyFormatDefault)))
	'end if
'	SetCellBorder(C_S_Steuern, CELL_BORDER_BOTTOM, 1, HorzLinienArt, COLOR_BLACK)										'Zeile mit Rahmen
	if b13Umsatzsteuer = false then
		DrawCell(C_S_Steuern, true)
	end if
End Function

'////////////////////////////////////////////////////////////////////////////////////
'Funktion - SteuernAusgabeBrutto
'Hilfsfunktion für die Ausgabe der Steuern
'/////////////////////////////////////////////////////////////
Function SteuernAusgabeBrutto(n1 as Numeric, n2 as Numeric, n3 as Numeric, n4 as Numeric, Gesamt as Numeric, nBreit_6 as Numeric, Font as FontType, VertLinie as PenType, Summe ref Numeric)
	C_S_SteuernBrutto = CreateCell(0, 0, CELL_TYPE_DYNHORZ + CELL_TYPE_DYNVERT + CELL_TYPE_HORZ)
	HandleLayout(C_S_SteuernBrutto, False, COLOR_TRANSPARENT, Font, PEN_NULL, VertLinie, 0)

	' Breite der Spalte 1 entspricht immer der Gesamtbreite abzüglich Einzelpreis und Gesamtpreis
	nBreit_1 = 150
	nBreit_1a = 500

	' Immer wie Einzelpreis
	nBreit_2 = 250
	' Immer wie Gesamtpreis
	nBreit_3 = nBreiteSpalte_7
	nBreit_4 = Gesamt - nBreit_3 - nBreit_2 - 650

	C_S_St_Spalte_1 = GetFormatCell(nBreit_1, 0, C_S_SteuernBrutto, C_C_S_SPALTE)
	SetCellStandard(C_S_St_Spalte_1, Font, CELL_TEXT_RIGHT, -1)
	C_S_St_Spalte_1a = GetFormatCell(nBreit_1a, 0, C_S_SteuernBrutto, C_C_S_SPALTE)
	SetCellStandard(C_S_St_Spalte_1a, Font, CELL_TEXT_LEFT, -1)
	C_S_St_Spalte_2 = GetFormatCell(nBreit_2, 0, C_S_SteuernBrutto, C_C_S_SPALTE)
	SetCellBorder(C_S_St_Spalte_3, CELL_BORDER_LEFT, 0, PEN_NULL, COLOR_Transparent)
	SetCellStandard(C_S_St_Spalte_2, Font, CELL_TEXT_RIGHT, -1)
	C_S_St_Spalte_3 = GetFormatCell(nBreit_3, 0, C_S_SteuernBrutto, C_C_S_SPALTE)
	SetCellStandard(C_S_St_Spalte_3, Font, CELL_TEXT_RIGHT, -1)
	SetCellBorder(C_S_St_Spalte_3, CELL_BORDER_LEFT, 0, PEN_NULL, COLOR_Transparent)

	C_S_St_Spalte_4 = GetFormatCell(nBreit_4, 0, C_S_SteuernBrutto, C_C_S_SPALTE)
	SetCellStandard(C_S_St_Spalte_4, Font, CELL_TEXT_LEFT, -1)

	dim szTemp as string = FormatNumeric("%.2f", GetNumeric("R", n1)) + " % "
	SetCellText(C_S_St_Spalte_1, szTemp )

	if n1 > 80 Then
		szTemp = sUstText + " aus Nebenleistungen"
	Else
		szTemp = sUstText + " aus"
	End if
	SetCellText(C_S_St_Spalte_1a, szTemp )

	If n2 <> 0 Then
		'if nBreiteSpalte_5 > 0 Then
		SetCellText(C_S_St_Spalte_2, HCS(GetCurrencyFormat("R", n2, CC_ORG, nCurrencyFormatDefault)))
		'end if
	End If
	SetCellText(C_S_St_Spalte_3, HCS(GetCurrencyFormatValue("R", n3, CC_ORG, nCurrencyFormatDefault, Betrag)))
	SetCellText(C_S_St_Spalte_4, "      Netto  = " + HCS(GetCurrencyFormatValue("R", n4, CC_ORG, nCurrencyFormatDefault, Betrag)))
	Summe = Summe + Betrag
	SetCellBorder(C_S_SteuernBrutto, CELL_BORDER_LEFT + CELL_BORDER_RIGHT , 1, VertLinienArt, COLOR_BLACK)										'Zeile mit Rahmen
	DrawCell(C_S_SteuernBrutto, true)
End Function


'////////////////////////////////////////////////////////////////////////////////////
'Funktion - SteuerfreiBrutto
'Hilfsfunktion für die Ausgabe von steuerfreien Leistungen
'/////////////////////////////////////////////////////////////
Function SteuerfreiBrutto(n1 as Numeric, Gesamt as Numeric, nBreit_6 as Numeric, Font as FontType, VertLinie as PenType)

	' Immer wie Einzelpreisspalte
	nBreit_1 = 650
	nBreit_4 = 250
	' Breite der Spalte 5 ist nur zum Formatieren, immer wie Rabattspalte und Einzelpreis
'	nBreit_5 = 400
	' Immer wie Gesamtpreis
'	nBreit_6 = 0
	' was übrigbleibt
	nBreit_5 = Gesamt - nBreit_4 - nBreit_1'- nBreit_5 - nBreit_6

	C_S_SteuernBrutto = CreateCell(0, 0, CELL_TYPE_DYNHORZ + CELL_TYPE_DYNVERT + CELL_TYPE_HORZ)
	HandleLayout(C_S_SteuernBrutto, False, COLOR_TRANSPARENT, Font, PEN_NULL, VertLinie, 0)
	C_S_St_Spalte_1 = GetFormatCell(nBreit_1, 0, C_S_SteuernBrutto, C_C_S_SPALTE)
	SetCellStandard(C_S_St_Spalte_1, Font, CELL_TEXT_LEFT, -1)
	C_S_St_Spalte_4 = GetFormatCell(nBreit_4, 0, C_S_SteuernBrutto, C_C_S_SPALTE)
	C_S_St_Spalte_5 = GetFormatCell(nBreit_5, 0, C_S_SteuernBrutto, C_C_S_SPALTE)
	SetCellStandard(C_S_St_Spalte_5, Font, CELL_TEXT_RIGHT, -1)
'	C_S_St_Spalte_6 = GetFormatCell(nBreit_6, 0,C_S_SteuernBrutto, C_C_S_SPALTE)
'	SetCellBorder(C_S_ST_Spalte_6, CELL_BORDER_LEFT, 0, VertLinie, COLOR_BLACK)
	SetCellStandard(C_S_St_Spalte_4, Font, CELL_TEXT_RIGHT, -1)
	If n1 > 100 Then
		SetCellText(C_S_St_Spalte_1, "steuerfreie Nebenleistungen" + sGrundstfrei  )
	Else
		If n1 <> 0 Then
			SetCellText(C_S_St_Spalte_1, "steuerfrei" + sGrundstfrei  )
		Else
			SetCellText(C_S_ST_Spalte_1, "Gesamt steuerfrei" + sGrundstfrei  )
		End If
	End If
	'if nBreiteSpalte_5 > 0 then
	SetCellText(C_S_St_Spalte_4, HCS(GetCurrencyFormat("R",  n1, CC_ORG, nCurrencyFormatDefault)))
	SetCellText(C_S_St_Spalte_5, "")

	'end if
'	SetCellBorder(C_S_SteuernBrutto, CELL_BORDER_BOTTOM, 1, HorzLinienArt, COLOR_BLACK) 'Zeile mit Rahmen
	SetCellBorder(C_S_SteuernBrutto, CELL_BORDER_LEFT + CELL_BORDER_RIGHT , 1, VertLinienArt, COLOR_BLACK)										'Zeile mit Rahmen

	if b13Umsatzsteuer = false then
		DrawCell(C_S_SteuernBrutto, true)
	end if
End Function


'////////////////////////////////////////////////////////////////////////////////////
'Funktion - ZaehleSteuersaetze
'Hilfsfunktion für die Ermittlung der Anzahl der Steuersätze, wird für die Berechnung der Ausgabe benötigt
'/////////////////////////////////////////////////////////////
Function ZaehleSteuersaetze() as Numeric
	ZaehleSteuerSaetze = 0
	If GetNumeric("R", 53) <> 0 Then
		ZaehleSteuersaetze = ZaehleSteuersaetze + 1
	End If
	If GetNumeric("R", 54) <> 0 Then
		ZaehleSteuersaetze = ZaehleSteuersaetze + 1
	End If
	If GetNumeric("R", 55) <> 0 Then
		ZaehleSteuersaetze = ZaehleSteuersaetze + 1
	End If
	If GetNumeric("R", 56) <> 0 Then
		ZaehleSteuersaetze = ZaehleSteuersaetze + 1
	End If
	If GetNumeric("R", 57) <> 0 Then
		ZaehleSteuersaetze = ZaehleSteuersaetze + 1
	End If
	If GetNumeric("R", 98) <> 0 Then
		ZaehleSteuersaetze = ZaehleSteuersaetze + 1
	End If
	If GetNumeric("R", 99) <> 0 Then
		ZaehleSteuersaetze = ZaehleSteuersaetze + 1
	End If
	If GetNumeric("R", 100) <> 0 Then
		ZaehleSteuersaetze = ZaehleSteuersaetze + 1
	End If
	If GetNumeric("R", 101) <> 0 Then
		ZaehleSteuersaetze = ZaehleSteuersaetze + 1
	End If
	If GetNumeric("R", 102) <> 0 Then
		ZaehleSteuersaetze = ZaehleSteuersaetze + 1
	End If
End Function
'////////////////////////////////////////////////////////////////////////////////////
'Funktion - ZaehleSteuersaetze
'Hilfsfunktion für die Ermittlung der Anzahl der Steuersätze, wird für die Berechnung der Ausgabe benötigt
'/////////////////////////////////////////////////////////////
Function ZaehleSteuersaetzeBrutto() as Numeric
	ZaehleSteuersaetzeBrutto = 0
	If GetNumeric("R", 58) <> 0 Then
		ZaehleSteuersaetzeBrutto = ZaehleSteuersaetzeBrutto + 1
	End If
	If GetNumeric("R", 59) <> 0 Then
		ZaehleSteuersaetzeBrutto = ZaehleSteuersaetzeBrutto + 1
	End If
	If GetNumeric("R", 60) <> 0 Then
		ZaehleSteuersaetzeBrutto = ZaehleSteuersaetzeBrutto + 1
	End If
	If GetNumeric("R", 61) <> 0 Then
		ZaehleSteuersaetzeBrutto = ZaehleSteuersaetzeBrutto + 1
	End If
	If GetNumeric("R", 62) <> 0 Then
		ZaehleSteuersaetzeBrutto = ZaehleSteuersaetzeBrutto + 1
	End If
	If GetNumeric("R", 103) <> 0 Then
		ZaehleSteuersaetzeBrutto = ZaehleSteuersaetzeBrutto + 1
	End If
	If GetNumeric("R", 104) <> 0 Then
		ZaehleSteuersaetzeBrutto = ZaehleSteuersaetzeBrutto + 1
	End If
	If GetNumeric("R", 105) <> 0 Then
		ZaehleSteuersaetzeBrutto = ZaehleSteuersaetzeBrutto + 1
	End If
	If GetNumeric("R", 106) <> 0 Then
		ZaehleSteuersaetzeBrutto = ZaehleSteuersaetzeBrutto + 1
	End If
	If GetNumeric("R", 107) <> 0 Then
		ZaehleSteuersaetzeBrutto = ZaehleSteuersaetzeBrutto + 1
	End If
End Function
'////////////////////////////////////////////////////////////////////////////////////
'Funktion - GetZusatzText
'Hilfsfunktion für die Ermittlung der Zusatztexte für die Fusszeile
'/////////////////////////////////////////////////////////////
Function GetZusatzText(nNumber as Numeric) as String
	DIM s as String = ""
	if nNumber = 1 then
		s = sFusszeileText1
	end if
	if nNumber = 2 then
		s = sFusszeileText2
	end if
	if nNumber = 3 then
		s = sFusszeileText3
	end if
	GetZusatzText = s
End Function

'//////////////////////////////////////////////////////////
'Auswertung der Combobox aus der freien Kopfzeile
'//////////////////////////////////////////////////////////
dim strTextLine as string = ""

function InhaltCombo(iCbn as numeric, strfreierText as string)


		if iCbn = 0 then
				strTextLine = strfreierText
		else
			if iCbn = 1 then
				strTextLine = Get(FA_NAME_1)
			else
				if iCbn = 2 then
					strTextLine = Get(FA_NAME_2)
				end if
					if iCbn = 3 then
						strTextLine = Get(FA_STRASSE)
					end if
						if iCbn = 4 then
							strTextLine = Get(FA_PLZ) + " " + Get(FA_ORT)
						end if
							if iCbn = 5 then
								strTextLine = Get(FA_TEL)
							end if

									if iCbn = 6 then
										strTextLine = Get(FA_FAX)
									end if
										if iCbn = 7 then
											strTextLine = Get(FA_eMAIL)
										end if

			end if
		end if

end function

'////////////////////////////////////////////////////////////////////////////////////
'Funktion - KopfZeile()
'Kopfzeile einer Seite drucken
'Der Druckbereich ist begrenzt auf den Bereich der in SetHeaderMargin() festgelegt wurde
'/////////////////////////////////////////////////////////////
Function KopfZeile()

	Dim bKopfzeileAnzeigen as bool = FALSE
	Dim nLinksFirst as numeric = nKopfFirstLinks '- nRandLinks
	Dim nObenFirst as numeric	= nKopfFirstOben '- nRandOben
	Dim nLinksNext as numeric	= nKopfNextLinks '- nRandLinks
	Dim nObenNext as numeric 	= nKopfNextOben '- nRandOben

	'wann darf Kopfzeile angezeigt werden ?
	if (bMitKopfzeileAufSeite1) and (nAuftragPage <= 1) then
		bKopfzeileAnzeigen = TRUE
	end if
	if (bMitKopfzeileAbSeite2) and (nAuftragPage > 1) then
		bKopfzeileAnzeigen = TRUE
	end if

	Dim iCbn as Numeric = 0
	Dim InhaltfreieKopfzeile as numeric
	Dim strTextLine1 as string
	Dim strTextLine2 as string
	Dim strTextLine3 as string
	Dim strTextLine4 as string
	Dim strTextLine5 as string
	Dim strTextLine6 as string
	Dim strTextLine7 as string
	Dim strTextLine8 as string
	Dim strTextLine9 as string
	Dim strTextLine10 as string

	strFirmenanschrift = ""

	if bKopfzeileAnzeigen then
		if bFreieKopfzeile then
			include "freieKopfzeile.lsf"
		else

			if is("L", 380) = FALSE then  'KOPFZEILE über 1. Zeile und folgende (Blöcke steuern)

					' Ausgabe der Zeile 1 mit der gewählten Schriftart
					SelectFont(SchriftArtKopfzeile)
					DrawTextExt(nKopfFirstLinks, nKopfFirstOben, Get(FA_NAME_1) + " " + Get(FA_NAME_2))
					' Ausgabe der Zeile 1 mit der gewählten Schriftart
					SelectFont(SchriftArtKopfFolgende)

					If Get(FA_STRASSE) <> "" then
						strFirmenanschrift = Get(FA_STRASSE) + ", "
					End If
					If Get(FA_PLZ) <> "" Then
						strFirmenanschrift = strFirmenanschrift + Get(FA_PLZ) + " "
					End If
					If Get(FA_ORT) <> "" Then
						strFirmenanschrift = strFirmenanschrift + Get(FA_ORT)
					End If
					DrawTextExt(nKopfNextLinks, nKopfNextOben, strFirmenanschrift)
					If Get(FA_TEL) <> "" Then
						strTelFax = "Tel. " + Get(FA_TEL) + " "
					End If
					If Get(FA_FAX) <> "" Then
						strTelFax = strTelFax + "Fax. " + Get(FA_FAX) + " "
					End If
					DrawTextExt(nKopfNextLinks, nKopfNextOben + (GetPosY() + GetLineHeight ()), strTelFax)
					If Get(FA_eMAIL) <> "" Then
						DrawTextExt(nKopfNextLinks, nKopfNextOben + (2*(GetPosY() + GetLineHeight ())), "E-Mail: " + Get(FA_eMAIL))
						If sKopfzeileText1 <> "" Then
							DrawTextExt(nKopfNextLinks, nKopfNextOben + (3*(GetPosY() + GetLineHeight ())), Get(LAY_KOPF_TEXT1))
						end if
					else
						If sKopfzeileText1 <> "" Then
							DrawTextExt(nKopfNextLinks, nKopfNextOben + (2*(GetPosY() + GetLineHeight ())), Get(LAY_KOPF_TEXT1))
						end if
					End If
			else	'Kopfzeilenorientierung LINKS, MITTE oder ZENTRIERT
					if nKopfZeileTextOrientation = LINKS then
						SetTabs("L")
					end if
					if nKopfZeileTextOrientation = RECHTS then
						SetTabs("R")
					end if
					if nKopfZeileTextOrientation = MITTE then
						SetTabs("C")
					end if
					' Ausgabe der Zeile 1 mit der gewählten Schriftart
					SelectFont(SchriftArtKopfzeile)
					TL(Tab + Get(FA_NAME_1) + " " + Get(FA_NAME_2))

					' Schriftart für die folgenden Zeilen
					if bSchriftArtNurZeile1 = true then
						SelectFont(SchriftArtStandard)
					else
						SelectFont(SchriftArtKopfFolgende)
					end if
					If Get(FA_STRASSE) <> "" then
						strFirmenanschrift = Get(FA_STRASSE) + ", "
					End If
					If Get(FA_PLZ) <> "" Then
						strFirmenanschrift = strFirmenanschrift + Get(FA_PLZ) + " "
					End If
					If Get(FA_ORT) <> "" Then
						strFirmenanschrift = strFirmenanschrift + Get(FA_ORT)
					End If
					strFirmenanschrift = strFirmenanschrift + "\n" + Tab
					If Get(FA_TEL) <> "" Then
						strFirmenanschrift = strFirmenanschrift + "Tel. " + Get(FA_TEL) + " "
					End If
					If Get(FA_FAX) <> "" Then
						strFirmenanschrift = strFirmenanschrift + "Fax. " + Get(FA_FAX) + " "
					End If
					If Get(FA_eMAIL) <> "" Then
						strFirmenanschrift = strFirmenanschrift + "E-Mail: " + Get(FA_eMAIL)
					End If
					strFirmenanschrift = strFirmenanschrift + "\n" + Tab
					If sKopfzeileText1 <> "" Then
						SetWordWrap(TRUE)
						strFirmenanschrift = strFirmenanschrift + Get(LAY_KOPF_TEXT1)
					end if
					TL(Tab + strFirmenanschrift)
			end if
		end if


	end if
	' Standardschriftart wiederherstellen
	SelectFont(SchriftArtStandard)
End Function

'////////////////////////////////////////////////////////////////////////////////////
'Funktion - EventKopfZeile()
'Kopfzeile einer Seite drucken, wird als Eventfunktion nach jedem Seitenwechsel aufgerufen
'/////////////////////////////////////////////////////////////
Function EventKopfZeile()
	KopfZeile()
End Function

' Ereignishandler für die Kopfzeile setzen
' Dadurch wird Funktion automatisch bei jedem Seitenanfang aufgerufen
SetEventHandler(EVENT_PRINT_HEADER, EventKopfZeile)


'////////////////////////////////////////////////////////////////////////////////////
'Funktion - FussZeile()
'Fusszeile einer Seite drucken
'Der Druckbereich ist begrenzt auf den Bereich der in SetFooterMargin() festgelegt wurde
'/////////////////////////////////////////////////////////////
Function FussZeile()

	Dim bFusszeileAnzeigen as bool = FALSE
	Dim sNextText as string = sFusszeileText1
	DIM nTextCount as numeric = 1
	dim Tab1 as numeric
	dim Tab2 as numeric
	dim Tab3 as numeric
	dim Tab4 as numeric

	dim strTab as string
	dim strTab1 as string
	dim strTab2 as string
	dim strTab3 as string
	dim strTab4 as string

	dim strCol1 as String = ""
	dim strCol2 as String = ""
	dim strCol3 as String = ""
	dim strZeile as String = ""
	dim strPreText as String = ""
	dim bHasBank1 as bool = False
	dim bHasBank2 as bool = False

	if bMitFussKonto or bMitFussIban or bMitFussBic then
		If Get(FA_BANK_1) <> "" Then
			bHasBank1 = True
		end if
		If Get(FA_BANK_2) <> "" Then
			bHasBank2 = True
		end if
		if bHasBank1 and bHasBank2 then
			strPreText = Tab + "Bankverbindungen:" 'Mehrzahl
		else
			strPreText = Tab + "Bankverbindung:"
		end if
	end if

	'wann darf Fußzeile angezeigt werden ?
	if bMitFusszeileAufSeite1 and nAuftragPage <= 1 then
		bFusszeileAnzeigen = TRUE
	end if
	if bMitFusszeileAbSeite2 and nAuftragPage > 1 then
		bFusszeileAnzeigen = TRUE
	end if

	if bFusszeileAnzeigen then
		' die Schrift für die Fusszeile auswählen
		SelectFont(SchriftArtFusszeile)
		if bMitFussLinie then
			DrawLine(1700, GetPosY())
		end if
		lf
		if bFreieFusszeile then
			include "freieFusszeile.lsf"
		else
			if GetNumeric(LAY_AUSRICHTUNG_OPTION)= 0 then 'Fusszeile zentriert
				RemoveAllTabs()
				SetTabs("C")
				if bHasBank1 or bHasBank2 then
					TL( Tab + strPreText )
				end if
				if bHasBank1 then
					'----- BANK 1 ausgeben -----
					strZeile = Tab + Get(FA_BANK_1)
					if bMitFussKonto then
						strZeile = strZeile + " · BLZ " + Get(FA_BLZ_1) + " · Kto.-Nr. " + Get(FA_KTONR_1)
					end if
					if bMitFussKonto then
						TL( strZeile )
						strZeile = ""
					end if
					if bMitFussIban And ( Get(FA_IBAN_1) <> "" ) then
						if strZeile = "" then
							strZeile = Tab
						else
							strZeile = strZeile + " · "
						end if
						strZeile = strZeile + "IBAN  " + Get(FA_IBAN_1)
					end if
					if bMitFussBic And (Get(FA_BIC_1) <> "") then
						if strZeile = "" then
							strZeile = Tab
						else
							strZeile = strZeile + " · "
						end if
						strZeile = strZeile + "BIC  " + Get(FA_BIC_1)
					end if
					if strZeile <> "" then
						TL(strZeile)
					end if
				end if

				if bHasBank2 then
					'----- BANK 2 ausgeben -----
					strZeile = Tab + Get(FA_BANK_2)
					if bMitFussKonto then
						strZeile = strZeile + " · BLZ " + Get(FA_BLZ_2) + " · Kto.-Nr. " + Get(FA_KTONR_2)
					end if
					if bMitFussKonto then
						TL( strZeile )
						strZeile = ""
					end if
					if bMitFussIban And ( Get(FA_IBAN_2) <> "" ) then
						if strZeile = "" then
							strZeile = Tab
						else
							strZeile = strZeile + " · "
						end if
						strZeile = strZeile + "IBAN  " + Get(FA_IBAN_2)
					end if
					if bMitFussBic And (Get(FA_BIC_2) <> "") then
						if strZeile = "" then
							strZeile = Tab
						else
							strZeile = strZeile + " · "
						end if
						strZeile = strZeile + "BIC  " + Get(FA_BIC_2)
					end if
					if strZeile <> "" then
						TL(strZeile)
					end if
				end if

				if (bMitFusszeileEGUSTID = True) and (Get(FA_EGID) <> "") Then
					TL(Tab + "USt-IdNr.: " + Get(FA_EGID))
				end if
				sNextText = GetZusatzText( 1 )
				if sNextText <> "" Then
					TL(Tab + sNextText)
				end if
				sNextText = GetZusatzText( 2 )
				if sNextText <> "" Then
					TL(Tab + sNextText)
				end if
				sNextText = GetZusatzText( 3 )
				if sNextText <> "" Then
					TL(Tab + sNextText)
				end if

				if (bMitFusszeileFzSteuernummer = True) And (Get(FZ_STEUERNUMMER) <> "") Then
					TL(Tab  + "Steuernr: " + Get(FZ_STEUERNUMMER))
				end if
				if bMitFusszeileFzAnschrift Then
					if Get(FZ_FINAMT_NAME) <> "" then
						TL(Tab + Get(FZ_FINAMT_NAME) + " · " + Get(FZ_FINAMT_STRASSE) + " · " + GET(FZ_FINAMT_PLZ) + " " + Get(FZ_FINAMT_ORT) )
					end if
				end if
				if bMitFusszeileFzBankverbindung Then
					if Get(FZ_FINAMT_BANK) <> "" Then
						strTemp = Tab + "Bankverbindung-Finanzamt: " + Get(FZ_FINAMT_BANK)
						if Get(FZ_FINAMT_IBAN) <> "" then
							strTemp = strTemp + " · IBAN " + Get(FZ_FINAMT_IBAN)
						end if
						if Get(FZ_FINAMT_BIC) <> "" then
							strTemp = strTemp + " · BIC " + Get(FZ_FINAMT_BIC)
						end if
						TL(strTemp)
					end if
				end if
		else 'Fusszeile über Blöcke einstellen
				if GetNumeric(LAY_AUSRICHTUNG_OPTION)= 1 then 'Fusszeile zentriert

					RemoveAllTabs()
					Tab1 = GetNumeric("L", 370)* 100
					Tab2 = GetNumeric("L", 371)* 100
					Tab3 = GetNumeric("L", 372)* 100
					Tab4 = GetNumeric("L", 373)* 100

					strTab1 = FormatNumeric("%.0f", Tab1)
					strTab4 = FormatNumeric("%.0f", Tab4)

					if bhasBank1 = False and bhasBank2 = False then
						strTab2 = strTab1
						strTab3 = strTab1
					else
						strTab2 = FormatNumeric("%.0f", Tab2)
						strTab3 = FormatNumeric("%.0f", Tab3)
					end if

					strTab = "L" + strTab1 + " L" + strTab2 +  " L" + strTab3 +  " L" + strTab4
					SetTabs(strTab)

					'Zeile Name
					if bhasBank1 then
						strCol1 = Get(FA_BANK_1)
					end if
					if bhasBank2 then
						if bhasBank1 then
							strCol2 = Get(FA_BANK_2)
						else
							strCol1 = Get(FA_BANK_2)
							strCol2 = "          "
						end if
					end if
					if (bMitFusszeileEGUSTID = true) and (Get(FA_EGID) <> "") then
						strCol3 = "USt-IdNr.: " + Get(FA_EGID)
					else
						strCol3 = GetZusatzText( nTextCount )
						nTextCount = nTextCount + 1
					end if
					TL( strPreText + Tab + strCol1 + Tab + strCol2 + Tab + strCol3 )

					RemoveAllTabs()
					strTab = "L" + strTab2 + " L" + strTab3 + " L" + strTab4
					SetTabs(strTab)

					'Zeile BLZ
					if bMitFussKonto And ((Get(FA_BLZ_1)<>"") Or (Get(FA_BLZ_2)<>"")) then
						strPreText = "BLZ       "
						if bhasBank1 then
							strCol1 = strPreText + Get(FA_BLZ_1)
						end if
						if bhasBank2 then
							if bhasBank1 then
								strCol2 = strPreText + Get(FA_BLZ_2)
							else
								strCol1 = strPreText + Get(FA_BLZ_2)
								strCol2 = "          "
							end if
						end if
						strCol3 = GetZusatzText( nTextCount )
						nTextCount = nTextCount + 1
						TL( Tab + strCol1 + Tab + strCol2 + Tab + strCol3 )
					end if

					'Zeile Konto
					if bMitFussKonto And ((Get(FA_KTONR_1)<>"") Or (Get(FA_KTONR_2)<>"")) then
						strPreText = "Kto.-Nr. "
						if bhasBank1 then
							strCol1 = strPreText + Get(FA_KTONR_1)
						end if
						if bhasBank2 then
							if bhasBank1 then
								strCol2 = strPreText + Get(FA_KTONR_2)
							else
								strCol1 = strPreText + Get(FA_KTONR_2)
								strCol2 = "          "
							end if
						end if
						strCol3 = GetZusatzText( nTextCount )
						nTextCount = nTextCount + 1
						TL( Tab + strCol1 + Tab + strCol2 + Tab + strCol3 )
					end if

					'Zeile IBAN
					if bMitFussIban And ((Get(FA_IBAN_1) <> "") Or (Get(FA_IBAN_2) <> "")) then
						strPreText = "IBAN:    "
						if bhasBank1 then
							strCol1 = strPreText + Get(FA_IBAN_1)
						end if
						if bhasBank2 then
							if bhasBank1 then
								strCol2 = strPreText + Get(FA_IBAN_2)
							else
								strCol1 = strPreText + Get(FA_IBAN_2)
								strCol2 = "          "
							end if
						end if
						strCol3 = GetZusatzText( nTextCount )
						nTextCount = nTextCount + 1
						TL( Tab + strCol1 + Tab + strCol2 + Tab + strCol3 )
					end if

					'Zeile BIC
					if bMitFussBic And ((Get(FA_BIC_1) <> "") Or (Get(FA_BIC_2) <> "")) then
						strPreText = "BIC:      "
						if bhasBank1 then
							strCol1 = strPreText + Get(FA_BIC_1)
						end if
						if bhasBank2 then
							if bhasBank1 then
								strCol2 = strPreText + Get(FA_BIC_2)
							else
								strCol1 = strPreText + Get(FA_BIC_2)
								strCol2 = "          "
							end if
						end if
						strCol3 = GetZusatzText( nTextCount )
						nTextCount = nTextCount + 1
						TL( Tab + strCol1 + Tab + strCol2 + Tab + strCol3 )
					end if

					if strTab2 = strTab1 then
						strPreText = Tab + "     "
					else
						strPreText = Tab + "     " + Tab + "     "
					end if

					while nTextCount < 4 do
						strCol3 = GetZusatzText( nTextCount )
						if strCol3 <> "" then
							TL( strPreText + Tab + strCol3 )
						end if
						nTextCount = nTextCount + 1
					end while

						if bMitFusszeileFzSteuernummer Then
							RemoveAllTabs()
							strTab = "L" + strTab4
							SetTabs(strTab)
							if Get(FZ_STEUERNUMMER) <> "" Then
								TL(Tab + "Steuernr: " + Get(FZ_STEUERNUMMER))
							end if
						else
							sNextText = GetZusatzText( nTextCount )
							RemoveAllTabs()
							strTab = "L" + strTab4
							SetTabs(strTab)
							if Get(FA_EGID) = "" then
								TL(Tab + sNextText + "\n")
							end if
						end if

						RemoveAllTabs()
						strTab = "L" + strTab1
						SetTabs(strTab)
						if bMitFusszeileFzAnschrift Then
							if Get(FZ_FINAMT_NAME) <> "" then
								TL(Tab + "Anschrift-Finanzamt: " + Get(FZ_FINAMT_NAME) + ", " + Get(FZ_FINAMT_STRASSE) + ", " + GET(FZ_FINAMT_PLZ) + " " + Get(FZ_FINAMT_ORT) )
							end if
						end if
						RemoveAllTabs()
						strTab = "L" + strTab1
						SetTabs(strTab)
						if bMitFusszeileFzBankverbindung Then
							if Get(FZ_FINAMT_BANK) <> "" Then
								strTemp = Tab + "Bankverbindung-Finanzamt: " + Get(FZ_FINAMT_BANK)
								if Get(FZ_FINAMT_IBAN) <> "" then
									strTemp = strTemp + " · IBAN " + Get(FZ_FINAMT_IBAN)
								end if
								if Get(FZ_FINAMT_BIC) <> "" then
									strTemp = strTemp + " · BIC " + Get(FZ_FINAMT_BIC)
								end if
								TL(strTemp)
							end if
						end if
				else 'oder Logo
					if GetNumeric(LAY_AUSRICHTUNG_OPTION)= 2 then
						SetPos(GetPosX(), GetPosY())
						DrawImage(nLogohorzFuss-nRandLinks, GetPosY(), nLogoBreiteFuss, nLogoHoeheFuss, strPfadLogoFuss)
					end if
				end if
			end if 'freie Fusszeile
		end if'("L", 489)
	end if

	' Standardschriftart wiederherstellen
	SelectFont(SchriftArtStandard)
End Function

'////////////////////////////////////////////////////////////////////////////////////
'Funktion - EventFussZeile()
'Fusszeile einer Seite drucken, wird als Eventfunktion nach jedem Seitenwechsel aufgerufen
'/////////////////////////////////////////////////////////////
Function EventFussZeile()
	Fusszeile()
End Function

' Ereignishandler für die FussZeile setzen
' Dadurch wird Funktion automatisch bei jedem Seitenende aufgerufen
SetEventHandler(EVENT_PRINT_FOOTER, EventFussZeile)

'///////////////////////////////////////////////////////////////////////////////////////////////
'Funktion - Seitenwechsel
'Funktion wird vor jedem Wechsel der Seite aufgerufen. Es werden alle Elemente außer der Tabelle gedruckt
'Der Druckbereich ist begrenzt auf den Bereich der in SetBodyMargin() festgelegt wurde
'/////////////////////////////////////////////////////////////
Function Seitenwechsel()
	DIM nX as numeric
	DIM nY as numeric

	' Seitennummerierung je Auftrag
	if fResetPage then
		nAuftragPage = 1
		fResetPage = false
	else
		nAuftragPage = nAuftragPage + 1
	end if

'	DIM n as numeric = nRandOben;
	' hier den Rumpfbereich wieder an den oberen Rand des Formulars ziehen, damit die nachfolgenden Felder
	' nicht tiefer dargestellt werden
	SetBodyMargin(nRandLinks, nRandOben, nRandRechts, nRandUnten + nFusszeileHoehe + 10)
	' Ausgaben für Seite 1
	if nAuftragPage = 1 then
		SetFormatNumericOptions(FN_CUSTOM, "", "")
		If bMitLogoAufSeite1 then
			DrawImage(nFirmenLogoLinks-nRandLinks, nFirmenLogoOben-nRandOben, nFirmenLogoBreite, nFirmenLogoHoehe, sFirmenLogoQuelle)
		End If
		If bMitLogo2AufSeite1 then
			DrawImage(nFirmenLogo2Links-nRandLinks, nFirmenLogo2Oben-nRandOben, nFirmenLogo2Breite, nFirmenLogo2Hoehe, sFirmenLogo2Quelle)
		End If
		' Absender anzeigen, wenn ausgewählt
		if is (FRANKIEREN_MIT_STAMPIT ) = FALSE Then
			if (bMitAbsenderAufSeite1 AND (is(FRANKIEREN_MIT_INTERNETMARKE)= FALSE))then
				PrintAbsenderZeile2018()
			end if
		else
			if is (FRANKIEREN_MIT_STAMPIT ) = TRUE Then
				if bStampitmitAbsender = TRUE then
					PrintAbsenderZeile2018()
				end if
			end if
		end if

		'Absenderzeile / Sichtfenster anzeigen, wenn ausgewählt
		if is(FRANKIEREN_MIT_STAMPIT ) Then
			PrintStampit(SchriftArtStamp)
		else
			if GetSichtfensterMode() = SichtfensterModeInternetmarke then
				PrintInternetmarke2018("de", false)
			else
				if bMitAbsenderAufSeite1 then
					PrintAbsenderZeile2018()
				end if
				if bMitSichtfensterAufSeite1 then
					PrintSichtfenster2018(SchriftArtSichtfenster, "de", false)
				end if
			end if
		end if

		' Infofeld anzeigen, wenn ausgewählt
		if bMitInfofeldAufSeite1 then
			PrintInfoBlock("L" + FormatNumeric("%.0f", nInfofeldLinks-nRandLinks) + "R" + FormatNumeric("%.0f", nInfofeldLinks - nRandLinks + nInfoFeldBreite), SchriftArtInfofeld)
		end if
		' Betrefftext anzeigen, wenn ausgewählt
		if bMitBetrefftextAufSeite1 then
			PrintBetreffText(SchriftArtBetrefftext1, SchriftArtBetrefftext2)
		end if
		if bFalzmarkeOben then
			SetPen(2, PEN_SOLID, COLOR_BLACK)
			DrawLineExt(-nRandLinks, -nRandOben+nFalzmarkeOben, -nRandLinks+80, -nRandOben+nFalzmarkeOben)
		end if
		if bFalzmarkeUnten then
			SetPen(2, PEN_SOLID, COLOR_BLACK)
			DrawLineExt(-nRandLinks, -nRandOben+nFalzmarkeUnten, -nRandLinks+80, -nRandOben+nFalzmarkeUnten)
		end if
		if bLochmarke then
			SetPen(2, PEN_SOLID, COLOR_BLACK)
			DrawLineExt(-nRandLinks, -nRandOben+nLochmarke, -nRandLinks+70, -nRandOben+nLochmarke)
		end if
	end if
	' Ausgaben ab Seite 2
	if nAuftragPage > 1 then
		SetFormatNumericOptions(FN_CUSTOM, "", "")
		' Firmenlogo ab Seite 2 anzeigen, wenn ausgewählt
		If bMitLogoAbSeite2 then
			DrawImage(nFirmenLogoLinks-nRandLinks, nFirmenLogoOben-nRandOben, nFirmenLogoBreite, nFirmenLogoHoehe, sFirmenLogoQuelle)
		End If
		If bMitLogo2AbSeite2 then
			DrawImage(nFirmenLogo2Links-nRandLinks, nFirmenLogo2Oben-nRandOben, nFirmenLogo2Breite, nFirmenLogo2Hoehe, sFirmenLogo2Quelle)
		End If
		' Absender ab Seite 2 anzeigen, wenn ausgewählt
		if bMitAbsenderAbSeite2 then
			PrintAbsenderZeile2018()
		end if
		'Sichtfenster ab Seite 2 anzeigen, wenn ausgewählt
		if bMitSichtfensterAbSeite2 then
			PrintSichtfenster2018(SchriftArtSichtfenster, "de", false)
		end if
		' Betrefftext ab Seite 2 anzeigen, wenn ausgewählt
		if bMitBetrefftextAbSeite2 then
			PrintBetreffText(SchriftArtBetrefftext1, SchriftArtBetrefftext2)
		end if
		' Infofeld ab Seite 2 anzeigen, wenn ausgewählt
			' Infozeile ?
			if	bInfoZeileStattInfoBlockAbSeite2 then
				PrintInfoZeile()
			else
				if bMitInfofeldAbSeite2 then
					PrintInfoBlock("L" + FormatNumeric("%.0f", nInfofeldLinks-nRandLinks) + "R" + FormatNumeric("%.0f", nInfofeldLinks - nRandLinks + nInfoFeldBreite), SchriftArtInfofeld)
				end if
			end if
		if bFalzmarkeOben then
			SetPen(2, PEN_SOLID, COLOR_BLACK)
			DrawLineExt(-nRandLinks, -nRandOben+nFalzmarkeOben, -nRandLinks+80, -nRandOben+nFalzmarkeOben)
		end if
		if bFalzmarkeUnten then
			SetPen(2, PEN_SOLID, COLOR_BLACK)
			DrawLineExt(-nRandLinks, -nRandOben+nFalzmarkeUnten, -nRandLinks+80, -nRandOben+nFalzmarkeUnten)
		end if
		if bLochmarke then
			SetPen(2, PEN_SOLID, COLOR_BLACK)
			DrawLineExt(-nRandLinks, -nRandOben+nLochmarke, -nRandLinks+70, -nRandOben+nLochmarke)
		end if
	end if
End Function


'///////////////////////////////////////////////////////////////////////////////////////////////
'Funktion - EventSeitenwechsel
'Funktion wird vor jedem Wechsel der Seite aufgerufen.
'Der Druckbereich ist begrenzt auf den Bereich der in SetBodyMargin() festgelegt wurde
'/////////////////////////////////////////////////////////////
Function EventSeitenwechsel()

	Seitenwechsel()
	' obere Position des Rumpfbereichs verändern, damit Tabelle nach unten versetzt dargestellt wird
	' Die Augabeposition der Tabelle ab Seite 2 kann nur über diesen Weg verändert werden.
	if nAuftragPage > 1 then
		SetBodyMargin(nRandLinks, nTabelleObenAbSeite2, nRandRechts, nRandUnten + nFusszeileHoehe + 10)
	end if
	' wenn Autoformat der Tabelle, dann linke Position bei der Positionnierung der Tabelle ignorieren
'	if bTabelleAutoFormat then
'		SetBodyMargin(nRandLinks, nTabelleObenAbSeite2, nRandRechts, nRandUnten + nFusszeileHoehe + 10)
'	else
'		SetBodyMargin(nTabelleLinksAbSeite2, nTabelleObenAbSeite2, nRandRechts, nRandUnten + nFusszeileHoehe + 10)
'	end if

End Function

' Ereignishandler für Anfang einer Seite setzen
' Dadurch wird Funktion automatisch bei jedem Seitenanfang aufgerufen
SetEventHandler(EVENT_START_PAGE, EventSeitenwechsel)

function OnUpdate(bLastTableCell as bool)
	dim strText as String = HCS(FormatCurrency(CC_LOC, nCurrencyFormatDefault, nSumme))

	SetCellStandard(C_S_Spalte_2, SchriftArtStandard, CELL_TEXT_RIGHT, -1)
	SetCellStandard(C_HU_Spalte_2, SchriftArtStandard, CELL_TEXT_RIGHT, -1)

	SetCellText(C_S_Spalte_2, strText)		'Setzen der Zwischensumme
	SetCellText(C_HU_Spalte_2, strText)		'Setzen des Übertrages
end function
'////////////////////////////////////////////////////////////////////////////////////
'Funktion - BaueTabelleNetto()
'Erzeugen der Tabelle, wenn NettoAuftrag (mit Spalten und Zeilen)
'/////////////////////////////////////////////////////////////
Function BaueTabelleNetto()
	Dim strWaehrung as String = "\n"
	strProzent = "\n"
	if bMitWaehrung = FALSE then
		strWaehrung = strWaehrung + GetCurrencySymbol(AUFTR_RG_BETRAG, bWaehrungAlsText)
		strProzent = strProzent + "%"
	end if

	nBreite = 0
	' wenn obere Postion der Tabelle auf Seite 1 automatisch positioniert werden soll
	' dann aktuelle Position abfragen und Tabelle darunter beginnen
	DIM nTabelleOben as numeric = nTabelleObenAufSeite1-nRandOben
	DIM nX as numeric
	DIM nY as numeric

	if bTabelleObenAufSeite1Auto then
		GetPos( nX, nY )
		nTabelleOben = nY + bTabelleObenAufSeite1AutoAbstand
	end if

	' wenn Autoformat( automatisches Anpassen der Breite), dann linke Position ignorieren
	if bTabelleAutoFormat then
		SetPos( 0 , nTabelleOben )
	else
		SetPos( nTabelleLinksAufSeite1-nRandLinks, nTabelleOben )
	end if

	'Definition der Überschriftenzeile
	C_H_Head = CreateCell(0, 0, CELL_TYPE_DYNHORZ + CELL_TYPE_DYNVERT + CELL_TYPE_VERT)
	C_H_Zeile = GetFormatCell(0, 0, C_H_Head, C_C_H_ZEILE)
	' Ausgabe der Steuern, nur wenn ausgewählt
	IF IS(LAY_TAB_MIT_STEUER) then
		C_HU_Zeile = GetFormatCell(0, 0, C_H_Head, C_C_H_ZEILE)
	end if
	SetCellBorder(C_H_Head, CELL_BORDER_ALL, 0, PEN_NULL, COLOR_TRANSPARENT)

	'Definition der Zeilen im Tabellenkörper
	'C_Zeile = CreateCell(0, 0, CELL_TYPE_DYNHORZ + CELL_TYPE_DYNVERT + CELL_TYPE_HORZ) -ohneZub
	C_Zeile = CreateCell(0, 0, CELL_TYPE_DYNHORZ + CELL_TYPE_DYNVERT + CELL_TYPE_HORZ + CELL_TYPE_BREAK)
	SetEventHandlerEx(EVENT_UPDATE, OnUpdate, C_Zeile)
	C_Zeile_s = CreateCell(0, 0, CELL_TYPE_DYNHORZ + CELL_TYPE_DYNVERT + CELL_TYPE_HORZ)

	'Definition der Summenzeilen
	C_S_Zeile = CreateCell(0, 0, CELL_TYPE_DYNHORZ + CELL_TYPE_DYNVERT + CELL_TYPE_HORZ)
	C_S_Noetig = CreateCell(0, 0, CELL_TYPE_DYNHORZ + CELL_TYPE_DYNVERT + CELL_TYPE_HORZ)

	C_S_Gesamt = CreateCell(0, 0, CELL_TYPE_DYNHORZ + CELL_TYPE_DYNVERT + CELL_TYPE_HORZ)
	C_S_Abschlag = CreateCell(0, 0, CELL_TYPE_DYNHORZ + CELL_TYPE_DYNVERT + CELL_TYPE_HORZ)

	if bMengenSpalteVorEPAuftrag = true then

		'Aussehen der Spalten im Tabellenkopf und -körper, wenn sich nicht um einen Lieferschein handelt
		C_H_Spalte_1 = GetFormatCell(nBreiteSpalte_1,	0, C_H_Zeile, C_C_H_SPALTE)	' "Pos"
		C_H_Spalte_3 = GetFormatCell(nBreiteSpalte_3,	0, C_H_Zeile, C_C_H_SPALTE)	' "Art.Nr."
		C_H_Spalte_8 = GetFormatCell(nBreiteSpalte_8,	0, C_H_Zeile, C_C_H_SPALTE)	' "Gewicht"
		C_H_Spalte_4 = GetFormatCell(nBreiteSpalte_4,	0, C_H_Zeile, C_C_H_SPALTE)	' "Text"
		C_H_Spalte_2 = GetFormatCell(nBreiteSpalte_2,	0, C_H_Zeile, C_C_H_SPALTE)	' "Menge"
		C_H_Spalte_5 = GetFormatCell(nBreiteSpalte_5,	0, C_H_Zeile, C_C_H_SPALTE)	' "Einzelpreis"
		C_H_Spalte_6 = GetFormatCell(nBreiteSpalte_6,	0, C_H_Zeile, C_C_H_SPALTE)	' "Rabatt"
		C_H_Spalte_6a = GetFormatCell(nBreiteSpalte_6a,	0, C_H_Zeile, C_C_H_SPALTE)	' "USt."
		C_H_Spalte_7 = GetFormatCell(nBreiteSpalte_7,	0, C_H_Zeile, C_C_H_SPALTE)	' "Gesamtpreis"

		C_Spalte_1 = GetFormatCell(nBreiteSpalte_1	, 0, C_Zeile, C_C_SPALTE)	' "Pos"
		C_Spalte_4 = GetFormatCell(nBreiteSpalte_3	, 0, C_Zeile, C_C_SPALTE)	' "Art.Nr"
		C_Spalte_9 = GetFormatCell(nBreiteSpalte_8	, 0, C_Zeile, C_C_SPALTE)	' "Gewicht"
		C_Spalte_5 = GetFormatCell(nBreiteSpalte_4	, 0, C_Zeile, C_C_SPALTE)	' "Text"
		C_Spalte_2 = GetFormatCell(nBreiteSpalte_2/2	, 0, C_Zeile, C_C_SPALTE)	' "Menge Stk"
		C_Spalte_3 = GetFormatCell(nBreiteSpalte_2/2	, 0, C_Zeile, C_C_SPALTE)	' "Menge Einheit"
		C_Spalte_6 = GetFormatCell(nBreiteSpalte_5	, 0, C_Zeile, C_C_SPALTE)	' "Einzelpreis"
		C_Spalte_7 = GetFormatCell(nBreiteSpalte_6	, 0, C_Zeile, C_C_SPALTE)	' "Rabatt"
		C_Spalte_7a = GetFormatCell(nBreiteSpalte_6a, 0, C_Zeile, C_C_SPALTE)	' "USt."
		C_Spalte_8 = GetFormatCell(nBreiteSpalte_7	, 0, C_Zeile, C_C_SPALTE)	' "Gesamtpreis"

		C_Spalte_1s = GetFormatCell(nBreiteSpalte_1	, 0, C_Zeile_s, C_C_SPALTE)	' "PosStücklistenart."
		C_Spalte_4s = GetFormatCell(nBreiteSpalte_3	, 0, C_Zeile_s, C_C_SPALTE)	' "Art.NrStücklistenart."
		C_Spalte_9s = GetFormatCell(nBreiteSpalte_8	, 0, C_Zeile_s, C_C_SPALTE)	' "GewichtStücklistenart."
		C_Spalte_5s = GetFormatCell(nBreiteSpalte_4	, 0, C_Zeile_s, C_C_SPALTE)	' "TextStücklistenart."
		C_Spalte_2s = GetFormatCell(nBreiteSpalte_2/2, 0, C_Zeile_s, C_C_SPALTE)' "Menge StkStücklistenart."
		C_Spalte_3s = GetFormatCell(nBreiteSpalte_2/2, 0, C_Zeile_s, C_C_SPALTE)' "Menge EinheitStücklistenart."
		C_Spalte_6s = GetFormatCell(nBreiteSpalte_5	, 0, C_Zeile_s, C_C_SPALTE)	' "EinzelpreisStücklistenart."
		C_Spalte_7s = GetFormatCell(nBreiteSpalte_6	, 0, C_Zeile_s, C_C_SPALTE)	' "RabattStücklistenart."
		C_Spalte_7sa = GetFormatCell(nBreiteSpalte_6a, 0, C_Zeile_s, C_C_SPALTE)	' "USt."
		C_Spalte_8s = GetFormatCell(nBreiteSpalte_7	, 0, C_Zeile_s, C_C_SPALTE)	' "GesamtpreisStücklistenart."

	else

		'Aussehen der Spalten im Tabellenkopf und -körper, wenn sich nicht um einen Lieferschein handelt
		C_H_Spalte_1 = GetFormatCell(nBreiteSpalte_1,	0, C_H_Zeile, C_C_H_SPALTE)	' "Pos"
		C_H_Spalte_2 = GetFormatCell(nBreiteSpalte_2,	0, C_H_Zeile, C_C_H_SPALTE)	' "Menge"
		C_H_Spalte_3 = GetFormatCell(nBreiteSpalte_3,	0, C_H_Zeile, C_C_H_SPALTE)	' "Art.Nr."
		C_H_Spalte_8 = GetFormatCell(nBreiteSpalte_8,	0, C_H_Zeile, C_C_H_SPALTE)	' "Gewicht"
		C_H_Spalte_4 = GetFormatCell(nBreiteSpalte_4,	0, C_H_Zeile, C_C_H_SPALTE)	' "Text"
		C_H_Spalte_5 = GetFormatCell(nBreiteSpalte_5,	0, C_H_Zeile, C_C_H_SPALTE)	' "Einzelpreis"
		C_H_Spalte_6 = GetFormatCell(nBreiteSpalte_6,	0, C_H_Zeile, C_C_H_SPALTE)	' "Rabatt"
		C_H_Spalte_6a = GetFormatCell(nBreiteSpalte_6a,	0, C_H_Zeile, C_C_H_SPALTE)	' "USt."
		C_H_Spalte_7 = GetFormatCell(nBreiteSpalte_7,	0, C_H_Zeile, C_C_H_SPALTE)	' "Gesamtpreis"

		C_Spalte_1 = GetFormatCell(nBreiteSpalte_1	, 0, C_Zeile, C_C_SPALTE)	' "Pos"
		C_Spalte_2 = GetFormatCell(nBreiteSpalte_2/2	, 0, C_Zeile, C_C_SPALTE)	' "Menge Stk"
		C_Spalte_3 = GetFormatCell(nBreiteSpalte_2/2	, 0, C_Zeile, C_C_SPALTE)	' "Menge Einheit"
		C_Spalte_4 = GetFormatCell(nBreiteSpalte_3	, 0, C_Zeile, C_C_SPALTE)	' "Art.Nr"
		C_Spalte_9 = GetFormatCell(nBreiteSpalte_8	, 0, C_Zeile, C_C_SPALTE)	' "Gewicht"
		C_Spalte_5 = GetFormatCell(nBreiteSpalte_4	, 0, C_Zeile, C_C_SPALTE)	' "Text"
		C_Spalte_6 = GetFormatCell(nBreiteSpalte_5	, 0, C_Zeile, C_C_SPALTE)	' "Einzelpreis"
		C_Spalte_7 = GetFormatCell(nBreiteSpalte_6	, 0, C_Zeile, C_C_SPALTE)	' "Rabatt"
		C_Spalte_7a = GetFormatCell(nBreiteSpalte_6a, 0, C_Zeile, C_C_SPALTE)	' "USt."
		C_Spalte_8 = GetFormatCell(nBreiteSpalte_7	, 0, C_Zeile, C_C_SPALTE)	' "Gesamtpreis"

		C_Spalte_1s = GetFormatCell(nBreiteSpalte_1	, 0, C_Zeile_s, C_C_SPALTE)	' "PosStücklistenart."
		C_Spalte_2s = GetFormatCell(nBreiteSpalte_2/2, 0, C_Zeile_s, C_C_SPALTE)	' "Menge StkStücklistenart."
		C_Spalte_3s = GetFormatCell(nBreiteSpalte_2/2, 0, C_Zeile_s, C_C_SPALTE)	' "Menge EinheitStücklistenart."
		C_Spalte_4s = GetFormatCell(nBreiteSpalte_3	, 0, C_Zeile_s, C_C_SPALTE)	' "Art.NrStücklistenart."
		C_Spalte_9s = GetFormatCell(nBreiteSpalte_8	, 0, C_Zeile_s, C_C_SPALTE)	' "GewichtStücklistenart."
		C_Spalte_5s = GetFormatCell(nBreiteSpalte_4	, 0, C_Zeile_s, C_C_SPALTE)	' "TextStücklistenart."
		C_Spalte_6s = GetFormatCell(nBreiteSpalte_5	, 0, C_Zeile_s, C_C_SPALTE)	' "EinzelpreisStücklistenart."
		C_Spalte_7s = GetFormatCell(nBreiteSpalte_6	, 0, C_Zeile_s, C_C_SPALTE)	' "RabattStücklistenart."
		C_Spalte_7sa = GetFormatCell(nBreiteSpalte_6a, 0, C_Zeile_s, C_C_SPALTE)	' "USt."
		C_Spalte_8s = GetFormatCell(nBreiteSpalte_7	, 0, C_Zeile_s, C_C_SPALTE)	' "GesamtpreisStücklistenart."
	end if

	SetCellStandard(C_Spalte_2s, SchriftArtStandard, CELL_TEXT_RIGHT, -1)
	SetCellStandard(C_Spalte_3s, SchriftArtStandard, CELL_TEXT_RIGHT, -1)

	'Die Zellen der Übertragzeile
	nBreite = nBreiteSpalte_1 + nBreiteSpalte_2 + nBreiteSpalte_3 + nBreiteSpalte_4 + nBreiteSpalte_5 + nBreiteSpalte_6 + nBreiteSpalte_6a
	C_HU_Spalte_1 = GetFormatCell(nBreite, 0, C_HU_Zeile, C_C_S_SPALTE)
	C_HU_Spalte_2 = GetFormatCell(nBreiteSpalte_7, 0, C_HU_Zeile, C_C_S_SPALTE)

	'Zellen der Summenzeile
	C_S_Spalte_1 = GetFormatCell(nBreite, 0, C_S_Zeile, C_C_S_SPALTE)
	C_S_Spalte_2 = GetFormatCell(nBreiteSpalte_7, 0, C_S_Zeile, C_C_S_SPALTE)

	'Ausrichtung des Textes in der Kopfzeile
	'SetCellStandard(C_H_Spalte_2, SchriftArtSpaltenKopf, CELL_TEXT_LEFT, -1)
	SetCellStandard(C_H_Spalte_4, SchriftArtSpaltenKopf, CELL_TEXT_LEFT, -1)
	SetCellStandard(C_H_Spalte_5, SchriftArtSpaltenKopf, CELL_TEXT_CENTER, -1)
	SetCellStandard(C_H_Spalte_6, SchriftArtSpaltenKopf, CELL_TEXT_CENTER, -1)
	SetCellStandard(C_H_Spalte_6a, SchriftArtSpaltenKopf, CELL_TEXT_CENTER, -1)
	SetCellStandard(C_H_Spalte_7, SchriftArtSpaltenKopf, CELL_TEXT_CENTER, -1)
	SetCellStandard(C_H_Spalte_8, SchriftArtSpaltenKopf, CELL_TEXT_CENTER, -1)

	'Ausrichtung des Textes im Tabellenkörper
	SetRowStandard(C_Zeile, SchriftArtStandard, CELL_TEXT_RIGHT, -1)			'Die ganze Zeile
	SetCellStandard(C_Spalte_3, SchriftArtStandard, CELL_TEXT_LEFT, -1)
	SetCellStandard(C_Spalte_4, SchriftArtStandard, CELL_TEXT_LEFT, -1)
	SetCellStandard(C_Spalte_5, SchriftArtStandard, CELL_TEXT_LEFT, -1)
	SetCellStandard(C_Spalte_9, SchriftArtStandard, CELL_TEXT_RIGHT, -1)
	SetCellAlign(C_Spalte_5, CELL_TEXT_RIGHT + CELL_TYPE_CLIP )					'keinen Umbruch für Einzelpreis
	SetCellAlign(C_Spalte_7, CELL_TEXT_RIGHT + CELL_TYPE_CLIP )					'keinen Umbruch für Gesamtpreis

	'Ausrichtung des Textes aller Zellen in einer Tabellenzeile Hier Rechts, Festlegen der Schriftart
	SetCellStandard(C_S_Spalte_2, SchriftArtStandard, CELL_TEXT_RIGHT, -1)
	SetCellStandard(C_S_Spalte_3, SchriftArtStandard, CELL_TEXT_RIGHT, -1)

	'Zellen der Übertragszeile auf den Seiten 2 -...
	SetCellStandard(C_HU_Spalte_1, SchriftArtStandard, CELL_TEXT_LEFT, -1)
	SetCellStandard(C_HU_Spalte_2, SchriftArtStandard, CELL_TEXT_RIGHT, -1)

	nBreite = nBreite + GetCellWidth(C_H_Spalte_7)
	'Diese Zeile zeichnet einen Strich unter die Tabelle bei Lieferscheinen, wenn keine Kilo
	C_S_TOP = CreateCell(nBreite, 0, CELL_TYPE_DYNHORZ + CELL_TYPE_VERT)
	HandleLayout(C_S_TOP, False, nSchraffurFarbeKopf, SchriftArtSpaltenKopf, PEN_NULL, VertLinienArt, nRand)
	SetCellBorder(C_S_Bottom, CELL_BORDER_BOTTOM, 0, HorzLinienArt, COLOR_BLACK)
	C_S_Bottom = CreateCell(nBreite, 0, CELL_TYPE_DYNHORZ + CELL_TYPE_VERT)
	HandleLayout(C_S_Bottom, False, nSchraffurFarbeKopf, SchriftArtSpaltenKopf, PEN_NULL, VertLinienArt, nRand)
	SetCellBorder(C_S_Bottom, CELL_BORDER_TOP, 0, HorzLinienArt, COLOR_BLACK)

	bMitSchraffur = True
	'Das Aussehen der Überschriftenzeile
	if bTabelleMitKopf = JA then
		HandleLayout(C_H_Head, bMitSchraffur, nSchraffurFarbeKopf, SchriftArtSpaltenKopf,  HorzLinienArt, VertLinienArt, nRand)
		HandleLayout(C_H_Zeile, bMitSchraffur, nSchraffurFarbeKopf, SchriftArtSpaltenKopf,  HorzLinienArt, VertLinienArt, nRand)
	end if
	' Aussehen Übertragszeile
	HandleLayout(C_HU_Zeile, bMitSchraffur, nSchraffurFarbeKopf, SchriftArtSpaltenKopf,  HorzLinienArt, VertLinienArt, nRand)

	'Diese Zeile ist die Summenzeile bei Seitenumbruch in den Nebenleistungen
	HandleLayout(C_S_Noetig, bMitSchraffur, nSchraffurFarbeKopf, SchriftArtSpaltenKopf,  HorzLinienArt, VertLinienArt, nRand)

	'Aussehen der Zeilen im Tabellenkörper
	bMitSchraffur = True
	HandleLayout(C_Zeile, bMitSchraffur, nSchraffurFarbe, SchriftArtStandard, PEN_NULL, VertLinienArt, nRand)
	bMitSchraffur = False

	'Aussehen der Summenzeile
	HandleLayout(C_S_Zeile, bMitSchraffur, nSchraffurFarbe, SchriftArtStandard, HorzLinienArt, VertLinienArt, nRand)
	HandleLayout(C_Zeile_s, bMitSchraffur, nSchraffurFarbe, SchriftArtStandard, PEN_NULL, VertLinienArt, nRand)
	SetCellBorder(C_S_Noetig, CELL_BORDER_TOP + CELL_BORDER_BOTTOM, 0, HorzLinienArt, COLOR_BLACK)

	'Setzen des Textinhaltes der Überschriftenzeile
	if bTabelleMitKopf = NEIN then
		SetCellText(C_H_Spalte_1, "" )
		SetCellText(C_H_Spalte_2, "" )
		SetCellText(C_H_Spalte_3, "" )
		SetCellText(C_H_Spalte_4, "" )
		SetCellText(C_H_Spalte_5, "" )
		SetCellText(C_H_Spalte_6, "" )
		SetCellText(C_H_Spalte_6a, "" )
		SetCellText(C_H_Spalte_7, "" )
		SetCellText(C_H_Spalte_8, "" )
	else
		SetCellText(C_H_Spalte_1, sTextSpalte_1) ' default "Pos"
		SetCellText(C_H_Spalte_2, sTextSpalte_2) ' default "Menge"
		SetCellText(C_H_Spalte_3, sTextSpalte_3) ' default "Art.-Nr."
		SetCellText(C_H_Spalte_4, sTextSpalte_4) ' default "Text"
		SetCellText(C_H_Spalte_5, sTextSpalte_5 + strWaehrung) ' default "Einzelpreis"
		SetCellText(C_H_Spalte_6, sTextSpalte_6 + strProzent) ' default "Rabatt"
		SetCellText(C_H_Spalte_6a, sTextSpalte_6a) ' default "USt."
		SetCellText(C_H_Spalte_7, sTextSpalte_7 + strWaehrung) ' default "Gesamtpreis"
		SetCellText(C_H_Spalte_8, sTextSpalte_8) ' "Gewicht"
	end if
	SetCellStandard(C_S_Spalte_1, SchriftArtStandard, CELL_TEXT_LEFT, -1)
	SetCellStandard(C_HU_Spalte_1, SchriftArtStandard, CELL_TEXT_LEFT, -1)

	SetCellText(C_S_Spalte_1, "Zwischensumme")
	SetCellText(C_S_Spalte_2, "")
	SetCellText(C_HU_Spalte_1, "Übertrag")
	SetCellText(C_HU_Spalte_2, "")

	'Zellen der Nötigen Zwischensumme wenn Nebenleistungen
	C_S_Not_Spalte_1 = DuplicateCell(C_S_Spalte_1)
	C_S_Not_Spalte_2 = DuplicateCell(C_S_Spalte_2)
	SetCellParent(C_S_Not_Spalte_1, C_S_Noetig)
	SetCellParent(C_S_Not_Spalte_2, C_S_Noetig)
End Function


'////////////////////////////////////////////////////////////////////////////////////
'Funktion - BaueTabelleBrutto()
'Erzeugen der Tabelle, wenn BruttoAuftrag (mit Spalten und Zeilen)
'/////////////////////////////////////////////////////////////
Function BaueTabelleBrutto()
	Dim strWaehrung as String = "\n"
	strProzent = "\n"
	if bMitWaehrung = FALSE then
		strWaehrung = strWaehrung + GetCurrencySymbol(AUFTR_RG_BETRAG, bWaehrungAlsText)
		strProzent = strProzent + "%"
	end if

	nBreite = 0

	' wenn obere Postion der Tabelle auf Seite 1 automatisch positioniert werden soll
	' dann aktuelle Position abfragen und Tabelle darunter beginnen
	DIM nTabelleOben as numeric = nTabelleObenAufSeite1-nRandOben
	DIM nX as numeric
	DIM nY as numeric

	if bTabelleObenAufSeite1Auto then
		GetPos( nX, nY )
		nTabelleOben = nY + bTabelleObenAufSeite1AutoAbstand
	end if
	' wenn Autoformat( automatisches Anpassen der Breite), dann linke Position ignorieren
	if bTabelleAutoFormat then
		SetPos( 0 , nTabelleOben )
	else
		SetPos( nTabelleLinksAufSeite1-nRandLinks, nTabelleOben )
	end if

	'Definition der Überschriftenzeile
	C_H_Head = CreateCell(0, 0, CELL_TYPE_DYNHORZ + CELL_TYPE_DYNVERT + CELL_TYPE_VERT)
	C_H_Zeile = GetFormatCell(0, 0, C_H_Head, C_C_H_ZEILE)
	' Ausgabe der Steuern, nur wenn ausgewählt
	IF IS(LAY_TAB_MIT_STEUER) then
		C_HU_Zeile = GetFormatCell(0, 0, C_H_Head, C_C_H_ZEILE)
	end if
	SetCellBorder(C_H_Head, CELL_BORDER_ALL, 0, PEN_NULL, COLOR_TRANSPARENT)

	'Definition der Zeilen im Tabellenkörper
	'C_Zeile = CreateCell(0, 0, CELL_TYPE_DYNHORZ + CELL_TYPE_DYNVERT + CELL_TYPE_HORZ) 'ohne Zub
	C_Zeile = CreateCell(0, 0, CELL_TYPE_DYNHORZ + CELL_TYPE_DYNVERT + CELL_TYPE_HORZ + CELL_TYPE_BREAK)
	SetEventHandlerEx(EVENT_UPDATE, OnUpdate, C_Zeile)
	C_Zeile_s = CreateCell(0, 0, CELL_TYPE_DYNHORZ + CELL_TYPE_DYNVERT + CELL_TYPE_HORZ)

	'Definition der Summenzeilen
	C_S_Zeile = CreateCell(0, 0, CELL_TYPE_DYNHORZ + CELL_TYPE_DYNVERT + CELL_TYPE_HORZ)
	C_S_Noetig = CreateCell(0, 0, CELL_TYPE_DYNHORZ + CELL_TYPE_DYNVERT + CELL_TYPE_HORZ)
	C_S_Gesamt = CreateCell(0, 0, CELL_TYPE_DYNHORZ + CELL_TYPE_DYNVERT + CELL_TYPE_HORZ)
	C_S_Abschlag = CreateCell(0, 0, CELL_TYPE_DYNHORZ + CELL_TYPE_DYNVERT + CELL_TYPE_HORZ)
	C_S_SteuerBruttoText = CreateCell(0, 0, CELL_TYPE_DYNHORZ + CELL_TYPE_DYNVERT + CELL_TYPE_HORZ)
	C_S_Forder = CreateCell(0, 0, CELL_TYPE_DYNHORZ + CELL_TYPE_DYNVERT + CELL_TYPE_HORZ)

'	C_S_SteuerBrutto = CreateCell(0, 0, CELL_TYPE_DYNHORZ + CELL_TYPE_DYNVERT + CELL_TYPE_HORZ)

	if bMengenSpalteVorEPAuftrag = true then

		'Aussehen der Spalten im Tabellenkopf und -körper, wenn sich nicht um einen Lieferschein handelt
		C_H_Spalte_1 = GetFormatCell(nBreiteSpalte_1,	0, C_H_Zeile, C_C_H_SPALTE)	' "Pos"
		C_H_Spalte_3 = GetFormatCell(nBreiteSpalte_3,	0, C_H_Zeile, C_C_H_SPALTE)	' "Art.Nr."
		C_H_Spalte_4 = GetFormatCell(nBreiteSpalte_4,	0, C_H_Zeile, C_C_H_SPALTE)	' "Text"
		C_H_Spalte_2 = GetFormatCell(nBreiteSpalte_2,	0, C_H_Zeile, C_C_H_SPALTE)	' "Menge"
		C_H_Spalte_5 = GetFormatCell(nBreiteSpalte_5,	0, C_H_Zeile, C_C_H_SPALTE)	' "Einzelpreis"
		C_H_Spalte_6 = GetFormatCell(nBreiteSpalte_6,	0, C_H_Zeile, C_C_H_SPALTE)	' "Rabatt"
		C_H_Spalte_6a = GetFormatCell(nBreiteSpalte_6a,	0, C_H_Zeile, C_C_H_SPALTE)	' "USt."
		C_H_Spalte_7 = GetFormatCell(nBreiteSpalte_7,	0, C_H_Zeile, C_C_H_SPALTE)	' "Gesamtpreis"

		C_Spalte_1 = GetFormatCell(nBreiteSpalte_1	, 0, C_Zeile, C_C_SPALTE)	' "Pos"
		C_Spalte_4 = GetFormatCell(nBreiteSpalte_3	, 0, C_Zeile, C_C_SPALTE)	' "Art.Nr"
		C_Spalte_5 = GetFormatCell(nBreiteSpalte_4	, 0, C_Zeile, C_C_SPALTE)	' "Text"
		C_Spalte_2 = GetFormatCell(nBreiteSpalte_2/2	, 0, C_Zeile, C_C_SPALTE)	' "Menge Stk"
		C_Spalte_3 = GetFormatCell(nBreiteSpalte_2/2	, 0, C_Zeile, C_C_SPALTE)	' "Menge Einheit"
		C_Spalte_6 = GetFormatCell(nBreiteSpalte_5	, 0, C_Zeile, C_C_SPALTE)	' "Einzelpreis"
		C_Spalte_7 = GetFormatCell(nBreiteSpalte_6	, 0, C_Zeile, C_C_SPALTE)	' "Rabatt"
		C_Spalte_7a = GetFormatCell(nBreiteSpalte_6a	, 0, C_Zeile, C_C_SPALTE)	' "USt."

		C_Spalte_8 = GetFormatCell(nBreiteSpalte_7	, 0, C_Zeile, C_C_SPALTE)	' "Gesamtpreis"

		C_Spalte_1s = GetFormatCell(nBreiteSpalte_1	, 0, C_Zeile_s, C_C_SPALTE)	' "PosStücklistenart."
		C_Spalte_4s = GetFormatCell(nBreiteSpalte_3	, 0, C_Zeile_s, C_C_SPALTE)	' "Art.NrStücklistenart."
		C_Spalte_9s = GetFormatCell(nBreiteSpalte_8	, 0, C_Zeile_s, C_C_SPALTE)	' "GewichtStücklistenart."
		C_Spalte_5s = GetFormatCell(nBreiteSpalte_4	, 0, C_Zeile_s, C_C_SPALTE)	' "TextStücklistenart."
		C_Spalte_2s = GetFormatCell(nBreiteSpalte_2/2, 0, C_Zeile_s, C_C_SPALTE)' "Menge StkStücklistenart."
		C_Spalte_3s = GetFormatCell(nBreiteSpalte_2/2, 0, C_Zeile_s, C_C_SPALTE)' "Menge EinheitStücklistenart."
		C_Spalte_6s = GetFormatCell(nBreiteSpalte_5	, 0, C_Zeile_s, C_C_SPALTE)	' "EinzelpreisStücklistenart."
		C_Spalte_7s = GetFormatCell(nBreiteSpalte_6	, 0, C_Zeile_s, C_C_SPALTE)	' "RabattStücklistenart."
		C_Spalte_7sa = GetFormatCell(nBreiteSpalte_6a	, 0, C_Zeile_s, C_C_SPALTE)	' "USt.Stücklistenart."
		C_Spalte_8s = GetFormatCell(nBreiteSpalte_7	, 0, C_Zeile_s, C_C_SPALTE)	' "GesamtpreisStücklistenart."
	else
		'Aussehen der Spalten im Tabellenkopf und -körper, wenn sich nicht um einen Lieferschein handelt
		C_H_Spalte_1 = GetFormatCell(nBreiteSpalte_1,	0, C_H_Zeile, C_C_H_SPALTE)	' "Pos"
		C_H_Spalte_2 = GetFormatCell(nBreiteSpalte_2,	0, C_H_Zeile, C_C_H_SPALTE)	' "Menge"
		C_H_Spalte_3 = GetFormatCell(nBreiteSpalte_3,	0, C_H_Zeile, C_C_H_SPALTE)	' "Art.Nr."
		C_H_Spalte_4 = GetFormatCell(nBreiteSpalte_4,	0, C_H_Zeile, C_C_H_SPALTE)	' "Text"
		C_H_Spalte_5 = GetFormatCell(nBreiteSpalte_5,	0, C_H_Zeile, C_C_H_SPALTE)	' "Einzelpreis"
		C_H_Spalte_6 = GetFormatCell(nBreiteSpalte_6,	0, C_H_Zeile, C_C_H_SPALTE)	' "Rabatt"
		C_H_Spalte_6a = GetFormatCell(nBreiteSpalte_6a,	0, C_H_Zeile, C_C_H_SPALTE)	' "USt."
		C_H_Spalte_7 = GetFormatCell(nBreiteSpalte_7,	0, C_H_Zeile, C_C_H_SPALTE)	' "Gesamtpreis"

		C_Spalte_1 = GetFormatCell(nBreiteSpalte_1	, 0, C_Zeile, C_C_SPALTE)	' "Pos"
		C_Spalte_2 = GetFormatCell(nBreiteSpalte_2/2	, 0, C_Zeile, C_C_SPALTE)	' "Menge Stk"
		C_Spalte_3 = GetFormatCell(nBreiteSpalte_2/2	, 0, C_Zeile, C_C_SPALTE)	' "Menge Einheit"
		C_Spalte_4 = GetFormatCell(nBreiteSpalte_3	, 0, C_Zeile, C_C_SPALTE)	' "Art.Nr"
		C_Spalte_5 = GetFormatCell(nBreiteSpalte_4	, 0, C_Zeile, C_C_SPALTE)	' "Text"
		C_Spalte_6 = GetFormatCell(nBreiteSpalte_5	, 0, C_Zeile, C_C_SPALTE)	' "Einzelpreis"
		C_Spalte_7 = GetFormatCell(nBreiteSpalte_6	, 0, C_Zeile, C_C_SPALTE)	' "Rabatt"
		C_Spalte_7a = GetFormatCell(nBreiteSpalte_6a	, 0, C_Zeile, C_C_SPALTE)	' "USt."

		C_Spalte_8 = GetFormatCell(nBreiteSpalte_7	, 0, C_Zeile, C_C_SPALTE)	' "Gesamtpreis"

		C_Spalte_1s = GetFormatCell(nBreiteSpalte_1	, 0, C_Zeile_s, C_C_SPALTE)	' "PosStücklistenart."
		C_Spalte_2s = GetFormatCell(nBreiteSpalte_2/2, 0, C_Zeile_s, C_C_SPALTE)	' "Menge StkStücklistenart."
		C_Spalte_3s = GetFormatCell(nBreiteSpalte_2/2, 0, C_Zeile_s, C_C_SPALTE)	' "Menge EinheitStücklistenart."
		C_Spalte_4s = GetFormatCell(nBreiteSpalte_3	, 0, C_Zeile_s, C_C_SPALTE)	' "Art.NrStücklistenart."
		C_Spalte_9s = GetFormatCell(nBreiteSpalte_8	, 0, C_Zeile_s, C_C_SPALTE)	' "GewichtStücklistenart."
		C_Spalte_5s = GetFormatCell(nBreiteSpalte_4	, 0, C_Zeile_s, C_C_SPALTE)	' "TextStücklistenart."
		C_Spalte_6s = GetFormatCell(nBreiteSpalte_5	, 0, C_Zeile_s, C_C_SPALTE)	' "EinzelpreisStücklistenart."
		C_Spalte_7s = GetFormatCell(nBreiteSpalte_6	, 0, C_Zeile_s, C_C_SPALTE)	' "RabattStücklistenart."
		C_Spalte_7sa = GetFormatCell(nBreiteSpalte_6a	, 0, C_Zeile_s, C_C_SPALTE)	' "USt.Stücklistenart."
		C_Spalte_8s = GetFormatCell(nBreiteSpalte_7	, 0, C_Zeile_s, C_C_SPALTE)	' "GesamtpreisStücklistenart."
	end if

	SetCellStandard(C_Spalte_2s, SchriftArtStandard, CELL_TEXT_RIGHT, -1)
	SetCellStandard(C_Spalte_3s, SchriftArtStandard, CELL_TEXT_RIGHT, -1)

	'Die Zellen der Übertragzeile
	nBreite = nBreiteSpalte_1 + nBreiteSpalte_2 + nBreiteSpalte_3 + nBreiteSpalte_4 + nBreiteSpalte_5 + nBreiteSpalte_6 + nBreiteSpalte_6a
	C_HU_Spalte_1 = GetFormatCell(nBreite, 0, C_HU_Zeile, C_C_S_SPALTE)
	C_HU_Spalte_2 = GetFormatCell(nBreiteSpalte_7, 0, C_HU_Zeile, C_C_S_SPALTE)
	'Zellen der Summenzeile
	C_S_Spalte_1 = GetFormatCell(nBreite, 0, C_S_Zeile, C_C_S_SPALTE)
	C_S_Spalte_2 = GetFormatCell(nBreiteSpalte_7, 0, C_S_Zeile, C_C_S_SPALTE)

	'Ausrichtung des Textes in der Kopfzeile
	'SetCellStandard(C_H_Spalte_2, SchriftArtSpaltenKopf, CELL_TEXT_LEFT, -1)
	SetCellStandard(C_H_Spalte_4, SchriftArtSpaltenKopf, CELL_TEXT_LEFT, -1)
	SetCellStandard(C_H_Spalte_5, SchriftArtSpaltenKopf, CELL_TEXT_CENTER, -1)
	SetCellStandard(C_H_Spalte_6, SchriftArtSpaltenKopf, CELL_TEXT_CENTER, -1)
	SetCellStandard(C_H_Spalte_6a, SchriftArtSpaltenKopf, CELL_TEXT_CENTER, -1)
	SetCellStandard(C_H_Spalte_7, SchriftArtSpaltenKopf, CELL_TEXT_CENTER, -1)

	'Ausrichtung des Textes im Tabellenkörper
	SetRowStandard(C_Zeile, SchriftArtStandard, CELL_TEXT_RIGHT, -1)			'Die ganze Zeile
	SetCellStandard(C_Spalte_3, SchriftArtStandard, CELL_TEXT_LEFT, -1)
	SetCellStandard(C_Spalte_4, SchriftArtStandard, CELL_TEXT_LEFT, -1)
	SetCellStandard(C_Spalte_5, SchriftArtStandard, CELL_TEXT_LEFT, -1)
	SetCellAlign(C_Spalte_5, CELL_TEXT_RIGHT + CELL_TYPE_CLIP )					'keinen Umbruch für Einzelpreis
	SetCellAlign(C_Spalte_7, CELL_TEXT_RIGHT + CELL_TYPE_CLIP )					'keinen Umbruch für Gesamtpreis

	'Ausrichtung des Textes aller Zellen in einer Tabellenzeile Hier Rechts, Festlegen der Schriftart
	SetCellStandard(C_S_Spalte_2, SchriftArtStandard, CELL_TEXT_RIGHT, -1)
	SetCellStandard(C_S_Spalte_3, SchriftArtStandard, CELL_TEXT_RIGHT, -1)

	'Zellen der Übertragszeile auf den Seiten 2 -...
	SetCellStandard(C_HU_Spalte_1, SchriftArtStandard, CELL_TEXT_LEFT, -1)
	SetCellStandard(C_HU_Spalte_2, SchriftArtStandard, CELL_TEXT_RIGHT, -1)

	nBreite = nBreite + GetCellWidth(C_H_Spalte_7)
	'Diese Zeile zeichnet einen Strich unter die Tabelle bei Lieferscheinen, wenn keine Kilo
	C_S_TOP = CreateCell(nBreite, 0, CELL_TYPE_DYNHORZ + CELL_TYPE_VERT)
	HandleLayout(C_S_TOP, False, nSchraffurFarbeKopf, SchriftArtSpaltenKopf, PEN_NULL, VertLinienArt, nRand)
	SetCellBorder(C_S_Bottom, CELL_BORDER_BOTTOM, 0, HorzLinienArt, COLOR_BLACK)

	C_S_Bottom = CreateCell(nBreite, 0, CELL_TYPE_DYNHORZ + CELL_TYPE_VERT)
	HandleLayout(C_S_Bottom, False, nSchraffurFarbeKopf, SchriftArtSpaltenKopf, PEN_NULL, VertLinienArt, nRand)
	SetCellBorder(C_S_Bottom, CELL_BORDER_TOP, 0, HorzLinienArt, COLOR_BLACK)

	bMitSchraffur = True
	if bTabelleMitKopf = JA then
		HandleLayout(C_H_Head, bMitSchraffur, nSchraffurFarbeKopf, SchriftArtSpaltenKopf,  HorzLinienArt, VertLinienArt, nRand)
		HandleLayout(C_H_Zeile, bMitSchraffur, nSchraffurFarbeKopf, SchriftArtSpaltenKopf,  HorzLinienArt, VertLinienArt, nRand)
	end if
	' Aussehen Übertragszeile
	HandleLayout(C_HU_Zeile, bMitSchraffur, nSchraffurFarbeKopf, SchriftArtSpaltenKopf,  HorzLinienArt, VertLinienArt, nRand)

	'Diese Zeile ist die Summenzeile bei Seitenumbruch in den Nebenleistungen
	HandleLayout(C_S_Noetig, bMitSchraffur, nSchraffurFarbeKopf, SchriftArtSpaltenKopf,  HorzLinienArt, VertLinienArt, nRand)

	'Aussehen der Zeilen im Tabellenkörper
	bMitSchraffur = True
	HandleLayout(C_Zeile, bMitSchraffur, nSchraffurFarbe, SchriftArtStandard, PEN_NULL, VertLinienArt, nRand)
	HandleLayout(C_Zeile_s, bMitSchraffur, nSchraffurFarbe, SchriftArtStandard, PEN_NULL, VertLinienArt, nRand)
	bMitSchraffur = False

	'Aussehen der Summenzeile
	HandleLayout(C_S_Zeile, bMitSchraffur, nSchraffurFarbe, SchriftArtStandard, HorzLinienArt, VertLinienArt, nRand)
	SetCellBorder(C_S_Noetig, CELL_BORDER_TOP + CELL_BORDER_BOTTOM, 0, HorzLinienArt, COLOR_BLACK)

	'Setzen des Textinhaltes der Überschriftenzeile
	if bTabelleMitKopf = NEIN then
		SetCellText(C_H_Spalte_1, "" )
		SetCellText(C_H_Spalte_2, "" )
		SetCellText(C_H_Spalte_3, "" )
		SetCellText(C_H_Spalte_4, "" )
		SetCellText(C_H_Spalte_5, "" )
		SetCellText(C_H_Spalte_6, "" )
		SetCellText(C_H_Spalte_6a, "" )
		SetCellText(C_H_Spalte_7, "" )
	else
		SetCellText(C_H_Spalte_1, sTextSpalte_1) ' default "Pos"
		SetCellText(C_H_Spalte_2, sTextSpalte_2) ' default "Menge"
		SetCellText(C_H_Spalte_3, sTextSpalte_3) ' default "Art.-Nr."
		SetCellText(C_H_Spalte_4, sTextSpalte_4) ' default "Text"
		SetCellText(C_H_Spalte_5, sTextSpalte_5 + strWaehrung) ' default "Einzelpreis"
		SetCellText(C_H_Spalte_6, sTextSpalte_6 + strProzent) ' default "Rabatt"
		SetCellText(C_H_Spalte_6a, sTextSpalte_6a )			' default "USt."
		SetCellText(C_H_Spalte_7, sTextSpalte_7 + strWaehrung) ' default "Gesamtpreis"
	end if

	SetCellStandard(C_S_Spalte_1, SchriftArtStandard, CELL_TEXT_LEFT, -1)
	SetCellStandard(C_HU_Spalte_1, SchriftArtStandard, CELL_TEXT_LEFT, -1)

	SetCellText(C_S_Spalte_1, "Zwischensumme")
	SetCellText(C_S_Spalte_2, "")
	SetCellText(C_HU_Spalte_1, "Übertrag")
	SetCellText(C_HU_Spalte_2, "")

	'Zellen der Nötigen Zwischensumme wenn Nebenleistungen
	C_S_Not_Spalte_1 = DuplicateCell(C_S_Spalte_1)
	C_S_Not_Spalte_2 = DuplicateCell(C_S_Spalte_2)
	SetCellParent(C_S_Not_Spalte_1, C_S_Noetig)
	SetCellParent(C_S_Not_Spalte_2, C_S_Noetig)
End Function


'////////////////////////////////////////////////////////////////////////////////////
'Funktion - BaueTabelleLieferschein()
'Erzeugen der Tabelle für den Lieferschein mit Spalten und Zeilen
'/////////////////////////////////////////////////////////////
Function BaueTabelleLieferschein()
	Dim strWaehrung as String = "\n"
	strGewicht	= "\n"
	if bMitWaehrung = FALSE then
		strWaehrung = strWaehrung + GetCurrencySymbol(AUFTR_RG_BETRAG, bWaehrungAlsText)
		strGewicht = strGewicht + "kg"
	end if

	nBreite = 0
	' wenn obere Postion der Tabelle auf Seite 1 automatisch positioniert werden soll
	' dann aktuelle Position abfragen und Tabelle darunter beginnen
	DIM nTabelleOben as numeric = nTabelleObenAufSeite1-nRandOben
	DIM nX as numeric
	DIM nY as numeric

	if bTabelleObenAufSeite1Auto then
		GetPos( nX, nY )
		nTabelleOben = nY + bTabelleObenAufSeite1AutoAbstand
	end if

	' wenn Autoformat( automatisches Anpassen der Breite), dann linke Position ignorieren
	if bTabelleAutoFormat then
		SetPos( 0 , nTabelleOben )
	else
		SetPos( nTabelleLinksAufSeite1-nRandLinks, nTabelleOben )
	end if

	'Definition der Überschriftenzeile
	C_H_Head = CreateCell(0, 0, CELL_TYPE_DYNHORZ + CELL_TYPE_DYNVERT + CELL_TYPE_VERT)
	C_H_Zeile = GetFormatCell(0, 0, C_H_Head, C_C_H_ZEILE)
	SetCellBorder(C_H_Head, CELL_BORDER_ALL, 0, PEN_NULL, COLOR_TRANSPARENT)

	'Definition der Zeilen im Tabellenkörper
'	C_Zeile = CreateCell(0, 0, CELL_TYPE_DYNHORZ + CELL_TYPE_DYNVERT + CELL_TYPE_HORZ) 'ohne Zub
	C_Zeile = CreateCell(0, 0, CELL_TYPE_DYNHORZ + CELL_TYPE_DYNVERT + CELL_TYPE_HORZ + CELL_TYPE_BREAK)
	SetEventHandlerEx(EVENT_UPDATE, OnUpdate, C_Zeile)
	C_Zeile_s = CreateCell(0, 0, CELL_TYPE_DYNHORZ + CELL_TYPE_DYNVERT + CELL_TYPE_HORZ) '(für Stücklistenpositionen

	if bMengenSpalteVorEPLiefer = true then

		'Aussehen der Spalten im Tabellenkopf und -körper, wenn es sich um einen Lieferschein handelt
		C_H_Spalte_1 = GetFormatCell(nLieferBreiteSpalte_1 , 0, C_H_Zeile, C_C_H_SPALTE)	' Position
		C_H_Spalte_3 = GetFormatCell(nLieferBreiteSpalte_3 , 0, C_H_Zeile, C_C_H_SPALTE)	' Art.-Nr.
		C_H_Spalte_4 = GetFormatCell(nLieferBreiteSpalte_4 , 0, C_H_Zeile, C_C_H_SPALTE)	' kg
		C_H_Spalte_5 = GetFormatCell(nLieferBreiteSpalte_5 , 0, C_H_Zeile, C_C_H_SPALTE)	' Text
		C_H_Spalte_2 = GetFormatCell(nLieferBreiteSpalte_2 , 0, C_H_Zeile, C_C_H_SPALTE)	' Menge
		C_H_Spalte_6 = GetFormatCell(nLieferBreiteSpalte_6 , 0, C_H_Zeile, C_C_H_SPALTE)	' Einzelpreis
		C_H_Spalte_7 = GetFormatCell(nLieferBreiteSpalte_7 , 0, C_H_Zeile, C_C_H_SPALTE)	' Gesamtpreis

		C_Spalte_1 = GetFormatCell(nLieferBreiteSpalte_1	, 0, C_Zeile, C_C_SPALTE)	' Position
		C_Spalte_4 = GetFormatCell(nLieferBreiteSpalte_3	, 0, C_Zeile, C_C_SPALTE)	' Art.-Nr.
		C_Spalte_5 = GetFormatCell(nLieferBreiteSpalte_4	, 0, C_Zeile, C_C_SPALTE)	' kg
		C_Spalte_6 = GetFormatCell(nLieferBreiteSpalte_5	, 0, C_Zeile, C_C_SPALTE)	' Text
		C_Spalte_2 = GetFormatCell(nLieferBreiteSpalte_2/2	, 0, C_Zeile, C_C_SPALTE)	' Menge - Anzahl
		C_Spalte_3 = GetFormatCell(nLieferBreiteSpalte_2/2	, 0, C_Zeile, C_C_SPALTE)	' Menge - Einheit
		' keine Umbruch für Einzel und Gesamtpreis, deshalb die Zellen hier von Hand erzeugen
	'	C_Spalte_7 = GetFormatCell(GetCellWidth(C_H_Spalte_6),	0, C_Zeile, C_C_SPALTE)	' Einzelpreis
	'	C_Spalte_8 = GetFormatCell(GetCellWidth(C_H_Spalte_7),	0, C_Zeile, C_C_SPALTE)	' Gesamtpreis
		C_Spalte_7 = CreateCell(nLieferBreiteSpalte_6, 0, CELL_TYPE_DYNVERT + CELL_TYPE_VERT )
		SetCellParent(C_Spalte_7, C_Zeile)
		SetCellBackground(C_Spalte_7, COLOR_TRANSPARENT)
		C_Spalte_8 = CreateCell(nLieferBreiteSpalte_7, 0, CELL_TYPE_DYNVERT + CELL_TYPE_VERT )
		SetCellParent(C_Spalte_8, C_Zeile)
		SetCellBackground(C_Spalte_8, COLOR_TRANSPARENT)

		C_Spalte_1s = GetFormatCell(nLieferBreiteSpalte_1	, 0, C_Zeile_s, C_C_SPALTE)	' PositionStücklistenartikel
		C_Spalte_4s = GetFormatCell(nLieferBreiteSpalte_3	, 0, C_Zeile_s, C_C_SPALTE)	' Art.-Nr.Stücklistenartikel
		C_Spalte_5s = GetFormatCell(nLieferBreiteSpalte_4	, 0, C_Zeile_s, C_C_SPALTE)	' kg
		C_Spalte_6s = GetFormatCell(nLieferBreiteSpalte_5	, 0, C_Zeile_s, C_C_SPALTE)	' TextStücklistenartikel
		C_Spalte_2s = GetFormatCell(nLieferBreiteSpalte_2/2	, 0, C_Zeile_s, C_C_SPALTE)	' Menge - AnzahlStücklistenartikel
		C_Spalte_3s = GetFormatCell(nLieferBreiteSpalte_2/2	, 0, C_Zeile_s, C_C_SPALTE)	' Menge - EinheitStücklistenartikel
		C_Spalte_7s = GetFormatCell(nLieferBreiteSpalte_6	, 0, C_Zeile_s, C_C_SPALTE)
		C_Spalte_8s = GetFormatCell(nLieferBreiteSpalte_7	, 0, C_Zeile_s, C_C_SPALTE)
	else
		'Aussehen der Spalten im Tabellenkopf und -körper, wenn es sich um einen Lieferschein handelt
		C_H_Spalte_1 = GetFormatCell(nLieferBreiteSpalte_1 , 0, C_H_Zeile, C_C_H_SPALTE)	' Position
		C_H_Spalte_2 = GetFormatCell(nLieferBreiteSpalte_2 , 0, C_H_Zeile, C_C_H_SPALTE)	' Menge
		C_H_Spalte_3 = GetFormatCell(nLieferBreiteSpalte_3 , 0, C_H_Zeile, C_C_H_SPALTE)	' Art.-Nr.
		C_H_Spalte_4 = GetFormatCell(nLieferBreiteSpalte_4 , 0, C_H_Zeile, C_C_H_SPALTE)	' kg
		C_H_Spalte_5 = GetFormatCell(nLieferBreiteSpalte_5 , 0, C_H_Zeile, C_C_H_SPALTE)	' Text
		C_H_Spalte_6 = GetFormatCell(nLieferBreiteSpalte_6 , 0, C_H_Zeile, C_C_H_SPALTE)	' Einzelpreis
		C_H_Spalte_7 = GetFormatCell(nLieferBreiteSpalte_7 , 0, C_H_Zeile, C_C_H_SPALTE)	' Gesamtpreis

		C_Spalte_1 = GetFormatCell(nLieferBreiteSpalte_1	, 0, C_Zeile, C_C_SPALTE)	' Position
		C_Spalte_2 = GetFormatCell(nLieferBreiteSpalte_2/2	, 0, C_Zeile, C_C_SPALTE)	' Menge - Anzahl
		C_Spalte_3 = GetFormatCell(nLieferBreiteSpalte_2/2	, 0, C_Zeile, C_C_SPALTE)	' Menge - Einheit
		C_Spalte_4 = GetFormatCell(nLieferBreiteSpalte_3	, 0, C_Zeile, C_C_SPALTE)	' Art.-Nr.
		C_Spalte_5 = GetFormatCell(nLieferBreiteSpalte_4	, 0, C_Zeile, C_C_SPALTE)	' kg
		C_Spalte_6 = GetFormatCell(nLieferBreiteSpalte_5	, 0, C_Zeile, C_C_SPALTE)	' Text
		' keine Umbruch für Einzel und Gesamtpreis, deshalb die Zellen hier von Hand erzeugen
	'	C_Spalte_7 = GetFormatCell(GetCellWidth(C_H_Spalte_6),	0, C_Zeile, C_C_SPALTE)	' Einzelpreis
	'	C_Spalte_8 = GetFormatCell(GetCellWidth(C_H_Spalte_7),	0, C_Zeile, C_C_SPALTE)	' Gesamtpreis
		C_Spalte_7 = CreateCell(nLieferBreiteSpalte_6, 0, CELL_TYPE_DYNVERT + CELL_TYPE_VERT )
		SetCellParent(C_Spalte_7, C_Zeile)
		SetCellBackground(C_Spalte_7, COLOR_TRANSPARENT)
		C_Spalte_8 = CreateCell(nLieferBreiteSpalte_7, 0, CELL_TYPE_DYNVERT + CELL_TYPE_VERT )
		SetCellParent(C_Spalte_8, C_Zeile)
		SetCellBackground(C_Spalte_8, COLOR_TRANSPARENT)

		C_Spalte_1s = GetFormatCell(nLieferBreiteSpalte_1	, 0, C_Zeile_s, C_C_SPALTE)	' PositionStücklistenartikel
		C_Spalte_2s = GetFormatCell(nLieferBreiteSpalte_2/2	, 0, C_Zeile_s, C_C_SPALTE)	' Menge - AnzahlStücklistenartikel
		C_Spalte_3s = GetFormatCell(nLieferBreiteSpalte_2/2	, 0, C_Zeile_s, C_C_SPALTE)	' Menge - EinheitStücklistenartikel
		C_Spalte_4s = GetFormatCell(nLieferBreiteSpalte_3	, 0, C_Zeile_s, C_C_SPALTE)	' Art.-Nr.Stücklistenartikel
		C_Spalte_5s = GetFormatCell(nLieferBreiteSpalte_4	, 0, C_Zeile_s, C_C_SPALTE)	' kg
		C_Spalte_6s = GetFormatCell(nLieferBreiteSpalte_5	, 0, C_Zeile_s, C_C_SPALTE)	' TextStücklistenartikel
		C_Spalte_7s = GetFormatCell(nLieferBreiteSpalte_6	, 0, C_Zeile_s, C_C_SPALTE)
		C_Spalte_8s = GetFormatCell(nLieferBreiteSpalte_7	, 0, C_Zeile_s, C_C_SPALTE)
	end if

	SetCellStandard(C_Spalte_2s, SchriftArtStandard, CELL_TEXT_RIGHT, -1)	'Menge Stücklistenartikel
	SetCellStandard(C_Spalte_5s, SchriftArtStandard, CELL_TEXT_RIGHT, -1)	'kg Stücklistenartikel

	nBreite = GetCellWidth(C_H_Spalte_1) + GetCellWidth(C_H_Spalte_2) + GetCellWidth(C_H_Spalte_3) + GetCellWidth(C_H_Spalte_4) + GetCellWidth(C_H_Spalte_5)
	SetCellStandard(C_H_Spalte_5, SchriftArtStandard, CELL_TEXT_LEFT, -1)
	'Ausrichtung des Textes in der Kopfzeile
	SetCellStandard(C_H_Spalte_2, SchriftArtSpaltenKopf, CELL_TEXT_CENTER, -1)
	SetCellStandard(C_H_Spalte_3, SchriftArtSpaltenKopf, CELL_TEXT_LEFT, -1)
	SetCellStandard(C_H_Spalte_4, SchriftArtSpaltenKopf, CELL_TEXT_CENTER, -1)
	SetCellStandard(C_H_Spalte_5, SchriftArtSpaltenKopf, CELL_TEXT_LEFT	, -1)
	SetCellStandard(C_H_Spalte_6, SchriftArtSpaltenKopf, CELL_TEXT_CENTER, -1)
	SetCellStandard(C_H_Spalte_7, SchriftArtSpaltenKopf, CELL_TEXT_CENTER, -1)

	'Ausrichtung des Textes im Tabellenkörper
	SetRowStandard(C_Zeile, SchriftArtStandard, CELL_TEXT_RIGHT, -1)		'Die ganze Zeile
	SetCellStandard(C_Spalte_1, SchriftArtStandard, CELL_TEXT_RIGHT, -1)	'Pos
	SetCellStandard(C_Spalte_2, SchriftArtStandard, CELL_TEXT_RIGHT, -1)	'Menge Stk
	SetCellStandard(C_Spalte_3, SchriftArtStandard, CELL_TEXT_LEFT	, -1)	'Menge Einheit
	SetCellStandard(C_Spalte_4, SchriftArtStandard, CELL_TEXT_LEFT	, -1)	'Art.Nr.
	SetCellStandard(C_Spalte_5, SchriftArtStandard, CELL_TEXT_RIGHT, -1)	'Gewicht
	SetCellStandard(C_Spalte_6, SchriftArtStandard, CELL_TEXT_LEFT	, -1) 'Text
	SetCellStandard(C_Spalte_7, SchriftArtStandard, CELL_TEXT_RIGHT, -1) 'Einzelpreis
	SetCellStandard(C_Spalte_8, SchriftArtStandard, CELL_TEXT_RIGHT, -1)	'Gesamtpreis

	bMitSchraffur = True
	'Das Aussehen der Überschriftenzeile
	if bTabelleMitKopf = JA then
		HandleLayout(C_H_Head, bMitSchraffur, nSchraffurFarbeKopf, SchriftArtSpaltenKopf,  HorzLinienArt, VertLinienArt, nRand)
		HandleLayout(C_H_Zeile, bMitSchraffur, nSchraffurFarbeKopf, SchriftArtSpaltenKopf,  HorzLinienArt, VertLinienArt, nRand)
	end if

	'Aussehen der Zeilen im Tabellenkörper
	bMitSchraffur = True
	HandleLayout(C_Zeile, bMitSchraffur, nSchraffurFarbe, SchriftArtStandard, PEN_NULL, VertLinienArt, nRand)
	HandleLayout(C_Zeile_s, bMitSchraffur, nSchraffurFarbe, SchriftArtStandard, PEN_NULL, VertLinienArt, nRand)
	bMitSchraffur = False

	'Definition der Zeile Gesamtbetrag
	C_S_Zeile  = CreateCell(0, 0, CELL_TYPE_DYNHORZ + CELL_TYPE_DYNVERT + CELL_TYPE_HORZ)
	'Die Zellen für den Gesmatbetrag
	nBreite = nLieferBreiteSpalte_1 + nLieferBreiteSpalte_2 + nLieferBreiteSpalte_3 + nLieferBreiteSpalte_4 + nLieferBreiteSpalte_5
	'nBreite = GetCellWidth(C_H_Spalte_1) + GetCellWidth(C_H_Spalte_2) + GetCellWidth(C_H_Spalte_3) + GetCellWidth(C_H_Spalte_4) + GetCellWidth(C_H_Spalte_5)
	C_S_Spalte_1 = GetFormatCell(nBreite, 0, C_S_Zeile, C_C_S_Spalte)
	C_S_Spalte_2 = GetFormatCell(nLieferBreiteSpalte_6+nLieferBreiteSpalte_7, 0, C_S_Zeile, C_C_S_Spalte)

	'Ausrichtung des Textes aller Zellen in einer Tabellenzeile Hier Rechts, Festlegen der Schriftart
	SetCellStandard(C_S_Spalte_1, SchriftArtStandard, CELL_TEXT_LEFT, -1)
	SetCellStandard(C_S_Spalte_2, SchriftArtStandard, CELL_TEXT_RIGHT, -1)

	HandleLayout(C_S_Zeile, bMitSchraffur, nSchraffurFarbe, SchriftArtStandard, PEN_NULL, PEN_NULL, nRand)
	if nLieferBreiteSpalte_7 = 0 then
		SetCellText(C_S_Spalte_1, "")
		SetCellBorder(C_S_Zeile, CELL_BORDER_TOP, 0, HorzLinienArt, COLOR_BLACK)
	else
		SetCellText(C_S_Spalte_1, "Zwischensumme")
		SetCellBorder(C_S_Zeile, CELL_BORDER_ALL,  1, HorzLinienArt, COLOR_BLACK)			'Zeile mit Rahmen

		'Übertrags-Zeile einschalten
		C_HU_Zeile = GetFormatCell(0, 0, C_H_Head, C_C_H_ZEILE)
		C_HU_Spalte_1 = GetFormatCell(nBreite, 0, C_HU_Zeile, C_C_S_SPALTE)
		C_HU_Spalte_2 = GetFormatCell(nLieferBreiteSpalte_6+nLieferBreiteSpalte_7, 0, C_HU_Zeile, C_C_S_SPALTE)
		SetCellStandard(C_HU_Spalte_1, SchriftArtStandard, CELL_TEXT_LEFT, -1)
		SetCellStandard(C_HU_Spalte_2, SchriftArtStandard, CELL_TEXT_RIGHT, -1)

		SetCellText(C_HU_Spalte_1, "Übertrag")
		SetCellText(C_HU_Spalte_2, "")
	end if
	SetCellText(C_S_Spalte_2, "")

	'Diese Zeile zeichnet einen Strich unter die Tabelle bei Lieferscheinen, wenn keine Kilo
'	C_S_Bottom = CreateCell(nBreite, 0, CELL_TYPE_DYNHORZ + CELL_TYPE_VERT)
	'HandleLayout(C_S_Bottom, False, nSchraffurFarbeKopf, SchriftArtSpaltenKopf, PEN_NULL, VertLinienArt, nRand)
'	SetCellBorder(C_S_Bottom, CELL_BORDER_TOP, 0, HorzLinienArt, COLOR_BLACK)

	'Setzen des Textinhaltes der Überschriftenzeile
	if bTabelleMitKopf = NEIN then
		SetCellText(C_H_Spalte_1, "" )
		SetCellText(C_H_Spalte_2, "" )
		SetCellText(C_H_Spalte_3, "" )
		SetCellText(C_H_Spalte_4, "" )
		SetCellText(C_H_Spalte_5, "" )
		SetCellText(C_H_Spalte_6, "" )
		SetCellText(C_H_Spalte_7, "" )
	else
		SetCellText(C_H_Spalte_1, sLieferTextSpalte_1 )	'default "Pos."
		SetCellText(C_H_Spalte_2, sLieferTextSpalte_2 ) 'default "Menge"
		SetCellText(C_H_Spalte_3, sLieferTextSpalte_3 ) 'default "Art.-Nr.
		SetCellText(C_H_Spalte_4, sLieferTextSpalte_4 + strGewicht)	'default "kg"
		SetCellText(C_H_Spalte_5, sLieferTextSpalte_5 ) 'default "Text"
		SetCellText(C_H_Spalte_6, sLieferTextSpalte_6 + strWaehrung) ' default "Einzelpreis"
		SetCellText(C_H_Spalte_7, sLieferTextSpalte_7 + strWaehrung) ' default "Gesamtpreis"
	end if
End Function


'////////////////////////////////////////////////////////////////////////////////////
'Funktion - LeereZellen()
'Löschen einer Zeile der Tabelle
'/////////////////////////////////////////////////////////////
Function LeereZellen()
	'Diese Funktion behandelt das Schraffieren der Tabellenzeilen und leert deren Inhalte
	HandleLayout(C_Zeile, bMitSchraffur, nSchraffurFarbe, SchriftArtStandard, PEN_NULL, VertLinienArt, nRand)
'	If bMitSchraffur Then
'		bMitSchraffur = false
'	else
'		bMitSchraffur = true
'	End If
	ClearRow(C_Zeile, "")
	ClearRow(C_Zeile_s, "")
	ClearRow(cRowLohn, "")
	ClearRow(cLine1Lohn, "")
	ClearRow(cLine1Row1Lohn, "")
	ClearRow(cLine1Row2Lohn, "")
	ClearRow(cLine2Lohn, "")
	ClearRow(cLine2Row1Lohn, "")
End Function

'////////////////////////////////////////////////////////////////////////////////////
'Funktion - PrintArtikelText()
'Drucken der zusätzlichen Bezeichnungen der Artikel nach der Hauptartikelbezeichnung
'///////////////////////////////////////////////////////////////
Function PrintArtikelText( Spalte as CellType )

	Dim sPosBez as String = ""
	Dim sPosText as String = ""

	if bMitArtikelbez then
		sPosBez = Get(POS_BEZ)
	end if
	if bMitArtikeltext Or (Not ((IS(POS_IST_STAMMART)) OR (IS(POS_IST_ALTERNATIV)) OR (IS(POS_IST_DATANORM)) OR (IS(POS_IST_LOHNLEISTUNG)))) then
		sPosText = Get(POS_ALLTEXT)
	end if

	Dim ArtikelText as String = ""

	if is (POS_IST_SEITENUMBRUCH) = FALSE then
		' Hauptbezeichnung
		ArtikelText = ArtikelText + sPosBez
		' alle weiteren Textzeilen
		if sPosText <> "" then
			if ArtikelText <> "" then ArtikelText = ArtikelText + "\n" end if
			ArtikelText = ArtikelText + sPosText
		end if
	end if
	if (IS( POS_IST_STAMMART )) OR (IS( POS_IST_ALTERNATIV ))  Then
		if (bArtikelFreifeld1) AND (Get(ART_FREIFELD1) <> "") then
			if ArtikelText <> "" then ArtikelText = ArtikelText + "\n" end if
			ArtikelText = ArtikelText + Get(ART_FREIFELD1)
		end if
		if (bArtikelFreifeld2)  AND (Get(ART_FREIFELD2) <> "") then
			if ArtikelText <> "" then ArtikelText = ArtikelText + "\n" end if
			ArtikelText = ArtikelText + Get(ART_FREIFELD2)
		end if
		if (bArtikelFreifeld3)  AND (Get(ART_FREIFELD3) <> "") then
			if ArtikelText <> "" then ArtikelText = ArtikelText + "\n" end if
			ArtikelText = ArtikelText + Get(ART_FREIFELD3)
		end if
		if (bArtikelFreifeld4)  AND (Get(ART_FREIFELD4) <> "") then
			if ArtikelText <> "" then ArtikelText = ArtikelText + "\n" end if
			ArtikelText = ArtikelText + Get(ART_FREIFELD4)
		end if
		if (bArtikelFreifeld5)  AND (Get(ART_FREIFELD5) <> "") then
			if ArtikelText <> "" then ArtikelText = ArtikelText + "\n" end if
			ArtikelText = ArtikelText + Get(ART_FREIFELD5)
		end if
		if (bArtikelFreifeld6)  AND (Get(ART_FREIFELD6) <> "") then
			if ArtikelText <> "" then ArtikelText = ArtikelText + "\n" end if
			ArtikelText = ArtikelText + Get(ART_FREIFELD6)
		end if
		if (GetNumeric( POS_IST_AKTIONPREIS ) = 2) AND ( Get(POS_AKTIONBEZEICHNUNG) <> "" ) then 'Preis ist Aktionspreis
			if ArtikelText <> "" then ArtikelText = ArtikelText + "\n" end if
			ArtikelText = ArtikelText + Get( POS_AKTIONBEZEICHNUNG )
		end if
	end if

	' wenn es eine Alternativposition ist, dann kennzeichnen
	if (IS(POS_IST_ALTERNATIV) = true) OR (IS(POS_IST_MANALTERNATIV) = true) then
		ArtikelText = "Alternativposition\n" + ArtikelText
	end if

	SetCellText(Spalte, ArtikelText)

End Function

'////////////////////////////////////////////////////////////////////////////////////
'Funktion - FuelleTabelleNetto()
'Füllen der Tabelle für einen NettoAuftrag
'////////////////////////////////////////////////////////////////
Function FuelleTabelleNetto()
	DIM bHatAbschlag as bool = false
	DIM nPosTyp as numeric
	DIM strBez as string = ""
	strGewicht = ""
	strProzent = ""
	DIM nLastPage as numeric = nAuftragPage
	Dim nCount as numeric     'Stücklistenpositionen
	Dim ArtikelLine as Numeric  'Artikelpos. Höhe
	Dim bPosKommentar as bool = false
	Dim bMitKommentar as bool = false
	DrawCell(C_H_Zeile, True)								'SpaltenÜberschriften
	SetHeaderCell(C_H_Head)
	' Ausgabe der Steuern, nur wenn ausgewählt
	IF IS(LAY_TAB_MIT_STEUER) then
		SetFooterCell(C_S_Zeile)
	else
		SetFooterCell(C_S_Bottom)
	end if

	nCurrencySymbol = CURRENCY_SYMBOL_HIDE
	' Ausgabe mit CURRENCY_SYMBOL_RIGHT hat unter '95 und '98 ein Problem, deshalb selbst formatieren
	if bMitWaehrung then
		strWaehrungsSymbol =  " " + GetCurrencySymbol(AUFTR_RG_BETRAG, bWaehrungAlsText)
		strGewicht = " kg"
		strProzent = " %"
	end if


	' in dieser Schleife werden alle Rechnungsposten ausgelesen und entsprechend in den Spalten dargestellt
	' die Ausgabe der Summenzeilen erfolgt in einer separaten Schleife
	Result_P= FirstRecord(AUFTRPOSITION)															'Erster Rechungsposten

	Dim Result_Z as bool
	dim bWeiter as bool = TRUE
	While Result_P Do
		nSteuerSatz = GetNumeric(POS_UST_SATZ)

		If IS(POS_IST_LOHNLEISTUNG) then

			nUstLohn = GetNumeric(POS_GES_UST)
			if nUstLohnalt <> nUstLohn then
				bAuftrLohnUst = true
			end if
			nUstLohnalt = nUstLohn

		end if
		if bmitSchraffur = true then
			bmitSchraffur = true
		else
			bmitSchraffur = false
		end if

		' Zwischensumme
		if is (POS_IST_ZWSUMME) then
			if bmitSchraffur = true then
				bmitSchraffur = false
			else
				bmitSchraffur = true
			end if
			SetCellText(C_Spalte_1, "Z")																			'Position als Zwischensumme kennzeichnen
			SetCellImage(C_Spalte_1, "", IMAGE_Bottom, 20 )
			SetCellImage(C_Spalte_4, "", IMAGE_Bottom, 20 )
			SetCellImage(C_Spalte_5, "", IMAGE_Bottom, 20 )
			SetCellImage(C_Spalte_6, "", IMAGE_Bottom, 20 )
		end if
		if IS(POS_IST_TEXTPOS) then
			SetCellImage(C_Spalte_1, "", IMAGE_Bottom, 20 )
			SetCellImage(C_Spalte_4, "", IMAGE_Bottom, 20 )
			SetCellImage(C_Spalte_5, "", IMAGE_Bottom, 20 )
		end if

		' nur wenn keine Nebenleistungen
		if IS(POS_IST_NEBENL) = FALSE then

			if nAnzahlSt = 0 then
				nAnzahlSt = 1 'erhöhe Anzahl Steuersätze wg. nicht steuerbaren
			end if

			'manueller Artikel, Stammartikel, Alternativpos
			IF IS( POS_IST_STAMMART ) OR IS( POS_IST_MANUELLE_POS ) OR IS( POS_IST_ALTERNATIV )OR IS(POS_IST_DATANORM)OR IS(POS_IST_MANALTERNATIV) OR IS(POS_IST_KOMMENTAR) OR IS(POS_IST_LOHNLEISTUNG) Then
				'AlternativPosition ?
				if (IS (POS_IST_ALTERNATIV) = true) OR (IS ( POS_IST_MANALTERNATIV) = true ) then
					'HandleLayout(C_Zeile, bMitSchraffur, nSchraffurFarbe, ARIAL_KURSIV_9, PEN_NULL, VertLinienArt, nRand)
					SetCellText(C_Spalte_1, "A")																	'Position als Alternativ kennzeichnen
				else
					if IS(POS_IST_KOMMENTAR) then
						SelectCellFont(C_Spalte_1, SchriftArtKommentar)
						SetCellText(C_Spalte_1, "")																	'Position als Alternativ kennzeichnen
					else
						SetCellText(C_Spalte_1, FormatNumeric("%.0f", GetNumeric(POS_NR)))				'PositionNr
					end if
				end if
				if IS( POS_IST_STAMMART ) OR is (POS_IST_ALTERNATIV) then
					if  (Get("A", 52) <> "") AND bmitBildAnhang = true then
						bBildExist = true
					end if
					if bmitBildSpalte and nBildSpalteAuswahl = 0 then
						include "bildanzeigen.lsf"
					end if
				else
					SetCellImage(C_Spalte_1, "", IMAGE_Bottom, 20 )
				end if
				if IS(POS_IST_KOMMENTAR) then
					SetCellText(C_Spalte_2,"")
				else
					SetCellText(C_Spalte_2, FormatNumeric(FormatMenge, GetNumeric(POS_MENGE)))			'Menge
				end if
				SetCellText(C_Spalte_3, Get(POS_EINHEIT))														'Einheit
				' Artikelnummer nur, wenn keine Manuelle Position und Spalte sichtbar
				IF IS( POS_IST_MANUELLE_POS ) = FALSE AND nBreiteSpalte_3 > 0 then
					' wenn eine Bestellung, dann nicht die normale Artikelnummer des Artikels nehmen, sondern
					' die Artikelnummer des Lieferanten
					If is(AUFTR_IST_B) then
						if IS(POS_IST_DATANORM) OR Get(POS_BESTEL_NR) = "" then
							strTemp = Get(POS_ART_NR)				'Artikelnummer bei Datanorm oder bei leerer Bestellnr
						else
							strTemp = Get(POS_BESTEL_NR)			'Artikelnummer beim Lieferanten
						end if
					else
						strTemp = Get(POS_ART_NR)					'Artikelnummer
					end if
					'Nummer ausgeben und ggf. das Artikelbild
					SetCellText(C_Spalte_4, strTemp)
					if IS( POS_IST_STAMMART ) OR is (POS_IST_ALTERNATIV) then
						if bmitBildSpalte = True and nBildSpalteAuswahl = 1 then
							include "bildanzeigen.lsf"
						end if
					else
						SetCellImage(C_Spalte_4, "", IMAGE_Bottom, 20 )
					end if
				ELSE
					SetCellText(C_Spalte_4, "")
					SetCellImage(C_Spalte_4, "", IMAGE_Bottom, 20 )
				END IF
			END IF
		END IF
		' alle Positionsarten ausser Nebenleistungen
		If IS( POS_IST_NEBENL ) = FALSE Then
			if IS (POS_IST_KOMMENTAR) then
				SelectCellFont(C_Spalte_5, SchriftArtKommentar)
			end if
			PrintArtikelText(C_Spalte_5)																			'Artikelbezeichnungen
			if IS( POS_IST_STAMMART ) OR is(POS_IST_ALTERNATIV) then
				if bmitBildSpalte and nBildSpalteAuswahl = 2 then
					include "bildanzeigen.lsf"
				end if
			else
				SetCellImage(C_Spalte_5, "", IMAGE_Bottom, 20 )
			end if
			ArtikelLine = GetCellHeight(C_Spalte_5)

		if bStuecklistenArtikelAnzeigen then
			If is (ART_MIT_STUECKLISTE) = true AND ((IS( POS_IST_STAMMART ) = true) AND IS( POS_IST_ALTERNATIV ) = true)  then
				nPosition = GetAreaLength() - GetPosY() - GetCellHeight(C_Zeile_s)  - GetCellHeight(C_Spalte_5) - (nCount * GetCellHeight(C_Zeile_s))
				if nPosition < 0 then
					DrawCell(C_S_Zeile, True)
					Pagebreak()
				end if
			end if
		end if

		SetCurrencyNKStellen(GetNumeric(FA_NACHKOMMAST_EK))											'setzen der Nachkommastellen wie in den Optionen
			' Währung nur anzeigen, wenn Wert nicht 0
			if (is (POS_IST_SEITENUMBRUCH) = true) OR (is (POS_IST_TEXTPOS) = true) OR  (is (POS_IST_ZWSUMME ) = true) OR (is (POS_IST_KOMMENTAR) = true)  then
				nCurrencyFormat = CURRENCY_SYMBOL_HIDE
			else
				nCurrencyFormat = nCurrencyFormatDefault
			end if

			if nBreiteSpalte_5 > 0 Then
			SetCelltext(C_Spalte_6, HCS(GetCurrencyFormat(POS_EINZELPREIS, CC_ORG, nCurrencyFormat)))	'Ausgabe des Einzelpreises
			end if
		SetCurrencyNKStellen( 2 )																				'setzen der Nachkommastellen auf 2 für rabatt und Gesamtpreis
			' Steuer statt Rabatt ausgeben
			IF bSteuerStattRabatt THEN
				'Prozentsatz des Steuersatzes bei Textpositionen nicht ausgeben
				IF IS( POS_IST_STAMMART ) OR IS( POS_IST_MANUELLE_POS ) OR IS( POS_IST_ALTERNATIV ) OR IS(POS_IST_DATANORM) OR IS(POS_IST_MANALTERNATIV) OR IS(POS_IST_LOHNLEISTUNG) Then
					SetCellText(C_Spalte_7, GetPositionsUStSatz() )
				end if
			ELSE
				if nBreiteSpalte_6 > 0 Then
					if GetNumeric(POS_RAB_PROZENT) <> 0 Then															'wenn Rabatt ausgewählt
						SetCellText(C_Spalte_7, FormatNumeric("%.2f", GetNumeric(POS_RAB_PROZENT)) + strProzent)		'Ausgabe des Rabattes
					end if
				end if
			END IF
			IF IS( POS_IST_STAMMART ) OR IS( POS_IST_MANUELLE_POS ) OR IS( POS_IST_ALTERNATIV ) OR IS(POS_IST_DATANORM) OR IS(POS_IST_MANALTERNATIV) OR IS(POS_IST_LOHNLEISTUNG)Then
				if nBreiteSpalte_6a > 0 then
					SetCellText(C_Spalte_7a, GetPositionsUStSatz() )
				end if
			end if
			' Währung nur anzeigen, wenn Wert nicht 0
			if (is (POS_IST_SEITENUMBRUCH) = true) OR (is (POS_IST_TEXTPOS) = true) OR (is (POS_IST_KOMMENTAR) = true) then
				nCurrencyFormat = CURRENCY_SYMBOL_HIDE
			else
				nCurrencyFormat = nCurrencyFormatDefault
			end if

			' den Gesamtbetrag bei einer Alternativposition in Klammern setzen
			if (is (POS_IST_ALTERNATIV) = true) OR (is ( POS_IST_MANALTERNATIV) = true ) then
				strPuffer = "( " + HCS(GetCurrencyFormatValue(POS_GES_NETPREIS, CC_ORG, nCurrencyFormat, nBetrag)) + " )"
			else
				strPuffer = HCS(GetCurrencyFormatValue(POS_GES_NETPREIS, CC_ORG, nCurrencyFormat, nBetrag))
			end if
			if nBreiteSpalte_7 > 0 Then
			SetCelltext(C_Spalte_8, strPuffer )																	'Ausgabe Gesamtpreis
			end if
			' AlternativPosition und Zwischensumme nicht in ZW-Berechnung
			if (is (POS_IST_ALTERNATIV) = false) AND (is (POS_IST_MANALTERNATIV) = false)AND  (is (POS_IST_ZWSUMME ) = false)  then
				nSumme = nSumme + nBetrag																			'Aufsummieren für den Übertrag, wenn keine Alternativpos
			end if
			if IS(POS_IST_KOMMENTAR) = false then																'Ausgabe der Zeile
				if is (POS_IST_SEITENUMBRUCH) then
					SetCellImage(C_Spalte_1, "", IMAGE_Bottom, 20 )
					SetCellImage(C_Spalte_4, "", IMAGE_Bottom, 20 )
					SetCellImage(C_Spalte_5, "", IMAGE_Bottom, 20 )
					SetCellImage(C_Spalte_6, "", IMAGE_Bottom, 20 )
				end if
				DrawCell(C_Zeile, True)
			else
				if IS(AUFTR_MIT_KOMMENTAR) = true then
					DrawCell(C_Zeile, True)
				end if
			end if

			If is (POS_IST_SEITENUMBRUCH)  Then
				DrawCell(C_S_Zeile, True)
				PageBreak()
			end if
	if bStuecklistenArtikelAnzeigen Then
			LeereZellen()

			IF (IS( POS_IST_STAMMART )) OR (IS(POS_IST_ALTERNATIV)) Then
			Result_Z = FirstRecord("Z")
			if Result_Z then
				if bmitSchraffur = true then
					bmitSchraffur = false
				else
					bmitSchraffur = true
				end if
				HandleLayout(C_Zeile_s, bMitSchraffur, nSchraffurFarbe, SchriftArtStandard, PEN_NULL, VertLinienArt, nRand)

				SetCellFont(C_Spalte_5s, "Arial", 8, FONT_BOLD, COLOR_BLACK)
				SetCellText(C_Spalte_1s, "")
				SetCellText(C_Spalte_2s, "")
				SetCellText(C_Spalte_3s, "")
				SetCellText(C_Spalte_4s, "")
				SetCellText(C_Spalte_5s, "bestehend aus:")
				SetCellText(C_Spalte_6s, "")
				SetCellText(C_Spalte_7s, "")
				SetCellText(C_Spalte_7sa, "")
				SetCellText(C_Spalte_8s, "")

				DrawCell(C_Zeile_s, True)

				nCount = 3
				While Result_Z do


					' Menge, Einheit, Artikelnummer, Bezeichnung
					SetCellText(C_Spalte_1s, "")
					SetCellText(C_Spalte_2s, FormatNumeric(FormatMenge, GetNumeric(STL_POS_MENGE)))
					SetCellText(C_Spalte_3s, Get(STL_POS_EINHEIT))
					SetCellText(C_Spalte_4s, Get(STL_POS_NR))
					SetCellText(C_Spalte_5s, Get(STL_POS_BEZ))' + "\n" + Get("Z", 96))
					SetCellFont(C_Spalte_1s, "Arial", 8, FONT_NORMAL, COLOR_BLACK)
					SetCellFont(C_Spalte_2s, "Arial", 8, FONT_NORMAL, COLOR_BLACK)
					SetCellFont(C_Spalte_3s, "Arial", 8, FONT_NORMAL, COLOR_BLACK)
					SetCellFont(C_Spalte_4s, "Arial", 8, FONT_NORMAL, COLOR_BLACK)
					SetCellFont(C_Spalte_5s, "Arial", 8, FONT_NORMAL, COLOR_BLACK)

					DrawCell(C_Zeile_s, True)

					nCount = nCount + 1
					Result_Z = NextRecord("Z")

				End While
				if bmitSchraffur = true then
					bmitSchraffur = false
				else
					bmitSchraffur = true
				end if
				end if
				LeereZellen()
			End if
	end if

			LeereZellen()																							'Leeren der Zellen, setzen der Schraffur

		'Wenn es Nebenleistungen gibt
		else
			Nebenleistung = True																					'wird für Darstellung der Zwischensummenzeile benötigt
		end if
		if IS(POS_IST_LOHNLEISTUNG) then
			nLohnbetrag = GetNumeric(POS_GES_NETPREIS)
			if is(KD_UMSAETZE_NICHT_STEUERBAR) = False then
				nLohnUst = 0.00
			else
				nLohnUst	= GetNumeric("P", 12)
			end if
			if bAuftrLohnUst = true then

				nLohnUstBetrag = nLohnbetrag * nLohnUst/100						'Betrag UstSteuer
				'nLohnbetrag = nLohnbetrag + nLohnUstBetrag						'BetragLohnnetto
				nSummeLohnBetrag = nSummeLohnBetrag + nLohnbetrag				'Summe Lohnbeträge
				nSummenLohnUstBetrag = nSummenLohnUstBetrag + nLohnUstBetrag	'Summe der Ust-Beträge


				If GetNumeric(AUFTR_RAB_GESAUFTR_DEM) <> 0 Then
					bAuftrhatgesamtrab = true
				end if
				bAuftrhatLohnleistung = true

			else

				If GetNumeric(AUFTR_RAB_GESAUFTR_DEM) <> 0 Then
					bAuftrhatgesamtrab = true
				end if
				bAuftrhatLohnleistung = true

				nSummeLohnBetrag = nSummeLohnBetrag + nLohnbetrag
			end if
		end if
		if bmitSchraffur = true then
				bmitSchraffur = false
			else
				bmitSchraffur = true
		end if
		Result_P= NextRecord(AUFTRPOSITION)				'Nächste Position
	End While
	'Ende der Darstellung Rechnungsposten

	if (Nebenleistung = True) and (nAnzahlStNeben=0) then
		nAnzahlStNeben = 1
	end if

	DrawCell(C_S_Bottom, true)

	SetFootercell(NULL)
	SetHeaderCell(NULL)

	nSumme = 0
'Seitenumbruch, wenn es für die folgenden Zeilen nicht mehr auf dieser Seite reicht
' Mit ZU nicht mehr nötig!! Da die automatischen ZWS nicht immer optisch angebracht sind!
	IF IS(LAY_TAB_MIT_STEUER) then
	nPosition = GetAreaLength() - GetPosY() - 8 * GetCellHeight(C_Zeile_s)
	If nPosition < 0  Then
		DrawCell(C_S_Zeile, True)
		PageBreak()
	end if
	else
	nPosition = GetAreaLength() - GetPosY() - GetCellHeight(C_Zeile_s)

	If nPosition < 0  Then
		DrawCell(C_S_Bottom, True)
		PageBreak()
	end if
	End If
	HandleLayout(C_S_Zeile, False, nSchraffurFarbe, SchriftArtStandard, PEN_NULL, VertLinienArt, nRand)


	'///////////////////////////////////////////////////////////////////
	'-----------------------Zwischensumme ausgeben, wenn Rabatt oder Nebenleistung--------------

	If GetNumeric(AUFTR_RAB_GESAUFTR_DEM) <> 0 Then																				'Wenn Rabatt auf den gesamten Auftrag
		LeereZellen()																														'Leeren der Zellen
		SetCellText(C_S_Spalte_1, "Zwischensumme")
		SetCellText(C_S_Spalte_2, HCS(GetCurrencyFormat(AUFTR_GESAMT_HAUPTL_NET, CC_ORG, nCurrencyFormatDefault)))			'Zwischensumme Netto
		SetCellBorder(C_S_Zeile, CELL_BORDER_TOP, 1, HorzLinienArt, COLOR_BLACK)										'Zeile mit Rahmen
		DrawCell(C_S_Zeile, True)																										'Ausgabe der Zeile Zwischensumme

		strPuffer = ""
		If is(AUFTR_IST_GES_RAB_BETRAG) = false Then
			strPuffer = FormatNumeric("%.2f", GetNumeric(AUFTR_RAB_GES_PROZ)) + "% "
		End If

		'Rabatt ausgeben
		LeereZellen()																							'Felder der Zeile leeren
		SetCellText(C_S_Spalte_1, "abzgl. " + strPuffer + strRabatt)
		SetCellText(C_S_Spalte_2, GetGesamtRabatt())
		SetCellBorder(C_S_Zeile, CELL_BORDER_TOP + CELL_BORDER_BOTTOM, 1, PEN_NULL, COLOR_BLACK)					'Zeile ohne Rahmen
		DrawCell(C_S_Zeile, True)																			'Ausgabe des Rabatts
	End If

	'Wenn es Nebenleistungen gibt, sieht Zwischensummenzeile anders aus
	If Nebenleistung Then												'Wenn es Nebenleistungen gibt
		LeereZellen()
		If GetNumeric(AUFTR_RAB_GESAUFTR_DEM) <> 0 Then			'Wenn Rabatt auf den gesamten Auftrag
			SetCellText(C_S_Spalte_1, "")
			SetCellText(C_S_Spalte_2, HCS(GetCurrencyFormatValue(AUFTR_NET_HAUPTL_NACH_RAB_ABZUG, CC_ORG, nCurrencyFormatDefault, nSumme)))	'Netto Hauptleistungen nach Rabattabzug
		Else
			SetCellText(C_S_Spalte_1, "Zwischensumme")
			SetCellText(C_S_Spalte_2, HCS(GetCurrencyFormatValue(AUFTR_GESAMT_HAUPTL_NET, CC_ORG, nCurrencyFormatDefault, nSumme)))		'Netto Hauptleistungen nach Rabattabzug
		End If

		SetCellBorder(C_S_Zeile, CELL_BORDER_TOP + CELL_BORDER_BOTTOM,  1, HorzLinienArt, COLOR_BLACK)			'Zeile mit Rahmen
		DrawCell(C_S_Zeile, True)																			'Ausgabe Rabatt
	End if

'	SetFootercell(C_S_Noetig)
'	SetHeaderCell(C_HU_Zeile)

	'/////////////////////////////////////////////////////////////////////////
	'------------------------------Nebenleistungen-----------------------------
	SetCellBorder(C_S_Zeile, CELL_BORDER_TOP + Cell_Border_Bottom, 1, HorzLinienArt, COLOR_BLACK)						'Zeile ohne Rahmen
	LeereZellen()																								'Zelleninhalte löschen

	' Alle Positionen eines Auftrags abklappern und unter Zwischensumme darstellen, wenn es sich um eine Nebenleistung handelt
	Result_P = FirstRecord(AUFTRPOSITION)
	While Result_P do
		'Wenn es Nebenleistungen gibt
		If is(POS_IST_NEBENL) Then
			SetCellText(C_S_Spalte_1, "zzgl. " + Get(POS_TEXT))																							'Nebenleistung
			SetCellText(C_S_Spalte_2, HCS(GetCurrencyFormatValue(POS_GES_NETPREIS, CC_ORG, nCurrencyFormatDefault, nBetrag)))	'Nebenleistung Betrag
			nSumme = nSumme + nBetrag

			DrawCell(C_S_Zeile, True)
			DrawCell(C_S_Bottom, True)
			SetCellText(C_S_Not_Spalte_2, HCS(FormatCurrency(CC_LOC, nCurrencyFormatDefault, nSumme)))
			SetCellText(C_HU_Spalte_2, HCS(FormatCurrency(CC_LOC, nCurrencyFormatDefault, nSumme)))
			LeereZellen()
		End If
		Result_P= NextRecord(AUFTRPOSITION)
	End While

	' Ausgabe der Steuern, nur wenn ausgewählt
	IF IS(LAY_TAB_MIT_STEUER) then
		'/////////////////////////////////////////////////////////////
		'---------------------Ausgabe der Steuern--------------------
			SetHeaderCell(NULL)
			nSumme = 0
			'Nur wenn auch USt. berechnet wurde
	'		If is(AUFTR_KEINE_UST) = false Then
				' Steuerstätze zählen
				n = 0
				nPosition = 0
				If (Getnumeric("R", 59) <> 0) Or (GetNumeric("R", 83) <> 0) Or (GetNumeric("R", 103) <> 0) Or (GetNumeric("R", 39) <> 0) Then
					Steuern = True
					n = ZaehleSteuersaetze()		'Zählen der einzelnen Steuersätze und Beträge
					n = n + 1	' einen Dazu, zur Korrektur
					nPosition = GetAreaLength() - GetPosY() - n * GetCellHeight(C_Zeile_s)
				End If

				SetCellText(C_S_Spalte_1, sTextGesamt)
				SetCellText(C_S_Spalte_2, HCS(GetCurrencyFormatValue("R", 110, CC_ORG, nCurrencyFormatDefault, nSumme)))
				SetCellBorder(C_S_Zeile, CELL_BORDER_TOP, 0, HorzLinienArt, COLOR_BLACK)		'Nettobetrag
				' wenn Steuern auf der nächsten Seite dargestellt werden müssen, dann muß das Feld Nettobetrag
				' auch unten einen Strich haben
				if nPosition < 0 then
					SetCellBorder(C_S_Zeile, CELL_BORDER_BOTTOM, 0, HorzLinienArt, COLOR_BLACK)
				end if
				DrawCell(C_S_Zeile, true)
				SetCellBorder(C_S_Zeile, CELL_BORDER_TOP, 0, PEN_NULL, COLOR_BLACK)
				If is("X", 15) then
					DrawCell(C_S_TOP, true)
					DrawCell(C_S_Bottom, true)
				End If
				LeereZellen()

				SelectFont(SchriftArtStandard)
				RemoveAllTabs()
				' wenn Steuersätze nicht mehr auf diese Seite passen, dann Seitenumbruch und Darstellung
				' auf der nächsten Seite
				if nPosition < 0 Then
					PageBreak()
					SetCellBorder(C_S_Zeile, CELL_BORDER_TOP + CELL_BORDER_BOTTOM, 1, HorzLinienArt, COLOR_BLACK)		'Nettobetrag
					DrawCell(C_S_Zeile, true)
					SetCellBorder(C_S_Zeile, CELL_BORDER_TOP + CELL_BORDER_BOTTOM, 0, PEN_NULL, COLOR_BLACK)
				End if
				'Ausgabe der einzelnen Umsatzsteuernsteuer mit Satz und Nettobeträge
				i=0
				nNetTeilsum = 53
				nBrutTeilsum = 58
				nUstsum  = 33
				nUstsatz = 38

				While i < nAnzahlSt do
					If bDruckeSteuerImmer Or (GetNumeric("R", nNetTeilsum) <> 0) Then
						If (GetNumeric("R", nUstsatz) <> 0) Or Is(AUFTR_HAT_NULLSTEUER) Then
							SteuernAusgabe(nUstsatz, nNetTeilsum, nUstsum, nBreite, GetCellWidth(C_H_Spalte_7), SchriftArtStandard, VertLinienArt, nSumme)
						Else
							Steuerfrei(nNetTeilsum, nBreite, GetCellWidth(C_H_Spalte_7), SchriftArtStandard, VertLinienArt)
						End If
					End If
					i=i+1
					nNetTeilsum = nNetTeilsum+1
					nBrutTeilsum = nBrutTeilsum+1
					nUstsum  = nUstsum+1
					nUstsatz = nUstsatz+1
				End While

				' Ausgabe Steuern auf Nebenleistungen
				i=0
				nNetTeilsum = 98
				nBrutTeilsum = 103
				nUstsum  = 78
				nUstsatz = 83

				While i < nAnzahlStNeben do
					If bDruckeSteuerImmer Or (GetNumeric("R", nNetTeilsum) <> 0) Then
						If (GetNumeric("R", nUstsatz) <> 0) Or Is(AUFTR_HAT_NULLSTEUER) Then
							SteuernAusgabe(nUstsatz, nNetTeilsum, nUstsum, nBreite, GetCellWidth(C_H_Spalte_7), SchriftArtStandard, VertLinienArt, nSumme)
						Else
							Steuerfrei(nBrutTeilsum, nBreite, GetCellWidth(C_H_Spalte_7), SchriftArtStandard, VertLinienArt)
						End If
					End If
					i = i + 1
					nNetTeilsum = nNetTeilsum + 1
					nBrutTeilsum = nBrutTeilsum + 1
					nUstsum  = nUstsum + 1
					nUstsatz = nUstsatz + 1
				End While
			If is("X", 15) then
				DrawCell(C_S_TOP, true)
				DrawCell(C_S_Bottom, true)
			End If
			SetHeaderCell(NULL)
			SetFooterCell(NULL)

		'///////////////////////////////////////////////////////////////
		'---------------------Formatierung der Gesamtsummenzeile------
'NETTO
		nBreite = GetCellWidth(C_H_Spalte_1) + GetCellWidth(C_H_Spalte_2) + GetCellWidth(C_H_Spalte_3) + GetCellWidth(C_H_Spalte_4) + GetCellWidth(C_H_Spalte_5) + GetCellWidth(C_H_Spalte_6) + GetCellWidth(C_H_Spalte_6a)  - (2*(GetCellWidth(C_H_Spalte_7)))

		C_S_Text = GetFormatCell(nBreite, 0, C_S_Abschlag, C_C_S_SPALTE)
		C_S_Text_2 = GetFormatCell(GetCellWidth(C_H_Spalte_7), 0, C_S_Abschlag, C_C_S_SPALTE)
		C_S_Text_3 = GetFormatCell(GetCellWidth(C_H_Spalte_7), 0, C_S_Abschlag, C_C_S_SPALTE)
		C_S_Text_4 = GetFormatCell(GetCellWidth(C_H_Spalte_7), 0, C_S_Abschlag, C_C_S_SPALTE)


		C_S_Spalte_1 = GetFormatCell(nBreite	, 0, C_S_Gesamt, C_C_S_SPALTE)
		C_S_Spalte_1a = GetFormatCell(GetCellWidth(C_H_Spalte_7), 0, C_S_Gesamt, C_C_S_SPALTE)
		C_S_Spalte_1b = GetFormatCell(GetCellWidth(C_H_Spalte_7), 0, C_S_Gesamt, C_C_S_SPALTE)
		C_S_Spalte_2 = GetFormatCell(GetCellWidth(C_H_Spalte_7), 0, C_S_Gesamt, C_C_S_SPALTE)


		SetRowStandard(C_S_Gesamt, SchriftArtStandard, CELL_TEXT_LEFT, -1)
		SetCellStandard(C_S_Spalte_1, SchriftArtGesamtbetrag, CELL_TEXT_LEFT, -1)
		SetCellStandard(C_S_Spalte_2, SchriftArtGesamtbetrag, CELL_TEXT_RIGHT, -1)

		SetRowStandard(C_S_Abschlag, SchriftArtStandard, CELL_TEXT_LEFT, -1)

		' beim Abschlag Forderungen drucken
		if (IsMitAbschlag()) then
			SetCellBorder(C_S_Gesamt, CELL_BORDER_TOP,    1, HorzLinienArt, nFarbe)
			SetCellBorder(C_S_Gesamt, CELL_BORDER_LEFT + CELL_BORDER_RIGHT, 1, VertLinienArt, nFarbe)

			'Ausgabe des Rechnungsbetrages
			SetCellText(C_S_Spalte_1, sTextGesamtbetrag + "\n")
			SetCellText(C_S_Spalte_2, "" + HCS(GetCurrencyFormat(AUFTR_RG_BETRAG, CC_ORG, nCurrencyFormatDefault)) + "\n")
			DrawCell(C_S_Gesamt, true)

			'Seitenumbruch, wenn es für die folgenden Zeilen nicht mehr auf dieser Seite reicht
			nPosition = GetAreaLength() - GetPosY() - 8 * GetCellHeight(C_Zeile_s)
			If nPosition < 0  Then
				DrawCell(C_S_Bottom, True)
				PageBreak()
			End If

			SetCellStandard(C_S_Text, SchriftArtGesamtbetrag, CELL_TEXT_LEFT, -1)
			SetCellStandard(C_S_Text_2, SchriftArtGesamtbetrag, CELL_TEXT_RIGHT, -1)
			SetCellStandard(C_S_Text_3, SchriftArtGesamtbetrag, CELL_TEXT_RIGHT, -1)
			SetCellStandard(C_S_Text_4, SchriftArtGesamtbetrag, CELL_TEXT_RIGHT, -1)
			SetCellStandard(C_S_Spalte_1, SchriftArtStandard, CELL_TEXT_LEFT, -1)
			SetCellStandard(C_S_Spalte_1a, SchriftArtStandard, CELL_TEXT_RIGHT, -1)
			SetCellStandard(C_S_Spalte_1b, SchriftArtStandard, CELL_TEXT_RIGHT, -1)
			SetCellStandard(C_S_Spalte_2, SchriftArtStandard, CELL_TEXT_RIGHT, -1)

			SetCellBorder(C_S_Abschlag, CELL_BORDER_LEFT + CELL_BORDER_RIGHT, 1, VertLinienArt, nFarbe)
			SetCellBorder(C_S_Abschlag, CELL_BORDER_Top, 1, HorzLinienArt, nFarbe)

				'Ausgabe des Abschlags

			SetCellText(C_S_Text, "\nAbzgl. bereits erhalten:")
			SetCellText(C_S_Text_2, "\nNetto")
			SetCellText(C_S_Text_3, "\n" + sUstText )
			SetCellText(C_S_Text_4, "\nBrutto")
			DrawCell(C_S_Abschlag, true)
			
			Result_G = FirstRecord("G")

			While Result_G do
				bHatAbschlag = TRUE
				SetFormatNumericOptions(FN_CUSTOM, "", "")
				SetCellText(C_S_Spalte_1, "Abschlagsre. Nr. " + FormatNumeric("%.0f", GetNumeric(ABS_RE_NR)) + " vom " + FormatDate("%d.%m.%Y", GetDate(ABS_RE_DATUM)) + " (" + sUstText + " "  + FormatNumeric("%.2f", GetNumeric(ABS_RE_SSATZ))+ " %)")
				SetFormatNumericOptions(FN_CUSTOM, ",", ".")
				SetCellText(C_S_Spalte_1a, HCS(GetCurrencyFormat(ABS_RE_NETTO, CC_ORG, nCurrencyFormatDefault)))
				SetCellText(C_S_Spalte_1b, HCS(GetCurrencyFormat(ABS_RE_UST, CC_ORG, nCurrencyFormatDefault)))
				SetCellText(C_S_Spalte_2, HCS(GetCurrencyFormat(ABS_RE_GESAMT, CC_ORG, nCurrencyFormatDefault)))
				DrawCell(C_S_Gesamt, true)
				Result_G = NextRecord("G")
			End While
			if bHatAbschlag = False then
				nTemp1x = GetNumeric(AUFTR_ABSCHLAG_ERHALTEN)
				strTemp2x= FormatNumeric("%.2f", GetNumeric(AUFTR_ABSCHLAG_NETTO))
				nTemp2x = StringToNumeric(strTemp2x)
				strUstAbschlag = nTemp1x - nTemp2x
				SetFormatNumericOptions(FN_CUSTOM, ",", ".")
				SetCellText(C_S_Spalte_1, GetTextAbschlagsbetrag())
				SetCellText(C_S_Spalte_1a, HCS(GetCurrencyFormat(AUFTR_ABSCHLAG_NETTO, CC_ORG, nCurrencyFormatDefault)))
				SetCellText(C_S_Spalte_1b, FormatNumeric("%.2f", strUstAbschlag) + strWaehrungsSymbol)
				SetCellText(C_S_Spalte_2, HCS(GetCurrencyFormat(AUFTR_ABSCHLAG_ERHALTEN, CC_ORG, nCurrencyFormatDefault)))
				DrawCell(C_S_Gesamt, true)
			end if
		end if
		ClearRow(C_S_Gesamt, "")


		'///////////////////////////////////////////////////////////////
		'---------------------Formatierung der Gesamtsummenzeile------

		SetCellStandard(C_S_Spalte_1, SchriftArtGesamtbetrag, CELL_TEXT_LEFT, -1)
		SetCellStandard(C_S_Spalte_2, SchriftArtGesamtbetrag, CELL_TEXT_RIGHT, -1)

		' die Zellen für den Gesamtbetrag neu formatieren
		SetCellBorder(C_S_Gesamt, CELL_BORDER_BOTTOM, 5, HorzLinienArt, COLOR_BLACK)
		SetCellBorder(C_S_Gesamt, CELL_BORDER_TOP,    1, HorzLinienArt, COLOR_BLACK)

		if VertLinienArt <> PEN_NULL then
			SetCellBorder(C_S_Gesamt, CELL_BORDER_LEFT + CELL_BORDER_RIGHT, 0, PEN_SOLID, COLOR_BLACK)
		else
			SetCellBorder(C_S_Gesamt, CELL_BORDER_LEFT + CELL_BORDER_RIGHT, 0, VertLinienArt, COLOR_BLACK)
		end if
		SetCellBorder(C_S_Spalte_2, CELL_BORDER_LEFT, 0, VertLinienArt, COLOR_BLACK)

		' beim Abschlag Forderungen drucken
		if (IsMitAbschlag()) then
			nTemp1 = GetNumeric(AUFTR_UST_GESBETRAG)
			nTemp2 = GetNumeric(AUFTR_ABSCHLAG_STEUER)
			strUstForderung = nTemp1 - nTemp2
			SetCellBorder(C_S_Spalte_1, CELL_BORDER_BOTTOM, 0, PEN_NULL, COLOR_BLACK)
			SetCellBorder(C_S_Gesamt, CELL_BORDER_BOTTOM, 0, PEN_NULL, COLOR_BLACK)


			SetCellText(C_S_Spalte_1, "Forderungsbetrag")
			SetFormatNumericOptions(FN_CUSTOM, ",", ".")
			SetCellText(C_S_Spalte_2, HCS(GetCurrencyFormat(AUFTR_ABSCHLAG_FORDER, CC_ORG, nCurrencyFormatDefault)))
			DrawCell(C_S_Gesamt, true)
			ClearRow(C_S_Gesamt, "")
			SetCellBorder(C_S_Gesamt, CELL_BORDER_TOP, 0, PEN_NULL, COLOR_BLACK)
			SetCellBorder(C_S_Spalte_1, CELL_BORDER_TOP, 0, PEN_NULL, COLOR_BLACK)
			SetCellBorder(C_S_Gesamt, CELL_BORDER_BOTTOM, 5, PEN_SOLID, COLOR_BLACK)
			SetCellStandard(C_S_Spalte_1, SchriftArtStandard, CELL_TEXT_LEFT, -1)
			If (Getnumeric(ABS_RE_UST) <> 0) OR (Getnumeric(AUFTR_ABSCHLAG_STEUER) <> 0) OR (Getnumeric(AUFTR_UST_GESBETRAG) <> 0) OR Is(AUFTR_HAT_NULLSTEUER) then
				SetCellText(C_S_Spalte_1, "Im Forderungsbetrag sind " + FormatNumeric("%.2f", strUstForderung) + " " + GetCurrencySymbol(AUFTR_RG_BETRAG, bWaehrungAlsText) + " " + sUstText + " enthalten.")
			else
				if b13Umsatzsteuer = false then
					SetCellText(C_S_Spalte_1, "Der Forderungsbetrag ist steuerfrei" + sGrundstfrei  + ".")
				end if
			end if
			DrawCell(C_S_Gesamt, true)
			ClearRow(C_S_Gesamt, "")
		else
			SetCellText(C_S_Spalte_1, "\n" + sTextGesamtbetrag)
			SetCellText(C_S_Spalte_2, "\n" + HCS(GetCurrencyFormat(AUFTR_RG_BETRAG, CC_ORG, nCurrencyFormatDefault)))
			DrawCell(C_S_Gesamt, true)
		end if
		'Zusatz für steuerfreie Aufträge nach § 13b UStG. - ab 01.04.04!
		if b13Umsatzsteuer = TRUE  then
			ClearRow(C_S_Gesamt, "")
			SetCellBorder(C_S_Spalte_1, CELL_BORDER_RIGHT, 0, PEN_NULL, COLOR_BLACK)
			SetCellBorder(C_S_Spalte_2, CELL_BORDER_LEFT, 0, PEN_NULL, COLOR_BLACK)

			if IS("K", 79)= false then
				SetCellText(C_S_Gesamt, "\n" + strText13bUstG)
			else
				SetCellText(C_S_Gesamt, "\n" + strText13bUstGSo)
			end if
			SetCellStandard(C_S_Gesamt, SchriftArtStandard, CELL_TEXT_LEFT, -1)
			SetCellBorder(C_S_Gesamt, CELL_BORDER_ALL, 0, PEN_SOLID, COLOR_BLACK)
			DrawCell(C_S_Gesamt, true)
		end if
	end if
	SetFormatNumericOptions(FN_CUSTOM, "", "")
	LeereZellen()
End Function

'////////////////////////////////////////////////////////////////////////////////////
'Funktion - FuelleTabelleBrutto()
'Füllen der Tabelle für einen BruttoAuftrag
'////////////////////////////////////////////////////////////////
Function FuelleTabelleBrutto()
	dim bHatAbschlag as bool = false
	Dim nCount as numeric     'Stücklistenpositionen
	Dim ArtikelLine as Numeric  'Artikelpos. Höhe
	strProzent = ""
	bAuftrhatLohnleistung = false
	bAuftrhatgesamtrab = false
	nSummeLohnUst = 0
	nLohnUst = 0
	nRabattprozentual = 0
	nRabattabsolut = 0
	nSummeHauptleistung = 0
	nSummeLohnbetragProz = 0
	nSummeRabattLohn = 0
	nSonstKosten = 0
	nLohnbetrag = 0
	nSummeLohnBetrag = 0
	nRabattbetrag = 0
	bAuftrLohnUst = false
	nSummenLohnUstBetrag = 0
	nRabattBetragLL = 0
	DrawCell(C_H_Zeile, True)								'SpaltenÜberschriften
	SetHeaderCell(C_H_Head)
	' Ausgabe der Steuern, nur wenn ausgewählt
	IF IS(LAY_TAB_MIT_STEUER) then
		SetFooterCell(C_S_Zeile)
	else
		SetFooterCell(C_S_Bottom)
	end if

	nCurrencySymbol = CURRENCY_SYMBOL_HIDE
	' Ausgabe mit CURRENCY_SYMBOL_RIGHT hat unter '95 und '98 ein Problem, deshalb selbst formatieren
	if bMitWaehrung then
		strWaehrungsSymbol =  " " + GetCurrencySymbol(AUFTR_RG_BETRAG, bWaehrungAlsText)
		strProzent = " %"
	end if

	' in dieser Schleife werden alle Rechnungsposten ausgelesen und entsprechend in den Spalten dargestellt
	' die Ausgabe der Summenzeilen erfolgt in einer separaten Schleife
	Result_P= FirstRecord(AUFTRPOSITION)																		'Erster Rechungsposten

	Dim Result_Z as bool

	While Result_P Do
		nSteuerSatz = GetNumeric(POS_UST_SATZ)

		If IS(POS_IST_LOHNLEISTUNG) then

			nUstLohn = GetNumeric(POS_GES_UST)
			if nUstLohnalt <> nUstLohn then
				bAuftrLohnUst = true
			end if
			nUstLohnalt = nUstLohn

		end if
		' Zwischensumme
		if is (POS_IST_ZWSUMME) then
			SetCellText(C_Spalte_1, "Z")																			'Position als Zwischensumme kennzeichnen
			SetCellImage(C_Spalte_1, "", IMAGE_Bottom, 20 )
			SetCellImage(C_Spalte_4, "", IMAGE_Bottom, 20 )
			SetCellImage(C_Spalte_5, "", IMAGE_Bottom, 20 )
			SetCellImage(C_Spalte_6, "", IMAGE_Bottom, 20 )
		end if
		if IS(POS_IST_TEXTPOS) then
			SetCellImage(C_Spalte_1, "", IMAGE_Bottom, 20 )
			SetCellImage(C_Spalte_4, "", IMAGE_Bottom, 20 )
			SetCellImage(C_Spalte_5, "", IMAGE_Bottom, 20 )
		end if

		' nur wenn keine Nebenleistungen
		if IS(POS_IST_NEBENL) = FALSE then

			if nAnzahlSt = 0 then
				nAnzahlSt = 1 'erhöhe Anzahl Steuersätze wg. nicht steuerbaren
			end if

			'manueller Artikel, Stammartikel, Alternativpos
			IF IS( POS_IST_STAMMART ) OR IS( POS_IST_MANUELLE_POS ) OR IS( POS_IST_ALTERNATIV ) OR IS(POS_IST_DATANORM) OR IS(POS_IST_MANALTERNATIV) OR IS(POS_IST_KOMMENTAR) OR IS(POS_IST_LOHNLEISTUNG) Then

				'AlternativPosition ?
				if (IS (POS_IST_ALTERNATIV) = true) OR (IS(POS_IST_MANALTERNATIV)) then
					'HandleLayout(C_Zeile, bMitSchraffur, nSchraffurFarbe, ARIAL_KURSIV_9, PEN_NULL, VertLinienArt, nRand)
					SetCellText(C_Spalte_1, "A")																	'Position als Alternativ kennzeichnen
				else
					if IS(POS_IST_KOMMENTAR) then
						SelectCellFont(C_Spalte_1, SchriftArtKommentar)
						SetCellText(C_Spalte_1,"")
					else
						SetCellText(C_Spalte_1, FormatNumeric("%.0f", GetNumeric(POS_NR)))				'PositionNr
					end if
				end if
				if IS( POS_IST_STAMMART ) OR is (POS_IST_ALTERNATIV) then
					if  (Get("A", 52) <> "") AND bmitBildAnhang = true then
						bBildExist = true
					end if
					if bmitBildSpalte and nBildSpalteAuswahl = 0 then
						include "bildanzeigen.lsf"
					end if
				else
					SetCellImage(C_Spalte_1, "", IMAGE_Bottom, 20 )
				end if
				if IS(POS_IST_KOMMENTAR) then
					SetCellText(C_Spalte_2,"")
				else
					SetCellText(C_Spalte_2, FormatNumeric(FormatMenge, GetNumeric(POS_MENGE)))			'Menge
				end if
				SetCellText(C_Spalte_3, Get(POS_EINHEIT))														'Einheit
				' Artikelnummer nur, wenn keine Manuelle Position und Spalte sichtbar
				IF IS( POS_IST_MANUELLE_POS ) = FALSE AND nBreiteSpalte_3 > 0 then
					' wenn eine Bestellung, dann nicht die normale Artikelnummer des Artikels nehmen, sondern
					' die Artikelnummer des Lieferanten
					If is(AUFTR_IST_B) then
						if IS(POS_IST_DATANORM) OR Get(POS_BESTEL_NR) = "" then
							strTemp = Get(POS_ART_NR)				'Artikelnummer bei Datanorm oder bei leerer Bestellnr
						else
							strTemp = Get(POS_BESTEL_NR)			'Artikelnummer beim Lieferanten
						end if
					else
						strTemp = Get(POS_ART_NR)					'Artikelnummer
					end if
					'Nummer ausgeben und ggf. das Artikelbild
					SetCellText(C_Spalte_4, strTemp)
					if IS( POS_IST_STAMMART ) OR is (POS_IST_ALTERNATIV) then
						if bmitBildSpalte = True and nBildSpalteAuswahl = 1 then
							include "bildanzeigen.lsf"
						end if
					else
						SetCellImage(C_Spalte_4, "", IMAGE_Bottom, 20 )
					end if
				ELSE
					SetCellText(C_Spalte_4, "")
					SetCellImage(C_Spalte_4, "", IMAGE_Bottom, 20 )
				end if
			end if
		end if
		' alle Positionsarten ausser Nebenleistungen
		If IS( POS_IST_NEBENL ) = FALSE Then
			if IS (POS_IST_KOMMENTAR) then
				SelectCellFont(C_Spalte_5, SchriftArtKommentar)
			end if
			PrintArtikelText(C_Spalte_5)																			'Artikelbezeichnungen
			if IS( POS_IST_STAMMART ) OR is (POS_IST_ALTERNATIV) then
				if bmitBildSpalte = true and nBildSpalteAuswahl = 2 then
					include "bildanzeigen.lsf"
				end if
			else
				SetCellImage(C_Spalte_5, "", IMAGE_Bottom, 20 )
			end if
			ArtikelLine = GetCellHeight(C_Spalte_5)
			if bStuecklistenArtikelAnzeigen then
				If is (ART_MIT_STUECKLISTE) = true AND ((IS( POS_IST_STAMMART ) = true) AND IS( POS_IST_ALTERNATIV ) = true)  then
					nPosition = GetAreaLength() - GetPosY() - GetCellHeight(C_Zeile_s)  - GetCellHeight(C_Spalte_5) - (nCount * GetCellHeight(C_Zeile_s))
					if nPosition < 0 then
						DrawCell(C_S_Zeile, True)
						Pagebreak()
					end if
				end if
			end if

			SetCurrencyNKStellen(GetNumeric(FA_NACHKOMMAST_EK))											'setzen der Nachkommastellen wie in den Optionen
			' Währung nur anzeigen, wenn Wert nicht 0
			if  (is (POS_IST_SEITENUMBRUCH) = true) OR (is (POS_IST_TEXTPOS) = true) OR  (is (POS_IST_ZWSUMME ) = true) OR (is (POS_IST_KOMMENTAR) = true) then
				nCurrencyFormat = CURRENCY_SYMBOL_HIDE
			else
				nCurrencyFormat = nCurrencyFormatDefault
			end if

			if nBreiteSpalte_5 > 0 Then
			SetCelltext(C_Spalte_6, HCS(GetCurrencyFormat(POS_EINZELPREIS, CC_ORG, nCurrencyFormat)))	'Ausgabe des Einzelpreises
			end if
			SetCurrencyNKStellen( 2 )																				'setzen der Nachkommastellen auf 2 für rabatt und Gesamtpreis
			' Steuer statt Rabatt ausgeben
			IF bSteuerStattRabatt THEN
				'Prozentsatz des Steuersatzes  bei Textpositionen nicht ausgeben
				IF IS( POS_IST_STAMMART ) OR IS( POS_IST_MANUELLE_POS ) OR IS( POS_IST_ALTERNATIV ) OR IS(POS_IST_DATANORM) OR IS(POS_IST_MANALTERNATIV) OR IS(POS_IST_LOHNLEISTUNG) then
					SetCellText(C_Spalte_7, GetPositionsUStSatz() )
				end if
			ELSE
				if nBreiteSpalte_6 > 0 Then
					if GetNumeric(POS_RAB_PROZENT) <> 0 Then																			'wenn Rabatt ausgewählt
						SetCellText(C_Spalte_7, FormatNumeric("%.2f", GetNumeric(POS_RAB_PROZENT)) + strProzent)		'Ausgabe des Rabattes
					end if
				end if
			END IF
			IF IS( POS_IST_STAMMART ) OR IS( POS_IST_MANUELLE_POS ) OR IS( POS_IST_ALTERNATIV ) OR IS(POS_IST_DATANORM) OR IS(POS_IST_MANALTERNATIV) OR IS(POS_IST_LOHNLEISTUNG) Then
				if nBreiteSpalte_6a > 0 then
					SetCellText(C_Spalte_7a, GetPositionsUStSatz() )
				end if
			end if

			if  (is (POS_IST_SEITENUMBRUCH) = true) OR (is (POS_IST_TEXTPOS) = true) OR (is (POS_IST_KOMMENTAR) = true) then
				nCurrencyFormat = CURRENCY_SYMBOL_HIDE
			else
				nCurrencyFormat = nCurrencyFormatDefault
			end if

			' den Gesamtbetrag bei einer Alternativposition in Klammern setzen
			strPuffer = HCS(GetCurrencyFormatValue(POS_GES_BRUTPREIS, CC_ORG, nCurrencyFormat, nBetrag))
			if (IS( POS_IST_ALTERNATIV )) OR (IS(POS_IST_MANALTERNATIV) )then
				strPuffer = "( " + strPuffer + " )"
			end if
			if nBreiteSpalte_7 > 0 then
				SetCelltext(C_Spalte_8, strPuffer )																	'Ausgabe Gesamtpreis
			end if
			' AlternativPosition und Zwischensumme nicht in ZW-Berechnung
			if (is (POS_IST_ALTERNATIV) = false) AND (IS(POS_IST_MANALTERNATIV) = false) AND  (is (POS_IST_ZWSUMME ) = false) then
				nSumme = nSumme + nBetrag																			'Aufsummieren für den Übertrag, wenn keine Alternativpos
			end if

			if IS(POS_IST_KOMMENTAR) = false then
				if is (POS_IST_SEITENUMBRUCH) then															'Ausgabe der Zeile
					SetCellImage(C_Spalte_1, "", IMAGE_Bottom, 20 )
					SetCellImage(C_Spalte_4, "", IMAGE_Bottom, 20 )
					SetCellImage(C_Spalte_5, "", IMAGE_Bottom, 20 )
					SetCellImage(C_Spalte_6, "", IMAGE_Bottom, 20 )
				end if
				DrawCell(C_Zeile, True)
			else
				if IS(AUFTR_MIT_KOMMENTAR) = true then
					DrawCell(C_Zeile, True)
				end if
			end if

			If is (POS_IST_SEITENUMBRUCH)  Then
				DrawCell(C_S_Zeile, True)
				PageBreak()
			end if

			if bStuecklistenArtikelAnzeigen Then
					LeereZellen()

				IF (IS( POS_IST_STAMMART )) OR (IS(POS_IST_ALTERNATIV)) Then
						Result_Z = FirstRecord("Z")

						if Result_Z then
							SetCellFont(C_Spalte_5s, "Arial", 8, FONT_BOLD, COLOR_BLACK)
							SetCellText(C_Spalte_1s, "")
							SetCellText(C_Spalte_2s, "")
							SetCellText(C_Spalte_3s, "")
							SetCellText(C_Spalte_4s, "")
							SetCellText(C_Spalte_5s, "bestehend aus:")
							SetCellText(C_Spalte_6s, "")
							SetCellText(C_Spalte_7s, "")
							SetCellText(C_Spalte_7sa, "")
							SetCellText(C_Spalte_8s, "")

							DrawCell(C_Zeile_s, True)

							nCount = 3

							While Result_Z do

								' Menge, Einheit, Artikelnummer, Bezeichnung
								SetCellText(C_Spalte_1s, "")
								SetCellText(C_Spalte_2s, FormatNumeric(FormatMenge, GetNumeric(STL_POS_MENGE)))
								SetCellText(C_Spalte_3s, Get(STL_POS_EINHEIT))
								SetCellText(C_Spalte_4s, Get(STL_POS_NR))
								SetCellText(C_Spalte_5s, Get(STL_POS_BEZ))
								SetCellFont(C_Spalte_1s, "Arial", 8, FONT_NORMAL, COLOR_BLACK)
								SetCellFont(C_Spalte_2s, "Arial", 8, FONT_NORMAL, COLOR_BLACK)
								SetCellFont(C_Spalte_3s, "Arial", 8, FONT_NORMAL, COLOR_BLACK)
								SetCellFont(C_Spalte_4s, "Arial", 8, FONT_NORMAL, COLOR_BLACK)
								SetCellFont(C_Spalte_5s, "Arial", 8, FONT_NORMAL, COLOR_BLACK)

								DrawCell(C_Zeile_s, True)
								nCount = nCount + 1

								Result_Z = NextRecord("Z")
							End While
							end if
							LeereZellen()

					end if
			end if
			if IS(POS_IST_LOHNLEISTUNG) then
				nLohnbetrag = GetNumeric(POS_GES_BRUTPREIS)
				if is(KD_UMSAETZE_NICHT_STEUERBAR) = False then
					nLohnUst	= 0.00
				else
					nLohnUst	= GetNumeric("P", 12)
				end if
				if bAuftrLohnUst = true then

					nSummeLohnBetrag = nSummeLohnBetrag + nLohnbetrag				'Summe Lohnbeträge
					nSummenLohnUstBetrag = nSummenLohnUstBetrag + nLohnUstBetrag	'Summe der Ust-Beträge


					If GetNumeric(AUFTR_RAB_GESAUFTR_DEM) <> 0 Then
						bAuftrhatgesamtrab = true
					end if
					bAuftrhatLohnleistung = true

				else

					If GetNumeric(AUFTR_RAB_GESAUFTR_DEM) <> 0 Then
						bAuftrhatgesamtrab = true
					end if
					bAuftrhatLohnleistung = true

					nSummeLohnBetrag = nSummeLohnBetrag + nLohnbetrag
				end if
			end if

			LeereZellen()
				if bMitSchraffur = true  then
					bMitSchraffur = false
				else
					bMitSchraffur = true
				end if

		'Wenn es Nebenleistungen gibt
		else
			Nebenleistung = True																					'wird für Darstellung der Zwischensummenzeile benötigt
		end if
		' Standard zurückstellen
'		if is( POS_IST_ALTERNATIV ) then
'			HandleLayout(C_Zeile, bMitSchraffur, nSchraffurFarbe, SchriftArtStandard, PEN_NULL, VertLinienArt, nRand)
'		end if
		Result_P= NextRecord(AUFTRPOSITION)				'Nächste Position
	End While
	'Ende der Darstellung Rechnungsposten

	if (Nebenleistung = True) and (nAnzahlStNeben=0) then
		nAnzahlStNeben = 1
	end if

	DrawCell(C_S_Bottom, true)

	SetFooterCell(NULL)
	SetHeaderCell(NULL)
	nSumme = 0

	'Seitenumbruch, wenn es für die folgenden Zeilen nicht mehr auf dieser Seite reicht
	' Ausgabe der Steuern, nur wenn ausgewählt
	IF IS(LAY_TAB_MIT_STEUER) then
		nPosition = GetAreaLength() - GetPosY() - 8 * GetCellHeight(C_Zeile_s)
		if b13Umsatzsteuer then
			nPosition = GetAreaLength() - GetPosY() - 10 * GetCellHeight(C_Zeile_s)
		end if
		If nPosition < 0  Then
			DrawCell(C_S_Zeile, True)
			PageBreak()
		end if
	else
		nPosition = GetAreaLength() - GetPosY() - GetCellHeight(C_Zeile_s)
		If nPosition < 0  Then
			DrawCell(C_S_Bottom, True)
			PageBreak()
		end if
	End If

	HandleLayout(C_S_Zeile, False, nSchraffurFarbe, SchriftArtStandard, PEN_NULL, VertLinienArt, nRand)

	'///////////////////////////////////////////////////////////////////
	'-----------------------Zwischensumme ausgeben, wenn Rabatt oder Nebenleistung--------------

	If GetNumeric(AUFTR_RAB_GESAUFTR_DEM) <> 0 Then																				'Wenn Rabatt auf den gesamten Auftrag
		LeereZellen()																														'Leeren der Zellen
		SetCellText(C_S_Spalte_1, "Zwischensumme")
		SetCellText(C_S_Spalte_2, HCS(GetCurrencyFormat(AUFTR_GESAMT_HAUPTL_BRUT, CC_ORG, nCurrencyFormatDefault)))			'Zwischensumme Netto
		SetCellBorder(C_S_Zeile, CELL_BORDER_TOP, 1, HorzLinienArt, COLOR_BLACK)										'Zeile mit Rahmen
		DrawCell(C_S_Zeile, True)																										'Ausgabe der Zeile Zwischensumme

		strPuffer = ""
		If is(AUFTR_IST_GES_RAB_BETRAG) = false Then
			strPuffer = FormatNumeric("%.2f", GetNumeric(AUFTR_RAB_GES_PROZ)) + "% "
		End If

		'Rabatt ausgeben
		LeereZellen()																							'Felder der Zeile leeren
		SetCellText(C_S_Spalte_1, "abzgl. " + strPuffer + strRabatt)
		SetCellText(C_S_Spalte_2, GetGesamtRabatt())
		SetCellBorder(C_S_Zeile, CELL_BORDER_TOP + CELL_BORDER_BOTTOM, 1, PEN_NULL, COLOR_BLACK)					'Zeile ohne Rahmen
		DrawCell(C_S_Zeile, True)																			'Ausgabe des Rabatts
	End If


	'Wenn es Nebenleistungen gibt, sieht Zwischensummenzeile anders aus
	If Nebenleistung Then												'Wenn es Nebenleistungen gibt
		LeereZellen()
		If GetNumeric(AUFTR_RAB_GESAUFTR_DEM) <> 0 Then			'Wenn Rabatt auf den gesamten Auftrag
			SetCellText(C_S_Spalte_1, "")
			SetCellText(C_S_Spalte_2, HCS(GetCurrencyFormatValue(AUFTR_BRUT_HAUPTL_NACH_RAB_ABZUG, CC_ORG, nCurrencyFormatDefault, nSumme)))	'Netto Hauptleistungen nach Rabattabzug
		Else
			SetCellText(C_S_Spalte_1, "Zwischensumme")
			SetCellText(C_S_Spalte_2, HCS(GetCurrencyFormatValue(AUFTR_GESAMT_HAUPTL_BRUT, CC_ORG, nCurrencyFormatDefault, nSumme)))		'Netto Hauptleistungen nach Rabattabzug
		End If

		SetCellBorder(C_S_Zeile, CELL_BORDER_TOP + CELL_BORDER_BOTTOM, 1, HorzLinienArt, COLOR_BLACK)			'Zeile mit Rahmen
		DrawCell(C_S_Zeile, True)																			'Ausgabe Rabatt
	End if
	IF IS(LAY_TAB_MIT_STEUER) then
		SetFootercell(C_S_Noetig)
	else
		SetFooterCell(C_S_Bottom)
	end if

'	SetFootercell(C_S_Noetig)
	SetHeaderCell(C_HU_Zeile)

	'/////////////////////////////////////////////////////////////////////////
	'------------------------------Nebenleistungen-----------------------------
	SetCellBorder(C_S_Zeile, CELL_BORDER_TOP + Cell_Border_Bottom, 0, HorzLinienArt, COLOR_BLACK)						'Zeile ohne Rahmen
	LeereZellen()																								'Zelleninhalte löschen

	' Alle Positionen eines Auftrags abklappern und unter Zwischensumme darstellen, wenn es sich um eine Nebenleistung handelt
	Result_P = FirstRecord(AUFTRPOSITION)
	While Result_P do
		'Wenn es Nebenleistungen gibt
		If is(POS_IST_NEBENL) Then
			SetCellText(C_S_Spalte_1, "zzgl. " + Get(POS_TEXT))																			'Nebenleistung
			SetCellText(C_S_Spalte_2, HCS(GetCurrencyFormatValue(POS_GES_BRUTPREIS, CC_ORG, nCurrencyFormatDefault, nBetrag)))	'Nebenleistung Betrag
			nSumme = nSumme + nBetrag
			DrawCell(C_S_Zeile, True)
			SetCellText(C_S_Not_Spalte_2, HCS(FormatCurrency(CC_LOC, nCurrencyFormatDefault, nSumme)))
			SetCellText(C_HU_Spalte_2, HCS(FormatCurrency(CC_LOC, nCurrencyFormatDefault, nSumme)))
			LeereZellen()
		End If
		Result_P= NextRecord(AUFTRPOSITION)
	End While




'///////////////////////////////////////////////////////////////
	'---------------------Formatierung der Gesamtsummenzeile------
'BRUTTO

	' Ausgabe der Steuern, nur wenn ausgewählt
	IF IS(LAY_TAB_MIT_STEUER) then
		nBreite = GetCellWidth(C_H_Spalte_1) + GetCellWidth(C_H_Spalte_2) + GetCellWidth(C_H_Spalte_3) + GetCellWidth(C_H_Spalte_4) + GetCellWidth(C_H_Spalte_5) + GetCellWidth(C_H_Spalte_6) + GetCellWidth(C_H_Spalte_6a)'- (2*(GetCellWidth(C_H_Spalte_7)))

		C_S_Spalte_1 = GetFormatCell(nBreite, 0, C_S_Gesamt, C_C_S_SPALTE)
		C_S_Spalte_2 = GetFormatCell(GetCellWidth(C_H_Spalte_7), 0, C_S_Gesamt, C_C_S_SPALTE)

		SetRowStandard(C_S_Gesamt, SchriftArtStandard, CELL_TEXT_LEFT, -1)
		SetCellStandard(C_S_Spalte_1, SchriftArtGesamtbetrag, CELL_TEXT_LEFT, -1)
		SetCellStandard(C_S_Spalte_2, SchriftArtGesamtbetrag, CELL_TEXT_RIGHT, -1)

		SetRowStandard(C_S_Abschlag, SchriftArtStandard, CELL_TEXT_LEFT, -1)


		' den Abschlag nur bei Rechnungen und Sammelrechnungen

				SetCellBorder(C_S_Gesamt, CELL_BORDER_TOP,    1, HorzLinienArt, nFarbe)
				SetCellBorder(C_S_Gesamt, CELL_BORDER_LEFT + CELL_BORDER_RIGHT, 1, VertLinienArt, nFarbe)

				'Ausgabe des Rechnungsbetrages
				SetCellText(C_S_Spalte_1, "\n" + sTextGesamtbetrag)
				SetCellText(C_S_Spalte_2, "\n" + HCS(GetCurrencyFormat(AUFTR_RG_BETRAG, CC_ORG, nCurrencyFormatDefault)))
				'SetCellBorder(C_S_Gesamt, CELL_BORDER_BOTTOM, 5, HorzLinienArt, COLOR_BLACK)
				SetCellBorder(C_S_Gesamt, CELL_BORDER_TOP,    1, HorzLinienArt, COLOR_BLACK)
				DrawCell(C_S_Gesamt, true)
				ClearRow(C_S_Gesamt, "")

	END IF

		'/////////////////////////////////////////////////////////////
		'---------------------Ausgabe der Steuern--------------------
	Dim Summe_Net as numeric = 0
	Dim nSumme_Mwst  as numeric = 0
	Dim Summe_Ges as numeric = 0

	Dim UST1 As Numeric = 0
	Dim UST2 As Numeric = 0
	Dim UST3 As Numeric = 0
	Dim UST4 As Numeric = 0
	Dim UST5 As Numeric = 0

	Dim UstNeben1 as Numeric = 0
	Dim UstNeben2 as Numeric = 0
	Dim UstNeben3 as Numeric = 0
	Dim UstNeben4 as Numeric = 0
	Dim UstNeben5 as Numeric = 0

	IF IS(LAY_TAB_MIT_STEUER) then

		SetHeaderCell(NULL)

		nBreite = nBreiteSpalte_1 + nBreiteSpalte_2 + nBreiteSpalte_3 + nBreiteSpalte_4 + nBreiteSpalte_5 + nBreiteSpalte_6 + nBreiteSpalte_6a + nBreiteSpalte_7

		C_S_SteuerBruttoText_1 = GetFormatCell(nBreite, 0, C_S_SteuerBruttoText, C_C_S_SPALTE)
		SetCellStandard(C_S_SteuerBruttoText_1, SchriftArtStandard, CELL_TEXT_LEFT, -1)
		SetCellBorder(C_S_SteuerBruttoText_1, CELL_BORDER_LEFT + CELL_BORDER_RIGHT, 0, VertLinienArt, COLOR_BLACK)
		nSumme = 0
		n = 0
		nPosition = 0
		If (Getnumeric("R", 59) <> 0) Or (GetNumeric("R", 83) <> 0) Or (GetNumeric("R", 103) <> 0) Or (GetNumeric("R", 39) <> 0) Then
			Steuern = True
			n = ZaehleSteuersaetzeBrutto()		'Zählen der einzelnen Steuersätze und Beträge
			n = n + 1	' einen Dazu, zur Korrektur
			nPosition = GetAreaLength() - GetPosY() - n * GetCellHeight(C_Zeile_s)
		End If

		UST1 = GetNumeric("R", 33)
		UST2 = GetNumeric("R", 34)
		UST3 = GetNumeric("R", 35)
		UST4 = GetNumeric("R", 36)
		UST5 = GetNumeric("R", 37)

		UstNeben1 = GetNumeric("R", 78)
		UstNeben2 = GetNumeric("R", 79)
		UstNeben3 = GetNumeric("R", 80)
		UstNeben4 = GetNumeric("R", 81)
		UstNeben5 = GetNumeric("R", 82)

		Summe_Ges = GetNumeric("R", 24)
		nSumme_Mwst = UST1 + UST2 + UST3 + UST4+ UST5 + UstNeben1 + UstNeben2 + UstNeben3 + UstNeben4 + UstNeben5
		Summe_Net = Summe_Ges - nSumme_Mwst

		' Steuerausgabe nur wenn, 2 Teilsummen, oder zwei Steuersätze vorhanden sind
		If (GetNumeric(AUFTR_BRUT_TEILSUM_2) <> 0)  Or (GetNumeric(AUFTR_NEBENL_UST_SATZ_1) <> 0 )
			Or (GetNumeric(AUFTR_NEBENL_BRUT_1) <> 0 )  Or (GetNumeric(AUFTR_UST_SATZ_SUM_2) <> 0 ) Then

			strTemp = "\nDer " + sTextGesamtbetrag + " setzt sich wie nachfolgend zusammen: "

			SetCellText(C_S_SteuerBruttoText_1, strTemp + "\n")

			DrawCell(C_S_SteuerBruttoText_1, True)

			'Ausgabe der einzelnen Umsatzsteuernsteuer mit Satz und Nettobeträge
				i=0
				nNetTeilsum = 53    'Bruttosumme - da inkl.
				nBrutTeilsum = 58
				nUstsum  = 33
				nUstsatz = 38

				While i < nAnzahlSt do
					If bDruckeSteuerImmer Or (GetNumeric("R", nNetTeilsum) <> 0) Then
						If (GetNumeric("R", nUstsatz) <> 0) Or Is(AUFTR_HAT_NULLSTEUER) Then
							SteuernAusgabeBrutto(nUstsatz, nBrutTeilsum, nUstsum, nNetTeilsum, nBreite, GetCellWidth(C_H_Spalte_7), SchriftArtStandard, PEN_NULL, nSumme)
						Else
							SteuerfreiBrutto(nBrutTeilsum, nBreite, GetCellWidth(C_H_Spalte_7), SchriftArtStandard, PEN_NULL)
						End If
					End If
					i=i+1
					nNetTeilsum = nNetTeilsum+1
					nBrutTeilsum = nBrutTeilsum+1
					nUstsum  = nUstsum+1
					nUstsatz = nUstsatz+1
				End While

				' Ausgabe Steuern auf Nebenleistungen
				i=0
				nNetTeilsum = 98  'Bruttosumme - da inkl.
				nBrutTeilsum = 103
				nUstsum  = 78
				nUstsatz = 83

				While i < nAnzahlStNeben do
					If bDruckeSteuerImmer Or (GetNumeric("R", nNetTeilsum) <> 0) Then
						If (GetNumeric("R", nUstsatz) <> 0) Or Is(AUFTR_HAT_NULLSTEUER) Then
							SteuernAusgabeBrutto(nUstsatz, nBrutTeilsum, nUstsum, nNetTeilsum, nBreite, GetCellWidth(C_H_Spalte_7), SchriftArtStandard, PEN_NULL, nSumme)
						Else
							SteuerfreiBrutto(nBrutTeilsum, nBreite, GetCellWidth(C_H_Spalte_7), SchriftArtStandard, PEN_NULL)
						End If
					End If
					i = i + 1
					nNetTeilsum = nNetTeilsum + 1
					nBrutTeilsum = nBrutTeilsum + 1
					nUstsum  = nUstsum + 1
					nUstsatz = nUstsatz + 1
				End While

			SetHeaderCell(NULL)
			SetFooterCell(NULL)

			If is("X", 17) then
				DrawCell(C_S_Bottom, true)
			End If

			Else			'Wenn nur einen Umsatzsteuersatz gibt
				n = GetNumeric(AUFTR_UST_GESBETRAG)
				if (n <> 0) Or (GetNumeric(AUFTR_UST_SATZ_SUM_1) <> 0) Or (Is(AUFTR_HAT_NULLSTEUER)) then
					SetCellText(C_S_SteuerBruttoText_1, "\nDer " + sTextGesamtbetrag+ " setzt sich aus Netto " + HCS(FormatCurrency(CC_LOC, nCurrencyFormatDefault, Summe_Net)) + " zuzüglich " + FormatNumeric("%.2f", GetNumeric(AUFTR_UST_SATZ_SUM_1)) + "% " + sUstText + " = " + HCS(FormatCurrency(CC_LOC, nCurrencyFormatDefault, n)) + " zusammen.")
					SetCellBorder(C_S_SteuerBruttoText_1, CELL_BORDER_Bottom, 0, HORZLinienArt, COLOR_BLACK)
					DrawCell(C_S_SteuerBruttoText_1, True)
				else
					SetCellText(C_S_SteuerBruttoText_1, "\nDer " + sTextGesamtbetrag + " ist steuerfrei" +  sGrundstfrei  + ".")
					SetCellBorder(C_S_SteuerBruttoText_1, CELL_BORDER_Bottom, 0, HORZLinienArt, COLOR_BLACK)
					if b13Umsatzsteuer = false then
						DrawCell(C_S_SteuerBruttoText_1, True)
					end if
				end if
			end if
			DrawCell(C_S_Bottom, true)

	end if

		if (b13Umsatzsteuer = TRUE) then
			if IS("K", 79)= false then
				SetCellText(C_S_SteuerBruttoText_1, "\n" + strText13bUstG)
			else
				SetCellText(C_S_SteuerBruttoText_1, "\n" + strText13bUstGSo)
			end if
			SetCellBorder(C_S_SteuerBruttoText_1, CELL_BORDER_Bottom, 0, HORZLinienArt, COLOR_BLACK)
			DrawCell(C_S_SteuerBruttoText_1, True)
		end if
		LeereZellen()



	'///////////////////////////////////////////////////////////////
	'---------------------Formatierung der Gesamtsummenzeile------
	'BRUTTO
	Dim dfABS_RE_GESAMT as numeric
	Dim dftABS_RE_UST as numeric
	Dim dftABS_NETTO as numeric

	' Ausgabe der Steuern, nur wenn ausgewählt
	IF IS(LAY_TAB_MIT_STEUER) then
		'Seitenumbruch, wenn es für die folgenden Zeilen (Abschlagszahlungne) nicht mehr auf dieser Seite reicht
		if (IsMitAbschlag()) then
			nPosition = GetAreaLength() - GetPosY() - 8 * GetCellHeight(C_Zeile_s)
		else
			nPosition = GetAreaLength() - GetPosY() - GetCellHeight(C_Zeile_s)
		end if 	
		
		If nPosition < 0  Then
			PageBreak()
		End If

		nBreite = GetCellWidth(C_H_Spalte_1) + GetCellWidth(C_H_Spalte_2) + GetCellWidth(C_H_Spalte_3) + GetCellWidth(C_H_Spalte_4) + GetCellWidth(C_H_Spalte_5) + GetCellWidth(C_H_Spalte_6) + GetCellWidth(C_H_Spalte_6a) - (2*(GetCellWidth(C_H_Spalte_7)))
		C_S_Text = GetFormatCell(nBreite , 0, C_S_Abschlag, C_C_S_SPALTE)
		C_S_Text_2 = GetFormatCell(GetCellWidth(C_H_Spalte_7) + 50, 0, C_S_Abschlag, C_C_S_SPALTE)
		C_S_Text_3 = GetFormatCell(GetCellWidth(C_H_Spalte_7) - 50, 0, C_S_Abschlag, C_C_S_SPALTE)
		C_S_Text_4 = GetFormatCell(GetCellWidth(C_H_Spalte_7), 0, C_S_Abschlag, C_C_S_SPALTE)

		C_S_Forder_1 = GetFormatCell(nBreite	, 0, C_S_Forder, C_C_S_SPALTE)
		C_S_Forder_2 = GetFormatCell(GetCellWidth(C_H_Spalte_7) + 50, 0, C_S_Forder, C_C_S_SPALTE)
		C_S_Forder_3 = GetFormatCell(GetCellWidth(C_H_Spalte_7) - 50, 0, C_S_Forder, C_C_S_SPALTE)
		C_S_Forder_4 = GetFormatCell(GetCellWidth(C_H_Spalte_7), 0, C_S_Forder, C_C_S_SPALTE)

		SetRowStandard(C_S_Forder, SchriftArtStandard, CELL_TEXT_LEFT, -1)
		SetCellStandard(C_S_Forder_1, SchriftArtGesamtbetrag, CELL_TEXT_LEFT, -1)
		SetCellStandard(C_S_Forder_4, SchriftArtGesamtbetrag, CELL_TEXT_RIGHT, -1)
		SetRowStandard(C_S_Abschlag, SchriftArtStandard, CELL_TEXT_LEFT, -1)

		' beim Abschlag Forderungen drucken
		if (IsMitAbschlag()) then
			SetCellStandard(C_S_Text, SchriftArtGesamtbetrag, CELL_TEXT_LEFT, -1)
			SetCellStandard(C_S_Text_2, SchriftArtGesamtbetrag, CELL_TEXT_RIGHT, -1)
			SetCellStandard(C_S_Text_3, SchriftArtGesamtbetrag, CELL_TEXT_RIGHT, -1)
			SetCellStandard(C_S_Text_4, SchriftArtGesamtbetrag, CELL_TEXT_RIGHT, -1)

			SetCellStandard(C_S_Forder_1, SchriftArtStandard, CELL_TEXT_LEFT, -1)
			SetCellStandard(C_S_Forder_2, SchriftArtStandard, CELL_TEXT_RIGHT, -1)
			SetCellStandard(C_S_Forder_3, SchriftArtStandard, CELL_TEXT_RIGHT, -1)
			SetCellStandard(C_S_Forder_4, SchriftArtStandard, CELL_TEXT_RIGHT, -1)

			SetCellBorder(C_S_Abschlag, CELL_BORDER_TOP, 0,HorzLinienArt, nFarbe)
			SetCellBorder(C_S_Abschlag, CELL_BORDER_LEFT + CELL_BORDER_RIGHT, 1, VertLinienArt, nFarbe)
			SetCellBorder(C_S_Forder, CELL_BORDER_LEFT + CELL_BORDER_RIGHT, 1, VertLinienArt, nFarbe)

			'Ausgabe des Abschlags

			SetCellText(C_S_Text, "\nAbzgl. bereits erhalten:")
			SetCellText(C_S_Text_2, "\nNetto")
			SetCellText(C_S_Text_3, "\n" + sUstText)
			SetCellText(C_S_Text_4, "\nBrutto")
			DrawCell(C_S_Abschlag, true)
				
			Result_G = FirstRecord("G")
			While Result_G do
				bHatAbschlag = TRUE
				dfABS_RE_GESAMT  = GetNumeric(ABS_RE_GESAMT)', CC_ORG, nCurrencySymbol)
				dftABS_RE_UST = GetNumeric(ABS_RE_UST)', CC_ORG, CURRENCY_SYMBOL_HIDE)
				dftABS_NETTO = dfABS_RE_GESAMT - dftABS_RE_UST
				SetFormatNumericOptions(FN_CUSTOM, "", "")
				SetCellText(C_S_Forder_1, "Abschlagsre. Nr. " + FormatNumeric("%.0f", GetNumeric(ABS_RE_NR)) + " vom " + FormatDate("%d.%m.%Y", GetDate(ABS_RE_DATUM)) + " (" + sUstText + " "  + FormatNumeric("%.2f", GetNumeric(ABS_RE_SSATZ))+ " %)")
				SetFormatNumericOptions(FN_CUSTOM, ",", ".")
				SetCellText(C_S_Forder_2, FormatNumeric("%.2f", dftABS_NETTO ) + strWaehrungsSymbol)
				SetCellText(C_S_Forder_3, HCS(GetCurrencyFormat(ABS_RE_UST, CC_ORG, nCurrencyFormatDefault)))
				SetCellText(C_S_Forder_4, HCS(GetCurrencyFormat(ABS_RE_GESAMT, CC_ORG, nCurrencyFormatDefault)))

				DrawCell(C_S_Forder, true)
				SetFormatNumericOptions(FN_CUSTOM, "", "")

				ClearRow(C_S_Forder, "")
				Result_G = NextRecord("G")
			End While
			ClearRow(C_S_Forder, "")
			if bHatAbschlag = False then
				nTemp1x = GetNumeric(AUFTR_ABSCHLAG_ERHALTEN)
				strTemp2x= FormatNumeric("%.2f", GetNumeric(AUFTR_ABSCHLAG_NETTO))
				nTemp2x = StringToNumeric(strTemp2x)
				strUstAbschlag = nTemp1x - nTemp2x
				SetFormatNumericOptions(FN_CUSTOM, ",", ".")
				SetCellText(C_S_Forder_1, GetTextAbschlagsbetrag())
				SetCellText(C_S_Forder_2, FormatNumeric("%.2f", GetNumeric(AUFTR_ABSCHLAG_NETTO)) + strWaehrungsSymbol)
				SetFormatNumericOptions(FN_CUSTOM, ",", ".")
				SetCellText(C_S_Forder_3, FormatNumeric("%.2f", strUstAbschlag)+ strWaehrungsSymbol)
				SetCellText(C_S_Forder_4, HCS(GetCurrencyFormat(AUFTR_ABSCHLAG_ERHALTEN, CC_ORG, nCurrencyFormatDefault)))

				DrawCell(C_S_Forder, true)
				SetFormatNumericOptions(FN_CUSTOM, "", "")
			end if
		end if
		ClearRow(C_S_Forder, "")

		'///////////////////////////////////////////////////////////////
		'---------------------Formatierung der Gesamtsummenzeile------
		SetCellStandard(C_S_Forder_1, SchriftArtGesamtbetrag, CELL_TEXT_LEFT, -1)
		SetCellStandard(C_S_Forder_4, SchriftArtGesamtbetrag, CELL_TEXT_RIGHT, -1)


		' die Zellen für den Gesamtbetrag neu formatieren
		SetCellBorder(C_S_Forder, CELL_BORDER_BOTTOM, 5, HorzLinienArt, COLOR_BLACK)
		SetCellBorder(C_S_Forder, CELL_BORDER_TOP,    1, HorzLinienArt, COLOR_BLACK)
		if VertLinienArt <> PEN_NULL then
			SetCellBorder(C_S_Forder, CELL_BORDER_LEFT + CELL_BORDER_RIGHT, 0, PEN_SOLID, COLOR_BLACK)
		else
			SetCellBorder(C_S_Forder, CELL_BORDER_LEFT + CELL_BORDER_RIGHT, 0, VertLinienArt, COLOR_BLACK)
		end if
		SetCellBorder(C_S_Forder_4, CELL_BORDER_LEFT, 0, VertLinienArt, COLOR_BLACK)

			nTemp1 = GetNumeric(AUFTR_UST_GESBETRAG)
			nTemp2 = GetNumeric(AUFTR_ABSCHLAG_STEUER)
			strUstForderung = nTemp1 - nTemp2

		' beim Abschlag Forderungen drucken
		if (IsMitAbschlag())then
			SetCellBorder(C_S_Forder_1, CELL_BORDER_BOTTOM, 0, PEN_NULL, COLOR_BLACK)
			SetCellBorder(C_S_Forder, CELL_BORDER_BOTTOM, 0, PEN_NULL, COLOR_BLACK)
			SetCellText(C_S_Forder_1, "Forderungsbetrag")
			SetFormatNumericOptions(FN_CUSTOM, ",", ".")
			SetCellText(C_S_Forder_4, HCS(GetCurrencyFormat(AUFTR_ABSCHLAG_FORDER, CC_ORG, nCurrencyFormatDefault)))
			DrawCell(C_S_Forder, true)
			ClearRow(C_S_Forder, "")
			SetCellBorder(C_S_Forder, CELL_BORDER_TOP, 0, PEN_NULL, COLOR_BLACK)
			SetCellBorder(C_S_Forder_1, CELL_BORDER_TOP, 0, PEN_NULL, COLOR_BLACK)
			SetCellBorder(C_S_Forder, CELL_BORDER_BOTTOM, 5, HorzLinienArt, COLOR_BLACK)
			SetCellStandard(C_S_Forder_1, SchriftArtStandard, CELL_TEXT_LEFT, -1)
			If (Getnumeric(ABS_RE_UST) <> 0) OR (Getnumeric(AUFTR_ABSCHLAG_STEUER) <> 0) OR (Getnumeric(AUFTR_UST_GESBETRAG) <> 0) OR Is(AUFTR_HAT_NULLSTEUER) then
				SetCellText(C_S_Forder_1, "Im Forderungsbetrag sind " + HCS(FormatCurrency(CC_LOC, nCurrencyFormatDefault, strUstForderung)) + " " + sUstText + " enthalten.")
			else
				if b13Umsatzsteuer = false then
					SetCellText(C_S_Forder_1, "Der Forderungsbetrag ist steuerfrei"  + sGrundstfrei  + ".")
				end if
			end if
			DrawCell(C_S_Forder, true)
			ClearRow(C_S_Forder, "")
		end if
	end if
	SetFormatNumericOptions(FN_CUSTOM, "", "")
	LeereZellen()

	LF
	SelectFont(SchriftArtStandard)
	SetTabs("L100")

End Function


'////////////////////////////////////////////////////////////////////////////////////
'Funktion - FuelleTabelleLieferschein()
'Füllen der Tabelle für einen Auftrag, wenn Lieferschein
'/////////////////////////////////////////////////////////////
Function FuelleTabelleLieferschein()
	'DIM strTemp as string = ""
	DIM nUst as numeric = 0
	Dim nCount as Numeric = 0
	Dim ArtikelLine as Numeric = 0

	DrawCell(C_H_Zeile, True)								'SpaltenÜberschriften
	SetHeaderCell(C_H_Head)
	SetFooterCell(C_S_Zeile)

	nCurrencySymbol = CURRENCY_SYMBOL_HIDE
	' Ausgabe mit CURRENCY_SYMBOL_RIGHT hat unter '95 und '98 ein Problem, deshalb selbst formatieren
	strGewicht = ""
	if bMitWaehrung then
		strWaehrungsSymbol = " " + GetCurrencySymbol(AUFTR_RG_BETRAG, bWaehrungAlsText)
		strGewicht = " kg"
	end if
	Dim Result_Z as Bool

	nSumme = 0
	nAnzahlSt = 0
	nAnzahlStNeben = 0

	Result_P= FirstRecord(AUFTRPOSITION)				'Erster Rechungsposten
	While Result_P Do
		nSteuerSatz = GetNumeric(POS_UST_SATZ)

		if IS(POS_IST_TEXTPOS) then
			SetCellImage(C_Spalte_1, "", IMAGE_Bottom, 20 )
			SetCellImage(C_Spalte_4, "", IMAGE_Bottom, 20 )
			SetCellImage(C_Spalte_6, "", IMAGE_Bottom, 20 )
		end if

		' Nebenleistungen haben auf dem Lieferschein nichts zu suchen
		If is (POS_IST_NEBENL) = FALSE  Then

			if nAnzahlSt = 0 then
				nAnzahlSt = 1 'erhöhe Anzahl Steuersätze wg. nicht steuerbaren
			end if

			'manueller Artikel, Stammartikel
			IF IS( POS_IST_STAMMART ) OR IS( POS_IST_MANUELLE_POS ) OR IS(POS_IST_DATANORM) OR IS(POS_IST_LOHNLEISTUNG) Then
				if IS(POS_IST_KOMMENTAR) then
					SelectCellFont(C_Spalte_1, SchriftArtKommentar)
					SetCellText(C_Spalte_1,"")
				else
					SetCellText(C_Spalte_1, FormatNumeric("%.0f", GetNumeric(POS_NR)))				'Position
				end if
				if IS( POS_IST_STAMMART ) OR is (POS_IST_ALTERNATIV) then
					if  (Get("A", 52) <> "") AND bmitBildAnhang = true then
						bBildExist = true
					end if
					if bmitBildSpalte and nBildSpalteAuswahl = 0 then
						include "bildanzeigen.lsf"
					end if
				else
					SetCellImage(C_Spalte_1, "", IMAGE_Bottom, 20 )
				end if
				if IS(POS_IST_KOMMENTAR) then
					SetCellText(C_Spalte_2,"")
				else
					SetCellText(C_Spalte_2, FormatNumeric(FormatMenge, GetNumeric(POS_MENGE)))		'Menge
				end if
				if IS(POS_IST_KOMMENTAR) then
					SetCellText(C_Spalte_3,"")
				else
					SetCellText(C_Spalte_3, Get(POS_EINHEIT))													'Einheit
				end if
				' Artikelnummer nur, wenn Spalte sichtbar
				IF (nLieferBreiteSpalte_3 > 0) AND (IS( POS_IST_STAMMART ) OR (IS(POS_IST_DATANORM)) OR (IS(POS_IST_LOHNLEISTUNG)) ) then
					SetCellText(C_Spalte_4, Get(POS_ART_NR))												'Artikelnummer
					if IS( POS_IST_STAMMART ) OR is (POS_IST_ALTERNATIV) then
						if  bmitBildSpalte = True and nBildSpalteAuswahl = 1 then
							include "bildanzeigen.lsf"
						end if
					else
						SetCellImage(C_Spalte_4, "", IMAGE_Bottom, 20 )
					end if
				ELSE
					SetCellText(C_Spalte_4, "")
					SetCellImage(C_Spalte_4, "", IMAGE_Bottom, 20 )
				END IF
				If GetNumeric(POS_GEWICHT_GES) <> 0 Then												'Es Gibt einen Kiloeintrag
					If nLieferBreiteSpalte_4 <> 0 Then													'nur Gesamtgewicht, wenn auch das Einzelgewicht angezeigt wird
						nGewicht = GetNumeric(POS_GEWICHT_GES)											'Kilo
						SetCellText(C_Spalte_5, Formatnumeric("%.3f", nGewicht) + strGewicht)'Eintrag in die Tabelle
						nGewichtSumme = nGewichtSumme + nGewicht										'Aufsummieren für den Übertrag, wenn keine Alternativpos
					END IF
				END IF
			END IF

			' alle Auftragsarten außer Zwischensumme
			IF IS( POS_IST_ZWSUMME ) = false then
				if IS (POS_IST_KOMMENTAR) then
					SelectCellFont(C_Spalte_6, SchriftArtKommentar)
				end if
				PrintArtikelText(C_Spalte_6)															'Artikelbezeichnungen
				if IS( POS_IST_STAMMART ) OR is (POS_IST_ALTERNATIV) then
					if bmitBildSpalte = true and nBildSpalteAuswahl = 2 then
						include "bildanzeigen.lsf"
					end if
				else
					SetCellImage(C_Spalte_6, "", IMAGE_Bottom, 20 )
				end if

			if bStuecklistenArtikelAnzeigen then
				If is (ART_MIT_STUECKLISTE) = true AND ((IS( POS_IST_STAMMART ) = true) AND IS( POS_IST_ALTERNATIV ) = true)  then
					nPosition = GetAreaLength() - GetPosY() - GetCellHeight(C_Zeile_s)  - GetCellHeight(C_Spalte_5) - (nCount * GetCellHeight(C_Zeile_s))
					if nPosition < 0 then
						DrawCell(C_S_Zeile, True)
						Pagebreak()
					end if
				end if
			end if

				if is(AUFTR_IST_PREISANGABEN_BRUT) then
					' Währung nur anzeigen, wenn Wert nicht 0
					if (is (POS_IST_SEITENUMBRUCH) = true) OR (is (POS_IST_TEXTPOS) = true) OR (is (POS_IST_KOMMENTAR) = true) then
						nCurrencyFormat = CURRENCY_SYMBOL_HIDE
					else
						nCurrencyFormat = nCurrencyFormatDefault
					end if
					nSumme = nSumme + GetNumeric(POS_GES_BRUTPREIS)
					strTemp = HCS(GetCurrencyFormatValue(POS_GES_BRUTPREIS, CC_ORG, nCurrencyFormat, nBetrag))
				else
					' Nettopreise (ohne Mwst)
					' Währung nur anzeigen, wenn Wert nicht 0
					if (is (POS_IST_SEITENUMBRUCH) = true) OR (is (POS_IST_TEXTPOS) = true) OR (is (POS_IST_KOMMENTAR) = true) then
						nCurrencyFormat = CURRENCY_SYMBOL_HIDE
					else
						nCurrencyFormat = nCurrencyFormatDefault
					end if
					nSumme = nSumme + GetNumeric(POS_GES_NETPREIS)
					strTemp = HCS(GetCurrencyFormatValue(POS_GES_NETPREIS, CC_ORG, nCurrencyFormat, nBetrag))
				end if
				SetCurrencyNKStellen(GetNumeric(FA_NACHKOMMAST_EK))							'setzen der Nachkommastellen wie in den Optionen
				SetCelltext(C_Spalte_7, HCS(GetCurrencyFormat(POS_EINZELPREIS, CC_ORG, nCurrencyFormat)))	'Ausgabe des Einzelpreises
				SetCurrencyNKStellen( 2 )																				'setzen der Nachkommastellen auf 2 für rabatt und Gesamtpreis

				SetCelltext(C_Spalte_8, strTemp)		'Ausgabe Gesamtpreis
				if IS(POS_IST_KOMMENTAR) = false then

					If is (POS_IST_SEITENUMBRUCH) = true Then
						SetCellImage(C_Spalte_1, "", IMAGE_Bottom, 20 )
						SetCellImage(C_Spalte_4, "", IMAGE_Bottom, 20 )
						SetCellImage(C_Spalte_5, "", IMAGE_Bottom, 20 )
						SetCellImage(C_Spalte_6, "", IMAGE_Bottom, 20 )
						'DrawCell(C_Zeile, True)	'keine Leerzeile!
					else
						DrawCell(C_Zeile, True)
					end if														'Ausgabe der Zeile

				else
					if IS(AUFTR_MIT_KOMMENTAR) = true then
						SetCellImage(C_Spalte_1, "", IMAGE_Bottom, 20 )
						SetCellImage(C_Spalte_4, "", IMAGE_Bottom, 20 )
						SetCellImage(C_Spalte_5, "", IMAGE_Bottom, 20 )
						SetCellImage(C_Spalte_6, "", IMAGE_Bottom, 20 )
						DrawCell(C_Zeile, True)
					end if
				end if

				If is (POS_IST_SEITENUMBRUCH)  Then		'erzwungener Seitenumbruch...
					'Spalten löschen wg. 0,00-Problem
					'SetCellText(C_S_Spalte_2, "")		'Setzen der Zwischensumme
					'SetCellText(C_HU_Spalte_2, "")		'Setzen des Übertrages
					DrawCell(C_S_Zeile, True)
					PageBreak()
				end if

				LeereZellen()								'Leeren der Zellen, setzen der Schraffur

				if bStuecklistenArtikelAnzeigen then

					IF IS( POS_IST_STAMMART ) Then

						Result_Z = FirstRecord("Z")

							if is(POS_ZUSAMMENGESETZT) = True Then

								SetCellFont(C_Spalte_6s, "Arial", 8, FONT_BOLD, COLOR_BLACK)
								SetCellText(C_Spalte_1s, "")
								SetCellText(C_Spalte_2s, "")
								SetCellText(C_Spalte_3s, "")
								SetCellText(C_Spalte_4s, "")
								SetCellText(C_Spalte_5s, "")
								SetCellText(C_Spalte_6s, "bestehend aus:")
								SetCellText(C_Spalte_7s, "")
								SetCellText(C_Spalte_8s, "")

								DrawCell(C_Zeile_s, True)

								LeereZellen()
								nCount = 3
								While Result_Z do

									' Menge, Einheit, Artikelnummer, Bezeichnung
									SetCellText(C_Spalte_1s, "")
									SetCellText(C_Spalte_2s, FormatNumeric(FormatMenge, GetNumeric(STL_POS_MENGE)))
									SetCellText(C_Spalte_3s, Get(STL_POS_EINHEIT))
									SetCellText(C_Spalte_4s, Get(STL_POS_NR))
									if GetNumeric(STL_POS_GEWICHT) <> 0 Then
										SetCellText(C_Spalte_5S, "( " + Formatnumeric("%.3f", GetNumeric(STL_POS_GEWICHT)) + " )")
									else
										SetCellText(C_Spalte_5s, "")
									end if

									SetCellText(C_Spalte_6s, Get(STL_POS_BEZ))
									SetCellText(C_Spalte_7s, "")
									SetCellText(C_Spalte_8s, "")
									SetCellFont(C_Spalte_1s, "Arial", 8, FONT_NORMAL, COLOR_BLACK)
									SetCellFont(C_Spalte_2s, "Arial", 8, FONT_NORMAL, COLOR_BLACK)
									SetCellFont(C_Spalte_3s, "Arial", 8, FONT_NORMAL, COLOR_BLACK)
									SetCellFont(C_Spalte_4s, "Arial", 8, FONT_NORMAL, COLOR_BLACK)
									SetCellFont(C_Spalte_5s, "Arial", 8, FONT_NORMAL, COLOR_BLACK)
									SetCellFont(C_Spalte_6s, "Arial", 8, FONT_NORMAL, COLOR_BLACK)

									DrawCell(C_Zeile_s, True)
									nCount = nCount + 1
									Result_Z = NextRecord("Z")

								End While
								end if
								LeereZellen()

						end if
				end if
				' Abfrage, ob die Preise Brutto-oder Nettopreise sind
				nUst = GetNumeric(POS_UST_PROZ)

			END IF
		END IF
		if bMitSchraffur = true  then
			bMitSchraffur = false
		else
			bMitSchraffur = true
		end if
		Result_P= NextRecord(AUFTRPOSITION)		'Nächste Position
	End While
	'Ende der Positionen

	if (Nebenleistung = True) and (nAnzahlStNeben=0) then
		nAnzahlStNeben = 1
	end if

	dim bGesamtGedruckt as bool = false

	' Ausgabe des Gesamtbetrags, wenn Steuer und Gesamtbetrag über den Assi gewählt
	IF IS(LAY_TAB_MIT_STEUER) THEN
		' wenn Lieferschein mit Preisen
		IF nLieferTabelle >= TABELLE_6 then
			' die Zellen für den Gesamtbetrag neu formatieren
			SetCellBorder(C_S_Zeile, CELL_BORDER_TOP + CELL_BORDER_BOTTOM, 0, HorzLinienArt, COLOR_BLACK)
			if VertLinienArt <> PEN_NULL then
				SetCellBorder(C_S_Zeile, CELL_BORDER_LEFT + CELL_BORDER_RIGHT, 0, PEN_SOLID, COLOR_BLACK)
			else
				SetCellBorder(C_S_Zeile, CELL_BORDER_LEFT + CELL_BORDER_RIGHT, 0, VertLinienArt, COLOR_BLACK)
			end if
			' die Werte der Zellen setzen
			SetCellText(C_S_Spalte_1, sTextGesamtbetrag)

			if is(AUFTR_IST_PREISANGABEN_BRUT) then
				SetCellText(C_S_Spalte_2, HCS(GetCurrencyFormat(AUFTR_GESAMT_HAUPTL_BRUT, CC_ORG, nCurrencyFormatDefault)))
			else
				SetCellText(C_S_Spalte_2, HCS(GetCurrencyFormat(AUFTR_GESAMT_HAUPTL_NET, CC_ORG, nCurrencyFormatDefault)))
			end if
			DrawCell(C_S_Zeile, True)

			LF
			If (is (AUFTR_KEINE_UST) = FALSE) Or Is(AUFTR_HAT_NULLSTEUER) Then
				if is(AUFTR_IST_PREISANGABEN_BRUT) then
					TL("Die Preise verstehen sich inkl. " + sUstText)
				else
					TL("Die Preise verstehen sich zzgl. " + sUstText)
				end if
			else
				TL("Die Preise sind steuerfrei" + sGrundstfrei + "." )
			end if
			bGesamtGedruckt = true
		END IF

	END IF

	' wenn kein Gesamtbetrag gedruckt wurde, dann brauchen wir trotzdem den abschließenden Strich für die Tabelle
	if bGesamtGedruckt = false then
		SetCellText(C_S_Spalte_1, "" )
		SetCellText(C_S_Spalte_2, "" )
		SetCellBorder(C_S_Zeile, CELL_BORDER_BOTTOM + CELL_BORDER_LEFT + CELL_BORDER_RIGHT, 0, PEN_NULL, COLOR_TRANSPARENT)
		SetCellBorder(C_S_Zeile, CELL_BORDER_TOP, 0, HorzLinienArt, COLOR_BLACK)
		DrawCell(C_S_Zeile, True)
	end if

	'Ausgabe des Gesamtgewichts, auf der letzten Seiten
	If nGewichtSumme <> 0 then																'Wenn es Kilos auf dem Lieferschein gibt
		LF
		LF
		TL("Das Gesamtgewicht beträgt " + FormatNumeric( "%.3f", nGewichtSumme ) + " kg.")
	end if
End Function

Function Anhang_PrintFooter()
	TL("")
End Function

Function Anhang_PrintHeader()
	TL("")
end function

Function Anhang_Seitenwechsel()

	SetHeaderMargin(nRandLinks, nRandOben, nRandRechts, 200)
	SetFooterMargin(nRandLinks, 200, nRandRechts, 80)
	SetBodyMargin(nRandLinks, nRandOben, nRandRechts, nRandUnten)

	SetEventHandler(EVENT_PRINT_HEADER, Anhang_PrintHeader)
	SetEventHandler(EVENT_PRINT_FOOTER, Anhang_PrintFooter)

end function
'///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
'----------------------------------------------Erzeugen des gesamten Formulars -----------------

'SetHeaderMargin(nRandLinks, nRandOben, nRandRechts, nKopfzeileHoehe)
' Header so Hoch wie der Body, damit in der Funktion Kopfzeile auf das ganze Blatt gezeichnet werden kann
SetHeaderMargin(nRandLinks, nRandOben , nRandRechts, nSeitenHoehe-nRandUnten - nFusszeileHoehe)
SetFooterMargin(nRandLinks, nFusszeileHoehe + 10, nRandRechts, nFusszeileHoehe)
SetBodyMargin(nRandLinks, nRandOben , nRandRechts, nRandUnten + nFusszeileHoehe + 10)

dim bPageBreak as bool = FALSE
dim nTemp as numeric = 0

Result_R = FirstRecord(AUFTRAG)				'Erste Rechnung oder sonstiges

' für die erste Seite werden die Funktionen des Seitenwechsels bereits hier aufgerufen
if Result_R then
	' hier den Rumpfbereich wieder an den oberen Rand des Formulars ziehen, damit die nachfolgenden Felder
	' nicht tiefer dargestellt werden
	SetBodyMargin(nRandLinks, nRandOben, nRandRechts, nRandUnten + nFusszeileHoehe + 10)
	nAuftragPage = 0
	Seitenwechsel()
end if

While Result_R Do

	if bMitWaehrung then
		strWaehrungsSymbol = " " + GetCurrencySymbol(AUFTR_RG_BETRAG, bWaehrungAlsText)
	else
		strWaehrungsSymbol = ""
	end if

	Nebenleistung = False
	Steuern = False
	nGewichtSumme = 0
	nGewicht = 0

	If (is(KD_UMSAETZE_NICHT_STEUERBAR) = False) And (Get(AUFTR_KD_NR)<>"") Then
		nAnzahlSt = 0
		nAnzahlStNeben = 0
		if Get(KD_GRUND_STEUERBEF) <> "" then
			sGrundstfrei = " (" + Get(KD_GRUND_STEUERBEF) + ")"
		else
			if is("F", 44) = true then
				sGrundstfrei = " §19 UStG (Kleinunternehmerregelung)"
			else
				If Get(KD_EG_ID_NUMMER) <> "" Then										' wenn KD.Ust-ID vorhanden, dann ausdrucken
					sGrundstfrei = " (Innergemeinschaftliche Lieferung)"
				else
					sGrundstfrei = " (Ausfuhrlieferung)"
				end if
			end if
		end if
	else
		sGrundstfrei = ""
		'Anzahl der Steuersätze ermitteln
		nAnzahlSt = 0
		nAnzahlStNeben = 0
		i = 0
		While i < 5 do
			If (GetNumeric("R", (i+38)) <> 0) or (GetNumeric("R", (i+53)) <> 0) Then
				nAnzahlSt = nAnzahlSt + 1
			end if
			If (GetNumeric("R", (i+83)) <> 0) or (GetNumeric("R", (i+98)) <> 0) Then
				nAnzahlStNeben = nAnzahlStNeben + 1
			end if
			i = i + 1
		end while
	end if
	if IS(AUFTR_UST13b) = true OR (GetNumeric("R", 306) > 0 ) then
		b13Umsatzsteuer = TRUE
	end if

	if bSeiteText1 then
		strText13bUstGSo = strSeiteText1
	else
		strText13bUstGSo = "Bei den vorgenannten Leistungen handelt es sich um sonstige Leistungen EG\nnach §13b UStG. Der Leistungsempfänger schuldet die Umsatzsteuer.\nEs gilt die Steuerschuldnerschaft des Leistungsempfängers (Reverse-Charge)."
	end if

	if bSeiteText2 then
		strText13bUstG = strSeiteText2
	else
		strText13bUstG = "Bei den vorgenannten Leistungen handelt es sich um eine sog. Bauleistung,\nfür die der Übergang der Steuerschuldnerschaft gem. § 13b UStG gilt. \nDie Umsatzsteuer ist somit vom Leistungsempfänger beim Finanzamt anzumelden und abzuführen.\nEs gilt die Steuerschuldnerschaft des Leistungsempfängers."
	end if

	'Aufbau und Füllen des Tabellengerüstes
	If is(AUFTR_IST_LS) Then
		BaueTabelleLieferschein()
		FuelleTabelleLieferschein()
	else											'alle anderen Auftragsarten (Rechnung, Auftragsbestätigung,....)
		' Unterscheidung zwischen Brutto und Netto Auftragstabelle
		'if bIstAuftragBrutto then
		'Unterscheidung zwischen Brutto und Netto Auftragstabelle jetzt direkt über die Brutto/Nettokennung des Aufttrags
		if is(AUFTR_IST_PREISANGABEN_BRUT) then
			BaueTabelleBrutto()
			FuelleTabelleBrutto()
		else
			BaueTabelleNetto()
			FuelleTabelleNetto()
		end if
	end if

	'Alle Felder löschen
	LeereZellen()

	SetFooterCell(NULL)
	SetHeaderCell(NULL)

	SelectFont(SchriftArtStandard)
	RemoveAllTabs()
	SetTabs("L100")

	nSumme = 0

	'Schlußtext drucken
	DruckeSchlussTexte()

	AusgabeGiroCode(IS(AUFTR_GIROCODE_DRUCKEN), Get(AUFTR_GIROCODE_FILEPATH), False )

	bAuftrhatLohnleistung = false
	bAuftrhatgesamtrab = false
	bAuftrLohnUst = false
	b13Umsatzsteuer = FALSE
	nSummeLohnUst = 0
	nLohnUst = 0
	nRabattprozentual = 0
	nRabattabsolut = 0
	nSummeHauptleistung = 0
	nSummeLohnbetragProz = 0
	nSummeRabattLohn = 0
	nSonstKosten = 0
	nLohnbetrag = 0
	nSummeLohnBetrag = 0
	nSummenLohnUstBetrag = 0
	nRabattBetragLL = 0
	nUstLohn = 0
	if bBildExist = true  then
		SetEventHandler(EVENT_START_PAGE, Anhang_Seitenwechsel)
		Pagebreak()
		include "anhangbild.lsf"

	end if
	bBildExist = false
	' nächste Rechnung oder sonstiges
	Result_R = NextRecord(AUFTRAG)
	' wenn neuer Auftrag, dann auf neuer Seite darstellen
	if Result_R  then
		SetHeaderCell(NULL)
		SetFooterCell(NULL)
		' hier den Rumpfbereich wieder an den oberen Rand des Formulars ziehen, damit die nachfolgenden Felder
		' nicht tiefer dargestellt werden
		SetBodyMargin(nRandLinks, nRandOben, nRandRechts, nRandUnten + nFusszeileHoehe + 10)
		' Pagebreak löst Event Fusszeile aus
		' Die Seite darf erst in der Funktion Seitenwechsel zurückgesetzt werden, da ansonsten zu
		' früh zurückgesetzt wird
		fResetPage = true

		SetEventHandler(EVENT_START_PAGE, EventSeitenwechsel)
		Pagebreak()
		DeleteEventHandler(EVENT_PRINT_FOOTER)
		DeleteEventHandler(EVENT_PRINT_HEADER)
		DeleteEVentHandler(EVENT_BREAK_TABLE)
		SetEventHandler(EVENT_PRINT_HEADER, EventKopfZeile)
		SetFooterMargin(nRandLinks, nFusszeileHoehe + 10, nRandRechts, nFusszeileHoehe)
		SetEventHandler(EVENT_PRINT_FOOTER, EventFussZeile)
	end if

End While
Editor is loading...
Leave a Comment