分享

VFP程序代码(二)<br>

 踏雪_寻梅 2010-03-23

VFP程序代码(二)

(2007-09-09 21:15:54)
标签:

vfp数据库

分类:VFP编程
二、主程序设计
1、主程序(用顶层表单,不能调用计算器、报表设计器)
public drive
drive=alltrim(sys(16))       设置通用路径
dr=substr(drive,1,2)
with _screen
  .visible=.f.
  .windowstate=2
endwith 
close all
application.visible=.f.
deactivate window"project manager"
set default to&dr\njjl,&dr\njjl\scx,&dr\njjl\dbf,&dr\njjl\\vcx,&dr\njjl\bmp,
&dr\njjl\frm,&dr\njjl\prg
do &dr\njjl\prg\setting
do form &dr\njjl\scx\rh_dl
on  shutdown quit
read events
do &dr\njjl\prg\reset 
 
1)、登录表单(顶层表单)密码文本框LostFocus事件代码
public user
if alltrim(thisform.text1.value)==alltrim(b_rh.口令)
user=b_rh.用户级别
thisform.release
do form e:\njjl\scx\njjl_main
else
ctitle="农机监理信息管理系统"
ctext="密码错误,重新输入吗?"
yn=messagebox(ctext,4+32,ctitle)
do case
case yn=6
thisform.text1.value=""
thisform.text1.setfocus
case yn=7
ctitle="农机监理信息管理系统"
ctext="不要入侵我的系统!"
messagebox(ctext,48,ctitle)
thisform.release
quit
endcase
endif
 
2、*主程序(不用顶层表单,建立一窗口,可调用计算器、报表设计器)
close all
public user
user=2
deactivate window"project manager"
set default to d:\fcgl,d:\fcgl\scx,d:\fcgl\dbf,d:\fcgl\vcx,d:\fcgl\bmp,d:\fcgl\frm,d:\fcgl\prg
do d:\fcgl\prg\setting
do form d:\fcgl\scx\dl_fc
with _screen
  .icon='d:\fcgl\bmp\classlib.ico'
  .visible=.f.
  .caption='房地产信息管理系统'
  .windowstate=2
  endwith
define window mywin from 0,0 to 150,150 ;
fill file d:\fcgl\bmp\小屋.jpg
activate window mywin bottom
do d:\fcgl\mpr\cd_fc.mpr
on  shutdown quit
read events
do d:\fcgl\prg\reset
 
(1)、登录表单(顶层表单)密码文本框LostFocus事件代码      
if thisform.text1.value=b_rh.口令
user=b_rh.用户级别
thisform.release
*application.visible=.t.
_screen.windowstate=2 
_screen.visible=.t.
*_screen.enabled=.t.
else
ctitle="房地产信息管理系统"
ctext="密码错误,重新输入吗?"
yn=messagebox(ctext,4+32,ctitle)
do case
case yn=6
thisform.text1.value=""
thisform.text1.setfocus
case yn=7
ctitle="房地产信息管理系统"
ctext="不要入侵我的系统!"
messagebox(ctext,32,ctitle)
thisform.release
quit
endcase
endif
 
三、数据录入:(有主索引字段,防止重复输入)
1、表单init事件代码
use d:\txl\dbf\b_txl
go bottom
THISFORM.TEXT1.VALUE=姓名
THISFORM.TEXT2.VALUE=手机
thisform.text1.enabled=.f.
thisform.text2.enabled=.f.
thisform.command1.caption='添加'
 
2、text1(主索引字段) lostfocus事件代码(姓名为主索引)
sele b_txl
locate for alltrim(姓名)==alltrim(thisform.text1.value) *用双等号
if found()
messagebox('此记录已存在!',48,'信息提示')
thisform.text1.value=姓名
thisform.text2.value=手机
thisform.text1.enabled=.f.
thisform.text2.enabled=.f.
thisform.command1.caption='添加'
endif
 
3、‘确定’按钮单击事件代码
sele b_txl
if this.caption='确定'
appe blank
replace next 1 姓名with THISFORM.TEXT1.VALUE
replace next 1 手机with THISFORM.TEXT2.VALUE
this.caption='添加'
*THISFORM.TEXT1.VALUE=''
*THISFORM.TEXT2.VALUE=''
thisform.text1.enabled=.f.
thisform.text2.enabled=.f.
THISFORM.TEXT1.setfocus
else
thisform.text1.enabled=.t.
thisform.text2.enabled=.t.
THISFORM.TEXT1.VALUE=''
THISFORM.TEXT2.VALUE=''
THISFORM.TEXT1.setfocus
this.caption='确定'
endif

    本站是提供个人知识管理的网络存储空间,所有内容均由用户发布,不代表本站观点。请注意甄别内容中的联系方式、诱导购买等信息,谨防诈骗。如发现有害或侵权内容,请点击一键举报。
    转藏 分享 献花(0

    0条评论

    发表

    请遵守用户 评论公约

    类似文章 更多