FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour Please Mr Nages Problem with xbrowse footer
Posts: 222
Joined: Mon Jun 04, 2012 12:00 PM
Please Mr Nages Problem with xbrowse footer
Posted: Thu Oct 04, 2012 11:38 PM
I have a xbrowse and I wish show the total of 8° column at footer



why I cannot show the totals at oBrw:aCols[8] ?

the code

Code (fw): Select all Collapse
 


@ 1, 1 XBROWSE oBrw  SIZE oFld1:aDialogs[1]:nwidth-5,oFld1:aDialogs[1]:nbottom-35 PIXEL OF oFld1:aDialogs[1] ALIAS "PF";
                                 COLUMNS 'PF->codice','PF->Voce','PF->Quantita',;
                                         ' PF->Unita','PF->Prezzo','PF->Sconti','PF->Iva','pf->importo' ;
                                 COLSIZES 90,140,50,60,40,80,90,90 ;
                                 HEADERS i18n("Codice"),i18n("Descrizione"), i18n("Quantità"),;
                                 i18n("Unità di misura"),i18n("Prezzo"),i18n("Sconti"),i18n("Iva"),i18n("Importo") ;
                                 PICTURES ,,'@ 9999',,'@ €99,999.99',,'99.99 %','@ €99,999.99' ;
                                 CELL LINES FOOTERS NOBORDER FASTEDIT
FOR i := 1 TO LEN( oBrw:aCols)
      oCol := oBrw:aCols[ i ]
     * oCol:bLDClickData  := {||   }
     oCol:oDataFont := oFontGrid
     oCol:bOnPostEdit := {|o, v, n| iif( n != VK_ESCAPE, ( DBRLOCK(), FieldPut( o:nCreationOrder, v ), DBUNLOCK() ), ) }
     oCol:bOnChange := { || oBrw:MakeTotals(), oBrw:RefreshFooters() }
   NEXT



                        WITH OBJECT  oBrw
                             WITH OBJECT  oBrw:aCols[1]
                                      :nBtnBmp := 1
                                      :nEditType := EDIT_BUTTON
                                      :bEditBlock  :={||Selezione_prodotti(oBrw)}
                                   END

                                WITH OBJECT  oBrw:aCols[4]
                                      :nEditType := EDIT_LISTBOX
                                      :aEditListTxt:={"pz.","gr","kg","mm" }
                                END

                                 WITH OBJECT  oBrw:aCols[7]
                                      :nBtnBmp := 1
                                      :nEditType := EDIT_LISTBOX
                                      :aEditListTxt:={"20","12","8","4" }

                                 END


                                 WITH OBJECT oBrw:aCols[8]
                                     :bStrData := { ||  Calcolo_Importo_Riga( PF->QUANTITA,PF->PREZZO,VAL(PF->IVA),PF->SCONTI,oBrw) }
                                     :nTotal := 0
                                     :lTotal := .t.
                                     :nFooterType := AGGR_SUM
                                     :addbmpfile( ".\bitmaps\cassa16.bmp" )
                                     :nDataStrAlign := AL_RIGHT
                                     :cEditPicture := '@ €99,999.99'
                                     :nFootStrAlign := AL_RIGHT
                                     :nFootBmpNo := 1 // Footer BMP
                                  END


                        END






                                  oBrw:lColDividerComplete := .t.
                                  oBrw:lRecordSelector     := .F.
                                  oBrw:lVScroll            := .F.
                                  oBrw:lHScroll            := .F.

                                  oBrw:nHeaderHeight       := 20
                                  oBrw:nRowHeight          := 20
                                  oBrw:nStretchCol  := STRETCHCOL_WIDEST
                                  oBrw:lFooter:=.t.
                                  oBrw:MakeTotals()
                                 * oBrw:RefreshFooters()
                                  oBrw:CreateFromCode()
Posts: 581
Joined: Tue Oct 11, 2005 11:28 AM
Re: Problem with xbrowse footer
Posted: Fri Oct 05, 2012 01:40 AM
Silvio,

Put this before the browse:

Code (fw): Select all Collapse
DbEval( { || nTotal += CHE1->valor } )
DbGoTop()
Kleyber Derick



FWH / xHb / xDevStudio / SQLLIB
Posts: 222
Joined: Mon Jun 04, 2012 12:00 PM
Re: Problem with xbrowse footer
Posted: Fri Oct 05, 2012 07:36 AM

sorry but on another app I use the same code and it run ok

ntotal is a value of XBROWSE

Posts: 85
Joined: Mon Apr 18, 2011 02:32 AM
Re: Problem with xbrowse footer
Posted: Fri Oct 05, 2012 09:00 AM

Hi..
me to have a problem like this.

Mulyadi.

Posts: 222
Joined: Mon Jun 04, 2012 12:00 PM
Please Nages Problem with xbrowse footer
Posted: Fri Oct 05, 2012 11:13 AM
Please Nages try this test sample



it create the dbf

New for insert a record

press Quantity to set the quantity of record

the total of footer not refresh()



Code (fw): Select all Collapse
 
#Include "Fivewin.ch"
#Include "dtpicker.ch"
#include "xbrowse.ch"
#include "constant.ch"
#include "ribbon.ch"
#define MARQSTYLE_HIGHLWIN7  7
#define LIGHTCYAN        nRGB( 203, 225, 252 )


  REQUEST DBFCDX
  REQUEST DBFFPT
  External ordkeyno, ordkeycount,ordcreate,ordkeygoto

 static oBrw

   Function Main()
   Local oFrmFattura
   Local oFld1,oFont
   Local  nBottom   := 42.3
   Local  nRight    := 110
   Local nWidth :=  Max( nRight * DLG_CHARPIX_W, 180 )
   Local nHeight := nBottom * DLG_CHARPIX_H
   local nClrText := CLR_BLACK
   RddSetDefault( "DBFCDX" )

    CREATE_DBF()




  if ! Db_OpenNoIndex("PARFAT","PF")
      return nil
   endif




DEFINE DIALOG oFrmFattura        ;
   TITLE "Fattura "    ;
   SIZE nWidth, nHeight  TRANSPARENT PIXEL               ;
     GRADIENT { { 1,CLR_WHITE, LIGHTCYAN } }    ;
   FONT oFont      STYLE nOr( DS_MODALFRAME, WS_POPUP, WS_CAPTION,  4 )



@  25,   3 FOLDEREX oFld1 Items "&Righe Documento",;
                                 "Pagamento",;
                                 "Note",;
                                 "Indirizzi",;
                                 "Opzioni";
              SIZE oFrmFattura:nwidth-440,230 PIXEL;
              OF oFrmFattura




 IF Iswinxp()
      oFontGrid:= TFont():New( "Lucida Console", 0, 12,, )
  ELSE
     oFontGrid:= TFont():New( "Lucida Console", 0, 12,, )
  ENDIF


 Table_Fattura(oFld1,oFont,nClrText)

 @ 0.5,10 BUTTON oBtn  PROMPT "New record" ACTION Selezione_prodotti(oBrw)  OF  oFrmFattura
 @ 0.5,40 BUTTON oBtn  PROMPT "Insert Quantity" ACTION Manual(oBrw)  OF  oFrmFattura

 ACTIVATE DIALOG oFrmFattura   RESIZE16 CENTERED
                        if oFrmFattura:nresult == IDOK
                             //Salvataggio


                         endif
  Return NIL


Function Manual(oBrw)

  FOR i := 1 TO LEN( oBrw:aCols)
      oCol := oBrw:aCols[ i ]
      oCol:nEditType := 1
     oCol:bOnPostEdit := {|o, v, n| iif( n != VK_ESCAPE, ( DBRLOCK(), FieldPut( o:nCreationOrder, v ), DBUNLOCK() ), ) }
   NEXT

Return NIL









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

Function Table_Fattura(oFld1,oFont,nClrText)
  @ 1, 1 XBROWSE oBrw  SIZE oFld1:aDialogs[1]:nwidth-5,oFld1:aDialogs[1]:nbottom-35 PIXEL OF oFld1:aDialogs[1] ALIAS "PF";
                                 COLUMNS 'PF->codice','PF->Voce','PF->Quantita',;
                                         ' PF->Unita','PF->Prezzo','PF->Sconti','PF->Iva','pf->importo' ;
                                 COLSIZES 90,140,50,60,40,80,90,90 ;
                                 HEADERS i18n("Codice"),i18n("Descrizione"), i18n("Quantità"),;
                                 i18n("Unità di misura"),i18n("Prezzo"),i18n("Sconti"),i18n("Iva"),i18n("Importo") ;
                                 PICTURES ,,'@ 9999',,'@ €99,999.99',,'99.99 %','@ €99,999.99'





   FOR i := 1 TO LEN( oBrw:aCols)
      oCol := oBrw:aCols[ i ]
     * oCol:bLDClickData  := {||   }
     oCol:oDataFont := oFontGrid
     oCol:bOnPostEdit := {|o, v, n| iif( n != VK_ESCAPE, ( DBRLOCK(), FieldPut( o:nCreationOrder, v ), DBUNLOCK() ), ) }
     oCol:bOnChange := { ||Calcolo_Importo_Riga( PF->QUANTITA,PF->PREZZO,VAL(PF->IVA),PF->SCONTI,oBrw),;
                            oBrw:MakeTotals(), ;
                            oBrw:RefreshFooters() }
   NEXT



                       WITH OBJECT  oBrw

                             WITH OBJECT  oBrw:aCols[1]
                                      :nBtnBmp := 1
                                      :nEditType := EDIT_BUTTON
                                      :bEditBlock  :={||Selezione_prodotti(oBrw)}
                                END
                                WITH OBJECT  oBrw:aCols[4]
                                      :nEditType := EDIT_LISTBOX
                                      :aEditListTxt:={"pz.","gr","kg","mm" }
                                END

                                 WITH OBJECT  oBrw:aCols[7]
                                      :nBtnBmp := 1
                                      :nEditType := EDIT_LISTBOX
                                      :aEditListTxt:={"20","12","8","4" }

                                   END


            WITH OBJECT oBrw:aCols[8]
              :bStrData := { ||  Calcolo_Importo_Riga( PF->QUANTITA,PF->PREZZO,VAL(PF->IVA),PF->SCONTI,oBrw) }


                                                  :addbmpfile( ".\bitmaps\cassa16.bmp" )
                                                  :nDataStrAlign := AL_RIGHT
                                                  :cEditPicture := '99,999.99'
                                                  :lTotal := .t.
                                                  :nTotal := 0
                                                  *:nFooterType := AGGR_TOTAL
                                                  :nFootStrAlign := AL_RIGHT
                                                  :nFootBmpNo := 1 // Footer BMP


                                END

                                 :nColDividerStyle := LINESTYLE_LIGHTGRAY
                                 :nMarqueeStyle    := MARQSTYLE_HIGHLWIN7
                                 :lColDividerComplete := .T.
                                 :lRecordSelector     := .F.
                                 :lVScroll            := .F.
                                 :lHScroll            := .F.
                                 :nHeaderHeight       := 20
                                 :nRowHeight          := 20
                                 :nStretchCol  := STRETCHCOL_WIDEST

                               END



                                 oBrw:SetRDD()
                                 oBrw:CreateFromCode()
                                 oBrw:lFooter:=.t.
                                 oBrw:MakeTotals()






RETURN NIL


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

fUNCTION CREATE_DBF()


 DbCreate('PF', {{ "CODICE"    , "C",      10,    0 },;
                 { "VOCE"      , "C",      60,    0 },;
                 { "QUANTITA"  , "N",       6,    0 },;
                 { "UNITA"     , "C",      10,    0 },;
                 { "PREZZO"    , "N",      10,    0 },;
                 { "SCONTI"    , "C",      10,    0 },;
                 { "IVA"       , "C",       2,    0 },;
                 { "IMPORTO"   , "N",      12,    0 } } , 'DBFCDX')


       close all
      use &('PF') new
      select PF
      if FILE('PARFAT.DBF')
         delete file &('PARFAT.cdx')
         append from &('PARFAT')
         dbcommitall()
         close all
         delete file &('PARFAT.dbf')
      endif
      close all
      rename &('PF.dbf') to &('PARFAT.dbf')
     dbcloseall()


RETURN NIL



fUNCTION Selezione_prodotti(oBrw)
SELECT PF
                            PF->(DbAppend())
                            n:=recno()
                            Replace PF->codice   with  "0000"+str(n)
                            Replace PF->Voce     with  "ARTICLE"+str(n)
                            Replace PF->Unita    with  "PZ."
                            Replace PF->Iva      with  "20"
                            Replace PF->Prezzo   with  3.4


                               oBrw:maketotals()
                               oBrw:refresh()

RETURN NIL





Function Calcolo_Importo_Riga( quant,unitario,iva,sconti,oBrw)
  Local  nImporto     := 0
  Local  nImponibile  := 0
  Local  nNetto       := 0
  Local  nNettot      := 0
  Local  nSconto      := 0


   nImporto:=quant*unitario
   nImponibile:= ((nImporto/100)*iva)
   nNetto:=nImponibile+nImporto
   nSconto:=nNetto*(val(sconti)/100)
   nNettoT := nNetto-nSconto
   oBrw:MakeTotals()
   *oBrw:RefreshFooters()
  * oBrw:Refresh()


 Return nNettoT





















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

function Db_OpenNoIndex(cDbf,cAlias)
   if file( cDbf + ".dbf" )
      USE &(cDbf+".dbf")      ;
         ALIAS &(cAlias) NEW
   else
     MsgStop( i18n( "Non si è trovato l'archivio dei dati." ) + CRLF + ;
               i18N( "Per favore  controlla la configurazone") + CRLF + ;
                i18N( "e indicizza gli archivi dell'applicazione." ) )
      return .f.
      return .f.
   END if
   if NetErr()
     msgStop( i18n( "Errore nell'aprire un archivio" ) + CRLF + ;
              i18n( "Per favore caricare di nuovo l'applicazione." ) )
      DbCloseAll()
      return .f.
   endif
return .t
Posts: 6983
Joined: Fri Oct 07, 2005 07:07 PM
Re: Please Mr Nages Problem with xbrowse footer
Posted: Fri Oct 05, 2012 12:07 PM

Silvio,
change quantity does not write in your database.
This is working for me.
Regards,
Otto

Function Calcolo_Importo_Riga( quant,unitario,iva,sconti,oBrw)
Local nImporto := 0
Local nImponibile := 0
Local nNetto := 0
Local nNettot := 0
Local nSconto := 0

nImporto:=quantunitario
nImponibile:= ((nImporto/100)
iva)
nNetto:=nImponibile+nImporto
nSconto:=nNetto*(val(sconti)/100)
nNettoT := nNetto-nSconto

pf->importo := nImporto

oBrw:MakeTotals()

Return nNettoT

Posts: 581
Joined: Tue Oct 11, 2005 11:28 AM
Re: Problem with xbrowse footer
Posted: Fri Oct 05, 2012 10:30 PM
Silvio,
Eoeo wrote:sorry but on another app I use the same code and it run ok
ntotal is a value of XBROWSE


I know ntotal is a value of XBrowse, but I think you misunderstood my answer. Anyway, if you have the same code running ok in other app, maybe you have to see more carefully in what you did.

Good luck.
Kleyber Derick



FWH / xHb / xDevStudio / SQLLIB
Posts: 222
Joined: Mon Jun 04, 2012 12:00 PM
Re: Please Mr Nages Problem with xbrowse footer
Posted: Sat Oct 06, 2012 06:18 PM

Sorry Yu're right
I made a mistake
I'm working from many days to converte Dos application clipper over 5000 lines and Im very tired !!!

thanks Otto!!!

Posts: 222
Joined: Mon Jun 04, 2012 12:00 PM
Re: Please Mr Nages Problem with xbrowse footer
Posted: Sat Oct 06, 2012 06:20 PM

Otto,
is there a method into xbrowse to insert a spinner on field quantity to add or del numeric field ?

Continue the discussion