<!--#include file="check.asp"-->
<%
dim action
Call hrPower(7.1,0)
action=request.QueryString("action")
Nowpage=cint(request.QueryString("page"))
id=cint(request.QueryString("id"))
upline=request.form("upline")

%>

<!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>
<link href="images/main.css" rel="stylesheet" type="text/css" media="all" />
</head>
<!--#include file="top.asp"-->
<div id="systime"><p id="servertime"></p></div>
<div id="mainBody" >

<div class="space">&nbsp;</div>
<div class="list">

<script language="javascript">
try{
    var nav="H08";
    var subnav="L0801";
	
    document.getElementById(nav).className="current";
    document.getElementById(subnav).className="first current";
    document.getElementById(subnav).parentNode.parentNode.style.display="block";

}catch(e){
	document.getElementById("H08").className="current";
}
</script>


          <%
		   select case action
           case "list"
		  %>


<table class="search_form">

<td align="right" width="100%"><a href="agent.asp?action=addnew"><b>添加代理人员</b></a></td>
</tr></form></table>



<table class="listtable">
  <thead>
    <tr>
      <th scope="col">代理ID</th>
	  <th scope="col">代理名</th>
            <th scope="col">联系QQ</th>
            <th scope="col">操作</th>

    </tr>
  </thead>
  <tbody> 

           <%
		   set Rs=GrateRs("select * from agent order by adminid desc",3)
		   Rs.PageSize=30
		   if not Rs.eof then 
		   If Nowpage=0 then Nowpage=1
		   Rs.AbsolutePage=Nowpage 
		   i=1
		   do while not Rs.eof and i<=Rs.pagesize
		   %>
<%if i mod 2 =0 then%>
         <tr class="listtr1" >
<%else%>
         <tr class="listtr2" >
<%end IF%>
              <td><%=Rs("adminid")%></td>
              <td><%=Rs("username")%></td>
              <td><%=Rs("a_qq")%></td>
              <td><a href="agent.asp?action=show&id=<%=Rs("adminid")%>">编辑</a> / <a href='javascript:if(confirm("确实要删除吗?"))location="agent.asp?action=del&id=<%=Rs("adminid")%>"'>删除</a></td>
            </tr>
			<%
		   i=i+1
		   Rs.movenext
		   loop
		  %>
<tr onmouseover="this.oldcolor=this.style.backgroundColor;this.style.backgroundColor='infobackground'" onmouseout="this.style.backgroundColor=this.oldcolor" style="color:#284775;background-color:White;">
		      <td height="26" colspan="7">&nbsp;<strong>翻页: :</strong>
<%
  myurl="agent.asp?action=list&"
 response.write("共："&Rs.recordcount&"条记录，共:"&Rs.PageCount&"页,"&Rs.PageSize&"条/页,第"&NowPage&"页&nbsp;")
  response.write("<a href='"&myurl&"page=1'>"&"首页</a>&nbsp;")
  if NowPage>1 then response.write("<a href='"&myurl&"page="&Nowpage-1&"'>上一页</a>&nbsp;")
  if NowPage<Rs.PageCount then response.write("<a href='"&myurl&"page="&Nowpage+1&"'>下一页</a>&nbsp;")
  response.write("<a href='"&myurl&"page="&Rs.PageCount&"'>尾页</a>&nbsp;")
		%>&nbsp;</td>
		      </tr>
		  </form>

			  <%else%>
<tr onmouseover="this.oldcolor=this.style.backgroundColor;this.style.backgroundColor='infobackground'" onmouseout="this.style.backgroundColor=this.oldcolor" style="color:#284775;background-color:White;">
              <td height="26" colspan="9">对不起,无记录!</td>
              </tr>
			  <%end if%>


		  <%
		 case "addnew"
			%>

<script language="javascript">
function check()
{


	rem = /\b13[0-9]{9}\b/;
	
	if (document.reg.a_address.value.length == "")//通讯地址
	{
		alert("请填写通讯地址！");
		return false;
	}
	
	
	
	if (document.reg.a_qq.value == "")
	{
		alert("请填写QQ号码，方便联系！");
		return false;
	}
if (document.reg.a_pay.value.length == "")//真实姓名
	{
		alert("请填写收款人姓名！");
		return false;
	}
	
	if (document.reg.a_bankid.value == "")
	{
		alert("请填写银行帐号！");
		return false;
	}
	if (isNaN(reg.a_bankid.value))
	{
		alert("银行帐号格式错误！");
		reg.a_bankid.focus();
		return false;
	}
	if (document.reg.a_bankadd.value == "")
	{
		alert("请填写开户银行详细地址！");
		return false;
	}
	
	return true;
}
</script>


        <table border="0" width="100%">
            <tr class="pagehead">
                <td>
                    &nbsp;&nbsp;<b>您现在所在位置：</b>
                    <span id="lblNav">增加代理</span>
                </td>
                <td>
                </td>
                <td align="right">
                </td>
            </tr>
            <tr>
                <td colspan="3" style="padding: 6px">
                    <table cellspacing="0" cellpadding="0" width="100%" border="0">
                        <tr>
                            <td align="left" colspan="2" height="34" style="height: 28px; background-color: aliceblue"
                                valign="middle">
                                &nbsp; <strong>
                                    增加代理
                                </strong>
                            </td>
                        </tr>



       <tr><form name="reg" onSubmit="return check()" method="post" action="agent.asp?action=upaddnew">
                            <td align="right" height="34" style="width: 180px; height: 28px" valign="middle"
                                class="leftTD dotted">
                                用户名
                                &nbsp;
                            </td>
                            <td height="34" valign="middle" width="*" class="dotted">
		<input name="inputusr" type="text" maxlength="150" id="inputusr" style="width:200px;" />
                            </td>
                        </tr>
                        <tr>
                            <td align="right" height="34" style="width: 180px; height: 28px" valign="middle"
                                class="leftTD dotted">
                                登陆密码
                                &nbsp;
                            </td>
                            <td height="34" valign="middle" width="*" class="dotted">
		<input name="inputpwd" type="password" maxlength="150" id="inputpwd" style="width:200px;" />
                            </td>
                        </tr>
                        <tr>
                            <td align="right" height="34" style="width: 180px; height: 28px" valign="middle"
                                class="leftTD dotted">
                                真实姓名
                                &nbsp;
                            </td>
                            <td height="34" valign="middle" width="*" class="dotted">
		<input name="a_name" type="text" maxlength="150" id="a_name" style="width:200px;" />
                            </td>
                        </tr>
                        <tr>
                            <td align="right" height="34" style="width: 180px; height: 28px" valign="middle"
                                class="leftTD dotted">
                                身份证号
                                &nbsp;
                            </td>
                            <td height="34" valign="middle" width="*" class="dotted">
		<input name="a_card" type="text" maxlength="150" id="a_card" style="width:200px;" />
                            </td>
                        </tr>
                        <tr>
                            <td align="right" height="34" style="width: 180px; height: 28px" valign="middle"
                                class="leftTD dotted">
                                电话号码
                                &nbsp;
                            </td>
                            <td height="34" valign="middle" width="*" class="dotted">
		<input name="a_tel" type="text" maxlength="150" id="a_tel" style="width:200px;" />
                            </td>
                        </tr>
                        <tr>
                            <td align="right" height="34" style="width: 180px; height: 28px" valign="middle"
                                class="leftTD dotted">
                                QQ号码
                                &nbsp;
                            </td>
                            <td height="34" valign="middle" width="*" class="dotted">
		<input name="a_qq" type="text" maxlength="150" id="a_qq" style="width:200px;" />
                            </td>
                        </tr>
                        <tr>
                            <td align="right" height="34" style="width: 180px; height: 28px" valign="middle"
                                class="leftTD dotted">
                                通讯地址
                                &nbsp;
                            </td>
                            <td height="34" valign="middle" width="*" class="dotted">
		<input name="a_address" type="text" maxlength="150" id="a_address" style="width:200px;" />
                            </td>
                        </tr>
                        <tr>
                            <td align="right" height="34" style="width: 180px; height: 28px" valign="middle"
                                class="leftTD dotted">
                                收款人
                                &nbsp;
                            </td>
                            <td height="34" valign="middle" width="*" class="dotted">
		<input name="a_pay" type="text" maxlength="150" id="a_pay" style="width:200px;" />
                            </td>
                        </tr>
                        <tr>
                            <td align="right" height="34" style="width: 180px; height: 28px" valign="middle"
                                class="leftTD dotted">
                                银行帐号
                                &nbsp;
                            </td>
                            <td height="34" valign="middle" width="*" class="dotted">
		<input name="a_bankid" type="text" maxlength="150" id="a_bankid" style="width:200px;" />
                            </td>
                        </tr>
                        <tr>
                            <td align="right" height="34" style="width: 180px; height: 28px" valign="middle"
                                class="leftTD dotted">
                                开户银行
                                &nbsp;
                            </td>
                            <td height="34" valign="middle" width="*" class="dotted">
		<input name="a_bank" type="text" maxlength="150" id="a_bank" style="width:200px;" />
                            </td>
                        </tr>
                        <tr>
                            <td align="right" height="34" style="width: 180px; height: 28px" valign="middle"
                                class="leftTD dotted">
                                开户地址
                                &nbsp;
                            </td>
                            <td height="34" valign="middle" width="*" class="dotted">
		<input name="a_bankadd" type="text" maxlength="150" id="a_bankadd" style="width:200px;" />
                            </td>
                        </tr>

                        <tr>
                            <td align="right" height="34" style="width: 180px; height: 28px" valign="middle"
                                class="leftTD dotted">
                                全登录省份
                                &nbsp;
                            </td>
                            <td height="34" valign="middle" width="*" class="dotted">
		<input name="diqu" type="text" maxlength="150" id="diqu" value="0" style="width:200px;" />
                            </td>
                        </tr>
                        <tr>
                            <td align="right" height="34" style="width: 180px; height: 28px" valign="middle"
                                class="leftTD dotted">
                                代理提成
                                &nbsp;
                            </td>
                            <td height="34" valign="middle" width="*" class="dotted">
		<input name="dltc" type="text" maxlength="150" id="dltc" value="0" style="width:200px;" />
                            </td>
                        </tr>
                        <tr>
                            <td align="right" height="34" style="width: 180px; height: 28px" valign="middle"
                                class="leftTD dotted">
                            </td>
                            <td height="34" valign="middle" width="*" class="dotted">
                                <input type="submit" name="Submit" value="增加代理" id="Submit" /></td>
                        </tr>
                    </table></form>
                </td>
            </tr>
        </table>




		  <%
		 case "show"
 			set Rs=GrateRs("select * from agent where adminid="&id,1)
 			if not Rs.eof then 
			%>


        <table border="0" width="100%">
            <tr class="pagehead">
                <td>
                    &nbsp;&nbsp;<b>您现在所在位置：</b>
                    <span id="lblNav">代理详细资料</span>
                </td>
                <td>
                </td>
                <td align="right">
                </td>
            </tr>
            <tr>
                <td colspan="3" style="padding: 6px">
                    <table cellspacing="0" cellpadding="0" width="100%" border="0">
                        <tr>
                            <td align="left" colspan="2" height="34" style="height: 28px; background-color: aliceblue"
                                valign="middle">
                                &nbsp; <strong>
                                    代理详细资料
                                </strong>
                            </td>
                        </tr>
        <tr><form name="reg"  method="post" action="agent.asp?action=up&adminid=<%=Rs("adminid")%>">
                            <td align="right" height="34" style="width: 180px; height: 28px" valign="middle"
                                class="leftTD dotted">
                                代理ID
                                &nbsp;</td>
                            <td height="34" valign="middle" width="*" class="dotted">
                                <input name="id" type="text" value="<%=Rs("adminid")%>" maxlength="20" readonly="readonly" id="id" onkeypress="return false" style="color:Gray;background-color:White;width:200px;" />
                            </td>
                        </tr>
                        <tr>
                            <td align="right" height="34" style="width: 180px; height: 28px" valign="middle"
                                class="leftTD dotted">
                                代理帐号
                                &nbsp;</td>
                            <td height="34" valign="middle" width="*" class="dotted">
                                <input name="username" type="text" value="<%=Rs("username")%>" maxlength="20" readonly="readonly" id="username" onkeypress="return false" style="color:Gray;background-color:White;width:200px;" />
                            </td>
                        </tr>
                        <tr>
                            <td align="right" height="34" style="width: 180px; height: 28px" valign="middle"
                                class="leftTD dotted">
                                登录密码
                                &nbsp;
                            </td>
                            <td height="34" valign="middle" width="*" class="dotted">
		<input name="password" type="password" maxlength="150" id="password" style="width:200px;" />
                            </td>
                        </tr>
                        <tr>
                            <td align="right" height="34" style="width: 180px; height: 28px" valign="middle"
                                class="leftTD dotted">
                                代理提成
                                &nbsp;
                            </td>
                            <td height="34" valign="middle" width="*" class="dotted">
		<input name="dltc" type="text" maxlength="150" id="dltc" value="<%=Rs("dltc")%>" style="width:200px;" />
                            </td>
                        </tr>
                        <tr>
                            <td align="right" height="34" style="width: 180px; height: 28px" valign="middle"
                                class="leftTD dotted">
                                真实姓名
                                &nbsp;
                            </td>
                            <td height="34" valign="middle" width="*" class="dotted">
		<input name="a_name" type="text" maxlength="150" id="a_name" value="<%=Rs("a_name")%>" style="width:200px;" />
                            </td>
                        </tr>
                        <tr>
                            <td align="right" height="34" style="width: 180px; height: 28px" valign="middle"
                                class="leftTD dotted">
                                身份证号
                                &nbsp;
                            </td>
                            <td height="34" valign="middle" width="*" class="dotted">
		<input name="a_card" type="text" maxlength="150" id="a_card" value="<%=Rs("a_card")%>" style="width:200px;" />
                            </td>
                        </tr>
                        <tr>
                            <td align="right" height="34" style="width: 180px; height: 28px" valign="middle"
                                class="leftTD dotted">
                                电话号码
                                &nbsp;
                            </td>
                            <td height="34" valign="middle" width="*" class="dotted">
		<input name="a_tel" type="text" maxlength="150" id="a_tel" value="<%=Rs("a_tel")%>" style="width:200px;" />
                            </td>
                        </tr>
                        <tr>
                            <td align="right" height="34" style="width: 180px; height: 28px" valign="middle"
                                class="leftTD dotted">
                                QQ号码
                                &nbsp;
                            </td>
                            <td height="34" valign="middle" width="*" class="dotted">
		<input name="a_qq" type="text" maxlength="150" id="a_qq" value="<%=Rs("a_qq")%>" style="width:200px;" />
                            </td>
                        </tr>
                        <tr>
                            <td align="right" height="34" style="width: 180px; height: 28px" valign="middle"
                                class="leftTD dotted">
                                通讯地址
                                &nbsp;
                            </td>
                            <td height="34" valign="middle" width="*" class="dotted">
		<input name="a_address" type="text" maxlength="150" id="a_address" value="<%=Rs("a_address")%>" style="width:200px;" />
                            </td>
                        </tr>
                        <tr>
                            <td align="right" height="34" style="width: 180px; height: 28px" valign="middle"
                                class="leftTD dotted">
                                收款人
                                &nbsp;
                            </td>
                            <td height="34" valign="middle" width="*" class="dotted">
		<input name="a_pay" type="text" maxlength="150" id="a_pay" value="<%=Rs("a_pay")%>" style="width:200px;" />
                            </td>
                        </tr>
                        <tr>
                            <td align="right" height="34" style="width: 180px; height: 28px" valign="middle"
                                class="leftTD dotted">
                                银行帐号
                                &nbsp;
                            </td>
                            <td height="34" valign="middle" width="*" class="dotted">
		<input name="a_bankid" type="text" maxlength="150" id="a_bankid" value="<%=Rs("a_bankid")%>" style="width:200px;" />
                            </td>
                        </tr>
                        <tr>
                            <td align="right" height="34" style="width: 180px; height: 28px" valign="middle"
                                class="leftTD dotted">
                                开户银行
                                &nbsp;
                            </td>
                            <td height="34" valign="middle" width="*" class="dotted">
		<input name="a_bank" type="text" maxlength="150" id="a_bank" value="<%=Rs("a_bank")%>" style="width:200px;" />
                            </td>
                        </tr>
                        <tr>
                            <td align="right" height="34" style="width: 180px; height: 28px" valign="middle"
                                class="leftTD dotted">
                                开户地址
                                &nbsp;
                            </td>
                            <td height="34" valign="middle" width="*" class="dotted">
		<input name="a_bankadd" type="text" maxlength="150" id="a_bankadd" value="<%=Rs("a_bankadd")%>" style="width:200px;" />
                            </td>
                        </tr>
                        <tr>
                            <td align="right" height="34" style="width: 180px; height: 28px" valign="middle"
                                class="leftTD dotted">
                                全登录省份
                                &nbsp;
                            </td>
                            <td height="34" valign="middle" width="*" class="dotted">
		<input name="diqu" type="text" maxlength="150" id="diqu" value="<%=Rs("diqu")%>" style="width:200px;" />
                            </td>
                        </tr>
                        <tr>
                            <td align="right" height="34" style="width: 180px; height: 28px" valign="middle"
                                class="leftTD dotted">
                            </td>
                            <td height="34" valign="middle" width="*" class="dotted">
                                <input type="submit" name="Submit" value="提交修改" id="Submit" /></td>
                        </tr>
                    </table></form>
                </td>
            </tr>
        </table>


   



		  <%
			 end if




		 
		  case "del"
 			set Rs=GrateRs("select * from agent where adminid="&id,3)
 			if not Rs.eof then 
 			  Rs.delete
 			  Rs.update
			 end if
		    response.write "<script language='JavaScript'>{window.alert('该会员已经被删除！');window.location='agent.asp?action=list';}</script>"
		    response.end


		  case "upaddnew"
 			set Rs=GrateRs("select * from agent where username like '"&request("inputusr")&"'",3)
			  if Rs.eof then  
 			  Rs.addnew
			rs("username")=trim(request.form("inputusr"))
			rs("password")=md5(trim(request.form("inputpwd")))
			rs("dltc")=trim(request.form("dltc"))
			rs("a_name")=trim(request.form("a_name"))
			rs("a_card")=trim(request.form("a_card"))
			rs("a_tel")=trim(request.form("a_tel"))
			rs("a_qq")=trim(request.form("a_qq"))
			rs("a_address")=trim(request.form("a_address"))
			rs("a_pay")=trim(request.form("a_pay"))
			rs("a_bankid")=trim(request.form("a_bankid"))
			rs("a_bank")=trim(request.form("a_bank"))
			rs("a_bankadd")=trim(request.form("a_bankadd"))
			rs("diqu")=trim(request.form("diqu"))
 			  Rs.update
			 end if
		    response.write "<script language='JavaScript'>{window.alert('增加代理成功！');window.location='agent.asp?action=list';}</script>"
		    response.end


			case "up"
			set Rs=GrateRs("select * from agent where adminid="&request("adminid"),3)
 			if not Rs.eof then 		

   if trim(request("password"))<>""  then rs("password")=md5(trim(request("password")))


			rs("dltc")=trim(request("dltc"))
			rs("a_name")=trim(request("a_name"))
			rs("a_card")=trim(request("a_card"))
			rs("a_tel")=trim(request("a_tel"))
			rs("a_qq")=trim(request("a_qq"))
			rs("a_address")=trim(request("a_address"))
			rs("a_pay")=trim(request("a_pay"))
			rs("a_bankid")=trim(request("a_bankid"))
			rs("a_bank")=trim(request("a_bank"))
			rs("a_bankadd")=trim(request("a_bankadd"))
			rs("diqu")=trim(request("diqu"))
			rs.update
			response.Write("<script>alert('资料修改成功!');window.location.href='agent.asp?action=show&id="&request("adminid")&"';</script>")
			end if
		  end select
		  %>
          </table>
       </td>
      </tr>
	  

    </table></td>
  </tr>
</table>
</body>
</html>
<%
call DBConnEnd
%>
