快撸三合一BS用户管理模块,撸完就去泡咖啡,谁能享受人生?

 子曰:“温故而知新,可以为师矣。

大家好,我是秦时明月。上次我记录了利用“猫框”实现BS系统登录界面,今天我们实验一下BS应用系统之用户管理模块,前提是先抛开CSS样式在网页中应用和软件操作权限控制,只聊实现这一功能的操作方式。

先看一下我们要实现的界面效果:

01—第一次打开页面时的样子:

图片

02—当你输入昵称“ALL”点“查询”之后的样子

图片

03—当你输入查询昵称“jiafeimao”点“查询”之后的样子:

图片

04—当你输入昵称和密码之后点击“添加”之后的界面

图片

图片

好了,通过以上的界面,我们知道了我们今天要试验的内容。接下来,我们来准备试验的文件。

1 当然是建表了wuser.dbf

图片

2.BS网页文件clryxx.htm

<html xmlns="http://www.w3.org/1999/xhtml"><head><title>用户管理模块</title><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /></head><body bgcolor="#ffffff">  <form id="form1" name="form1" method="post" action="clryxx.fsp">    <label for="textfield">请输入昵称:</label>    <input type="text" name="lkname" id="lkname" value="<%u(cname)%>" title="输入 ALL  显示所有用户名"/>    <input type="submit" name="button" id="button" value="查询" />    <label for="textfield">&nbsp;&nbsp;[输入ALL显示所有用户]</label>  </form>  <% if not empty(cname)%>    <hr />  <table>  <tr>  <td align="center" bgcolor="#66CCFF"><strong>用户ID</strong></td>  <td align="center" bgcolor="#66CCFF"><strong>昵称</strong></td> <td align="center" bgcolor="#66CCFF"><strong>密码</strong></td>  <td bgcolor="#66CCFF"><strong>操作</strong></td>  </tr>  <tr>  <% scan %>  <form name="fm<%u(ID)%>" method=post action="clryxx.fsp">  <td><input name="uid" type=text value="<%u(uid)%>" readonly="readonly"/></td>  <td><input type=text name="uname" value="<%u(uname)%>"/></td>  <td><input type=password name="upass" value="<%u(upwd)%>"/></td>  <td><input type=hidden name="id" value="<%u(ID)%>" id="id" />  <button type="submit" name="act" id="act" value="1"  onclick="return confirm('确定要修改吗?')">修改</button>  <button type="submit" name="act" id="act" value="2"  onclick="return confirm('确定要删除吗?')">删除</button></td>     </form></tr>  <% endscan %>  </table> <%endif %>
  <hr />    <table>  <tr>  <td align="center" bgcolor="#66CCFF"><strong>用户ID</strong></td>  <td align="center" bgcolor="#66CCFF"><strong>昵称</strong></td> <td align="center" bgcolor="#66CCFF"><strong>密码</strong></td>  <td bgcolor="#66CCFF"><strong>操作</strong></td>  </tr>        <tr>  <form name="fmadd" method=post action="clryxx.fsp">  <td><input name="uid" type=text value="系统自动分配" readonly="readonly"/></td>  <td><input type=text name="uname" value="登录名"/></td>  <td><input type=password name="upass" value=""/></td>  <td><input type=hidden name="id" value="<%u(ID)%>" id="id" />  <button type="submit" name="act" id="act" value="3"  onclick="return confirm('确定要添加吗?')">添加</button></td>     </form></tr>  </table></body></html>

看着很多,实际上要关注的是以下的代码,这是输入查询条件的代码

<form id="form1" name="form1" method="post" action="clryxx.fsp">    <label for="textfield">请输入昵称:</label>    <input type="text" name="lkname" id="lkname" value="<%u(cname)%>" title="输入 ALL  显示所有用户名"/>    <input type="submit" name="button" id="button" value="查询" />    <label for="textfield">&nbsp;&nbsp;[输入ALL显示所有用户]</label>  </form>

这是中间列表部分的代码(列表,修改)

 <% if not empty(cname)%>    <hr />  <table>  <tr>  <td align="center" bgcolor="#66CCFF"><strong>用户ID</strong></td>  <td align="center" bgcolor="#66CCFF"><strong>昵称</strong></td> <td align="center" bgcolor="#66CCFF"><strong>密码</strong></td>  <td bgcolor="#66CCFF"><strong>操作</strong></td>  </tr>  <tr>  <% scan %>  <form name="fm<%u(ID)%>" method=post action="clryxx.fsp">  <td><input name="uid" type=text value="<%u(uid)%>" readonly="readonly"/></td>  <td><input type=text name="uname" value="<%u(uname)%>"/></td>  <td><input type=password name="upass" value="<%u(upwd)%>"/></td>  <td><input type=hidden name="id" value="<%u(ID)%>" id="id" />  <button type="submit" name="act" id="act" value="1"  onclick="return confirm('确定要修改吗?')">修改</button>  <button type="submit" name="act" id="act" value="2"  onclick="return confirm('确定要删除吗?')">删除</button></td>     </form></tr>  <% endscan %>  </table> <%endif %>

看下方的新增功能模块

<table>  <tr>  <td align="center" bgcolor="#66CCFF"><strong>用户ID</strong></td>  <td align="center" bgcolor="#66CCFF"><strong>昵称</strong></td> <td align="center" bgcolor="#66CCFF"><strong>密码</strong></td>  <td bgcolor="#66CCFF"><strong>操作</strong></td>  </tr>        <tr>  <form name="fmadd" method=post action="clryxx.fsp">  <td><input name="uid" type=text value="系统自动分配" readonly="readonly"/></td>  <td><input type=text name="uname" value="登录名"/></td>  <td><input type=password name="upass" value=""/></td>  <td><input type=hidden name="id" value="<%u(ID)%>" id="id" />  <button type="submit" name="act" id="act" value="3"  onclick="return confirm('确定要添加吗?')">添加</button></td>     </form></tr>  </table>
利用了三个<form>标签,提交给处理文件action=”clryxx.fsp”,除了“查询”按钮,其他按钮都有属性name=”act”,那么我们就来看看clryxx.fsp的代码。
define class clryxx as session       procedure ondefault            private   cname,cid,cuid,cuname,ccpwd,cact        && 以下是获取网页传递过来的参数 无论是get or post           && 至于谁被传递过来是由触发提交表单的按钮决定的        cname=allt(httpqueryparams("lkname"))        cact=allt(httpqueryparams("act"))        cid=allt(httpqueryparams("id"))        cuid=allt(httpqueryparams("uid"))        cuname=allt(httpqueryparams("uname"))        ccpwd=allt(httpqueryparams("upass"))        && 以下根据  name="act" 的 值决定进行什么操作   3 ad 2 del 1 edit  其他是查询        do case             case cact="3" && 添加动作                    return this.actadd(cuname,ccpwd)               case cact="2" &&  删除动作                    return this.actdel(cid)               case cact="1"  && 添加动作             return this.actedit( cid,cuid,cuname,ccpwd)         other && 查询动作                   return this.showlookinfo(cname)              endcase        endpro          proce  showlookinfo            lpara s            if not used('wuser') then            sele 0           use wuser        endif         sele wuser        if UPPER(s)<>"ALL" then           set filter to  "&s"$allt(uname)             endif         set dele on         go top                  _currentcode="UTF-8"        chtml=getwwwrootpath("")+"clryxx.htm"        chtml= FWS_MergeFile(chtml)        use in select('wuser')        set dele off         return chtml                endproc             proc  actadd     lpara cuname,ccpwd     if not used('wuser') then         sele 0        use wuser     endif              sele wuser          &&      这里是生成新序号     select max(uid) uid  from wuser into cursor TJ     sele tj      private lsid     lsid=allt(subs(uid,2))     lsid="A"+padl(int(val(lsid))+1,4,"0")     use in select('tj')          sele wuser    appe blank     repl uid with lsid,uname with cuname,upwd with ccpwd     use in select('wuser')     return this.showlookinfo(cuname)         endpro            proc actdel          lpara cid          private cmdstr          if not used('wuser') then              sele 0             use wuser          endif                   sele wuser          set dele on                  cmdstr=" dele for id="+cid          &cmdstr          use in select('wuser')          set dele off           return this.showlookinfo("")      endpro            proc actedit          lpara    cid,cuid,cuname,ccpwd          if not used('wuser') then              sele 0             use wuser         endif                  sele wuser         set dele on                 cmdstr=" loca for id="+cid         &cmdstr         if found()             repl uname with cuname             repl upwd with ccpwd         else            cuname=""         endif          use in select('wuser')         set dele off            return this.showlookinfo(cuname)             endprocenddefi

猫框项目中启动调试服务器,然后在地址栏里输入http://IP:801/clryxx.fsp。而不是输入 clryxx.htm,不妨自己在地址栏试验一下,看有什么区别,为什么?欢迎在评论区留言。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

加菲猫的VFP

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值