Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Cleaning my Cursor
Message
De
13/06/2014 06:51:27
Luis Santos
Biglevel-Soluções Informáticas, Lda
Portugal
 
 
À
12/06/2014 14:10:11
Antonio Lopes (En ligne)
BookMARC
Coimbra, Portugal
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Versions des environnements
Visual FoxPro:
VFP 9 SP2
OS:
Windows Server 2012
Network:
Windows 2008 Server
Database:
MS SQL Server
Application:
Web
Divers
Thread ID:
01601791
Message ID:
01601810
Vues:
35
Hello Antonio

i change my code like that:


Local TemReforço as double
Local myCustoComponentes as Double
Local myPA as string

TemReforço = 0.000
myCustoComponentes = 0.000
myPA = ''

IF Inlist(bo.ndos,17)
Select bi
Scan

If Upper(bi.familia) = 'COLARIN' and bi.producao = .T. and bi.u_refPA = myPA
Text to msel textmerge noshow
Select (Case when u_reforco = 'Sim' then 0.01 else 0.02 end ) as Reforco
from st (nolock) where st.ref = ?bi.ref
Endtext

If u_sqlexec(msel,[_reforco])
TemReforço = _reforco.reforco
Endif

Text to msel textmerge noshow
Select Isnull((Case when epcpond = 0 then epcusto else epcpond end),0) as epcpond,
Isnull((Case when pcpond = 0 then pcusto else pcpond end),0) as pcpond from st (nolock) where st.ref = ?bi.ref
Endtext

If u_sqlexec(msel,[_PCM])
myEpcm = _PCM.epcpond
mypcm = _PCM.pcpond
Endif

Replace bi.epcusto with myEpcm + TemReforço
Replace bi.pcusto with mypcm + (TemReforço * 200.482)

Endif

IF Upper(bi.unidade) = 'UN' and bi.familia = 'PUNH' and bi.producao = .T.
Select BI
Replace bi.epcusto with myEpcm + 0.005
Replace bi.pcusto with mypcm + (0.005 * 200.482)
Else
IF Upper(bi.unidade) = 'PAR' and bi.familia = 'PUNH' and bi.producao = .T.
Select BI
Replace bi.epcusto with myEpcm + 0.01
Replace bi.pcusto with mypcm + (0.01 * 200.482)
Endif
Endif

IF Upper(bi.unidade) = 'UN' and bi.familia = 'PAL' and bi.producao = .T.
Select BI
Replace bi.epcusto with myEpcm + 0.005
Replace bi.pcusto with mypcm + (0.005 * 200.482)
Else
IF Upper(bi.unidade) = 'PAR' and bi.familia = 'PAL' and bi.producao = .T.
Select BI
Replace bi.epcusto with myEpcm + 0.01
Replace bi.pcusto with mypcm + (0.01 * 200.482)
Endif
Endif

IF Upper(bi.unidade) = 'UN' and bi.familia = 'PLA' and bi.producao = .T.
Select BI
Replace bi.epcusto with myEpcm + 0.005
Replace bi.pcusto with mypcm + (0.005 * 200.482)
Else
IF Upper(bi.unidade) = 'PAR' and bi.familia = 'PLA' and bi.producao = .T.
Select BI
Replace bi.epcusto with myEpcm + 0.01
Replace bi.pcusto with mypcm + (0.01 * 200.482)
Endif
Endif
Endscan

DO CalculaCustoPA
select myBI
use
Endif
Fecha([_reforco])
Fecha([_PCM])

Procedure CalculaCustoPA
Local myRefActual as String
myRefActual = ''

Select BO
IF Inlist(bo.ndos,17)
Select BI

Create Cursor myBI (RefPA C(18), CustComp N(10,3))

DO ClearCursor

select bi.u_refpa as [RefPA], sum(epcusto) as 'CustComp' from bi where composto = .T.;
into Cursor myBI READWRITE group by bi.u_refpa

Select myBI
Scan
msg(myBI.refPA)
myRefActual = myBI.refPA
Select BI
Scan
If bi.u_refpa = myRefActual and bi.producao = .T.
Replace bi.epcusto with bi.epcusto + myBI.CustComp
Replace bi.pcusto with bi.pcusto + (myBI.CustComp * 200.482)
Endif
Endscan
Endscan
Endif
EndProc

PROCEDURE ClearCursor
select myBI
=CURSORSETPROP("Buffering", 3) && Line 1
SET SAFETY OFF
ZAP
ENDPROC


But my cursor dont clean, curiously when i save do secund time my document, the values are correct on myBI cursor and the document are recalculate right.

Have you another ideia.

Best regards
Luis Santos
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform