FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin para Harbour/xHarbour xbrowse y array
Posts: 652
Joined: Wed Oct 19, 2005 12:03 PM

xbrowse y array

Posted: Sat May 03, 2014 05:13 PM
Hola compa帽eros, estoy tratando de hace un xbrowse para facturas, y no logro hacer que funcione bien, para facilitar mi consulta les muestro parte del c贸digo en cuestion

Code (fw): Select all Collapse
 聽 REDEFINE 聽xbrowse oBrw id 108 of oDlg ARRAY adet;
聽 聽 聽 headers 聽"C贸digo","Medida","Marca","Modelo","Cant","Precio","Total" ;
聽 聽 聽 columns 1, 2, 3, 4, 5, 6, 7 ;
聽 聽 聽 colsizes 100,95,95,90,70,80,80 ;
聽 聽 聽 lines cell fastedit

聽 聽WITH OBJECT oBrw
聽 聽 聽:nMarqueeStyle := MARQSTYLE_HIGHLCELL
聽 聽 聽:nColDividerStyle := LINESTYLE_BLACK
聽 聽 聽:nStretchCol := STRETCHCOL_LAST
聽 聽 聽:lColDividerComplete := .t.
聽 聽 聽:l2007 := .t.
聽 聽 聽:lRecordSelector := .t. 
聽 聽 聽:lAllowColHiding := .f. 
聽 聽 聽:lAllowColSwapping := .f. 

聽 聽END WITH


聽 聽 聽oBrw:aArrayData := adet
聽// 聽AEval( oBrw:aCols, { |o| o:nEditType := EDIT_GET } )



聽 聽 聽 WITH OBJECT oBrw:aCols[ 1 ] 
聽 聽 聽:beditvalue := {|| adet[oBrw:nArrayAt, 1] 聽}
聽 聽 聽:nFootStrAlign := AL_RIGHT
聽 聽 聽:nEditType := EDIT_GET
聽 聽 聽:bEditValid := { | oGet, oCol | valido(oBrw,oMysql,oQdetalle) 聽 } 聽
聽 聽 聽:bOnPostEdit := { | oCol, xVal, nKey | If( nKey <> VK_ESCAPE ,oCol:value := xVal, ) }
聽 聽 聽END WITH


聽 聽 聽WITH OBJECT oBrw:aCols[ 2 ]
聽 聽 聽 聽:beditvalue := {||aDet[ oBrw:nArrayAt, 2 ] }
聽 聽 聽 聽:nFootStrAlign := AL_LEFT
聽 聽 聽 聽:nEditType := EDIT_GET
聽 聽 聽 聽:bOnPostEdit := {| oCol, xVal, nKey | If( nKey <> VK_ESCAPE,oCol:value := xVal, ) }
聽 聽 聽END WITH 
///////

聽 聽 oBrw:bPastEof 聽:= { || AddRow( oBrw ) }
聽 聽 oBrw:bKeyDown := {| nKey | If( nKey == VK_DELETE, DelRow( oBrw ), ) }


la funci贸n valido es la siguiente

STATIC FUNCTION valido(,oBrw,oMysql,oQdetalle)
local oQry:= bprodu(,oQdetalle,oMysql)

adet[oBrw:nArrayAt, 1] := oQry:codigo
adet[oBrw:nArrayAt, 2] := oQry:producto
adet[oBrw:nArrayAt, 3] := oQry:marca
adet[oBrw:nArrayAt, 4] := oQry:modelo
oQry:end()
oBrw:refresh()
return .t.


Lo que me muestra en las respectivas columnas es 1, 1, 1, 1

Hice varias pruebas pero no puedo hacer que muestre los valores que en valido realmente carga.
Indudablemente 贸 falta algo 贸 el c贸digo esta mal

Gracias
Posts: 2064
Joined: Fri Jan 06, 2006 09:28 PM

Re: xbrowse y array

Posted: Sun May 04, 2014 04:06 AM

Que intentas hacer en la funcion VALIDO.? tengo una facturacion ful funcionando con array y tdolphin sin problema y que hace bprodu(,oQdetalle,oMysql) ya que se la pasas al oQry, por lo mens explica que intentas hacer en esas funciones para ayudarte mejor, saludos... :shock:

Dios no est谩 muerto...



Gracias a mi Dios ante todo!
Posts: 652
Joined: Wed Oct 19, 2005 12:03 PM

Re: xbrowse y array

Posted: Sun May 04, 2014 08:07 AM
Hola Jos茅 Luis bvalido la funci贸n que cumple es cargar en el array los valores de los productos, bprodu es la que me muestra un listbox con los c贸digos de los productos y me devuelve los datos que necesito.

Esto con wbrowse funciona perfectamente.

La imagen que muestra el enlace es con la prueba de xbrowse, selecciono el c贸digo y cuando acepto en las 4 primeras celdas aparece un 1, cuando debiera ser c贸digo, producto marca y modelo

https://drive.google.com/file/d/0B8UT409V4x1mTWs2TXp3eTUyaU0/edit?usp=sharing

Gracias Jose Luis por tu interes
Posts: 2064
Joined: Fri Jan 06, 2006 09:28 PM

Re: xbrowse y array

Posted: Sun May 04, 2014 03:02 PM

Por favor revisa bien los valores que envias a la funcion valida, fijate que en la que la llama esta asi....

valido(oBrw,oMysql,oQdetalle)

pero en la que la recibe esta asi...

valido(,oBrw,oMysql,oQdetalle)

tienes una COMA de primero, repara eso haber si ese es el problema sino, informalo, saludos... :shock:

Dios no est谩 muerto...



Gracias a mi Dios ante todo!
Posts: 652
Joined: Wed Oct 19, 2005 12:03 PM

Re: xbrowse y array

Posted: Mon May 05, 2014 02:13 PM
Jos茅 Luis prob茅 pero segu铆a igual hasta que me fij茅 en una diferencia que hab铆a entre los dos programas

el de wbrowse ten铆a definido el array

oCta:adet := array(0)
aadd(oCta:adet,{ space(24),space(20),space(20),space(20),0,0,0,0,.t.})


y en el prg con xbrowse

oCta:adet := { space(24),space(20),space(20),space(20),0,0,0,0,.t.}

al modificarlo me muestra correctamente las celdas

Ahora el problema que me surge es que elige me los muestra, pero al dar enter para pasar a la celda 5 se sale del foco y vuelve al primer foco que es el de inicio del programa y una vez de pasar otra vez por todos los get vuelve el foco a la columa 2 del xbrowse
ademas en las celdas 6 y 7 me da error al compilar (no s茅 cual es por que el verce no funciona bien en los detalles de errores), como hay que hacer para que de la columna 1 pase directamente a la 5 , y como se hace para una vez terminada la fila pase al siguiente item,

Te muestro el c贸digo del xbrowse para ver si me puedes dar una ayuda

Code (fw): Select all Collapse
   REDEFINE  xbrowse oBrw id 108 of oDlg ARRAY oCta:adet;
      headers  "C贸digo","Medida","Marca","Modelo","Cant","Precio","Total" ;
      columns 1, 2, 3, 4, 5, 6, 7 ;
      colsizes 100,95,95,90,70,80,80 ;
      lines cell fastedit

   WITH OBJECT oBrw
     :nMarqueeStyle := MARQSTYLE_HIGHLCELL
     :nColDividerStyle := LINESTYLE_BLACK
     :nStretchCol := STRETCHCOL_LAST
     :lColDividerComplete := .t.
     :l2007 := .t.
     :lRecordSelector := .t. 
     :lAllowColHiding := .f. 
     :lAllowColSwapping := .f. 

   END WITH


     oBrw:aArrayData := oCta:adet
     AEval( oBrw:aCols, { |o| o:nEditType := EDIT_GET } )



      WITH OBJECT oBrw:aCols[ 1 ] 
     :beditvalue := {|| oCta:adet[oBrw:nArrayAt, 1]  }
     :nFootStrAlign := AL_RIGHT
     :nEditType := EDIT_GET
     :bEditValid := { | oGet, oCol | valido(oBrw,oBrw:nArrayAt,oMysql,oQdetalle)   }  
     :bOnPostEdit := { | oCol, xVal, nKey | If( nKey <> VK_ESCAPE ,oCol:value := xVal, ) }
     END WITH


     WITH OBJECT oBrw:aCols[5 ]
       :beditvalue := {|| oCta:aDet[ oBrw:nArrayAt, 5 ] }
       :nFootStrAlign := AL_LEFT
       :nEditType := EDIT_GET
       :bOnPostEdit := {| oCol, xVal, nKey | If( nKey <> VK_ESCAPE,oCol:value := xVal, ) }
     END WITH 
 
/*
     WITH OBJECT oBrw:aCols[6 ]
       :beditvalue := {|| oCta:aDet[ oBrw:nArrayAt, 6 ] }
       :nFootStrAlign := AL_LEFT
       :nEditType := EDIT_GET
       :bOnPostEdit := {| oCol, xVal, nKey | If( nKey <> VK_ESCAPE,oCol:value := xVal,(oCta;adet[oBrw:nArrayAt7] := multi(oCta:aDet[ oBrw:nArrayAt, 5 ],oCta:aDet[ oBrw:nArrayAt, 6 ] ) ) }
     END WITH*/

/*      WITH OBJECT oBrw:aCols[ 7 ] 
     :beditvalue := {|| oCta:adet[oBrw:nArrayAt, 7]  }
     :nFootStrAlign := AL_RIGHT
     :nEditType := EDIT_GET
     :bOnPostEdit := { | oCol, xVal, nKey | If( nKey <> VK_ESCAPE ,oCol:value := xVal, oCol:value := xVal,AddRow( oBrw ) ) }
     END WITH   */

 
    oBrw:bKeyDown := {| nKey | If( nKey == VK_DELETE, DelRow( oBrw ), ) }



  ACTIVATE DIALOG oDlg


Disculpa pero son demasiadas consultas en una
Gracias
Posts: 2064
Joined: Fri Jan 06, 2006 09:28 PM

Re: xbrowse y array

Posted: Mon May 05, 2014 05:25 PM
Te muestro mi codigo completo de edicion de celda con array tipo factura, espero te ayude, sino entiendes algo, avisa, saludos... :-)

asi se salta a una columna determinada, tambien con que no sea editable creo que la salta

oBrw:SelectCol( 3 )

Code (fw): Select all Collapse
 聽 REDEFINE xBrowse oBrw ID 100 of oDlg ;
聽 聽 聽 COLUMNS 1, 2, 3, 4, 5 ;
聽 聽 聽 ARRAY aItems FASTEDIT LINES

聽 聽WITH OBJECT oBrw
聽 聽 聽 :nMarqueeStyle 聽 聽:= MARQSTYLE_HIGHLCELL
聽 聽 聽 :nColDividerStyle := LINESTYLE_BLACK
聽 聽 聽 :nStretchCol 聽 聽 聽:= STRETCHCOL_LAST
聽 聽 聽 :lColDividerComplete := .t.
聽 聽 聽 :nHeaderHeight := 30
聽 聽 聽 :l2007 := .t.
聽 聽 聽 :lFooter := .t.
聽 聽 聽 :lAllowColHiding := .f.
聽 聽 聽 :lAllowColSwapping := .f.
聽 聽 聽 :bClrStd := {|| IF( oBrw:nArrayAt % 2 == 0, {CLR_BLACK, CLR_WHITE} ,;
聽 聽 聽 聽 聽{0, RGB(203, 226, 254)} ) }
聽 聽END WITH

聽 聽WITH OBJECT oBrw:aCols[1]
聽 聽 聽 :cHeader := "C贸digo"
聽 聽 聽 :cEditPicture := "99999"
聽 聽 聽 :nWidth := 100
聽 聽 聽 :nDataStrAlign := AL_LEFT
聽 聽 聽 :bStrData := {|| IIF( LEN( aItems ) = 0, SPACE(10) ,;
聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 aItems[oBrw:nArrayAt, 1] ) }
聽 聽 聽 :nEditType := EDIT_GET_BUTTON
聽 聽 聽 :bEditBlock := {|| leecodigo( oQryPro, , {"productos_id", "productos_nombre"} ,;
聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 {"C贸digo", "Nombre"}, oBrw, aItems, 1 ) }
聽 聽 聽 :bEditValid := { | oGet | buscacodigo( oGet:value(), oBrw, aItems ,;
聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 oQryPro, "productos_id" ,;
聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 {"productos_id", "productos_nombre"} ,;
聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 {"C贸digo", "Nombre"}, 1 ) }
聽 聽 聽 聽 :bOnPostEdit := { | oCol, xVal, nKey | IF( nKey <> VK_ESCAPE .and. !EMPTY( xVal ) ,;
聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽( oCol:value := xVal ,;
聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽oBrw:SelectCol( 3 ) ), 聽) }
聽 聽END WITH

聽 聽WITH OBJECT oBrw:aCols[2]
聽 聽 聽 :cHeader := "Descripci贸n"
聽 聽 聽 :nWidth 聽:= 350
聽 聽 聽 :nDataStrAlign := AL_LEFT
聽 聽 聽 :bStrData := {|| IIF( LEN( aItems ) = 0, SPACE(10) ,;
聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 aItems[oBrw:nArrayAt, 2] ) }
聽 聽END WITH

聽 聽WITH OBJECT oBrw:aCols[3]
聽 聽 聽 :cHeader := "Cantidad"
聽 聽 聽 :nWidth 聽:= 70
聽 聽 聽 :cDataType := "N"
聽 聽 聽 :nDataStrAlign := AL_RIGHT
聽 聽 聽 :bStrData := {|| IIF( LEN( aItems ) = 0, SPACE(10) ,;
聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 TRANS( aItems[oBrw:nArrayAt, 3],"@E 999,999.99" ) ) }
聽 聽 聽 :cEditPicture 聽:= "@E 999,999.99"
聽 聽 聽 :nFootStrAlign := AL_RIGHT
聽 聽 聽 聽 :nEditType聽 聽 聽:= EDIT_GET
聽 聽 聽 :bEditValid 聽 聽:= { | oGet, oCol | mayorqcero( oGet:value() ) }
聽 聽 聽 聽 :bOnPostEdit 聽 := { | oCol, xVal, nKey | If( nKey <> VK_ESCAPE ,;
聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽( oCol:value := xVal ), ) }
聽 聽 聽 :bEditWhen 聽 := {|| !EMPTY( aItems[oBrw:nArrayAt, 2] ) }
聽 聽END WITH

聽 聽WITH OBJECT oBrw:aCols[4]
聽 聽 聽 :cHeader := "Precio"
聽 聽 聽 :cEditPicture := "@E 999,999.99"
聽 聽 聽 :nWidth 聽:= 70
聽 聽 聽 :cDataType := "N"
聽 聽 聽 :nDataStrAlign := AL_RIGHT
聽 聽 聽 :bStrData := {|| IIF( LEN( aItems ) = 0, SPACE(10) ,;
聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 TRANS( aItems[oBrw:nArrayAt, 4], "@E 999,999.99" ) ) }
聽 聽 聽 :nFootStrAlign := AL_RIGHT
聽 聽 聽 :cFooter 聽 聽 聽 := "Total Pagar ->"
聽 聽 聽 :nEditType := EDIT_GET
聽 聽 聽 :bEditValid 聽 聽:= { | oGet, oCol | mayorqcero( oGet:value() ) }
聽 聽 聽 聽 :bOnPostEdit 聽 := { | oCol, xVal, nKey | If( nKey <> VK_ESCAPE ,;
聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽( oCol:value := xVal ,;
聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽totalinea( oBrw, aVar, aGet ) ,;
聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽addrow( oBrw, aVar, aGet ) ), ) }
聽 聽 聽 :bEditWhen := {|| !EMPTY( aItems[oBrw:nArrayAt, 1] ) }
聽 聽END WITH

聽 聽WITH OBJECT oBrw:aCols[5]
聽 聽 聽 :cHeader := "Total"
聽 聽 聽 :nWidth 聽:= 70
聽 聽 聽 :cDataType := "N"
聽 聽 聽 :nDataStrAlign := AL_RIGHT
聽 聽 聽 :bStrData := {|| IIF( LEN( aItems ) = 0, SPACE(10) ,;
聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 TRANSFORM( aItems[oBrw:nArrayAt, 5] ,;
聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 "@E 9,999,999.99" ) ) }
聽 聽 聽 :cEditPicture 聽:= "@E 9,999,999.99"
聽 聽 聽 :nFooterType 聽 := AGGR_SUM
聽 聽 聽 :nFootStrAlign := AL_RIGHT
聽 聽END WITH

聽 聽oBrw:MakeTotals()
聽 聽oBrw:RefreshFooters()
聽 聽oBrw:Refresh()
Dios no est谩 muerto...



Gracias a mi Dios ante todo!
Posts: 652
Joined: Wed Oct 19, 2005 12:03 PM

Re: xbrowse y array

Posted: Tue May 06, 2014 11:54 AM
Jose Luis ahora funciona un poco mejor digo as铆 ya que luego de seleccionar el producto (ahora se posiciona en la 5潞 columna) pero sigue yendose del foco xbrowse al primer get y al pasar por todos los objetos y entrar al xbrowse se posiciona en la 5ta columna y sigue como si nada hubiera pasado

te muestro el prg completo

Code (fw): Select all Collapse
#include "fivewin.ch"
#include "tarray.ch"
#include "splitter.ch"
#include "xbrowse.ch"

#define HA_LEFT 聽0
#define HA_RIGHT 1
#define HA_CENTER 2

static aGet := array(14)
static oQfac
static oCta
static nsaldo := 0
static oDlg
static oQdetalle

function factura(oMysql, lnueva, lcliente)


local aItem := {"Contado","30 d铆as","45 d铆as","90 d铆as","120 d铆as"}
local aBut := array(3)
local oBrw
local oSpli
local cEva1 := {|| oBrw:setfocus() }
local nBut := array(3)
local cTitulo := iif(lcliente,"Factura Clientes","Factura proveedor")


聽LOCAL 聽 cQuery := "SELECT * FROM producto ORDER by codigo"


// Este no va, porque maeclien puede ser una tabla y aqui en
// SQL no se pone en uso cada tabla sino solo el contenedor (base de datos)
// 聽oMysql:Selectdb("maeclie")

// Aqui te aplica una especie d ZAP a la tabla maeclien
// 聽oMysql:execute( "TRUNCATE TABLE maeclie" )

聽 oQdetalle := oMysql:Query( cQuery )

聽 oQdetalle:gotop()

聽 xbrNumFormat( "E", .T. )

oCta := oCtac()

聽aadd(oCta:adet,{ space(24),space(20),space(20),space(20),0,0,0,0,.t.})

DEFINE DIALOG oDlg resource "dia_factura"
oDlg:cCaption := "Factura clientes"

聽 聽REDEFINE GET aGet[1] VAR oCta:ncli picture "99999" ID 101 UPDATE 聽of odlg 聽;
聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 VALID cargocli(oBrw,oMysql)

聽 聽REDEFINE GET aGet[2] VAR oCta:nape 聽ID 102 of odlg UPDATE

聽 聽REDEFINE GET aGet[3] VAR oCta:domi 聽ID 103 of odlg UPDATE
聽 聽REDEFINE GET aGet[5] VAR oCta:cuit 聽 ID 104 of odlg UPDATE
聽 聽REDEFINE GET aGet[4] VAR oCta:iva 聽ID 105 of odlg UPDATE
聽 聽REDEFINE COMBOBOX aGet[8] VAR oCta:condicion 聽ITEMS aItem ID 113 of odlg UPDATE 聽// VALID ( Eval( cEva1 ), .T. )
聽 聽REDEFINE GET aGet[6] VAR oCta:fecha picture "@d" 聽ID 106 of odlg UPDATE
聽 聽REDEFINE GET aGet[14] VAR oCta:pventa picture "9999" 聽ID 115 of odlg UPDATE valid( oCta:pventa:=RIGHT("0000"+AllTrim( oCta:pventa),4),aGet[14]:refresh(),.t.)
聽 聽REDEFINE GET aGet[8] VAR oCta:factura 聽ID 107 of odlg UPDATE valid ( oCta:factura:=RIGHT("0000"+AllTrim( oCta:factura),8),aGet[8]:refresh(),.t.)
聽 聽REDEFINE GET aGet[9] VAR oCta:subtotal picture "@e 9,999,999.99" 聽ID 109 of odlg UPDATE
聽 聽REDEFINE GET aGet[10] VAR oCta:total picture "@e 9,999,999.99" 聽ID 112 of odlg UPDATE
聽 聽REDEFINE GET aGet[11] VAR oCta:niva picture "@e 999,999.99" 聽ID 110 of odlg UPDATE
聽 聽REDEFINE GET aGet[12] VAR oCta:ib picture "@e 999,999.99" 聽ID 111 of odlg UPDATE

聽 聽REDEFINE SPLITTER aGet[13] ID 116 COLOR rgb(234,234,234) ADJUST of odlg _3DLOOK


聽 聽REDEFINE BUTTON nbut[ 1 ] id 200 of odlg;
聽 聽 聽 聽 聽ACTION ACEPTO(oMysql, lnueva, lcliente)

聽 聽REDEFINE BUTTON nbut[ 2 ] id 201 of odlg;
聽 聽 聽 聽 聽ACTION nil

聽 聽REDEFINE BUTTON nbut[ 3 ] id 202 of odlg;
聽 聽 聽 聽 聽ACTION nil



聽 聽REDEFINE 聽xbrowse oBrw id 108 of oDlg ARRAY oCta:adet;
聽 聽 聽 headers 聽"C贸digo","Medida","Marca","Modelo","Cant","Precio","Total" ;
聽 聽 聽 columns 1, 2, 3, 4, 5, 6, 7 ;
聽 聽 聽 colsizes 100,95,95,90,70,80,80 ;
聽 聽 聽 lines cell 聽fastedit



聽 聽 聽oBrw:aArrayData := oCta:adet

聽 聽WITH OBJECT oBrw:aCols[ 1 ] 
聽 聽 聽:beditvalue := {|| oCta:adet[oBrw:nArrayAt, 1] 聽}
聽 聽 聽:nFootStrAlign := AL_RIGHT
聽 聽 聽:nEditType := EDIT_GET
聽 聽 聽:bEditvalid := { | oGet, oCol | valido(oBrw,oBrw:nArrayAt,oMysql,oQdetalle),.t. 聽 } 聽
聽 聽 聽:bOnPostEdit := { | oCol, xVal, nKey | If( nKey <> VK_ESCAPE ,(oCol:value := xVal,;
聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽oBrw:SelectCol( 5 )), ) }
聽 聽 聽END WITH


聽 聽 聽 WITH OBJECT oBrw:aCols[ 2 ] 
聽 聽 聽:beditvalue := {|| oCta:adet[oBrw:nArrayAt, 2] 聽}
聽 聽 聽:nFootStrAlign := AL_RIGHT
聽 聽 聽:nEditType := EDIT_GET
聽 聽 聽:bOnPostEdit := { | oCol, xVal, nKey | If( nKey <> VK_ESCAPE ,oCol:value := xVal, ) }
聽 聽 聽END WITH


聽 聽 聽 WITH OBJECT oBrw:aCols[ 3 ] 
聽 聽 聽:beditvalue := {|| oCta:adet[oBrw:nArrayAt, 3] 聽}
聽 聽 聽:nFootStrAlign := AL_RIGHT
聽 聽 聽:nEditType := EDIT_GET
聽 聽 聽:bOnPostEdit := { | oCol, xVal, nKey | If( nKey <> VK_ESCAPE ,oCol:value := xVal, ) }
聽 聽 聽END WITH

聽 聽 聽 WITH OBJECT oBrw:aCols[ 4 ] 
聽 聽 聽:beditvalue := {|| oCta:adet[oBrw:nArrayAt, 4] 聽}
聽 聽 聽:nFootStrAlign := AL_RIGHT
聽 聽 聽:nEditType := EDIT_GET
聽 聽 聽:bOnPostEdit := { | oCol, xVal, nKey | If( nKey <> VK_ESCAPE ,oCol:value := xVal, ) }
聽 聽 聽END WITH

聽 聽 聽WITH OBJECT oBrw:aCols[5 ]
聽 聽 聽 聽:beditvalue := {|| oCta:aDet[ oBrw:nArrayAt, 5 ] }
聽 聽 聽 聽:cEditPicture := "@e 99,999"
聽 聽 聽 聽:nFootStrAlign := AL_LEFT
聽 聽 聽 聽:nEditType := EDIT_GET
聽 聽 聽 聽:bOnPostEdit := {| oCol, xVal, nKey | If( nKey <> VK_ESCAPE,oCol:value := xVal, ) }
聽 聽 聽END WITH 

聽 聽 聽WITH OBJECT oBrw:aCols[6 ]
聽 聽 聽 聽:beditvalue := {|| oCta:aDet[ oBrw:nArrayAt, 6 ] }
聽 聽 聽 聽:cEditPicture := "@e 999,999.99"
聽 聽 聽 聽:nFootStrAlign := AL_LEFT
聽 聽 聽 聽:nEditType := EDIT_GET
聽 聽 聽 聽:bOnPostEdit := {| oCol, xVal, nKey | If( nKey <> VK_ESCAPE,(oCol:value := xVal,totales(obrw)), ) }
聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 
聽 聽 聽END WITH

聽 聽 聽 WITH OBJECT oBrw:aCols[ 7 ] 
聽 聽 聽:beditvalue := {|| oCta:adet[oBrw:nArrayAt, 7] 聽}
聽 聽 聽:cEditPicture := "@e 999,999.99"
聽 聽 聽:nFootStrAlign := AL_RIGHT
聽 聽 聽:nEditType := EDIT_GET
聽 聽 聽:bOnPostEdit := { | oCol, xVal, nKey | If( nKey <> VK_ESCAPE ,(oCol:value := xVal, AddRow( oBrw )), ) }
聽 聽 聽END WITH 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 

聽 聽WITH OBJECT oBrw
聽 聽 聽:nMarqueeStyle := MARQSTYLE_HIGHLCELL
聽 聽 聽:nColDividerStyle := LINESTYLE_BLACK
聽 聽 聽:nStretchCol := STRETCHCOL_LAST
聽 聽 聽:lColDividerComplete := .t.
聽 聽 聽:l2007 := .t.
聽聽 聽 :lRecordSelector := .f. 
聽 聽 聽:lAllowColHiding := .f. 
聽 聽 聽:lAllowColSwapping := .f. 
聽 聽END WITH



聽 聽 oBrw:bKeyDown := {| nKey | If( nKey == VK_DELETE, DelRow( oBrw ), ) }



聽 ACTIVATE DIALOG oDlg



聽 return nil


/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
static function cargocli(oBrw,oMysql)
local oQmae 聽:= oMysql:Query( "SELECT * FROM maeclie")
local oQry1
local z := 1
local lTipo := .f.
local nImporte


oQry1 :=busnap(,oQmae,oCta:ncli,oMysql)
聽
if empty(oQry1 )
聽 聽 return .f.
endif

oCta:ncli := oQry1:ncli
oCta:nape := oQry1:nape
oCta:domi := alltrim(oQry1:domi) +" - " + oQry1:loca
oCta:cuit := oQry1:cuit
oCta:iva := oQry1:iva
oDlg:update()
oQmae:end()

return .t.

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

static function AddRow( oBrw )

聽 聽aadd(oCta:adet,{ space(24),space(20),space(20),space(20),0,0,0,0,.t.})
聽 聽oBrw:GoBottom()
聽 聽oBrw:Refresh()
聽 聽oBrw:SetFocus()

return nil
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
static function DelRow( oBrw )

聽 聽if oBrw:nLen > 0
聽 聽 聽 ADel( oBrw:aArrayData, oBrw:nArrayAt )
聽 聽 聽 ASize( oBrw:aArrayData, oBrw:nLen - 1 )
聽 聽 聽 oBrw:Refresh()
聽 聽endif
聽 聽oBrw:SetFocus()
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
STATIC FUNCTION oCtac( )
local oCta
聽 聽 聽 DEFINE STRUCT oCta
聽 聽 聽STRUCT FIELD "ncli" INIT 0
聽 聽 聽 聽 聽STRUCT FIELD "nape" INIT ""
聽 聽 聽STRUCT FIELD "domi" INIT ""
聽 聽 聽STRUCT FIELD 聽"fecha" INIT date()
聽 聽 聽STRUCT FIELD 聽"cuit" INIT ""
聽 聽 聽STRUCT FIELD 聽"iva" INIT ""
聽 聽 聽STRUCT FIELD 聽"condicion" INIT "Contado"
聽 聽 聽STRUCT FIELD 聽"subtotal" INIT 0
聽 聽 聽STRUCT FIELD 聽"total" INIT 0
聽 聽 聽STRUCT FIELD 聽"niva" INIT 0
聽 聽 聽STRUCT FIELD 聽"ib" INIT 0
聽 聽 聽STRUCT FIELD 聽"pventa" INIT space(4)
聽 聽 聽STRUCT FIELD 聽"factura" INIT space(8)
聽 聽 聽STRUCT FIELD 聽"adet" INIT array(0)
聽 聽 聽END STRUCT

return oCta
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
聽STATIC FUNCTION valido(oBrw,nAt,oMysql,oQdetalle)


聽local oQry


// oQry2 := ocheque:seek("codigo =" + 聽alltrim(str(adet[nAt,1])) ,, {"*"})

oQry := 聽bprodu(,oQdetalle,oMysql)
if empty(oQry)
聽 聽msgstop("No esta cargado ese producto","Aviso del sistema")
聽 聽return nil
endif



聽oCta:adet[nAt, 1] := oQry:codigo
聽oCta:adet[nAt, 2] := oQry:producto
聽oCta:adet[nAt, 3] := oQry:marca
聽oCta:adet[nAt, 4] := oQry:modelo


聽oQry:end()
聽oBrw:refresh() 
return .t. 


/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
STATIC FUNCTION ACEPTO(oMysql, lnueva, lcliente)
LOCAL cQuery
LOCAL cQueryfac
LOCAL oQrycta
LOCAL oQryfac
LOCAL cQuerysto := "SELECT * FROM detapro"
LOCAL oQrysto := oMysql:Query(cQuerysto)

if empty(oCta:ntotal)
聽 聽msgstop("No hay datos para grabar","Ingrese datos")
聽 聽return nil
endif

if 聽lcliente
聽 cQuery:= 聽 "SELECT * FROM ctacte ORDER by ncli"
聽 cQueryfac := 聽"SELECT * FROM factura ORDER by nrofac"
else
聽 cQuery:= 聽 "SELECT * FROM ctacp ORDER by ncli"
聽 cQueryfac := 聽"SELECT * FROM facpro ORDER by nrofac"
endif

聽 oQrycta := 聽oMysql:Query(cQuery)

聽 oQrycta:blank()
聽 oQrycta:ncli := oCta:ncli
聽 oQrycta:comprobante := oCta:pventa + "-"+ oCta:factura
聽 oQrycta:fecha := oCta:fecha
聽 oQrycta:descripcion := 聽oCta:tipocom
聽 oQrycta:importe := oCta:ntotal
聽 oQrycta:tipo := "1"
聽 oQrycta:pventa := oCta:pventa
聽 oQrycta:numero := oCta:factura
聽 oQrycta:save()
聽 oQrycta:end()




聽 聽oQryfac := 聽 oMysql:Query(cQueryfac)
聽 聽oQryfac:blank() 聽
聽 聽oQryfac:ncli := oCta:ncli
聽 聽oQryfac:nrofac := oCta:pventa + "-"+ oCta:factura
聽 聽oQryfac:fecha := oCta:fecha
聽 聽oQryfac:importe := oCta:ntotal
聽 聽oQryfac:plazo := oCta:condicion
聽 聽oQryfac:baseimpo := oCta:subtotal
聽 聽oQryfac:iva := oCta:niva
聽 聽oQryfac:ingbruto := oCta:ib
聽 聽oQryfac:tipo := oCta:tipocom
聽 聽oQryfac:save()
聽 聽oQryfac:end() 



聽 聽oQrysto := 聽 oMysql:Query(cQueryfac)
聽 聽for z = 1 to len(oCta:adet)
聽 聽 聽 聽oQrySto:blank()
聽 聽 聽 聽 iif(lcliente,oQrysto:ncli := oCta:ncli, oQrysto:npro := oCta:ncli)
聽 聽 聽 聽oQrysto:codigo := oCta:adet[z,1]
聽 聽 聽 聽oQrysto:comprobante := oCta:pventa + "-"+ oCta:factura
聽 聽 聽 聽oQrysto:costo := oCta:adet[z,6]
聽 聽 聽 聽oQrysto:fecha := oCta:fecha
聽 聽 聽 聽oQrysto:cantidad := oCta:adet[z,5]
聽 聽 聽 聽oQrysto:save()
聽 聽next
聽 聽oQrysto:end()

RETURN NIL
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
static function totales(oBrw)

oCta:adet[oBrw:nArrayAt,7] := multi(oCta:aDet[ oBrw:nArrayAt, 5 ],oCta:aDet[ oBrw:nArrayAt, 6 ] )
obrw:refresh()
return .t.


De tu c贸digo la parte que no entiendo y que creo que hace lo que yo quiero implementar es

Code (fw): Select all Collapse
 聽 聽 聽:bEditBlock := {|| leecodigo( oQryPro, , {"productos_id", "productos_nombre"} ,;
聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 {"C贸digo", "Nombre"}, oBrw, aItems, 1 ) }
聽 聽 聽 :bEditValid := { | oGet | buscacodigo( oGet:value(), oBrw, aItems ,;
聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 oQryPro, "productos_id" ,;
聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 {"productos_id", "productos_nombre"} ,;
聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 {"C贸digo", "Nombre"}, 1 ) }



Un abrazo

Luis
Posts: 652
Joined: Wed Oct 19, 2005 12:03 PM

Re: xbrowse y array

Posted: Sat May 10, 2014 04:24 PM
Hola lamentablemente no pude hacerlo funcionar as铆 que momentaneamente hice el proyecto con wbrowse (para los casos como factura,remitos ,etc) en los casos que tengo que editar una celda y seleccionar un item.

Les env铆o una imagen de lo que sucede con el prg que envi茅 anteriormente para que sea mas f谩cil captar el problema que acontece cuando hago el valid en la celda 1, como pueden ver se posiciona en el c贸digo de cliente





Despu茅s de volver a navegar desde el c贸digo de cliente y al llegar a la condici贸n d贸nde existe un valid oBrw:setfocus(), se posiciona en la celda 5 y se continua normalmente hasta que llegas al 2潞 fila y otra vez sopa.

Si quito el bvalid de la 1潞 celda navega correctamente

Gracias por vuestra atenci贸n

Luis

Me ayudar铆an a resolver este problema?

Gracias
Posts: 2064
Joined: Fri Jan 06, 2006 09:28 PM

Re: xbrowse y array

Posted: Sat May 10, 2014 06:52 PM

Probastes el que te envie.? ese trabaja sin problemas y esta con array, revisare tu codigo mas detenidamente haber que detalle le consigo, estaba un poco ful y no habia podido revisar lo que pusistes de tu codigo, saludos... :shock:

Dios no est谩 muerto...



Gracias a mi Dios ante todo!
Posts: 652
Joined: Wed Oct 19, 2005 12:03 PM

Re: xbrowse y array

Posted: Sat May 10, 2014 08:50 PM
Jose no lo pude probar ya que no s茅 que funci贸n cumple
Code (fw): Select all Collapse
 聽 聽 聽:bEditBlock := {|| leecodigo( oQryPro, , {"productos_id", "productos_nombre"} ,;
聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 {"C贸digo", "Nombre"}, oBrw, aItems, 1 ) }


todo lo que necesito es lo que hago en bedivalid es abrir otra funci贸n en la que elijo el c贸digo del producto y cargo los elementos necesarios del array, y como se puede ver cargar los carga, pero el problema est谩 en que sale del foco del xbrowse y vuelve al primer get de la funci贸n


Luis
Posts: 652
Joined: Wed Oct 19, 2005 12:03 PM

Re: xbrowse y array

Posted: Sat May 10, 2014 10:31 PM
Cambie la declaraci贸n de la primera celda, en vez de hacer
Code (fw): Select all Collapse
聽 聽 :nEditType := EDIT_GET
聽 聽 :bEditValid := { | oGet, oCol | valido(oBrw,oMysql,oQdetalle) 聽 }


hice lo siguiente:

Code (fw): Select all Collapse
 聽 聽 聽 聽
聽 聽 聽 聽 聽:nEdittype := EDIT_BUTTON
聽 聽 聽 聽 聽:bEditBlock := { || valido(oBrw,oBrw:nArrayAt,oMysql,oQdetalle) 聽}
聽 聽 聽 聽 聽:bOnPostEdit := { | oCol, xVal, nKey | If( nKey <> VK_ESCAPE ,(oCol:value := xVal,;
聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽oBrw:SelectCol( 5 )), )


Y ahora hace lo que necesito, pero la idea era mantener la misma forma que hago con wbrowse , es decir al hacer enter que se abra la ventana con los productos , y seleccionarlo.

Igualmente me gustar铆a saber el porque del comportamiento del primer c贸digo.

Luis

Continue the discussion