<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<!--#include file="Include/connect.asp"-->
<!--#include file="../Include/md5code.asp"-->
<!--#include file="Inc/char.asp"-->
<!--#include file="top.asp"-->
<link href="CSS/right.css" rel="stylesheet" type="text/css">
<%
select case request("action")
case "saveedit"
call saveedit()
case else
call normal()
end select
sub normal()
dim userid,rs,Username,Password
userid=trim(request.QueryString("userid"))
if userid<>"" then
set rs=server.CreateObject("adodb.recordset")
sql="select * from Show5_AdminUser where UserID="&userid&""
rs.open sql,cn,1,1
if rs.bof and rs.eof then
response.Write("<script>alert('用户不存在或已被删除！');history.back()</script>")
response.End()
end if
Username=rs("Username")
Password=rs("Password")
end if
response.Write("<table width='770' border='0' align='center' cellpadding='0' cellspacing='1' class='tablecolor'>")
response.Write("<tr class='banner'><td height='25' align='center' >管理管理员</td></tr></table>")
response.Write("<table width='770' border='0' align='center' cellpadding='3' cellspacing='1' class='tablecolor'>")
response.Write("<form name='form1' method='post' action='?action=saveedit'>")
response.Write("<tr class='tablebody'><td width='200' height='25' align='center'>管理员名称</td><td ><input name='adminname' type='text' id='adminname' value="&chr(34)&""&Username&""&chr(34)&" maxlength='20'")
if Username<>"" then response.Write("readonly")
response.Write("></td></tr>")
response.Write("<tr class='tablebody'><td height='25' align='center' >管理员密码</td><td><input name='adminpwd' type='text' value="&chr(34)&""&Password&""&chr(34)&" maxlength='20'>&nbsp;至少6位</td></tr>")
response.Write("<tr class='tablebody'><td height='25' align='center' >&nbsp;</td><td><input type='hidden' name='id' value='"&userid&"'><input type='submit' name='Submit' value='提 交'>&nbsp;<input type='reset' name='Submit2' value='重 置'></td></tr></form></table>")
end sub
sub saveedit()
dim adminname,adminpwd,userid
id=checkStr(request.Form("userid"))
adminname=checkStr(Request.Form("adminname"))
adminpwd=checkStr(Request.Form("adminpwd"))
if adminname="" then
response.Write("<script>alert('用户名不能为空！');history.back()</script>")
response.End()
end if
if len(adminpwd)<6 then
response.Write("<script>alert('密码小于6位！');history.back()</script>")
response.End()
end if
dim rs
set rs=server.CreateObject("adodb.recordset")
if id="" then
rs.open "select * from Show5_AdminUser where Username='"&adminname&"'",cn,1,3
if not rs.bof and not rs.eof then
response.Write("<script>alert('用户名已存在！');history.back()</script>")
response.End()
end if
rs.addnew
rs("Username")=adminname
rs("Password")=md5(adminpwd)
rs.update 
rs.close
set rs=nothing
response.Write("<script>alert('添加成功！');location='adminlist.asp'</script>")
response.End()
else
rs.open "select * from Show5_AdminUser where userid="&userid&"",cn,1,3
rs("Username")=adminname
if md5(adminpwd)<>rs("Password") then
rs("Password")=md5(adminpwd)
end if
rs.update
rs.close
set rs=nothing
response.Write("<script>alert('修改成功！');location='adminlist.asp'</script>")
response.End()
end if
end sub
%>
<!--#include file="end.asp"-->


