Hola
como puedo sumar una columna y poner la suma en el Footer
Saludos
Aida
sumar una columna como le hago??? (YA RESUELTO GRACIAS)
sumar una columna como le hago??? (YA RESUELTO GRACIAS)
Last edited by AIDA on Sun May 11, 2008 9:59 pm, edited 1 time in total.
Que es mejor que programar? creo que nada
Atropellada pero aqui ando
I love Fivewin
séʌǝɹ ןɐ ɐʇsǝ opunɯ ǝʇsǝ
Atropellada pero aqui ando
I love Fivewin
séʌǝɹ ןɐ ɐʇsǝ opunɯ ǝʇsǝ
Holaaaaaa
Ya pude poner la suma de una columna en un footer
pero como le puedo hacer para que refresque la cantidad cuando alteren algun registro.
Saludos
Aida
pero como le puedo hacer para que refresque la cantidad cuando alteren algun registro.
Saludos
Aida
Que es mejor que programar? creo que nada
Atropellada pero aqui ando
I love Fivewin
séʌǝɹ ןɐ ɐʇsǝ opunɯ ǝʇsǝ
Atropellada pero aqui ando
I love Fivewin
séʌǝɹ ןɐ ɐʇsǝ opunɯ ǝʇsǝ
- carlos vargas
- Posts: 1421
- Joined: Tue Oct 11, 2005 5:01 pm
- Location: Nicaragua
NO LE ENTIENDO
NO LE ENTIENDO A NADA
if ! Empty( oCol := oBrw:oCol( "Salary" ) )
oCol:bFooter := { || nTotal }
oCol:lTotal := .t.
oCol:nEditType := EDIT_GET
oCol:bOnPostEdit := {| o, u, n| If( n == 13, ( nTotal += (u - oCust:Salary), oCust:Salary := u, oCust:Save() ), nil ) }
// total salary in the footer changes automatically.
// no need to code or call refresh
endif
Toy como atarantada el dia de hoy
if ! Empty( oCol := oBrw:oCol( "Salary" ) )
oCol:bFooter := { || nTotal }
oCol:lTotal := .t.
oCol:nEditType := EDIT_GET
oCol:bOnPostEdit := {| o, u, n| If( n == 13, ( nTotal += (u - oCust:Salary), oCust:Salary := u, oCust:Save() ), nil ) }
// total salary in the footer changes automatically.
// no need to code or call refresh
endif
Toy como atarantada el dia de hoy
Que es mejor que programar? creo que nada
Atropellada pero aqui ando
I love Fivewin
séʌǝɹ ןɐ ɐʇsǝ opunɯ ǝʇsǝ
Atropellada pero aqui ando
I love Fivewin
séʌǝɹ ןɐ ɐʇsǝ opunɯ ǝʇsǝ
Aida..
precisamente estoy terminando algo parecido usando TWBrowse.. siguiendo los ejemplos que vienen en los fuentes de la clase..
Espero y te pueda servir yo tambien pase por esa jaqueca.. saludos
GABO
precisamente estoy terminando algo parecido usando TWBrowse.. siguiendo los ejemplos que vienen en los fuentes de la clase..
Code: Select all
// Los TEXTBOX que pintan los totales
REDEFINE GET oGets[15] VAR hVars["SUBTOTAL"] ID 1115 OF oDlg PICTURE '99,999,999,999.99' UPDATE;
COLOR CLR_BLACK, RGB(176,196,222) WHEN .F. FONT oFontImp
REDEFINE GET oGets[16] VAR hVars["DESCTOS"] ID 1116 OF oDlg PICTURE '99,999,999,999.99' UPDATE;
COLOR CLR_BLACK, RGB(176,196,222) WHEN .F. FONT oFontImp
REDEFINE GET oGets[17] VAR hVars["TOT_IVA"] ID 1117 OF oDlg PICTURE '99,999,999,999.99' UPDATE;
COLOR CLR_BLACK, RGB(176,196,222) WHEN .F. FONT oFontImp
REDEFINE GET oGets[18] VAR hVars["IMPORTE"] ID 1118 OF oDlg PICTURE '99,999,999,999.99' UPDATE;
COLOR CLR_BLACK, RGB(176,196,222) WHEN .F. FONT oFontImp
oGets[15]:lDisColors = .F.
oGets[16]:lDisColors = .F.
oGets[17]:lDisColors = .F.
oGets[18]:lDisColors = .F.
// El bitmap que se pinta en la primera columna del browse estilo de xBrowse
hBitmap := LoadBitmap( GetResources(),"BMP_ROW_SELECTION" )
// Se crea el browse desde recurso usando TWBROWSE
aDetalle:= {}
REDEFINE LISTBOX oBrwDetalle ;
FIELDS "" ;
HEADERS "", "Codigo", "Nombre/Titulo del libro", "Cantidad", "Costo Unitario", ;
"D-1", "D-2", "Importe";
ID 1200 OF oDlg;
FIELDSIZES 30, 120, 327, 75, 100, 50, 50, 100
oBrwDetalle:bLine:= {|nAt| nAt:= oBrwDetalle:nAt, ;
If( Len( aDetalle ) < 1 .or. nAt > Len( aDetalle ),;
Array(8), ;
{ If( oBrwDetalle != NIL .and. oBrwDetalle:lSelect, hBitmap, 0 ),;
aDetalle[nAt,1], ;
aDetalle[nAt,2], ;
Transform( aDetalle[nAt,3], '@Z 999,999,999' ), ;
Transform( aDetalle[nAt,4], '@Z 999,999,999.99' ), ;
Transform( aDetalle[nAt,5], '@Z 99.99' ), ;
Transform( aDetalle[nAt,6], '@Z 99.99' ), ;
Transform( aDetalle[nAt,7], '@Z 999,999,999.99' ) } ) }
oBrwDetalle:aJustify:= { 2, .F., .F., .T., .T., .T., .T., .T. } // Se justifican las columnas left-center-right
oBrwDetalle:SetArray( aDetalle ) // Se asignan los datos del arreglo en este caso esta VACIO
// Bloque de codigo que sirve para controlar la edicion en el browse
oBrwDetalle:bEdit:= {|nCol, cBuffer, lFirstEdit|;
EditaCelda( oBrwDetalle, nCol, cBuffer, aDetalle, lFirstEdit, ;
aTotales, Self, hVars, oGets ) }
// Este es estetico solo para mostrar la primera columna con el color de windows tipo xBrowse
oBrwDetalle:bBkColor:= {|nRow,nCol,nStyle| ;
if( nStyle==3 .OR. nStyle=0, if( nCol==1,GetSysColor( COLOR_BTNFACE ),),) }
oBrwDetalle:bTextColor:= {|nRow,nCol,nStyle| ;
if( nStyle==3 .OR. nStyle=0, if( nCol==1,RGB( 192,192,192 ),),) }
// Configuracion del browse
oBrwDetalle:lAdjLastCol := .T.
oBrwDetalle:lAutoEdit := .T.
oBrwDetalle:lAutoSkip := .T.
oBrwDetalle:lAdjLastCol := .F.
oBrwDetalle:lDrawHeaders := .T.
oBrwDetalle:lDrawFooters := .F.
oBrwDetalle:lVScroll := .T.
oBrwDetalle:lHScroll := .F.
oBrwDetalle:nLineStyle := 1
oBrwDetalle:nHeaderStyle := 2
oBrwDetalle:nClrLine := RGB(179,219,255) // Color de las lineas que separan las columnas y filas
oBrwDetalle:nLineHeight := 18
oBrwDetalle:nHeaderHeight:= 20
// Botones para el ABC en el browse
REDEFINE SBUTTON oBtns[1] ID 1201 OF oDlg;
ACTION ( AddNewItem( aDetalle, oBrwDetalle, hVars ), oBrwDetalle:Edit() );
RESOURCE "BMP_ITEM_ADD",,"BMP_ITEM_ADD_GREY" LOOK W97;
TOOLTIP "Agregar titulo a la compra"
REDEFINE SBUTTON oBtns[2] ID 1202 OF oDlg;
ACTION DelSelItem( aDetalle, oBrwDetalle, aTotales ) ;
RESOURCE "BMP_ITEM_DEL",,"BMP_ITEM_DEL_GREY" LOOK W97;
TOOLTIP "Eliminar titulo de la compra"
REDEFINE SBUTTON oBtns[3] ID 1203 OF oDlg;
ACTION If( Len(aDetalle) > 0 .AND. ;
oBrwDetalle:nAt <= Len(aDetalle) .AND. oBrwDetalle:nAt > 0,;
( oBrwDetalle:Edit(), oBrwDetalle:SetFocus() ), ) ;
RESOURCE "BMP_ITEM_EDIT",,"BMP_ITEM_EDIT_GREY" LOOK W97;
TOOLTIP "Modificar titulo"
/*----------------------------------------------------------------------------------------------------*/
STATIC FUNCTION EditaCelda( oLbx, nCol, cBuffer, aDatos, lFirstEdit, aTotal, ;
oSelf, hGets, oGets )
// oLbx - Objeto tWbrowse
// nCol - Columna sobre la cual se esta haciendo edicion
// cBuffer - Valor de la celda sobre la que se escribe
// aDatos - Array de datos del browse
// lFirstEdit - Si es la primera vez que se edita
// aTotal - Arrau de totales de las columnas del browse SubTotal -Iva - Descuentos - Total Gral
// oSelf - oApplication
// hGets - Array de variables de los gets
// oGets - Array de objetos gets
/*----------------------------------------------------------------------------------------------------*/
LOCAL aResult, nAt:= oLbx:nAt, uBuffer, lContinue:= .t.
LOCAL bValid, nColReal:= nCol
LOCAL nSubTotal, nImport_1, nImport_2, nDescto_1, nDescto_2
nCol-- // Para que sea como si no exisiera la primer columna del BitMap flechita
uBuffer := aDatos[nAt,nCol]
DO WHILE .T.
DO CASE
CASE nCol == 1
bValid:= {|| aResult:= ValidaItems( @uBuffer, oSelf ), aResult[2] }
IF lContinue:= oLbx:lEditCol( nColReal, @uBuffer,, bValid, RGB(0,0,0), RGB(149,198,147) )
aDatos[nAt,1]:= uBuffer
aDatos[nAt,2]:= aResult[1]
aDatos[nAt,4]:= aResult[3]
ENDIF
CASE nCol == 3 // Cantidad
IF lContinue:= oLbx:lEditCol( nColReal, @uBuffer, "@Z 999,999,999",,RGB(0,0,0), RGB(149,198,147))
If uBuffer <= 0
MsgAlert("Debe Especificar una cantidad !!!")
Loop
EndIf
aDatos[nAt,3]:= uBuffer
ENDIF
CASE nCol == 4 // Costo Unitario
If lContinue:= oLbx:lEditCol( nColReal, @uBuffer, "@Z 999,999,999.99",,RGB(0,0,0), RGB(149,198,147) )
aDatos[nAt,4]:= uBuffer
ENDIF
CASE nCol == 5 // Descuento 1
If lContinue:= oLbx:lEditCol( nColReal, @uBuffer, "@Z 99.99",, RGB(0,0,0), RGB(149,198,147) )
aDatos[nAt,5]:= uBuffer
ENDIF
CASE nCol == 6 // Descuento 2
If lContinue:= oLbx:lEditCol( nColReal, @uBuffer, "@Z 99.99",, RGB(0,0,0), RGB(149,198,147) )
aDatos[nAt,6]:= uBuffer
aDatos[nAt,8]:= .F. // Ya no es un Nuevo Registro !!!
EndIf
CASE nCol == 7 .AND. ! lFirstEdit .and. Len( aDatos ) == nAt // Importe total
AddNewItem( aDatos, oLbx, hGets )
ENDCASE
IF ! lContinue .AND. aDatos[nAt,8] // Se habia agregado un nuevo Item !!!
DelSelItem( aDatos, oLbx, hGets, oGets )
RETURN .F.
ENDIF
EXIT
ENDDO
IF Len( aDatos ) > 0
// Estas operaciones son para poner el importe de la columna de Total aplicando
// los vbalores de las columnas Descuento-1 y Descuento-2
nSubTotal:= aDatos[nAt,3] * aDatos[nAt,4]
nDescto_1:= IF( aDatos[nAt,5] > 0, ( nSubTotal * ( aDatos[nAt,5] / 100) ), 0 )
nImport_1:= nSubTotal - nDescto_1
nDescto_2:= IF( aDatos[nAt,6] > 0, ( nImport_1 * ( aDatos[nAt,6] / 100) ), 0 )
nImport_2:= nImport_1 - nDescto_2
aDatos[nAt,7]:= nImport_2
SumaTotal( aDatos, hGets, oGets )
ENDIF
IF lContinue
DO CASE
CASE oLbx:nLastKey == VK_UP
return If( !GetKeyState(VK_SHIFT), -3, -2 )
CASE oLbx:nLastKey == VK_DOWN
return If( !GetKeyState(VK_SHIFT), 3, 2 )
CASE oLbx:nLastKey == VK_TAB
return If( GetKeyState(VK_SHIFT), -1, 1 )
ENDCASE
ENDIF
RETURN lContinue
/*----------------------------------------------------------------------------------------------------*/
STATIC Function AddNewItem( aDatos, oLbx, hGets )
// Funcion donde se agrega un nuevo elemento al arreglo de los datos del browse
/*----------------------------------------------------------------------------------------------------*/
LOCAL nAt, nDescto1, nDescto2
nDescto1:= 0
nDescto2:= 0
IF hGets["DESCTO1"] > 0
nDescto1:= hGets["DESCTO1"]
ENDIF
IF hGets["DESCTO2"] > 0
nDescto2:= hGets["DESCTO2"]
ENDIF
// Aqui se agrega un nuevo registro al browse
Aadd( aDatos, { Space(20), Space(45), 1, 0, nDescto1, nDescto2, 0, .T. } )
oLbx:Refresh()
oLbx:lHitBottom:= .F.
oLbx:GoBottom()
SysRefresh()
return NIL
/*----------------------------------------------------------------------------------------------------*/
STATIC Function DelSelItem( aDatos, oLbx, hGets, oGets )
// Elimina un elemento del arreglo lo cual significa un registro del browse
/*----------------------------------------------------------------------------------------------------*/
LOCAL nAt:= oLbx:nAt
ADel( aDatos, nAt )
ASize( aDatos, Len( aDatos ) - 1 )
oLbx:GoUp()
oLbx:Refresh()
SumaTotal( aDatos, hGets, oGets )
RETURN NIL
/*----------------------------------------------------------------------------------------------------*/
STATIC Function SumaTotal( aDatos, hGets, oGets )
/*----------------------------------------------------------------------------------------------------*/
LOCAL aItems, nSubTotal, nImport_1, nImport_2, nDescto_1, nDescto_2, nIva, nTotal
hGets["SUBTOTAL"]:= 0
hGets["DESCTOS"] := 0
hGets["TOT_IVA"] := 0
hGets["IMPORTE"] := 0
FOR EACH aItems IN aDatos
nSubTotal:= aItems[3] * aItems[4] // Cantidad * Costo Unitario
nDescto_1:= IF( aItems[5] > 0, ( nSubTotal * ( aItems[5] / 100) ), 0 )
nImport_1:= nSubTotal - nDescto_1
nDescto_2:= IF( aItems[6] > 0, ( nImport_1 * ( aItems[6] / 100) ), 0 )
nImport_2:= nImport_1 - nDescto_2
nIva := IF( hGets["IVA"] > 0, ( nImport_2 * ( hGets["IVA"] / 100) ), 0 )
nTotal := nImport_2 + nIva
hGets["SUBTOTAL"]+= nImport_2
hGets["DESCTOS"] += (nDescto_1 + nDescto_2)
hGets["TOT_IVA"] += nIva
hGets["IMPORTE"] += nTotal
END
// Y por fin aqui se actualiza los totales refrescando los TEXTBOX
oGets[15]:Refresh()
oGets[16]:Refresh()
oGets[17]:Refresh()
oGets[18]:Refresh()
RETURN NIL
/*----------------------------------------------------------------------------------------------------*/
STATIC FUNCTION ValidaItems( xVar, oSelf )
// Valida la clave del ITEM en esta caso son libros o sea la clave del libro y despliega una ventana
// en caso que la clave no se encuentre el archivo de catalogo
/*----------------------------------------------------------------------------------------------------*/
LOCAL cOLdOrder, lRetorno, aRetorno, cClave, cDescrip
cOldOrder:= ( oSelf:oTbLibros:cAlias )->( OrdSetFocus("CLAVE") )
IF oSelf:oTbLibros:Seek( xVar )
aRetorno:= { oSelf:oTbLibros:FieldGet( "TITULO" ), .T., oSelf:oTbLibros:FieldGet("COSTO") }
ELSE
lRetorno:= HlpTitulos( @cClave, xVar, @cDescrip, oSelf, 100, 200 )
IF lRetorno
aRetorno:= { oSelf:oTbLibros:FieldGet("TITULO"), .T., oSelf:oTbLibros:FieldGet("COSTO") }
xVar:= cClave
ELSE
aRetorno:= { " ", .F., 0 }
ENDIF
ENDIF
( oSelf:oTbLibros:cAlias )->( OrdSetFocus( cOldOrder ) )
RETURN aRetorno
GABO
GRACIAS!!!!
Y tambien es igual con txbrowse es el que toy usando
me pondre a leerlo con calmita
Que lindo y muchas gracias
Aida
me pondre a leerlo con calmita
Que lindo y muchas gracias
Aida
Que es mejor que programar? creo que nada
Atropellada pero aqui ando
I love Fivewin
séʌǝɹ ןɐ ɐʇsǝ opunɯ ǝʇsǝ
Atropellada pero aqui ando
I love Fivewin
séʌǝɹ ןɐ ɐʇsǝ opunɯ ǝʇsǝ
Hola aida
La forma de de definir un Listbox y que sume tu footer es la siguiente
REDEFINE LISTBOX oLbx ;
FIELDS oPreccos:Codigo , ;
oPreccos:Nombre , ;
transform(oPreccos:ventas,"999,999,999.99") , ;
transform(oPreccos:Costo ,"999,999,999.99") , ;
transform(oPreccos:margen,"999,999,999.99") , ;
transform(oPreccos:utilidad,"999,999,999.99")+"%" ;
HEADER "Código","Nombre","Ventas", "Costo","Utilidad","Margen" ;
ID 172 ;
OF oWndFact01 ;
ON DBLCLICK funcion( variable para mandar a la funcion ) ;
SIZES 40,380,75,75,75,50 UPDATE
oPreccos:SetBrowse( oLbx )
oLbx:nLineHeight := 16
oLbx:nHeaderHeight := 16
oLbx:nFreeze := 4
oLbx:aHJustify:={2,2,2,2,2}
oLbx:aJustify:={.t.,.f.,.t.,.t.,.t.}
oLbx:lDrawFooters :=.T.
oLbx:aActions := Array( 6 )
oLbx:aActions[1] := { || OrdenArEq( 3, 3 , oPreccos, oLbx,oWndFact01,aGets ) }
oLbx:aActions[2] := { || OrdenArEq( 2, 3 , oPreccos, oLbx,oWndFact01,aGets ) }
oLbx:aActions[3] := { || OrdenArEq( 1, 3 , oPreccos, oLbx,oWndFact01,aGets ) }
oLbx:aActions[4] := { || OrdenArEq( 4, 3 , oPreccos, oLbx,oWndFact01,aGets ) }
oLbx:aActions[5] := nil
oLbx:aActions[6] := nil
aTot1 := aTot1 + 1+2+3 etc
aTot2 := aTot2 + 1+2+3 etc
aTot3 := aTot3 + 1+2+3 etc
aTot4 := aTot4 + 1+2+3 etc
///Esta seria la forma de sumar en el foote del oLbx
oLbx:aFooters :={|| {"","Total",Tran(aTot[1],"9,999,999,999 "),Tran(aTot[2],"9,999,999,999 "),Tran(aTot[3],"9,999,999,999 "),Tran(aTot[4],"9,999,999,999 ") }}
//Ahora para refrescar seria de la siguiente forma
oWndFact01:Update()
oLbx:Refresh()
Espero que te sirva
Atentamente Julio Ponce
La forma de de definir un Listbox y que sume tu footer es la siguiente
REDEFINE LISTBOX oLbx ;
FIELDS oPreccos:Codigo , ;
oPreccos:Nombre , ;
transform(oPreccos:ventas,"999,999,999.99") , ;
transform(oPreccos:Costo ,"999,999,999.99") , ;
transform(oPreccos:margen,"999,999,999.99") , ;
transform(oPreccos:utilidad,"999,999,999.99")+"%" ;
HEADER "Código","Nombre","Ventas", "Costo","Utilidad","Margen" ;
ID 172 ;
OF oWndFact01 ;
ON DBLCLICK funcion( variable para mandar a la funcion ) ;
SIZES 40,380,75,75,75,50 UPDATE
oPreccos:SetBrowse( oLbx )
oLbx:nLineHeight := 16
oLbx:nHeaderHeight := 16
oLbx:nFreeze := 4
oLbx:aHJustify:={2,2,2,2,2}
oLbx:aJustify:={.t.,.f.,.t.,.t.,.t.}
oLbx:lDrawFooters :=.T.
oLbx:aActions := Array( 6 )
oLbx:aActions[1] := { || OrdenArEq( 3, 3 , oPreccos, oLbx,oWndFact01,aGets ) }
oLbx:aActions[2] := { || OrdenArEq( 2, 3 , oPreccos, oLbx,oWndFact01,aGets ) }
oLbx:aActions[3] := { || OrdenArEq( 1, 3 , oPreccos, oLbx,oWndFact01,aGets ) }
oLbx:aActions[4] := { || OrdenArEq( 4, 3 , oPreccos, oLbx,oWndFact01,aGets ) }
oLbx:aActions[5] := nil
oLbx:aActions[6] := nil
aTot1 := aTot1 + 1+2+3 etc
aTot2 := aTot2 + 1+2+3 etc
aTot3 := aTot3 + 1+2+3 etc
aTot4 := aTot4 + 1+2+3 etc
///Esta seria la forma de sumar en el foote del oLbx
oLbx:aFooters :={|| {"","Total",Tran(aTot[1],"9,999,999,999 "),Tran(aTot[2],"9,999,999,999 "),Tran(aTot[3],"9,999,999,999 "),Tran(aTot[4],"9,999,999,999 ") }}
//Ahora para refrescar seria de la siguiente forma
oWndFact01:Update()
oLbx:Refresh()
Espero que te sirva
Atentamente Julio Ponce
Holaaaaaa
Hola!!!
Ya por fin le entendi ya pude poner una sumita en el en el Footer y que se refresque cuando ponen o modifican un dato.
agradesco mucho a:
carlos vargas
gabo
jponce
Vicente Heredia Guijarro
y si me falto alguien tambien muchas gracias por su ayuda
es chistoso como algunas cosas nos pueden atorar y mas cuando nos bloqueamos del cerebrito pero con amigos como ustedes todo se aclara.
Atentamente
Aida
PD aqui falta una carita de beso y otra de habrazo
Ya por fin le entendi ya pude poner una sumita en el en el Footer y que se refresque cuando ponen o modifican un dato.
agradesco mucho a:
carlos vargas
gabo
jponce
Vicente Heredia Guijarro
y si me falto alguien tambien muchas gracias por su ayuda
es chistoso como algunas cosas nos pueden atorar y mas cuando nos bloqueamos del cerebrito pero con amigos como ustedes todo se aclara.
Atentamente
Aida
PD aqui falta una carita de beso y otra de habrazo
Que es mejor que programar? creo que nada
Atropellada pero aqui ando
I love Fivewin
séʌǝɹ ןɐ ɐʇsǝ opunɯ ǝʇsǝ
Atropellada pero aqui ando
I love Fivewin
séʌǝɹ ןɐ ɐʇsǝ opunɯ ǝʇsǝ