<%@language=vbscript codepage=936 %>
<!--#include file="../../Inc/conn.asp"-->
<!--#include file="../admin.asp"-->
<!-- #include file="../Inc/Head.asp" -->
<%
dim Action,BigClassName,SmallClassName,rs,FoundErr,ErrMsg
Action=ChkFormStr(Request("Action"))
BigClassID=strToNum(request("BigClassID"))
SmallClassName=ChkFormStr(request("SmallClassName"))
OrderID=strToNum(request("OrderID"))
IsShow=strToNum(request("IsShow"))
if Action="Add" then
	if BigClassID=0 then
		FoundErr=True
		ErrMsg=ErrMsg & "<br><li>大栏目不能为空！</li>"
	end if
	if SmallClassName="" then
		FoundErr=True
		ErrMsg=ErrMsg & "<br><li>小栏目名不能为空！</li>"
	end if
	Set Brs=Conn.Execute("Select BigClassName From BigClass_New Where BigClassID="&BigClassID&"")
		If Brs.Bof And Brs.Eof Then
			FoundErr=True
			ErrMsg=ErrMsg & "<br><li>大栏目不存在或已被删除！</li>"
		Else
			BigClassName=Brs("BigClassName")
		End If
	Brs.Close:Set Brs=Nothing	
		if FoundErr<>True then
			Set rs=Server.CreateObject("Adodb.RecordSet")
			rs.open "Select * From SmallClass_New 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("BigClassName")=BigClassName
					rs("SmallClassName")=SmallClassName
					rs("OrderID")=OrderID
					if IsShow=1 Then
						rs("IsShow")=true
					else
						rs("IsShow")=false
					end if
     		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
%>
<script language="JavaScript" type="text/JavaScript">
function checkSmall()
{
  if (document.AddBigForm.BigClassID.value=="")
  {
    alert("请先添加大栏目名称！");
	document.AddBigForm.BigClassID.focus();
	return false;
  }

  if (document.AddBigForm.SmallClassName.value=="")
  {
    alert("小栏目名称不能为空！");
	document.AddBigForm.SmallClassName.focus();
	return false;
  }
}
</script>
<form name="AddBigForm" method="post" action="News_ClassAddSmall.asp" onSubmit="return checkSmall();">
  <table width="100%" border="0" align="center" cellpadding="3" cellspacing="1" class="table_southidc">
    <tr bgcolor="#A4B6D7" class="title">
      <td height="25" colspan="2" align="center" bgcolor="#A4B6D7"><strong>添加小栏目</strong></td>
    </tr>
    <tr class="tdbg">
      <td height="22" align="right" bgcolor="#C0C0C0" class="tr_southidc"><strong>所属大类：</strong></td>
      <td width="497" bgcolor="#E3E3E3" class="tr_southidc"><select name="BigClassID">
        <%
	dim rsBigClass
	set rsBigClass=server.CreateObject("adodb.recordset")
	rsBigClass.open "Select * From BigClass_New",conn,1,1
	if rsBigClass.bof and rsBigClass.bof then
		response.write "<option>请先添加文章大类</option>"
	else
		do while not rsBigClass.eof
			if rsBigClass("BigClassID")=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 class="tdbg">
      <td height="22" align="right" bgcolor="#C0C0C0" class="tr_southidc"><strong>小类名称：</strong></td>
      <td bgcolor="#E3E3E3" class="tr_southidc"><input name="SmallClassName" type="text" size="20" maxlength="30"></td>
    </tr>
            <tr bgcolor="#C0C0C0" class="tdbg">
              <td height="22" align="right" class="tr_southidc"><strong>排列顺序：</strong></td>
              <td height="22" align="left" class="tr_southidc"><input name="OrderID" type="text" id="OrderID" value="0" size="5"></td>
            </tr>
            <tr bgcolor="#C0C0C0" class="tdbg">
              <td height="22" align="right" class="tr_southidc"><strong>是否显示：</strong></td>
              <td height="22" align="left" class="tr_southidc"><label>
                <input name="IsShow" type="checkbox" id="IsShow" value="1" checked>
              </label></td>
            </tr>
    <tr class="tdbg">
      <td height="22" align="center" bgcolor="#C0C0C0" class="tr_southidc">&nbsp;</td>
      <td height="22" align="center" bgcolor="#E3E3E3" class="tr_southidc"><div align="left">
        <input name="Action" type="hidden" id="Action3" value="Add">
        <input name="Add" type="submit" value="确认添加">
      &nbsp;
      <input type="button" name="Submit" value="返回上一页" onClick="history.go(-1);">
      </div></td>
    </tr>
  </table>
</form>
<%
end if
%>
<!-- #include file="../Inc/Foot.asp" -->