Armando wrote:José Luis:
Muchas gracias, es un buen comienzo
Saludos
if msgyesno("Want to add to other database")
FOR I = 1 TO LEN(oBrwCol:aSELECTED) // obrw:aSELECTED is an array containing recnos marked
oBrwCol:BookMark := oBrwCol:aSelected[ i ] // works for dbf, rowset, ado and all
att->(dbappend())
att->artcode = nofoto->id // database of browse, but you can also use xbrowse data
att->fab_name = nofoto->fabrikan
att->colnaam = oBrwCol:A:value
att->colstr = upper(alltrim(nofoto->id)+oBrwCol:A:value)
next
oBrwAtt:refresh()
endif
Armando wrote:Amigos:
Gracias a su valioso apoyo he logrado seleccionar varios registros de un xBrowse, ahora
lo que necesito es que cada que se elija un registro obtener la suma de una columna,
que método debo usar para sumar dicha columna?
Estoy usando FWH1711
Saludos
#include "fivewin.ch"
REQUEST DBFCDX
function Main()
local oDlg, oBrw, oFont
USE CUSTOMER NEW ALIAS CUST VIA "DBFCDX"
DEFINE FONT oFont NAME "TAHOMA" SIZE 0,-14
DEFINE DIALOG oDlg SIZE 700,500 PIXEL TRUEPIXEL FONT oFont ;
TITLE FWVERSION + " : MULTISELECT"
@ 60,20 XBROWSE oBrw SIZE -20,-20 PIXEL OF oDlg ;
DATASOURCE "CUST" ;
COLUMNS .F., "FIRST", "CITY", "SALARY" ;
HEADERS "" ;
CELL LINES FOOTERS NOBORDER
WITH OBJECT oBrw
:nMarqueeStyle := MARQSTYLE_HIGHLROWMS
WITH OBJECT :aCols[ 1 ]
:bEditValue := { || AScan( oBrw:aSelected, oBrw:BookMark ) > 0 }
:SetCheck()
:nHeadBmpNo := 2
:bFooter := { || Len( oBrw:aSelected ) }
END
WITH OBJECT :Salary
:nFooterType := AGGR_SUM
:bSumCondition := { || AScan( oBrw:aSelected, oBrw:BookMark ) > 0 }
END
:bOnMultiSelect := { || oBrw:MakeTotals() }
:bChange := { || If( Len( oBrw:aSelected ) <= 1, ;
( oBrw:Salary:nTotal := oBrw:Salary:Value, ;
oBrw:Salary:RefreshFooter() ), ;
nil ) }
:MakeTotals()
//
:CreateFromCode()
END
@ 10, 20 BTNBMP PROMPT "SelectAll" SIZE 100,40 PIXEL OF oDlg FLAT ;
ACTION ( oBrw:SelectAll(), oBrw:SetFocus() )
@ 10,140 BTNBMP PROMPT "ClearAll" SIZE 100,40 PIXEL OF oDlg FLAT ;
ACTION ( oBrw:SelectNone(), oBrw:SetFocus() )
@ 10,300 SAY "Shift-Click to Select Block or Rows" + CRLF + ;
"Ctrl-Click to Toggle Selection" ;
SIZE 380,40 PIXEL OF oDlg RIGHT ;
COLOR CLR_HRED,CLR_WHITE TRANSPARENT
ACTIVATE DIALOG oDlg CENTERED
RELEASE FONT oFont
return nil
oBrw:=TxBrowse():New(oDlg)
oBrw:nMarqueeStyle := MARQSTYLE_HIGHLROWMS
oBrw:nColDividerStyle := LINESTYLE_LIGHTGRAY
oBrw:nRowDividerStyle := LINESTYLE_LIGHTGRAY
oBrw:lColDividerComplete := (.F.)
oBrw:nHeaderHeight := 25
oBrw:nRowHeight := 22
oBrw:nHeaderLines := 1
oBrw:nDataLines := 1
oBrw:nFooterHeight := 20
oBrw:nFooterLines := 1
oBrw:lFooter := (.T.)
oBrw:lHScroll := (.F.)
aCol[ 1] := oBrw:AddCol()
aCol[ 1]:bStrData := { || IF(oRsCxc:RecordCount() > 0,TRANSFORM(oRsCxc:Fields("CARCAR"):Value,"@Z 9999999"),SPACE(01))}
aCol[ 1]:cHeader := "Factura"
aCol[ 1]:nHeadStrAlign := AL_RIGHT
aCol[ 1]:nDataStrAlign := AL_RIGHT
aCol[ 1]:nWidth := 60
aCol[ 2] := oBrw:AddCol()
aCol[ 2]:bStrData := { || IF(oRsCxc:RecordCount() > 0,TRANSFORM(oRsCxc:Fields("CARCLI"):Value,"@Z 99999"),SPACE(01))}
aCol[ 2]:cHeader := "Cliente"
aCol[ 2]:nHeadStrAlign := AL_RIGHT
aCol[ 2]:nDataStrAlign := AL_RIGHT
aCol[ 2]:nWidth := 60
aCol[ 3] := oBrw:AddCol()
aCol[ 3]:bStrData := { || IF(oRsCxc:RecordCount() > 0,oRsCxc:Fields("CLINOM"):Value,SPACE(01))}
aCol[ 3]:cHeader := "Nombre o Razón Social"
aCol[ 3]:nHeadStrAlign := AL_LEFT
aCol[ 3]:nDataStrAlign := AL_LEFT
aCol[ 3]:nWidth := 300
aCol[ 4] := oBrw:AddCol()
aCol[ 4]:bStrData := { || IF(oRsCxc:RecordCount() > 0,Date2Txt(DameFecha(oRsCxc:Fields("CARFEC"):Value)),SPACE(01))}
aCol[ 4]:cHeader := "Emisión"
aCol[ 4]:nHeadStrAlign := AL_RIGHT
aCol[ 4]:nDataStrAlign := AL_RIGHT
aCol[ 4]:nWidth := 85
aCol[ 5] := oBrw:AddCol()
aCol[ 5]:bStrData := { || IF(oRsCxc:RecordCount() > 0,Date2Txt(DameFecha(oRsCxc:Fields("CARVTO"):Value)),SPACE(01))}
aCol[ 5]:cHeader := "Vencimiento"
aCol[ 5]:nHeadStrAlign := AL_RIGHT
aCol[ 5]:nDataStrAlign := AL_RIGHT
aCol[ 5]:nWidth := 85
aCol[ 5]:cFooter := { || Len( oBrw:aSelected ) }
aCol[ 6] := oBrw:AddCol()
aCol[ 6]:bStrData := { || IF(oRsCxc:RecordCount() > 0,TRANSFORM(oRsCxc:Fields("CARIMP"):Value,"@Z 99,999,999.99"),SPACE(01))}
aCol[ 6]:cHeader := "Saldo"
aCol[ 6]:nHeadStrAlign := AL_RIGHT
aCol[ 6]:nDataStrAlign := AL_RIGHT
aCol[ 6]:nWidth := 48
aCol[ 6]:nFooterType := AGGR_SUM
oBrw:bOnMultiSelect := { || oBrw:MakeTotals() }
oBrw:bChange := { || IF( LEN( oBrw:aSelected ) <= 1, ;
( oBrw:aCol[6]:nTotal := oBrw:aCol[ 6]:Value,;
oBrw:aCol[6]:RefreshFooter() ),NIL ) }
oBrw:l2007 := (.F.)
oBrw:nStretchCol := STRETCHCOL_LAST
oBrw:bClrHeader := { || {CLR_WHITE,CLR_BLACK} }
oBrw:bClrStd := { || {CLR_BLACK,CLR_WHITE} }
oBrw:bClrFooter := { || {CLR_WHITE,CLR_BLACK} }
oBrw:nRecSelColor := oApp:nRowParClr // Triangulo de selección
oBrw:bClrSel := { || {CLR_BLACK,CLR_WHITE} }
oBrw:bClrSel := {|| IF( oRsCxc:AbsolutePosition % oApp:nRowsInt == 0 ,{ CLR_BLACK, oApp:nRowParClr },{ CLR_BLACK, oApp:nRowNonClr }) }
oBrw:bClrSelFocus := { || {oApp:nFClrFocus,oApp:nBClrFocus} }
oBrw:bGoTop := { || IF( ! oRsCxc:BOF() .AND. ! oRsCxc:EOF(), oRsCxc:MoveFirst(), ) }
oBrw:bGoBottom := { || IF( ! oRsCxc:BOF() .AND. ! oRsCxc:EOF(), oRsCxc:MoveLast(), ) }
oBrw:bBof := { || oRsCxc:BOF() }
oBrw:bEof := { || oRsCxc:EOF() }
oBrw:bBookMark := { | uBm | IF( oRsCxc:BOF() .AND. oRsCxc:EOF(), 0, IF( uBm == NIL, oRsCxc:BookMark, oRsCxc:BookMark := uBm ) ) }
oBrw:bKeyNo := { | n | IF( oRsCxc:BOF() .AND. oRsCxc:EOF(), 0, IF( n == NIL, oRsCxc:AbsolutePosition, oRsCxc:AbsolutePosition := n ) ) }
oBrw:bKeyCount := {|| oRsCxc:RecordCount() }
oBrw:SetAdo(oRsCxc)
oBrw:bClrStd := {|| IF( oRsCxc:AbsolutePosition % oApp:nRowsInt == 0 ,{ CLR_BLACK, oApp:nRowParClr },{ CLR_BLACK, oApp:nRowNonClr }) }
oBrw:nRecSelColor := oApp:nRowParClr
oBrw:CreateFromResource(201)
aCol[ 6]:bStrData := { || IF(oRsCxc:RecordCount() > 0,TRANSFORM(oRsCxc:Fields("CARIMP"):Value,"@Z 99,999,999.99"),SPACE(01))}
aCols[ 6 ]:nFooterType := AGGR_SUM
FWNumFormat( "A", .t. )
REDEFINE XBROWSE oBrw ID 201 OF oDlg;
DATASOURCE oRsCxc ;
COLUMNS "CARCAR", "CARCLI", "CLINOM", "CARFEC", "CARVIO", "CARIMP" ;
HEADERS "Factura", "Cliente", "Nombre o Razón Social", "Emisión", "Vencimiento", "Saldo" ;
COLSIZES 60,60,300,85,85 ;
FOOTERS
// Your preferences
WITH OBJECT oBrw
:l2007 := .f.
:lHScroll := .f.
:nMarqueeStyle := MARQSTYLE_HIGHLROWMS
:nColDividerStyle := LINESTYLE_LIGHTGRAY
:nRowDividerStyle := LINESTYLE_LIGHTGRAY
:nStretchCol := STRETCHCOL_WIDEST
:bClrHeader := { || {CLR_WHITE,CLR_BLACK} }
:bClrFooter := { || {CLR_WHITE,CLR_BLACK} }
:bClrSel := {|| IF( oBrw:KeyNo % oApp:nRowsInt == 0 ,{ CLR_BLACK, oApp:nRowParClr },{ CLR_BLACK, oApp:nRowNonClr }) }
:bClrSelFocus := { || {oApp:nFClrFocus,oApp:nBClrFocus} }
:bClrStd := {|| IF( oBrw:KeyNo % oApp:nRowsInt == 0 ,{ CLR_BLACK, oApp:nRowParClr },{ CLR_BLACK, oApp:nRowNonClr }) }
:nRecSelColor := oApp:nRowParClr
//
:lDisplayZeros := .f. // zero values are not displayed. Added by GNRao. No need to use @Z
END
// Settings for Totals and Count
WITH OBJECT oBrw
:aCols[ 5]:bFooter := { || Len( oBrw:aSelected ) }
WITH OBJECT :aCols[ 6]
:nFooterType := AGGR_SUM
:bSumCondition := { || AScan( oBrw:aSelected, oBrw:BookMark ) > 0 }
END
:bOnMultiSelect := { || oBrw:MakeTotals() }
:bChange := { || IF( LEN( oBrw:aSelected ) <= 1, ;
( oBrw:oCol(6):nTotal := oBrw:oCol(6):Value,;
oBrw:oCol(6):RefreshFooter() ),NIL ) }
:MakeTotals()
END
ACTIVATE DIALOG oDlg // <other clauses>
oBrw:bGoTop := { || IF( ! oRsCxc:BOF() .AND. ! oRsCxc:EOF(), oRsCxc:MoveFirst(), ) }
oBrw:bGoBottom := { || IF( ! oRsCxc:BOF() .AND. ! oRsCxc:EOF(), oRsCxc:MoveLast(), ) }
oBrw:bBof := { || oRsCxc:BOF() }
oBrw:bEof := { || oRsCxc:EOF() }
oBrw:bBookMark := { | uBm | IF( oRsCxc:BOF() .AND. oRsCxc:EOF(), 0, IF( uBm == NIL, oRsCxc:BookMark, oRsCxc:BookMark := uBm ) ) }
oBrw:bKeyNo := { | n | IF( oRsCxc:BOF() .AND. oRsCxc:EOF(), 0, IF( n == NIL, oRsCxc:AbsolutePosition, oRsCxc:AbsolutePosition := n ) ) }
oBrw:bKeyCount := {|| oRsCxc:RecordCount() }
oBrw:SetAdo(oRsCxc)
oBrw:CreateFromResource(201)
REDEFINE XBROWSE oBrw ID 201 OF oDlg;
DATASOURCE oRsCxc ;
COLUMNS "CARCAR", "CARCLI", "CLINOM", "CARFEC", "CARVTO", "CARIMP" ;
HEADERS "Factura", "Cliente", "Nombre o Razón Social", "Emisión", "Vencimiento", "Saldo" ;
COLSIZES 60,60,300,85,85 ;
FOOTERS
// Your preferences
WITH OBJECT oBrw
:l2007 := .f.
:lHScroll := .f.
:nMarqueeStyle := MARQSTYLE_HIGHLROWMS
:nColDividerStyle := LINESTYLE_LIGHTGRAY
:nRowDividerStyle := LINESTYLE_LIGHTGRAY
:nStretchCol := STRETCHCOL_WIDEST
:bClrHeader := { || {CLR_WHITE,CLR_BLACK} }
:bClrFooter := { || {CLR_WHITE,CLR_BLACK} }
:bClrSel := { || IF( oBrw:KeyNo % oApp:nRowsInt == 0 ,{ CLR_BLACK, oApp:nRowParClr },{ CLR_BLACK, oApp:nRowNonClr }) }
:bClrSelFocus := { || {oApp:nFClrFocus,oApp:nBClrFocus} }
:bClrStd := { || IF( oBrw:KeyNo % oApp:nRowsInt == 0 ,{ CLR_BLACK, oApp:nRowParClr },{ CLR_BLACK, oApp:nRowNonClr }) }
:nRecSelColor := oApp:nRowParClr
:lDisplayZeros := .f. // zero values are not displayed. Added by GNRao. No need to use @Z
END
// Settings for Totals and Count
WITH OBJECT oBrw
:aCol[ 5]:bFooter := { || Len( oBrw:aSelected ) } // this line produces the error
WITH OBJECT :aCol[ 6]
:nFooterType := AGGR_SUM
:bSumCondition := { || AScan( oBrw:aSelected, oBrw:BookMark ) > 0 }
END
:bOnMultiSelect := { || oBrw:MakeTotals() }
:bChange := { || IF( LEN( oBrw:aSelected ) <= 1, ;
( oBrw:oCol(6):nTotal := oBrw:oCol(6):Value,;
oBrw:oCol(6):RefreshFooter() ),NIL ) }
:MakeTotals()
END
Return to FiveWin para Harbour/xHarbour
Users browsing this forum: wilsongamboa and 42 guests