MASTAPP Help Contents

Click the underlined text that matches a button's label to learn more about the parts of  MASTAPP, the sample application that demonstrates Delphi's database capabilities.

Help for each button describes the button's purpose in the application, lists the MASTAPP project files used to build that part of the application, and details significant database and Delphi features that the button illustrates.

New Orders enters new customer orders.

Browse examines existing orders.

Parts maintains the MAST inventory.

Reports prints MASTAPP reports using ReportSmith.

Close exits MASTAPP.

Help describes how MASTAPP help is implemented.

Click Splash Screen to learn about the banner that appears when you start MASTAPP.


Select Customer

This form enables you to select a customer by name for placing new orders, or for browsing existing orders. Select the desired customer, and click OK. The Select Customer form is the same form used by Select Part, except that the data source and data fields are different.

Source code for this form can be found in:

BRMODAL.PAS

BRMODAL.DFM


Select Part

This form enables you to select a part by name when entering customer orders. Select the desired part, and click OK. The Select Part form is the same form used by Select Customer, except that the data source and data fields are different.

Source code for this form can be found in:

BRMODAL.PAS

BRMODAL.DFM


New Orders

New Orders enables you to enter new customer orders, modify existing customer orders, browse existing orders, or print the current order.

The form contains two TDBNavigator controls, one for editing and inserting records, and another for navigating among records. When you enter a new record, the navigation buttons are disabled, and only the Post and Insert buttons are enabled on the other control. When you browse existing records, the navigation buttons are enabled. When you edit a record, all navigation buttons on both navigator controls are enabled as appropriate.

A mode indicator in the upper right corner of the form indicates whether you are inserting, editing, or browsing.

Source code for the New Orders form can be found in:

EDORDERS.PAS

EDORDERS.DFM


Insert Mode

The following behavior can be expected on the New Orders form in insert mode.

The OrderNo TDBEdit control is automatically filled in with the next available record number. The Date TDBEdit control is automatically filled in with today's date. You can enter a customer number in the CustNo TDBEdit control, double-click the control, or click the button to the right of the control to select a customer from the Select Customer form. When you enter a customer number in the CustNo control, the application fills in the rest of the customer information in the Bill To edit controls. You can cut and paste from the Bill To edit controls to the Ship To edit controls, or enter different values as appropriate.

The Sold By, Terms, Payment, and Ship Via fields are TDBComboBox controls tied to the ORDERS table. You can select values for these fields from the drop-down lists.

You can enter parts ordered by the customer in the TDBGrid control. When you enter the grid, the Parts glyph button below the grid is enabled. You can double-click in the grid, or click the Parts button to select parts from the MAST inventory. Both methods invoke the Select Part form.

As parts are entered in the grid, calculations are automatically performed to update the values in the Subtotal, Tax Rate, Tax Total, Freight, and Due database edit controls. These controls, and the Paid control, are connected to the ORDERS table. When the new record is posted, these values are inserted into the ORDERS table.


Edit Mode

The following behavior can be expected on the New Orders form in edit mode.

The first record in the ORDERS table is displayed in the form. You can enter an order number in the OrderNo field to move to a specific record. You can also enter a customer number in the CustNo TDBEdit control, double-click the control, or click the button to the right of the control to select a customer from the Select Customer form to move to that customer's first record, or use the navigation controls to scroll through all records. You can modify fields within records as long as those fields are not read-only.

You can modify or add parts ordered by the customer in the TDBGrid control. When you enter the grid, the Parts glyph button below the grid is enabled. You can double-click in the grid, or click the Parts button to select parts from the MAST inventory. Both methods invoke the Select Part form.

As parts are entered in the grid, calculations are automatically performed to update the values in the Subtotal, Tax Rate, Tax Total, Freight, and Due database edit controls. These controls, and the  Paid control, are connected to the ORDERS table. When the new record is posted, these values are inserted into the ORDERS table.


Browse Mode

The following behavior can be expected on the New Orders form in edit mode.

The first record in the ORDERS table is displayed in the form. You can enter an order number in the OrderNo field to move to a specific record. You can also enter a customer number in the CustNo TDBEdit control, double-click the control, or click the button to the right of the control to select a customer from the Select Customer form to move to that customer's first record, or use the navigation controls to scroll through all records.

If you attempt to modify any field in a record you enter Edit Mode.


Browse

To examine orders placed by customers, click the Browse button. It invokes the Orders By Customer form.

Orders By Customer displays two TDBGrid controls. The top control displays all MAST customers, ordered by customer number. When the form first appears, the first customer number in the CUSTOMER table is selected. The bottom grid displays all orders associated with the current customer number.

Use the TDBNavigator control between the grids to scroll on either grid. To establish which grid the navigator affects, click on the desired grid. If you scroll to a different record on the customer grid, the orders grid changes to reflect those orders associated with the current customer number. Scrolling the bottom grid lets you see all orders associated with the current customer number.

The Define Query button invokes the Specify Range dialog box, where you can enter a narrower range of dates against which to check for customer invoices, in order to reduce the number of records returned in customer grid. After you define a query, use the Activate Query button to execute the query. When a query is active, the Activate Query button remains in a depressed state. To deactivate the query and restore the default customer list display, click the Activate Query button again.

The Orders By Customer form demonstrates how to switch data sources for a control programmatically at run time. The Define Query and Activate Query code demonstrates how to construct parameterized SQL queries from user input at run time, and how to switch between data sets programmatically.

Source code for Orders By Customer can be found in:

CUSTORD.PAS

CUSTORD.DFM


Parts

The Browse Parts form enables you to browse and edit the MAST inventory

The form contains a TDBGrid for displaying all parts and backordered parts, a TDBNavigator control for scrolling through records, a Backorder button for querying to see all parts on back order, an Edit button that displays the Edit Parts form for adding or modifying parts, and a Close button for exiting the form.

Browse Parts demonstrates how a single data source can be used by either a TTable or TQuery component. By default, when the form appears, it displays data for all parts from the TTable component. Clicking the Backorders button invokes code that connects TQuery to the data source and executes a query that displays only those parts on back order.

Source code for Browse Parts can be found in:

BRPARTS.PAS

BRPARTS.DFM


Edit Parts

The Edit Parts form enables you to add or modify parts in the MAST inventory, and print information about parts.

The form contains a TDBNavigator control for scrolling through records, adding and deleting records, and posting or canceling changes. It contains six TDBEedit controls for display, entry, and modification of fields in the PARTS table. It also contains a TDBLookupCombo control for display, entry, and modification of vendor names in the VENDORS table based on vendor numbers in the PARTS table.

Edit Parts demonstrates how to look up, display, and edit field values in one table based on key values in another table by using TDBLookupCombo.

Source code for Edit Parts can be found in:

EDPARTS.PAS

EDPARTS.DFM


Reports

The Reports form lets you specify three different types of reports to print:

Customer List lists MAST customers.

Orders History details the orders placed with MAST.

Invoice provides a full report on a specified invoice.

These reports are run-time versions of ReportSmith reports built into MASTAPP at design time. MAIN.PAS contains commented code that sets the path, directory, and ReportSmith variable names for MASTAPP reports at run-time.

ReportSmith uses dynamic data exchange (DDE) to communicate with applications such as MASTAPP. When passing values to ReportSmith variables from an application, preface the ReportSmith variables with an @ sign, and pass the values as quoted strings within angle brackets. For example, in MAIN.PAS, the code used to pass dates to ReportSmith variables for the Orders reports is as follows:

InitialValues.Add('@startdate=<'+DateToStr(FromDate)+'>');

InitialValues.Add('@enddate=<'+DateToStr(ToDate)+'>');

Source code for the Reports selection form can be found in:

PICKREP.PAS

PICKREP.DFM


Close

To exit MASTAPP, click Close, or choose File|Exit from the menu.


Help on Help

MASTAPP help demonstrates how to access a custom help file from a Delphi application. To link a help file to an application and access it, follow these steps:

1.	Set the application's HelpFile property to the name of the .HLP file to use. For example, in MASTAPP.DPR, the following code specifies the name of the help file to use for MASTAPP:

Application.HelpFile := 'MASTAPP.HLP';

2.	Set the main component's HelpContext property to 1. For example, in MASTAPP, MAIN.PAS contains the code for  MainForm. Select the MainForm component, then set its HelpContext to 1 in the Object Inspector.

3.	To access help from a button, create a help procedure that calls the HelpCommand method with a valid WINHELP command. To display the contents for a help file, use the HELP_CONTENTS command, and set the data integer to 0. In MASTAPP, the following help procedure is defined with a context ID that calls the MASTAPP Contents page:

procedure TMainForm.HelpBtnClick(Sender: TObject);

begin

   Application.HelpCommand(HELP_CONTENTS, 0);

end;

Note  At design time, set the HelpContext property for individual components to specify a context-sensitive help screen to display if the user presses F1 when those components have focus. In MASTAPP, context-sensitive help is implemented for all components on the Parts form, and the Edit Parts form.

4.	Create a button that calls a help procedure when clicked. In MASTAPP, MAIN.PAS contains the following code for creating a help button:

HelpBtn: TSpeedButton;

In the Object Inspector, set the button's OnClick event to the name of the help procedure to call. In MASTAPP, the name of the procedure that is called in HelpBtnClick.

5.	Create a procedure that calls HelpCommand with the WINHELP command, HELP_QUIT to quit WINHELP when the application ends. IN MASTAPP, MAIN.PAS contains the following procedure for exiting WINHELP:

procedure TMainForm.FormDestroy(Sender: TObject);

begin

   Application.HelpCommand(HELP_QUIT,0);

end;


Splash Screen

The Splash screen appears when MASTAPP starts. MASTAPP.DPR calls TSplashForm.Create to create the splash screen and the instance of the application, calls SplashForm.Show to display the form while all other MASTAPP forms are created, and calls SplashForm.Update to display the application's "Loading ..." message on the form.

When all MASTAPP forms are created, MASTAPP.DPR calls SplashForm.Hide to hide the Splash screen display.

Source code for the splash screen can be found in:

SPLASH.PAS

SPLASH.DFM