<!--#include file="../../conn/conn.asp" -->
<!--#include file="../../Inc/Commoncode.asp" -->
<!--#include file="../checkvalid.asp" -->
<%
If Not FRAdminLevel(102) Then
	Call ErrorMsg()
End If
%>
<%
fid=request("fid")
if request("step")="add" then
province_city=request("province_city")
enprovince_city=request("enprovince_city")
enprovince_order=request("enprovince_order")
if province_city="" then
	response.write "<script>alert('对不起，中文省份不能为空！');location.href='javascript:history.back()';</script>"
	Response.End 
end if
if enprovince_city="" then
	response.write "<script>alert('对不起，英文省份不能为空！');location.href='javascript:history.back()';</script>"
	Response.End 
end if
if not Isnumeric(enprovince_order) then
	response.write "<script>alert('对不起，排序只能为数字！');location.href='javascript:history.back()';</script>"
	Response.End 
end if
sql="select * from JOB_provinceandcity"
set rs=Server.CreateObject("ADODB.Recordset")                                                    
rs.open sql,conn,1,3
rs.addnew
rs("province_city")=province_city
rs("enprovince_city")=enprovince_city
rs("order")=enprovince_order
rs("fid")=fid
rs.Update
rs.Close
set rs=nothing
Response.Redirect "Admin_Sysprovinceandcity.asp?fid="&fid&"&ceng="&request("ceng")
end if

if request("step")="del" then
conn.execute("delete from JOB_provinceandcity where fid="&request("id"))
conn.execute("delete from JOB_provinceandcity where id="&request("id"))
Response.Redirect "Admin_Sysprovinceandcity.asp?fid="&fid&"&ceng="&request("ceng")

end if

if request("step")="alldel" then
sql="select * from JOB_provinceandcity order by id desc"
set rs=Server.CreateObject("ADODB.Recordset")                                                    
rs.open sql,conn,1,1
if not rs.eof then
do while not rs.eof
	if rs("fid")<>0 then
	sqlt="select * from JOB_provinceandcity where id="&rs("fid")&" order by id desc"
	set rst=Server.CreateObject("ADODB.Recordset")                                                    
	rst.open sqlt,conn,1,1
		if (rst.eof and rst.bof) then
		conn.execute("delete from JOB_provinceandcity where fid="&rs("fid")&"")
		end if
	rst.close
	end if
rs.movenext                                             
loop   
end if                                   
rs.close 
set rs=nothing
Response.Redirect "Admin_Sysprovinceandcity.asp?fid="&fid&"&ceng="&request("ceng")

end if

if request("step")="modi" then
province_city=request("province_city")
enprovince_city=request("enprovince_city")
enprovince_order=request("enprovince_order")
if province_city="" then
	response.write "<script>alert('对不起，中文省份不能为空！');location.href='javascript:history.back()';</script>"
	Response.End 
end if
if enprovince_city="" then
	response.write "<script>alert('对不起，英文省份不能为空！');location.href='javascript:history.back()';</script>"
	Response.End 
end if
if not Isnumeric(enprovince_order) then
	response.write "<script>alert('对不起，排序只能为数字！');location.href='javascript:history.back()';</script>"
	Response.End 
end if
conn.execute("update JOB_provinceandcity set province_city='"&province_city&"',enprovince_city='"&enprovince_city&"',[order]="&enprovince_order&" where id="&request("id"))
Response.Redirect "Admin_Sysprovinceandcity.asp?fid="&fid&"&ceng="&request("ceng")
end if
if request("step")="order" then
set rs=server.CreateObject("adodb.recordset")
sql="select date from JOB_provinceandcity where id="&request("id")
rs.open sql,conn,1,3
rs("date")=now()
rs.update
rs.close
set rs=nothing
Response.Redirect "Admin_Sysprovinceandcity.asp?fid="&fid&"&ceng="&request("ceng")
end if
%>

<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>系统区域信息设置</title>
<link href="../css/style<%=sk%>.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="../inc/input.js"></script>
</head>

<body>
<table width="98%" border="0" cellspacing="1" cellpadding="2" align=center class="tableBorder">
  <tr>
    <th height=25 colspan="2" class="tableHeaderText">系统区域信息管理 </th>
  </tr>
  <tr>
    <td colspan="2"><p><B>注意</B>：<BR>
      ①区域分类直接与会员及会员发布的信息相关联，删除上级分类同时将删除该类别下的所有小分类以及所有相关的信息。<BR>
    </td>
  </tr>
   <%
  	ceng=request("ceng")
	if request("fid")="" then 
	fid=0 
	else
	fid=request("fid")
	end if
	if fid=0 then
    ceng=1	
	end if%>
  <tr>
    <td width="10%" height=25><B>操作选项</B></td>
    <td><a href="Admin_Sysprovinceandcity.asp?fid=0">返回一级分类 </a>| <a href="Admin_CreateJs.asp?Action=CreateProvinceJs">生成区域分类JS</a> | <a href="Admin_Sysprovinceandcity.asp?fid=<%=fid%>&step=alldel&ceng=<%=ceng%>">清理垃圾数据</a> | [<a href="javascript:location.reload()">刷新页面</a>] </td>
  </tr>
</table>
<table width="98%" border="0" align="center" cellpadding="2" cellspacing="1" class="tableBorder">
	<%if fid<>0 then
	set rsw=conn.execute("select province_city from JOB_provinceandcity where id="&fid)
	province_city=rsw("province_city")
	rsw.close
	set rsw=nothing
	%><tr>
    <th class="tableHeaderText" colspan=4 height=25><%=province_city%>各<%
	select case ceng
	case 2
	response.Write "城市"
	case 3
	response.Write "县区"
	end select
	%>列表</th>
  </tr>
  <%else%>
   <tr>
    <th class="tableHeaderText" colspan=4 height=25>一级区域列表</th>
  </tr>
  <%end if%>
  <%
	sql="select * from JOB_provinceandcity where fid="&fid&" order by [order] asc,date desc"
set rs=Server.CreateObject("ADODB.Recordset")                                                    
rs.open sql,conn,1,1 
	if (rs.eof and rs.bof) then
	response.write "<tr align=""center""><td height=20>暂无内容</td></tr>"
else                                                 
n=0                                                   
do while not rs.eof
n=n+1%>
<tr align="center">
    <td width="10%"><%=rs("id")%></td>
	<td width="65%" height="25" align="left"><%=rs("province_city")%> (<%=rs("enprovince_city")%>) </td>
	<td width="25%" align="center"><!--<input name="Submit" type="button" class="inputs" onClick="window.location='Admin_Sysprovinceandcity.asp?fid=<%'=fid%>&id=<%'=rs("id")%>&step=order&ceng=<%'=ceng%>'" value="排序">--> 
	 
	<%if ceng<3 then%><input name="Submit1" type="button" class="inputs" id="Submit1" onClick="window.location='Admin_Sysprovinceandcity.asp?fid=<%=rs("id")%>&ceng=<%=ceng+1%>'" value="子类"> 
	<%end if%>
      <input name="Submit2" type="button" class="inputs" id="Submit2" onClick="window.location='Admin_Sysprovinceandcity.asp?fid=<%=fid%>&id=<%=rs("id")%>&step=mod&ceng=<%=ceng%>#modi'" value="修改">
        <input name="Submit3" type="button" class="inputs" id="Submit3" onClick="window.location='Admin_Sysprovinceandcity.asp?fid=<%=fid%>&id=<%=rs("id")%>&step=del&ceng=<%=ceng%>'" value="删除">
    </td>
  </tr>
  <%rs.movenext                                             
loop   
end if                                   
rs.close                                             
set rs=nothing%>
</table>
<%if request("step")<>"mod" then%>
<table width="98%" border="0" align="center" cellpadding="2" cellspacing="1" class="tableBorder">
  <tr>
    <th class="tableHeaderText" colspan=7 height=25>新增分类</th>
  </tr>
  <form name="addpc" action="Admin_Sysprovinceandcity.asp?step=add&fid=<%=fid%>&ceng=<%=ceng%>" method="post">
    <tr>
      <td width="12%" align="right">中文名称：</td>
      <td width="20%"><input type="text" name="province_city"></td>
      <td width="10%" align="right">英文名称：</td>
      <td width="19%"><input name="enprovince_city" type="text"></td>
      <td width="6%" align="right">排序：</td>
      <td width="16%"><input name="enprovince_order" type="text" size="6" value="0"></td>
      <td width="17%"><input name="Submit4" type="submit" class="inputs" value="提交"></td>
    </tr>
  </form>
</table>
<%else%>
<a name="modi"></a><table width="98%" border="0" align="center" cellpadding="2" cellspacing="1" class="tableBorder">
  <tr>
    <th class="tableHeaderText" colspan=7 height=25>修改分类</th>
  </tr>
  <%id=request("id")%>
  <form name="addpc" action="Admin_Sysprovinceandcity.asp?step=modi&fid=<%=fid%>&id=<%=id%>&ceng=<%=ceng%>" method="post">
    <% set rsw=conn.execute("select * from JOB_provinceandcity where id="&id)%>
	<tr>
      <td width="12%" align="right">中文名称：</td>
      <td width="20%"><input type="text" name="province_city"  value="<%=rsw("province_city")%>"></td>
      <td width="10%" align="right">英文名称：</td>
      <td width="19%"><input name="enprovince_city" type="text" value="<%=rsw("enprovince_city")%>"></td>
      <td width="7%" align="right">排序：</td>
      <td width="15%"><input name="enprovince_order" type="text" size="6" value="<%=rsw("order")%>"></td>
      <td width="17%"><input name="Submit4" type="submit" class="inputs" value="提交"></td>
    </tr>
	<%
		rsw.close
		set rsw=nothing
	%>
  </form>
</table>
<%end if%>
<!--#include file="../inc/copy.asp" -->
</body>
</html>