Subject Re: Form menu's
From Akshat Kapoor <akshat.kapoor@kapoorsons.in>
Date Mon, 27 Jul 2020 13:19:35 +0530
Newsgroups dbase.getting-started
Attachment(s) menu_data.wfm

Good Morning Tony,
> Hi more help ?
> Can anyone explain to me why " code one works" , and "code two" will not - I have played with this for 6 hours and can not see the difference - Too simple ??
> Code one works perfectly in using coded forms ?, and I want to repeat.
> -----------------------------------------------------------------
> Code one
> -----------------------------------------------------------------
>     function PUSHBUTTON1_onClick()
>        do allproahead.wfm
>        form.close()
>        return
> -------------------------------------------------------------------------------------------
> Does Not Work -  Code Number 2
> --------------------------------------------------------------------------------------------
>     function PUSHBUTTON1_onClick()
>        form.close()
>                 do Displaymbc.wfm
>        return

You Code 1 works becuase you execute the line do ???????.wfm before
closing the form

In code 2 you have placed code after the form.close() line.

Once a form encounters form.close() it will not execute any other
command in the file apart from canClose or onClose events of the form.

I hope this helps.

At one or two places you have mentioned ???.wfo
No need to mention wfo just mention .wfm and dbase will take care of the
rest.

I also use pushbuttons to create menu options but my approach is
slightly different. I have attached a form that I am using.

Regards
Akshat.



parameter bModal
mmenu_data = 0
mmenu_sub = " "
local f
do WHILE mmenu_data >=0
        f = new menu_dataForm()
        f.mdi = false // ensure not MDI
        f.readModal()
        numlock()
        do case
                case mmenu_data = 1
                        do e_sales.wfm with .t.
                case mmenu_data = 2
                        do e_day.wfm with .t.
                case mmenu_data = 3
                        if empty(mcompany.go1+mcompany.go2)
                                msgbox("No godown/branches specified hence unable to continue")
                        else
                                do e_trans2.wfm
                        endif
                case mmenu_data = 4
                        do e_purch.wfm
                case mmenu_data = 5
                        msgbox("Challan")
                case mmenu_data = 6
                        do e_tax.wfm
                case mmenu_data = 7
                        do e_quot.wfm
                case mmenu_data = 8
                        do e_prof.wfm
                case mmenu_data = 9
                        do e_jour.wfm
                case mmenu_data = 10
                        do e_inve.wfm with .t.
                case mmenu_data = 11
                        do e_mast.wfm
                case mmenu_data = 12
                        do barcode.wfm
                case mmenu_data = 13
                        do e_label.wfm
                case mmenu_data = 14
                        do rapid.wfm with .t.
                case mmenu_data = 15
                        do e_big.wfm with .t.
                case mmenu_data = 16
                        do e_stax.wfm with .t.
                case mmenu_data = 17
                        do e_sinve.wfm with .t.
      case mmenu_data = 18
         do arapid.wfm with .t.
        endcase
enddo
return
** END HEADER -- do not remove this line
//
// Generated on 25.12.2019
//
parameter bModal
local f
f = new menu_dataForm()
if (bModal)
   f.mdi = false // ensure not MDI
   f.readModal()
else
   f.open()
endif

class menu_dataForm of MUN_FORM from "mun_controls.cc"
   set procedure to mun_controls.cc additive
   with (this)
      onOpen = class::FORM_ONOPEN
      height = 28.6364
      left = -0.4286
      top = -3.9091
      width = 190.2857
   endwith

   this.CASH = new MUN_PUSH(this)
   with (this.CASH)
      when = {||mcompany.inven}
      onClick = class::CASH_ONCLICK
      height = 2.0
      left = 53.0
      top = 3.5
      width = 30.0
      text = "&1. Cash Memo"
   endwith

   this.DAY = new MUN_PUSH(this)
   with (this.DAY)
      onClick = class::DAY_ONCLICK
      height = 2.0
      left = 53.0
      top = 6.4091
      width = 30.0
      text = "&2. Day Book"
   endwith

   this.TRANSFER = new MUN_PUSH(this)
   with (this.TRANSFER)
      when = {||mcompany.inven}
      onClick = class::TRANSFER_ONCLICK
      height = 2.0
      left = 53.0
      top = 9.3182
      width = 30.0
      text = "&3. Stock Transfer "
   endwith

   this.NEW_PURCH = new MUN_PUSH(this)
   with (this.NEW_PURCH)
      when = {||mcompany.inven and mcompany.access >2}
      onClick = class::NEW_PURCH_ONCLICK
      height = 2.0
      left = 53.0
      top = 12.2273
      width = 30.0
      text = "&4. New Purchases"
   endwith

   this.CHALLAN = new MUN_PUSH(this)
   with (this.CHALLAN)
      when = {||mcompany.inven}
      onClick = class::CHALLAN_ONCLICK
      height = 2.0
      left = 53.0
      top = 15.0
      width = 30.0
      text = "&5. Challan"
   endwith

   this.TAX = new MUN_PUSH(this)
   with (this.TAX)
      when = {||mcompany.inven}
      onClick = class::TAX_ONCLICK
      height = 2.0
      left = 53.0
      top = 18.0455
      width = 30.0
      text = "&6. Tax Invoice"
   endwith

   this.QUOTATION = new MUN_PUSH(this)
   with (this.QUOTATION)
      when = {||mcompany.inven}
      onClick = class::QUOTATION_ONCLICK
      height = 2.0
      left = 53.0
      top = 20.9545
      width = 30.0
      text = "&7. Quotation"
   endwith

   this.RAPID = new MUN_PUSH(this)
   with (this.RAPID)
      onClick = class::RAPID_ONCLICK
      height = 2.0
      left = 53.0
      top = 23.8636
      width = 30.0
      text = "&H. Hot keys"
   endwith

   this.PROFORMA = new MUN_PUSH(this)
   with (this.PROFORMA)
      when = {||mcompany.inven}
      onClick = class::PROFORMA_ONCLICK
      height = 2.0
      left = 92.0
      top = 3.5
      width = 30.0
      text = "&8. Proforma Invoice"
   endwith

   this.JOURNAL = new MUN_PUSH(this)
   with (this.JOURNAL)
      onClick = class::JOURNAL_ONCLICK
      height = 2.0
      left = 92.0
      top = 6.4091
      width = 30.0
      text = "&9. Journal"
   endwith

   this.ITEMS = new MUN_PUSH(this)
   with (this.ITEMS)
      when = {||mcompany.inven}
      onClick = class::ITEMS_ONCLICK
      height = 2.0
      left = 92.0
      top = 9.3182
      width = 30.0
      text = "&I. Create/alter items"
   endwith

   this.ACCOUNT = new MUN_PUSH(this)
   with (this.ACCOUNT)
      onClick = class::ACCOUNT_ONCLICK
      height = 2.0
      left = 92.0
      top = 12.2273
      width = 30.0
      text = "&A. Create / Alter Accounts"
   endwith

   this.DISC = new MUN_PUSH(this)
   with (this.DISC)
      when = {||mcompany.inven}
      onClick = class::DISC_ONCLICK
      height = 2.0
      left = 92.0
      top = 18.0455
      width = 30.0
      text = "&P. Print Disc Stickers"
   endwith

   this.LABE_L = new MUN_PUSH(this)
   with (this.LABE_L)
      when = {||mcompany.inven}
      onClick = class::LABE_L_ONCLICK
      height = 2.0
      left = 92.0
      top = 15.0
      width = 30.0
      text = "&L. Labels"
   endwith

   this.CL_OSE = new MUN_PUSH(this)
   with (this.CL_OSE)
      onClick = class::CL_OSE_ONCLICK
      height = 2.0
      left = 92.0
      top = 20.9545
      width = 30.0
      text = "&C. Close"
   endwith

   this.BIG_STICK = new MUN_PUSH(this)
   with (this.BIG_STICK)
      onClick = class::BIG_STICK_ONCLICK
      height = 2.0
      left = 92.0
      top = 23.8636
      width = 30.0
      text = "&Big Stickers"
   endwith

   this.QTY = new MUN_SPIN(this)
   with (this.QTY)
      height = 1.0
      left = 127.0
      top = 18.5
      width = 8.0
      step = 3.0
      rangeMax = 999
      value = 33
   endwith

   this.MUN_TEXTLABEL1 = new MUN_TEXTLABEL(this)
   with (this.MUN_TEXTLABEL1)
      height = 1.5
      left = 76.0
      top = 1.0
      width = 52.0
      text = "Data Entry Options"
      fontSize = 18.0
      fontBold = true
      alignHorizontal = 1        // Center
   endwith

   this.MUN_TEXTLABEL2 = new MUN_TEXTLABEL(this)
   with (this.MUN_TEXTLABEL2)
      height = 1.0
      left = 137.0
      top = 18.5
      width = 24.0
      text = "Stickers of                  %"
   endwith

   this.DISC_RATE = new MUN_SPIN(this)
   with (this.DISC_RATE)
      height = 1.0
      left = 149.0
      top = 18.5
      width = 8.0
      step = 5.0
      value = 10
   endwith

   this.BARCODE = new MUN_PUSH(this)
   with (this.BARCODE)
      onClick = class::BARCODE_ONCLICK
      height = 2.0
      left = 127.0
      top = 3.5
      width = 30.0
      text = "Ba&r Code Linking"
   endwith

   this.OFFERPRICE1 = new MUN_PUSH(this)
   with (this.OFFERPRICE1)
      onClick = class::OFFERPRICE1_ONCLICK
      height = 2.0
      left = 127.0
      top = 6.4091
      width = 30.0
      text = "Offer Price 2 Line"
   endwith

   this.OFFER_PRICE3 = new MUN_PUSH(this)
   with (this.OFFER_PRICE3)
      onClick = class::OFFER_PRICE3_ONCLICK
      height = 2.0
      left = 127.0
      top = 9.3182
      width = 30.0
      text = "Offer Price 3 Line"
   endwith

   this.STAX = new MUN_PUSH(this)
   with (this.STAX)
      onClick = class::STAX_ONCLICK
      height = 2.0
      left = 127.0
      top = 12.2273
      width = 30.0
      text = "Services Tax Invoice"
   endwith

   this.E_SINVE = new MUN_PUSH(this)
   with (this.E_SINVE)
      onClick = class::E_SINVE_ONCLICK
      height = 2.0
      left = 127.0
      top = 15.0
      width = 30.0
      text = "Services Head"
   endwith

   this.ARAPID = new MUN_PUSH(this)
   with (this.ARAPID)
      onClick = class::ARAPID_ONCLICK
      height = 2.0
      left = 127.0
      top = 21.0
      width = 30.0
      text = "Accounts Hot Key&s"
   endwith


   function ACCOUNT_onClick()
      mmenu_data = 11
//      do e_mast.wfm
      form.close()
      return

   function ARAPID_onClick()
      mmenu_data = 18
      form.close()            
      return

   function BARCODE_onClick()
      mmenu_data = 12
      form.close()      
      return

   function BIG_STICK_onClick()
      mmenu_data = 15
      form.close()
      return

   function CASH_onClick()
      mmenu_data = 1
//      do e_sales.wfm with .t.
      form.close()
      return

   function CHALLAN_onClick()
      mmenu_data = 5
      form.close()
      return

   function CL_OSE_onClick()
      mmenu_data = -1
      form.close()
      return

   function DAY_onClick()
      mmenu_data = 2
      form.close()
      return

   function DISC_onClick()
//      tmpfile = funique("labe????.dbf")
      mcompany.adodb.executesql('create temporary table if not exists disco (rate numeric(5))')
      mcompany.adodb.executesql('delete from disco where 1')
//      cmd = 'create table "'+tmpfile+'" (rate numeric(5))'
//      &cmd
//      use &tmpfile
      cmd = 'insert into disco values '
      a = 0
      for a= 1 to  form.qty.value
         if len(cmd)>26
            cmd+=','
         endif
         cmd+= '('+ form.disc_rate.value+ ' )'
//         append blank
//         repl rate with form.disc_rate.value
      endfor
      mcompany.adodb.executesql(cmd)
//      use
      set procedure to disco.lab additive
      l = new discoreport()
      load_ini("label.ini","l.printer")
//      l.disco1.sql = 'select * from "'+tmpfile +'"'
      if l.printer.chooseprinter()
         l.title = "Discount Stickers"
         l.render()
      endif
      close procedure disco.lab
      release l
//      delete table &tmpfile
      return

   function E_SINVE_onClick()
      mmenu_data = 17
      form.close()      
      return

   function ITEMS_onClick()
      mmenu_data = 10
      form.close()
      return

   function JOURNAL_onClick()
      mmenu_data = 9
      form.close()
      return

   function LABE_L_onClick()
      mmenu_data = 13
      form.close()
      return

   function NEW_PURCH_onClick()
      mmenu_data = 4
      form.close()
      return

   function OFFERPRICE1_onClick()
      //to print 2 line offer price sticker
      set procedure to offerprice2.lab
      r = new offerprice2()
      load_ini("label.ini","r.printer")
      if r.printer.chooseprinter()
         r.title = "Offer Price 2 Line stickers "
         r.render()
      endif
      close procedure offerprice2.lab
      return

   function OFFER_PRICE3_onClick()
      //to print 3 line offer price sticker
      set procedure to offerprice.lab
      r = new offerprice()
      load_ini("label.ini","r.printer")
      if r.printer.chooseprinter()
         r.title = "Offer Price 3 Line stickers "
         r.render()
      endif
      close procedure offerprice.lab
      return

   function PROFORMA_onClick()
      mmenu_data = 8
      form.close()
      return

   function QUOTATION_onClick()
      mmenu_data = 7
      form.close()
      return

   function RAPID_onClick()
      mmenu_data = 14
      form.close()
      return

   function STAX_onClick()
      mmenu_data = 16
      form.close()      
      return

   function TAX_onClick()
      mmenu_data = 6
      form.close()
      return

   function TRANSFER_onClick()
      mmenu_data = 3
      form.close()
      return

   function form_onOpen()
      //form.height = form_height
                //form.width  = form_width
                form.text = [Data Entry Menu ]+ mcompany.company
                if not mcompany.inven
         form.big_stick.enabled     = false
         form.big_stick.colornormal = push_dis
         form.barcode.enabled       = false
         form.barcode.colornormal   = push_dis
         form.offerprice1.enabled   = false
         form.offer_price3.colornormal=push_dis
         form.offer_price3.enabled   = false
         form.offerprice1.colornormal=push_dis
                        form.cash.enabled                         = false
                        form.cash.colornormal                 = push_dis
                        form.day.setfocus()
                        form.challan.enabled                 = false
                        form.challan.colornormal         = push_dis
                        form.disc.enabled                         = false
                        form.disc.colornormal                 = push_dis
                        form.disc_rate.enabled                 = false
                        form.items.enabled                        = false
                        form.items.enabled                        = false
                        form.items.colornormal                = push_dis
                        form.labe_l.enabled                        = false
                        form.labe_l.colornormal                = push_dis
                        form.new_purch.enabled                = false
                        form.new_purch.colornormal        = push_dis
                        form.proforma.enabled                = false
                        form.proforma.colornormal        = push_dis
                        form.qty.enabled                                = false
                        form.quotation.enabled                = false
                        form.quotation.colornormal        = push_dis
                        form.tax.enabled                                = false
                        form.tax.colornormal                        = push_dis
                        form.transfer.enabled                = false
                        form.transfer.colornormal        = push_dis
         form.rapid.enabled         = false
         form.rapid.colornormal     = push_dis
//         form.stax.enabled          = true
//         form.stax.colornormal      = "White/0xe5fd8"
                        if empty(mcompany.go1+mcompany.go2)
                                form.transfer.enabled = false
                                form.transfer.colornormal = push_dis
                        endif
      else
         form.e_sinve.enabled       = false
         form.e_sinve.colornormal   = push_dis
         form.stax.enabled          = false
         form.stax.colornormal      = push_dis        
                endif
      return

endclass