<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<%
Dim NCheck:NCheck=false

%>
<!--#include file="cgi/Config.asp"-->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>系统初始化安装</title>
<style type="text/css">
<!--
body,td,th {
	font-size: 12px;
}
body {
	margin-left: 0px;
	margin-top: 0px;
}
.steupmain{ width:980px; margin:0px auto; clear:both;}
.ziborder{
	border: 1px solid #9900CC;
}
-->
</style>

</head>

<body>
<%
Dim act:act=request("act")
if act="save" then 
	Dim u_name,u_pass
	u_name=trim(request("u_name"))
	u_pass=trim(request("u_pass"))
	if u_name="" or u_pass="" then  mobj.JsCheck "账户、密码不能为空",1
	if not mobj.testreg(u_name,"^\w{1,20}$") then mobj.JsCheck "账户只能是数字或者字母",1
	mobj.crs rs
	rs.open "select * from b2c_admin where a_type=1",dstr,1,3
	if rs.eof and rs.bof then 
		rs.addnew()
		rs("a_username")=u_name
		rs("a_userpass")=md5(u_pass)
		rs("a_active")=1
		rs("a_type")=1
		rs.update
		mobj.drs rs
		mobj.cexe "update b2c_sys set s_guid='"&mobj.GenerateGuid()&"' where s_id=1"
		mobj.jsgoto "系统安装成功",loginPage		
	else
		mobj.drs rs
		 mobj.JsCheck "系统中已经有管理员账号",1
	end if	
end if
Dim isSetup:isSetup=false
mobj.crs rs
rs.open "select * from b2c_admin where a_type=1",dstr,1,1
if not(rs.eof and rs.bof) then
	isSetup=true
end if 
mobj.drs rs
if isSetup then 
	response.Redirect(loginPage)
	response.End()
end if
%>
<div class="steupmain ziborder" style="margin-top:80px;">
  <table width="100%" border="0" cellspacing="0" cellpadding="0">
    <tr>
      <td height="30" align="center" bgcolor="#9900CC"><strong style="color:#FFF;">安装系统-设定管理员登陆账号密码</strong></td>
    </tr>
    <tr>
      <td align="center"><table width="450" border="0" cellspacing="5" cellpadding="0"><form id="setupform" method="post" action="index.asp?act=save">
        <tr>
          <td width="106" height="50" align="right">管理员账号：</td>
          <td width="329" align="left"><label>
            <input type="text" name="u_name" id="u_name" />
            
          </label><font style="color:#333;">只可使用字母或数字</font></td>
        </tr>
        <tr>
          <td height="50" align="right">管理员密码：</td>
          <td align="left"><input type="text" name="u_pass" id="u_pass" /></td>
        </tr>
        <tr>
          <td height="50" align="right">&nbsp;</td>
          <td align="left"><label>
            <input name="按钮" type="button" onclick="checkSetup();"  value="保存管理员信息" />
          </label></td>
        </tr>
        <tr>
          <td height="50" colspan="2" align="center">ASP订单管理系统 V1.0</td>
          </tr>
        <tr>
          <td height="50" colspan="2" align="center"><a href="/demo.asp" target="_blank">下单页面演示效果</a></td>
          </tr></form>
      </table></td>
    </tr>
  </table>
</div>
</body>
</html>
<script language="javascript">
	function checkSetup(){		
		if (document.getElementById("u_name").value=="") {
			alert("账户名称不能为空!");
			document.getElementById("u_name").focus();
			return;
		}
		
		if (document.getElementById("u_pass").value=="") {
			alert("登陆密码不能为空!");
			document.getElementById("u_pass").focus();
			return;
		}
		
	
		document.getElementById("setupform").submit();
		}
</script>
