Misleading code

Misleading code

Postby MarcoBoschi » Thu Sep 15, 2011 2:14 pm

Please,
compile this little sample and try in two differents pc connected in a lan.

Please choice a record in the first PC and in the same record in the second PC.
In the first click Edit, You enter in a second dialog containing two get objects.
Modify the second get (oLast & cLast)
Click in save button
Immediatly in the other PC click Edit button
You do not find the modified values but the old values and yet I initialize the two variables in ths way

cLast := customer->last
cFirst := customer->first

Is not misleading?

Marco



Code: Select all  Expand view
#include "fivewin.ch"

FUNCTION LISTVIEW()


LOCAL oDlg
LOCAL oBrw
LOCAL oEdita
SET DELETED ON
SET EXCLUSIVE OFF


USE customer
INDEX ON field->first TAG first TO myindex
USE
SELECT 0

USE customer
SET INDEX TO myindex


DEFINE DIALOG oDlg FROM 10 , 10 TO 500 , 500 PIXEL

@ 50 , 1 LISTBOX oBrw FIELDS OF oDlg SIZE 200 , 200 PIXEL

@  1 , 1 BUTTON oEdita PROMPT "Edit" ACTION formview()

ACTIVATE DIALOG oDlg CENTER

RETURN NIL


FUNCTION FORMVIEW()
LOCAL oDlg
LOCAL oLast  , cLast
LOCAL oFirst , cFirst
LOCAL oSave

cLast  := customer->last
cFirst := customer->first


DEFINE DIALOG oDlg FROM 10 , 10 TO 300 , 300 PIXEL
@ 1 , 1 GET oFirst VAR cFirst OF oDlg
@ 2 , 1 GET oLast  VAR cLast  OF oDlg
@ 5 , 4 BUTTON oSave PROMPT "Save" ACTION ( salva( cLast , cFirst )  , oDlg:end() )


ACTIVATE DIALOG oDlg CENTER
RETURN NIL

FUNCTION  SALVA( cLast , cFirst )
IF rlock()
   REPLACE customer->first  WITH cFirst , ;
           customer->last   WITH cLast
   dbcommit()

ENDIF

RETURN NIL

 
User avatar
MarcoBoschi
 
Posts: 1065
Joined: Thu Nov 17, 2005 11:08 am
Location: Padova - Italy

Re: Misleading code

Postby nageswaragunupudi » Thu Sep 15, 2011 2:54 pm

Please unlock the record inside the function salva and check again.
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10631
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: Misleading code

Postby Patricio Avalos Aguirre » Thu Sep 15, 2011 3:29 pm

Hola

Prueba con este codigo

Code: Select all  Expand view
DEFINE DIALOG oDlg FROM 10 , 10 TO 300 , 300 PIXEL
@ 1 , 1 GET oFirst VAR cFirst OF oDlg
@ 2 , 1 GET oLast  VAR cLast  OF oDlg
@ 5 , 4  BUTTON oSave PROMPT "Save" ACTION iif( salva( cLast , cFirst ), oDlg:end(), MsgInfo( "Error al guardar datos", "Usuario" ) )
@ 5 , 10 BUTTON PROMPT "Exit" ACTION oDlg:End()

ACTIVATE DIALOG oDlg CENTER

RETURN NIL
//-------------------------------------------------------------------------
FUNCTION  SALVA( cLast , cFirst )

if customer->( !rlock() )
    return( .f. )
endif

  REPLACE customer->first  WITH cFirst , ;
          customer->last   WITH cLast
  customer->( dbcommit() )
  customer->( dbrUnlock() )

return( .t. )
//-------------------------------------------------------------------------
 
Saludos
Patricio

__________________________________________________________________
Version: Harbour 3.2.0dev (r1307082134),Compiler: Borland C++ 5.8.2 (32-bit)
PCode version: 0.3, FWH 13.2
http://www.sialm.cl
User avatar
Patricio Avalos Aguirre
 
Posts: 1060
Joined: Fri Oct 07, 2005 1:56 pm
Location: La Serena, Chile

Re: Misleading code

Postby MarcoBoschi » Thu Sep 15, 2011 3:39 pm

Many thanks
marco
User avatar
MarcoBoschi
 
Posts: 1065
Joined: Thu Nov 17, 2005 11:08 am
Location: Padova - Italy


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot] and 92 guests