<!--#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>
<link href="style/global.css" rel="stylesheet" type="text/css">
<script>
function check(obj){
	if(obj.username.value==""){
		alert("用户名不能为空!");
		obj.username.focus();
		return false;		
	}
	if(obj.PassWord.value==""){
		alert("密码不能为空!");
		obj.PassWord.focus();
		return false;		
	}
	return true;
}
</script>
</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
act=request.QueryString("act")

if(act="add") then	
	adminname=trim(request.Form("username"))
	PassWord=Md5(Replace(Trim(Request.Form("PassWord")),"'","''"),16)
	if(request.Form("RoleId")<>"") then
		RoleId=Cint(request.Form("RoleId"))
	else
		response.Write("<script>alert('请选择角色!');history.back();</script>")
		response.end()
	end if
	'添加到库
	set rs=server.createobject("adodb.recordset")
	sql="select top 1 * from admin where UserName='"&adminname&"' order by id desc "
	rs.open sql,conn,3,3
	if not rs.eof then
		response.Write("<script>alert(""该用户已存在!"");history.back();</script>")
		response.End()
	else
		rs.addnew
		rs("UserName")=adminname
		rs("PassWord")=PassWord
		rs("LoginNum")=0
		rs("Lock")=0
		rs("RoleId")=RoleId
		rs("ModiTime")=now	
		rs.update		
		response.Write("<p align=""center"">添加管理员成功~!</p>")
		response.Write("<p align=""center""><br><a href=admin_add.asp>返回</a></p>")
	end if
	rs.close
	set rs=nothing
else
%>
<FORM method="POST" name="form1" action="admin_add.asp?act=add" style="margin:0 0 0 0;" onSubmit="return check(this)">
  <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" size="30"></TD>
</TR>
<TR bgcolor="#F5F5F5">
  <TD><div align="center">密码：</div></TD>
  <TD><div align="left">
    <input name="PassWord" type="text" id="PassWord" size="50">
  </div></TD>
</TR>
<TR bgcolor="#F5F5F5">
  <TD><div align="center">角色：</div></TD>
  <TD><select name="RoleId" id="RoleId">
    <%=getRoleOption(0)%>
  </select></TD>
</TR>
<TR bgcolor="#F5F5F5">
	<TD align=right>&nbsp;	  </TD>
    <TD align=right><div align="left"> 
        <input type=submit name=b1 value="提 交">&nbsp;&nbsp;
        <input type=reset name=b2 value="重 填">       
    </div></TD>
</TR>
</TABLE>
</FORM>
<%
end if
%>
</BODY>
</HTML>
<%
call connclose()
%>