Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
About text report (Hillmar Zonneveld)
Message
From
28/10/2004 10:40:54
Hilmar Zonneveld
Independent Consultant
Cochabamba, Bolivia
 
General information
Forum:
Visual FoxPro
Category:
Reports & Report designer
Miscellaneous
Thread ID:
00955165
Message ID:
00955289
Views:
17
>Hi Hillmar,
>would you like explain to me step by step, how can i print my invoice via your text report class ?
>
>TIA

OK, I already sent a basic outline, but I will give you more details here, including the usual debugging process. Please ask again if anything is not clear, or if you need additional options.

1) Create a class based on the Text Report class. Let's assume you call it cInvoice.

2) The user will probably interact with the system with some form. From this form, invoke the class like this:
CreateObject("cInvoice", lnDestination, lnInvoice)
where lnDestination indicates the destination (preview, print, and some other options - see the example included in the download),

and lnInvoice is the primary key of your invoice. Note that the CreateObject() will run the class immediately. I had planned to change this, to make it more object-oriented, but this is the way it works now.

3) Accept the parameter in your cInvoice class, in the Init() method. Save the invoice number to a property, which you have to add. For example:
lparameters tnDestination, tnInvoice
This.nInvoice = tnInvoice
...
DoDefault(tnDestination)
4) Prepare the data in the .Select() method. This may be one SELECT - SQL command, several of them, or any other command which you would use to create a table. For example:
* Table invoice header
select InvoiceId, InvoiceNumber, Date;
  from Invoice;
  where InvoiceId = This.nInvoice;
  into cursor TempReport;
  nofilter
* Table invoice detail
select TempReport.*, id.Product, id.Quantity, id.Price;
  from TempReport join InvoiceDetail id;
    on TempReport.InvoiceId = id.InvoiceId;
  into cursor TempReport

* Debugging: Check the results so far
browse normal
cancel
5) Eliminate the last two commands from the .Select() method, and print the line details. The .Detail() method will execute once for each record. In the .Detail() method, use commands like:
* Method .Detail()
.PrintLine(Product, transform(Quantity, "###,###.##"),;
  transform(Price, "###,###.##"))
Notes:
  • The comma will insert an additional space, just like the "?" and "??" commands.
  • You can also concate strings with "+", but it is better to include separate fields as separate parameters; this way, the output to Excel (which is also supported by the class) will work correctly.
  • You should NOT use the ? and ?? commands. If you do, several details won't work. For a start, the class will not know how the line and column position. Also, I was planning to change to LLFF eventually, to avoid certain problems. Use the wrapper functions (.Print() and .PrintLine()) instead.

    Test your results so far.

    6) Add commands to the .PageHeader(), for the invoice header and the column headers. For example:
    * Method .PageHeader()
    This.Print("Invoice # ...")
    This.PrintLine("Date: ", Date)
    This.PrintLine()
    This.PrintLine("Product", "Quantity", "Price")
    This.PrintLine()
    Try it, and adjust the spacing.

    HTH,

    Hilmar.
    Difference in opinions hath cost many millions of lives: for instance, whether flesh be bread, or bread be flesh; whether whistling be a vice or a virtue; whether it be better to kiss a post, or throw it into the fire... (from Gulliver's Travels)
  • Previous
    Reply
    Map
    View

    Click here to load this message in the networking platform