<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<!--#include file="../Conn/conn.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" />
<link rel="stylesheet" href="../css/indexTwo.css" type="text/css">
<title>网站后台</title>
</head>
<body>
<script type="text/javascript">
function CheckForm()
{
			if(document.form.SortName.value=="")
			{
				alert("请输入新类别名！");
				document.form.SortName.focus();
				return false;
			}
			if(document.form.SortOrder.value=="")
			{
				alert("请输入序号！");
				document.form.SortOrder.focus();
				return false;
			}
			if(isNaN(document.form.SortOrder.value))
			{   
				  alert("序号必须输入整数");
				  return false;
			 }
			
}
</script>
<%
SortID=request("SortID")
if request("action")="edit" then
	Pid=request.Form("Pid")
	SortName=request.Form("SortName")
	SortOrder=request.Form("SortOrder")
	
	sql="select * from TbNewsSort where id="&SortID
	rs.open sql,conn,1,3
	if not rs.eof then
		rs("name")=SortName
		rs("pid")=Pid
		rs("order")=SortOrder
		rs.update
	end if
	rs.close
	response.write "<script> alert('修改成功');window.document.location.href='News_Sort_List.asp';   </script>"
	response.End()
end if
sql="select * from TbNewsSort where id="&SortID
rs.open sql,conn,1,1
if not rs.eof then
	SortName=rs("name")
	SortOrder=rs("order")
end if
rs.close
%>
<table width="100%" border="0" cellspacing="1" class="Navi2">
  <tr>
    <th colspan="2">信息类别添加</th>
    <th><a href="News_Sort_List.asp" class="link2">返回</a></th>
  </tr>
</table>
<form name="form"  method="post" action="?SortID=<%=SortID%>" onsubmit="return CheckForm(this);">
  <input type="hidden" name="action" value="edit" />
  <table width="100%" border="0" cellspacing="1" class="Navi2">
    <tr>
      <td style="width:150px;text-align:right; padding-right:8px;">父类名称</td>
      <td style="text-align:left;padding-left:8px;"><%call pidSort(SortID)%>
      </td>
    </tr>
    <tr>
      <td style="text-align:right; padding-right:8px;">类别名称</td>
      <td style="text-align:left;padding-left:8px;"><input type="text" name="SortName" value="<%=SortName%>" style="width:200px;" maxlength="250" />
      </td>
    </tr>
    <tr>
      <td style="text-align:right; padding-right:8px;">类别序号</td>
      <td style="text-align:left;padding-left:8px;"><input type="text" name="SortOrder" value="<%=SortOrder%>" style="width:200px;" maxlength="250" />
      </td>
    </tr>
    <tr>
      <td colspan="2" style=" text-align:left; padding-left:158px;"><input type="submit" name="submit" value="提交" /></td>
    </tr>
    <tr>
      <td colspan="2">&nbsp;</td>
    </tr>
  </table>
</form>
</body>
</html>
<!--#include file="../Conn/conn_close.asp"-->
<%
sub pidSort(SortID)
	response.Write("<select name='Pid' style='width:200px;'>")
	sql="select * from TbNewsSort where id="&SortID
	rs.open sql,conn,1,1
	if not rs.eof then
		if rs("pid")=0 then
			response.Write("	<option value='0'>根目录</option>")	
		else
			sql2="select * from TbNewsSort where  pid in (select pid from TbNewsSort where id="&rs("pid")&")"
			rs2.open sql2,conn,1,1
			if not rs2.eof then
				do while not rs2.eof
					if clng(rs2("id"))=clng(rs("pid")) then
						response.Write("	<option value='"&rs2("id")&"' selected>"&rs2("name")&"</option>")
					else
						response.Write("	<option value='"&rs2("id")&"'>"&rs2("name")&"</option>")
					end if
					rs2.movenext
				loop
			end if
			rs2.close			
		end if	
	end if
	rs.close
	response.Write("</select>")
end sub
%>
