<!--#include file="../inc/config.asp"-->
<!--#include file="../inc/conn.asp"-->
<!-- #include file="inc/Session.asp" -->
<!-- #include file="inc/checkrole.asp" -->
<html>
<head>
<title>行业管理</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<style type="text/css">
<!--
body {
	margin-left: 0px;
	margin-top: 0px;
	margin-right: 0px;
	margin-bottom: 0px;
	background-color: #FFFFFF;
}
-->
</style>
<link href="style/global.css" rel="stylesheet" type="text/css">
<style type="text/css">
<!--
.style1 {color: #FF0000}
.style2 {color: #CCCCCC}
.style3 {color: #FFFFFF;
	font-weight: bold;
}
-->
</style>
<script language="javascript">
function check(obj){
	if(obj.Title.value==""){
		alert("行业名称不能为空!");
		obj.Title.focus();
		obj.Title.select();
		return false;
	}
	if(obj.Title.value==""){
		alert("Title不能为空!");
		obj.Title.focus();
		obj.Title.select();
		return false;
	}
	return true;
}
function goto(frm)
{
	var gourl ="?";
	gourl += "page=" + (frm.page.value);
     var hid=parseInt(frm.hid.value);
	 if(parseInt(frm.page.value)>hid||frm.page.value<=0){
	 alert("错误！请确定你输入的数字在1-"+hid+"之间");
	 return false;
	 }
	window.location.href(gourl);
}
function ConfirmDel()
{
   if(confirm("确认删除？并且不能恢复！确定要删除此信息吗？"))
     return true;
   else
     return false;
	 
}
</script>
</head>

<body>
<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
act=trim(request.QueryString("act"))
if isempty(act) or act="" then
	call InnerKeys_List
elseif(act="add") then
	call InnerKeys_Add
elseif(act="addok") then
	call InnerKeys_AddOk
elseif(act="mod") then
	call InnerKeys_Mod
elseif(act="modok") then
	call InnerKeys_ModOk
end if
%>
<%
Sub InnerKeys_Add
	dim pid,ptitle
	pid=Clng(request.QueryString("pid"))
	if(pid=0) then
		ptitle="根目录"
	else
		set rs=server.createobject("adodb.recordset")
		rs.open "select title from t_industry where id="&pid,conn,3,1
		if not rs.eof then
			ptitle=rs(0)
		end if
		rs.close
		set rs=nothing
	end if
%>
<FORM method="POST" name="form1" action="?act=addok" 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="#FF9900">
  <TD height="24" colspan="2"><div align="center" class="style3">添加行业</div></TD>
  </TR>
<TR bgcolor="#F5F5F5">
  <TD width="46%"><div align="right">上级：</div></TD>
  <TD width="54%">
  	<select name="pid">
    	<option value="<%=pid%>"><%=ptitle%></option>
    </select>
  </TD>
</TR>
<TR bgcolor="#F5F5F5">
  <TD width="46%"><div align="right">名称：</div></TD>
  <TD width="54%"><input name="Title" type="text" id="Title" size="35"></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 Sub
Sub InnerKeys_AddOk
	dim title,pid
	title=replace(request.Form("Title"),"'","")
	pid=cint(request.Form("pid"))
	set rs=server.createobject("adodb.recordset")
	rs.open "select top 1 * from t_industry where title='"&title&"'",conn,3,3
	if not rs.eof then
		response.Write("<script>alert(""该关键字已存在!"");history.back();</script>")
		response.End()
	else		
		rs.addnew
		rs("pid")=pid		
		rs("title")=title	
		rs.update	
		response.Write("添加行业成功~!")
		response.Write("<br><a href=industry.asp>返回</a>")
	end if
	rs.close
	set rs=nothing
end Sub
Sub InnerKeys_ModOk
	dim id,title,url
	id=Clng(request.QueryString("id"))
	pid=clng(request.Form("pid"))
	title=request.Form("title")
	set rs=server.createobject("adodb.recordset")
	rs.open "select top 1 * from t_industry where id="&id,conn,3,3
	if not rs.eof then		
		rs("pid")=pid		
		rs("title")=title	
		rs.update	
		response.Write("修改行业成功~!")
		response.Write("<br><a href=""industry.asp"">返回</a>")
	end if
	rs.close
	set rs=nothing
	response.Redirect("industry.asp")
end Sub
Sub InnerKeys_Mod
	dim id,rs,pid,title
	id=Clng(request.QueryString("id"))
	set rs=conn.execute("select * from t_industry where id="&id)
	if not rs.eof then
		pid=rs("pid")
		title=rs("title")
	end if
	rs.close
	set rs=nothing
%>
<FORM method="POST" name="form1" action="?act=modok&id=<%=id%>" 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="#FF9900">
  <TD height="24" colspan="2"><div align="center" class="style3">添加行业</div></TD>
  </TR>
<TR bgcolor="#F5F5F5">
  <TD width="46%"><div align="right">上级：</div></TD>
  <TD width="54%">
  <select name="pid">
  	<option value="0">根目录</option>
  	<%
		dim sel
		set rs=conn.execute("select * from t_industry where pid=0")
		while not rs.eof
			if(rs("id")=pid) then
				sel="selected=""selected"""
			else
				sel=""
			end if
			response.Write("<option value="""&rs("id")&""""&sel&">"&rs("title")&"</option>")
			rs.movenext
		wend
		rs.close
		set rs=nothing
		%>
    
  </select>
  </TD>
</TR>
<TR bgcolor="#F5F5F5">
  <TD width="46%"><div align="right">名称：</div></TD>
  <TD width="54%"><input name="Title" type="text" id="Title" size="35" value="<%=title%>"></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 Sub
Sub InnerKeys_List
	dim BeginTime,i,currentpage,allrec,totalpage,n,p
	BeginTime=Timer
%>
<table width="100%"  border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#999999">
  <tr bgcolor="#FF9900">
    <td height="22" colspan="5"><div align="center"><span class="style3">◆ 管理行业 ◆</span></div></td>
  </tr>
  <tr bgcolor="#EEEEEE">
    <td width="73%" height="22"><div align="center">名称</div></td>    
    <td width="10%"><div align="center">修改</div></td>
    <td width="9%"><div align="center">删除</div></td>
  </tr>
  <tr>
    <td colspan="3" bgcolor="#FFFFFF" style="padding-left:10px; line-height:24px;"><a href="?act=add&pid=0"><strong>添加一级行业</strong></a><a href="industry_genjs.asp"> 生成JS调用</a></td>
  </tr>
  <%
		dim fcity
		set rs=server.createobject("adodb.recordset")
		rs.open "select id,title from t_industry where pid=0",conn,3,1
		if not rs.eof then
			fcity=rs.getrows()
		end if
		rs.close
		set rs=nothing
		if isarray(fcity) then
			for i=0 to ubound(fcity,2)
	%>  
  <tr>
    <td style="padding-left:10px; line-height:24px;" bgcolor="#FFFFFF"><h2><%=fcity(1,i)%> &nbsp;<a href="?act=add&pid=<%=fcity(0,i)%>"><strong>添加二级行业</strong></a></h2></td>    
    <td bgcolor="#FFFFFF"><div align="center"><a href="?act=mod&id=<%=fcity(0,i)%>">修改</a></div></td>
    <td bgcolor="#FFFFFF"><div align="center"><a href="dele.asp?id=<%=fcity(0,i)%>&table=t_industry" onClick="return ConfirmDel()">删除</a></div></td>
  </tr>  
  <%
				set rs=server.createobject("adodb.recordset")
				rs.open "select id,title from t_industry where pid="&fcity(0,i),conn,3,1
				while not rs.eof
	%>
  <tr>
    <td style="padding-left:20px; line-height:24px;" bgcolor="#FFFFFF"><h2><%=rs(1)%></h2></td>    
    <td bgcolor="#FFFFFF"><div align="center"><a href="?act=mod&id=<%=rs(0)%>">修改</a></div></td>
    <td bgcolor="#FFFFFF"><div align="center"><a href="dele.asp?id=<%=rs(0)%>&table=t_industry" onClick="return ConfirmDel()">删除</a></div></td>
  </tr>
  <%
					rs.movenext
				wend
				rs.close
				set rs=nothing
			next
    end if
		set fcity=nothing
  %>
</table>
<%end Sub%>
<table width="100%"  border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td height="40"><div align="center"></div></td>
  </tr>
</table>
</body>
</html>
<%
call connclose()
%>