VFP中口令表单的设置

作者在 2014-03-23 15:20:12 发布以下内容
    口令子表单的属性和事件应作如下设置:

    DataSession设为2(私有数据工作区)。

       WindowType设为1(模式)。

       BarderStyle设为2(固定对话框)。

       Unload事件:

return this.cuser

    这一行代码的意思是:关闭子表单时返回自定义属性“cuser”“cuser”用于存放欲返回的用户姓名。

    用于输入密码的文本框的Keypress事件代码:

if nkeycode=13

this form.command1.click

endif

    解释:在输入密码时,若敲回车键,则自动激发“command 1”(它通常是确定按钮)的click事件。

    口令子表单中确定按钮的“click”事件代码:

locate for upper(login.userid)=upper(allt(thisform.text1.value))

if found() and allt(password)==allt(thisform.text2.value)

thisform.cuser=alltrim(login.userid)

thisform.release

else

waitwondow "用户口令不正确,请重新输入!" time out 1.5

thisform.text1.value=""

thisform.text2.value=""

thisform.text1.setfocus

endif

    解释:

    口令子表单中取消按钮的事件代码:

thisform.cuser=""

thisform.release

    口令子表单的数据环境设置为:login.dbf

    下面这一段是经过实践优化了的口令表单确定按钮的click代码:

locate for upper(职员.姓名)=upper(allt(thisform.combo1.value))

do case

case found() and allt(职员.口令)==allt(thisform.txt口令.value)

&&thisform.cuser=alltrim(职员.姓名)

messagebox("口令正确!")

thisform.txt口令.value=""

&&thisform.release

otherwise

messagebox( "用户口令不正确,请重新输入!")

thisform.txt口令.value=""

thisform.txt口令.setfocus

endcase

vfp | 阅读 4154 次
文章评论,共1条
冬冬123
2014-03-31 15:02
1
有意思
游客请输入验证码
浏览107385次
最新评论