Tuto WEBDEV 25
Part 3: Intranet site with data 117 ▶ To search and display data in the page: 1. Click the page in the editor. 2. Press F2. The code editor displays the different page events. 3. In the "Global declarations" event, write the following code below the code previously written: HReadSeekFirst(Product,ProductID,gnProductID) IF HFound(Product) = False THEN // Display the list of products PageDisplay(PAGE_List_of_products) END FileToPage() 4. Let’s take a look at this WLanguage code: • HReadSeekFirst is used to find the first record in the Product data file for which the ProductID item is equal to the value of gnProductID. gnProductID corresponds to the parameter passed to the page. • HFound is used to check whether a record was actually found. This function is mainly required for the multi-user sites. It is used to avoid errors caused by the deletions performed by the other users. In our case, if the record was not found ( HFound returns False), the list of product is redisplayed. • FileToPage is used to display in the controls the data found in the data file, for the current record. In our case, the current record corresponds to the record found by HReadSeekFirst . 5. Close the code editor. Creating buttons The "PAGE_Product_form" page will be used to modify a product found in the list of products. We will add two Button controls: a cancellation button and a validation button. • The "Cancel" Button control will simply display the previous page again. • The "Validate" Button control will check the entered data and save the modified data. Cancel button ▶ To create the "Cancel" Button control: 1. On the "Creation" pane, in the "Usual controls" group, click "Button". 2. Click below the edit controls to create the Button control. 3. Modify the control caption (press Space to edit the caption): the new caption is "Cancel".
Made with FlippingBook
RkJQdWJsaXNoZXIy NDQ0OA==