<!--#include file="../inc/config.asp"-->
<!--#include file="../inc/conn.asp"-->
<!-- #include file="inc/Session.asp" -->
<!--#include file="../Inc/Md5.asp" -->
<!-- #include file="inc/util.asp" -->
<!-- #include file="inc/checkrole.asp" -->
<HTML>
<HEAD>
<TITLE>修改管理员</TITLE>
<META http-equiv=Content-Type content="text/html; charset=gb2312">
<style>
body,td,input,textarea {font-size:9pt}
body {
	margin-left: 0px;
	margin-top: 0px;
	margin-right: 0px;
	margin-bottom: 0px;
}
.style1 {
	color: #FFFFFF;
	font-weight: bold;
}
</style>

</HEAD>
<BODY>
<%
'''''''''''''''''''''''''''''''''''''''''''''''
call checkPrevilege(Session("Name"),"p0000")
'''''''''''''''''''''''''''''''''''''''''''''''
%>
<table width="100%"  border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td><iframe src="right_top.htm" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" height="30" width="100%"></iframe></td>
  </tr>
</table>
<%
dim act,adminname,PassWord,RoleId,id,pass2
id=Cint(request("id"))
act=request.QueryString("act")

if(act="modinfo_ok") then	
	adminname=trim(request.Form("username"))	
	RoleId=Cint(request.Form("RoleId"))
	'添加到库
	set rs=server.createobject("adodb.recordset")
	rs.open "select * from admin where UserName='"&adminname&"' and id<>"&id,conn,3,1
	if not rs.eof then
		response.Write("<script>alert(""该管理员已存在!"");history.back();</script>")
		response.End()
	end if
	rs.close
	sql="select top 1 * from admin where id="&id&" order by id desc "
	rs.open sql,conn,3,3	
	rs("UserName")=adminname	
	rs("RoleId")=RoleId
	rs("ModiTime")=now	
	rs.update
	rs.close
	set rs=nothing
	response.Write("<script>alert('成功修改用户信息！');window.location.href='admin_manage.asp';</script>")
elseif(act="modinfo") then
	call modinfo()
elseif(act="modpass") then
	call modpass()
elseif(act="modpass_ok") then
	if not isempty(request("PassWord")) then 
		PassWord=replace(trim(request("PassWord")),"'","")
	else
		PassWord=""
	end if	
	if not isempty(request("pass2")) then 
		pass2=replace(trim(request("pass2")),"'","")
	else
		pass2=""
	end if	
	if(pass2<>PassWord) then
		Response.Write("<script>alert(""错误：\n两次输入密码不同！"&Copyright&""");history.back();</script>")
		Response.End
	end if
	if len(PassWord)<6 then
		Response.Write("<script>alert(""错误：\n密码不能少于6个字符"&Copyright&""");history.back();</script>")
		Response.End
	end if
	if(PassWord<>"" and len(PassWord)>=6) then
		PassWord=Md5(PassWord,16)
		conn.execute("update admin set PassWord='"&PassWord&"' where id="&id)
	end if
	response.Write("<p align=""center"">修改管理员成功~!</p>")
	response.Write("<p align=""center""><br><a href=admin_manage.asp>返回</a></p>")
end if
sub modinfo
	set rs=server.createobject("adodb.recordset")
	sql="select top 1 * from admin where id="&id&" order by id desc "
	rs.open sql,conn,3,1
	if not rs.eof then
%>
<FORM method="POST" name="form1" action="admin_mod.asp?act=modinfo_ok" style="margin:0 0 0 0;">
  <TABLE width="100%" border="0" align="center" cellpadding="2" cellspacing="1" bgcolor="#666666">
<TR bgcolor="#FFFFFF">
  <TD height="24" colspan="2" bgcolor="#FF9900"><div align="center" class="style1">◆ 修改管理员 ◆</div></TD>
  </TR>
<TR bgcolor="#F5F5F5">
  <TD width="14%"><div align="center">用户名：</div></TD>
  <TD width="86%"><input name="username" type="text" id="username" value="<%=rs("UserName")%>" size="30"></TD>
</TR>
<TR bgcolor="#F5F5F5">
  <TD><div align="center">角色：</div></TD>
  <TD><select name="RoleId" id="RoleId">
  <option value="0">总管理员</option>
  <%=getRoleOption(rs("RoleId"))%>  
  </select></TD>
</TR>
<TR bgcolor="#F5F5F5">
	<TD align=right>&nbsp;	  </TD>
    <TD align=right><div align="left"> 
		<input type="hidden" name="id" value="<%=id%>">
        <input type=submit name=b1 value="提 交">&nbsp;&nbsp;
        <input type=reset name=b2 value="重 填">       
    </div></TD>
</TR>
</TABLE>
</FORM>
<%
	end if
end sub
sub modpass
%>
<FORM method="POST" name="form1" action="admin_mod.asp?act=modpass_ok" style="margin:0 0 0 0;">
  <TABLE width="100%" border="0" align="center" cellpadding="2" cellspacing="1" bgcolor="#666666">
<TR bgcolor="#FFFFFF">
  <TD height="24" colspan="2" bgcolor="#FF9900"><div align="center" class="style1">◆ 修改密码 ◆</div></TD>
  </TR>
<TR bgcolor="#F5F5F5">
  <TD width="14%"><div align="center">密码：</div></TD>
  <TD width="86%"><div align="left">
    <input name="PassWord" type="text" id="PassWord" size="30"> 
    </div></TD>
</TR>
<TR bgcolor="#F5F5F5">
  <TD><div align="center">确认密码：</div></TD>
  <TD><div align="left"><input name="pass2" type="text" id="PassWord" size="30"></div></TD>
</TR>
<TR bgcolor="#F5F5F5">
	<TD align=right>&nbsp;	  </TD>
    <TD align=right><div align="left"> 
		<input type="hidden" name="id" value="<%=id%>">
        <input type=submit name=b1 value="提 交">&nbsp;&nbsp;
        <input type=reset name=b2 value="重 填">       
    </div></TD>
</TR>
</TABLE>
</FORM>
<%end sub%>
</BODY>
</HTML>
<%
call connclose()
%>