<!--#include file="../include/config.asp"-->
<script language=javascript src=../include/mouse_on_title.js></script>
<%call checkmanage("03")%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<link rel="stylesheet" href="manage.css" type="text/css">
<script language="JavaScript" type="text/JavaScript">
function JM_wu(ob){
 ob.style.display="none";
}
function JM_you(ob){
 ob.style.display="";
}
function uppic(model,frmname) {
 id=document.prodtable.ProdId.value;
 if (id=='') {
 alert("请先填写商品编号！");
 document.prodtable.ProdId.focus();
return false;}
window.open("upload.asp?fuptype=pic&fupname="+id+model+"&frmname="+frmname,"blank_","scrollbars=yes,resizable=no,width=650,height=450")
}

function CheckAll(form) {
 for (var i=0;i<form.elements.length;i++) {
 var e = form.elements[i];
 if (e.name != 'chkall') e.checked = form.chkall.checked; 
 }
 }
</script>
</head>

<BODY background="../images/admin/back.gif">

<%
if request("action")="add" or request("show")="yes" then
 response.cookies("buyok")("sql")=""
end if

url="prod1.asp"

action = request("action")
if action="" then
%>

<table width="750" border="1" style="border-collapse: collapse; border-style: dotted; border-width: 0px" bordercolor="#333333" cellspacing="0" cellpadding="2">
<form name=Prodlist action=prod1.asp method=post>
<tr><td colspan=9 class=td height=18>商品管理</td></tr>
<tr>
<td width=15 align=center>选</td> 
<td width=50 align=center>编号</td> 
<td width=200 align=center>名称 [点击名称预览该商品]</td>
<td width=85 align=center>添加/提升日期</td>
<td width=265 align=center colspan=3>编辑</td>
<td width=30 align=center>状态</td>
<td width=40 align=center>点击数</td>
</tr>

<%
'显示商品列表
Set setup = conn.Execute("select * from shopsetup") 
per_page_num=setup("per_page_num")'读取每页商品数
if per_page_num="" or per_page_num<=1 then per_page_num=20
paixu=setup("paixu")'读取排序方式
set setup=nothing

pages = per_page_num
set rs = server.createobject("adodb.recordset")
if request.cookies("buyok")("sql")="" then'无搜索选项，即显示全部商品
if paixu="1" then orderby=" order by adddate desc"
if paixu="2" then orderby=" order by adddate"
if paixu="3" then orderby=" order by prodid desc"
if paixu="4" then orderby=" order by adddate"
if paixu="5" then orderby=" order by prodname"
if paixu="6" then orderby=" order by ClickTimes desc"
sql = "select * from bproduc where ProdId is not null " + orderby
else'有搜索选项，显示搜索结果
sql=request.cookies("buyok")("sql")
end if

rs.open sql,conn,1,3 

if rs.eof and rs.bof then
response.write "<tr><td colspan=9 align=center height=50>没有找到相关商品</td></tr>"
end if

if not (rs.eof and rs.bof) then
totalrec = RS.RecordCount

rs.pageSize = pages
allPages = rs.pageCount
page = Request("page")
If not isNumeric(page) then page=1
if isEmpty(page) or int(page) <= 1 then
page = 1
elseif int(page) >= allPages then
page = allPages 
end if
rs.AbsolutePage = page
 
do while not rs.eof and pages>0
%>
<tr><td colspan=9 height=5 onMouseOver="bgColor='#FF8899'" onMouseOut="bgColor='E7E7E7'"></td></tr>
<%
adddate=split(rs("adddate")," ")
response.write "<tr><td><input type='checkbox' value='"&rs("ProdNum")&"' name=id></td>"
response.write "<td>"&rs("ProdId")&"</a></td><td><a target='_blank' href='../gotourl.asp?list.asp?ProdId="&rs("ProdId")&"' alt='查看<font color=red> "&rs("ProdName")&" </font>的前台页面'>"&lleft(rs("ProdName"),32)&"</a></td>"
response.write "<td><span title="&replace(rs("adddate")," ",",")&">"&adddate(0)&"</span></td>"
if rs("remark")="0" then
tjian="../images/admin/prodgif1.gif"
else
tjian="../images/admin/prodgif3.gif"
end if
if rs("tejia")="0" then
tjia="../images/admin/prodgif2.gif"
else
tjia="../images/admin/prodgif4.gif"
end if
response.write "<td align=center><input type=button onClick='javascript:location.href=""prod1.asp?page="&currentpage&"&action=detail&id="&rs("ProdId")&""";' value='编辑'> <input alt='执行此操作，将实现：<br>前台：此商品将成为首页第一个商品<br>后台：出现在列表顶端' type=button onClick='javascript:location.href=""prod1.asp?action=tisheng&id="&rs("ProdId")&""";' value='提升'></td><td align=center><img border=0 src="&tjian&" onClick='javascript:location.href=""prod1.asp?action=tuijian&id="&rs("ProdId")&""";'></td><td align=center><img border=0 src="&tjia&" onClick='javascript:location.href=""prod1.asp?action=tejia&id="&rs("ProdId")&""";'></td>"
response.write "<td align=center>"
if rs("online")=true then 
response.write "显示</td>"
else
response.write "<font color=red>关闭</font></td>"
end if
response.write "<td align=right>"&rs("ClickTimes")&"</td></tr>"

pages=pages-1
rs.movenext 
loop
end if

rs.close
conn.close
set rs=nothing
set coon=nothing
%>

<tr><td colspan=9>
<input type='checkbox' name=chkall onclick='CheckAll(this.form)'>全选
<input type="submit" name="action" value="删除" onClick="{if(confirm('商品删除后将无法恢复，您确定要删除选定的商品吗？')){this.document.Prodlist.submit();return true;}return false;}"> 
<input type="submit" name="action" value="关闭">
<input type="submit" name="action" value="打开">
<input type="button" name="action" onClick="javascript:location.href='prod1.asp?action=add';" value="添加商品">
</td></tr>
</form>
</table>

<%
call listpage()
end if

if action="detail" then
id=request("id")
call proddetail()
end if

if action="tisheng" then
id=request("id")
call tisheng()
end if

if action="tuijian" then
id=request("id")
call tuijian()
end if

if action="tejia" then
id=request("id")
call tejia()
end if

if action="删除" then
delid=replace(request("id"),"'","")
call proddel()
end if

if action="关闭" then 
ProdNum=replace(request("id")," ","")
call prodclose()
end if

if action="打开" then
ProdNum=replace(request("id")," ","")
call prodopen()
end if

if action="add" then
call prodadd()
end if

if action="delother" then
call delother()
end if


sub listpage()

if allpages <= 1 then exit sub 
if page = 1 then
response.write "<br><font color=#878787>首页 上页</font>"
 else
response.write "<br> <a href='"&request.ServerVariables("script_name")&"?page=1'>首页</a> "
response.write " <a href='"&request.ServerVariables("script_name")&"?page="&page-1&"'>上页</a> "
end if
if page = allpages then
response.write "<font color=#878787>下页 末页</font>"
else
response.write " <a href='"&request.ServerVariables("script_name")&"?page="&page+1&"'>下页</a> "
response.write " <a href='"&request.ServerVariables("script_name")&"?page="&allpages&"'>末页</a> "
end if

response.write " &nbsp;&nbsp;&nbsp;第"&page&"页 共"&allpages&"页 &nbsp;&nbsp;&nbsp; 商品总数："&totalrec& "&nbsp;&nbsp; 每页商品数："& per_page_num

end sub

sub prodclose()
if ProdNum="" or isnull(ProdNum) then
response.write "<script language='javascript'>"
response.write "alert('您什么也没有选择，单击“确定”返回上一页！');"
response.write "location.href='javascript:history.go(-1)';"
response.write "</script>"
response.end
else
Set rs=Server.CreateObject("ADODB.Recordset")
sql="select * from bproduc where ProdNum in ("&ProdNum&")"
rs.open sql,conn,1,3
if rs.eof and rs.bof then
response.write "<script language='javascript'>"
response.write "alert('该商品并不存在，单击“确定”返回上一页！');"
response.write "location.href='javascript:history.go(-1)';"
response.write "</script>"
response.end
else
Do while not rs.eof
rs("online")=false
rs.update
rs.movenext
loop
end if 
response.write "<script language='javascript'>"
response.write "alert('所选商品已经被关闭！');"
response.write "location.href='"&url&"';"
response.write "</script>"

rs.close
conn.close
set rs=nothing
set conn=nothing
end if
end sub

sub prodopen()
if ProdNum="" or isnull(ProdNum) then
response.write "<script language='javascript'>"
response.write "alert('您什么也没有选择，单击“确定”返回上一页！');"
response.write "location.href='javascript:history.go(-1)';"
response.write "</script>"
response.end
else
Set rs=Server.CreateObject("ADODB.Recordset")
sql="select * from bproduc where ProdNum in ("&ProdNum&")"
rs.open sql,conn,1,3
if rs.eof and rs.bof then
response.write "<script language='javascript'>"
response.write "alert('该商品并不存在，单击“确定”返回上一页！');"
response.write "location.href='javascript:history.go(-1)';"
response.write "</script>"
response.end
else
Do while not rs.eof
rs("online")=true
rs.update
rs.movenext
loop
end if 
response.write "<script language='javascript'>"
response.write "alert('所选商品已经被打开！');"
response.write "location.href='"&url&"';"
response.write "</script>"

rs.close
conn.close
set rs=nothing
set conn=nothing
end if
end sub

sub delother()
'删除多图
conn.execute("delete from more_pic where ProdId='"&request("id")&"' and FilePath='"&request("FilePath")&"'")
response.redirect "prod1.asp?action=detail&id="&request("id")
end sub

sub prodadd()
if request("add") ="ok" then

Set rs=Server.CreateObject("ADODB.Recordset")
sql="select * from bproduc Where ProdId='"&request("ProdId")&"'"
rs.open sql,conn,3,3
if not rs.eof then

response.write "<script language='javascript'>"
response.write "alert('出错了，商品编号重复，请检查！');"
response.write "location.href='javascript:history.go(-1)';"
response.write "</script>"
response.end
rs.close
set rs=nothing
response.end
end if

if request("midcode")="" then
response.write "<script language='javascript'>"
response.write "alert('出错了，您没有选择有效的商品分类！');"
response.write "location.href='javascript:history.go(-1)';"
response.write "</script>"
response.end
end if

if request("ProdId")="" or request("ProdIdtext")="" or request("Prodname")="" or request("Prodnametext")="" or request("PriceList")="" or request("PriceListtext")="" or request("PriceOrigin")="" or request("PriceOrigintext")="" or request.form("ProdDisctext")="" or request.form("MemoSpectext")="" then
response.write "<script language='javascript'>"
response.write "alert('出错了，商品资料填写不完整！');"
response.write "location.href='javascript:history.go(-1)';"
response.write "</script>"
response.end
'response.end
end if

if len(request("ProdDisc"))>200 then
response.write "<script language='javascript'>"
response.write "alert('出错了，您填写的简介内容太长了！');"
response.write "location.href='javascript:history.go(-1)';"
response.write "</script>"
response.end
'response.end
end if


Set rs=Server.CreateObject("ADODB.Recordset")
sql="select * from bproduc Where ProdId='"&request("ProdId")&"'"
rs.open sql,conn,3,3
Set rsfile=Server.CreateObject("ADODB.Recordset")
rsfile.open "more_pic" ,conn,3,3

if not rs.eof then
response.write "<script language='javascript'>"
response.write "alert('出错了，商品编号重复，请检查！');"
response.write "location.href='javascript:history.go(-1)';"
response.write "</script>"
response.end
end if

rs.Addnew
rs("ProdIdtext")=request.form("ProdIdtext")	'编号名称
rs("ProdId")=request.form("ProdId")	'编号
rs("ProdNametext")=request.form("ProdNametext")	'品名名称
rs("ProdName")=request.form("ProdName")	'商品名称
rs("Modeltext")=request.form("Modeltext")	'型号名称
rs("Model")=request.form("Model")	'型号
rs("prodtext1")=request.form("prodtext1")	'自定义一名称
rs("prod1")=request.form("prod1")	'自定义一
rs("prodtext2")=request.form("prodtext2")	'自定义二名称
rs("prod2")=request.form("prod2")	'自定义二
rs("PriceOrigintext")=request.form("PriceOrigintext")	'原价名称
rs("PriceOrigin")=request.form("PriceOrigin")	'原价
rs("PriceListtext")=request.form("PriceListtext")	'现价名称
rs("PriceList")=request.form("PriceList")	'现价
code=split(request.form("Midcode"),"^")
rs("LarCode")=code(0)	'大类
rs("MidCode")=code(1)	'中类
rs("ProdDisctext")=request.form("ProdDisctext")	'简介名称
rs("ProdDisc")=request.form("ProdDisc")	'简介
rs("ImgPrev")=request.form("ImgPrev")	'商品图片
rs("more_pic")=request.form("more_pic")	'商品大图\多图
rs("Quantity")=request.form("Quantity")	'备货状态
rs("MemoSpectext")=request.form("MemoSpectext")	'商品介绍名称
rs("MemoSpec")=request.form("MemoSpec")	'商品介绍
rs("Remark")=request.form("Remark")	'是否推荐
rs("tejia")=request.form("tejia")	'是否特价
rs("online")=true 	'是否在线
rs.update
rs.close
set rs=nothing

'如果有大图时，将大图写入另一个表
if request("more_pic")="1" then
 For m=1 to request.form("more")
rsfile.addnew
rsfile("FilePath")=request.form("more"&m)
rsfile("ProdId")=request.form("ProdId")
rsfile.update
 Next
end if

rsfile.close
set rsfile=nothing
conn.close
set conn=nothing

response.write "<script language='javascript'>"
response.write "alert('商品添加成功，单击“确定”返回商品列表。');"
response.write "location.href='prod1.asp';"
response.write "</script>"

else
LarCode=request("LarCode")
%>

<table width="750" border="1" style="border-collapse: collapse; border-style: dotted; border-width: 0px" bordercolor="#333333" cellspacing="0" cellpadding="2">
<tr><td colspan=2 class=td height=18>添加商品</td></tr>

<form name=prodtable method="post" action="">
<%Dim a,b,c 
set rsmid=server.createobject("adodb.recordset") 
sqlmid="select distinct LarCode,LarSeq,MidCode,midSeq from buyok_class order by LarSeq,MIdSeq" 
rsmid.Open sqlmid,conn,1,1 

response.write "<TR><TD width=100 align=center>商品分类</td><td>"
response.write "<select name='MidCode'>"
response.write"<option value='未归类^未归类' selected>---选择商品所属分类---</option>"
if rsmid.bof and rsmid.eof then
response.write "<option selected value='未归类^未归类'>-暂无商品分类-</option>"
else
Do While Not rsmid.eof
a = rsmid("larcode")
response.write "<option value='"&rsmid("larCode")&"^"&rsmid("MidCode")&"'>"&rsmid("LarSeq")&"-"&rsmid("LarCode")&" >> "&rsmid("MidSeq")&"-"&rsmid("MidCode")&"</option>"
rsmid.movenext
if rsmid.eof then exit do
if rsmid("larcode")<>a then response.write "<option value=''>--------------------------</option>"
loop
end if
rsmid.close
set rsmid=nothing

response.write "</TD></TR>"

'确定商品编号
set rs = server.createobject("adodb.recordset")
sql = "select * from bproduc where ProdId is not null"
rs.cursorlocation = 3
rs.open sql,conn,1,1 
if rs.bof and rs.eof then
 autoid=1
 else
 totalid=rs.RecordCount'根据数据库中商品总数确定下一个商品的编号
 autoid=totalid+1
end if
rs.close
set rs=nothing

autoidtxt=cstr(autoid)
 if len(autoidtxt)=1 then
 autoidtxt="000"&autoidtxt
 elseif len(autoidtxt)=2 then
 autoidtxt="00"&autoidtxt
 elseif len(autoidtxt)=3 then
 autoidtxt="0"&autoidtxt
 end if

for i=1 to totalid
'检查自动生成的编号是否有重复，若有重复则自动加1

set rs=conn.execute("select prodid from bproduc where prodid='"&autoidtxt&"'")
if not (rs.eof and rs.bof) then
 autoid=autoid+1
autoidtxt=cstr(autoid)
 if len(autoidtxt)=1 then
 autoidtxt="000"&autoidtxt
 elseif len(autoidtxt)=2 then
 autoidtxt="00"&autoidtxt
 elseif len(autoidtxt)=3 then
 autoidtxt="0"&autoidtxt
 end if
end if
set rs=nothing
next

Set rstxt = conn.Execute("select * from shopsetup") 
ProdName=rstxt("ProdName")
Prodid=rstxt("Prodid")
shichang=rstxt("shichang")
remai=rstxt("remai")
Proddisc=rstxt("Proddisc")
MemoSpec=rstxt("MemoSpec")
Modeltext=rstxt("Modeltext")
prodtext1=rstxt("prodtext1")
prodtext2=rstxt("prodtext2")
set rstxt=nothing
%>

<TR><TD width=100 align=center>
<input name="Prodidtext" type="text" value="<%=prodid%>" size=7>
</td><td>
<input name="ProdId" type="text" value="<%=autoidtxt%>" size="20" maxlength="7"> &nbsp;<img src=../images/admin/memo.gif alt='商品编号不能修改'></TD></TR>

<TR><TD width=100 align=center>
<input name="Prodnametext" type="text" value="<%=prodname%>" size=7>
</td><td>
<input name="ProdName" type="text" value="" size="20" maxlength="50"> &nbsp;<img src=../images/admin/memo.gif alt='必填，不能为空'></TD></TR>

<TR><TD width=100 align=center>
<input name="Modeltext" type="text" value="<%=Modeltext%>" size=7>
</td><td>
<input name="Model" type="text" value=""> &nbsp;<img src=../images/admin/memo.gif alt='选填，填写商品的其它属性<br>如：“商品型号”、“品牌”、“产地”等'></TD></TR>

<TR><TD width=100 align=center>
<input name="Prodtext1" type="text" value="<%=prodtext1%>" size=7>
</td><td>
<input name="prod1" type="text" value=""> </TD></TR>

<TR><TD width=100 align=center><input name="Prodtext2" type="text" value="<%=prodtext2%>" size=7></td><td>
<input name="prod2" type="text" value=""> </TD></TR>

<TR><TD width=100 align=center>
<input name="PriceOrigintext" type="text" value="<%=shichang%>" size=7>
</td><td>
<input name="PriceOrigin" type="text" value="0" size="6" maxlength="10"> 元</TD></TR>

<TR><TD width=100 align=center>
<input name="PriceListtext" type="text" value="<%=remai%>" size=7>
</td><td>
<input name="PriceList" type="text" value="0" size="6" maxlength="10"> 元&nbsp;<img src=../images/admin/memo.gif alt="价格为0时，显示“价格请咨询”等提示语<br>可在“综合设置”下的“商品参数设置”中设置此提示语"></TD></TR>

<TR><TD width=100 align=center>备货状态</td><td>
<input type="radio" name="Quantity" value="1" checked>有货&nbsp;<input type="radio" name="Quantity" value="0">缺货&nbsp;<img src="../images/admin/memo.gif" alt="缺货时，显示“货品备货中”等提示语<br>可在“综合设置”下的“商品参数设置”中设置此提示语"></TD></TR>

<TR><TD width=100 align=center>商品略图</td><td>
<input name="ImgPrev" type="text" value="pic/none.gif" size="40" maxlength="100">&nbsp;<INPUT alt="请单击“浏览”上传图片<br>或填写图片的网址，如<font color=blue>http://www.buyok.net/pic/mp3.jpg</font><br>或填写站内的图片路径、文件名，如<font color=blue>pic/more/001.jpg</font>" TYPE="button" value="浏览" onClick="javascript:uppic('','ImgPrev');">&nbsp;&nbsp; <img src=../images/admin/memo.gif alt='<font color=red>何谓“略图”：</font><br>略图也就是商品的小图片，建议制作为130象素宽<br>略图显示在首页、分类页、搜索页、商品介绍页<br><font color=red>大图显示在什么位置？</font><br>点击商品页的“查看大图”按钮可查看所有大图'></TD></TR>

<TR><TD width=100 align=center>商品大图</td><td>
<SCRIPT LANGUAGE="JavaScript">
function createForm(textN,number) {
data = ""; 
inter = "'";
if (number < 11 && number > -1) {
for (i=1; i <= number; i++) {
if (i < 10) spaces=" ";
else spaces=" ";
data =data + "&nbsp;&nbsp;<input name="+textN+i+" type=text value='' size='30' maxlength='100'><INPUT TYPE='button' value='上传"+i+"' onclick=javascript:uppic('_more"+i+"','more"+i+"')><br>";
}
if (document.layers) {
document.layers.cust.document.write(data);
document.layers.cust.document.close();
}
else {
if (document.all) {
cust.innerHTML = data;
 }
 }
}
else {
window.alert("请不要超过10张图片.");
 }
}
// End -->
</script>
<INPUT TYPE="radio" NAME="more_pic" checked value=0 onclick=JM_wu(s1)>无 
<INPUT TYPE="radio" NAME="more_pic" value=1 onclick=JM_you(s1)>有&nbsp;<span id=s1 style="display:none"><input name="more" type=text value='1' size='5' maxlength='1'> <input type=button value="张大图" onClick="createForm('more',document.prodtable.more.value);"><br>
<span id=cust style="position:relative;"></span></span>

</TD></TR>

<TR><TD width=100 align=center valign="top">
<input name="ProdDisctext" type="text" value="<%=ProdDisc%>" size=7>
<br>(200字内)</td><td><textarea name="ProdDisc" cols="85" rows="4"></textarea></TD></TR>

<TR><TD width=100 align=center valign="top">
<input name="MemoSpectext" type="text" value="<%=MemoSpec%>" size=7>
</td><td>
<textarea name="MemoSpec" style="display:none"></textarea>
<iframe ID="edit3" src="../webedit/ewebeditor.asp?id=MemoSpec&style=putong" frameborder="0" scrolling="no" width="620" HEIGHT="500"></iframe> 
</TD></TR>

<TR><TD width=100 align=center>是否推荐</td><td>
<input type="radio" name="Remark" value="0" checked>否&nbsp;<input type="radio" name="Remark" value="1">是
&nbsp;<img src=../images/admin/memo.gif alt='选择“是”将设为推荐商品'></TD></TR>

<TR><TD width=100 align=center>是否特价</td><td>
<input type="radio" name="tejia" value="0" checked>否&nbsp;<input type="radio" name="tejia" value="1">是 
&nbsp;<img src=../images/admin/memo.gif alt='特价商品将出现在主页“特价商品”栏目中'></TD></TR>

<TR><TD colspan=2><INPUT TYPE="hidden" name=add value=ok><input type="submit" name="action" value="添加完成"></TD></TR>

</form>
</TABLE>
<%
end if
end sub

sub proddel()
if delid="" or isnull(delid) then
response.write "<script language='javascript'>"
response.write "alert('您什么也没有选择，单击“确定”返回上一页！');"
response.write "location.href='javascript:history.go(-1)';"
response.write "</script>"
response.end
else

'conn.execute("delete from bproduc where ProdNum in ("&delid&")")

set rs = server.createobject("adodb.recordset")
sql="select * from bproduc where ProdNum in ("&delid&")"
rs.open sql,conn,1,3
do while not rs.eof
conn.execute("delete from more_pic where Prodid = '"&rs("prodid")&"'")
rs.delete
rs.update
rs.movenext
if rs.eof then exit do
loop
rs.close
set rs=nothing

response.write "<script language='javascript'>"
response.write "alert('操作成功，所选商品已被删除！');"
response.write "location.href='"&url&"';"
response.write "</script>"
response.end
conn.close
set conn=nothing
end if
end sub

sub proddetail()
if id="" then
response.write "<script language='javascript'>"
response.write "alert('提交的商品编号不存在，请检查！');"
response.write "location.href='javascript:history.go(-1)';"
response.write "</script>"
response.end
else
'修改商品资料
if request("modify")="ok" then
if request("midcode")="" then
response.write "<script language='javascript'>"
response.write "alert('您没有选择有效的商品分类，单击“确定”返回上一页！');"
response.write "location.href='javascript:history.go(-1)';"
response.write "</script>"
response.end
end if

if request("ProdId")="" or request("ProdIdtext")="" or request("Prodname")="" or request("Prodnametext")="" or request("PriceList")="" or request("PriceListtext")="" or request("PriceOrigin")="" or request("PriceOrigintext")="" or request.form("ProdDisctext")="" or request.form("MemoSpectext")="" then
response.write "<script language='javascript'>"
response.write "alert('商品资料填写不完整，单击“确定”返回上一页！');"
response.write "location.href='javascript:history.go(-1)';"
response.write "</script>"
response.end
response.end
end if

if len(request("ProdDisc"))>200 then
response.write "<script language='javascript'>"
response.write "alert('您填写的商品简介内容太长了，单击“确定”返回上一页！');"
response.write "location.href='javascript:history.go(-1)';"
response.write "</script>"
response.end
end if

set rs=server.createobject("adodb.recordset")
sql = "select * from bproduc where ProdId='"&id&"'"
rs.open sql,conn,1,3
if not (rs.eof and rs.bof) then
rs("ProdId")=rs("ProdId")
rs("ProdIdtext")=request.form("ProdIdtext")'编号名称
rs("ProdNametext")=request.form("ProdNametext")'品名名称
rs("ProdName")=request.form("ProdName")'商品名称
rs("Modeltext")=request.form("Modeltext")'型号名称
rs("Model")=request.form("Model")'型号
rs("prodtext1")=request.form("prodtext1")'自定义一名称
rs("prod1")=request.form("prod1")'自定义一
rs("prodtext2")=request.form("prodtext2")'自定义二名称
rs("prod2")=request.form("prod2")'自定义二
rs("PriceOrigintext")=request.form("PriceOrigintext")'原价名称
rs("PriceOrigin")=request.form("PriceOrigin")'原价
rs("PriceListtext")=request.form("PriceListtext")'现价名称
rs("PriceList")=request.form("PriceList")'现价
code=split(request.form("Midcode"),"^")
rs("LarCode")=code(0)'大类
rs("MidCode")=code(1)'中类
rs("ProdDisctext")=request.form("ProdDisctext")'简介名称
rs("ProdDisc")=request.form("ProdDisc")'简介
rs("ImgPrev")=request.form("ImgPrev")'商品图片
rs("more_pic")=request.form("more_pic")'商品大图\多图
rs("Quantity")=request.form("Quantity")'备货状态
rs("MemoSpectext")=request.form("MemoSpectext")'商品介绍名称
rs("MemoSpec")=request.form("MemoSpec")'商品介绍
rs("ClickTimes")=request.form("ClickTimes")'点击次数
rs("Remark")=request.form("Remark")'是否推荐
rs("tejia")=request.form("tejia")'是否特价
if request.form("up")="1" then rs("AddDate")=now()'是否提升
rs.update
rs.close
set rs=nothing
end if


'写入大图到其它表
if request.form("more_pic")="1" then
set rsfile=Server.Createobject("ADODB.recordset")
sql="select * from more_pic where ProdId='"&request.form("ProdId")&"'"
rsfile.open sql,conn,3,3
if not rsfile.eof then '如果已经有图片表明是修改，则先删除旧的，再添加
conn.execute("delete from more_pic where ProdId='"&request.form("ProdId")&"'")
end if
rsfile.close
set rsfile=nothing

Set rs=Server.CreateObject("ADODB.Recordset")
rs.open "more_pic" ,conn,3,3
For m=1 to request("m")
rs.addnew
rs("FilePath")=request.form("more"&m)
rs("ProdId")=request.form("ProdId")
rs.update
next
rs.close
set rs=nothing
end if

page=request("page")	'修改商品后返回当前页
response.write "<script language='javascript'>"
response.write "alert('您已成功修改了一件商品！');"
response.write "location.href='"&url&"?page="&page&"';"
response.write "</script>"

response.end
end if

set rs = server.createobject("adodb.recordset")
sql = "select * from bproduc where ProdId='"&id&"'"
rs.open sql,conn,1,1

if rs.eof and rs.bof then
response.write "<script language='javascript'>"
response.write "alert('没有此商品序号，请检查！');"
response.write "location.href='javascript:history.go(-1)';"
response.write "</script>"
response.end
end if

if not (rs.eof and rs.bof) then 
%>

<table width="750" border="1" style="border-collapse: collapse; border-style: dotted; border-width: 0px" bordercolor="#333333" cellspacing="0" cellpadding="2">
<tr><td colspan=2 class=td height=18>编辑商品资料</td></tr>

<!--表单提交程序中加入 page=<%=request("page")%> 是为了编辑商品后返回当前页-->
<form name=prodtable method="post" action='prod1.asp?action=detail&id=<%=id%>&page=<%=request("page")%>'>

<%
'从商品资料中读取分类
LarCode=rs("LarCode")
MidCode=rs("MidCode")

'从分类表中读取所有分类
set rsmid=server.createobject("adodb.recordset") 
sqlmid="select distinct LarCode,LarSeq,MidCode,midSeq from buyok_class order by LarSeq,MIdSeq " 
rsmid.Open sqlmid,conn,1,1 
%>

<TR><TD width=100 align=center>商品分类</td><td>
<%
response.write "<select name='MidCode'>"
if rsmid.bof and rsmid.eof then
response.write "<option selected value='未归类^未归类'>-暂无分类-</option>"
else
 response.write "<option value='未归类^未归类' >-该商品不归类-</option>"
 Do While Not rsmid.eof
a=rsmid("larcode")
 response.write "<option value='"&rsmid("larCode")&"^"&rsmid("MidCode")&"'"
 if MidCode=rsmid("MidCode") and larCode=rsmid("larCode") then response.write " selected"
 response.write ">"&rsmid("LarSeq")&"-"&rsmid("LarCode")&" >>"&rsmid("MidSeq")&"-"&rsmid("MidCode")&"</option>"
 rsmid.movenext
if rsmid.eof then exit do
if rsmid("larcode")<>a then response.write "<option value=''>--------------------------</option>"
 loop
end if
rsmid.close
set rsmid=nothing
%>
</TD></TR>

<TR><TD width=100 align=center>
<input name="prodidtext" type="text" value="<%=rs("prodidtext")%>" size=7>
</td><td>
<input name="ProdId" type="text" readonly value="<%=rs("ProdId")%>" size="20" maxlength="30"> &nbsp;<img src=../images/admin/memo.gif alt='商品编号不能修改'></TD></TR>

<TR><TD width=100 align=center>
<input name="ProdNametext" type="text" value="<%=rs("ProdNametext")%>" size=7>
</td><td>
<input name="ProdName" type="text" value="<%=rs("ProdName")%>" size="20" maxlength="50"> &nbsp;<img src=../images/admin/memo.gif alt='必填，不能为空'></TD></TR>

<TR><TD width=100 align=center>
<input name="Modeltext" type="text" value="<%=rs("Modeltext")%>" size=7>
</td><td>
<input name="Model" type="text" value="<%=rs("Model")%>"></TD></TR>

<TR><TD width=100 align=center>
<input name="prodtext1" type="text" value="<%=rs("prodtext1")%>" size=7>
</td><td>
<input name="prod1" type="text" value="<%=rs("prod1")%>"></TD></TR>

<TR><TD width=100 align=center>
<input name="prodtext2" type="text" value="<%=rs("prodtext2")%>" size=7>
</td><td>
<input name="prod2" type="text" value="<%=rs("prod2")%>"></TD></TR>

<TR><TD width=100 align=center>
<input name="PriceOrigintext" type="text" value="<%=rs("PriceOrigintext")%>" size=7>
</td><td>
<input name="PriceOrigin" type="text" value="<%=rs("PriceOrigin")%>" size="6" maxlength="10"> 元</TD></TR>

<TR><TD width=100 align=center>
<input name="PriceListtext" type="text" value="<%=rs("PriceListtext")%>" size=7>
</td><td>
<input name="PriceList" type="text" value="<%=rs("PriceList")%>" size="6" maxlength="10"> 元&nbsp;
<img src=../images/admin/memo.gif alt="价格为0时，显示“价格请咨询”等提示语<br>可在“综合设置”下的“商品参数设置”中设置此提示语"></TD></TR>

<TR><TD width=100 align=center>备货状态</td><td>
<input type="radio" name="Quantity" value="1" <%if rs("Quantity")<>"0" then%>checked<%end if%>>有货&nbsp;<input type="radio" name="Quantity" value="0" <%if rs("Quantity")="0" then%>checked<%end if%>>缺货&nbsp;<img src="../images/admin/memo.gif" alt="缺货时，显示“货品备货中”等提示语<br>可在“综合设置”下的“商品参数设置”中设置此提示语"></TD></TR>

<TR><TD width=100 align=center>商品略图</td><td>
<input name="ImgPrev" type="text" value="<%=rs("ImgPrev")%>" size="30" maxlength="100">&nbsp;
<INPUT TYPE="button" alt="请单击“浏览”上传图片<br>或填写图片的网址，如<font color=blue>http://www.buyok.net/pic/mp3.jpg</font><br>或填写站内的图片路径、文件名，如：<font color=blue>pic/more/001.jpg</font>" value="浏览" onClick="javascript:uppic('_sml','ImgPrev');"> &nbsp;&nbsp; <img src=../images/admin/memo.gif alt='<font color=red>何谓“略图”：</font><br>略图也就是商品的小图片，建议制作为200象素宽<br>略图显示在首页、分类页、搜索页、商品介绍页<br><font color=red>大图显示在什么位置？</font><br>点击商品页的“查看大图”按钮可查看所有大图'></TD></TR>

<%
Set rsfile=conn.execute("select * from more_pic where ProdId='"&id&"'")
if (rsfile.eof and rsfile.bof) then temp="none"
set rsfile=nothing
%>

<TR><TD width=100 align=center>商品大图</td><td>
<INPUT TYPE="radio" NAME="more_pic" <%if rs("more_pic")=0 or temp="none" then%>checked<%end if%> value=0 onclick=JM_wu(s1)>无 
<INPUT TYPE="radio" NAME="more_pic" 
<%
if rs("more_pic")=1 and temp<>"none" then
response.write "checked value=1 onclick=JM_you(s1)>有 <span id=s1 style='display:'>"
Set rsfile=Server.CreateObject("ADODB.Recordset")
sql="select * from more_pic where ProdId='"&id&"'"
rsfile.open sql,conn,1,1
count=rsfile.RecordCount '图片总数
For m=1 to count
response.write "<br> <input size=40 type=text name=more"&m&" value='"&rsfile("FilePath")&"'>"
response.write "<a href='prod1.asp?action=delother&FilePath="&rsfile("FilePath")&"&id="&rsfile("ProdId")&"'>删除</a>"
rsfile.movenext
next
response.write " <input type=button value='增加到' onClick=""createForm('more',document.prodtable.more.value,"&m&");"">"
response.write "<input name=more type=text value='"&m&"' size=1 maxlength=1><br><span id=cust style='position:relative;'>"
response.write "<INPUT TYPE='hidden' name='m' value="&count&"></span></span>"
%>

<SCRIPT LANGUAGE="JavaScript">
function createForm(textN,number,count) {
data = "<INPUT TYPE='hidden' name='m' value="+count+">"; 
inter = "'";
if (number < 11 && number > -1) {
for (i=count; i <= number; i++) {
if (i < 10) spaces=" ";
else spaces=" ";
data =data + "&nbsp;&nbsp;<input name="+textN+i+" type=text value='' size='30' maxlength='100'><INPUT TYPE='button' value='上传"+i+"' onclick=javascript:uppic('_more"+i+"','more"+i+"')><br>";
}
if (document.layers) {
document.layers.cust.document.write(data);
document.layers.cust.document.close();
}
else {
if (document.all) {
cust.innerHTML = data;
 }
 }
}
else {
window.alert("请不要超过10张图片.");
 }
}
</script>
<%
else
response.write "value=1 onclick=JM_you(s1)>有 <span id=s1 style='display:none'>"
response.write "<input name='m' type=text value='1' size='5' maxlength='1'>"
response.write "<input type=button value=张大图 onClick=createForm('more',document.prodtable.m.value);>"
response.write "<br><span id=cust style='position:relative;'></span></span>"
%>

<SCRIPT LANGUAGE="JavaScript">
function createForm(textN,number) {
data = ""; 
inter = "'";
if (number < 11 && number > -1) {
for (i=1; i <= number; i++) {
if (i < 10) spaces=" ";
else spaces=" ";
data =data + "&nbsp;&nbsp;<input name="+textN+i+" type=text value='' size='30' maxlength='100'><INPUT TYPE='button' value='上传"+i+"' onclick=javascript:uppic('_more"+i+"','more"+i+"')><br>";
}
if (document.layers) {
document.layers.cust.document.write(data);
document.layers.cust.document.close();
}
else {
if (document.all) {
cust.innerHTML = data;
 }
 }
}
else {
window.alert("请不要超过10张图片.");
 }
}
</script>

<%end if%>

</TD></TR>

<TR><TD width=100 align=center valign="top">
<input name="Proddisctext" type="text" value="<%=rs("Proddisctext")%>" size=7>
</td><td>
<textarea name="ProdDisc" cols="85" rows="4" style="overflow:auto;"><%=rs("ProdDisc")%></textarea></TD></TR>

<TR><TD width=100 align=center valign="top">
<input name="MemoSpectext" type="text" value="<%=rs("MemoSpectext")%>" size=7>
</td><td>
<textarea name="MemoSpec" style="display:none"><%=Server.HTMLEncode(rs("MemoSpec"))%></textarea>

<iframe ID="Edit4" src="../webedit/ewebeditor.asp?id=MemoSpec&style=putong" frameborder="0" scrolling="no" width="620" HEIGHT="500"></iframe> 

</TD></TR>

<TR><TD width=100 align=center>是否推荐</td><td>
 <input type="radio" name="Remark" value="0" 
 <%if rs("Remark")=0 then%>checked<%end if%>> 否
 <input type="radio" name="Remark" value="1" 
 <%if rs("Remark")=1 then%>checked<%end if%>> 是 
&nbsp;<img src=../images/admin/memo.gif alt='选择“是”将设为推荐商品'></TD></TR>

<TR><TD width=100 align=center>是否特价</td><td>
 <input type="radio" name="tejia" value="0" 
 <%if rs("tejia")=0 then%>checked<%end if%>> 否
 <input type="radio" name="tejia" value="1" 
 <%if rs("tejia")=1 then%>checked<%end if%>> 是 
&nbsp;<img src=../images/admin/memo.gif alt='特价商品将出现在主页“特价商品”栏目中'></TD></TR>

<TR><TD width=100 align=center>是否提升</td><td>
 <input type="radio" name="up" value="0" checked> 否
 <input type="radio" name="up" value="1" > 是 
&nbsp;<img src=../images/admin/memo.gif alt='若选择“是”，将实现：<br>前台：此商品将成为首页第一个商品<br>后台：出现在列表顶端'></TD></TR>

<TR><TD width=100 align=center>浏览次数</td><td>
 此商品已被浏览 <input type=text name=ClickTimes value=<%=rs("ClickTimes")%> size=5 maxlength=5> 次
&nbsp;<img src=../images/admin/memo.gif alt="小技巧：<br>要让此商品出现在热卖排行的前面位置<br>只需将此数字改得尽量大即可<br><font color=red>最大的排在第一位置</font>"></TD></TR>


<TR><Td colspan=2><INPUT TYPE="hidden" name=modify value=ok><input type="submit" name="action" value="保存设置"></TD></TR>

</form></TABLE>

<%
end if
rs.close
set rs=nothing
end if
end sub


'提升
sub tisheng()
set rs=server.createobject("adodb.recordset")
sql = "select * from bproduc where ProdId='"&id&"'"
rs.open sql,conn,1,3
if not (rs.eof and rs.bof) then
rs("AddDate")=now()
rs.update
rs.close
end if
response.write "<script language='javascript'>"
response.write "alert('所选商品已被提升到列表顶端，单击“确定”返回商品列表。');"
response.write "location.href='"&url&"';"
response.write "</script>"
end sub


'推荐或取消推荐
sub tuijian()
set rs=server.createobject("adodb.recordset")
sql = "select * from bproduc where ProdId='"&id&"'"
rs.open sql,conn,1,3
if not (rs.eof and rs.bof) then
if rs("remark")="1" then 
rs("remark")="0"
rs("tjdate")=rs("adddate")
tjian="所选商品已取消推荐，单击“确定”返回商品列表。"
else
rs("remark")="1"
rs("tjdate")=now()
tjian="所选商品已列为推荐商品，单击“确定”返回商品列表。"
end if
rs.update
rs.close
end if
response.write "<script language='javascript'>"
response.write "alert('"&tjian&"');"
'response.write "location.href='javascript:history.go(-1)';"
response.write "location.href='"&url&"';"
response.write "</script>"
end sub


'设置或取消特价
sub tejia()
set rs=server.createobject("adodb.recordset")
sql = "select * from bproduc where ProdId='"&id&"'"
rs.open sql,conn,1,3
if not (rs.eof and rs.bof) then
if rs("tejia")="1" then 
rs("tejia")="0"
tjia="所选商品已列为非特价商品，单击“确定”返回商品列表。"
else
rs("tejia")="1"
tjia="所选商品已列为特价商品，单击“确定”返回商品列表。"
end if
rs.update
rs.close
end if
response.write "<script language='javascript'>"
response.write "alert('"&tjia&"');"
response.write "location.href='"&url&"';"
response.write "</script>"
end sub
%>

</body>
</html>
