Stacked Canvas A content canvas is a main from canvas while a stacked canvas is a secondary canvas...

Post on 05-Jan-2016

233 views 2 download

Tags:

Transcript of Stacked Canvas A content canvas is a main from canvas while a stacked canvas is a secondary canvas...

Stacked Canvas

A content canvas is a main from canvas while a stacked canvas is a secondary canvas that overlays or partially covers a content canvas. In other words, it can be stacked on another canvas.

Thus in this slide presentation a content canvas will be made first, followed by a stacked canvas.

Open a new Form Module

Create a new data block using the

EMPLOYEE table

Use a new Content canvas

Set these prompts

The layout style should be Form

Display only on record and title the frame Employee Details

The Employee Details frame

Open the Property Palette for EMPLOYEE NUMBER

Change the required property to No

Highlight the Module and create a new data block for the EMPLOYEETYPE table

Deselect Auto-join. This data block should not be related to EMPLOYEE

Place this data block on a new stacked canvas

Use these prompts

Select the Form layout

Only display one record

Use the Frame Title, Employee Type Details

The canvas for Employee Type Details

In the Layout Editor, resize this stacked canvas to the Following:

Height 75Width 410

The canvas has been resized

Notice the size of the canvas

Change the name of the Content Canvas to

EMPLOYEES

Change the name of the Stacked Canvas to

EMPLOYEE_TYPE

Name changes can be done in the Property Palette or on the Object Navigator. In using the Object Navigator, highlight the object to

be changed. Ensure that the highlight is blue, not yellow, and change the name.

The names have been changed

Highlight the form window, WINDOW1. Open the Property

Palette and set these properties:Name: PRINCIPAL_WINDOWTitle: EMPLOYEE CHANGE FORMPrimary Canvas: EMPLOYEES

Properties changed

The window is now called

PRINCIPAL_WINDOW

Highlight Windows and create a new window

by clicking Edit, Create

The new window, WINDOW11 has been created. Open the Property Palette and set these properties:

Name: EMPLOYEE_TYPETitle: ADD NEW TYPEPrimary Canvas: EMPLOYEE_TYPE

Properties changed

For the EMPLOYEE_TYPE window, set these additional properties:

X Position: 20Y Position: 50Width: 410Height :75

Properties changed

Open the Property Palette for the

EMPLOYEE_TYPE canvas

Change the window to EMPLOYEE_TYPE

Locate the EMPLOYEETYPE item in the EMPLOYEE data

block and create a When-Validate-Item

trigger

Enter this source code for

the triggerFor the explanation of %ROWTYPE see the

next slide

%ROWTYPE Attribute

The %ROWTYPE attribute provides a record type that represents a row in a database table. The record can store an entire row of data selected from the table or fetched from a cursor or cursor variable. Variables declared using &ROWTYPE are treated like those declared using a datatype name.

%ROWTYPE can include all the columns in a table:

emp_rec employee%ROWTYPE;

Or a subset of the columns, based on a cursor:

CURSOR XYZ IS

SELECT DepartmentNumber, DepartmentName FROM departments;

Dept_rec XYZ%ROWTYPE;

Columns in such rows have the same names and datatypes, but do not inherit constraints such as NOT NULL or default values.

Open the Layout Editor for

EMPLOYEE

Add a button next to Emp. Type

Push Button has been added. Open the property Palette and give it the following properties:Name: ADD_TYPELabel: ADD TYPE

Properties changed

Name changed

Create a When-Button-Pressed trigger for the ADD_TYPE item. With Triggers highlighted, click Edit,

Create

Enter this code

Go_block navigates to the indicated data block. If the

target block is non-enterable, an error occurs. The syntax:

Go-block (‘Block Name’);

Open the Property Palette for the data block EMPLOYEETYPE. Set the following properties:

Update Allowed: NoDelete Allowed: NoQuery Allowed: No

1. Compile and run the form. Enter Ctrl-F11 to enter data on

the form. You must be connected to the database!

2. Enter an invalid Emp. Type

3. This warning is given

Change the Emp. Type back to its original value and click the

ADD TYPE button

The stacked canvas, ‘Employee Type Details’ appears on the top of the content canvas,

‘Employee Details’.

Notice that there are two windows:1. EMPLOYEE CHANGE FORM2. ADD NEW TYPEThe ADD NEW TYPE window is the active window.

1. Enter a new Emp. Type as shown

2. Click Insert record3. Click Save

4. A new record will have been added to

the database

A new record has been added to

EMPLOYEETYPE