there are two errors
the footers totale of the last column
and the says at the bottom of the dialog when I move the mouse over the xbrowse add values : why ?
the test
- Code: Select all Expand view RUN
#Include "Fivewin.ch"
#include "xbrowse.ch"
#include "constant.ch"
#define MARQSTYLE_HIGHLWIN7 7
#define LIGHTCYAN nRGB( 203, 225, 252 )
REQUEST DBFCDX
REQUEST DBFFPT
external ordkeyno, ordkeycount,ordcreate,ordkeygoto
Static nTotaleGenerale,nTotaleIva,nTotaleImponibile
Static oSay1,oSay2,oSay3
Function Invoice()
Local oFrmInvoice
Local oBrw
Local oFld1,oFld2,oFld3
Local oBtn[3]
Local nBottom := 30
Local nRight := 90
Local nWidth := Max( nRight * DLG_CHARPIX_W, 180 )
Local nHeight := nBottom * DLG_CHARPIX_H
RDDSETDEFAULT( "DBFCDX" )
USE INVOICE ALIAS IN
nTotaleGenerale :=0
nTotaleIva :=0
nTotaleImponibile :=0
DEFINE FONT oFontTotal NAME "Arial" SIZE 0, -25
DEFINE DIALOG oFrmInvoice ;
TITLE "Invoice" ;
SIZE nWidth, nHeight PIXEL ;
GRADIENT { { 1,CLR_WHITE, LIGHTCYAN } }
oBrw := TXBrowse():New( oFrmInvoice )
oBrw:nTop := 66
oBrw:nLeft := 0.8
oBrw:nBottom := 120
oBrw:nRight := 350
oBrw:lfooter:=.t.
aBrowse := { { { ||IN->ITCODE}, i18n("Codice"), 50, },;
{ { ||IN->ITDESC }, i18n("Descrizione"), 200, } ,;
{ { ||IN->ITMEASURE }, i18n("Misura"), 40, } ,;
{ { ||IN->ITQTY }, i18n("Quantità"), 60,"9999" } ,;
{ { ||IN->ITTAX }, i18n("Iva"), 40,"99%" } ,;
{ { ||IN->ITDESCONT}, i18n("Sconto"), 40, } ,;
{ { ||IN->ITUNIT }, i18n("Unitario"), 80,'@ €99,999.99' } ,;
{ { ||IN->ITTOTAL }, i18n("Totale"), 80,'@ €99,999.99' }}
FOR i := 1 TO Len(aBrowse)
oCol := oBrw:AddCol()
oCol:bEditValue := aBrowse[ i, 1 ]
oCol:cHeader := aBrowse[ i, 2 ]
oCol:nWidth := aBrowse[ i, 3 ]
if !Empty(aBrowse[ i, 4 ])
oCol:cEditPicture:=aBrowse[ i, 4 ]
Endif
NEXT
WITH OBJECT oBrw
WITH OBJECT oBrw:aCols[1]
:nBtnBmp := 1
:nEditType := EDIT_BUTTON
:bEditBlock :={||MsgInfo("selezione articolo")}
END
WITH OBJECT oBrw:aCols[2]
:nEditType := EDIT_GET
:bOnPostEdit := {|o, v, n| iif( n != VK_ESCAPE, ( IN->(DBRLOCK()), IN->ITDESC:=v, IN->(DBUNLOCK(),CALC(IN->ITQTY,IN->ITUNIT,IN->ITTAX,IN->ITDESCONT,OBRW)) ), ) }
END
WITH OBJECT oBrw:aCols[3]
:nEditType := EDIT_LISTBOX
:aEditListTxt:={"pz.","gr","kg","mm" }
:bOnPostEdit := {|o, v, n| iif( n != VK_ESCAPE, ( IN->(DBRLOCK()), IN->ITMEASURE:=v, IN->(DBUNLOCK(),CALC(IN->ITQTY,IN->ITUNIT,IN->ITTAX,IN->ITDESCONT,OBRW)) ), ) }
END
WITH OBJECT oBrw:aCols[4]
:nEditType := EDIT_GET
:bOnPostEdit := {|o, v, n| iif( n != VK_ESCAPE, ( IN->(DBRLOCK()), IN->ITQTY:=v, IN->(DBUNLOCK(),CALC(IN->ITQTY,IN->ITUNIT,IN->ITTAX,IN->ITDESCONT,OBRW)) ), ) }
END
WITH OBJECT oBrw:aCols[5]
:nBtnBmp := 1
:nEditType := EDIT_LISTBOX
:aEditListTxt:={"21","20","12","8","4" }
:bOnPostEdit := {|o, v, n| iif( n != VK_ESCAPE, ( IN->(DBRLOCK()), IN->ITTAX:=v, IN->(DBUNLOCK(),CALC(IN->ITQTY,IN->ITUNIT,IN->ITTAX,IN->ITDESCONT,OBRW)) ), ) }
END
WITH OBJECT oBrw:aCols[6]
:nEditType := EDIT_GET
:bOnPostEdit := {|o, v, n| iif( n != VK_ESCAPE, ( IN->(DBRLOCK()), IN->ITDESCONT:=v, IN->(DBUNLOCK(),CALC(IN->ITQTY,IN->ITUNIT,IN->ITTAX,IN->ITDESCONT,OBRW)) ), ) }
END
WITH OBJECT oBrw:aCols[7]
:nEditType := EDIT_GET
:bOnPostEdit := {|o, v, n| iif( n != VK_ESCAPE, ( IN->(DBRLOCK()), IN->ITUNIT:=v, IN->(DBUNLOCK(),CALC(IN->ITQTY,IN->ITUNIT,IN->ITTAX,IN->ITDESCONT,OBRW)) ), ) }
END
WITH OBJECT oBrw:aCols[8]
:bStrData := { || CALC(IN->ITQTY,IN->ITUNIT,IN->ITTAX,IN->ITDESCONT,OBRW) }
:nTotal := 0
:lTotal := .t.
:nFooterType := AGGR_TOTAL
:nDataStrAlign := AL_RIGHT
:cEditPicture := '@ €99,999.99'
:nFootStrAlign := AL_RIGHT
END
:nStretchCol := STRETCHCOL_WIDEST
:lHscroll:=.f.
:lRecordSelector := .f.
END
oBrw:nMarqueeStyle = MARQSTYLE_HIGHLWIN7
oBrw:CreateFromCode()
// oBrw:MakeTotals() this make error
// oBrw:RefreshFooters()
@ oBrw:nbottom+3, 5 BUTTON oBtn[1] PROMPT "&New Item" ;
SIZE 40,10 PIXEL OF oFrmInvoice ACTION NewItem(oBrw,"IN")
@ oBrw:nbottom+3, 46 BUTTON oBtn[2] PROMPT "&Edit Item" ;
SIZE 40,10 PIXEL OF oFrmInvoice ACTION nil
@ oBrw:nbottom+3, 87 BUTTON oBtn[3] PROMPT "&Del Item" ;
SIZE 40,10 PIXEL OF oFrmInvoice ACTION Del_row(oBrw)
@ 165, 115 SAY "Imponibile" OF oFrmInvoice COLOR 0, 16777215 SIZE 80, 12 PIXEL
@ 192, 115 SAY "Iva " OF oFrmInvoice COLOR 0, 16777215 SIZE 80, 12 PIXEL
@ 211, 115 SAY "Totale Documento " OF oFrmInvoice COLOR 0, 16777215 SIZE 80, 12 PIXEL
@ 165, 260 SAY oSay1 PROMPT nTotaleImponibile OF oFrmInvoice COLOR 0, 16777215 SIZE 80, 12 PIXEL FONT oFontTotal
@ 192, 260 SAY oSay2 PROMPT nTotaleIva OF oFrmInvoice COLOR 0, 16777215 SIZE 80, 12 PIXEL FONT oFontTotal
@ 211, 260 SAY oSay3 PROMPT nTotaleGenerale OF oFrmInvoice COLOR 0, 16777215 SIZE 80, 12 PIXEL FONT oFontTotal
ACTIVATE DIALOG oFrmInvoice CENTER
RETURN NIL
Function Calc( QTY,UNIT,TAX,DESCONT,oBrw)
Local nImporto := 0
Local nImponibile := 0
Local nNetto := 0
Local nNettot := 0
Local nSconto := 0
nOldTotaleImponibile := nTotaleImponibile
nOldTotaleGenerale := nTotaleGenerale
nOldTotaleIva := nTotaleIva
nImporto:=QTY*UNIT
nImponibile:= ((nImporto/100)*VAL(TAX))
nNetto:=nImponibile+nImporto
nSconto:=nNetto*(val(DESCONT)/100)
nNettoT := nNetto-nSconto
oBrw:MakeTotals()
oBrw:RefreshFooters()
* oBrw:Refresh()
nTotaleImponibile := nImponibile + nOldTotaleImponibile
nTotaleGenerale := nNettoT + nOldTotaleGenerale
nTotaleIva := 0 + nOldTotaleIva
oSay1:refresh()
oSay2:refresh()
oSay3:refresh()
Return nNettoT
Function Del_row(oBrw)
local nRecord := IN->(Recno())
local nNext
* oApp():nEdit ++
IF in->(OrdKeyCount()) > 0
if msgYesNo( i18n("¿ E' sicuro di voler cancellare questo record ?") + CRLF + ;
(trim(IN->ITDESC)))
IN->(DbSkip())
nNext := IN->(Recno())
IN->(DbGoto(nRecord))
IN->(DbDelete())
IN->(DbPack())
IN->(DbGoto(nNext))
if IN->(EOF()) .or. nNext == nRecord
IN->(DbGoBottom())
endif
endif
else
MsgInfo("Non c'è nessun record da cancellare")
endif
* if oCont != nil
* RefreshCont(oCont,"RU")
* endif
oBrw:MakeTotals()
oBrw:RefreshFooters()
oBrw:Refresh(.t.)
oBrw:SetFocus(.t.)
*oApp():nEdit --
oSay1:refresh()
oSay2:refresh()
oSay3:refresh()
Return NIL
Function NewItem(oBrw,calias)
IN->(DbAppend())
IN->(DbCommit())
oBrw:refresh()
oBrw:setfocus()
Return NI