Have you tried my function?
I think here is the problem. I have commanded this line too.
//oBrowse:aArraydata:= aItems
Here all is working - btw this is a handy sample.
That easy one could make a ECR.
Best regards,
Otto
- Code: Select all Expand view
#include"fivewin.ch"
Function test()
Local oDlg,oFolder,oFont
Local adata:={}
Local oBrowse
Local oBtnServices[3]
local nInvoice:="1234567890123"
local lSearch:=.t.
local lShowbutton:=.f.
local oSelNumber
// to simulation
adata := addFirstRecord(nInvoice)
DEFINE FONT oFont NAME "TAHOMA" SIZE 0,-14
DEFINE DIALOG oDlg ;
TITLE "test" ;
SIZE 1130,650 PIXEL ;
FONT oFont
@ 1, 0 FOLDEREX oFolder OF oDlg SIZE oDlg:nWidth-585,oDlg:nHeight-390 PIXEL ;
PROMPT "Prenotazioni","Pagamenti","Familiari"
oFolder:aEnable = { .t., .f. ,.t.}
@ 60, 02 XBROWSE oBrowse OF oFolder:aDialogs[1] ;
COLUMNS 1,2,3,4,5,6,7,8,9,10,11;
HEADERS "Ico","Tipo","Servizio","Q.tà","Costo","Tot p q.tà","Dal","al","Giorni","Sconto","Totale" ;
PICTURES nil, nil,"@!","9999","€ 999,999.99","€ 999,999.99", "dd-mmmm-yyyy","dd-mmmm-yyyy","999","€ 999,999.99","€ 999,999.99" ;
COLSIZES 55, 25,130,50,90,90,140,140,50,90,120 ;
ARRAY aData ;
SIZE 100,80 PIXEL NOBORDER
WITH OBJECT oBrowse
:nRowHeight := 30
:MakeTotals()
:lfooter := .T.
:ldrawborder:=.t.
:lHscroll := .F.
:l2007 := .F.
:l2015 := .T.
:nStretchCol := STRETCHCOL_WIDEST
:lAllowRowSizing := .F.
:lAllowColSwapping := .F.
:lAllowColHiding := .F.
:nMarqueeStyle := 4
:CreateFromCode()
END
@ 260,80 BUTTONBMP oSelBtn;
RESOURCE "INVOICE_SELBTN" ;
PROMPT " test new" SIZE 85,15 PIXEL OF oDlg;
TEXTRIGHT ;
ACTION (lSearch:=!lsearch, ;
Search_New( oBrowse,nInvoice,lSearch,@lShowbutton,@oSelNumber, aData),;
oSelNumber:refresh())
@ 260,280 BUTTONBMP oSelNumber;
PROMPT " test new Select number" SIZE 85,15 PIXEL OF oDlg;
TEXTRIGHT UPDATE;
ACTION (Search_New(oBrowse,nInvoice,.f.,@lShowbutton,@oSelNumber)) WHEN lShowbutton
oDlg:bResized := <||
oRect := oDlg:GetCliRect()
oFolder:nWidth := oRect:nRight-2
oFolder:nHeight := oRect:nBottom-160
oBrowse:nTop := oRect:nBottom-350
oBrowse:nWidth := oRect:nWidth - 15
return nil
>
ACTIVATE DIALOG oDlg ;
ON INIT (SerVices(oFolder,adata,nInvoice,obrowse),;
oSelNumber:disable(),;
EVAL( oDlg:bResized) )
RETURN NIL
//-------------------------------------------------------------//
//
Function addFirstRecord(nInvoice)
Local atmp:= {}
local cIcoPro ,;
cTipo ,;
cDescPro ,;
nQta ,;
nPreUni ,;
nPreTot ,;
nTotQta ,;
dDataIni ,;
dDataFin ,;
nGiorni ,;
nSconto ,;
nTotaleRiga ,;
lPrintA4 ,;
lPrintPos,;
cStruttura,;
cDescBreve,;
serial,ntotale
// to make a simulation
cIcoPro := ".\bitmaps\ombrellone.png"
cTipo := "E"
cDescPro := "OMBRELLONE"
nQta := 1
nPreUni := 6
nPreTot := 6
nTotQta := 1
dDataIni := date()
dDataFin := date()
nGiorni := 1
nSconto := 0
nTotaleRiga := 6
lPrintA4 := .f.
lPrintPos:= .f.
cStruttura:=""
cDescBreve:=""
serial :=1
nTotale:= nPreUni* nQta
AaDd(aTmp,{ cIcoPro ,;
cTipo ,;
cDescPro ,;
nQta ,;
nPreUni ,;
nTotQta ,;
dDataIni ,;
dDataFin ,;
nGiorni ,;
nSconto ,;
nTotale ,;
nInvoice ,;
lPrintA4 ,;
lPrintPos,;
cStruttura,;
cDescBreve,;
serial })
return aTmp
//---------------------------------------------------------------//
Function Search_New(oBrowse,nInvoice,lSearch,lShowbutton,oSelNumber, adata)
If lSearch
adata:= {} //empty
oSelNumber:enable()
lShowbutton:=.t.
oSelNumber:Refresh()
ELSE
adata := addNewRecord(nInvoice)
oSelNumber:Disable()
lShowbutton:=.F.
oSelNumber:Refresh()
ENDIf
// oBrowse:aArraydata:= adata
oBrowse:refresh()
return nil
//---------------------------------------------------------------//
Function addNewRecord(nInvoice)
Local atmp:= {}
local cIcoPro ,;
cTipo ,;
cDescPro ,;
nQta ,;
nPreUni ,;
nPreTot ,;
nTotQta ,;
dDataIni ,;
dDataFin ,;
nGiorni ,;
nSconto ,;
nTotaleRiga ,;
lPrintA4 ,;
lPrintPos,;
cStruttura,;
cDescBreve,;
serial,ntotale
// to make a simulation
cIcoPro := ".\bitmaps\ombrellone.png"
cTipo := "E"
cDescPro := "OMBRELLONE"
nQta := 1
nPreUni := 6
nPreTot := 6
nTotQta := 1
dDataIni := date()+2
dDataFin := date()+5
nGiorni := 1
nSconto := 0
nTotaleRiga := 6
lPrintA4 := .f.
lPrintPos:= .f.
cStruttura:=""
cDescBreve:=""
serial :=1
nTotale:= nPreUni* nQta
AaDd(aTmp,{ cIcoPro ,;
cTipo ,;
cDescPro ,;
nQta ,;
nPreUni ,;
nTotQta ,;
dDataIni ,;
dDataFin ,;
nGiorni ,;
nSconto ,;
nTotale ,;
nInvoice ,;
lPrintA4 ,;
lPrintPos,;
cStruttura,;
cDescBreve,;
serial })
return aTmp
//---------------------------------------------------------------//
Function SerVices(oFolder,adata,nInvoice,obrowse)
local aServices:={ {"Bed",8},;
{"Chair",6},;
{"Seat",12}}
Local abtnServices[3]
local nservizio
local cDesc,nPrice
local nRow:= 100
local nCol:= 10
For nServizio =1 to 3
cDesc:= aServices[nServizio][1]
nPrice:= aServices[nServizio][2]
@ nRow, ncol BTNBMP aBtnservices[nServizio] ;
SIZE 192,95 PIXEL FLAT ;
PROMPT cDesc +CRLF+ ltrim(str(nPrice)) ;
OF oFolder:aDialogs[1]
aBtnservices[nServizio]:Cargo := {cDesc,nPrice}
aBtnservices[nServizio]:bAction := { | oBtnpro | InsertServices(oBtnpro,nInvoice,adata,obrowse) ,obrowse:gobottom(),obrowse:setfocus(), obrowse:refresh()}
ncol+=200
Next
return nil
//---------------------------------------------------------------//
Function InsertServices(oBtnpro,nInvoice,adata,obrowse)
// simulation insertion products
Local cProdDesc := oBtnpro:Cargo[1]
Local nProdPrice := oBtnpro:Cargo[2]
local cIcoPro:="" ,;
cTipo :="S" ,;
cDescPro := cProdDesc,;
nQta := 1,;
nPreUni :=nProdPrice,;
nPreTot := nPreUni*nQta,;
nTotQta := nPreTot,;
dDataIni := date(),;
dDataFin := date(),;
nGiorni := 1,;
nSconto := 0,;
nTotaleRiga :=nTotQta *nGiorni ,;
lPrintA4 := .t.,;
lPrintPos:= .t.,;
cStruttura:= "",;
cDescBreve:= "",;
nUni:= 0 ,;
nSerial := 0
AaDd(aData,{ cIcoPro ,;
cTipo ,;
cDescPro ,;
nQta ,;
nPreUni ,;
nTotQta ,;
dDataIni ,;
dDataFin ,;
nGiorni ,;
nSconto ,;
nTotaleRiga ,;
nInvoice ,;
lPrintA4 ,;
lPrintPos,;
cStruttura,;
cDescBreve,;
nSerial,;
nUni })
obrowse:refresh()
return nil