problem with xBrowse and TDatarow

problem with xBrowse and TDatarow

Postby lucasdebeltran » Tue Jun 11, 2013 12:16 pm

Hello,

I have an xBrowse with action buttons for Add, Delete, Modify, Print, etc.

After adding a Record with ADO and TDataRow, despite I add oBrowse:refresh(), the browse is not refreshed:

This is the code:

Code: Select all  Expand view  RUN


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

   LOCAL oDlg                         // Objeto Diálogo
   LOCAL oRs, oData
   LOCAL oBrowse


   //
   // RecordSet
   //-----------
   oRs   := ado_AbreRecordSet( "select * from APUNTES order by APUNTE ASC"  )

   IF oRs = nil
      RETURN NIL
   ENDIF





   //
   // Caja de Diálogo -----------------------------------------------------
   DEFINE DIALOG oDlg RESOURCE "APUNTES" ;
                      TITLE "Mantenimiento"


   REDEFINE XBROWSE oBrowse  ID 101 OF oDlg ;
            DATASOURCE oRs ;
            AUTOCOLS AUTOSORT CELL LINES


   // Estilo-----------
   oBrowse:nMarqueeStyle       := 5 //9 // 5 por defecto MARQSTYLE_IDESOFT
   oBrowse:nHeaderLines        := 1.5
   oBrowse:nStretchCol         := STRETCHCOL_LAST
   oBrowse:lAllowColHiding     := .F.   // Impedir tocar columnas


   oBrowse:blDblClick := { || (  AltasApuntes( .F., oRs:AbsolutePosition ) ) }
   oBrowse:bKeyDown := { | nKey, nFlags | IF (nKey==VK_RETURN, oDlg:End(), ),;
                             IF (nKey==VK_ESCAPE, oDlg:End(), ) }





   REDEFINE BUTTON ID 711 OF oDlg ;
                  ACTION( AltasApuntes( .T. ), ;
                          oBrowse:Refresh() )

   REDEFINE BUTTON ID 712 OF oDlg ;
                  ACTION( ado_Borrar( oRs ), ;
                          oBrowse:Refresh() )

   REDEFINE BUTTON ID 713 OF oDlg ;
                  ACTION( AltasApuntes( .F., oRs:AbsolutePosition ), ;
                          oBrowse:Refresh() )

   REDEFINE BUTTON ID 716 OF oDlg ACTION( oDlg:End() )




   ACTIVATE DIALOG oDlg CENTERED ON INIT oBrowse:SetFocus()


   ado_CierraRecordSet( oRs )



// ---------------------------------------------------------------------------
FUNCTION AltasApuntes( lAppend, nRegistro )

   LOCAL oDlg                         // Objeto Diálogo
   LOCAL oRs, oData
   LOCAL lSave       := .F.            // Grabado




   //
   // Seleccionamos RecordSet
   //-------------------------
   oRs   := ado_AbreRecordSet( "select * from APUNTES order by APUNTE ASC"  )

   IF oRs = nil
      RETURN NIL
   ENDIF





   IF lAppend                         // Si hay que a¤adir
      oData := TDataRow():New( oRs, nil, .t. )
      oData:Fecha := Date()

   ELSE
      oRs:AbsolutePosition := nRegistro  // Goto
      oData := TDataRow():New( oRs )

   ENDIF


[...]



   REDEFINE GET oData:Fecha        ID  20 OF oDlg  PICTURE "@D"

   REDEFINE GET oData:Cuenta       ID  21 OF oDlg  PICTURE "@E 9999"


   REDEFINE BUTTON ID 701 OF oDlg  ACTION( lSave := .T., oDlg:End() )
   REDEFINE BUTTON ID 702 OF oDlg  ACTION( lSave := .F., oDlg:End() )



   ACTIVATE DIALOG oDlg CENTERED





   IF lSave // .AND. !Empty( oData:cCuenta ) .AND. !cDebeHaber = "Seleccione"
      oData:Save()
   ENDIF
   // ---------------------------------------------------------------------




   ado_CierraRecordSet( oRs )



RETURN NIL
// ---------------------------------------------------------------------------




 




Anything else has to be done for ADO?.

Thank you. Best regards-.
Muchas gracias. Many thanks.

Un saludo, Best regards,

Harbour 3.2.0dev, Borland C++ 5.82 y FWH 13.06 [producción]

Implementando MSVC 2010, FWH64 y ADO.

Abandonando uso xHarbour y SQLRDD.
User avatar
lucasdebeltran
 
Posts: 1303
Joined: Tue Jul 21, 2009 8:12 am

Re: problem with xBrowse and TDatarow

Postby nageswaragunupudi » Tue Jun 11, 2013 3:21 pm

Please first build the sample below and test.

You see that same code of XBrowse and TDataRow works for DBF, TDatabase and ADO. You can test all options.

Code: Select all  Expand view  RUN
/*
* tstdrow.prg
* test TDataRow usage
*
*/


#include "fivewin.ch"
#include "xbrowse.ch"

REQUEST DBFCDX

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

function Main()

   local oCn
   local nChoice, uDataSource

   SET DATE ITALIAN
   SET CENTURY ON
   SET DELETED ON
   FWNumFormat( "A", .t. )

   nChoice := Alert( "Choose DataSource", { "DBF", "TDATABASE", "ADO", "Quit" }, "DATASOURCE" )
   if nChoice  <= 2
      USE C:\FWH\SAMPLES\CUSTOMER NEW ALIAS CUST SHARED VIA "DBFCDX"
      if nChoice == 1
         uDataSource    := Alias()
      else
         DATABASE uDataSource
      endif
   elseif nChoice == 3
      oCn         := FW_OpenAdoConnection( "c:\fwh\samples\xbrtest.mdb" )
      uDataSource := FW_OpenRecordSet( oCn, "CUSTOMER" )
   else
      return nil
   endif

   BrowseData( uDataSource )

   if nChoice == 1
      ( uDataSource )->( DbCloseArea() )
   else
      uDataSource:Close()
      if oCn != nil
         oCn:Close()
      endif
   endif

return nil

//----------------------------------------------------------------------------//
// TESTING XBROWSE WITH TDATAROW
// Both XBrowse and TDataRow Code is the same for all Data Sources
//----------------------------------------------------------------------------//

static function BrowseData( uData )

   local oDlg, oBrw, oFont, oRec

   DEFINE FONT oFont NAME "TAHOMA" SIZE 0,-14
   DEFINE DIALOG oDlg SIZE 900,400 PIXEL FONT oFont ;
      TITLE "TDataRow test : " + FWVERSION
   @ 30,10 XBROWSE oBrw SIZE -10,-10 PIXEL OF oDlg ;
      DATASOURCE uData AUTOCOLS AUTOSORT ;
      FOOTERS CELL LINES NOBORDER

   WITH OBJECT oBrw
      //
      :CreateFromCode()
   END

   @ 10,10 BUTTON "Edit" SIZE 40,12 PIXEL OF oDlg ;
      ACTION ( oRec := TDataRow():New( uData ), oRec:Edit(), oBrw:Refresh(), oBrw:SetFocus() )
   @ 10,60 BUTTON "Append" SIZE 40,12 PIXEL OF oDlg ;
      ACTION ( oRec := TDataRow():New( uData, nil, .t. ), oRec:Edit(), oBrw:Refresh(), oBrw:SetFocus() )

   ACTIVATE DIALOG oDlg CENTERED
   RELEASE FONT oFont

return nil

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

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

Re: problem with xBrowse and TDatarow

Postby lucasdebeltran » Tue Jun 11, 2013 3:36 pm

Mr. Nages,

I sent you a full working example.

Did you were able to test it, please?.

I also discovered:

Mr. Nages,

I am sorry to disturb you, but I have found several errors with xBrowse, DataRow and ADO.

Please, see sample attached.

First, after adding a new record with "Añadir" option, the xBrowse is not refresed despite the call oBrowse:Refresh(), and the new record is not shown:

Code: Select all  Expand view  RUN
 REDEFINE BUTTON ID 711 OF oDlg ;
                  ACTION( AltasApuntes( .T. ), ;
                          oBrowse:Refresh() )

 



Also, when we succeed in refreshing, I would like to set the xBrowse on the new row added. In DBFS it is done automatically.


Second, the same happens with Modificar (Modify) option.


Also, if I click on header and I change the short method of the column, oRs:AbsolutePosition is not updated, at:

Code: Select all  Expand view  RUN
  oBrowse:blDblClick := { || (  AltasApuntes( .F., oRs:AbsolutePosition ) ) }  



Thank you. Best regards
Muchas gracias. Many thanks.

Un saludo, Best regards,

Harbour 3.2.0dev, Borland C++ 5.82 y FWH 13.06 [producción]

Implementando MSVC 2010, FWH64 y ADO.

Abandonando uso xHarbour y SQLRDD.
User avatar
lucasdebeltran
 
Posts: 1303
Joined: Tue Jul 21, 2009 8:12 am

Re: problem with xBrowse and TDatarow

Postby nageswaragunupudi » Tue Jun 11, 2013 3:46 pm

Mr Lucas
I shall go through your code.

Meanwhile please build and test the code posted by me.
Let me know if you find any problem there.

I shall respond to your code a little while later
Regards

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

Re: problem with xBrowse and TDatarow

Postby lucasdebeltran » Tue Jun 11, 2013 8:46 pm

Mr. Nages,

Thank you very much.

Your code seems to be working ok.

But it is different that mine. Mine uses a DIALOG and also two separate and independant RecordSet.

I await your answer.

Thank you for the good class and excelent supprt.

Best regards,
Muchas gracias. Many thanks.

Un saludo, Best regards,

Harbour 3.2.0dev, Borland C++ 5.82 y FWH 13.06 [producción]

Implementando MSVC 2010, FWH64 y ADO.

Abandonando uso xHarbour y SQLRDD.
User avatar
lucasdebeltran
 
Posts: 1303
Joined: Tue Jul 21, 2009 8:12 am


Return to FiveWin for Harbour/xHarbour

Who is online

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