Tlist con Xbrowse

Tlist con Xbrowse

Postby audisys » Tue Apr 22, 2008 2:37 pm

Alguien por curiosidad tiene la Clase Tlist de Manuel Exposito, mejorada para que trabaje con Xbrowse, no he podido hacer funcionar con el Xbrowse de la 8.04. El Metodo Setarray no sincroniza bien con el Xbrowse.


Mil Gracias,
José David Angulo
Auditoria y Sitemas Ltda.
Cartagena Colombia
audisys
 
Posts: 49
Joined: Wed Apr 18, 2007 6:01 pm
Location: Cartagena - Colombia

Postby Antonio Linares » Tue Apr 22, 2008 5:42 pm

José,

Puedes mostrarnos la parte del código PRG en donde llamas al método SetArray() ? gracias
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42161
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Postby audisys » Tue Apr 22, 2008 8:43 pm

Antonio este el codigo del llamado al xbrowse

REDEFINE XBROWSE ::oLbxBody ID 600 OF oDlg ;
FIELDS Str( oList:Pos,3) ,;
oList:Current[1] ,;
oList:Current[2] ,;
Transform(oList:Current[3],"@Z 9999,999.99") ,;
Transform(oList:Current[4],"@Z 9999,999,999.99") ,;
Transform(oList:Current[5],"@Z 999.99") ,;
Transform(oList:Current[6],"@Z 999.99") ,;
TransForm(Round((oList:Current[3]*oList:Current[4]),0),"@Z 9999,999,999");
HEADERS "No","Código","Descripción del Producto","Cantidad","Vlr.Unitario" ,;
"% Desc","% Iva","Subtotal" ;
ON DBLCLICK IF(!Empty(::oMacot:CodCli) .And. !lView ,;
(::NewIte(oList,.F.),::oLbxBody:Refresh()),) ;
ON CHANGE Eval(bChanBrw) ;
JUSTIFY 1,0,0,1,1,1,1,1 ;
COLSIZES 27,90,140,70,90,40,40,90


XbrStyles(::oLbxBody ) // Confugurando el Estilo del Xbrowse
::oLbxBody:nHeaderLines := 1
::oLbxBody:bKeyDown := {|nKey,nFlags|::LeeTecla(nKey,nFlags,oList,lView),Eval(bChanBrw)}
oList:SetBrowse(::oLbxBody)

Siempre me muestra el primer elemento.

Adjunto la clase Tlist que estoy usando.

/---------------------------------------------------------
//----------------------------------------------------------------------------//
// AUTOR.....: Manuel Exp¢sito Su rez Soft 4U '1994-2001 //
// e-Mail....: maex14@dipusevilla.es //
// CLASE.....: TList //
// FECHA MOD.: 09/04/2001 //
// VERSION...: 1.00 //
// PROPOSITO.: Gesti¢n de arrays //
//----------------------------------------------------------------------------//

#include "FiveWin.ch"


CLASS TList

DATA aList AS ARRAY
DATA Pos, Size AS NUMERIC
DATA EOA, BOA AS LOGICAL
DATA aDelete AS ARRAY // Jose David , Pista de los Borrados


METHOD New( xLen ) CONSTRUCTOR

/* Mantenimiento */
METHOD Add( Val )
METHOD Insert( Val )
METHOD Update( Val ) INLINE ::aList[ ::Pos ] := Val
MESSAGE Delete() METHOD _Delete()

/* Movimiento */
METHOD GoTo( n )
METHOD GoTop() INLINE ::GoTo( 1 )
METHOD GoBottom() INLINE ::GoTo( ::Size )
METHOD First() INLINE ::GoTo( 1 )
METHOD Last() INLINE ::GoTo( ::Size )
METHOD Prior() INLINE ::Skip( -1 )
METHOD Next() INLINE ::Skip( 1 )
METHOD Skip( n )

/* Varios */
METHOD Current() INLINE ::aList[ ::Pos ]
METHOD Eval( bBlock ) INLINE AEval( ::aList, bBlock )
METHOD Sort( bSort ) INLINE ASort( ::aList,, bSort )
METHOD Scan( uVal, nInit )

/* Browse */
METHOD SetBrowse( oBrw )
METHOD Skipper( n )

/* Jose */
//METHOD ValDefault()
METHOD ReadRow()
METHOD SaveRow(Val)
METHOD BlankRow()

ENDCLASS

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

METHOD New( xElem ) CLASS TList

local cType := ValType( xElem )

if cType == "N"
::aList := Array( xElem )
elseif cType == "A"
::aList := xElem
else
::aList := {}
endif

::aDelete := {}
::Size := len( ::aList )
::Pos := if( ::Size > 0, 1, 0 )
::EOA := ::BOA := ( ::Size == 0 )

return( Self )

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

METHOD _Delete() CLASS TList

Local aRec:=::ReadRow()
Local nLen

IF Len(::aList) > 0
//Pista de Los Borrados
nLen:=Len(::aList[::Pos])
IF ::aList[::Pos,nLen] > 0
AADD(::aDelete,::aList[::Pos,nLen]) // Solo Grabo el Numero del Registro, y si es > 0
Endif
ADel(::aList, ::Pos )
ASize(::aList, --::Size )
Else
Tone(500,1)
Endif


return( Self )

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

METHOD Insert( Val ) CLASS TList


Local aDef:=::BlankRow()

::EOA := ::BOA := .f.

AAdd( ::aList, nil )
AIns( ::aList, ::Pos )

if !empty( Val )
::aList[ ::Pos ] := Val
else
::aList[ ::Pos ] := aDef

Endif

++::Size

return( Self )

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

METHOD Add( Val ) CLASS TList

::EOA := ::BOA := .f.

if !empty( Val )
aAdd( ::aList, Val )
Else
aAdd( ::aList, ::BlankRow())
Endif
::Pos := ++::Size

return( Self )

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

METHOD GoTo( n ) CLASS TList

local nRec := ::Pos

::EOA := ::BOA := .f.

if ValType( n ) == "N" .and. n > 0
::Pos := if( n > ::Size, ( ::EOA := .t., ::Size ), n )
endif

return( Self )

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

METHOD Skip( n ) CLASS TList

Local nPos := 0

DEFAULT n:= 1

if ValType( n ) = "N"
nPos := ::Pos + n
if nPos > ::Size
::GoBottom()
::EOA := .t.
elseif nPos < 1
::GoTop()
::BOA := .t.
else
::GoTo( nPos )
endif
endif

return( Self )

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

METHOD Skipper( nSkip ) CLASS TList

local nSkipped := 0

nSkipped := Min( Max( nSkip, 1 - ::Pos ), ::Size - ::Pos )

::GoTo( ::Pos + nSkipped )

return( nSkipped )

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

METHOD SetBrowse( oBrw ) CLASS TList

if upper( oBrw:ClassName() ) $ "TWBROWSE TCBROWSE TGRID" // De WINDOWS
oBrw:bGoTop := { || ::GoTop() }
oBrw:bGoBottom := { || ::GoBottom() }
oBrw:bSkip := { | n | ::Skipper( n ) }
oBrw:bLogicLen := { || ::Size }
oBrw:cAlias := "ARRAY"
elseif upper( oBrw:ClassName() ) $ "TBROWSE TDBBRW" // Del DOS
oBrw:goTopBlock := { || ::GoTop() }
oBrw:goBottomBlock := { || ::GoBottom() }
oBrw:SkipBlock := { | n | ::Skipper( n ) }
endif

if upper( oBrw:ClassName() ) $ "XBROWSE" // De WINDOWS
oBrw:bGoTop := { || ::GoTop() }
oBrw:bGoBottom := { || ::GoBottom() }
oBrw:bSkip := { |n| ::Skipper( n ) }
//oBrw:bLogicLen := { || ::Size }
oBrw:bKeyCount := { || Len( ::aList ) }
oBrw:cAlias := "ARRAY"
Endif
//::ValDefault()


return( oBrw )

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

METHOD Scan( uVal, nInit ) CLASS TList

local nPos := aScan( ::aList, uVal, nInit )

::Pos := if( nPos == 0, ::Pos, nPos )

return( nPos )

//---------------------------------------------------------------------------//
/*
METHOD ValDefault() CLASS TList

Local aStru:={}, x

FOR X:=1 To LEN(::aList[1])
if valtype(::aList[1,x])=="N"
aadd(aStru,0)
elseif valtype(::aList[1,x])=="C"
aadd(aStru,space(len(::aList[1,x])))
elseif valtype(::aList[1,x])=="L"
aadd(aStru,.f.)
elseif valtype(::aList[1,x])=="D"
aadd(aStru,CTOD(""))
else
aadd(aStru,NIL)
endif
next

::aDefault :=aStru

Return(Self)
*/
//---------------------------------------------------------------------------//

METHOD ReadRow() CLASS TList

Local nColumns
Local aDatos

nColumns := If( ! Empty( ::aList ), Len( ::aList[1] ), 0 )

aDatos:=Array(nColumns)

For nI := 1 To nColumns
aDatos[ni]:=::aList[::Pos,nI]
Next

Return (aDatos)

//---------------------------------------------------------------------------//
METHOD SaveRow( Val ) CLASS TList

For nI := 1 To Len( ::aList[1] )
::aList[::Pos,nI]:=Val[ni]
Next

Return (NIL)

//-----------------------------------
METHOD BlankRow() CLASS TList

Local aStru:={}, x

FOR X:=1 To LEN(::aList[1])
if valtype(::aList[1,x])=="N"
aadd(aStru,0)
elseif valtype(::aList[1,x])=="C"
aadd(aStru,space(len(::aList[1,x])))
elseif valtype(::aList[1,x])=="L"
aadd(aStru,.f.)
elseif valtype(::aList[1,x])=="D"
aadd(aStru,CTOD(""))
else
aadd(aStru,NIL)
endif
next

Return(aStru)




[/img][/quote][/code]
José David Angulo
Auditoria y Sitemas Ltda.
Cartagena Colombia
audisys
 
Posts: 49
Joined: Wed Apr 18, 2007 6:01 pm
Location: Cartagena - Colombia

Postby Antonio Linares » Wed Apr 23, 2008 11:56 am

José,

Prueba así:
Code: Select all  Expand view  RUN
REDEFINE XBROWSE ::oLbxBody ID 600 OF oDlg ;
      FIELDS oList:Pos ,;
         oList:Current[1] ,;
         oList:Current[2] ,;
         oList:Current[3] ,;
         oList:Current[4] ,;
         oList:Current[5] ,;
         oList:Current[6] ,;
         Round((oList:Current[3]*oList:Current[4]),0) ;
      HEADERS "No","Código","Descripción del Producto","Cantidad","Vlr.Unitario" ,;
      "% Desc","% Iva","Subtotal" ;
      PICTURES "999", nil, nil,"@Z 9999,999.99","@Z 9999,999,999.99","@Z 999.99","@Z 999.99", ;
      "@Z 9999,999,999" ;
      COLSIZES 27,90,140,70,90,40,40,90 ;
// JUSTIFY no es necesario. TXBrowse justifica automaticamente basándose en el tipo de datos
// No es necesario usar Transform(). Puedes usar la claúsula PICTURE si te hace falta

oList:SetBrowse( ::oLbxBody )
ACTIVATE DIALOG oDlg CENTERED

Modifica la Clase TList método SetBrowse() de esta forma:
Code: Select all  Expand view  RUN
if upper( oBrw:ClassName() ) $ "TXBROWSE" // De WINDOWS

   oBrw:bGoTop       := { || ::GoTop() }
   oBrw:bGoBottom    := { || ::GoBottom() }
   oBrw:bBof         := { || ::BoA }
   oBrw:bEof         := { || ::EoA }
   oBrw:bSkip        := { |n| ::Skipper( If( n == nil, 1, n ) ) }
   oBrw:bKeyCount    := { || Len( ::aList ) }
   oBrw:bKeyNo       := ;
   oBrw:bBookMark    := { |n| If( n == nil, ::pos, ::pos := n ) }

   oBrw:nDataType    := 3

Endif
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42161
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Postby audisys » Wed Apr 23, 2008 3:02 pm

Antonio,

Funciono perfecto.

Mil Gracias
José David Angulo
Auditoria y Sitemas Ltda.
Cartagena Colombia
audisys
 
Posts: 49
Joined: Wed Apr 18, 2007 6:01 pm
Location: Cartagena - Colombia


Return to FiveWin para Harbour/xHarbour

Who is online

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