<!--#include file="conn.asp" -->
<!--#include file="checkout.asp" -->
<%if (session("userkey")=1) then%>
  <script language=javascript>  
    alert( "错误：您无权进行用户管理！"  );
    location.href = "javascript:history.back()"  
  </script>
<%end if%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<meta name="GENERATOR" content="Microsoft FrontPage 4.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<title>添加产品分类</title>
<LINK href="css.css" rel=stylesheet type=text/css>
</head>
<body>
<table width="95%" cellspacing="1" cellpadding="5" bgcolor=#999999 align=center>
  <tr bgcolor=#ffffff><td height=30>
<form method="POST" name="form1">
<%
op=trim(request("op"))
if op="" or op="add" then
	op="add"
	title="添加"
elseif op="update" then
	title="修改"

    id=request("id")
    id=replace(trim(id),"'","")
    id=replace(trim(id)," ","")

	sql="select * from newclass where id="&id&" order by code"
	set rs=server.createobject("adodb.recordset")
	rs.open sql,conn,1,1
	if not rs.eof then
		code=trim(rs("code"))
		'if len(rs("code"))=2 then
			'code_new=right(code,2)
		'elseif len(rs("code"))=3 then
			code_new=right(code,1)
		'end if
		name=trim(rs("name"))
		img=htmlencode1(rs("img"))
		notes=htmlencode1(rs("notes"))
	else
	%>
		<script language="vbscript">
			msgbox "出错：找不到ID=<%=id%>的记录！"
			history.back()
		</script>
	<%
		response.end
	end if
end if
%>
　<div align="center">
  <center>
<table border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" id="AutoNumber1" width="498">
  <tr>
    <td align="right" height="25" bgcolor="#F7F7F7" width="602">
      <div align="center">
        <table border="0" cellpadding="0" cellspacing="0" width="602">
          <tr>
            <td><IMG height=17 src="images/14.gif" width=602></td>
          </tr>
          <tr>
            <td background="images/16.gif" height="100">
              <div align="center">
                <table border="0" cellpadding="0" cellspacing="0" width="95%" height="244">
                  <tr>
                    <td width="19%" height="10" align="right" bgcolor="#F2F2F2">　</td>
                    <td width="81%" height="10" bgcolor="#F2F2F2">
                      　</td>
                  </tr>
                  <tr>
                    <td width="19%" height="25" align="right" bgcolor="#F2F2F2">分类位置：</td>
                    <td width="81%" height="25" bgcolor="#F2F2F2">
                      <p style="margin-left: 5"><select size="1" name="code">
    <option value="">根目录</option>
<%
sql="select * from newclass order by code"
set rs=server.createobject("adodb.recordset")
rs.open sql,conn,1,1
for i=1 to rs.recordcount
	if rs.eof then exit for
	response.write "<option value='"&trim(rs("code"))&"'"
	if op="update" and code<>"" then
		if trim(rs("code"))=left(code,len(code)-1) then
			response.write space(1) & "selected"
		end if
	end if
	response.write ">"
	for j=1 to len(rs("code"))
		response.write "-"
	next
	response.write ">"&trim(rs("code"))&":"&trim(rs("name"))&"</option>"
	rs.movenext
next
response.write "下面"
rs.close
set rs=nothing
%>    
    </select></td>
                  </tr>
                  <tr>
                    <td width="19%" height="25" align="right" bgcolor="#F2F2F2">分类代码：</td>
                    <td width="81%" height="25" bgcolor="#F2F2F2">
                      <p style="margin-left: 5">
                      <input type="text" name="code_new" size="20" maxlength="3" value="<%=code_new%>" style="BORDER-TOP-WIDTH: 1px; BORDER-LEFT-WIDTH: 1px; FONT-SIZE: 12px; BORDER-BOTTOM-WIDTH: 1px; BORDER-RIGHT-WIDTH: 1px"></td>
                  </tr>
                  <tr>
                    <td width="19%" height="25" align="right" bgcolor="#F2F2F2">分类名称：</td>
                    <td width="81%" height="25" bgcolor="#F2F2F2">
                      <p style="margin-left: 5"><input type="text" name="name" size="60" value="<%=name%>" style="BORDER-TOP-WIDTH: 1px; BORDER-LEFT-WIDTH: 1px; FONT-SIZE: 12px; BORDER-BOTTOM-WIDTH: 1px; BORDER-RIGHT-WIDTH: 1px"></td>
                  </tr>
                  <tr>
                    <td width="19%" height="138" align="right" bgcolor="#F2F2F2">分类说明：</td>
                    <td width="81%" height="138" bgcolor="#F2F2F2">
                      <p style="margin-left: 5; margin-top: 5; margin-bottom: 5"><textarea rows="6" name="notes" cols="60" style="BORDER-TOP-WIDTH: 1px; BORDER-LEFT-WIDTH: 1px; FONT-SIZE: 12px; BORDER-BOTTOM-WIDTH: 1px; BORDER-RIGHT-WIDTH: 1px"><%=notes%></textarea></td>
                  </tr>
                  <tr>
                    <td width="100%" height="32" colspan="2">
                      <div align="center">
                        <table border="0" cellpadding="0" cellspacing="0" width="46%">
                          <tr>
                            <td width="50%" height="30">
                              <p align="center">
                              <input type="button" value="<%=title%>" name="B1" onclick="FORM1OK()"></td>
                            <td width="50%">
                              <p align="center"><input type="button" value="返回" name="B2" onclick="window.location.href=news_class.asp'"></td>
                          </tr>
                        </table>
                      </div>
                    </td>
                  </tr>
                </table>
              </div>
            </td>
          </tr>
          <tr>
            <td><IMG height=16 src="images/15.gif" width=602></td>
          </tr>
        </table>
      </div>
    </td>
  </tr>
  <tr> 
    <td width="496" height="20"></td>
  </tr>
</table>
  </center>
</div>
<input type="hidden" name="op" value="<%=op%>">
<input type="hidden" name="id" value="<%=id%>">
</form>
<script language="vbscript">
sub FORM1OK()
	if trim(form1.code_new.value)="" then
		msgbox "请填写代码！"
		form1.code_new.focus()
		exit sub
	end if
	if trim(form1.name.value)="" then
		msgbox "请填写分类名称！"
		form1.name.focus()
		exit sub
	end if

	form1.action="news_class_manage.asp"
	form1.submit()
end sub
</script>
</td>
</tr>
</table>
</body>
</html>

