<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<!--#include file="conn.asp"-->
<!--#include file="admin.asp"-->
<!-- #include file="Inc/Head.asp" -->
<%
dim Action,BigClassName,SmallClassName,rs,FoundErr,ErrMsg
Action=trim(Request("Action"))
BigClassName=trim(request("BigClassName"))
SmallClassName=trim(request("SmallClassName"))
wlink=trim(request("wlink"))
linktarg=trim(request("linktarg"))
paixvid=trim(request("paixvid"))
conclass=trim(request("conclass"))
if Action="Add" then
	if BigClassName="" 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 SmallClass_New Where BigClassName='" & BigClassName & "' AND SmallClassName='" & SmallClassName & "'",conn,1,3
		if not rs.EOF then
			FoundErr=True
			ErrMsg=ErrMsg & "<br><li>“" & BigClassName & "”中已经存在文章小类“" & SmallClassName & "”！</li>"
		else
     		rs.addnew
			rs("BigClassName")=BigClassName
    	 	rs("SmallClassName")=SmallClassName
			rs("wlink")=wlink
			rs("linktarg")=linktarg
			rs("paixv")=paixvid
			rs("conclass")=conclass
     		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.form2.BigClassName.value=="")
  {
    alert("请先添加大类名称！");
	document.form1.BigClassName.focus();
	return false;
  }

  if (document.form2.SmallClassName.value=="")
  {
    alert("小类名称不能为空！");
	document.form2.SmallClassName.focus();
	return false;
  }
}
</script>
<table width="100%" height="100%" border="0" cellpadding="0" cellspacing="0">
  <tr> 
    <td width="150" align="center" valign="top" bgcolor="#A0CCD8"><!-- #include file="info_left.asp" --></td>
    <td align="center" valign="top"> <table width="100%" border="0" cellpadding="0" cellspacing="0">
  <tr> 
    <td align="center" valign="top"> <table width="100%" height="0"  border="0" cellpadding="5" cellspacing="0">
      <tr>
        <td height="24" background="image/usercenter_3.jpg">
          <div align="center"><a href="ClassManage.asp"><strong><font color="#FFFFFF">新 闻 类 别 设 置</font></strong></a> </div></td>
      </tr>
    </table>          
      <table width="100%" border="0" align="center" cellpadding="0" cellspacing="1" class="border">
	  <form name="form2" method="post" action="News_ClassAddSmall.asp" onSubmit="return checkSmall()">
          <tr bgcolor="#C2DAE1" class="title"> 
            <td height="25" colspan="2" align="center"><strong>添加小类</strong></td>
          </tr>
          <tr class="tdbg"> 
            <td width="100" height="22" bgcolor="#C2DAE1"><strong>所属大类：</strong></td>
            <td width="534" bgcolor="#EFEEE9"> 

			<input name="BigClassName" type="text" id="BigClassName" value="<%=BigClassName%>" size="20" maxlength="30" readonly="">
			<%
			dim rsBigClass,rsSmallClass_New,paixvid
			set rsBigClass=server.CreateObject("adodb.recordset")
			rsBigClass.open "Select * From BigClass_New where BigClassName='"&BigClassName&"'",conn,1,1
			
			set rsSmallClass_New=server.CreateObject("adodb.recordset")
			rsSmallClass_New.open "Select count(*) as curpaixv From SmallClass_New where BigClassName='"&BigClassName&"'",conn,1,1
			if rsSmallClass_New("curpaixv")=0 then
				paixvid=rsBigClass("BigClassID")+10
			else
				set rspaixv=server.CreateObject("adodb.recordset")
				rspaixv.open "Select max(paixv) as curpaixvid From SmallClass_New where BigClassName='"&BigClassName&"'",conn,1,1
				paixvid=rspaixv("curpaixvid")+1
			end if
			
			%>
			<input name="paixvid" type="hidden" id="paixvid" value="<%=paixvid%>" size="20" maxlength="30"></td>
          <%
		    rspaixv.close
		    rsSmallClass_New.close
			rsBigClass.close
			%>
		  </tr>
          <tr class="tdbg"> 
            <td width="100" height="22" bgcolor="#C2DAE1"><strong>小类名称：</strong></td>
            <td bgcolor="#EFEEE9"> <input name="SmallClassName" type="text" size="20" maxlength="30"></td>
          </tr>
		  <tr class="tdbg"> 
            <td width="100" height="22" bgcolor="#C2DAE1"><strong>外链接：</strong></td>
            <td bgcolor="#EFEEE9"> <input name="wlink" type="text" value="No" size="40" maxlength="100">
           &nbsp;
           <select name="linktarg" id="linktarg">
		     <option value="_self" selected>_self</option>
             <option value="_blank">_blank</option>
             <option value="_parent">_parent</option>
             <option value="_top">_top</option>
           </select> 
           链接到外部地址，此项根据网站的需要可选。</td>
          </tr>
		  <tr class="tdbg"> 
            <td width="100" height="22" bgcolor="#C2DAE1"><strong>小类名称：</strong></td>
            <td bgcolor="#EFEEE9">
			<select name="conclass" id="conclass">
              <option>信息类</option>
              <option>图片类</option>
              <option>简介类</option>
			  <option>外链接</option>
            </select>
              请选择栏目类型。</td>
          </tr>
          <tr class="tdbg"> 
            <td width="100" height="22" align="center" bgcolor="#C2DAE1">&nbsp; </td>
            <td height="22" align="center" bgcolor="#EFEEE9"> <div align="left"> 
                <input name="Action" type="hidden" id="Action3" value="Add">
                <input name="Add" type="submit" value=" 添 加 ">
              </div></td>
          </tr>
		  </form>
        </table>
      </td>
  </tr>
</table>
<%
end if
%>
</td>
  </tr>
</table>
<!-- #include file="Inc/Foot.asp" -->