Attribute VB_Name = "druck"
Public firstline As Boolean


Sub druck_evko()

FMVorschau.dr.FontSize = 14
FMVorschau.dr.FontUnderline = True
FMVorschau.dr.Text = "BAUMAT Eigenverbrauchsliste                                                                                        " + Format(Date, "dd.mm.yyyy") + "   Seite: " + Format(FMVorschau.dr.PageCount)
FMVorschau.dr.FontUnderline = False
FMVorschau.dr.FontSize = 12
FMVorschau.dr.Paragraph = ""
FMVorschau.dr.Paragraph = ""
sel = ""
If (FMDruck.SDATVON.DateValue > 0) Or (FMDruck.SDATBIS.DateValue > 0) Then
   sel = "  Von Datum " + Format(FMDruck.SDATVON.DateValue, "dd.mm.yyyy") + "  bis Datum " + Format(FMDruck.SDATBIS.DateValue, "dd.mm.yyyy") + ","
End If
If FMDruck.SPCODE.Text <> "" Then
   sel = sel + "   nur Mitarbeiter " + FMDruck.SPCODE.Text + ","
End If
If FMDruck.CHErf Then
   sel = sel + "   nur erfaßte Eigenverbräuche,"
End If
If sel <> "" Then FMVorschau.dr.Paragraph = "   Selektion:  " + Left(sel, Len(sel) - 1)
FMVorschau.dr.Paragraph = ""
FMVorschau.dr.FontSize = 10
End Sub

Sub druck_ev()
Dim erg() As String

FMDrfort.Meter.Value = 0
FMDrfort.Show
FMDrfort.Left = FMDruck.Left + 100
FMDrfort.Top = FMDruck.Top + FMDruck.Height - FMDrfort.Height - 100
DoEvents

FMVorschau.dr.Orientation = orLandscape
FMVorschau.dr.StartDoc
FMVorschau.dr.FontSize = 10
levnr = ""
fo = "<+2.3cm|^+1.5cm|>+2.0cm|^+1.5cm|<+6cm|>+2cm|^+1cm|<+7cm|<+2cm|<+1.5cm"
hea = "Datum|Pcode|Nr.|Art.Nr.|Bezeichnung|Menge|VKE|Grund|Korr.-Art|Lk.-Nr"
firstline = True
par = ""
par = par + """" + da_vb_msm(FMDruck.SDATVON.DateValue) + ""","
par = par + """" + da_vb_msm(FMDruck.SDATBIS.DateValue) + ""","
par = par + """" + FMDruck.SPCODE.Text + ""","
If FMDruck.CHErf.Value Then
  par = par + """0"""
 Else
  par = par + """"""
End If
anz = dbcalld("D DRU1^BMUEGVA(" + par + ")", Chr(255), erg)

FMDrfort.Meter.MinValue = 1
FMDrfort.Meter.MaxValue = anz

For n = 1 To anz
  FMDrfort.Meter.Value = n
  DoEvents
  
  levnr = erg(n)
  ad = dbcall("S P0=$$ASCIANSI^%UML(^EIGV(FIRMA,1," + levnr + ")) W:$F($ZV,""MSM"") P0")
  lkart = Piece(ad, tr, 9) + "/" + Piece(ad, tr, 10)
  If lkart = "/" Then lkart = ""
  bod = Format(da_msm_vb(Piece(ad, tr, 3)), "dd.mm.yyyy") + "|" + Piece(ad, tr, 14) + "|" + levnr + "|" + Piece(ad, tr, 1) + "|" + Piece(ad, tr, 5) + "|" + Format(Val(Piece(ad, tr, 2)), "###,##0.00") + "|" + Piece(ad, tr, 13) + "|" + Piece(ad, tr, 8) + "|" + lkart + "|" + Piece(ad, tr, 15)
  FMVorschau.dr.AddTable fo, hea, bod, vbGreen, , Not firstline
  If firstline Then firstline = False
Next
FMDrfort.Visible = False

FMVorschau.Show
FMVorschau.dr.EndDoc
FMVorschau.PGScroll.Max = FMVorschau.dr.PageCount
FMVorschau.SEIT.Caption = Format(FMVorschau.PGScroll.Value) + " von " + Format(FMVorschau.dr.PageCount)
DoEvents

End Sub
