Value changing event in browser?

2019-09-07 03:25发布

问题:

define variable hOrderQuery     as handle no-undo.
define variable browseOrder-hdl as handle no-undo.
define variable browse-hdl      as handle  no-undo.
define variable CNumber         as integer no-undo.

CREATE QUERY hQuery.
hQuery:SET-BUFFERS(BUFFER Customer:HANDLE).
hQuery:QUERY-PREPARE("FOR EACH Customer").
hQuery:QUERY-OPEN().

CREATE BROWSE browse-hdl
ASSIGN
TITLE     = "Customer Browser"
FRAME     = FRAME MyFrame:HANDLE
QUERY     = hQuery
X         = 2
Y         = 2
WIDTH     = 74
DOWN      = 10
VISIBLE   = YES
SENSITIVE = TRUE
READ-ONLY = yes.
browse-hdl:ADD-COLUMNS-FROM(BUFFER Customer:HANDLE,"SalesRep,email,fax,comments,address,City,State,PostalCode").


on value-changed of browse-hdl
do:

FIND CURRENT Customer.
cNumber = Customer.CustNum.

CREATE QUERY hOrderQuery.
hOrderQuery:SET-BUFFERS(BUFFER Order:HANDLE).
hOrderQuery:QUERY-PREPARE("FOR EACH Order where Order.CustNum = " + string(cNumber)) no-    error.
hOrderQuery:QUERY-OPEN().

CREATE BROWSE browseOrder-hdl
ASSIGN
TITLE     = "Order Browser"
FRAME     = FRAME MyFrame:HANDLE
QUERY     = hOrderQuery
X         = 2
Y         = 240
WIDTH     = 74
DOWN      = 10
VISIBLE   = YES
SENSITIVE = TRUE
READ-ONLY = yes.
browseOrder-hdl:ADD-COLUMNS-FROM(BUFFER Order:HANDLE,"warehousenum,CustNum").

end.


on value-changed of browseOrder-hdl
do:
message "hai" view-as alert-box.
end.

this is my issue.I have 3 browsers.Now i created only two. When I click on first customer browser's one row it should select the current customer and should show his order in the second browser-order browser. When I click on order browser value it should show the corresponding orderline table values in the 3rd orderline browser(which i didnt create now).

So when I tried to take the browseOrder-hdl to create second value-changed event, it is showing it is already deleted. How to overcome this issue??Please reply.

回答1:

DEFINE FRAME MyFrame
  WITH 1 DOWN NO-BOX KEEP-TAB-ORDER OVERLAY 
  SIDE-LABELS NO-UNDERLINE THREE-D 
  AT COL 1 ROW 1
  SIZE 80 BY 16.

define variable hOrderQuery     as handle  no-undo.
define variable browseOrder-hdl as handle  no-undo.
define variable browse-hdl      as handle  no-undo.
define variable CNumber         as integer no-undo.
DEFINE VARIABLE hQuery          AS HANDLE  NO-UNDO.

CREATE QUERY hQuery.
hQuery:SET-BUFFERS(BUFFER Customer:HANDLE).
hQuery:QUERY-PREPARE("FOR EACH Customer").
hQuery:QUERY-OPEN().

CREATE BROWSE browse-hdl
  ASSIGN
  TITLE     = "Customer Browser"
  FRAME     = FRAME MyFrame:HANDLE
  QUERY     = hQuery
  X         = 2
  Y         = 2
  WIDTH     = 74
  DOWN      = 10
  VISIBLE   = TRUE
  SENSITIVE = TRUE
  READ-ONLY = TRUE
  TRIGGERS:
    ON VALUE-CHANGED DO:
      RUN ShowOrderBrowser.
    END.  
  END.  

  browse-hdl:ADD-COLUMNS-FROM(BUFFER Customer:HANDLE,"SalesRep,email,fax,comments,address,City,State,PostalCode").



WAIT-FOR CLOSE OF THIS-PROCEDURE.



/* **********************  Internal Procedures  *********************** */

PROCEDURE ShowOrderBrowser:
  /*------------------------------------------------------------------------------
      Purpose:                                                                        
      Notes:                                                                      
  ------------------------------------------------------------------------------*/
  FIND CURRENT Customer.
  cNumber = Customer.CustNum.

  CREATE QUERY hOrderQuery.
  hOrderQuery:SET-BUFFERS(BUFFER Order:HANDLE).
  hOrderQuery:QUERY-PREPARE("FOR EACH Order WHERE Order.CustNum = " + STRING(cNumber)).
  hOrderQuery:QUERY-OPEN().

  CREATE BROWSE browseOrder-hdl
    ASSIGN
    TITLE     = "Order Browser"
    FRAME     = FRAME MyFrame:HANDLE
    QUERY     = hOrderQuery
    X         = 2
    Y         = 240 
    WIDTH     = 74
    DOWN      = 10
    VISIBLE   = TRUE
    SENSITIVE = TRUE
    READ-ONLY = TRUE    
    TRIGGERS:
      ON VALUE-CHANGED DO:
        MESSAGE "hai"
        VIEW-AS ALERT-BOX.
      END.
    END.

  browseOrder-hdl:ADD-COLUMNS-FROM(BUFFER Order:HANDLE,"warehousenum,CustNum").  

  WAIT-FOR VALUE-CHANGED OF browseOrder-hdl.

END PROCEDURE.