FOR NAGES- RESOLVED

FOR NAGES- RESOLVED

Postby Silvio.Falconi » Wed Jun 24, 2020 6:10 pm

I came back from a situation that temporarily took me away from the computer, I am sitting but with one leg stretched out on a chair, I hope to return to normal soon

a little question

on a dialog at init I insert an aData array into an XBROWSE

Code: Select all  Expand view  RUN

@ 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
 

the user can change something (date range, number, type of object) while entering the data in the dialog, so if there is a change I have to delete everything in oBrowse: aArrayData [/ b]

first, however, I'm going to search the archive to see if the article is free or not

if it is free I can add a new record, taking the new data entered by the user, I have to create a new record.
When I create this record I put it in an array [b] aItems [/ b] and then I have to save it in the xbrowse

Code: Select all  Expand view  RUN
aItems:=AddFirstRecord(1,cDescElemento,ncella,;
                        dFirst,dLast,cSettore,nImage, ;
                        lStagioneIntera,nInvoice)

 for n := 1 to len( aItems ) // is allways 1
          aadd( oBrowse:aArrayData,aItems[n])
   next
 


the problem is that initially before inserting the new record [b]I have to delete the contents of oBrowse:aArrayData


whether the search is successful and whether it is negative

I tried with
aSize( oBrowse:aArrayData, 1 ) or aSize( oBrowse:aArrayData, 0 ) but not run

I tried with

aData:={}
for n := 1 to len( aData )
aadd( oBrowse:aArrayData,aData[n])
next

but not run

How I can resolve ?
please a solution
Last edited by Silvio.Falconi on Fri Jul 03, 2020 11:26 am, edited 1 time in total.
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: 7067
Joined: Thu Oct 18, 2012 7:17 pm

Re: FOR NAGES

Postby nageswaragunupudi » Thu Jun 25, 2020 1:31 pm

I came back from a situation that temporarily took me away from the computer, I am sitting but with one leg stretched out on a chair, I hope to return to normal soon

Very sorry to know. Wish you get well soon.
Regards

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

Re: FOR NAGES

Postby nageswaragunupudi » Thu Jun 25, 2020 1:42 pm

Assuming the new single row is
aNewRow := { 1, 2, 3, ..... }

you do
oBrw:aArrayData := { aNewRow }
oBrw:Refresh()
Regards

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

Re: FOR NAGES

Postby Silvio.Falconi » Thu Jun 25, 2020 4:12 pm

Sorry Nages,

When I create the new record I made :

aItems:=AddFirstRecord(1,cDescElemento,ncella,;
dFirst,dLast,cSettore,nImage, ;
lStagioneIntera,nInvoice)

this function return me an array empty aTmp:={} if the search is positive ( found the record)
this function returns an empty array to me if the search performed successfully, ie found a matching record
If instead the search did not find any record it returns me an array full of only one record


Code: Select all  Expand view  RUN

Function AddFirstRecord(nMode,cDescElemento,nElemento,;
                        ddcheckin,ddcheckout,cSettore,nImage,;
                        lStagioneIntera,nInvoice)

       local aTmp:={}

....

AaDd(aTmp,{  cIcoPro  ,;
                          cTipo    ,;
                          cDescPro ,;
                          nQta     ,;
                          nPreUni  ,;
                          nTotQta  ,;
                          dDataIni ,;
                          dDataFin ,;
                          nGiorni  ,;
                          nSconto  ,;
                          nTotale  ,;
                          nInvoice ,;
                          lPrintA4 ,;
                          lPrintPos,;
                          cStruttura,;
                          cDescBreve,;
                          serial    ,;
                          nPrezzoBase})
return atmp
 




then I made

Local aItems:={}
aItems:=AddFirstRecord(1,cDescElemento,ncella,;
dFirst,dLast,cSettore,nImage, ;
lStagioneIntera,nInvoice)

IF LEN(aItems)>0


oBrowse:aArrayData:=aItems
oBrowse:Refresh()
oBrowse:MakeTotals()

CalcoloTotali(oBrowse,aGetTotali) // func to calc the totals

ELSE

oBrowse:aArrayData:=aItems
oBrowse:Refresh()
oBrowse:MakeTotals()
CalcoloTotali(oBrowse,aGetTotali) // func to calc the totals

Endif

this could work but after when I insert the services I don't see them in the xbrowse because the services are added to the initial array called aData

then I tried to call "aItems" with "aData"
but I have the same problem

is very hard to create a demo sample
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: 7067
Joined: Thu Oct 18, 2012 7:17 pm

Re: FOR NAGES

Postby nageswaragunupudi » Thu Jun 25, 2020 4:18 pm

is very hard to create a demo sample


I suggest you relax now and take care of your health. Once you are ok, you will fix your code by yourself as you always do.
Regards

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

Re: FOR NAGES

Postby Silvio.Falconi » Fri Jun 26, 2020 8:55 am

nageswaragunupudi wrote:
is very hard to create a demo sample


I suggest you relax now and take care of your health. Once you are ok, you will fix your code by yourself as you always do.


you're right but I have to solve, I have friends who beat me

I made a little test to show you How it ( not ) run ..

Image

this is the dialog, a xbrowse and buttons of services

at the beginning I insert a record and you can press the buttons that are in the folder (bed, chair, seat) all the services are inserted in the xbrowse.

test one
press the "test new" button, the function inserts a new record, now you can insert the services (bed, chair, seat) but they are not inserted in the xbrowse why?

test two
press the "test new" button again to activate the "test select number" button the function inserts a new record,
in the same way you can enter the services but they are not shown in the xbrowse why?


the small test

Code: Select all  Expand view  RUN

#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       := MARQSTYLE_HIGHLROWMS
                      :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),;
     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)
   Local aItems:= {}

   If lSearch
      aItems:= {}    //empty

      oSelNumber:enable()
      lShowbutton:=.t.
      oSelNumber:Refresh()

   ELSE
      aItems:=  addNewRecord(nInvoice)

      oSelNumber:Disable()
      lShowbutton:=.F.
      oSelNumber:Refresh()


   ENDIf

   oBrowse:aArraydata:= aItems
   oBrowse:refresh()
 *  xbrowser  oBrowse:aArraydata

   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) }



           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
 


thanks
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: 7067
Joined: Thu Oct 18, 2012 7:17 pm

Re: FOR NAGES

Postby Otto » Fri Jun 26, 2020 1:16 pm

Silvio,
I changed
:nMarqueeStyle := 4
and
aBtnservices[nServizio]:bAction := { | oBtnpro | InsertServices(oBtnpro,nInvoice,adata,obrowse) ,obrowse:gobottom(),obrowse:setfocus(), obrowse:refresh()}

It seems to work.
Best regards,
Otto
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
https://www.facebook.com/groups/modharbour.club
********************************************************************
User avatar
Otto
 
Posts: 6335
Joined: Fri Oct 07, 2005 7:07 pm

Re: FOR NAGES

Postby Silvio.Falconi » Fri Jun 26, 2020 5:05 pm

???
Perhaps you not understood
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: 7067
Joined: Thu Oct 18, 2012 7:17 pm

Re: FOR NAGES

Postby Otto » Fri Jun 26, 2020 6:17 pm

Silvio, I see. I think you mix up aItems(local) and aData.
Best regards,
Otto
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
https://www.facebook.com/groups/modharbour.club
********************************************************************
User avatar
Otto
 
Posts: 6335
Joined: Fri Oct 07, 2005 7:07 pm

Re: FOR NAGES

Postby Otto » Fri Jun 26, 2020 6:22 pm

Silvio,
this seems to work:
Code: Select all  Expand view  RUN
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

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

 
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
https://www.facebook.com/groups/modharbour.club
********************************************************************
User avatar
Otto
 
Posts: 6335
Joined: Fri Oct 07, 2005 7:07 pm

Re: FOR NAGES

Postby Silvio.Falconi » Sat Jun 27, 2020 8:27 am

unfortunately when you go to create an example to make it clear on the forum what your problem is there is a danger that you insert errors.
the example that I actually made is of a much more complex dialog:

Image

I have:
a) a combobox where I go to select the type of the umbrella
b) a combobox where I go to select the number of the umbrella
c) then I have two datepick controls dfirst and dlast which have a bchange but this bchange performs the function first of all
when it inserts a rental, the dialog opens with the parameters already created, that is

a) type umbrella
b) umbrella number
c) date dFirst
d) dates dlast
and automatically creates a first record in the xbrowse with the total of the umbrella
Now the user can enter the services or he could change the type, number and date range. If the period and the type and number of the umbrella are changed, the procedure goes to search (1) on the archive if this umbrella is free or not.
a) if it is free, enter the first record with the new price in xbrowse
b) if it is not free, delete everything in xbrowse and activate a button where it shows a small section of the beach to select a new number of umbrellas. if the user selects the new number, the procedure must redo the search described in point (1)
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: 7067
Joined: Thu Oct 18, 2012 7:17 pm

Re: FOR NAGES

Postby Silvio.Falconi » Sat Jun 27, 2020 8:38 am

Otto wrote:Silvio,
this seems to work:
Code: Select all  Expand view  RUN
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

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

 



this not run because

when you press "test new" button the xbrowse must be clear and reinsert a new record if lsearch is false and it is ok
press one services and it not show them on xbrowse
then press "test new" the button "test number selection is activated now press the services but the procedure not insert the services

Code: Select all  Expand view  RUN

#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       := MARQSTYLE_HIGHLROWMS
                      :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),;
     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)
   Local aItems:= {}

   If lSearch
      aItems:= {}    //empty

      oSelNumber:enable()
      lShowbutton:=.t.
      oSelNumber:Refresh()

   ELSE

      aItems:=  addNewRecord(nInvoice)

      oSelNumber:Disable()
      lShowbutton:=.F.
      oSelNumber:Refresh()


   ENDIf

   oBrowse:aArraydata:= aItems
   oBrowse:refresh()
   oBrowse:goBottom()
   oBrowse:setfocus()

 *  xbrowser  oBrowse:aArraydata

 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) }



           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()
   oBrowse:goBottom()
   oBrowse:setfocus()

 return nil
 
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: 7067
Joined: Thu Oct 18, 2012 7:17 pm

Re: FOR NAGES

Postby Silvio.Falconi » Sat Jun 27, 2020 8:47 am

Otto wrote:Silvio,
this seems to work:
Code: Select all  Expand view  RUN
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

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

 




Otto you add this
Function Search_New(oBrowse,nInvoice,lSearch,lShowbutton,oSelNumber, adata)

on my source not insert adata
adata is the array of xbrowse and the services are inserted in adata that has become oBrowse:aArraydata

I use another aItems array which becomes empty if the search is true, it becomes full if the search is false
then save aItems to arraydata
and it run ok
but then I cannot insert services into xbrowse because the services are placed on adata which in the meantime has become aItems
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: 7067
Joined: Thu Oct 18, 2012 7:17 pm

Re: FOR NAGES

Postby Silvio.Falconi » Sat Jun 27, 2020 8:52 am

if you try to insert at bottom of the InsertServices() function

xbrowser oBrowse:aArraydata

you'll see it not put services on this oBrowse:aArraydata ( after when you press the button "test new" )

this is the problem
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: 7067
Joined: Thu Oct 18, 2012 7:17 pm

Re: FOR NAGES

Postby Silvio.Falconi » Sat Jun 27, 2020 8:59 am

perhaps I found a solution


when i insert a services i must insert it on AaDd(oBrowse:aArraydata,{ ....

and not on adata array

I want to know the opinion of Nages, and ask if I should do this or it is wrong

Code: Select all  Expand view  RUN
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(oBrowse:aArraydata,{  cIcoPro  ,;
                          cTipo    ,;
                          cDescPro ,;
                          nQta     ,;
                          nPreUni  ,;
                          nTotQta  ,;
                          dDataIni   ,;
                          dDataFin    ,;
                          nGiorni  ,;
                          nSconto  ,;
                          nTotaleRiga ,;
                          nInvoice ,;
                          lPrintA4 ,;
                          lPrintPos,;
                          cStruttura,;
                          cDescBreve,;
                          nSerial,;
                          nUni  })


   oBrowse:refresh()
   oBrowse:goBottom()
   oBrowse:setfocus()
       
 return nil
 



the problem is that in the program I am going to load the services in ON INIT first and then the dialog creates the xbrowse so I think it is not good
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: 7067
Joined: Thu Oct 18, 2012 7:17 pm

Next

Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Silvio.Falconi and 36 guests