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

如图,本人制作了一个组合条件查询表单,设计思路是:
用户在“条件选择”列表框中选定字段后,其值显示在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
sdta
Rank: 20Rank: 20Rank: 20Rank: 20Rank: 20
来 自:江苏省连云港市
等 级:版主
威 望:335
帖 子:9821
专家分:27099
注 册:2012-2-5
收藏
得分:0 
楼主书写代码的习惯,不敢恭维
代码层次一定要分明,这种代码看了,让人头发晕。
建议将TEXT4改为EDIT1。

[ 本帖最后由 sdta 于 2013-1-22 12:23 编辑 ]
收到的鲜花
  • 陶然愚者2013-01-23 08:00 送鲜花  3朵   附言:谢谢斑竹点拨

坚守VFP最后的阵地
2013-01-22 12:05
sdta
Rank: 20Rank: 20Rank: 20Rank: 20Rank: 20
来 自:江苏省连云港市
等 级:版主
威 望:335
帖 子:9821
专家分:27099
注 册:2012-2-5
收藏
得分:0 
请楼主上传表单

坚守VFP最后的阵地
2013-01-22 12:24
陶然愚者
Rank: 1
等 级:新手上路
帖 子:151
专家分:8
注 册:2012-12-13
收藏
得分:0 
回复 3楼 sdta
谢谢斑竹直言相告。的确,本人年逾五十,学生时代基本在文革时期度过,学习VFP其实根本不具备条件,由于不懂基础语言,又不懂英语,可又倔强地总想学一些“时尚”(其实在本人看来是日常工作所需要的)知识。学习过程中难免会消化不良。以编写代码为例,无所谓什么习惯,实质上就是对相关知识领会不透,导致不仅是层次不清,更有许多冗余代码的问题。鼓足勇气上此论坛提问,也就不怕露丑,只要能向各位行家学习就好。

斑竹关于将text4改为编辑框的提示,非常赞同,这就去改。只是题中问题还望各位老师不吝赐教
2013-01-22 13:09
sdta
Rank: 20Rank: 20Rank: 20Rank: 20Rank: 20
来 自:江苏省连云港市
等 级:版主
威 望:335
帖 子:9821
专家分:27099
注 册:2012-2-5
收藏
得分:0 
回复 5楼 陶然愚者
上传表单

坚守VFP最后的阵地
2013-01-22 13:16
陶然愚者
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
sdta
Rank: 20Rank: 20Rank: 20Rank: 20Rank: 20
来 自:江苏省连云港市
等 级:版主
威 望:335
帖 子:9821
专家分:27099
注 册:2012-2-5
收藏
得分:0 
与表单有关的全部文件

坚守VFP最后的阵地
2013-01-22 13:40
sdta
Rank: 20Rank: 20Rank: 20Rank: 20Rank: 20
来 自:江苏省连云港市
等 级:版主
威 望:335
帖 子:9821
专家分:27099
注 册:2012-2-5
收藏
得分:0 
在表单的load事件中添加了如下代码:
DIMENSION zdtj(6),gxysf(6),cxz(6),ljysf(6)
PUBLIC cxtj,i
cxtj=''
i=1
定义为全局变量,数组中元素太少,设置与数据表中字段数FCOUNT()相同

坚守VFP最后的阵地
2013-01-22 13:44
快速回复:请教组合条件查询表单设计问题
数据加载中...
 
   



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

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