Tuto WINDEV Mobile 25
Part 6: Windows Mobile application 203 2. We will modify the code of the Button control used to validate the form: • Right-click the Button control and select "Code" from the popup menu. • In the "Click" event, replace the existing WLanguage code with the following: ScreenToFile() IF Product..NewRecord THEN HAdd(Product) ELSE HModify(Product) END Close() Let’s take a look at these lines of code: • ..NewRecord is used to find out whether the current record must be created. • If HReset was called beforehand, the property returns True (click on "New product") and the record must be created by HAdd . • Otherwise, the current record already exists and it must be modified by HModify . Remark The test code of new record can be replaced by HSave . This function is used to check whether the record is already found in the data file, and it allows you to add it or to modify it. The code becomes: ScreenToFile() HSave(Product) Close() 3. Save the modifications by clicking among the quick access buttons. 4. Close the code window (click X at the top right corner of code editor). ▶ Display the "WIN_List_of_products" window in the window editor and run its test in the simulator ( among the quick access buttons). • In the list of products, click the "New product" button. • Type a new product. • Validate. The new product is displayed in the list of products. • Close the simulator.
Made with FlippingBook
RkJQdWJsaXNoZXIy NDQ0OA==