欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

asp 通用修改和增加函数代码

程序员文章站 2022-09-01 23:34:10
接下来我利用一点空余时间发一个函数里面包含和添加和删除功能。实验的架构可以使用iis.5web服务器access数据库。这个我其实不用说的很详细了,因为大家都应该知道的。我...
接下来我利用一点空余时间发一个函数里面包含和添加和删除功能。实验的架构可以使用iis.5web服务器access数据库。这个我其实不用说的很详细了,因为大家都应该知道的。我就直接把函数贴出来。大家只要稍微修改即可使用。
复制代码 代码如下:

<%
sub adminedit()
dim action,rscheckadd,rs,sql
action=request.querystring("action")
if action="saveedit" then '保存编辑管理员信息
set rs = server.createobject("adodb.recordset")
if result="add" then '创建网站管理员
set rscheckadd = conn.execute("select adminname from ameav_admin where adminname='" & trim(request.form("adminname")) & "'")
if not (rscheckadd.bof and rscheckadd.eof) then '判断此管理员名是否存在
response.write "<script language=javascript><!--
alert('" & trim(request.form("adminname")) & "管理员已经存在,请换一个登录名再试试!');history.back(-1);
// --></script>"
response.end
end if
     sql="select * from ameav_admin"
rs.open sql,conn,1,3
rs.addnew
if len(trim(request.form("adminname")))<3 or len(trim(request.form("password")))>10 then
response.write "<script language=javascript><!--
alert('管理员登录名必填,且字符数为3-10位!');history.back(-1);
// --></script>"
response.end
end if    
if len(trim(request.form("password")))<6 or len(trim(request.form("password")))>16 then
response.write "<script language=javascript><!--
alert('管理员密码必填,且字符数为6-16位!');history.back(-1);
// --></script>"
response.end
end if
     if request.form("password")<>request.form("vpassword") then
response.write "<script language=javascript><!--
alert('两次输入的密码不一样!');history.back(-1);
// --></script>"
response.end
     end if
rs("adminname")=trim(request.form("adminname"))
     if request.form("working")=1 then
rs("working")=request.form("working")
     else
rs("working")=0
     end if
     rs("password")=md5(request.form("password"))
     rs("username")=trim(request.form("username"))
     rs("adminpurview")=request.form("purview111") & request.form("purview112") & request.form("purview113") &_
     request.form("purview114") & request.form("purview115") & request.form("purview116") &_
     request.form("purview117") & request.form("purview118") & request.form("purview119") &_
     request.form("purview120") & request.form("purview121") & request.form("purview122") &_
     request.form("purview123") & request.form("purview124") & request.form("purview125") &_
     request.form("purview126") & request.form("purview127") & request.form("purview128") &_
     request.form("purview129") & request.form("purview130") & request.form("purview131") &_
     request.form("purview132") & request.form("purview133") & request.form("purview134") &_
     request.form("purview135") & request.form("purview136") & request.form("purview137") &_
     request.form("purview138") & request.form("purview139") & request.form("purview140") &_
     request.form("purview141") & request.form("purview142") & request.form("purview143") &_
     request.form("purview144") & request.form("purview145") & request.form("purview146") &_
     request.form("purview147") & request.form("purview148") & request.form("purview149") &_
     request.form("purview150") & request.form("purview151") & request.form("purview152") &_
     request.form("purview153")
     rs("explain")=trim(request.form("explain"))
     rs("addtime")=now()
    end if
    if result="modify" then '修改网站管理员
sql="select * from ameav_admin where id="&id
rs.open sql,conn,1,3
rs("adminname")=trim(request.form("adminname"))
     if request.form("working")=1 then
rs("working")=request.form("working")
     else
rs("working")=0
     end if
if trim(request.form("password"))<>"" then
     if len(trim(request.form("password")))<6 or len(trim(request.form("password")))>20 then
response.write "<script language=javascript><!--
alert('管理员密码必填,且字符数为6-20位!');history.back(-1);
// --></script>"
response.end
end if
     if request.form("password")<>request.form("vpassword") then
response.write "<script language=javascript><!--
alert('两次输入的密码不一样!');history.back(-1);
// --></script>"
response.end
     end if
     rs("password")=md5(request.form("password"))
     end if
     rs("username")=trim(request.form("username"))
     rs("adminpurview")=request.form("purview111") & request.form("purview112") & request.form("purview113") &_
     request.form("purview114") & request.form("purview115") & request.form("purview116") &_
     request.form("purview117") & request.form("purview118") & request.form("purview119") &_
     request.form("purview120") & request.form("purview121") & request.form("purview122") &_
     request.form("purview123") & request.form("purview124") & request.form("purview125") &_
     request.form("purview126") & request.form("purview127") & request.form("purview128") &_
     request.form("purview129") & request.form("purview130") & request.form("purview131") &_
     request.form("purview132") & request.form("purview133") & request.form("purview134") &_
     request.form("purview135") & request.form("purview136") & request.form("purview137") &_
     request.form("purview138") & request.form("purview139") & request.form("purview140") &_
     request.form("purview141") & request.form("purview142") & request.form("purview143") &_
     request.form("purview144") & request.form("purview145") & request.form("purview146") &_
     request.form("purview147") & request.form("purview148") & request.form("purview149") &_
     request.form("purview150") & request.form("purview151") & request.form("purview152") &_
     request.form("purview153")
     rs("explain")=trim(request.form("explain"))
    end if
    rs.update
    rs.close
set rs=nothing
response.write "<script language=javascript><!--
alert('成功编辑网站管理员!');changeadminflag('网站管理员');location.replace('adminlist.asp');
// --></script>"
else '提取管理员信息
    if result="modify" then
set rs = server.createobject("adodb.recordset")
sql="select * from ameav_admin where id="& id
rs.open sql,conn,1,1
     adminname=rs("adminname")
     working=rs("working")
     username=rs("username")
     purview=rs("adminpurview")
     explain=rs("explain")
     rs.close
set rs=nothing
    end if
end if
end sub

%>