You can just use a parameterized remote view or cursor adapter : procedure form.load() use removeView nodata procedure form.Init() viewParm = someValue requery(remoteView) FOR EACH loCntl IN this.Controls FOXOBJECT BindEvent(m.loCntl, 'LostFocus', m.this.cmdCancel, 'Refresh’) BindEvent(m.loCntl, 'LostFocus', m.this.cmdSave, 'Refresh') BindEvent(m.loCntl, 'LostFocus', m.thisForm.cmdOK, 'Refresh') ENDFOR
procedure cmdCancel.Refresh this.Enabled = thisForm.lCustomerModified()
procedure lCustomerModified * Has customer been modified? LOCAL lnRecno, llResult
lnRecno = Recno('v_customer') && Buffering 5 GO TOP IN v_customer llResult = GetNextModified(0, 'v_customer', .T.) > 0 IF m.lnRecno < 0 OR Between(m.lnRecno, 1, Reccount('v_customer')) GO m.lnRecno IN v_customer ENDIF
RETURN m.llResult
Thierry Nivelet FoxInCloud Give your VFP app a second life in the cloud http://foxincloud.com/ http://foxincloud.com/ Le 03/02/2017 à 22:19, Paul H. Tarver a écrit :
Now we are getting to hear to the heart of what I'm looking for, specifically your first point, Fernado: Changing my VFP grid mentality into something that is scalable for a client server approach for the data storage. Fundamentally, the questions I have are: What does the best practices user interface for updating data look like in a client/server environment vs native VFP desktop, and what are the general things required to make that work. In my standard environment it works like this:
- open a table in buffered mode
- let the user browse that data
- user choices record to edit
- user edits field and when field loses focus, we check to see if there
were any changes. 5) If changes detected, we enable a "save" button and if the user tries to exit the screen without clicking "save" we prompt them to save or discard. 6) If 'save' option made by clicking button or confirming save query, then new data is written to table.
I am aware that this outline of procedure would necessarily be different in the client/server configuration and that is exactly what I'm trying to determine and what are the best ways to implement that client/server approach.
Your information was very helpful and answered a couple of questions for me already.
Do you know of any applications out there that are written in VFP with a client/server backend that might have a demo that I can review or try in order to get some ideas?
Thanks again!
Paul H. Tarver Tarver Program Consultants, Inc.
-----Original Message----- From: Fernando D. Bozzo [mailto:fdbozzo@gmail.com mailto:fdbozzo@gmail.com] Sent: Friday, February 03, 2017 1:11 PM To: profoxtech@leafe.com mailto:profoxtech@leafe.com Subject: Re: SQL Backend Question - Part Deux
Hi Paul,
now it's much clear what you want. At first seemed to me like you wanted to change technology.
Ok, so these are just some points about general good practices applied on VFP and used in practice in my experience:
- Forget grids, or at least forget showing ALL the data to the user. This do
not work with C/S system, because do not scale. You will need predefined filters on the search screens, so the user can change them, but never take out all of them, so the query to the server brings a limited scope of records. You can bring records in chunks if you need to show something with "more records" or "next page" or similar, but never bring all the data. That's fundamental.
- You can cache part of the data for those tables that are hevily used if
needed, maybe a view that updates from time to time based on a datetime timestamp for synchronizing
- All logic that you can put on the database, is reusable by other fronts.
In some cases some processes are faster on the database
- Forget about locking records. There are no such thing on C/S systems
(well, technically you can, but it's really a bad idea)
- If going to web in some point, then Thierry's FoxInCloud could be a good
idea
- For local editing of data you can use a loca cursor if you want, so you
can use the same data modification detection techniques you already know (getNextModified(), etc) but at the end the data must go to the server, so no need to have a real table in local. Another approach is using an object whose properties are bound to the ControlSources (we use this approach in one of our apps), but in this case all the change-detection is by code
- This seems a big project, so Source Control is very important. You have
many options here, I suggest using a DVCS (Distributed Version Control System)
If using git, then you have these projects available:
Lutz Scheffler's "Bin 2 Text extension" at VFPx: http://vfpx.codeplex.com/wikipage?title=Bin%202%20Text%20Extension http://vfpx.codeplex.com/wikipage?title=Bin%202%20Text%20Extension
Mike Potjer's "Git Utils" at github: https://github.com/mikepotjer/vfp-git-utils https://github.com/mikepotjer/vfp-git-utils
If using Plastc, then you can use the "Plastic tools for Visual FoxPro 9": https://github.com/fdbozzo/plasticscm-tools-for-visual-foxpro-9 https://github.com/fdbozzo/plasticscm-tools-for-visual-foxpro-9
If using another SCM/DVCS like SourceSafe, Mercurial or similar, then you can use FoxBin2Prg because of the two-way conversion between binaries and text: http://vfpx.codeplex.com/wikipage?title=FoxBin2Prg http://vfpx.codeplex.com/wikipage?title=FoxBin2Prg
On the server side, you mentioned SQLServer. I suppose your client have a license, but if not, there is no need to buy one, you can use any DB, like PostgreSQL, MariaDB, etc, for free.
Finally, if you want to test your code (more good practices:) in an automated or semi-automated way, then you can use the excellent Eric Selje's FoxUnit: http://vfpx.codeplex.com/wikipage?title=FoxUnit&referringTitle=Home http://vfpx.codeplex.com/wikipage?title=FoxUnit&referringTitle=Home
May be others can add more on the SQL topic, articles or more resources.
Fernando D. Bozzo
2017-02-03 17:50 GMT+01:00 Paul H. Tarver paul@tpcqpc.com mailto:paul@tpcqpc.com:
Ok, from the range of answers I got back so far, all of which I appreciate greatly, it is clear that I need to clarify my project and goals just a bit in order to narrow the width of the discussion.
Here's the situation and the parameters:
I have a client that is still using a btrieve based dos systemthat
I created 20+ years ago to keep up with the names, addresses and activities of in excess of 30k+ members. The system creates a lot of specialized reports for the client and they have been unwilling to move to anything else because of all the custom functionality built into the system. (In case you are wondering, they are running the system on virtualized XP Pro systems as the verision of btrieve they have dies on anything later.)
I want to upgrade them to a VFP9 + Windows user interface andapplication in order to get them off the virtual machines, to take advantage of a lot of the speed and features available in VFP9 and I could certainly completely re-write this system in VFP using native dbf table if I chose to do so. HOWEVER.
In the long term, I can see a future for this client where theyhave a web-based front-end for members of their group to login remotely via the web and maintain their demographic data themselves thereby de-centralizing a lot of the data entry process currently done by the home office.
Plus, I want the best of both worlds. I want the users in thecentral office to take advantage of all the functionality I can bring to them with VFP9 as a networked desktop application AND at some point I want to add a web-based front-end for remote users to update various data points.
The final requirement is not really a requirement but a desire on my part to learn how to best handle the data entry process and build the user interface functionality in VFP9 to create a desktop application using SQL as data storage. I am used to creating a form with a tabbed pageframe on it, creating a data grid on the first tab, adding some filter capabilities for searches and then putting all the fields on the second or third or fourth or however many detail tabs I need to conveniently display the data I want the user to edit, add, delete or save through a sub-classed button bar that I drop on the form and connect to the table in question. My sub-classed tools use CURSORGETPROP to detect any changes and prompt the user to save the buffered changes if necessary.
I have come to the understanding from all I've read that this method of providing grid based data entry screens for users (while perfectly workable in my data interface projects) will not be as efficient when it comes to using SQL instead of native DBFs. I have also read lots of different opinions on how best to let the user search for the specific record they want to use and I have tried to review as many programs as I can to get some sense of the generally accepted method that makes the most sense for a best practices user interface but no joy so far. Once a user finds the record in question, I need to figure out what code snippets I need to build to detect changes and push the updates back to the SQL database and all the other stuff that goes along with that.
My hope was that someone could point me toward some good VFP examples or articles specific to VFP that outlines the best practices that seemed to work best. I am not interested in moving to a development tool other than VFP9, because my personal goal in doing the project is to give me a way to learn to program the best user interface I can with VFP as the front-end and SQL as the backend.
Hopefully that clarifies my original question just a bit.
Paul H. Tarver Tarver Program Consultants, Inc.
--- StripMime Report -- processed MIME parts --- multipart/alternative text/plain (text body -- kept) text/html
[excessive quoting removed by server]