| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 2478 人关注过本帖
标题:请教组合条件查询表单设计问题
取消只看楼主 加入收藏
陶然愚者
Rank: 1
等 级:新手上路
帖 子:151
专家分:8
注 册:2012-12-13
结帖率:100%
收藏
已结贴  问题点数:15 回复次数:14 
请教组合条件查询表单设计问题
图片附件: 游客没有浏览图片的权限,请 登录注册

如图,本人制作了一个组合条件查询表单,设计思路是:
用户在“条件选择”列表框中选定字段后,其值显示在text1文本框中,再选择“关系运算符”,其值显示在text2文本框中,在text3中输入查询值,点击“添加条件”按纽,条件表达式显示在text4文本框中。用户可以重复添加多个条件,text4的值随添加的条件动态改变。最后依据text4值的组合条件表达式筛选数据。
在表单的load事件中添加了如下代码:
DIMENSION zdtj(6),gxysf(6),cxz(6),ljysf(6)
PUBLIC cxtj,i
cxtj=''
i=1

list1的InteractiveChange事件代码:
DO case
CASE thisform.list1.Value='企业代码'
thisform.text1.Value='qyjbxxb.jgdm'
thisform.Optiongroup1.option2.enabled= .F.
thisform.Optiongroup1.option3.enabled= .F.
thisform.Optiongroup1.option4.enabled= .F.
thisform.Optiongroup1.option5.enabled= .F.
CASE thisform.list1.Value='企业名称'
thisform.text1.Value='qyjbxxb.jgmc'
thisform.Optiongroup1.option2.enabled= .F.
thisform.Optiongroup1.option3.enabled= .F.
thisform.Optiongroup1.option4.enabled= .F.
thisform.Optiongroup1.option5.enabled= .F.
CASE thisform.list1.Value='企业地址'
thisform.text1.Value='qyjbxxb.jgdz'
thisform.Optiongroup1.option2.enabled= .F.
thisform.Optiongroup1.option3.enabled= .F.
thisform.Optiongroup1.option4.enabled= .F.
thisform.Optiongroup1.option5.enabled= .F.
CASE thisform.list1.Value='行政区划'
thisform.text1.Value='qyjbxxb.xzqh'
thisform.Optiongroup1.option2.enabled= .F.
thisform.Optiongroup1.option3.enabled= .F.
thisform.Optiongroup1.option4.enabled= .F.
thisform.Optiongroup1.option5.enabled= .F.
CASE thisform.list1.Value='邮政编码'
thisform.text1.Value='qyjbxxb.yzbm'
thisform.Optiongroup1.option2.enabled= .F.
thisform.Optiongroup1.option3.enabled= .F.
thisform.Optiongroup1.option4.enabled= .F.
thisform.Optiongroup1.option5.enabled= .F.
CASE thisform.list1.Value='法人代表'
thisform.text1.Value='qyjbxxb.fddbr'
thisform.Optiongroup1.option2.enabled= .F.
thisform.Optiongroup1.option3.enabled= .F.
thisform.Optiongroup1.option4.enabled= .F.
thisform.Optiongroup1.option5.enabled= .F.
CASE thisform.list1.Value='经济行业'
thisform.text1.Value='qyjbxxb.jjhy'
thisform.Optiongroup1.option2.enabled= .F.
thisform.Optiongroup1.option3.enabled= .F.
thisform.Optiongroup1.option4.enabled= .F.
thisform.Optiongroup1.option5.enabled= .F.
CASE thisform.list1.Value='经济类型'
thisform.text1.Value='qyjbxxb.jjlx'
thisform.Optiongroup1.option2.enabled= .F.
thisform.Optiongroup1.option3.enabled= .F.
thisform.Optiongroup1.option4.enabled= .F.
thisform.Optiongroup1.option5.enabled= .F.
CASE thisform.list1.Value='企业类型'
thisform.text1.Value='qyjbxxb.jglx'
thisform.Optiongroup1.option2.enabled= .F.
thisform.Optiongroup1.option3.enabled= .F.
thisform.Optiongroup1.option4.enabled= .F.
thisform.Optiongroup1.option5.enabled= .F.
CASE thisform.list1.Value='职工人数'
thisform.text1.Value='qyjbxxb.zgrs'
thisform.Optiongroup1.option7.enabled= .F.
thisform.Optiongroup1.option8.enabled= .F.
thisform.Optiongroup1.option9.enabled= .F.
CASE thisform.list1.Value='年产值'
thisform.text1.Value='qyjbxxb.ncz'
thisform.Optiongroup1.option7.enabled= .F.
thisform.Optiongroup1.option8.enabled= .F.
thisform.Optiongroup1.option9.enabled= .F.
CASE thisform.list1.Value='登记日期'
thisform.text1.Value='DTOC(qyjbxxb.djrq,1)'
thisform.Optiongroup1.option7.enabled= .F.
thisform.Optiongroup1.option8.enabled= .F.
thisform.Optiongroup1.option9.enabled= .F.
CASE thisform.list1.Value='认证类型'
thisform.text1.Value='qyjbxxb.rzlx'
thisform.Optiongroup1.option2.enabled= .F.
thisform.Optiongroup1.option3.enabled= .F.
thisform.Optiongroup1.option4.enabled= .F.
thisform.Optiongroup1.option5.enabled= .F.
CASE thisform.list1.Value='产品名称'
thisform.text1.Value='qyzycpk.zycp'
thisform.Optiongroup1.option2.enabled= .F.
thisform.Optiongroup1.option3.enabled= .F.
thisform.Optiongroup1.option4.enabled= .F.
thisform.Optiongroup1.option5.enabled= .F.
CASE thisform.list1.Value='产品类别'
thisform.text1.Value='qyzycpk.cplb'
thisform.Optiongroup1.option2.enabled= .F.
thisform.Optiongroup1.option3.enabled= .F.
thisform.Optiongroup1.option4.enabled= .F.
thisform.Optiongroup1.option5.enabled= .F.
CASE thisform.list1.Value='执行标准等级'
thisform.text1.Value='qyzycpk.cpbzdj'
thisform.Optiongroup1.option2.enabled= .F.
thisform.Optiongroup1.option3.enabled= .F.
thisform.Optiongroup1.option4.enabled= .F.
thisform.Optiongroup1.option5.enabled= .F.
CASE thisform.list1.Value='是否采标'
thisform.text1.Value='qyzycpk.cbbz'
thisform.Optiongroup1.option2.enabled= .F.
thisform.Optiongroup1.option3.enabled= .F.
thisform.Optiongroup1.option4.enabled= .F.
thisform.Optiongroup1.option5.enabled= .F.
CASE thisform.list1.Value='获奖名称'
thisform.text1.Value='qyzycpk.hjmc'
thisform.Optiongroup1.option2.enabled= .F.
thisform.Optiongroup1.option3.enabled= .F.
thisform.Optiongroup1.option4.enabled= .F.
thisform.Optiongroup1.option5.enabled= .F.
CASE thisform.list1.Value='许可类型'
thisform.text1.Value='qyzycpk.xklx'
thisform.Optiongroup1.option2.enabled= .F.
thisform.Optiongroup1.option3.enabled= .F.
thisform.Optiongroup1.option4.enabled= .F.
thisform.Optiongroup1.option5.enabled= .F.
CASE thisform.list1.Value='许可证号'
thisform.text1.Value='qyzycpk.xkzh'
thisform.Optiongroup1.option2.enabled= .F.
thisform.Optiongroup1.option3.enabled= .F.
thisform.Optiongroup1.option4.enabled= .F.
thisform.Optiongroup1.option5.enabled= .F.
ENDCASE
zdtj(i)=alltrim(thisform.text1.value)

Optiongroup1的InteractiveChange代码:
if thisform.Optiongroup1.Value=10
thisform.text2.Value='is'
thisform.text3.value='null'
ELSE
DO case
CASE thisform.Optiongroup1.Value=1
thisform.text2.Value='='
CASE thisform.Optiongroup1.Value=2
thisform.text2.Value='>'
CASE thisform.Optiongroup1.Value=3
thisform.text2.Value='>='
CASE thisform.Optiongroup1.Value=4
thisform.text2.Value='<'
CASE thisform.Optiongroup1.Value=5
thisform.text2.Value='<='
CASE thisform.Optiongroup1.Value=6
thisform.text2.Value='<>'
CASE (thisform.Optiongroup1.Value=7).or.(thisform.Optiongroup1.Value=8).or.(thisform.Optiongroup1.Value=9)
thisform.text2.Value='like'
ENDCASE
thisform.text3.SetFocus
ENDIF
gxysf(i)=ALLTRIM(thisform.text2.Value)

Combo1的InteractiveChange代码:
if
DO case
CASE
ljysf(i)='.and.'
CASE
ljysf(i)='.or.'
ENDCASE
thisform.text1.Value=''
thisform.text2.Value=''
thisform.text3.Value=''
thisform.list1.SetFocus
thisform.Optiongroup1.value=0
thisform.Optiongroup1.option2.enabled= .T.
thisform.Optiongroup1.option3.enabled= .T.
thisform.Optiongroup1.option4.enabled= .T.
thisform.Optiongroup1.option5.enabled= .T.
thisform.Optiongroup1.option7.enabled= .T.
thisform.Optiongroup1.option8.enabled= .T.
thisform.Optiongroup1.option9.enabled= .T.
ENDIF

在“添加条件”按纽的click事件中,添加了如下代码:
IF EMPTY(zdtj).or.empty(gxysf).or.empty(cxz)
MESSAGEBOX('您还没有设置条件!')
thisform.list1.SetFocus
ENDIF
IF (thisform.Optiongroup1.Value=7).or.(thisform.Optiongroup1.Value=8).or.(thisform.Optiongroup1.Value=9)
DO case
case thisform.Optiongroup1.Value=7
cxtj=cxtj+zdtj(i)+' '+gxysf(i)+' '+'"%'+cxz(i)+'%"'
CASE thisform.Optiongroup1.Value=8
cxtj=cxtj+zdtj(i)+' '+gxysf(i)+' '+'"%'+cxz(i)+'"'
CASE thisform.Optiongroup1.Value=9
cxtj=cxtj+zdtj(i)+' '+gxysf(i)+' '+'"'+cxz(i)+'%"'
ENDCASE
ELSE
IF thisform.Optiongroup1.Value=10
cxtj=cxtj+zdtj(i)+' '+gxysf(i)+' '+'"'+cxz(i)+'"'
ELSE
cxtj=cxtj+zdtj(i)+gxysf(i)+cxz(i)
ENDIF
ENDIF
IF
cxtj=cxtj+ljysf(i)
ENDIF
thisform.text4.value=cxtj
运行表单,选择字段条件后,显示:
图片附件: 游客没有浏览图片的权限,请 登录注册

在“添加条件”按纽的click事件代码最后加一行:
i=i+1
再运行,选择字段条件后则提示:
图片附件: 游客没有浏览图片的权限,请 登录注册

请问:我的问题出在哪里?怎样解决?
谢谢!

[ 本帖最后由 陶然愚者 于 2013-1-22 13:18 编辑 ]
收到的鲜花
  • tlliqi2013-01-22 19:47 送鲜花  20朵   附言:对你的学习精神给予鼓励。
搜索更多相关主题的帖子: PUBLIC 表达式 文本框 
2013-01-22 11:34
陶然愚者
Rank: 1
等 级:新手上路
帖 子:151
专家分:8
注 册:2012-12-13
收藏
得分:0 
补充:“挂起”程序后,问题都指向
zdtj(i)=alltrim(thisform.text1.value)
这一句
2013-01-22 11:49
陶然愚者
Rank: 1
等 级:新手上路
帖 子:151
专家分:8
注 册:2012-12-13
收藏
得分:0 
回复 3楼 sdta
谢谢斑竹直言相告。的确,本人年逾五十,学生时代基本在文革时期度过,学习VFP其实根本不具备条件,由于不懂基础语言,又不懂英语,可又倔强地总想学一些“时尚”(其实在本人看来是日常工作所需要的)知识。学习过程中难免会消化不良。以编写代码为例,无所谓什么习惯,实质上就是对相关知识领会不透,导致不仅是层次不清,更有许多冗余代码的问题。鼓足勇气上此论坛提问,也就不怕露丑,只要能向各位行家学习就好。

斑竹关于将text4改为编辑框的提示,非常赞同,这就去改。只是题中问题还望各位老师不吝赐教
2013-01-22 13:09
陶然愚者
Rank: 1
等 级:新手上路
帖 子:151
专家分:8
注 册:2012-12-13
收藏
得分:0 
表单内容见帖。

[ 本帖最后由 陶然愚者 于 2013-1-22 14:08 编辑 ]
2013-01-22 13:22
陶然愚者
Rank: 1
等 级:新手上路
帖 子:151
专家分:8
注 册:2012-12-13
收藏
得分:0 
初步认识,就当前的症状,应该是变量的设置或传递使用的问题。可惜具体问题在哪里因水平有限实在找不出。有劳各位老师指点。
2013-01-22 13:37
陶然愚者
Rank: 1
等 级:新手上路
帖 子:151
专家分:8
注 册:2012-12-13
收藏
得分:0 
回复 10楼 sdta
数组的元素数量应该是组合条件的条件个数吧,测试中“添加条件”次数并未超过6次,为什么会警示“超界”?
2013-01-22 13:52
陶然愚者
Rank: 1
等 级:新手上路
帖 子:151
专家分:8
注 册:2012-12-13
收藏
得分:0 
试了一下:引用数组变量时不用下标,貌似可以解决问题。不知对否?
2013-01-22 14:11
陶然愚者
Rank: 1
等 级:新手上路
帖 子:151
专家分:8
注 册:2012-12-13
收藏
得分:0 
回复 13楼 sdta
回头抽时间再试。测试成功再来汇报。谢谢斑竹持续在线指导。
2013-01-22 14:27
陶然愚者
Rank: 1
等 级:新手上路
帖 子:151
专家分:8
注 册:2012-12-13
收藏
得分:0 
    谢谢各位指点。试着从以下几个方面进行了改进:
    1、去掉了表单中load事件建立数组和变量i的语句,直接在其Init事件中定义五个变量,分别用于存贮“字段条件”、“关系运算符”、“查询值”、“逻辑运算符”和组合条件表达式。
    2、将TEXT4改用编辑框控件。
    3、Combo1的InteractiveChange事件代码末尾加一行代码恢复初始设置:
        
    4、各控件中InteractiveChange事件代码中接收相关值的变量均去掉下标。
    经过以上修改,问题基本得到解决,用户可以选择多个条件进行组合,编辑框edit1中能够动态显示组合条件表达式。运行结果如下图:
图片附件: 游客没有浏览图片的权限,请 登录注册

    其他的一些关于条件表达式生成中的细节问题尚待进一步学习修正。学习中遇到的问题本人会及时提出,还请各位老师赐教。

[ 本帖最后由 陶然愚者 于 2013-1-22 17:29 编辑 ]
2013-01-22 17:16
陶然愚者
Rank: 1
等 级:新手上路
帖 子:151
专家分:8
注 册:2012-12-13
收藏
得分:0 
回复 16楼 TonyDeng
感谢斑竹。由此又对变量有了进一步的认识。
2013-01-23 07:48
快速回复:请教组合条件查询表单设计问题
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.020836 second(s), 10 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved