ERROR XBROWSE MAKETOTALS

ERROR XBROWSE MAKETOTALS

Postby Silvio.Falconi » Fri Feb 08, 2013 12:31 pm

Image


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

#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
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour November 2023 - January 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
User avatar
Silvio.Falconi
 
Posts: 7056
Joined: Thu Oct 18, 2012 7:17 pm

Re: ERROR XBROWSE MAKETOTALS

Postby lucasdebeltran » Fri Feb 08, 2013 12:50 pm

Silvio,

Application
===========
Path and name: C:\test\sylvio.exe (32 bits)
Size: 2,349,056 bytes
Compiler version: Harbour 3.2.0dev (Rev. 17516)
FiveWin Version: FWH 12.12
Windows version: 6.1, Build 7601 Service Pack 1

Time from start: 0 hours 0 mins 0 secs
Error occurred at: 02/08/13, 13:47:21
Error description: (DOS Error 2) DBFCDX/1001 Open error: INVOICE.dbf

Stack Calls
===========
Called from: => DBUSEAREA( 0 )
Called from: sylvio.prg => INVOICE( 32 )
Muchas gracias. Many thanks.

Un saludo, Best regards,

Harbour 3.2.0dev, Borland C++ 5.82 y FWH 13.06 [producción]

Implementando MSVC 2010, FWH64 y ADO.

Abandonando uso xHarbour y SQLRDD.
User avatar
lucasdebeltran
 
Posts: 1303
Joined: Tue Jul 21, 2009 8:12 am

Re: ERROR XBROWSE MAKETOTALS

Postby joseluisysturiz » Fri Feb 08, 2013 2:12 pm

Sylvio, prueba asi, me funciona sin problema, saludos... :shock: :

// CONFIGURACION DEL xBROWSE
WITH OBJECT oBrw
:nMarqueeStyle := MARQSTYLE_HIGHLCELL
:nColDividerStyle := LINESTYLE_BLACK
:nStretchCol := STRETCHCOL_LAST
:bRClicked := { || msginfo( "pulsastes boton derecho..." ) } // LLAMA MENU-POPUP CON BOTON DERECHO
:lColDividerComplete := .t.
:nHeaderHeight := 30 // ANCHO CABEZERA
:l2007 := .t.
:lFooter := .t.
:lRecordSelector := .t. // SI/NO 1RA.COL.IZQ.QUE TIENE LA FLECHITA NEGRA
:lAllowColHiding := .f. // SI/NO BOTON DERECHO SOBRE CABEZERA, MUESTRE ARRAY COL.
:lAllowColSwapping := .f. // SI/NO INTERCAMBIAR COL.
:bClrStd := {|| IF( oBrw:nArrayAt % 2 == 0, {CLR_BLACK, CLR_WHITE}, {0, RGB(203, 226, 254)} ) }
:bKeyDown := {| nKey | teclado( nKey, oBrw, aVar, aGet, oQryCJ ) } // CONTROLA VIRTUAL KEY
***:bPastEof := { || addrow( oBrw ) } // HACE EDICION DE CELDA AUTOMATICAMENTE CON FLECHA ABAJO...

:bChange := { || oBrw:MakeTotals(), oBrw:RefreshFooters() } // ACT.TOT.EN LOS FOOTERS
:MakeTotals()

END WITH

WITH OBJECT oBrw:aCols[7] // MONTO
:cHeader := "MONTO"
:bStrData := {|| IIF( LEN( aItems ) = 0, SPACE(10) ,; // bEditValue
TRANSFORM( aItems[oBrw:nArrayAt, 7], "@E 9,999,999.99" ) ) }
:nWidth := 100
:lTotal := .t. // PARA TOTALIZAR COL.
:nTotal := sumador(oBrw) // PARA TOTALIZAR COL.
:nFooterType := AGGR_SUM // PARA TOTALIZAR COL.
:cEditPicture := "@E 9,999,999.99" // MASCARA PARA FOOTER
:nEditType := EDIT_GET
:bEditValid := { | oGet, oCol | mayorqcero( oGet:value() ) }
:bOnPostEdit := { | oCol, xVal, nKey | If( nKey <> VK_ESCAPE ,;
( oCol:value := xVal ,;
oBrw:aArrayData[oBrw:nArrayAt, 8] := "CAJ" ,; // DESTINO
totalinea( oBrw, aVar, aGet ) ,;
graba_caja( oQryCJ, oBrw, lNew, aVar, aGet ) ,;
disponcaja( oQryCJ, aVar, aGet ) ,;
addrow( oBrw, oQryCJ, lNew ) ), ) }
END WITH
Dios no está muerto...

Gracias a mi Dios ante todo!
User avatar
joseluisysturiz
 
Posts: 2064
Joined: Fri Jan 06, 2006 9:28 pm
Location: Guatire - Caracas - Venezuela

Re: ERROR XBROWSE MAKETOTALS

Postby nageswaragunupudi » Fri Feb 08, 2013 2:28 pm

WITH OBJECT oBrw:aCols[8]
:bStrData := { || CALC(IN->ITQTY,IN->ITUNIT,IN->ITTAX,IN->ITDESCONT,OBRW) }
:nTotal := 0
:lTotal := .t.
:nFooterType := AGGR_TOTAL

MakeTotals() method totals numeric result of bEditValue codeblock.
Please provide bEditValue codeblock returning a numeric value instead of bStrData.

Note: When :nFooterType is specified it is not necessary to assign ( nTotal and lTotal )
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10632
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: ERROR XBROWSE MAKETOTALS

Postby Silvio.Falconi » Fri Feb 08, 2013 5:44 pm

Dear Nages
Now I correct and I see now the footer but only whe I change a field
if I open the procedure and there is one record the footer is zero (0.00)


At INIT

Image

when I change a field

Image


Then the big problem is when I move the mouse over the xbrowse the procedure refresh the says ( are at the bottom of the dialog)
adding with new values and refreshed I not Understtod why but I think there is an error on calc function I must revised it
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour November 2023 - January 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
User avatar
Silvio.Falconi
 
Posts: 7056
Joined: Thu Oct 18, 2012 7:17 pm

Re: ERROR XBROWSE MAKETOTALS

Postby nageswaragunupudi » Sat Feb 09, 2013 12:06 am

First time and any time you re-read data from the source or if you change the data on your own, you need to call the method oBrw:MakeTotals().
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10632
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: ERROR XBROWSE MAKETOTALS

Postby Silvio.Falconi » Sat Feb 09, 2013 9:34 am

Dear Nages,
at init i inser maketotals

aBrowse := { { { ||IN->ITCODE}, i18n("Codice"), 50, },;
{ { ||IN->ITDESC }, i18n("Descrizione"), 180, } ,;
{ { ||IN->ITMEASURE }, i18n("Misura"), 40, } ,;
{ { ||IN->ITQTY }, i18n("Quantità"), 60,"9999" } ,;
{ { ||IN->ITTAX }, i18n("Iva"), 40,"99%" } ,;
{ { ||IN->ITDESCONT}, i18n("Sconto"), 80, } ,;
{ { ||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

oCol:oDataFont := oFontGrid

oCol:bOnChange := { ||CALC(IN->ITQTY,IN->ITUNIT,IN->ITTAX,IN->ITDESCONT,OBRW),;
oBrw:MakeTotals(), ; oBrw:RefreshFooters() }


NEXT


but it not run ok
only when I move the mouse intoone row it show the footer right


If i insert maketotals the the oBrw:CreateFromCode()
make error !!!!

WITH OBJECT oBrw
...
END

oBrw:CreateFromCode()
oBrw:MakeTotals()


If i insert maketotals into WITH OBJECT oBrw..end make error !!!!
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour November 2023 - January 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
User avatar
Silvio.Falconi
 
Posts: 7056
Joined: Thu Oct 18, 2012 7:17 pm


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 112 guests