<!--#include file="pysjzx_conn.asp"-->
<!--#include file="session.asp"-->
<html><head><title>品牌管理</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<link href="../css/style.css" rel="stylesheet" type="text/css">
<script>
function IsDigit()
{
  return ((event.keyCode >= 48) && (event.keyCode <= 57));
}
</script>
<SCRIPT language=javaScript>
<!--
function mOvr(src,clrOver){ 
	if (!src.contains(event.fromElement)) { 
		src.bgColor = clrOver; 
	}
}
function mOut(src,clrIn)  { 
	if (!src.contains(event.toElement)) { 
		src.bgColor = clrIn; 
	}
} 
//-->
</SCRIPT>
</head>
<body>
<%

'-------------- 添加 --------------
if request("action")="add" then
	letter=trim(request("letter"))
	anclass=trim(request("anclass"))
	anclassidorder=request.form("anclassidorder")
	If letter="" Then
		response.write "字母不能为空！<a href=javascript:history.go(-1)>返回重新填写</a>！"
		response.end
	end if
	If anclass="" Then
		response.write "品牌名称不能为空！<a href=javascript:history.go(-1)>请返回重新填写</a>！"
		response.end
	end if
	If anclassidorder="" Then
		response.write "排序不能为空！请<a href=javascript:history.go(-1)>返回重新填写</a>！"
		response.end
	end if
Set rs = Server.CreateObject("ADODB.Recordset")
rs.open "select * from anclass",conn,1,3
rs.addnew
rs("letter")=letter
rs("anclass")=anclass
rs("anclassidorder")=anclassidorder
rs.update
rs.close
set rs=nothing
response.write "<script language=javascript>alert('品牌添加成功！');window.location.href='anclass.asp';</script>"
end if

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


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

%> 

                              <div align="center">
                              <table class="tableBorder" width="90%" border="1" cellpadding="3" cellspacing="1" bgcolor="#FFFFFF" style="border-collapse: collapse" bordercolor="#C0C0C0">
							  <tr>
							  <td colspan="4" bgcolor="#E8F1FF" >
								<p align="center">
								<span lang="zh-cn">品牌管理</span></th>
							  </tr>
                                <tr > 
                                   <td class="forumRowHighlight" width="15%" align="center">
									开头字母</td>
                                   <td class="forumRowHighlight" width="55%" align="center">
									品牌名称</td>
                                   <td class="forumRowHighlight" width="15%" align="center">排序</td>
                                   <td class="forumRowHighlight" width="15%" align="center">
									选择</td>
                                </tr>                                <form name="form" method="post" action="anclass.asp?action=update">
                                <%set rs=server.CreateObject("adodb.recordset")
		  rs.Open "select * from anclass order by anclassidorder ",conn,1,1
		  dim paixu
		  	  paixu=1
		  if rs.EOF and rs.BOF then
		  response.Write "<div align=center><font color=red>还没有分类</font></center>"
		    paixu=0
		  else
		  do while not rs.EOF
		  %>

                                 
                               <tr  onmouseout="mOut(this,'#Ffffff');" onmouseover="mOvr(this,'#FFD28E');"> 
                                     <td class="forumRowHighlight">&nbsp;<input name="letter" type="text"  size="4" maxlength=1 value="<%=rs("letter")%>">
                                     <input type="hidden" name="anclassid" value="<%=rs("anclassid")%>">
                                     </td>
                                     <td class="forumRowHighlight"><input name="anclass" type="text" id="anclass" size="25" value="<%=trim(rs("anclass"))%>"></td>
                                       <td class="forumRowHighlight"><%=paixu%>　<input name="anclassidorder" type="text" id="anclassidorder" size="4" value="<%=int(rs("anclassidorder"))%>"  ONKEYPRESS="event.returnValue=IsDigit();">
                                    	</td>
                                   
                                     <td class="forumRowHighlight">
<input name="selectid" type="checkbox" id="selectid" value="<%=rs("anclassid")%>" ></td>
                                  </tr><%rs.MoveNext
                                  paixu=paixu+1
								loop
								paixu=rs.RecordCount
								end if%> <tr align="center"> 
                                     <td class="forumRowHighlight" colspan="4"> 
          <p align="right">全选 
<input type="checkbox" name="checkbox" value="Check All" onClick="mm()">&nbsp;&nbsp; </td>
                                  </tr>
								<tr align="center"> 
                                     <td class="forumRowHighlight" colspan="4"> 
          <input class=button type="submit" name="Submit2" value="保存修改" >
          &nbsp; 
          <input class=button type="reset" value="重新设定" name="重置">&nbsp;&nbsp; 
          <input class=button type="submit" name="Submit" value="删除" onClick="return del();" ></td>
                                  </tr>
                                </form>
						
								</table></div>
<br>
<div align="center">
<table class="tableBorder" width="90%" border="1" cellpadding="3" cellspacing="1" bgcolor="#FFFFFF" style="border-collapse: collapse" bordercolor="#C0C0C0">
<tr>
<td colspan="4" bgcolor="#E8F1FF" >
<p align="center"><span style="font-weight: 400">品牌添加</span></td>
</tr>
<form name="form1" method="post" action="anclass.asp?action=add">
<tr align="center"> 
 <td class="forumRowHighlight" width=15%>
<input name="letter" type="text"  size="4" maxlength=1 ></td>
 <td class="forumRowHighlight" width=55%>
<input name="anclass" type="text" id="anclass2" size="25"></td>
 <td class="forumRowHighlight" width=15%>
<input name="anclassidorder" type="text" id="anclassidorder" size="4" value="<%=paixu+1%>"  ONKEYPRESS="event.returnValue=IsDigit();">
</td>
 <td class="forumRowHighlight" width=15%>
<input type="submit" name="Submit3" value="添 加">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;

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