FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour To Nages: tdatarow add new
Posts: 7318
Joined: Thu Oct 18, 2012 07:17 PM
To Nages: tdatarow add new
Posted: Wed Feb 06, 2019 12:48 PM
is there something of Wrong ?

I open Servizi on two xbrowse
Code (fw): Select all Collapse
cFilter1:= 'MULTIPLE=.F.'
   cFilter2:= 'MULTIPLE=.T.'

   oServizi := TDatabase():Open( , "SERVIZI", "DBFCDX", .T. )
   oServizi:bTrigger := { || If( Empty( ORDINE ), ORDINE := RECNO(), nil ),;
                             If( Empty( ID ), ID := strzero(RECNO(),4), nil )}
   oServizi:SetOrder( 0 )
   oServizi:GoTop()


   oServiziSingoli := TDatabase():Open( , "SERVIZI", "DBFCDX", .T. )
   oServiziSingoli:bTrigger := { || If( Empty( ORDINE ), ORDINE := RECNO(), nil ),;
                             If( Empty( ID ), ID := strzero(RECNO(),4), nil )}

   oServiziSingoli:SetOrder( 1 )
   oServiziSingoli:setFilter( cFilter1)
   oServiziSingoli:GoTop()

   oServiziMultipli := TDatabase():Open( , "SERVIZI", "DBFCDX", .T. )
   oServiziMultipli:bTrigger := { || If( Empty( ORDINE ), ORDINE := RECNO(), nil ),;
                             If( Empty( ID ), ID := strzero(RECNO(),4), nil )}

   oServiziMultipli:SetOrder( 1 )
   oServiziMultipli:setFilter( cFilter2)
   oServiziMultipli:GoTop()


and I create the xbrowse with no setodbffunc but with datasource command

then I add oBrw1:bEdit := { |oRec| EditServizi( oRec,oBrw1 ) }



on Editsource function I must cal the new number on cId if lAdd

Code (fw): Select all Collapse
Function EditServizi( oRec,oBrw  )

   local lAdd := ( oRec:RecNo == 0 )
   local lSave := .F.
   local oFont
   local oBtn
   local oDlg
   local oBtnImage
   local cFile :=""
   local cImgPath:=".\images\"
   local cDefaImage:=cImgPath+UrlImage("noImage.png")

   Local cImage:=   lfn2sfn(rtrim(oRec:Image))
   Local oImage

   local cId := strzero(oRec:RecNo,4)
   local aGet[10]


   If lAdd
         oBrw:clearFilter()
         oRec:gobottom()
         cId:= strzero(oRec:RecNo+1,4)
         oBrw:setFilter( cFilter1)
         oBrw:GoTop()
         oRec:Load(.t.)
      else
         cId := strzero(oRec:RecNo,4)
     Endif

  DEFINE FONT oFont NAME "TAHOMA" SIZE 0, 15
   DEFINE DIALOG oDlg SIZE 422, 326 PIXEL ; //FROM 100, 100 TO 426,522;
   TITLE If( lAdd, "New Service", "Edit Service" ) FONT oFont ;
    COLOR CLR_BLACK,CLR_WHITE TRANSPARENT

  @ 12, 10 SAY "Code:" OF oDlg SIZE 19, 8 PIXEL
  @ 10, 46 GET aGet[1] VAR  cId   OF oDlg SIZE 25, 12 PIXEL;
       VALID If( Empty( cId ), ( MsgInfo( NO_EMPTY ), .f. ), ;
            If( Duplicate( cId, "ID", oRec:RecNo,oServizi,aGet[1] ), ( MsgInfo( YES_DUPLICATE ), .f. ), ;
            .t. ) )


// this is wrong ?

Code (fw): Select all Collapse
 If lAdd
         oBrw:oDbf:clearFilter()
         oRec:gobottom()
         cId:= strzero(oRec:RecNo+1,4)
         oBrw:oDbf:setFilter( cFilter1)
         oBrw:oDbf:GoTop()
         oRec:Load(.t.)
      else
         cId := strzero(oRec:RecNo,4)
     Endif



I cannot make it ?
SomeOne sad me it is wrong and I cannot make it..

wich is the problem ?
can you explain me ?

thanks
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)

I use : FiveWin for Harbour March-April 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
Posts: 4043
Joined: Wed Dec 19, 2007 06:40 PM
Re: To Nages: tdatarow add new
Posted: Wed Feb 06, 2019 06:23 PM
Silvio,

instead of < filter > i'm normally using ORDSCOPE
in my old programs ( much faster ) and never noticed a problem.

using with tDatabase something like :

oCust:ORDSCOPE(0, Empty(oCust:LAST) ) // set top scope
oCust:ORDSCOPE(1, Empty(oCust:LAST) ) // set bottom to NIL
or using
oCust:MARRIED = .T.
oCust:Age > 30

oCust:ordScope(0, NIL ) // set top to NIL
oCust:ordScope(1, NIL ) // set bottom to NIL

from tDatabase
METHOD ordScope( nScopeType, uValue )

doesn't show any xBrowse-result :-)

a new test
I only want to show customers with the range names "Co"



regards
Uwe :-)
Since 1995 ( the first release of FW 1.9 )

i work with FW.

If you have any questions about special functions, maybe i can help.
Posts: 1283
Joined: Fri Feb 10, 2006 02:34 PM
Re: To Nages: tdatarow add new
Posted: Thu Feb 07, 2019 07:34 AM

Uwe,

After ordScope you should to do a GoTop

Salutacions, saludos, regards

"...programar es fácil, hacer programas es difícil..."

UT Page -> https://carles9000.github.io/
Forum UT -> https://discord.gg/bq8a9yGMWh
HIX -> https://github.com/carles9000/hix
Posts: 7318
Joined: Thu Oct 18, 2012 07:17 PM
Re: To Nages: tdatarow add new
Posted: Thu Feb 07, 2019 07:41 AM
Uwe,
the problem not is the filter or the ordscope or How show the xbrowse
the problem is another, how add a new record with a field caracter used for incremental code
Someone sad that this part is wrong, because the final user must not see the code (cId) when he add new record

Code (fw): Select all Collapse
    
      If lAdd
             oBrw:oDbf:clearFilter()
             oRec:gobottom()
             cId:= strzero(oRec:RecNo+1,4)
             oBrw:oDbf:setFilter( cFilter1)
             oBrw:oDbf:GoTop()
             oRec:Load(.t.)
          else
             cId := strzero(oRec:RecNo,4)
         Endif


I wish Know if this is correct (to do) or not
the problem is when I save the record I can save two records with two same numbers
but it 's no correct for me not show the cid
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)

I use : FiveWin for Harbour March-April 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com

Continue the discussion