Simple demo of Customer/Orders one to many form with conflict detection and resolution
Often I’m asked to demo Foxpro to people who’ve never seen it before. In one demo I show how simple it is to create a usable one to many form that allows multiple instances with collision detection and resolution.
- From the main menu choose File->New->Form
- In the property sheet, change BufferMode to optimistic and DataSession to 2 (Private)
- From the main menu choose View->Data Environment (or right click on the form)
- Navigate to some sample data like Samples\Northwind or Samples\Data
- Add Customer and Orders tables. Notice that the relationship between these tables is displayed (you can even click on the relationship line and see its properties in the property sheet.
- Close the “Add Table or View dialog”
- Multiple select some fields of the Customer table and Right-Click drag to the form.
- Choose “Create Multiple Controls Here” from the drag context menu. This adds labels and textboxes to the form.
- Click/drag the orders table to the form. This adds a grid.
- You can resize the form or contained objects as desired.
- Click on the “View Classes” library button on the Form Controls Toolbar, choose Add and navigate to the FFC\_datanav.vcx Visual Class library.
- Choose the “_datanav” buttons object and put it on the form. It will have First, Forward, Rewind, and Last buttons on it.
Save the form as “form1”
Do this twice to get 2 forms: From the command window, DO FORM form1
Move the 2 instances of the form around so you can see both. Click on the navigate buttons to show that the one to many feature works fine.
Now navigate to the same customer record in each form, make a different change in each, and a messagebox comes up:
---------------------------
Data Conflict
---------------------------
A value has been changed by another user.
Field: CONTACT
Record Number: 4
Original Value: Thomas Hardy
Current Value: Thomas Hardy2
Your change: Thomas Hardy1
Do you want to overwrite the current value with your change?
(Choose 'Cancel' to restore the original value.)
---------------------------
Yes No Cancel
---------------------------
At this point, I ask the audience “How many lines of code are needed to create a one to many form with collation detection?” Also notice that you can create useful things in Foxpro without first having to create a project and decide what kind of project it’s going to be.
I’ve been giving this demo for over 10 years since VFP 3.0
Notes:
- you can hit Ctrl-E to close the form designer and run the form. When you close the form, it will return to the designer. If you run two instances of the form, and you close the first instance, it will try to return to design mode, and you might get a “File is in use” error, because it’s in use by the other form.
- Beware if you change the primary key (like Customerid). You can lose the related records or violate triggers
Comments
Anonymous
July 21, 2005
How comforting foxpro can keep on embracing new technologies without abandoned its heritage (i.e. you can run the same demo for the last 10 years)Anonymous
June 02, 2006
The comment has been removedAnonymous
July 10, 2006
hi calvin:
I am the one of the chinease guy who you interviewed serveral weaks ago.And now i sit in cti's office and wait for working for you.:-)
we have see this class and demo for many years,and now there are some new property in vfp9's cursoradapter base class for conflict detection and resolution,I think that do need a demo to help we find the way to use them.
thanks.Anonymous
August 17, 2007
SQLExpress is free and comes with Visual Studio, but the sample Northwind database isn’t included. YouAnonymous
August 17, 2007
PingBack from http://msdnrss.thecoderblogs.com/2007/08/17/Anonymous
August 17, 2007
SQLExpress is free and comes with Visual Studio, but the sample Northwind database isn’t included. YouAnonymous
June 16, 2009
PingBack from http://fixmycrediteasily.info/story.php?id=16475Anonymous
June 16, 2009
PingBack from http://topalternativedating.info/story.php?id=3095