FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour Misleading code
Posts: 1091
Joined: Thu Nov 17, 2005 11:08 AM
Misleading code
Posted: Thu Sep 15, 2011 02: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 (fw): Select all Collapse
#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
Marco Boschi
info@marcoboschi.it
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: Misleading code
Posted: Thu Sep 15, 2011 02:54 PM

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

Regards



G. N. Rao.

Hyderabad, India
Posts: 1074
Joined: Fri Oct 07, 2005 01:56 PM
Re: Misleading code
Posted: Thu Sep 15, 2011 03:29 PM
Hola

Prueba con este codigo

Code (fw): Select all Collapse
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
Posts: 1091
Joined: Thu Nov 17, 2005 11:08 AM
Re: Misleading code
Posted: Thu Sep 15, 2011 03:39 PM

Many thanks
marco

Marco Boschi
info@marcoboschi.it

Continue the discussion