Example: Creating a Button Group

Previous Next

See Also

The button group at the bottom of the Reservations info window has the following functionality:

· If the user clicks the Add Person Booking button, a default entry should be made for the person booking (RESERVATION.MADE_BY) in the PARTICIPANT table and this entry should also appear in the related Participants box in the Reservations window.

 

· If the user clicks the Cancel Reservation button, the reservation should be canceled. A reservation is canceled if it has a CANCEL_DATE value.

 

· If the user clicks the Quote Final Price button, this should result in a price (re)calculation taking into account the current record, but it should not result in commit.

 

· If the user clicks the Confirm Reservation button, the transaction should be committed.

To create a Button Class for the button group:

1. Click the Controls tab page in the Windows Designer catalog.
2. Right-click on the Button node and choose New from the resulting menu.

A Subclass of Button is created.

3. Expand the Button node and right-click on the Subclass of Button, and choose Rename.
4. Rename to Palette Button.

To create the button group:

1. Open the Reservations info window.

Make sure that the Info Window itself is selected. The status line should read Info Window: Reservations.

2. Click the Controls tab page in the Windows Designer catalog.
3. Drag and drop four Palette Buttons from the Controls tab page onto the design view.
4. Holding down the CTRL key, select all four buttons.
5. Right-click on the buttons, and choose Group.

To give the button group a better layout:

1. Position the new button group on the design view.

Set the Position property to a value higher than the Position of the columnBox for the participant data.

2. Give each of the buttons its correct prompt.

To give the buttons the correct behavior:

1. Add the following Action property to the Add Person Booking button:

SqlScript(insert into participant(person_id, res_id, insurance)

values(:MADE_BY, :RES_ID, 'N'))

Participants_taking_part_in_Reservation.QueryExecute()

Participants_taking_part_in_Reservation.person_id.esd_int.ControlSetFocus()

2. Add the following Action property to the Cancel Reservation button:

ActionDecision(CANCEL_RES)

RecordStore('QUIET')

In the CANCEL_RES decision, set Decision SQL to:

SELECT SYSDATE

and the Decision Yes Action to:

query.cancel_date(:1)

The syntax for retrieving the current date and time, here represented by SYSDATE, is RDBMS-specific.

3. Add the following Action property to the Quote Final Price button:

Participants_taking_part_in_Reservation.RecordStore('QUIET'))

4. Add the following Action property to the Confirm Reservation button:

DataCommit()