B4J Question Tip needed

kisoft

Well-Known Member
Licensed User
Longtime User
Hello everyone, I want to create a program for issuing invoices with a database (contractors, materials, services, etc.) and of course printing documents ... What will be the best approach to do it, what to use ... ... Thank you for all the help ...
 

MegatenFreak

Active Member
Licensed User
Hi. I have a very large app that includes the functions you mention as a small part of it.
My personal suggestion for an approach would be as follows: (Sorry if parts of it seem too simple; I don't mean to insult anyone's intelligence!)
I can't give more detail without knowing the specifics about your application.

1. Choose a database type (local/online). Local would do fine unless you want it to run on several machines with synced data.
2. In the database, make sure you assign IDs (via sql's auto increment, preferably) to every invoice that is issued, so you can later easily produce statistics or retrieve a specific one.
3. After receiving the required data for the issuing of the invoice through a B4J form, store that data in a database table. Keeping whatever is issued will prove handy later on in case you decide to expand the functions of your app.
4. As for printing, you have several options. Test each one and see which one produces the best results)
Here's a couple of things you can do:
a) Create your output form as a B4J view and print the view's contents (not recommended).
b) If you known HTML, convert the data into an HTML form that looks just like the output you want, and then either: A) create an invisible WebView, display the HTML inside it, and print the contents using the code I'll mention further below; B) write the HTML into a file and send it to Microsoft Word; that works better for customizability.
c) If the result can take the form of an EXCEL output, use the B4J library to create the excel file and send it to Microsoft Excel to be printed from there.

Code to print the contents of a webview:
B4X:
Sub PrintWebView(w As WebView)
    Dim PJ As PrinterJob = PrinterJob_Static.CreatePrinterJob
    PJ.ShowPageSetupDialog(Null)
    PJ.ShowPrintDialog(Null)
    Dim WVJO As JavaObject = w
    WVJO.RunMethodJO("getEngine",Null).RunMethod("print",Array(PJ.GetObject))
    PJ.EndJob
End Sub

I might be able to give better information if you give more details about the nature of your application.
I hope this helps
 
Upvote 0

kisoft

Well-Known Member
Licensed User
Longtime User
Thanks to everyone for the answers...

I want to create a typical application for issuing various sales documents, no big deal, with the ability to view sales results for a given period of time. I just wanted information on how to go about it and what solutions to use...
 
Last edited:
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…