<!--#include file="conn.asp"-->
<%
if session("admin")="" then
conn.close
set conn = nothing
response.Write "<script language='javascript'>alert('请先登录！');location.href='index.asp' ;</script>"
response.End
else
if request.cookies("sundxshop")("admin")="" then
conn.close
set conn = nothing
response.Write "<script language='javascript'>alert('请先登录！');location.href='index.asp' ;</script>"
response.End
end if
end if


dim id
id=SafeRequest("id",1)
%>
<%
dim sortsid,i,strsql,strcat,strsorts,catid
catid = SafeRequest("aid",1)
sortsid=SafeRequest("nid",1)

set rs = server.CreateObject("adodb.recordset")
rs.open "select category from category where categoryid="&catid&" ",conn,1,1
strcat = rs("category")
rs.close
if sortsid<>"" then
rs.open "select sorts from sorts where sortsid="&sortsid&" ",conn,1,1
strsorts = rs("sorts")
rs.close
end if
%>
<%
dim selectm,selectkey,selectid
selectkey=trim(request.form(trim("selectkey")))
selectm=trim(request.form("selectm"))
if selectkey="" then
selectkey=FormatSQL(request.QueryString("selectkey"))
end if
if selectm="" then
selectm=FormatSQL(request.QueryString("selectm"))
end if

selectid=request.form("selectid")
if selectid<>"" then
if session("rank")>2 then
conn.close
set conn = nothing
response.Write "<script language='javascript'>alert('你无权管理商品！');history.go(-1);</script>"
response.End
end if
conn.execute "delete from product where id in ("&selectid&")"
response.Redirect "editproallcat.asp"
response.End
end if
%>
<title>编辑商品属性</title>
<link href="css.css" rel="stylesheet" type="text/css">

<body>
<table width="98%" border="0" align="center" cellpadding="1" cellspacing="1" BGCOLOR="#39867B">
  <tr> 
    <td align="center"><font color="#FFFFFF">商品查询</font></td>
  </tr>
  <tr bgcolor="#FFFFFF"> 
    <form name="form2" method="post" action="editproall.asp">
      <td>
	  <table width="80%" border="0" align="center" cellpadding="1" cellspacing="1" bgcolor="#CCCCCC">
          <tr bgcolor="#FFFFFF" align="center"> 
            <td width="35%"> <input name="selectkey" type="text" id="selectkey" onFocus="this.value=''" value="请输入关健字"> 
            </td>
            <td width="45%"> <select name="selectm" id="select">
                <OPTION VALUE="name">按商品名称</OPTION>
                <OPTION VALUE="zuozhe">按品牌类别</OPTION>
                <OPTION VALUE="chubanshe">按商品简介</OPTION>
              </select> </td>
            <td width="20%"><input type="submit" name="Submit" value="查 询" onClick="return chkkey();"></td>
          </tr>
        </table></td>
    </form>
  </tr>
</table>
<table width="780" border="0" align="center" cellpadding="0" cellspacing="1" BGCOLOR="#39867B">
  <tr > 
    <td height="20" align="right" colspan="5" ><font color="#FFFFFF">商品查看与修改----</font><font color="#FF0000"><b><%=strcat %>--<%=strsorts %></b></font></td><td height="20" align="right"  colspan="5"><select NAME="select" ONCHANGE="var jmpURL=this.options[this.selectedIndex].value ; if(jmpURL!='') {window.location=jmpURL;} else {this.selectedIndex=0 ;}" ><BASE TARGET=Right> 
<OPTION selected>通过分类修改</OPTION>
<%   Dim rs2
	  set rs2= server.CreateObject("adodb.recordset")
	  rs2.open "select categoryid,category from category where first=0 order by categoryorder",conn,1,1
	  if rs2.eof and rs2.bof then
	  response.Write "<tr><td align=center>还没有商品分类</td></tr>"
	  else
	  do while not rs2.eof %>

          
          <OPTION value="editproallcat.asp?catid=<% = rs2("categoryid") %>"><% = rs2("category") %></OPTION>
          <% 
	  Dim rs1
	  set rs1 = server.CreateObject("adodb.recordset")
	  rs1.open "select categoryid,sortsid,sorts from sorts where sorts.categoryid="&rs2("categoryid")&" order by sortsorder",conn,1,1
	 do while not rs1.eof %>
          <OPTION value="editproallclass.asp?aid=<% = rs1("categoryid") %>&nid=<% = rs1("sortsid") %>">&nbsp;&nbsp;→<% = rs1("sorts") %></OPTION>
 <%
	  rs1.movenext  %>
              <% if rs1.eof then %>
             
   
<%	  rs1.movenext 
	 end if
	  loop
	  rs1.close
	  set rs1 = nothing %>
            <%
	  rs2.movenext
	  loop
	  rs2.close
	  set rs2 = nothing
	  end if
	  %>   
</select> </td>
  </tr>
 <tr bgcolor="#FFFFFF" align="center" height="20" > 
           <td width="100">商品名称</td>
           
            <td width="36" class=table-youxia>商城价</td>
            <td width="36" class=table-youxia>会员价</td>
            <td width="55" class=table-youxia>商品品牌</td>
            <td width="150" class=table-youxia>商品简介</td>
            <td width="70" class=table-youxia>备注</td>
            <td width="28" class=table-youxia>库存</td>
             <td width="28" class=table-youxia>属性</td>
            <td width="62" class=table-youxia >详细修改</td>
            <td width="24" class=table-youxia>修改</td>
        
 </tr>
<tr> 
    
      <td height="100" bgcolor="#FFFFFF" colspan="10"> 
        <%
				Const MaxPerPage=100
   				dim totalPut   
   				dim CurrentPage
   				dim TotalPages
   				dim j
   				dim sql
    				if Not isempty(SafeRequest("page",1)) then
      				currentPage=Cint(SafeRequest("page",1))
   				else
      				currentPage=1
   				end if
           
set rs=server.CreateObject("adodb.recordset")
			select case selectm
			case ""
            rs.open "select * from product where sortsid="&sortsid&" order by name asc",conn,1,1
		    case "0"
			response.write "<center>请返回选择您要查询的方式！<br><br><a href=javascript:history.go(-1)>点击返回上一页</a></center>"
			response.End
			case "name"
			rs.open "select * from product where name like '%"&selectkey&"%' order by name asc",conn,1,1
			case "zuozhe"
			rs.open "select * from product where brand like '%"&selectkey&"%' order by name asc",conn,1,1
			case "chubanshe"
			rs.open "select * from product where introduce like '%"&selectkey&"%' order by name asc",conn,1,1
		  end select
		   	if err.number<>0 then
				response.write ""
				end if
				
  				if rs.eof And rs.bof then
       				Response.Write "<p align='center' class='contents'> 数据库中暂时无数据！</p>"
   				else
				
  				
   				
	  				totalPut=rs.recordcount

      				if currentpage<1 then
          				currentpage=1
      				end if

      				if (currentpage-1)*MaxPerPage>totalput then
	   					if (totalPut mod MaxPerPage)=0 then
	     					currentpage= totalPut \ MaxPerPage
	   					else
	      					currentpage= totalPut \ MaxPerPage + 1
	   					end if
      				end if

       				if currentPage=1 then
            			showContent
            			showpage totalput,MaxPerPage,"editproallclass.asp?aid="&catid&"&nid="&sortsid&""
       				else
          				if (currentPage-1)*MaxPerPage<totalPut then
            				rs.move  (currentPage-1)*MaxPerPage
            				dim bookbrand
            				bookbrand=rs.bookbrand
            				showContent
             				showpage totalput,MaxPerPage,"editproallclass.asp?aid="&catid&"&nid="&sortsid&""
        				else
	        				currentPage=1
           					showContent
           					showpage totalput,MaxPerPage,"editproallclass.asp?aid="&catid&"&nid="&sortsid&""
	      				end if
	   				end if
   				   				end if

   				sub showContent
       			dim i
	   			i=0%>
          

         <table width="780" border="0" align="center" cellpadding="1" cellspacing="1" class=table-xia >
          
          <%
		  do while not rs.eof%>
          
          <tr bgcolor="#FFFFFF" align="left" height="20" class=table-xia> 
           <form name="myform" method="post" action="saveaddproall.asp?action=edit&id=<%=trim(rs("id"))%>">
           
           <td width="57" align="left" class=table-youxia><input name="name" type="text" id="name" size="18" value="<%=trim(rs("name"))%>"></td>
            
           <td width="39" class=table-youxia><input name="price1" type="text" id="price1" size="6" value="<%=trim(rs("price1"))%>"></td>
           <td width="39" class=table-youxia><input name="price2" type="text" id="price2" size="6" value="<%=trim(rs("price2"))%>"></td>
           <td width="39" class=table-youxia><input name="brand" type="text" id="brand" size="10" value="<%=trim(rs("brand"))%>"></td>
           <td width="169" class=table-youxia><input name="introduce" type="text" id="introduce" size="28" value="<%=trim(rs("introduce"))%>"></td>
           <td width="91" class=table-youxia><input name="grade" type="text" id="grade" size="15" value="<%=trim(rs("grade"))%>"></td>
            <td width="30" class=table-youxia><input name="stock" type="text" id="stock" size="6" value="<%=trim(rs("stock")-1)%>"></td>
          
            <td width="30" class=table-youxia>
                    <select name="recommend" id="recommend">
			<option value="0" <% if rs("recommend")=0 Then Response.write("Selected") %>>普通</option>
                        <option value="1" <% if rs("recommend")=1 Then Response.write("Selected") %>>推荐</option>
                       <option value="2" <% if rs("recommend")=2 Then Response.write("Selected") %>>特价</option>
                     </select>

</td>
            <td width="57" class=table-youxia><a href=editpro.asp?id=<%=rs("id")%> target="_blank">详细</a></td>
           <td width="25" align="right" class=table-youxia><input type="submit" name="Submit" value="修改" ></td></form>
          </tr>
                 
            
         
           
          <%i=i+1
			if i>=MaxPerPage then Exit Do
			rs.movenext
		  loop
		  rs.close
		  set rs=nothing%>
          <tr bgcolor="#FFFFFF">  <table width="95%" border="0" align="center" cellpadding="0" cellspacing="0"><tr>
            <td height="30" colspan="6" align="right"></td>
                &nbsp;&nbsp; </td></tr></table></td>
          </tr>
        </table>
         

<%  
				End Sub   
  
				Function showpage(totalnumber,maxperpage,filename)  
  				Dim n
  				
				If totalnumber Mod maxperpage=0 Then  
					n= totalnumber \ maxperpage  
				Else
					n= totalnumber \ maxperpage+1  
				End If
				
				Response.Write "<form method=Post action="&filename&"?selectm="&selectm&"&selectkey="&selectkey&" >"  
				Response.Write "<p align='center' class='contents'> "  
				If CurrentPage<2 Then  
					Response.Write "<font class='contents'>首 页 上一页</font> "  
				Else  
					Response.Write "<a href="&filename&"?page=1&selectm="&selectm&"&selectkey="&selectkey&" class='contents'>首 页</a> "  
					Response.Write "<a href="&filename&"?page="&CurrentPage-1&"&selectm="&selectm&"&selectkey="&selectkey&" class='contents'>上一页</a> "  
				End If
				
				If n-currentpage<1 Then  
					Response.Write "<font class='contents'>下一页 末 页</font>"  
				Else  
					Response.Write "<a href="&filename&"?page="&(CurrentPage+1)&"&selectm="&selectm&"&selectkey="&selectkey&" class='contents'>"  
					Response.Write "下一页</a> <a href="&filename&"?page="&n&"&selectm="&selectm&"&selectkey="&selectkey&" class='contents'>末 页</a>"  
				End If  
					Response.Write "<font class='contents'> 页次：</font><font class='contents'>"&CurrentPage&"</font><font class='contents'>/"&n&"页</font> "  
					Response.Write "<font class='contents'> 共有"&totalnumber&"种商品 " 
					Response.Write "<font class='contents'>转到第：</font><input type='text' name='page' size=2 maxlength=10 class=smallInput value="&currentpage&">页"  
					Response.Write "&nbsp;<input type='submit'  class='contents' value='跳转' name='cndok' ></form>"  
				End Function  
			%>
    
  </td></tr>
</table>
<table width="98%" border="0" align="center" cellpadding="1" cellspacing="1" BGCOLOR="#39867B">
  <tr> 
    <td align="center"><font color="#FFFFFF">商品查询</font></td>
  </tr>
  <tr bgcolor="#FFFFFF"> 
    <form name="form2" method="post" action="editproall.asp">
      <td>
	  <table width="80%" border="0" align="center" cellpadding="1" cellspacing="1" bgcolor="#CCCCCC">
          <tr bgcolor="#FFFFFF" align="center"> 
            <td width="35%"> <input name="selectkey" type="text" id="selectkey" onFocus="this.value=''" value="请输入关健字"> 
            </td>
            <td width="45%"> <select name="selectm" id="select">
                <OPTION VALUE="name">按商品名称</OPTION>
                <OPTION VALUE="zuozhe">按品牌类别</OPTION>
                <OPTION VALUE="chubanshe">按商品简介</OPTION>
              </select> </td>
            <td width="20%"><input type="submit" name="Submit" value="查 询" onClick="return chkkey();"></td>
          </tr>
        </table></td>
    </form>
  </tr>
</table>
<%rs1.close
set rs1=nothing
conn.close
set conn=nothing%>



