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
// ---------------------------------------------------------------------------
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-.