Page 1 of 1

where do I get an example xBrowse (TDolphin)? *Fixed*

Posted: Mon Jun 16, 2014 8:40 am
by dutch
Dear All,

I try to move to MySql with xBrowse but I cannot fine absolutely simple example in the group.

Can anyone show an example to use xBrowse MySql via TDolphin or TMySql.
Like

Code: Select all

@  0, 0 XBROWSE COLUMNS oQry:Field1, oQry:Field2 ;
                          HEADERS 'Field1 Header', 'Field2 Header' ;
                          DATASOURCE oQry ;
                          ....
 
I can make from XBROWSER( oQry ) but it is not user define columns.

Thanks in advance,

Re: where do I get an example xBrowse & (TMySql or TDolphin)?

Posted: Mon Jun 16, 2014 2:54 pm
by FranciscoA
dutch: This is the way I do. Maybe it helps you. (MYSQL)

Code: Select all

1-
oQry:=oServer:Query("SELECT fechemis,td,numdoc,concepto,SUM(debe) debitos, SUM(haber) creditos, SUM(debe-haber) Diferencia, codibancos FROM " + cTablaFuente + " GROUP BY numdoc HAVING SUM(debe-haber) != 0;")

if oQry:LastRec() != 0
   xBrowse(oQry," DOCUMENTOS")
endif
oQry:End()
Return nil

.or.
//---------------------------------//
2-
oQry := oServer:Query("SELECT * FROM comprobd ORDER BY numdoc ;")
oQry:Gotop()
   
  oLbx := TXBrowse():New( oDlg ) 
  oLbx:SetMySql(oQry,.f.)

  oCol = oLbx:AddCol()
  oCol:bStrData = { || Transform( oQry:NumCD,"9999999999")  }
  oCol:cHeader = "Num/CD" 
  oCol:nWidth = 70
  oCol:nFootStrAlign := 1

  oCol = oLbx:AddCol()
  oCol:bStrData = { || DtoC(oQry:Fechemis) }
  oCol:nDataStrAlign := 1
  oCol:cHeader = "Fecha" 
  oCol:nWidth = 66
 
Regards.

Re: where do I get an example xBrowse & (TMySql or TDolphin)?

Posted: Mon Jun 16, 2014 10:19 pm
by Adolfo
Ducth, I tested all the options to work with Mysql, now I'm working with tDolphin with no problem at all, locally, in LAN, WEB.

There´s plenty of samples in tDolphin's web http://tdolphin.blogspot.com/ and in samples directory in tDolhpin´s installation

If you have any problem, send me a private mail

From Chile
Adolfo

Re: where do I get an example xBrowse & (TMySql or TDolphin)?

Posted: Wed Jun 18, 2014 3:07 am
by ShumingWang

Re: where do I get an example xBrowse & (TMySql or TDolphin)?

Posted: Thu Jun 19, 2014 12:16 am
by nageswaragunupudi
dutch wrote:Dear All,

I try to move to MySql with xBrowse but I cannot fine absolutely simple example in the group.

Can anyone show an example to use xBrowse MySql via TDolphin or TMySql.
Like

Code: Select all

@  0, 0 XBROWSE COLUMNS oQry:Field1, oQry:Field2 ;
                          HEADERS 'Field1 Header', 'Field2 Header' ;
                          DATASOURCE oQry ;
                          ....
 
I can make from XBROWSER( oQry ) but it is not user define columns.

Thanks in advance,
Just the same way as you write code for DBF or ADO RecordSet.

Code: Select all

oQry := oSrv:Query( "SELECT * FROM CUSTOMER" )
@ 0,0 XBROWSE oBrw OF oWnd DATASOURCE oQry ;
COLUMNS "First", "Last", "Salary"  ;
HEADERS "FirstName", "SurName", "Salary" <otherclauses>
 
If anyone knows how to code xbrowse for DBF, he already knows coding for any other datasource, be it TDataBase, ADO RecordSet, TMySql or TDolphin or any other.

Exactly the same code works for all. Only difference is the value for the clause DATASOURCE.

For example, in this statement:

Code: Select all

@ 0,0 XBROWSE oBrw OF oWnd DATASOURCE uVar ;
COLUMNS "First", "Last", "City", "Salary" <otherclauses>
 
if uVar is caharacter variable and is an alias name, it is DBF browse.
If uvar is an object and a recordset, it is ADO browse
If uvar is an object and TMySql/TDolphin Query, then it is TMySql/TDolphin Query
If uVar is an object and TDatabase class, it is TDatabase browse.
If uvar is an object and is oTree it is tree browse.
If uvar is an object and has Ado properties, it is properties browse.
If uvar is any other object, it browses the datas of the object.

Re: where do I get an example xBrowse (TDolphin)? *Fixed*

Posted: Thu Jun 19, 2014 1:29 pm
by nageswaragunupudi
You modified the title as *Fixed*.
Is the xbrowse with Dolphin working well for you?
If so can you post a sample xbrowse command you have used?

Re: where do I get an example xBrowse (TDolphin)? *Fixed*

Posted: Fri Jun 20, 2014 1:35 am
by dutch
Dear Mr.Rao,

Thank you for your kind help, this is the code (sample from Daniel Blog) that working now.

Code: Select all

#include "fivewin.ch"
#include "xbrowse.ch"
#include "ribbon.ch"
#include "hbcompat.ch"

FUNCTION Main()

   LOCAL oDlg
   LOCAL aBtns := Array( 5 )
   LOCAL oBrw, oQry, oServer
   local cValType

   
   D_SetCaseSensitive( .T. )
   
   IF ( oServer := ConnectTo() ) == NIL
      msgalert('cannot connect to server')
      RETURN NIL
   ENDIF
   oServer:bDebug = {| cQry | LogFile( "debuf.log", {cQry} ) }
   
   oQry = oServer:Query( "SELECT * FROM rmty_avl") // where rta_rmty='LOB'" )
   
   oQry:SetPages( 100 )
   oQry:bOnChangePage = { || oBrw:Refresh(), ChangeTitle( oQry, oDlg ) }

//   cValType := valtype( oQry:FieldGet( 'rta_stamp' )) return "C"
//   cValType := oQry:FieldType( 'rta_stamp' )      return "T"
//   cValType := valtype( oQry:rta_stamp )          return "C"

//   msginfo(cValType)

   DEFINE DIALOG oDlg TITLE "Current Page: " + StrZero( oQry:nCurrentPage, 5 ) + " / " + StrZero( oQry:nMaxPages, 5 ) SIZE 565, 480 
   

   BuildButtons( aBtns, oDlg, oQry )

   @ 30, 10 XBROWSE oBrw OF oDlg DATASOURCE oQry ;
            COLUMNS "rta_date", "rta_rmty", "rta_tlrm", "rta_occ" ;
            COLSIZES 100, 100, 100, 100 ;
            HEADERS "Date", "RmTy", "Total Room", "Occupied" ;
            PIXEL SIZE 260, 200 LINES ;
            UPDATE

//          AUTOCOLS AUTOSORT PIXEL SIZE 260, 200 LINES

// Uncomment this line for fivewin version < 10.7   
//   SetDolphin( oBrw, oQry )
   
   oBrw:CreateFromCode()
      
   ACTIVATE DIALOG oDlg CENTERED
   
   
RETURN NIL


PROCEDURE BuildButtons( aBtns, oDlg, oQry )
   LOCAL nPage


   @ 10, 10 RBBTN aBtns[ 1 ] PROMPT "&First" OF oDlg SIZE 20, 15 ;
            GROUPBUTTON FIRST  CENTER ;
            ROUND ROUNDSIZE 2;
            ACTION( oQry:FirstPage() ) ;
            WHEN( oQry:nCurrentPage > 1 )                    

   @ 10, 30 RBBTN  aBtns[ 2 ] PROMPT "&Prev" OF oDlg SIZE 20, 15 ;
            GROUPBUTTON  CENTER ;
            ROUND ROUNDSIZE 2;
            ACTION( oQry:PrevPage() ) ;
            WHEN( oQry:nCurrentPage > 1 )

   @ 10, 50 RBBTN aBtns[ 3 ] PROMPT "&Goto" OF oDlg SIZE 20, 15 ;
             GROUPBUTTON  CENTER ;
             ROUND ROUNDSIZE 2;
             ACTION( nPage := oQry:nCurrentPage,;
                     MsgGet( "Select Page:", "Page", @nPage ),;
                     oQry:GoToPage( nPage ) )

  
   @ 10, 70 RBBTN aBtns[ 4 ] PROMPT "&Next" OF oDlg SIZE 20, 15 ;
             GROUPBUTTON  CENTER ;
             ROUND ROUNDSIZE 2;
             ACTION( oQry:NextPage() ) ;
             WHEN( oQry:nCurrentPage < oQry:nMaxPages )

   @ 10, 90 RBBTN aBtns[ 5 ] PROMPT "&Last" OF oDlg SIZE 20, 15 ;
             GROUPBUTTON END  CENTER ;
             ROUND ROUNDSIZE 2;             
             ACTION( oQry:LastPage() ) ;
             WHEN( oQry:nCurrentPage < oQry:nMaxPages )


RETURN 

PROCEDURE ChangeTitle( oQry, oDlg )

   oDlg:cTitle = "Current Page: " + StrZero( oQry:nCurrentPage, 5 ) + " / " + StrZero( oQry:nMaxPages, 5 )
   
RETURN

#include "connto.prg"
#include "setbrw.prg"  
 
nageswaragunupudi wrote:You modified the title as *Fixed*.
Is the xbrowse with Dolphin working well for you?
If so can you post a sample xbrowse command you have used?