Example: printing data from a DataStore – PB Docs 2017

Example: printing data from a DataStore

Suppose you have a window called w_employees that allows users to
retrieve, update, and print employee data retrieved from the
database:

dspic7.gif

The DataWindow object displayed in the DataWindow control is
suitable for online display but not for printing. In this case, you
could define a second DataWindow object for printing that has the same
result set description as the object used for display and assign the
second object to a DataStore. You could then share data between the
DataStore and the DataWindow control. Whenever the user asked to print
the data in the window, you could print the contents of the
DataStore.

When the window or form
opens

The code you write begins by establishing the hand pointer as the
current row indicator for the dw_employees DataWindow control. Then the
script sets the transaction object for dw_employees and issues a
Retrieve method to retrieve some data. After retrieving data, the script
creates a DataStore using the instance variable or data member
ids_datastore, and assigns the DataWindow object d_employees to the
DataStore. The final statement of the script shares the result set for
the dw_employees DataWindow control with the DataStore.

This code is for the window’s Open event:

Code for the Update button

Code for the cb_update button applies the update operation to the
dw_employees DataWindow control.

This code is for the Update button’s Clicked event:

Code for the Print button

The Clicked event of the cb_print button prints the contents of
ids_datastore. Because the DataWindow object for the DataStore is
d_employees, the printed output uses the presentation specified for this
object.

This code is for the Print button’s Clicked event:

When the window or form
closes

When the window closes, the DataStore gets destroyed.

This code is for the window’s Close event:


Document get from Powerbuilder help
Thank you for watching.
Was this article helpful?
Subscribe
Notify of
guest
0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x