  <% 
	data_path="../../" 'ACC连接数据库路径，对SQL无效
	numid="110"
	dir="../err.asp" 
  %>
  <!--#include file="../../conn/conn.asp"-->
<!--#include file="../../inc/safe.asp"-->
 <!--#include file="../rolecheck.asp"-->
 <html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<LINK href="../css/Style.css" rel=stylesheet type=text/css>
<title>会员资料修改</title></head>
  <%
sf=Replace_Text(request("sf")) 
addsf=Replace_Text(request("addsf")) 
delid=Replace_Text(request("delid")) 
modisf=Replace_Text(request("modisf")) 
midno=Replace_Text(request("midno")) 
midname=Replace_Text(request("midname"))
addshi=Replace_Text(request("addshi"))
shi=Replace_Text(request("shi"))
sheng=Replace_Text(request("sheng"))
orderid=Replace_Text(request("orderid"))
orderno=Replace_Text(request("orderno"))

'添加一级区域-----------------------------
if addsf<>"" and sf<>""  and orderid<>"" then
if not isnumeric(orderid) then 
response.Write("<script>alert(' 请输入排序号为数字！');history.back(-1);</script>")
response.End()
end if
set rs1=server.CreateObject("adodb.recordset")
sql1="select * from Websen_area where Province ='"&sf&"'"
rs1.open sql1,conn,1,3
if not rs1.eof then 
response.Write("<script >alert('对不起！该一级区域名已经存在，请另换一个！ ');location.href='addarea.asp?action=addsf';</script>")
response.End()
else
rs1.addnew 
rs1("Province")=sf
rs1("orderid")=orderid
rs1.update
end if
rs1.close
end if

'------------------------------------

'删除一级区域------------------------------------
if delid<>"" then 
conn.execute "delete from Websen_area where id="&delid
conn.execute "delete from Websen_areacity where cityof="&delid
  conn.execute "delete from Websen_areaaddr where cityof="&delid

response.Redirect(request.ServerVariables("HTTP_REFERER"))
end if

'------------------------------------
'修改一级区域-------------------------------
if modisf<>"" and midname<>""   then 
set rs2=server.CreateObject("adodb.recordset")
sql2="select * from Websen_area where Province ='"&midname&"' and   id<>"&midno
rs2.open sql2,conn,1,3
if not rs2.eof then 
response.Write("<script >alert('对不起！该一级区域名已经存在，请另换一个！ ');history.back(-1);</script>")
response.End()
else
conn.execute "update Websen_area set Province='"&midname&"',orderid="&orderno&" where id="&midno

response.Redirect("addarea.asp")
  end if
rs2.close

end if
 
'----------------------------------

'--添加二级区域--------------------------------
if addshi<>"" and shi<>"" and sheng<>"0"  then 
set rs3=server.CreateObject("adodb.recordset")
sql3="select * from Websen_areacity where cityof="&sheng&" and  city ='"&shi&"'"
rs3.open sql3,conn,1,3
if not rs3.eof then 
response.Write("<script >alert('对不起！该二级区域名已经存在，请另换一个！ ');location.href='addarea.asp?action=addshi';</script>")
response.End()
else
rs3.addnew 
rs3("city")=shi
rs3("cityof")=sheng
rs3.update
end if
rs3.close 

end if

'----------------------------------\
modishi=Replace_Text(request("modishi"))
mshiid=Replace_Text(request("mshiid"))
mshiname=Replace_Text(request("mshiname"))
mcof=Replace_Text(request("mcof"))
'--修改二级区域--------------------------------
  if modishi<>"" and  mshiname<>""  and mcof<>"0" then
 set rs3=server.CreateObject("adodb.recordset")
sql3="select * from Websen_areacity where cityof="&mcof&" and  city ='"&mshiname&"' and id <>"&mshiid
  rs3.open sql3,conn,1,3

if not rs3.eof then 
    response.Write("<script >alert('对不起！该一级区域内该二级区域名已经存在，请另换一个！ ');history.back(-1);</script>")
response.End()
else
 conn.execute "update Websen_areacity set city='"&mshiname&"',cityof="&mcof&" where id="&mshiid
 conn.execute "update Websen_areaaddr set  cityof="&mcof&" where addrof="&mshiid&" "
 response.Redirect("addarea.asp")
 end if
rs3.close
 end if
 '----------------------------------
 '-删除二级区域---------------------------------
delac=Replace_Text(request("delac"))
delcid=Replace_Text(request("delcid"))
if delac<>"" and delcid<>"" then 
conn.execute "delete from Websen_areacity where id="&delcid
conn.execute "delete from Websen_areaaddr where addrof="&delcid
response.Redirect(request.ServerVariables("HTTP_REFERER"))
end if
 '----------------------------------
 '--添加三级区域--------------------------------
 addq=Replace_Text(request("addq"))
 chengshi=Replace_Text(request("chengshi"))
 qu=Replace_Text(request("qu"))
 shengfen=Replace_Text(request("shengfen"))
   if addq<>"" and chengshi<>"" and shengfen<>"" then
    
 set rsq=server.CreateObject("adodb.recordset")
 sqlq="select  * from Websen_areaaddr where addr='"&qu&"' and addrof="&chengshi&" and cityof="&shengfen
 rsq.open sqlq,conn,1,3
 if not rsq.eof then 
 response.Write("<script >alert('对不起！该该二级区域内该三级区域名已经存在，请另换一个！ ');location.href='addarea.asp?action=addqu';</script>")
response.End()
else
rsq.addnew
rsq("addr")=qu
rsq("addrof")=chengshi
rsq("cityof")=shengfen
rsq.update
 end if
 rsq.close
 end if
 
 '----------------------------------
 
  '-修改三级区域---------------------------------
    qumgo=Replace_Text(request("qumgo"))
	qid=Replace_Text(request("qid"))
	qn=Replace_Text(request("qn"))
	qc=Replace_Text(request("qc"))
	qp=Replace_Text(request("qp"))
    if qumgo<>"" and qn<>"" and qid<>"" and  qp<>"" and qc<>"" then
	 set rsq1=server.CreateObject("adodb.recordset")
 sqlq1="select  * from Websen_areaaddr where addr='"&qn&"' and addrof="&qc&" and cityof="&qp&" and  id<>"&qid
   rsq1.open sqlq1,conn,1,3
 if not rsq1.eof then 
 response.Write("<script >alert('对不起！该该二级区域内该三级区域名已经存在，请另换一个！ ');history.back(-1);</script>")
response.End()
else
response.Write("dsjfl")
 conn.execute "update Websen_areaaddr set addr='"&qn&"',addrof="&qc&",cityof="&qp&" where id="&qid
 response.Redirect("addarea.asp")
  end if
 rsq1.close
	end if   

  '----------------------------------

  '- 删除三级区域---------------------------------
  cae=Replace_Text(request("cae"))
  delqu=Replace_Text(request("delqu"))
  if cae="del" then 
  conn.execute "delete from Websen_areaaddr where id="&delqu
  response.Redirect(request.ServerVariables("HTTP_REFERER"))
   end if
  '----------------------------------

%>
<script language="javascript">
function isokg(value)
{
var i=confirm(value);
if(i)
{
return true ;
}
else
{
return false;
}

}
 
</script>
<%
    set rsa=server.createobject("adodb.recordset")
   sqla = "select * from Websen_area"
   rsa.open sqla,conn,1,1

   set rsb=server.createobject("adodb.recordset")
   sqlb = "select * from Websen_areacity"
   rsb.open sqlb,conn,1,1
%>
<SCRIPT language = "javascript">
var onecount;
onecount=0;
subcat = new Array();
        <%
        count = 0
        do while not rsb.eof 
        %>
subcat[<%=count%>] = new Array("<%= trim(rsb("city"))%>","<%= trim(rsb("cityof"))%>","<%= trim(rsb("id"))%>");
        <%
        count = count + 1
        rsb.movenext
        loop
        rsb.close
        %>
onecount=<%=count%>;

function change2(locationid2)
    {
    document.formcd.chengshi.length = 0; 

    var locationid2=locationid2;
    var i;
    for (i=0;i < onecount; i++)
        {
            if (subcat[i][1] == locationid2)
            { 
                document.formcd.chengshi.options[document.formcd.chengshi.length] = new Option(subcat[i][0], subcat[i][2]);
            }        
        }
        
    }    
</SCRIPT>

 

<table width="95%" border="1"  align=center cellpadding="0" cellspacing="0" bordercolor="#84A3E0">
<tr>
<th align=center colspan=8 height=23>区域资料管理(用于模糊搜索等）</th>
</tr>
<tr>
<td height="30"  bgcolor="#F3F3F3" >&nbsp;&nbsp;<font color="red">提示:添加顺序[先添加一级区域，再二级区域，后三级区域]</font>&nbsp;&nbsp;<a href="addarea.asp?action=addsf">添加一级区域</a>&nbsp;&nbsp;&nbsp;<a href="addarea.asp?action=addshi">添加二级区域</a>&nbsp;&nbsp;&nbsp;<a href="addarea.asp?action=addqu">添加三级区域</a> </td>
 </tr>
</table> 


<%
 if Replace_Text(request("ace"))<>"" then
%>
    <table cellpadding="2" cellspacing="1" border="0"  bgcolor="#D3DCEE" width="95%"  align=center>
<form name="formcd1" method="post" action="">
<tr>
  <td align="center">
 修改三级区域名：
   <input type="text" name="qn" value="<%=Replace_Text(request("quname"))%>">
<input type="hidden" name="qid" value="<%=Replace_Text(request("editqu"))%>">
<input type="hidden" name="qp" value="<%=Replace_Text(request("qpn"))%>">
<input type="hidden" name="qc" value="<%=Replace_Text(request("qcn"))%>">
<input type="submit" name="qumgo" value="修改">
</td>
</tr>
</form>
</table>
<%
end if


if Replace_Text(request("action"))="addqu" then 
  %>
    <table cellpadding="2" cellspacing="1" border="0"  bgcolor="#D3DCEE" width="95%"  align=center>
  <form name="formcd" action="" method="post" ><tr>
<td  align="center" height="30" >添加三级区域:
 
 
 <select name="shengfen" onChange="change2(document.formcd.shengfen.options[document.formcd.shengfen.selectedIndex].value)">
      <option selected value="">选择一级区域</option>
         <% do while not rsa.eof  %>
      <option value="<%=trim(rsa("id"))%>"><%=trim(rsa("Province"))%></option>
         <%
          rsa.movenext
             loop
       %>
     </select>
二级区域：
<select name="chengshi">
  <option selected value="">先选择区域</option>
</select> 
 
 
<input type="text" name="qu" value="" maxlength="20" onBlur="this.value=this.value.replace(/\s/igm,'')"> &nbsp;<input type="submit" name="addq" value="添加三级区域">	
 </td>
 </tr></form>
</table>
    <%
  end if
 
if  Replace_Text(request("shimodi"))<>"" then
%>
<table cellpadding="2" cellspacing="1" border="0" width="95%"  bgcolor="#D3DCEE" align=center>
  <form name="formsa" action="" method="post" ><tr>
<td width=9% align="center"   height="30">修改二级区域名：
<select size="1" name="mcof">
<%
set rsh1=server.CreateObject("adodb.recordset")
sqlh1="select * from Websen_area "
rsh1.open sqlh1,conn,1,1
if rsh1.eof then 
%>
<option value="0" >无任何一级区域</option>
 <%
else
do while not rsh1.eof 
 %>
<option value="<%=rsh1("id")%>"  	 <%if Replace_Text(request("cof"))=Replace_Text(rsh1("id")) then   response.Write("selected") end if%>><%=rsh1("Province")%></option>
<%
rsh1.movenext
loop
rsh1.close
end if
%>
</select>


<input type="hidden" name="mshiid" value="<%=Replace_Text(request("shiid"))%>" >
<input type="text" name="mshiname" value="<%=Replace_Text(request("shiname"))%>" maxlength="20" onBlur="this.value=this.value.replace(/\s/igm,'')">&nbsp;&nbsp; &nbsp;<input type="submit" name="modishi" value="修改">	
 </td>
 </tr></form>
</table>
<%
end if
if  Replace_Text(request("modiid")) <>"" then
%>
<table cellpadding="2" cellspacing="1" border="0" width="95%"  bgcolor="#D3DCEE" align=center>
  <form name="form1" action="" method="post" ><tr>
<td width=9% align="center"   height="30">修改一级区域：<input type="hidden" name="midno" value="<%=Replace_Text(request("modiid"))%>" >
<input type="text" name="midname" value="<%=Replace_Text(request("modname"))%>" maxlength="20" onBlur="this.value=this.value.replace(/\s/igm,'')">&nbsp;<input type="text" name="orderno" value="<%=Replace_Text(request("ordno"))%>"  onBlur="if(/[^0-9]/g.test(this.value)){alert('请输入整型数字！');this.value=0}">&nbsp;&nbsp; &nbsp;<input type="submit" name="modisf" value="修改">	
 </td>
 </tr></form>
</table>
<%
end if
 if Replace_Text(request("action"))="addsf" then 
 %>
 <table cellpadding="2" cellspacing="1" border="0"  bgcolor="#D3DCEE" width="95%"  align=center>
  <form name="form" action="" method="post" ><tr>
<td  align="center" height="30" >添加一级区域:
  <input type="text" name="sf" value="" maxlength="20" onBlur="this.value=this.value.replace(/\s/igm,'')"> 
  &nbsp;排序值:
  <input type="text" name="orderid" value="0"   onBlur="if(/[^0-9]/g.test(this.value)){alert('请输入整型数字！');this.value=0}">&nbsp;
  <input type="submit" name="addsf" value="添加一级区域">	
 </td>
 </tr></form>
</table>
<%
 end if
 if Replace_Text(request("action"))="addshi" then 
  %>
    <table cellpadding="2" cellspacing="1" border="0"  bgcolor="#D3DCEE" width="95%"  align=center>
  <form name="formshi" action="" method="post" ><tr>
<td  align="center" height="30" >添加二级区域:
  <select size="1" name="sheng">
<%
set rsh=server.CreateObject("adodb.recordset")
sqlh="select * from Websen_area "
rsh.open sqlh,conn,1,1
if rsh.eof then 
%>
<option value="0" >无任何一级区域</option>
 <%
else
do while not rsh.eof 
 %>
<option value="<%=rsh("id")%>"><%=rsh("Province")%></option>
<%
rsh.movenext
loop
rsh.close
end if
%>
</select>
<input type="text" name="shi" value="" maxlength="20" onBlur="this.value=this.value.replace(/\s/igm,'')"> &nbsp;<input type="submit" name="addshi" value="添加二级区域">	
 </td>
 </tr></form>
</table>
    <%
  end if
  %>
 <table cellpadding="0"   cellspacing="0" border="1" bordercolor="#7698DD" width="95%"  align=center>
   <tr>
   <%
 set rs=server.CreateObject("adodb.recordset")
 sql="select * from Websen_area  order by orderid  "
 rs.open sql,conn,1,1
 msg_per_page=1 '定义每页显示记录条数
 %>
<!--#include file="../../inc/headpage.asp"-->
<%
if rs.eof then
response.Write"<tr><td  collspan=2  align=center height=80>暂无数据信息</td></tr> "
else
i=1
do while not rs.eof and rowcount > 0 %>
<tr><td  height="25">&nbsp;<font  color="#006699">⊥</font><b><%=rs("Province")%></b>(<font color="#0066CC"><%=rs("orderid")%></font>)&nbsp;<a href="addarea.asp?ordno=<%=rs("orderid")%>&modiid=<%=rs("id")%>&modname=<%=rs("Province")%>"><font color="#999999">修改</font></a>|<a href="addarea.asp?delid=<%=rs("id")%>" onClick="return isokg('你确定要删除吗?将删除其下的所有下级地区!');"><font color="#999999">删除</font></a></td></tr>
<!---二级-->
<tr><td>
 <table width="95%" border="1"  align=right cellpadding="0"   cellspacing="0" bordercolor="#D3DCEE" bgcolor="#F9F9F9">
 
<%
set rst=server.CreateObject("adodb.recordset")
sqlt="select  * from Websen_areacity where cityof="&rs("id")
rst.open sqlt,conn,1,1
if not rst.eof then 
j=1
do while not rst.eof 
%><tr>
<td height="25"> <font color="#0099CC"><%=j%></font>.<%=rst("city")%>&nbsp;&nbsp;<a href="addarea.asp?cof=<%=rst("cityof")%>&shimodi=modi&shiname=<%=rst("city")%>&shiid=<%=rst("id")%>"><font color="#999999">修改</font></a>|<A href="addarea.asp?delac=del&delcid=<%=rst("id")%>" onClick="return isokg('你确定要删除吗?将删除其下的所有下级地区!');"><font color="#999999">删除</font></A>

<!--所属二级的地区-->
<table width="95%" border="1"  align=right cellpadding="0"   cellspacing="0" bordercolor="#F5F5F5" bgcolor="#D3DCEE">
 <tr>
 <%
 set rsd=server.CreateObject("adodb.recordset")
 sqld="select   * from Websen_areaaddr where addrof="&rst("id")
  rsd.open sqld,conn,1,1
 if  not rsd.eof then 
 k=1
 do while not rsd.eof 
 %>
  <td height="25"><font color="#0099CC"><%=k%></font>.<font color="#0066CC"><%=rsd("addr")%></font>&nbsp;<a href="addarea.asp?qpn=<%=rsd("cityof")%>&qcn=<%=rsd("addrof")%>&quname=<%=rsd("addr")%>&ace=edit&editqu=<%=rsd("id")%>"><font color="#999999">修改</font></a>|<A href="addarea.asp?cae=del&delqu=<%=rsd("id")%>"  onClick="return isokg('你确定要删除吗?');"><font color="#999999">删除</font></A> </td>
  <%
  if k mod 3 =0 then 
  response.Write("</tr><tr>")
  end if
  k=k+1
 rsd.movenext 
 loop
  end if 
 %>

 </tr></table>

<!--所属二级的地区-->
 </td></tr>
 
<%
 
j=j+1
rst.movenext
loop
rst.close
end if
%>
</table>
</td></tr>
<!---二级-->
<%

  i=i+1
  rowcount=rowcount-1
rs.movenext
loop
end if
%>
  
 <tr><td colspan="5"  align="center"> <%=listPages("addarea.asp")%>&nbsp;</td></tr>
</table>
  
<%
rs.close
 conn.close
set conn=nothing
%>
<!--#include file="../copy.asp"-->