Page 1 of 1

Problem on xbrowse :bOnChange //RESOLVED

PostPosted: Wed Nov 13, 2019 9:18 am
by Silvio.Falconi
Image


if I go to change the penultimate line, then the last row is also changed why ?

on my xbrowse at init I made

I use array on Xbrowse

bCalcRow := { || (MyCalcFun(oBrowse,.t.), CalcoloTotali(oBrowse,aGet) )}



MyCalcFun function
Code: Select all  Expand view


Function MyCalcFun(oBrowse,lModifica)
   Local  dData_in        := oBrowse:aCols[ 7 ]:Value
   Local  dData_out       := oBrowse:aCols[ 8 ]:Value
   Local  lStagioneIntera
   Local  nTipoServizio   := oBrowse:aCols[ 2]:Value
   Local  nCosto          := 0
   Local  nTotalexQuantita:= 0
   Local  cProdotto       := oBrowse:aCols[ 3 ]:Value
   Local  nQuantita       := oBrowse:aCols[ 4 ]:Value
   Local  nGiorni         := (dData_out  -   dData_in )+1
   Local  nSconto         := oBrowse:aCols[ 10 ]:Value
   local  nTotale         := oBrowse:aCols[ 11 ]:Value

   // controllo stagione Intera
       IF nGiorni > 90  //mettere in configurazione Max_giorni_intera
          lStagioneIntera := .t.
       else
           lStagioneIntera := Is_Stagionale(dData_in,dData_out)
        Endif


  IF lModifica
        // modifica riga
       If  nTipoServizio<>"E"  // se è diverso da elemento

           If  lStagioneIntera
                nCosto          := Prezzo_Servizi(dData_in,dData_out,lStagioneIntera,cProdotto)
                nTotalexQuantita:= nQuantita * nCosto
                nTotale         := nTotalexQuantita  -  nSconto
             else
                nCosto           :=  Prezzo_Servizi(dData_in,dData_out,lStagioneIntera,cProdotto)// oBrowse:aCols[ 5 ]:Value
                nTotalexQuantita:= nQuantita * nCosto
                nTotale          := (nTotalexQuantita -  nSconto)  * nGiorni
             Endif

          else

             Msginfo("Non puoi modificare i prezzi e il totale su questa riga")
          Endif

       ELSE

     // inserimento riga
           If  lStagioneIntera
                nCosto          := Prezzo_Servizi(dData_in,dData_out,lStagioneIntera,cProdotto)
                nTotalexQuantita:= nQuantita * nCosto
                nTotale         := nTotalexQuantita  -  nSconto
             else
                nCosto           := oBrowse:aCols[ 5 ]:Value
                nTotalexQuantita:= nQuantita * nCosto
                nTotale          := (nTotalexQuantita -  nSconto)  * nGiorni
             Endif

         ENDIF


// save on xbrowse

             oBrowse:aCols[5]:VarPut( nCosto)
             oBrowse:aCols[6]:VarPut(nTotalexQuantita)
             oBrowse:aCols[9]:VarPut (nGiorni)
             oBrowse:aCols[11]:VarPut( nTotale )


  return nil


where i the problem ?

Re: Problem on xbrowse :bOnChange

PostPosted: Thu Nov 14, 2019 10:24 am
by Silvio.Falconi
Nages please see the video https://recordit.co/saKLrKT7T1

If I change a row then it change also some columns of the last row

Re: Problem on xbrowse :bOnChange

PostPosted: Fri Nov 15, 2019 5:27 am
by shri_fwh
Hi Silvio ,

May I request to post this Sample Code ? Thanks in advance...!

Thanks
Shridhar

Re: Problem on xbrowse :bOnChange

PostPosted: Fri Nov 15, 2019 9:35 am
by nageswaragunupudi
Please post a self-contained sample that we can build at our end.

Re: Problem on xbrowse :bOnChange

PostPosted: Fri Nov 15, 2019 10:53 am
by Silvio.Falconi
nageswaragunupudi wrote:Please post a self-contained sample that we can build at our end.

see at your e-mail

Re: Problem on xbrowse :bOnChange

PostPosted: Fri Nov 15, 2019 11:01 am
by Silvio.Falconi
shri_fwh wrote:Hi Silvio ,

May I request to post this Sample Code ? Thanks in advance...!

Thanks
Shridhar


I don't think it can create a small example because many archives are connected around 10,
for example in the creation of the articles are connected the articles and the prices of the articles.

When I go to modify a line the procedure goes to check the period (periods.dbf, listini.dbf) and if it is an entire season it goes to look for the right price in the item price archive or if the customer is known every customer has a particular price list

my problem is that when I go to edit a line I have to change the price of the product by calculating the total of days.

The procedure recognizes that the interval is not an entire season and therefore must calculate the period and days, so it must enter the unit price, the total price by quantity, the number of days, the total which is the multiplication between the price and the days .

The procedure changes the selected line but the line below also changes to me

this is the xbrowse

Code: Select all  Expand view
@ 120, 02 XBROWSE  oBrowse OF oFolder:aDialogs[1] ;
        COLUMNS 3,4,5,6,7,8,9,10,11,12,13;
        HEADERS "Ico","Tipo","Servizio","Q.tà","Costo","Tot p q.tà","Dal","al","Giorni","Sconto","Totale"   ;
        COLSIZES 55, 25,190,50,90,90,140,140,50,60,90 ;
        PICTURES nil, nil,"@!","9999","€ 999,999.99","€ 999,999.99", "dd-mmmm-yyyy","dd-mmmm-yyyy","999","€ 999,999.99","€ 999,999.99";
        ARRAY aItems       ;
        SIZE 100,62 PIXEL STYLE FLAT NOBORDER

       ADD COLUMN TO XBROWSE oBrowse


   bCalcRow := { || (MyCalcFun(oBrowse,.t.), CalcoloTotali(oBrowse,aGet)     )}

Re: Problem on xbrowse :bOnChange

PostPosted: Fri Nov 15, 2019 12:19 pm
by Silvio.Falconi
perhaps I found the error

on Function CalcoloTotali(oBrowse,aGet)

I insert this command

oBrowse:GoBottom()

this go to the last record and it is modified