Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Get all employee
Message
De
09/02/2005 11:45:38
 
 
À
09/02/2005 08:47:04
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Versions des environnements
Visual FoxPro:
VFP 5
Database:
Visual FoxPro
Divers
Thread ID:
00985090
Message ID:
00985222
Vues:
30
>i write this code under to get result for one employee every time,
>i need to get all employee,
>
> CLOSE ALL
>set talk off
>set echo off
>SELECT 1
>USE MSTR
>LOCATE FOR NO=THISFORM.TEXT1.VALUE
>SELECT 1
>USE MSTR
>LOCATE FOR NO=THISFORM.TEXT1.VALUE
>if !found()
>   =messagebox("ÑÞã ÇáãæÙÝ ÛíÑ ãæÌæÏ")
>   thisform.command1.visible=.f.
>   thisform.command2.visible=.f.
>
>else
>   thisform.command1.visible=.t.
>   thisform.command2.visible=.t.
>   M.DAT=DAT
>
> SELECT 2
>   USE TAX1
>     M.NETTOT=NETTOT
>       m.s=monthnam
>   LOCATE FOR NO=THISFORM.TEXT1.VALUE
>    IF FOUND()
>                  set filter to no=THISFORM.TEXT1.VALUE .and. montno>=THISFORM.TEXT2.VALUE .AND. MONTNO<=THISFORM.TEXT3.VALUE
>DO WHILE .T. .and. no=THISFORM.TEXT1.VALUE
>SKIP
>M.NETTOT=NETTOT
>m.s=monthnam
>  IF EOF()
>    EXIT
>  ENDIF
>ENDDO
>
>endif
>report form coptax1 preview
>endif
>
>thanks.


There are a few problems in your example.

If I understand you correctly, the easiest way to get the result is to query for all employees.
m.no=THISFORM.TEXT1.VALUE
m.nMin=THISFORM.TEXT2.VALUE
m.nMax=THISFORM.TEXT3.VALUE
Select from tax1 where no=m.no and montno between m.nMin and m.nMax into cursor employees
report form coptax1 preview
In your code you set the locate for MSTR twice. Only one is needed.
It is not a good idea to set areas specifically by number with SELECT 1, SELECT 2. You should let VFP select the next available area with SELECT 0 and then refer to it by alias:
SELECT 0
USE MSTR
or
USE MSTR IN 0
SELECT MSTR
Generally you should try to avoid using SET FILTER as it could be slow in a big table without full Rushmore optimization.

Another speed tip is to save the control.Value to a memvar, validate it, then refer to the memvar. Every time you refer to the control value: THISFORM.TEXT1.VALUE, VFP has to traverse the hierarchy (each 'dot') to define the value if it is not cached, therefore wasting time. And from a security standpoint, if you refer directly to the user-entered value in a query, instead of a validated-memvar, you could open the program to malicious code being entered.

You do not need DO WHILE .T. .and. no=THISFORM.TEXT1.VALUE
If you want a loop just doing DO WHILE no=m.Text1Value is enough

HTH


Alex Feldstein, MCP, Microsoft MVP
VFP Tips: English - Spanish
Website - Blog - Photo Gallery


"Once again, we come to the Holiday Season, a deeply religious time that each of us observes, in his own way, by going to the mall of his choice." -- Dave Barry
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform