Visual FoxPro 9 for Developers Contents Contents......................................................................................................................................................... i Chapter 1 - Overview....................................................................................................................................... 1 Why FoxPro?........................................................................................................................................... 1 Course Objectives................................................................................................................................... 1 Chapter 2 - Visual FoxPro Databases............................................................................................................ 2 Chapter Objectives.................................................................................................................................. 2 Creating a Project.................................................................................................................................... 3 Creating a Database................................................................................................................................ 4 Default Values.......................................................................................................................................... 9 Stored Procedures - Database Code Belongs in the Database...................................................... 10 Using NewID Stored Procedure in Person Table............................................................................. 14 Primary Key Fields................................................................................................................................ 15 Primary Indexes...................................................................................................................................... 15 AutoInc Integer Fields !....................................................................................................................... 16 Primary Key Fields – The Whole Story............................................................................................. 17 Default Values – The Whole Story..................................................................................................... 17 Database Rules for Data Validation Work......................................................................................... 18 Record Level Rules............................................................................................................................... 19 Field Level Rules................................................................................................................................... 20 Database Rules for Non-Validation Work......................................................................................... 21 Database Rules – The Whole Story................................................................................................... 23 Database Triggers – Cascading Deletes............................................................................................ 24 Database Triggers – Restricting Deletes........................................................................................... 27 Chapter 3 - Visual FoxPro Forms – the Basics........................................................................................... 29 Chapter Objectives................................................................................................................................ 29 Creating Visual FoxPro Forms............................................................................................................. 30 Chapter 4 - Data Buffering............................................................................................................................ 37 Chapter Objectives................................................................................................................................ 37 Using Private Data Sessions............................................................................................................... 38 Using Data Buffering............................................................................................................................ 39 Buffer Modes......................................................................................................................................... 41 TableUpdate() and TableRevert()....................................................................................................... 42 Transactions.......................................................................................................................................... 43 Chapter 5 - Framework Data Handling........................................................................................................ 44 Chapter Objectives................................................................................................................................ 44 Framework Principles............................................................................................................................ 45 What is the DataEnvironment?........................................................................................................... 45 Query the Form Data Environment for Open Tables....................................................................... 46 Button Set for the Form........................................................................................................................ 48 Button Set for the Form........................................................................................................................ 48 Data Handling Procedures for Forms................................................................................................. 49 Cancel Method...................................................................................................................................... 50 Load Method......................................................................................................................................... 51 CheckProperties Method..................................................................................................................... 51 SetAllCursorProperties Method......................................................................................................... 52 Init Method............................................................................................................................................ 53 QueryUnload Method.......................................................................................................................... 53 AskToSave Function............................................................................................................................ 53 DataModified Function........................................................................................................................ 54 Close Procedure..................................................................................................................................... 54 Delete Procedure................................................................................................................................... 55 OkToDelete Function........................................................................................................................... 55 DeleteMainRecord Procedure............................................................................................................. 56 Find Procedure...............................................................................................................