<%@ codepage ="936" %>
<%charset="gb2312"%>
<%Session.CodePage=936%>
<!--#include file="Admin.asp"-->
<!--#include file="Conn.asp"-->
<!--#include file="Inc/Function.asp"-->
<%
dim Action,BigClassID,SmallClassName,rs,FoundErr,ErrMsg
Action=trim(Request("Action"))
BigClassID=trim(request("BigClassID"))
If BigClassID<>"" Then BigClassName=conn.execute("select bigclassname from NewsbigClass where bigClassID="&CLng(BigClassID))(0)
SmallClassName=trim(request("SmallClassName"))
orders=trim(request("orders"))
If orders="" Then orders=0
show=trim(request("show"))
If show="" Then show=0
if Action="Add" then
	if BigClassID="" then
		FoundErr=True
		ErrMsg=ErrMsg & "<br><li>频道大类名不能为空！</li>"
	end if
	if SmallClassName="" then
		FoundErr=True
		ErrMsg=ErrMsg & "<br><li>频道小类名不能为空！</li>"
	end if
	if FoundErr<>True then
		Set rs=Server.CreateObject("Adodb.RecordSet")
		rs.open "Select * From NewsSmallClass Where BigClassID=" & BigClassID & " AND SmallClassName='" & SmallClassName & "'",conn,1,3
		if not rs.EOF then
			FoundErr=True
			ErrMsg=ErrMsg & "<br><li>“" & BigClassName & "”中已经存在该小类“" & SmallClassName & "”！</li>"
		else
     		rs.addnew
			rs("BigClassID")=BigClassID
    	 	rs("SmallClassName")=SmallClassName
     		rs("orders")=orders
			rs("show")=show
     		rs.update
	     	rs.Close
    	 	set rs=Nothing
     		call CloseConn()
			Response.Redirect "News_ClassManage.asp"  
		end if
	end if
end if
if FoundErr=True then
	call WriteErrMsg()
Else

	tjzShow=0
	If BigClassID<>"" Then 
		sqlt="select show from Newsbigclass where BigClassID=" & BigClassID & ""
		Set rst = Server.CreateObject("ADODB.Recordset")
		rst.Open sqlt,conn,1,1
		If Not(rst.bof And rst.eof) Then
			If rst(0)>0 Then tjzShow=1
		End If
		rst.close
		Set rst=Nothing
	End if
%>
<script language="JavaScript" type="text/JavaScript">
function checkSmall()
{
  if (document.form2.BigClassID.value=="")
  {
    alert("请先选择大类！");
	document.form1.BigClassID.focus();
	return false;
  }

  if (document.form2.SmallClassName.value=="")
  {
    alert("小类名称不能为空！");
	document.form2.SmallClassName.focus();
	return false;
  }
}
</script>
<!-- #include file="Inc/Head.asp" -->
<div align=center>
<TABLE class=tableBorder1 style="WIDTH: 100%" cellSpacing=0 cellPadding=3 
align=center border=0>
  <TBODY>
  <TR>
    <TD height=50></TD></TR></TBODY></TABLE>
<TABLE class=tableBorder cellSpacing=0 cellPadding=0 width="85%" align=center border=0>
	<tr> 
		<TH align=left height=23 class="tableHeaderText"><div align="center"><font color=white>频 道 类 别 设 置</font></div></TH>
	</tr>
	<tr> 
	  <td height="25" class=forumrow>
		<form name="form2" method="post" action="News_ClassAddSmall.asp" onsubmit="return checkSmall()">
        <table width="100%" border="0" align="center" cellpadding="1" cellspacing="2">
          <tr> 
            <td class=forumHeaderBackgroundAlternate height="25" colspan="2" align="center"><strong>添加小类</strong></td>
          </tr>
          <tr> 
            <td class=forumRow_shui width="15%" height="22" align=right><strong>所属大类：</strong></td>
            <td bgcolor="#E3E3E3" width="85%"> 
              <select name="BigClassID">
                <%
	dim rsBigClass
	set rsBigClass=server.CreateObject("adodb.recordset")
	rsBigClass.open "Select * From NewsBigClass",conn,1,1
	if rsBigClass.bof and rsBigClass.bof then
		response.write "<option>请先添加频道大类</option>"
	else
		do while not rsBigClass.eof
			if rsBigClass("BigClassID")=CInt(BigClassID) then
				response.write "<option value='"& rsBigClass("BigClassID") & "' selected>" & rsBigClass("BigClassName") & "</option>"
			else
				response.write "<option value='"& rsBigClass("BigClassID") & "'>" & rsBigClass("BigClassName") & "</option>"
			end if
			rsBigClass.movenext
		loop
	end if
	rsBigClass.close
	set rsBigClass=nothing
	%>
              </select></td>
          </tr>
          <tr> 
            <td class=forumRow_shui height="22" align=right><strong>小类名称：</strong></td>
            <td bgcolor="#E3E3E3">
			<input name="SmallClassName" type="text" size="30" maxlength="30"></td>
          </tr>

          <tr> 
            <td class=forumRow_shui height="25" bgcolor="#C0C0C0"> 
              <div align="right"><strong>排序：</strong></div></td>
            <td bgcolor="#E3E3E3"> 
              <input name="orders" type="text" size="5" maxlength="5" value="0">
            </td>
          </tr>

          <tr<%if tjzShow=0 then response.write " style='display:none;'"%>> 
            <td class=forumRow_shui height="25" bgcolor="#C0C0C0"> 
              <div align="right"><strong>首页推荐值：</strong></div></td>
            <td bgcolor="#E3E3E3"> 
              <input name="show" type="text" size="5" maxlength="5" value="0">　　<font color=#777777>(说明：值越大越靠前显示，最多显示3个)</font>
            </td>
          </tr>

          <tr> 
            <td class=forumRow_shui height="22" align="center">&nbsp; </td>
            <td height="22" align="center" bgcolor="#E3E3E3">
<div align="left">
                <input name="Action" type="hidden" id="Action3" value="Add">
                <input name="Add" type="submit" value=" 添 加 ">
&nbsp;&nbsp;&nbsp;
				<input name="back" type="button" id="back" value=" 返 回 " onclick="history.go(-1);">
              </div></td>
          </tr>
        </table>
</form>
	  </td>
  </tr>
</table>
<!-- #include file="Inc/Foot.asp" -->
</div>
<%
end if
call CloseConn()
%>
