Agregar columna xbrowse

Agregar columna xbrowse

Postby surGom » Sun Jul 14, 2019 1:19 am

Hola buenas noches, quiero hacer un xbrowse de una base de datos , y en el mismo agregar una columna con la suma de dos campos numericos
de la base de datos mas la celda anterior de esta columna. O algún ejemplo para emular.

Gracias
surGom
 
Posts: 640
Joined: Wed Oct 19, 2005 12:03 pm

Re: Agregar columna xbrowse

Postby nageswaragunupudi » Sun Jul 14, 2019 5:28 am

Code: Select all  Expand view
#include "fivewin.ch"

REQUEST DBFCDX

function Main()

   local oDlg, oBrw, oFont, aTotals, d
   local nTotal   := 0

   SetGetColorFocus()
   FWNumFormat( "E", .t. )

   USE CUSTOMER NEW ALIAS CUST SHARED VIA "DBFCDX"
   SET FILTER TO !DELETED()
   GO TOP
   aTotals  := Array( OrdKeyCount() )
   DBEVAL( { || aTotals[ OrdKeyNo() ] := nTotal := FIELD->AGE + FIELD->SALARY + nTotal } )
   GO TOP

   DEFINE FONT oFont NAME "TAHOMA" SIZE 0,-14
   DEFINE DIALOG oDlg SIZE 500,500 PIXEL TRUEPIXEL FONT oFont
   @ 20,20 XBROWSE oBrw SIZE -20,-20 PIXEL OF oDlg ;
      DATASOURCE "CUST" ;
      COLUMNS "FIRST", "AGE", "SALARY", { || aTotals[ OrdKeyNo() ] } ;
      HEADERS nil, nil, nil, "CUMTOTAL" ;
      PICTURES nil, nil, nil, NUMPICT( 11, 2 ) ;
      CELL LINES NOBORDER FASTEDIT

   WITH OBJECT oBrw
      :nEditTypes    := EDIT_GET
      :CumTotal:nEditType := EDIT_NONE
      :Age:bOnChange := ;
      :Salary:bOnChange := { |oCol,uOldVal| d := oCol:Value - uOldVal, ;
                              AEval( aTotals, { |n,i| aTotals[i] := n + d }, CUST->( OrdKeyNo() ), ;
                              oBrw:Refresh() ) }
      :CreateFromCode()
   END

   ACTIVATE DIALOG oDlg CENTERED
   RELEASE FONT oFont

return nil
 


This sample uses customer.dbf in fwh\samples folder.
The last column is the cumulative (running) total of the fields AGE + SALARY.
This browse can be edited. When AGE or SALARY is edited and modified, the last column values are also changed.
Regards

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

Re: Agregar columna xbrowse

Postby surGom » Mon Jul 15, 2019 10:53 pm

Thanks Mrs Rao it worked perfect
surGom
 
Posts: 640
Joined: Wed Oct 19, 2005 12:03 pm


Return to FiveWin para Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 56 guests