Mr. Rao Pls your help

Mr. Rao Pls your help

Postby Armando » Fri Jan 29, 2021 6:40 pm

Hi. Mr. Rao:

Would you help us, we need make a tree in a xBrowse, this is our
code but it does not show us the records, why?

Code: Select all  Expand view

#include "fivewin.ch"
#Include "Ado.ch"

FUNCTION TestTree()
   LOCAL oRsLoc, oDlg, oFont, oBrw

   oRsLoc := FW_OpenRecordSet(oApp:oCon,"SELECT " +;
                                          "* " +;
                                       "FROM " +;
                                          "Locales ",;
                                       "ORDER BY " +;
                                          "LOC_CAL,LOC_LOC",adLockOptimistic,adOpenDynamic,0)

   oRsLoc:MoveFirst()

   DEFINE FONT oFont NAME "TAHOMA" SIZE 0,-14
    DEFINE DIALOG oDlg RESOURCE "TestTree"

        REDEFINE XBROWSE oBrw ID 200 OF oDlg;
            DATASOURCE oRsLoc;
            COLUMNS "LOC_CAL","LOC_LOC","LOC_GAS","LOC_LUZ","LOC_AGU","LOC_REN";
            HEADERS "Calle/Local","Local","Gastos","Luz","Agua","Arriendo";
         CELL LINES NOBORDER

         WITH OBJECT oBrw
            :SetTree( 2 )
            :oTree:OpenAll()
            :lDisplayZeros := .f.
         END

   ACTIVATE DIALOG oDlg CENTERED
   oFont:END()
RETURN(NIL)
 


With best 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
Armando
 
Posts: 3076
Joined: Fri Oct 07, 2005 8:20 pm
Location: Toluca, México

Re: Mr. Rao Pls your help

Postby nageswaragunupudi » Sat Jan 30, 2021 4:26 am

This seems to be working with DBF but not ADO.
We are looking into it and will come back to you.
Please give us a little time.
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10295
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: Mr. Rao Pls your help

Postby richard-service » Sat Jan 30, 2021 10:48 am

nageswaragunupudi wrote:This seems to be working with DBF but not ADO.
We are looking into it and will come back to you.
Please give us a little time.


Dear Mr.Rao

How about use TMySQL? Compatible?
Best Regards,

Richard

Harbour 3.2.0dev (r2402101027) => Borland C++ v7.7 32bit
MySQL v5.7 /ADS v10
Harbour 3.2.0dev (r2011030937) => Borland C++ v7.4 64bit
User avatar
richard-service
 
Posts: 770
Joined: Tue Oct 16, 2007 8:57 am
Location: New Taipei City, Taiwan

Re: Mr. Rao Pls your help

Postby Armando » Sat Jan 30, 2021 3:10 pm

Mr. Rao:

Don't worry, take your time.

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
Armando
 
Posts: 3076
Joined: Fri Oct 07, 2005 8:20 pm
Location: Toluca, México

Re: Mr. Rao Pls your help

Postby Armando » Sat Jan 30, 2021 3:45 pm

Mr. Richard:

I'm afraid not yet.

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
Armando
 
Posts: 3076
Joined: Fri Oct 07, 2005 8:20 pm
Location: Toluca, México

Re: Mr. Rao Pls your help

Postby nageswaragunupudi » Sat Jan 30, 2021 8:01 pm

richard-service wrote:
nageswaragunupudi wrote:This seems to be working with DBF but not ADO.
We are looking into it and will come back to you.
Please give us a little time.


Dear Mr.Rao

How about use TMySQL? Compatible?


It should work with TMySql as it is.
It worked for me with FWH built-in MySql library.
This is my test.
Code: Select all  Expand view
  oCn := maria_Connect( "localhost,fwh,root,password" )
   oRs := oCn:RowSet( "select * from customer order by state,city" )

   DEFINE DIALOG oDlg SIZE 800,600 PIXEL TRUEPIXEL
   @ 20,20 XBROWSE oBrw SIZE -20,-20 PIXEL OF oDlg ;
      DATASOURCE oRs ;
      COLUMNS "STATE", "CITY", "FIRST", "SALARY" ;
      CELL LINES NOBORDER

   oBrw:lDisplayZeros := .f.
   oBrw:SetTree( 2 )
   oBrw:CreateFromCode()

   ACTIVATE DIALOG oDlg CENTERED //ON INIT oBrw:SetTree( 2 )
 

Please try with TMySql and let us know.
You need to use "ORDERBY fld1, fld2" in your query and then use the same fld1,fld2 as the first two fields in xBrowse.

Problem is only with ADO.
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10295
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: Mr. Rao Pls your help

Postby Armando » Sat Jan 30, 2021 11:59 pm

Mr. Rao:

Many thanks, I don't use TMySql at all. Just FWH, MySQL & ADO. :cry:

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
Armando
 
Posts: 3076
Joined: Fri Oct 07, 2005 8:20 pm
Location: Toluca, México

Re: Mr. Rao Pls your help

Postby nageswaragunupudi » Sun Jan 31, 2021 12:49 pm

My reply about TMySql was intended for Mr. Richard.
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10295
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: Mr. Rao Pls your help

Postby nageswaragunupudi » Sun Jan 31, 2021 1:24 pm

The facility to convert a normal browse of ordered data into a Tree browse by calling oBrw:SetTree( nLevels, [aBitmaps] ) is working in case of datasources, which accept GOTO( 0 ) (similar to :BookMark := 0) and when Eof() returns blank values for fields. So, this is working with DBF, RowSets, Arrays, etc, but not with ADO.

Setting oRs:Bookmark := 0.0 errors out and when oRs:Eof() we can not access any field values.

For this reason, we need to modify xbrowse to handle ADO recordsets. These modifications are made in FWH 21.01.

We publish here the changes you can make to xbrowse.prg to make it work for ADO recordsets.

1) Please locate this line of code in the method SetTree(...) (line 7790 in FWH 2012)
Code: Select all  Expand view

      bOnSkip     := { || Eval( bBookMark, ::oTreeItem:cargo ) }
 

Please replace this single line code with the following code:
Code: Select all  Expand view

      if lAnd( ::nDataType, DATATYPE_ADO )
         bOnSkip     := { || If( Empty( ::oTreeItem:Cargo ),,Eval( bBookMark, ::oTreeItem:cargo ) ) }
         AEval( ::aCols, { |o| AdoTreeBlocks( o ) }, nLevels + 1 )
      else
         bOnSkip     := { || Eval( bBookMark, ::oTreeItem:cargo ) }
      endif
 


After making this change, add this static function anywhere in the xbrowse.prg.
Code: Select all  Expand view

static function AdoTreeBlocks( oCol )

   local bEditValue  := oCol:bEditValue
   local oBrw        := oCol:oBrw

   oCol:bEditValue := { |x,o| If( Empty( oBrw:oTreeItem:Cargo ), ;
                              uValBlank( Eval( bEditValue ) ), ;
                              Eval( bEditValue, x, o ) ) }


return nil
 


With these two changes, your application code will work as expected.
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10295
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: Mr. Rao Pls your help

Postby nageswaragunupudi » Sun Jan 31, 2021 2:14 pm

We discussed how to convert a normal browse of ordered data into a tree-browse at runtime. This is provided as an extra feature.

Still, the normal and standard way is to first create a tree object from the data and then browse the tree object.

Here is an example:
Code: Select all  Expand view
#include "fivewin.ch"

function Main()

   local oCn, oRs, oTree, tmp
   local oDlg, oBrw

   oCn   := FW_OpenAdoConnection( "xbrtest.mdb" )
   if oCn == nil
      return nil
   endif
   oRs   := FW_OpenRecordSet( oCn, "SELECT * FROM CUSTOMER ORDER BY STATE,CITY,FIRST" )

   oRs:MoveFirst()
   TREE oTree
      do while !oRs:Eof()
         TREEITEM oRs:Fields( "state" ):Value ;
            CARGO { uValBlank( oRs:Fields( "first" ):Value ), uValBlank( oRs:Fields( "salary" ):Value ) }
         tmp := oRs:Fields( "state" ):Value
         TREE
         do while !oRs:Eof() .and. oRs:Fields( "state" ):Value == tmp
            TREEITEM oRs:Fields( "city" ):Value CARGO { oRs:Fields( "first" ):Value, oRs:Fields( "salary" ):Value }
            oRs:MoveNext()
         enddo
         ENDTREE
      enddo
   ENDTREE
   oRs:MoveFirst()
   oTree:OpenAll()

   DEFINE DIALOG oDlg SIZE 550,600 PIXEL TRUEPIXEL
   @ 20,20 XBROWSE oBrw SIZE -20,-20 PIXEL OF oDlg ;
      DATASOURCE oTree COLUMNS 1, 2 ;
      HEADERS "STATE>CITY", "FIRST", "SALARY" ;
      CELL LINES NOBORDER

   oBrw:lDisplayZeros := .f.
   oBrw:CreateFromCode()

   ACTIVATE DIALOG oDlg CENTERED

return nil
 


Image
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10295
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: Mr. Rao Pls your help

Postby Marcelo Roggeri » Sun Apr 17, 2022 10:18 pm

Buenas noches Mr Rao, que bueno se podría totaliza en la cabecera del grupo el total del SALARY?
Seria interesante
Saludos
FWH - Harbour - BCC7 - PellesC
User avatar
Marcelo Roggeri
 
Posts: 325
Joined: Sat Jul 22, 2006 9:04 pm
Location: Venado Tuerto - Santa Fe -Argentina

Re: Mr. Rao Pls your help

Postby nageswaragunupudi » Mon Apr 18, 2022 3:44 am

Code: Select all  Expand view
#include "fivewin.ch"

function Main()

   local oCn, oRs, oTree, tmp, oState
   local oDlg, oBrw

   oCn   := FW_OpenAdoConnection( "xbrtest.mdb" )
   if oCn == nil
      return nil
   endif
   oRs   := FW_OpenRecordSet( oCn, "SELECT * FROM CUSTOMER ORDER BY STATE,CITY,FIRST" )

   oRs:MoveFirst()
   TREE oTree
      do while !oRs:Eof()
         TREEITEM oState PROMPT oRs:Fields( "state" ):Value ;
            CARGO { uValBlank( oRs:Fields( "first" ):Value ), uValBlank( oRs:Fields( "salary" ):Value ) }
         tmp := oRs:Fields( "state" ):Value
         TREE
         do while !oRs:Eof() .and. oRs:Fields( "state" ):Value == tmp
            TREEITEM oRs:Fields( "city" ):Value CARGO { oRs:Fields( "first" ):Value, oRs:Fields( "salary" ):Value }
            oState:Cargo[ 2 ] += oRs:Fields( "salary" ):Value
            oRs:MoveNext()
         enddo
         ENDTREE
      enddo
   ENDTREE
   oRs:MoveFirst()
   oTree:OpenAll()

   DEFINE DIALOG oDlg SIZE 550,600 PIXEL TRUEPIXEL
   @ 20,20 XBROWSE oBrw SIZE -20,-20 PIXEL OF oDlg ;
      DATASOURCE oTree COLUMNS 1, 2 ;
      HEADERS "STATE>CITY", "FIRST", "SALARY" ;
      PICTURES nil, nil, "99,999,999.00" ;
      CELL LINES NOBORDER

   oBrw:lDisplayZeros := .f.
   oBrw:bClrStd   := { || { CLR_BLACK, If( oBrw:oTreeItem:nLevel == 1, CLR_YELLOW, CLR_WHITE ) } }
   oBrw:CreateFromCode()

   ACTIVATE DIALOG oDlg CENTERED

return nil


Image
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10295
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: Mr. Rao Pls your help

Postby Marcelo Roggeri » Mon Apr 18, 2022 12:11 pm

Buenísimo y rapidísimo Mr Rao, muchas gracias
Saludos
FWH - Harbour - BCC7 - PellesC
User avatar
Marcelo Roggeri
 
Posts: 325
Joined: Sat Jul 22, 2006 9:04 pm
Location: Venado Tuerto - Santa Fe -Argentina


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot] and 22 guests