To Nages : Problem With Dragand Drop

To Nages : Problem With Dragand Drop

Postby Silvio.Falconi » Tue Jun 13, 2017 7:15 pm

In a pizzeria, customers may pay a table with a separate account


Image


I created a table inserting all the commodity products in that table
And I wanted to transfer with the mouse or by pressing the button the products from the first table to the second table

Everything works well, but a product may have variants attached ( see the V last column)

And when I pass a product that has the variants I also wanted to automatically transfer the product variants

How I can make it ?

this the source



Code: Select all  Expand view
#include "FiveWin.ch"
#include "xbrowse.ch"
#include "Constant.ch"

REQUEST HB_LANG_IT
REQUEST DBFCDX
REQUEST DBFFPT
EXTERNAL ORDKEYNO,ORDKEYCOUNT,ORDCREATE,ORDKEYGOTO



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

function Contoseparato()
   // Numero dello scontrino o numero del tavolo
  // quanti coperti cioè quante persone
  // cameriere


   local oDlgDivide, oCursor, oLbx, oLbx2
   local cItem:=""
   Local nScontrino:="0006"
   Local cTitle :=".:: Conto separato ::.   "+"|"+nScontrino
   Local nCoperti:= 2

   Local aBtnScrollBrw:=array(4)    //Touch btns for scrolling
   Local aBtnDropBrw:=array(2)      //Touch btns for drag and drop


   Local aVars     := { 0, 0, 0, 0, 0}  //totali browse 1
   Local aVars2    := { 0, 0, 0, 0, 0}  //totali browse 2
   Local oSaysTxt:=array(5)     //totali browse 1
   Local oSaysGet:=array(5)     //totali browse 1
   Local oSaysTxt1:=array(5)   //totali browse 2
   Local oSaysGet1:=array(5)    //totali browse 2
   Local oGr1,oGr2


   // MISURE INIZIALI della dialog
      Local nBottom   := 49
      Local nRight    := 132
      Local nWidth :=  Max( nRight * DLG_CHARPIX_W, 180 )
      Local nHeight := nBottom * DLG_CHARPIX_H

      Local arrayTicket:= {}
      Local arrayTicketNew:= {}


      Local nProdotti:= 0
      Local nPrezzo:=0
      Local nImporto:=0
      Local nQuantita := 0
      Local nTotaleRiga:= 0
      Local nImponibile:= 0




      Local oFntGets                 := TFont():New( "Segoe UI",  0, ( 40 ), .f., .f. )
      Local oFntSaysTxt              := TFont():New( "Segoe UI",  0, ( 22 ), .f., .t. )
      RddSetDefault( "DBFCDX" )
      SetHandleCount( 100 )



      USE CONSUM ALIAS CO
      INDEX ON upper(NUMDOC)+Upper(numriga) TAG MESACON  TO CONSUM  for !deleted()
      xbrowse()

      SELECT CO
           CO->(DbSetOrder(1))
           CO->(DbGoTop())
           DO WHILE ! CO->(EoF())
              IF CO->NUMDOC==nScontrino
                 nProdotti++
                 AAdd( arrayTicket, {CO->Cantidad,;
                                     CO->Desc,;
                                     CO->Precio,;
                                     CO->Importe,;
                                     CO->Iva,;
                                     CO->Imponibile,;
                                     CO->Tipo,;
                                     CO->Numriga  } )

             ENDIF
            CO->(DBSkip())
            ENDDO


       aVars[1] := nProdotti
       aVars2[1] := nProdotti

       aVars[2] := nCoperti
       aVars2[2] := nCoperti

   DEFINE CURSOR oCursor hand

   DEFINE DIALOG oDlgDivide      ;
TITLE cTitle     ;
   SIZE nWidth, nHeight  TRANSPARENT PIXEL


   @ 2,5 XBROWSE oLbx OF oDlgDivide ;
      SIZE 200, 200  NOBORDER  STYLE  2015
      oLbx:SetArray(arrayTicket)

   oLbx:aCols[1]:cHeader  := i18n("Qta")
   oLbx:aCols[1]:nWidth   := 30
   oLbx:aCols[2]:cHeader  := i18n("Descrizione")
   oLbx:aCols[2]:nWidth   := 80
   oLbx:aCols[3]:cHeader  := i18n("Prezzo")
   oLbx:aCols[3]:nWidth   := 60
   oLbx:aCols[4]:cHeader  := i18n("Importo")
   oLbx:aCols[4]:nWidth   := 60
   oLbx:aCols[5]:cHeader  := i18n("Iva")
   oLbx:aCols[5]:nWidth   := 40
   oLbx:aCols[6]:cHeader  := i18n("Imponibile")
   oLbx:aCols[6]:nWidth   := 80


    oLbx:nHeaderHeight:= 30
    oLbx:nRowHeight  := 40
    oLbx:nColDividerStyle    := LINESTYLE_LIGHTGRAY
    oLbx:nRowDividerStyle    := LINESTYLE_LIGHTGRAY
    oLbx:nMarqueeStyle := MARQSTYLE_HIGHLROW
    oLbx:lHScroll      := .f.
    oLbx:lVScroll      := .f.

    oLbx:bClrStd := {|| { IIF(oLbx:aArrayData[1][7]="V", CLR_GRAY,CLR_BLUE),CLR_WHITE } }

   // Set a DropOver action for the ListBox
   oLbx:bDropOver = { | uDropInfo, nRow, nCol, nKeyFlags | ;
                        AAdd( oLbx:aArrayData,  oLbx2:aArrayData[ uDropInfo ] ), ;
                        ADel( oLbx2:aArrayData, uDropInfo, .t. ), ;
                        oLbx:Refresh(.t.), oLbx2:Refresh(.t.),;
                        SetTotals(oLbx,oLbx2,oDlgDivide,aVars,aVars2) }

   oLbx:oDragCursor = oCursor         // Select a Drag cursor

   oLbx:bDragBegin  = { | nRow, nCol, nKeyFlags | ;
                        SetDropInfo( oLbx:nArrayAt )   }

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

   @ 2, 35 XBROWSE oLbx2 OF oDlgDivide;
   COLUMNS 1, 2, 3, 4 , 5, 6 ;
   HEADERS "Qta","Descrizione","Prezzo","Importo","Iva","Imponibile"   ;
   COLSIZES 30,80,60,60,40,80          ;
   ARRAY arrayTicketNew  SIZE 200, 200  NOBORDER  STYLE  2015


   oLbx2:nHeaderHeight:= 30
   oLbx2:nRowHeight  := 40
   oLbx2:nColDividerStyle    := LINESTYLE_LIGHTGRAY
   oLbx2:nRowDividerStyle    := LINESTYLE_LIGHTGRAY
   oLbx2:nMarqueeStyle       := MARQSTYLE_HIGHLROW

   oLbx2:lHScroll      := .f.
   oLbx2:lVScroll      := .f.

   oLbx2:bDropOver = { | uDropInfo, nRow, nCol, nKeyFlags | ;
                        AAdd( oLbx2:aArrayData,  oLbx:aArrayData[ uDropInfo ] ), ;
                        ADel( oLbx:aArrayData, uDropInfo, .t. ), ;
                        oLbx:Refresh(.t.), oLbx2:Refresh(.t.),;
                        SetTotals(oLbx,oLbx2,oDlgDivide,aVars,aVars2) }

   oLbx2:oDragCursor = oCursor         // Select a Drag cursor
   oLbx2:bDragBegin  = { | nRow, nCol, nKeyFlags | ;
                        SetDropInfo( oLbx2:nArrayAt ) }



   oLbx:CreateFromCode()
   oLbx2:CreateFromCode()















 //-------------------------------------------------------------------------------------------------------------------------//
 // For scroll the xbrowses
 //-------------------------------------------------------------------------------------------------------------------------//

 @  50,6  BTNBMP  aBtnScrollBrw[1] OF  oDlgDivide SIZE 30, 30 PIXEL     Filename ".\bitmaps\BMP_UP_BTN.bmp"    NOBORDER    ;
                  ACTION ( oLbx:KeyDown(VK_UP, 0) ,oLbx:setfocus())
 @  180,6 BTNBMP aBtnScrollBrw[2]  OF  oDlgDivide SIZE 30, 30 PIXEL     Filename ".\bitmaps\BMP_DOWN_BTN.bmp"  NOBORDER    ;
                   ACTION (oLbx:KeyDown(VK_DOWN, 0) ,oLbx:setfocus())



 @  50,490  BTNBMP  aBtnScrollBrw[3] OF  oDlgDivide SIZE 30, 30 PIXEL  Filename ".\bitmaps\BMP_UP_BTN.bmp"    NOBORDER   ;
                  ACTION (oLbx2:KeyDown(VK_UP, 0) ,oLbx2:setfocus())
 @  180,490 BTNBMP aBtnScrollBrw[4]  OF  oDlgDivide SIZE 30, 30 PIXEL  Filename ".\bitmaps\BMP_DOWN_BTN.bmp"  NOBORDER    ;
                   ACTION (oLbx2:KeyDown(VK_DOWN, 0) ,oLbx2:setfocus())





  //-------------------------------------------------------------------------------------------------------------------------//
 // For Drag and Drop  the xbrowses
 //-------------------------------------------------------------------------------------------------------------------------//

  @  50,245 BTNBMP  aBtnDropBrw[1] OF  oDlgDivide SIZE 30, 30 PIXEL  Filename ".\bitmaps\dropin.bmp"   NOBORDER     ;
                  ACTION  ( AAdd( oLbx2:aArrayData,  oLbx:aArrayData[ oLbx:nRowSel ] ), ;
                                            ADel( oLbx:aArrayData, oLbx:nRowSel, .t. ), ;
                                              oLbx:Refresh(.t.), oLbx2:Refresh(.t.),;
                                              oLbx:setfocus() ,SetTotals(oLbx,oLbx2,oDlgDivide,aVars,aVars2))



   @  90,245  BTNBMP  aBtnDropBrw[2] OF  oDlgDivide SIZE 30, 30 PIXEL  Filename ".\bitmaps\dropout.bmp"  NOBORDER     ;
                  ACTION ( AAdd( oLbx:aArrayData,  oLbx2:aArrayData[ oLbx2:nRowSel ] ), ;
                                            ADel( oLbx2:aArrayData, oLbx2:nRowSel, .t. ), ;
                                              oLbx:Refresh(.t.), oLbx2:Refresh(.t.),;
                                              oLbx2:setfocus(),SetTotals(oLbx,oLbx2,oDlgDivide,aVars,aVars2) )







  //-------------------------------------------------------------------------------------------------------------------------//
 // buttons at footer
 //-------------------------------------------------------------------------------------------------------------------------//

   @ 2.7,43 button "Ricarica Conto originale" OF  oDlgDivide SIZE 120, 18 ;
                            PIXEL   ACTION NIL

   @ 2.7,200 button "Scompatta" OF  oDlgDivide SIZE 40, 18  PIXEL ;
                              ACTION  NIL

   @ 2.7,290 button "Nuovo Conto" OF  oDlgDivide SIZE 80, 18  PIXEL ;
                              ACTION NIL



    @ 329,390 button "Scontrino" OF  oDlgDivide SIZE 80, 18  PIXEL    ACTION NIL



   //-------------------------------------------------------------------------------------------------------------------------//
 // For Totals  the xbrowses
 //-------------------------------------------------------------------------------------------------------------------------//

  @ 230,20 GROUP oGr1 TO 298,250 PIXEL  OF oDlgDivide

  @  240, 40 SAY  oSaysTxt[1] PROMPT '#Prodotti:'  OF oDlgDivide  SIZE 400, 12 PIXEL FONT  oFntSaysTxt
  @  260, 40 SAY  oSaysTxt[2] PROMPT '#Coperti :'  OF oDlgDivide  SIZE 400, 12 PIXEL FONT  oFntSaysTxt
  @  240,130 SAY  oSaysTxt[3] PROMPT '#SubTotale:' OF oDlgDivide  SIZE 400, 12 PIXEL FONT  oFntSaysTxt
  @  260,130 SAY  oSaysTxt[4] PROMPT '#Servizio:'  OF oDlgDivide  SIZE 400, 12 PIXEL FONT  oFntSaysTxt
  @  280,130 SAY  oSaysTxt[5] PROMPT '#Totale:'    OF oDlgDivide  SIZE 400, 12 PIXEL FONT  oFntSaysTxt

  @  240,95 GET  oSaysGet[1] VAR aVars[1]   OF oDlgDivide ;
                    FONT oFntSaysTxt SIZE 30, 12 PIXEL PICTURE '999'  UPDATE READONLY    RIGHT

  @  260,95 GET  oSaysGet[2] VAR aVars[2]   OF oDlgDivide;
                    FONT oFntSaysTxt SIZE 30, 12 PIXEL PICTURE '999'    READONLY    RIGHT  UPDATE

  @  240,180 GET  oSaysGet[3] VAR aVars[3]    OF oDlgDivide;
             FONT oFntSaysTxt SIZE 55, 12 PIXEL PICTURE '99999,999.99' READONLY  RIGHT    UPDATE

  @  260,180 GET  oSaysGet[4] VAR aVars[4]  OF oDlgDivide;
             FONT oFntSaysTxt SIZE 55, 12 PIXEL PICTURE '99999,999.99'     READONLY  RIGHT  UPDATE

  @  280,180 GET  oSaysGet[5] VAR aVars[5]   OF oDlgDivide;
            FONT oFntSaysTxt SIZE 55, 12 PIXEL PICTURE '99999,999.99'  READONLY  RIGHT  UPDATE


  @  240,280 SAY  oSaysTxt1[1] PROMPT '#Prodotti:'  OF oDlgDivide  SIZE 400, 12 PIXEL FONT  oFntSaysTxt
  @  260,280 SAY  oSaysTxt1[2] PROMPT '#Coperti :'  OF oDlgDivide  SIZE 400, 12 PIXEL FONT  oFntSaysTxt
  @  240,370 SAY  oSaysTxt1[3] PROMPT '#SubTotale:' OF oDlgDivide  SIZE 400, 12 PIXEL FONT  oFntSaysTxt
  @  260,370 SAY  oSaysTxt1[4] PROMPT '#Servizio:'  OF oDlgDivide  SIZE 400, 12 PIXEL FONT  oFntSaysTxt
  @  280,370 SAY  oSaysTxt1[5] PROMPT '#Totale:'    OF oDlgDivide  SIZE 400, 12 PIXEL FONT  oFntSaysTxt


  @  240,335 GET  oSaysGet1[1] VAR aVars2[1]   OF oDlgDivide ;
                    FONT oFntSaysTxt SIZE 30, 12 PIXEL PICTURE '999'  UPDATE READONLY    RIGHT

  @  260,335 GET  oSaysGet1[2] VAR aVars2[2]   OF oDlgDivide;
                    FONT oFntSaysTxt SIZE 30, 12 PIXEL PICTURE '999'    READONLY    RIGHT  UPDATE

  @  240,420 GET  oSaysGet1[3] VAR aVars2[3]    OF oDlgDivide;
             FONT oFntSaysTxt SIZE 55, 12 PIXEL PICTURE '99999,999.99' READONLY  RIGHT    UPDATE

  @  260,420 GET  oSaysGet1[4] VAR aVars2[4]  OF oDlgDivide;
             FONT oFntSaysTxt SIZE 55, 12 PIXEL PICTURE '99999,999.99'     READONLY  RIGHT  UPDATE

  @  280,420 GET  oSaysGet1[5] VAR aVars2[5]   OF oDlgDivide;
            FONT oFntSaysTxt SIZE 55, 12 PIXEL PICTURE '99999,999.99'  READONLY  RIGHT  UPDATE


  Activate dialog oDlgDivide
  //ON INIT SetTotals(oLbx,oLbx2,oDlgDivide,aVars,aVars2)



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

Re: To Nages : Problem With Dragand Drop

Postby gabo » Tue Jun 13, 2017 8:02 pm

Silvio
You complicate life in the product table add a field for the name or reference of the customer. Make editable that column in the browse and go putting for each product to which client belongs.
1 caprese ....... peter or ch1 (ch=Chair)
1 lasagne........ jhon or ch2
1 tomato......... peter or ch1
1 coca cola...... jhon or ch2
1 beer corona.... charles or ch3
1 beef ............ charles or ch3
etc
etc
etc
after you printer the count is easy and each client will have their own account
jhon ticket 100
peter ticket 105
charles ticket 102

Regards
gabo
 
Posts: 128
Joined: Tue Jan 03, 2006 8:31 pm

Re: To Nages : Problem With Dragand Drop

Postby Silvio.Falconi » Wed Jun 14, 2017 8:29 am

Gabo, I must make how I made I wish only transfer product with variant and make another ticketx for each customers
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: Google [Bot] and 109 guests