<!--#include file="conn.asp"-->
<link href="../image/css.css" rel="stylesheet" type="text/css">
<link href="images/bg.css" rel="stylesheet" type="text/css">
<%'//判断是否属于合法用户
dim action
action=request.QueryString("action")
select case action
case "addone"
if request.Cookies("godbook")("shjianame")="" then
request.Redirect "<script language=javascript>alert('网络超时或还没有登录');location.href='admin_login.asp';</script>"
request.End
end if
'//判断用户等级限制免费用户只能发布10款产品
dim rss
set rss=server.createobject("adodb.recordset")
rss.open"select * from price_shjia where shjiaid="&request.Cookies("godbook")("shjiaid")&"",conn,1,1
if rss.recordcount>=10 then
request.Write"<script language=javascript>alert('您的商品已满，立即升级为收费商家拥有更多功能与服务');history.go(-1);</script>"
else%>
<!--正常页面开始 -->
<!--选择一级二级分类 -->
<%dim count
set rs=server.createobject("adodb.recordset")
rs.open "select * from shop_nclass order by nclassidorder",conn,1,1%>
<script language = "JavaScript">
function checkkk()
{
}
var onecount;
onecount=0;
subcat = new Array();
<%count = 0
do while not rs.eof%>
subcat[<%=count%>] = new Array("<%= trim(rs("nclass"))%>","<%= rs("anclassid")%>","<%= rs("nclassid")%>");
<%count = count + 1
rs.movenext
loop
rs.close%>
		
onecount=<%=count%>;

function changelocation(locationid)
    {
    document.myform.nclassid.length = 0; 

    var locationid=locationid;
    var i;
    for (i=0;i < onecount; i++)
        {
            if (subcat[i][1] == locationid)
            { 
             document.myform.nclassid.options[document.myform.nclassid.length] = new Option(subcat[i][0], subcat[i][2]);
            }        
        }
        
    }    
</script>
<%dim count1
set rs=server.createobject("adodb.recordset")
rs.open "select * from pinpai order by pingpaiorder",conn,1,1%>
<script language = "JavaScript">
function checkkk()
{
}
var onecount1;
onecount1=0;
subcat1 = new Array();
<%count1 = 0
do while not rs.eof%>
subcat1[<%=count1%>] = new Array("<%= trim(rs("pingpainame"))%>","<%= rs("nclassid")%>","<%= rs("ppid")%>");
<%count1 = count1 + 1
rs.movenext
loop
rs.close%>
		
onecount1=<%=count1%>;

function changelocation1(locationid)
    {
    document.myform.ppid.length = 0; 

    var locationid=locationid;
    var i;
    for (i=0;i < onecount1; i++)
        {
            if (subcat1[i][1] == locationid)
            { 
             document.myform.ppid.options[document.myform.ppid.length] = new Option(subcat1[i][0], subcat1[i][2]);
            }        
        }
        
    }    
</script>
<form name="myform" method="get" action="?action=add" onsubmit="checkkk">
<input name="action" id="action" value="add" type="hidden">
<table class="tableBorder" width="90%" border="0" align="center" cellpadding="5" cellspacing="1" bgcolor="#EFF7CE">
<tr> 
<td class="shjiatop" colspan="4">请按分类级别由高到低从下面的选框中选择商品分类，完成后请点“下一步”</td>
</tr>
<tr>
<td align="center" class="shjiatdcolor">
<%'//选择一级分类
set rs=server.createobject("adodb.recordset")
rs.open "select * from shop_anclass where anclassidorder<1000 order by anclassidorder",conn,1,1
if rs.eof and rs.bof then
request.write "请先添加栏目。"
request.end
else%>
<select class="wenbenkuang" name="anclassid" size=25 style='width:150px' id="anclassid" onchange="changelocation(document.myform.anclassid.options[document.myform.anclassid.selectedIndex].value)">
<option selected value="<%=rs("anclassid")%>"><%=trim(rs("anclass"))%> -></option>
<%dim selclass
selclass=rs("anclassid")
rs.movenext
do while not rs.eof%>
<option value="<%=rs("anclassid")%>"><%=trim(rs("anclass"))%> -></option>
<%rs.movenext
loop
end if
rs.close%>
</select>
&gt;
<select class="wenbenkuang" name="nclassid" id="nclassid" size=25 style='width:150px' onchange="changelocation1(document.myform.nclassid.options[document.myform.nclassid.selectedIndex].value)">
<%set rs=server.createobject("adodb.recordset")
rs.open "select * from shop_nclass where anclassid="&selclass&" order by nclassidorder " ,conn,1,1
if not(rs.eof and rs.bof) then%>
<option selected value="<%=rs("nclassid")%>"><%=rs("nclass")%> -></option>
<%dim selnclass
selnclass=rs("nclassid")
rs.movenext
do while not rs.eof%>
<option value="<%=rs("nclassid")%>"><%=rs("nclass")%> -></option>
<%rs.movenext
loop
end if
rs.close
set rs = nothing%>
</select>
&gt;
<select class="wenbenkuang" name="ppid" id="ppid" size=25 style='width:150px'>
<%set rs=server.createobject("adodb.recordset")
rs.open "select * from pinpai where nclassid="&selnclass&" order by pingpaiorder " ,conn,1,1
if not(rs.eof and rs.bof) then%>
<option selected value="<%=rs("ppid")%>"><%=rs("pingpainame")%> -></option>
<% rs.movenext
do while not rs.eof%>
<option value="<%=rs("ppid")%>"><%=rs("pingpainame")%> -></option>
<%rs.movenext
loop
end if
rs.close
set rs = nothing%>
</select></td>
</tr>
<tr>
<td align="center" class="shjiatdcolor">　
<input class="go-wenbenkuang" type="submit" name="Submit" value="OK,下一步->" onclick='return checkkk();'></td>
</tr>
</table>
</form><%end if
rss.close
set rss=nothing%>

<%case "add"
if request.Cookies("godbook")("shjianame")="" then
request.Redirect "<script language=javascript>alert('网络超时或还没有登录');location.href='admin_login.asp';</script>"
request.End
end if
anclassid=request("anclassid")
nclassid=request("nclassid")
ppid=request("ppid")
if anclassid="" then
response.write"<script language=javascript>alert('没有选择一级分类');history.go(-1);</script>"
end if
if nclassid="" then
response.write"<script language=javascript>alert('没有选择二级分类');history.go(-1);</script>"
end if
if ppid="" then
response.write"<script language=javascript>alert('没有选择三级分类');history.go(-1);</script>"
end if%>
<table width="100%" cellpadding="0" cellspacing="0" border="0">
<tr><td height="5"></td></tr>
<tr><td>
<table class="bgcolor" width="90%" border="0" align="center" cellpadding="3" cellspacing="1" bgcolor="#FFFFFF">
<tr>
<td colspan="7" class="shjiatop">添加商品</td> 
</tr>
<tr class="shjiatdcolor">
<td class="padleft">ID号</td>
<td class="padleft">产品名称</td>
<td class="padleft">产品参数</td>
<td class="padleft">产品报价</td>
<td class="padleft">库存</td>
<td class="padleft">销售</td>
<td class="padleft">选择</td>
</tr><!--产品开始 -->
<%set rs=server.createobject("adodb.recordset")
rs.open"select * from price where ppid="&ppid,conn,1,1
if rs.eof then
else
rs.PageSize =10 '每页记录条数
iCount=rs.RecordCount '记录总数
iPageSize=rs.PageSize
maxpage=rs.PageCount 
page=request("page")
if Not IsNumeric(page) or page="" then
page=1
else
page=cint(page)
end if
if page<1 then
page=1
elseif  page>maxpage then
page=maxpage
end if
rs.AbsolutePage=Page
if page=maxpage then
x=iCount-(maxpage-1)*iPageSize
else
x=iPageSize
end if
end if
For i=1 To x
money=split(rs("money"),"|")%>
<form name="form1" method="post" action="?action=addsave">
<tr class="shjiatdcolor">
<td class="padleft"><%=rs("bookid")%><input name="anclassid" id="anclassid" type="hidden" value="<%=anclassid%>"><input name="nclassid" id="nclassid" type="hidden" value="<%=nclassid%>"><input name="ppid" id="ppid" type="hidden" value="<%=ppid%>"><input name="bookid" id="bookid" type="hidden" value="<%=rs("bookid")%>"><input name="shjiaid" id="shjiaid" type="hidden" value="<%=request.Cookies("godbook")("shjiaid")%>"><input name="shjianame" id="shjianame" type="hidden" value="<%=request.Cookies("godbook")("name")%>"></td>
<td class="padleft">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr><td><img src="../<%=rs("pic1")%>" height="80" width="100" border="0">
<input name="pic" id="pic" type="hidden" value="<%=rs("pic1")%>" /></td></tr>
<tr><td><%=left(rs("bookname"),8)%>
<input name="bookname" id="bookname" type="hidden" value="<%=rs("bookname")%>" /></td></tr></table></td>
<td class="padleft"><%=replace(rs("hid"),"|","<br>")%>
<input name="hid" id="hid" type="hidden" value="<%=rs("hid")%>"></td>
<td class="padleft">参考:<%=money(0)%>元<br>销售价<input id="money1" name="money1" type="text" class="inputother"><br>
同行价<input id="money2" name="money2" type="text" class="inputother"></td>
<td class="padleft"><input id="kucun" name="kucun" type="text" class="inputother" /></td>
<td class="padleft"><select name="att" id="att" class="select">
<option value="直销" selected>直销</option>
<option value="特价">特价</option>
<option value="促销">促销</option>
</select></td>
<td class="padleft"><input type="submit" name="Submit" value="添加" onclick="return test();" class="go-wenbenkuang" /></td>
</tr></form>
<%rs.movenext
next
rs.close
set rs=nothing%>
<tr class="shjiatdcolor">
<td colspan="7" align="right">&nbsp;</td></tr>

<tr class="shjiatdcolor"><form method=get onsubmit=""document.location = "<%=request.ServerVariables("url")%>?<%=temp%>page="+ this.page.value;return false;""><td colspan="18" align="center">
<%Dim query, a, x, temp
if instr(Request.ServerVariables("QUERY_STRING"), "&")>=0 then
query = Split(Request.ServerVariables("QUERY_STRING"), "&")
For Each x In query
a = Split(x, "=")
If StrComp(a(0), "page", vbTextCompare) <> 0 Then
temp = temp & a(0) & "=" & a(1) & "&"
End If
Next
end if
if page<=1 then%>首页 上页
<%else%>
<a href="<%=request.ServerVariables("url")%>?<%=temp%>page=1">首页</a>&nbsp;
<a href="<%=request.ServerVariables("url")%>?<%=temp%>page=<%=(page-1)%>">上页</a>
<%end if%>
<%if page>=maxpage then%> 下页 尾页
<%else%>
<a href="<%=request.ServerVariables("url")%>?<%=temp%>page=<%=page+1%>">下页</a>&nbsp;
<a href="<%=request.ServerVariables("url")%>?<%=temp%>page=<%=maxpage%>">尾页</a> 
<%end if%>
页次：<%= page %>/<%=maxpage%>页&nbsp;
共有<%= icount %>条&nbsp;
转到<input tyep="text" name=page size=2 maxlength=5 value="<%=page%>">页<input type=submit value=go>
</td></form></tr></table></td></tr></table>
<script>
function test()
{
  if(!confirm('确认添加吗？')) return false;
}
</script>

<%case "addsave"
set rs=server.createobject("adodb.recordset")
rs.open"select * from price_shjia where bookid like '%"&request("bookid")&"%'",conn,1,1
if rs.recordcount>0 then
request.write "<span style='height:500px;font-size:12px;padding-top:200px;padding-left:150px;color:red'>已经添加过此款产品</span><script>window.setTimeout(""history.go(-1)"",1000);</script>"
request.End
else
set rs=server.createobject("adodb.recordset")
rs.open"select * from price_shjia",conn,2,3
rs.addnew
rs("bookid")=int(request("bookid"))
rs("shjiaid")=int(request("shjiaid"))
rs("shjianame")=trim(request("shjianame"))
rs("bookname")=trim(request("bookname"))
rs("pic")=trim(request("pic"))
rs("money")=trim(request("money1"))&"|"&trim(request("money2"))
rs("anclassid")=int(request("anclassid"))
rs("nclassid")=int(request("nclassid"))
rs("ppid")=int(request("ppid"))
rs("hid")=trim(request("hid"))
rs("kucun")=int(request("kucun"))
rs("att")=trim(request("att"))
rs("datetime")=now()
rs("updatetime")=now()
rs("chengjiaocount")=0
rs("count")=0
rs.update
rs.close
set rs=nothing
response.write "<span style='height:500px;font-size:12px;padding-top:200px;padding-left:150px;color:red'>添加成功，2秒后自动返回产品列表</span><script>window.setTimeout(""location.href='?'"",1000);</script>"
response.End
end if%>

<%case ""   '商家商品管理页面
if request.Cookies("godbook")("shjianame")="" then
response.Redirect "<script language=javascript>alert('网络超时或还没有登录');location.href='admin_login.asp';</script>"
response.End
end if%>
<table width="100%" cellpadding="0" cellspacing="0" border="0">
<tr><td height="5"></td></tr>
<tr><td>
<table class="bgcolor" width="90%" border="0" align="center" cellpadding="3" cellspacing="1" bgcolor="#FFFFFF"><!--产品开始 -->
<tr>
<td colspan="7" class="shjiatop">商品管理
</td> 
</tr>
<tr class="shjiatdcolor">
<td class="padleft">ID号</td>
<td class="padleft">产品名称</td>
<td class="padleft">产品参数</td>
<td class="padleft">产品报价</td>
<td class="padleft">库存</td>
<td class="padleft">销售</td>
<td class="padleft">管理</td>
</tr>
<%set rs=server.createobject("adodb.recordset")
rs.open"select * from price_shjia where shjiaid="&request.Cookies("godbook")("shjiaid")&" order by updatetime desc",conn,1,1
if rs.eof then
else
rs.PageSize =10 '每页记录条数
iCount=rs.RecordCount '记录总数
iPageSize=rs.PageSize
maxpage=rs.PageCount 
page=request("page")
if Not IsNumeric(page) or page="" then
page=1
else
page=cint(page)
end if
if page<1 then
page=1
elseif  page>maxpage then
page=maxpage
end if
rs.AbsolutePage=Page
if page=maxpage then
x=iCount-(maxpage-1)*iPageSize
else
x=iPageSize
end if
end if
For i=1 To x
money=split(rs("money"),"|")%>
<form name="form1" method="post" action="?action=edit&book_id=<%=rs("book_id")%>">
<tr class="shjiatdcolor">
<td class="padleft"><%=rs("bookid")%><input name="anclassid" id="anclassid" type="hidden" value="<%=anclassid%>"><input name="nclassid" id="nclassid" type="hidden" value="<%=nclassid%>"><input name="ppid" id="ppid" type="hidden" value="<%=ppid%>"><input name="shjiaid" id="shjiaid" type="hidden" value="<%=request.Cookies("godbook")("shjiaid")%>"></td>
<td class="padleft"><table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr><td><img src="../<%=rs("pic")%>" height="80" width="100" border="0"></td></tr>
<tr><td><%=left(rs("bookname"),8)%><input name="bookname" id="bookname" type="hidden" value="<%=rs("bookname")%>" /></td>
</tr></table></td>
<td class="padleft"><%=replace(rs("hid"),"|","<br>")%></td>
<td class="padleft">销售价<input id="money1" name="money1" type="text" class="inputother" value="<%=money(0)%>"><br>同行价<input id="money2" name="money2" type="text" class="inputother" value="<%=money(1)%>"></td>
<td class="padleft"><input id="kucun" name="kucun" type="text" class="inputother" value="<%=rs("kucun")%>" /></td>
<td class="padleft"><select name="att" id="att" class="select">
  <option value="<%=rs("att")%>" selected><%=rs("att")%></option>
  <option value="直销">直销</option>
  <option value="特价">特价</option>
  <option value="促销">促销</option>
</select></td>
<td class="padleft"><a href="?action=del&book_id=<%=rs("book_id")%>">删除</a><input type="submit" name="Submit" value="修改" class="go-wenbenkuang"></td>
</tr></form>
<%rs.movenext
next
rs.close
set rs=nothing%>

<tr class="shjiatdcolor"><form method=get onsubmit=""document.location = "<%=request.ServerVariables("url")%>?<%=temp%>page="+ this.page.value;return false;""><td colspan="20" align="center">
<%if instr(Request.ServerVariables("QUERY_STRING"), "&")>=0 then
query = Split(Request.ServerVariables("QUERY_STRING"), "&")
For Each x In query
a = Split(x, "=")
If StrComp(a(0), "page", vbTextCompare) <> 0 Then
temp = temp & a(0) & "=" & a(1) & "&"
End If
Next
end if
if page<=1 then%>首页 上页
<%else%>
<a href="<%=request.ServerVariables("url")%>?<%=temp%>page=1">首页</a>&nbsp;
<a href="<%=request.ServerVariables("url")%>?<%=temp%>page=<%=(page-1)%>">上页</a>
<%end if%>
<%if page>=maxpage then%> 下页 尾页
<%else%>
<a href="<%=request.ServerVariables("url")%>?<%=temp%>page=<%=page+1%>">下页</a>&nbsp;
<a href="<%=request.ServerVariables("url")%>?<%=temp%>page=<%=maxpage%>">尾页</a> 
<%end if%>
页次：<%= page %>/<%=maxpage%>页&nbsp;
共有<%= icount %>条&nbsp;
转到<input tyep="text" name=page size=2 maxlength=5 value="<%=page%>">页<input type=submit value=go>
</td></form></tr></table></td></tr></table>

<%case "edit"
set rs=server.createobject("adodb.recordset")
rs.open"select * from price_shjia where book_id ="&request("book_id"),conn,2,3
rs("money")=request("money1")&"|"&request("money2")
rs("kucun")=request("kucun")
rs("att")=request("att")
rs("updatetime")=now()
rs.update
rs.close
set rs=nothing
response.write "<span style='height:500px;font-size:12px;padding-top:200px;padding-left:150px;color:red'>修改成功，2秒后自动返回产品列表</span><script>window.setTimeout(""location.href='?'"",1000);</script>"
response.End%>

<%case "del"
book_id=request("book_id")
if book_id<>"" then
conn.execute"delete from price_shjia where book_id in ("&book_id&")"
end if
response.write "<span style='height:500px;font-size:12px;padding-top:200px;padding-left:150px;color:red'>删除成功，2秒后自动返回产品列表</span><script>window.setTimeout(""location.href='?'"",1000);</script>"
response.End%>

<%end select%>