<% userPageRights="{info}" %>
<!--#include file="check.asp"-->
<%
dim Action,BigClassName,SmallClassName,rs,FoundErr,ErrMsg
Action=trim(Request("Action"))
m_bigid=trim(request("bigid"))
SmallClassName=trim(request("SmallClassName"))
if Action="Add" then
	if m_bigid="" then
		FoundErr=True		
		response.write"<SCRIPT language=JavaScript>alert('请选择大类！');"
        response.write"this.location.href='javascript:history.back();'</SCRIPT>"
        response.end 
	end if
	if SmallClassName="" then
		FoundErr=True
		
		response.write"<SCRIPT language=JavaScript>alert('小类名不能为空！');"
        response.write"this.location.href='javascript:history.back();'</SCRIPT>"
        response.end 
	end if
	if FoundErr<>True then
		Set rs=Server.CreateObject("Adodb.RecordSet")
		rs.open "Select * From info_SmallClass Where f_bigclassid=" & m_bigid & " AND f_value='" & SmallClassName & "'",conn,1,3
		if not rs.EOF then
			FoundErr=True
		response.write"<SCRIPT language=JavaScript>alert('该大类中已经存在小类[" & SmallClassName & "]！');"
        response.write"this.location.href='javascript:history.back();'</SCRIPT>"
        response.end 		
		else
     		rs.addnew
			rs("f_bigclassid")=m_bigid
    	 	rs("f_value")=SmallClassName
			rs("f_index")=request("f_index")
     		rs.update
	     	rs.Close
    	 	set rs=Nothing
     		conn.close
			set conn=nothing
			Response.Redirect "admin_infoclass.asp"  
		end if
	end if
end if

%>
<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>

<link href="Images/Style.css" rel="stylesheet" type="text/css">

<table width="100%" height="100%" border="0" cellpadding="0" cellspacing="0">
  <tr> 
    <td align="center" valign="top"> <br> <br>
      <strong>产 品 类 别 设 置</strong> <br> <br> <br> <form name="form2" method="post" action="ClassAddSmall.asp" onsubmit="return checkSmall()">
        <table width="350" border="0" align="center" cellpadding="0" cellspacing="2" class="border">
          <tr bgcolor="#CCCCCC" class="title"> 
            <td height="25" colspan="2" align="center"><strong>添加小类</strong></td>
          </tr>
          <tr bgcolor="f2f2f2" class="tdbg"> 
            <td width="126" height="22"><strong>所属大类：</strong></td>
            <td width="218"> 
              <select name="bigid">
                <%
	dim rsBigClass
	set rsBigClass=server.CreateObject("adodb.recordset")
	rsBigClass.open "Select * From info_BigClass",conn,1,1
	if rsBigClass.bof and rsBigClass.bof then
		response.write "<option>请先添加大类</option>"
	else
		do while not rsBigClass.eof
			if rsBigClass("f_value")=request("BigClassName") then
				response.write "<option value='"& rsBigClass("f_id") & "' selected>" & rsBigClass("f_value") & "</option>"
			else
				response.write "<option value='"& rsBigClass("f_id") & "'>" & rsBigClass("f_value") & "</option>"
			end if
			rsBigClass.movenext
		loop
	end if
	rsBigClass.close
	set rsBigClass=nothing
	%>
              </select></td>
          </tr>
          <tr bgcolor="f2f2f2" class="tdbg"> 
            <td width="126" height="22"><strong>小类名称：</strong></td>
            <td> 
              <input name="SmallClassName" type="text" size="20" maxlength="30"></td>
          </tr>
		     <tr bgcolor="f2f2f2" class="tdbg"> 
            <td width="126" height="22"><strong>排序：</strong></td>
            <td><input name="f_index" type="text" id="f_index" value="0" size="5">
              <font color="#FF0000">越大越优先</font></td>
          </tr>
          <tr bgcolor="f2f2f2" class="tdbg"> 
            <td height="22" align="center">&nbsp; </td>
            <td height="22" align="center"> 
              <div align="left"> 
                <input name="Action" type="hidden" id="Action3" value="Add">
                <input name="Add" type="submit" value=" 添 加 ">
              </div></td>
          </tr>
        </table>
      </form></td>
  </tr>
</table>

<%

conn.close
set conn=nothing
%>