<!--#include file="pysjzx_conn.asp"-->
<!--#include file="session.asp"-->
<html>
<head>
<title>系列管理</title>
<script>
function IsDigit()
{
  return ((event.keyCode >= 48) && (event.keyCode <= 57));
}
</script>
<link href="../css/style.css" rel="stylesheet" type="text/css">
<body>
<%
'-------------- 添加 --------------
if request("action")="add" then
	anclassid=request("anclassid")
	nclass=trim(request("nclass"))
	nclassidorder=request.form("nclassidorder")
	If nclass="" Then
		response.write "系列不能为空！<a href=javascript:history.go(-1)>请返回重新填写</a>！"
		response.end
	end if
	If nclassidorder="" Then
		response.write "排序不能为空！请<a href=javascript:history.go(-1)>返回重新填写</a>！"
		response.end
	end if
Set rs = Server.CreateObject("ADODB.Recordset")
rs.open "select * from nclass",conn,1,3
rs.addnew
rs("anclassid")=anclassid
rs("nclass")=nclass
rs("nclassidorder")=nclassidorder
rs.update
rs.close
set rs=nothing
response.write "<script language=javascript>alert('系列添加成功！');window.location.href='nclass.asp?anclassid="&anclassid&"';</script>"
end if


'-------------- 修改 --------------
if request("action")="update" then
	anclassid2=request("anclassid2")
    for i=1 to request.form("nclassid").count
    anclassid=replace(request.form("anclassid3")(i),"'","")
	nclassid=replace(request.form("nclassid")(i),"'","")
	nclass=replace(request.form("nclass")(i),"'","")
	nclassidorder=replace(request.form("nclassidorder")(i),"'","")
	if replace(request.form("nclassidorder")(i),"'","")="" then
%>
<script language=javascript>
history.back()
alert("请填写排序！")
</script>
<%
		Response.End
	end if
	conn.execute("update nclass set nclassidorder='"&nclassidorder&"',nclass='"&nclass&"',anclassid='"&anclassid&"' where nclassid="&nclassid)
    next
response.write "<script language=javascript>alert('系列修改成功！');window.location.href='nclass.asp?anclassid="&anclassid2&"';</script>"
end if

'-------------- 删除 --------------
if request("submit")="删除" then
selectid=request("selectid")
if selectid<>"" then
conn.execute "delete from nclass where nclassid in ("&selectid&")"
response.Redirect "nclass.asp?anclassid="&anclassid
response.End
end if
end if

anclassid=int(request("anclassid"))
%>
<div align="center">
<table cellpadding="3" cellspacing="1" border="1" width="100%" class="tableBorder" style="border-collapse: collapse" bordercolor="#C0C0C0">
<form name="form" method="post" action="nclass.asp?action=update">
	<tr> 
	  <td class="tableHeaderText" colspan=5 height=20 bgcolor="#E8F1FF">
		<p align="center">系列设置</td>
  </tr>
      <tr> 
        <td colspan="5" align="center" class="forumRowHighlight" bgcolor="#F7F7F7" >
		<p align="left">&nbsp;
<%
Set rs_s = Server.CreateObject("ADODB.Recordset")
rs_s.open "SELECT  * from anclass  order by anclassidorder",conn,1,1
while not rs_s.eof
if letter <> rs_s("letter") then
response.write "<br>"
end if
response.write "[<a href=nclass.asp?anclassid="&rs_s("anclassid")&">"
if rs_s("anclassid")=anclassid then%><font color="#FF0000"><%end if%>
<%response.write rs_s("letter")&"-"&rs_s("anclass")&"</a></font>]&nbsp;&nbsp;"
letter=rs_s("letter")
rs_s.movenext
wend
rs_s.close
set rs_s=nothing
%>
        </td>
      </tr>
      <tr align=center height=25> 
        <td class="forumRowHighlight" bgcolor="#F7F7F7">序号</td>
        <td class="forumRowHighlight" bgcolor="#F7F7F7">品牌</td>
        <td class="forumRowHighlight" bgcolor="#F7F7F7">系列</td>
        <td class="forumRowHighlight" bgcolor="#F7F7F7">排序(必填项，数字)</td>
        <td class="forumRowHighlight" bgcolor="#F7F7F7">删除</td>
      </tr>
<%
Set rs = Server.CreateObject("ADODB.Recordset")
if anclassid<>"" then
  rs.open "SELECT  * from nclass  where anclassid="&anclassid&" order by nclassidorder",conn,1,1
else
  rs.open "SELECT  * from nclass  where 1<> 1 order by nclassidorder",conn,1,1
end if
if rs.recordcount=0 then 
%>
      <tr> 
        <td colspan="5"align="center" width="100%" class="forumRowHighlight" bgcolor="#F7F7F7"> 
		还没有添加系列</td>
      </tr>
<%
else
    do while not rs.eof
%>
      <tr> 
        <td align=center class="forumRowHighlight" bgcolor="#F7F7F7"><%=rs("nclassID")%></td>
        <td align=center class="forumRowHighlight" bgcolor="#F7F7F7"> 
          <select name="anclassid3" size="1">
<%
Set rs_s = Server.CreateObject("ADODB.Recordset")
rs_s.open "SELECT  * from anclass  order by anclassidorder",conn,1,1
while not rs_s.eof
%>
<option value="<%=rs_s("anclassid")%>" <%if rs_s("anclassid")=rs("anclassid") then%>selected<%end if%>><%=rs_s("anclass")%></option>
<%
rs_s.movenext
wend
rs_s.close
set rs_s=nothing
%>
          </select>
        </td>
        <td align=center class="forumRowHighlight" bgcolor="#F7F7F7">
          <input type="hidden" name="nclassid" value="<%=rs("nclassid")%>">
          <input class=text type="text" name="nclass" size="30" value="<%=trim(rs("nclass"))%>">
        </td>
        <td align=center class="forumRowHighlight" bgcolor="#F7F7F7"> 
          <input class=text type="text" name="nclassidorder" size="10" value="<%=rs("nclassidorder")%>" ONKEYPRESS="event.returnValue=IsDigit();" >
        </td>
        <td align=center class="forumRowHighlight" bgcolor="#F7F7F7"> 
<input name="selectid" type="checkbox" id="selectid" value="<%=rs("nclassid")%>" ></td>
      </tr>
      <%
    rs.MoveNext
    Loop
%>
      <tr> 
        <td colspan="5" align="center" width="100%" class="forumRowHighlight" bgcolor="#F7F7F7"> 
          <p align="right">全选 
<input type="checkbox" name="checkbox" value="Check All" onClick="mm()">&nbsp;&nbsp; 
        </td>
      </tr>
      <tr> 
        <td colspan="5" align="center" width="100%" class="forumRowHighlight" bgcolor="#F7F7F7"> 
          <input class=button type="submit" name="Submit2" value="保存修改" >&nbsp; 
          <input class=button type="reset" value="重新设定" name="重置" >
          <input type="hidden" name="anclassid2" value="<%=anclassid%>">
        &nbsp;<input class=button type="submit" name="Submit" value="删除" onClick="return del();" ></td>
      </tr>
<%
end if

%>
    </form>
    <form name="form2" method="post" action="nclass.asp?action=add">
      <tr> 
        <td align=center class="forumRowHighlight" bgcolor="#F7F7F7">添加系列</td>
        <td align=center class="forumRowHighlight" bgcolor="#F7F7F7"> 
          <select name="anclassid" size="1">
<%
Set rs_s = Server.CreateObject("ADODB.Recordset")
rs_s.open "SELECT  * from anclass  order by anclassidorder",conn,1,1
while not rs_s.eof
%>
<option value="<%=rs_s("anclassid")%>" <%if rs_s("anclassid")=anclassid then%>selected<%end if%>><%=rs_s("letter")%>-<%=rs_s("anclass")%></option>

<%
rs_s.movenext
wend
rs_s.close
set rs_s=nothing
rs.close
set rs=nothing
%>
          </select>
        </td>
        <td align=center class="forumRowHighlight" bgcolor="#F7F7F7"> 
          <input class=text type="text" name="nclass" size="30">
        </td>
        <td align=center class="forumRowHighlight" bgcolor="#F7F7F7"> 
          <input class=text type="text" name="nclassidorder" size="10" ONKEYPRESS="event.returnValue=IsDigit();">
        </td>
        <td align=center class="forumRowHighlight" bgcolor="#F7F7F7"> 
          <input class=button type="submit" name="Submit2" value="添加">
        </td>
      </tr>
    </form>
</table>
</div>
</body>
</html> 
<script>
function del()
{
  if(!confirm('确认删除吗？')) return false;
}
</script>
<script language=javascript>
function mm()
{
   var a = document.getElementsByTagName("input");
   if(a[0].checked==true){
   for (var i=0; i<a.length; i++)
      if (a[i].type == "checkbox") a[i].checked = false;
   }
   else
   {
   for (var i=0; i<a.length; i++)
      if (a[i].type == "checkbox") a[i].checked = true;
   }
}
</script> 