【问题标题】:Passing a value as a search criteria传递一个值作为搜索条件
【发布时间】:2014-03-25 22:32:00
【问题描述】:

我确实想根据搜索框中的输入过滤结果,我将解释它应该如何工作

  1. 最初它应该显示“每个客户”的完整结果
  2. 然后在结果中,如果我按“s”,将出现一个搜索框,提示输入客户编号
  3. 在提供公司编号时,应仅显示该公司的结果。

代码:

for each customer where customer.no = num no-lock:
    tmpname.name = customer.name
    tmpname.no = customer.no
end.

if num = "" then
    for each customer no-lock:    
        create tmptable  
        tmpname.name = customer.name  
        tmpname.no = customer.no   
    end.

上表将显示所有公司的结果,

此表单将提示输入 customer.no

 form num
        customer.no
     with frame f1.
 update num with frame f1.

现在,我不知道如何将此数字传递回第一个“FOR EACH”。仅过滤给定客户编号的搜索。非常感谢您的帮助。提前致谢。

【问题讨论】:

  • 您说“上表将显示所有公司的结果”,但实际上它什么也没显示——它只是(试图)建立一个临时表(这可能也不起作用—— - 示例代码看起来很乱码)。所以你显然在做一些你没有透露的事情。真正的问题是什么?

标签: progress-4gl openedge


【解决方案1】:

我认为这与您用文本(但不是代码)描述的一样:

define variable cNum as integer no-undo.

define query q for customer.

define browse b query q display customer.custNum customer.name with 10 down.

form b with frame custList row 1 column 1.

form
  cNum
 with
  frame updCustNum
  column 50
  row 1
.

on "s" anywhere do:
  apply "entry" to cNum in frame updCustNum.
  return no-apply.
end.

on "go", "enter" of cNum in frame updCustNum do:
  cNum = integer( self:screen-value ).
  close query q.
  open query q for each customer no-lock where customer.custNum = cNum.
  apply "entry" to b in frame custList.
  return no-apply.
end.

open query q for each customer no-lock.

enable cNum with frame updCustNum.
enable b with frame custList.
apply "entry" to b in frame custList.

wait-for "close" of this-procedure.

return.

【讨论】:

    【解决方案2】:

    我真的不能 100% 确定您的要求,但您可以(应该)将您的逻辑放在一个过程甚至一个单独的程序中,并在特定事件(按钮单击、程序启动或您选择的任何内容)中调用它)。

    PROCEDURE searchCustomer:
        DEFINE INPUT  PARAMETER piCustomerNo AS INTEGER     NO-UNDO.
        DEFINE OUTPUT PARAMETER TABLE FOR tmpname.
    
        IF piCustomerNo = 0 THEN DO:
            FOR EACH customer NO-LOCK TABLE-SCAN: /* TABLE-SCAN only works in version 11.something and forward */
                CREATE tmpname.
                BUFFER-COPY customer TO tmpName.
            END.
        END.
        ELSE DO:
            FOR EACH customer NO-LOCK WHERE Customer.NO = piCustomerNo:
                CREATE tmpname.
                BUFFER-COPY customer TO tmpName.
            END.
        END.
    
    END PROCEDURE.
    

    关于你所做的具体事件:

    RUN searchCustomer(INPUT 0, OUTOUT TABLE tmpname).
    

    或

    RUN searchCustomer(INPUT iCustomer, OUTOUT TABLE tmpname).
    

    【讨论】:

    • 该表单在单独的过程中,我想将值从单独的过程传递到主循环。
    • 你也可以做输出参数。我仍然不能 100% 确定您要做什么。
    • 主循环可以调用 Jensd 创建的过程,然后在过程之后你有一个包含你需要的所有数据的临时表。很好很简单。
    猜你喜欢
    • 2017-02-28
    • 2021-08-18
    • 1970-01-01
    • 1970-01-01
    • 2021-12-29
    • 1970-01-01
    • 2011-03-20
    • 1970-01-01
    • 2022-01-13
    相关资源
    最近更新 更多