Xbrowse con FASTEDIT y RECORDSET

Post Reply
User avatar
Armando
Posts: 2479
Joined: Fri Oct 07, 2005 8:20 pm
Location: Toluca, México
Contact:

Xbrowse con FASTEDIT y RECORDSET

Post by Armando »

Hola Amigos del foro:

Como el título dice, alguien que me tire un pequeño ejemplo de un xBrowse, FASTEDIT
pero atacando un RECORDSET, he buscado aquí y lo que encontré es atacando un ARRAY.

Saludos y muchas gracias
SOI, s.a. de c.v.
estbucarm@gmail.com
http://www.soisa.mex.tl/
http://sqlcmd.blogspot.com/
Tel. (722) 174 44 45
Carpe diem quam minimum credula postero
User avatar
nageswaragunupudi
Posts: 8017
Joined: Sun Nov 19, 2006 5:22 am
Location: India
Contact:

Re: Xbrowse con FASTEDIT y RECORDSET

Post by nageswaragunupudi »

XBrowse syntax and functionality is identical whatever be the datasource, eg. DBF, TDatabase, ADO RecordSet, MySql/PostGre QueryObject, etc.

Please copy this sample program to your fwh\samples folder and build with buildh.bat or buildx.bat or any build????.bat
Please notice that XBrowse and TDataRow work exactly the same way with identical syntax for all datasources.

Code: Select all

#include "fivewin.ch"

REQUEST DBFCDX

static aSource := { "DBF", "TDataBase", "ADO.MSSQL", "MYSQL" }
static oCn, nSource, uData

//----------------------------------------------------------------------------//

function Main()

   RDDSETDEFAULT( "DBFCDX" )
   SET DELETED ON
   SetGetColorFocus()
   FWNumFormat( "E", .t. )

   REPEAT
      nSource := Alert( "SELECT DATASOURCE", aSource )
      if nSource > 0
         OpenData()
         BrowseData()
         CloseData()
      endif
   UNTIL nSource == 0

return nil

//----------------------------------------------------------------------------//

static function BrowseData()

   local oDlg, oFont, oBar, oBrw

   DEFINE FONT oFont NAME "TAHOMA" SIZE 0,-14
   DEFINE DIALOG oDlg SIZE 900,600 PIXEL TRUEPIXEL FONT oFont TITLE aSource[ nSource ]
   DEFINE BUTTONBAR oBar OF oDlg SIZE 100,32 2007
   DEFINE BUTTON OF oBar PROMPT "Add"    ACTION oBrw:EditSource( .T. )
   DEFINE BUTTON OF oBar PROMPT "Edit"   ACTION oBrw:EditSource()
   DEFINE BUTTON OF oBar PROMPT "Delete" ACTION oBrw:Delete()
   DEFINE BUTTON OF oBar PROMPT "Excel"  ACTION oBrw:ToExcel() GROUP
   DEFINE BUTTON OF oBar PROMPT "Report" ACTION oBrw:Report()
   DEFINE BUTTON OF oBar PROMPT "Close"  ACTION oDlg:End() GROUP

   @ 40,20 XBROWSE oBrw SIZE -20,-20 PIXEL OF oDlg ;
      DATASOURCE uData ; // Alias, TDatabase Object, RecordSet or MySql/PostGre query object
      COLUMNS "ID", "FIRST", "CITY", "STATE", "AGE", "SALARY" ;
      CELL LINES NOBORDER FOOTERS FASTEDIT

   WITH OBJECT oBrw
      :nEditTypes          := EDIT_GET
      :Salary:nFooterType  := AGGR_SUM
      :MakeTotals()
      //
      :CreateFromCode()
   END

   ACTIVATE DIALOG oDlg CENTERED
   RELEASE FONT oFont

return nil

//----------------------------------------------------------------------------//

static function OpenData()

   do case
   case nSource == 1
      USE CUSTOMER NEW ALIAS "CUST" SHARED VIA "DBFCDX"
      uData    := ALIAS()
   case nSource == 2
      uData    := TDataBase():Open( nil, "CUSTOMER", "DBFCDX", .t. )
   case nSource == 3
      oCn      := FW_MSSQLDB()
      uData    := FW_OpenRecordSet( oCn, "customer" )
   case nSource == 4
      oCn      := FW_DemoDB()
      uData    := oCn:RowSet( "customer" )
   endcase

return uData

//----------------------------------------------------------------------------//

static function CloseData()

   if nSource == 1
      ( uData )->( DBCLOSEAREA() )
   else
      uData:Close()
      if oCn != nil
         oCn:Close()
      endif
   endif

return nil

//----------------------------------------------------------------------------//
 
Regards

G. N. Rao.
Hyderabad, India
User avatar
Armando
Posts: 2479
Joined: Fri Oct 07, 2005 8:20 pm
Location: Toluca, México
Contact:

Re: Xbrowse con FASTEDIT y RECORDSET

Post by Armando »

Mr.Rao:
}
Thanks so much, I will.

Regards
SOI, s.a. de c.v.
estbucarm@gmail.com
http://www.soisa.mex.tl/
http://sqlcmd.blogspot.com/
Tel. (722) 174 44 45
Carpe diem quam minimum credula postero
User avatar
damianodec
Posts: 372
Joined: Wed Jun 06, 2007 2:58 pm
Location: Italia
Contact:

Re: Xbrowse con FASTEDIT y RECORDSET

Post by damianodec »

this is my code:

Code: Select all

...
tuple = "select cod, qta from tbart where cod = 'ESA10"
oRs := FW_OpenRecordSet( oCn, tuple )

    DEFINE DIALOG oDlg2 SIZE 1000,600 PIXEL  FONT oFont

    @ 40,10 XBROWSE oBrw SIZE -10,-50 PIXEL CELL AUTOCOLS AUTOSORT FASTEDIT ;
      RECORDSET oRs ;
      HEADERS "CODICE", "QUANTITA'" ;
      PICTURE NIL, "@ZE 99999999.999" ;
      OF oDlg2  

       WITH OBJECT oBrw
          :nEditTypes          := EDIT_GET
          :CreateFromCode()
       END  
...  
 
when I edit qta field (i.e. from 10 to 8) value on display not change, it is always 10 but if I exit and run pgm qta is 8.

any help?
FiveWin for xHarbour 17.09 - Sep. 2017 - Embarcadero C++ 7.00 for Win32
FWH 64 for Harbour 19.06 (MSVC++) Jun. 2019 - Harbour 3.2.0dev (r1904111533)
Visual Studio 2019 - Pelles C V.8.00.60 (Win64)
User avatar
Armando
Posts: 2479
Joined: Fri Oct 07, 2005 8:20 pm
Location: Toluca, México
Contact:

Re: Xbrowse con FASTEDIT y RECORDSET

Post by Armando »

Damiano:

Muchas gracias.

Thanks a lot.

Saludos
Regards
SOI, s.a. de c.v.
estbucarm@gmail.com
http://www.soisa.mex.tl/
http://sqlcmd.blogspot.com/
Tel. (722) 174 44 45
Carpe diem quam minimum credula postero
User avatar
damianodec
Posts: 372
Joined: Wed Jun 06, 2007 2:58 pm
Location: Italia
Contact:

Re: Xbrowse con FASTEDIT y RECORDSET

Post by damianodec »

hi,
my post is a question for mr.Rao
FiveWin for xHarbour 17.09 - Sep. 2017 - Embarcadero C++ 7.00 for Win32
FWH 64 for Harbour 19.06 (MSVC++) Jun. 2019 - Harbour 3.2.0dev (r1904111533)
Visual Studio 2019 - Pelles C V.8.00.60 (Win64)
Post Reply