打开APP
userphoto
未登录

开通VIP,畅享免费电子书等14项超值服

开通VIP
看实例学VFP:对时间段进行查询的例子

看实例学VFP:对时间段进行查询的例子

时间:2009-02-10 本站 老马
-

这个例子应用到了select语句中的between...and子句的知识,关于select语句请参考:select SQL 命令sql语言教程

本例运行时如下图:

本例用到了“数据1”数据库中的“人员信息表”,关于该数据库的情况已经在看实例学VFP:示例数据库一文中给出,这里不再详述。
 

制作步骤如下:

一、新建表单,将其caption属性值设为“对时间段进行查询的例子”,width属性值设为290,height属性值设为195,AutoCenter属性值设为.t.,并将其保存为“对时间段进行查询的例子.scx”。

二、向表单上添加两个Label控件,将它们的caption属性值分别设置为“出生日期在”和“与”,ForeColor属性值都设置为“0,0,255”,并将这两个Label控件排成一行。

三、向表单上添加两个文本框控件,调整它们的位置,把两个Label控件间隔开,并把它们的Value属性值都设为“{}”(关于文本框控件的属性请参考:文本框(textbox)控件)。

四、在文本框和Label控件的下方添加一个grid控件,并将其width属性值设为290,height属性值设为110。

五、在grid控件下方再添加两个命令按钮command1和command2,并将它们的caption属性值分别设置为“查询”和“退出”。

六、对表单上各控件的位置进行适当调整,调整后的表单设计器如下图:

七、添加事件代码:

(一)表单的unload事件:close data

(二)表单的init事件:

use 人员信息表with thisform.grid1    .recordsource="人员信息表"    .deletemark=.f.    .visible=.t.    .readonly=.t.    .ColumnCount=8    .Column1.Header1.Caption="编号"    .Column1.Header1.BackColor=RGB(255,255,190)    .Column2.Header1.BackColor=RGB(255,255,190)    .Column2.Header1.Caption="姓名"    .Column3.Header1.BackColor=RGB(255,255,190)    .Column3.Header1.Caption="部门"    .Column4.Header1.Caption="性别"    .Column4.Header1.BackColor=RGB(255,255,190)    .Column5.Header1.Caption="学历"    .Column5.Header1.BackColor=RGB(255,255,190)    .Column6.Header1.Caption="基本工资"    .Column6.Header1.BackColor=RGB(255,255,190)    .Column7.Header1.Caption="家庭住址"    .Column7.Header1.BackColor=RGB(255,255,190)    .Column8.Header1.Caption="出生日期"    .Column8.Header1.BackColor=RGB(255,255,190)    .Column1.width=40    .Column2.width=50    .Column3.width=50    .Column4.width=30    .Column5.width=60    .Column6.width=60    .Column7.width=60    .Column8.width=60endwiththisform.grid1.Setall("DynamicBackColor","RGB(224,225,255)","Column")

(三)“查询”按钮(command1)的click事件:

if thisform.text1.value={}	messagebox("请填入起始的出生日期",16,"系统提示")	thisform.text1.setfocuselse	if thisform.text2.value={}	  messagebox("请填入终止的出生日期",16,"系统提示")	  thisform.text2.setfocus	else	  Select * from 人员信息表 where 出生日期;	  between thisform.text1.value and thisform.text2.value;	  into cursor 临时人员信息表      with thisform.grid1        .width=450        .height=130        .recordsource="临时人员信息表"        .deletemark=.f.        .visible=.t.        .ColumnCount=8        .Column1.Header1.Caption="编号"        .Column1.Header1.BackColor=RGB(255,255,190)        .Column2.Header1.BackColor=RGB(255,255,190)        .Column2.Header1.Caption="姓名"        .Column3.Header1.BackColor=RGB(255,255,190)        .Column3.Header1.Caption="部门"        .Column4.Header1.Caption="性别"        .Column4.Header1.BackColor=RGB(255,255,190)        .Column5.Header1.Caption="学历"        .Column5.Header1.BackColor=RGB(255,255,190)        .Column6.Header1.Caption="基本工资"        .Column6.Header1.BackColor=RGB(255,255,190)        .Column7.Header1.Caption="家庭住址"        .Column7.Header1.BackColor=RGB(255,255,190)        .Column8.Header1.Caption="出生日期"        .Column8.Header1.BackColor=RGB(255,255,190)        .Column1.width=40        .Column2.width=50        .Column3.width=50        .Column4.width=30        .Column5.width=60        .Column6.width=60        .Column7.width=60        .Column8.width=60    endwith    thisform.grid1.Setall("DynamicBackColor","RGB(224,225,255)","Column")   endifendif

(四)“退出”按钮(command2)的click事件:thisform.release

八、运行“对时间段进行查询的例子.scx”。

参考资料:

vfp基础教程:http://bianceng.cn/vfpjc/index0.htm

vfp初级教程:http://bianceng.cn/cc/index.htm

vfp中级教程:http://bianceng.cn/mcc/mcc.htm

vfp高级教程:http://bianceng.cn/hcc/hcc.htm

VFP网络开发:http://bianceng.cn/VFPwz/vfpwlkf.htm

vfp调用api函数:http://bianceng.cn/VFPwz/vfpapi.htm

VFP报表打印:http://bianceng.cn/VFPwz/vfpreport.htm

VFP常用技术:http://bianceng.cn/VFPwz/vfpcyjs.htm

VFP经验汇总:http://bianceng.cn/VFPwz/vfpjyhz.htm

VFP控件使用:http://bianceng.cn/VFPwz/vfpkjsy.htm

VFP数据处理:http://bianceng.cn/VFPwz/vfpsjcl.htm

本例代码在Win2003+VFP6.0环境下调试通过。

查看全套“菜鸟也学VFP”教程

本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请点击举报
打开APP,阅读全文并永久保存 查看更多类似文章
猜你喜欢
类似文章
【热】打开小程序,算一算2024你的财运
vfp6.0表格控件(grid)技巧篇
第三章:面向对象程序设计~VFP语法、实例、函数和类库参考手册~
在VFP中制作"日期选择器"
VFP表格的刷新问题
编程入门网
Adding Checkbox to Grid header #VFP
更多类似文章 >>
生活服务
热点新闻
分享 收藏 导长图 关注 下载文章
绑定账号成功
后续可登录账号畅享VIP特权!
如果VIP功能使用有故障,
可点击这里联系客服!

联系客服