To Nages: tdatarow add new

To Nages: tdatarow add new

Postby Silvio.Falconi » Wed Feb 06, 2019 12:48 pm

is there something of Wrong ?

I open Servizi on two xbrowse
Code: Select all  Expand view
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: Select all  Expand view


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: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

  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: Select all  Expand view
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 November 2023 - January 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
User avatar
Silvio.Falconi
 
Posts: 6834
Joined: Thu Oct 18, 2012 7:17 pm

Re: To Nages: tdatarow add new

Postby ukoenig » Wed Feb 06, 2019 6: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"

Image

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.
User avatar
ukoenig
 
Posts: 4043
Joined: Wed Dec 19, 2007 6:40 pm
Location: Germany

Re: To Nages: tdatarow add new

Postby Carles » Thu Feb 07, 2019 7: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
Skype -> https://join.skype.com/cnzQg3Kr1dnk
User avatar
Carles
 
Posts: 1101
Joined: Fri Feb 10, 2006 2:34 pm
Location: Barcelona

Re: To Nages: tdatarow add new

Postby Silvio.Falconi » Thu Feb 07, 2019 7: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: Select all  Expand view
   
      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 November 2023 - January 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
User avatar
Silvio.Falconi
 
Posts: 6834
Joined: Thu Oct 18, 2012 7:17 pm


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 60 guests