Postby ConvertFromOldNGs » Fri Aug 07, 2009 2:59 pm
by Dean Cooper >> Wed, 27 Aug 2008 0:26:25 GMT
The attached zip file contains a very simple Order and Order Line example system.
If you extract the zip, you'll see a 6.2.15 scm and ddb file that you can load into JADE to create an OrderEntry subschema of the RootSchema.
Copy the JPGs to a c:\temp\OrderEntry folder (the JadeScript below expects them to be in this location and will get an exception if they're not).
Once you've loaded the schemas, have a look at the JadeScript::createTheLot method in the OrderEntry schema. This deletes all existing data and then creates several persistent Product and Customer objects in the database. The very first thing it does (after the delete) is create a singleton Root object, as described by Patwos. If you look at the all* collections on the Root class, you will see that they each have a myRoot inverse reference on the related class. When the JadeScript sets the myRoot reference on an objects, JADE automatically adds that object to the related collection on the Root object.
Once you have a reference to the Root object, you can use the all* collections to access your data. That's what the simple GUI application in the OrderEntry schema does. If you look at OrderEntrySchema::initOrderEntry (the application's initialise method that is called when the application starts), you will see that it gets the first instance of the Root class and holds this in a myRoot reference on the transient app object (that every application has). You can define initialise and finalise methods for your application by selecting Browse | Applications, right clicking the application you want and selecting Change, then using the Initialize Method and Finalize Method combo boxes (enter a new method name or select an existing method).
If you look at all of the references to app.myRoot (select the myRoot property on the OrderEntrySchema class, right click and selected References), you can click on each method to see how it uses myRoot to access collections and retrieve data. For example, the OrderCreateForm::load method uses app.myRoot to iterate the allCustomers collection to load a combo box. The OrderLineCreateForm::load method iterates app.myRoot.allProducts to load a combo box.
From an OrderEntrySchema Class Browser window, click the green arrow in the toolbar and run the OrderEntryApp. Select Orders | Create Order. This has executed the OrderCreateForm::load method to load the Customer combo box with the data created by the JadeScript::createTheLot method. Enter an Order Number, select a Customer and then click New Line. This has executed the OrderLineCreateForm::load method to load the Product combo box with data. Select a Product, enter a Price and Quantity, then click OK. Click OK to create the Order. Now select Order | List Orders and you will see the Order you have just created. Select it to show the Order Line details. This has executed the OrderListForm::load and OrderListForm::tblOrders_mouseDown methods (which have in turn executed OrderListForm::refreshTheLot and OrderListForm::fillDetailTable).
Dean.
-
Attachments
-
- 5396_1.zip
- (178.05 KiB) Downloaded 317 times