<%
if request.cookies("buyok")("admin")="" then response.write "<meta http-equiv='refresh' content='0;URL=../admin.asp'>"
%>
<!--#include file="../include/config.asp"-->

<script language=javascript src=../include/mouse.js></script>
<%
sub checkmanage(str)
Set mrs = conn.Execute("select * from manage where username='"&request.cookies("buyok")("admin")&"'")
if not (mrs.bof and mrs.eof) then
manage=mrs("manage")
if instr(manage,str)<=0 then
response.write "<script language='javascript'>"
response.write "alert('警告：您没有此项操作的权限！');"
response.write "location.href='quit.asp';"
response.write "</script>"
response.end
else
session("buyok_admin_login")=0
end if
else 
response.write "<script language='javascript'>"
response.write "alert('没有登陆，不能执行此操作！');"
response.write "location.href='quit.asp';"
response.write "</script>"
response.end
end if
set mrs=nothing
end sub
%>
<%call checkmanage("03")%>

 
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<LINK href="../images/css.css" type=text/css rel=stylesheet>
<LINK href="../list/newhead.css" type=text/css rel=stylesheet>
<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=pic1&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 bgcolor="#D9EAFC">

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

url="prod_dj.asp"

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

<table height="5"><tr><td></td></tr></table>
<TABLE cellSpacing=0 cellPadding=0 width=95% border=0 style="BORDER-RIGHT: #b1bfee 1px solid; BORDER-TOP: #b1bfee 1px solid; BORDER-LEFT: #b1bfee 1px solid; BORDER-BOTTOM: #b1bfee 1px solid" 
>
  <TBODY>
    <TR>
      <TD width="90%" bgColor=#f4f5fd><font color="#000000">　<B><font color="#FF0000">&nbsp;积分兑奖商品管理</font></B></font></TD>
      <TD bgColor=#f4f5fd height=30>&nbsp;</TD>
    </TR>
  </TBODY>
</TABLE>
		  <table height="5"><tr><td></td></tr></table>

<table width="95%"  border="0" cellpadding="0" cellspacing="1" bgcolor="#b1bfee">
<form name=Prodlist action=prod_dj.asp method=post>
<tr>
<td width=15 align=center bgcolor="#FFFFFF">选</td> 
<td width=50 align=center bgcolor="#FFFFFF">编号</td> 
<td align=center bgcolor="#FFFFFF">名称 [点击名称预览该商品]</td>
<td width=85 align=center bgcolor="#FFFFFF">添加/提升日期</td>
<td width=265 align=center colspan=3 bgcolor="#FFFFFF">编辑</td>
<td width=30 align=center bgcolor="#FFFFFF">状态</td>
<td width=40 align=center bgcolor="#FFFFFF">点击数</td>
</tr>

<%
'显示商品列表
per_page_num=20
paixu=1
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 bproduc1 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 bgcolor=#FFFFFF>没有找到相关商品</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 bgcolor="#f4f5fd"></td></tr>
<%
adddate=split(rs("adddate")," ")
response.write "<tr><td bgcolor=#FFFFFF><input type='checkbox' value='"&rs("ProdNum")&"' name=id></td>"
response.write "<td bgcolor=#FFFFFF>"&rs("ProdId")&"</a></td><td bgcolor=#FFFFFF><a target='_blank' href='../list1.asp?ProdId="&rs("ProdId")&"' alt='查看<font color=red> "&rs("ProdName")&" </font>的前台页面'>"&lleft(rs("ProdName"),32)&"</a></td>"
response.write "<td bgcolor=#FFFFFF><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 bgcolor=#FFFFFF><input type=button onClick='javascript:location.href=""prod_dj.asp?page="&currentpage&"&action=detail&id="&rs("ProdId")&""";' value='编辑'></td><td align=center bgcolor=#FFFFFF><img border=0 src="&tjian&" onClick='javascript:location.href=""prod_dj.asp?action=tuijian&id="&rs("ProdId")&""";'></td><td align=center bgcolor=#FFFFFF><img border=0 src="&tjia&" onClick='javascript:location.href=""prod_dj.asp?action=tejia&id="&rs("ProdId")&""";'></td>"
response.write "<td align=center bgcolor=#FFFFFF>"
if rs("online")=true then 
response.write "显示</td>"
else
response.write "<font color=red>关闭</font></td>"
end if
response.write "<td align=right bgcolor=#FFFFFF>"&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 bgcolor=#FFFFFF>
<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='prod_dj.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 bproduc1 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 bproduc1 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 prodadd()
if request("add") ="ok" then

Set rs=Server.CreateObject("ADODB.Recordset")
sql="select * from bproduc1 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 bproduc1 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
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("zidingyi1")=request.form("zidingyi1")	'自定义二名称
rs("zdy1")=request.form("zdy1")	'自定义二
rs("zidingyi2")=request.form("zidingyi2")	'自定义二名称
rs("zdy2")=request.form("zdy2")	'自定义二
rs("kaiguan1")=request.form("kaiguan1")'编号名称
rs("kaiguan2")=request.form("kaiguan2")'编号名称
rs("kaiguan3")=request.form("kaiguan3")'品名名称
rs("kaiguan4")=request.form("kaiguan4")'商品名称
rs("kaiguan5")=request.form("kaiguan5")'型号名称

rs("PriceOrigintext")=request.form("PriceOrigintext")	'原价名称
rs("PriceOrigin")=request.form("PriceOrigin")	'原价
rs("PriceListtext")=request.form("PriceListtext")	'现价名称
rs("PriceList")=request.form("PriceList")	'现价
rs("jifenname")=request.form("jifenname")
rs("jifenzhi")=request.form("jifenzhi")
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("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


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

else
LarCode=request("LarCode")
%>
<table height="5"><tr><td></td></tr></table>
<TABLE cellSpacing=0 cellPadding=0 width=95% border=0 style="BORDER-RIGHT: #b1bfee 1px solid; BORDER-TOP: #b1bfee 1px solid; BORDER-LEFT: #b1bfee 1px solid; BORDER-BOTTOM: #b1bfee 1px solid" 
>
  <TBODY>
    <TR>
      <TD width="90%" bgColor=#f4f5fd><font color="#000000">　<B><font color="#FF0000">&nbsp;添加</font><font color="#000000"><B><font color="#FF0000">积分兑奖</font></B></font><font color="#FF0000">商品</font></B></font></TD>
      <TD bgColor=#f4f5fd height=30></TD>
    </TR>
  </TBODY>
</TABLE>
		  <table height="5"><tr><td></td></tr></table>
<%
     Set rsbp=Server.CreateObject("ADODB.Recordset")
	 sql="select * from bproduc1"
	 rsbp.open sql,conn,1,3
%>

<table width="95%"  border="0" cellpadding="0" cellspacing="1" bgcolor="#b1bfee">
  <form name=prodtable method="post" action="">
    <%Dim a,b,c 
set rsmid=server.createobject("adodb.recordset") 
sqlmid="select distinct LarCode,LarSeq,MidCode,midSeq from bclass1 order by LarSeq,MIdSeq" 
rsmid.Open sqlmid,conn,1,1 

response.write "<TR><TD width=100 align=center bgcolor=#FFFFFF>商品分类</td><td bgcolor=#FFFFFF>"
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 bproduc1 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 bproduc1 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

ProdName="商品名称"
Prodid="商品编号"
shichang="市场价"
remai="优惠价"
Proddisc="商品简介"
MemoSpec="商品介绍"
Modeltext="商品型号："
prodtext1="商品单位："
prodtext2="商品品牌："
%>
<%
Set rstxt = conn.Execute("select * from shopsetup") 
mingcheng=rstxt("ProdNametext")
bianhao=rstxt("ProdIdtext")
yuanjia=rstxt("PriceOrigintext")
xianjia=rstxt("PriceListtext")
huiyuanjia=rstxt("zidingyi2")
jifenming=rstxt("jifenname")
jianjie=rstxt("ProdDisctext")
jieshao=rstxt("MemoSpectext")
xinghao=rstxt("Modeltext")
pinpai=rstxt("prodtext1")
chandi=rstxt("prodtext2")

set rstxt=nothing
%>

    <TR> 
      <TD width=100 align=center bgcolor=#FFFFFF> <input name="Prodidtext" type="text" value="<%=bianhao%>" size=7> 
      </td>
      <td bgcolor=#FFFFFF> <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 bgcolor=#FFFFFF> <input name="Prodnametext" type="text" value="<%=mingcheng%>" size=7> 
      </td>
      <td bgcolor=#FFFFFF> <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 bgcolor=#FFFFFF> <input name="Modeltext" type="text" value="<%=xinghao%>" size=7> 
      </td>
      <td bgcolor=#FFFFFF> <input name="Model" type="text" value=""> &nbsp;<img src=../images/admin/memo.gif alt='选填，填写商品的其它属性<br>如：“商品型号”、“品牌”、“产地”等'></TD>
    </TR>
    <TR> 
      <TD width=100 align=center bgcolor=#FFFFFF> <input name="Prodtext1" type="text" value="<%=pinpai%>" size=7> 
      </td>
      <td bgcolor=#FFFFFF> <input name="prod1" type="text" value=""> </TD>
    </TR>
    <TR> 
      <TD width=100 align=center bgcolor=#FFFFFF><input name="Prodtext2" type="text" value="<%=chandi%>" size=7></td>
      <td bgcolor=#FFFFFF> <input name="prod2" type="text" value=""> </TD>
    </TR>
    <TR bgcolor="#FFFFFF"> 
      <TD align=center>所需积分</td>
      <td><input name="jifenzhi" type="text" value="0" size="6" maxlength="10"></TD>
    </TR>
    <TR bgcolor="#FFFFFF"> 
      <TD width=100 align=center>备货状态</td>
      <td> <input type="radio" name="Quantity" value="1" checked>
        有货&nbsp; <input type="radio" name="Quantity" value="0">
        缺货&nbsp;</TD>
    </TR>
    <TR bgcolor="#FFFFFF"> 
      <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.mcvrlab.com/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 bgcolor="#FFFFFF"> 
      <TD width=100 align=center valign="top"> <input name="ProdDisctext" type="text" value="<%=jianjie%>" size=7> 
        <br>
        (200字内)</td>
      <td><textarea name="ProdDisc" cols="60" rows="4"></textarea> </TD>
    </TR>
    <TR bgcolor="#FFFFFF"> 
      <TD align=center valign="top">商品常规信息</td>
      <td>常规属性一： 
        <input type="radio" name="kaiguan1" value="1">
        引用&nbsp; <input type="radio" name="kaiguan1" value="0" checked>
        不引用<br>
        常规属性二： 
        <input type="radio" name="kaiguan2" value="1" >
        引用&nbsp; <input type="radio" name="kaiguan2" value="0" checked>
        不引用<br>
        常规属性三： 
        <input type="radio" name="kaiguan3" value="1">
        引用&nbsp; <input type="radio" name="kaiguan3" value="0" checked>
        不引用<br>
        常规属性四： 
        <input type="radio" name="kaiguan4" value="1">
        引用&nbsp; <input type="radio" name="kaiguan4" value="0" checked>
        不引用<br>
        常规属性五： 
        <input type="radio" name="kaiguan5" value="1">
        引用&nbsp; <input type="radio" name="kaiguan5" value="0" checked>
        不引用</TD>
    </TR>
    <TR bgcolor="#FFFFFF"> 
      <TD width=100 align=center valign="top"> <input name="MemoSpectext" type="text" value="<%=jieshao%>" size=7> 
      </td>
      <td> <br> <textarea name="MemoSpec" style="display:none"></textarea> <iframe ID="edit1" src="../edit/ewebeditor.asp?id=Memospec&style=putong" frameborder="0" scrolling="no" width="100%" HEIGHT="350"></iframe> 
      </TD>
    </TR>
    <TR bgcolor="#FFFFFF"> 
      <TD colspan=2><INPUT TYPE="hidden" name=add value=ok> <INPUT TYPE="hidden" NAME="more_pic" value="0"> 
        <INPUT TYPE="hidden" NAME="zidingyi2" value="无"> 
        <INPUT TYPE="hidden" NAME="zidingyi1" value="无"> 
        <INPUT TYPE="hidden" NAME="zdy2" value="自定义2"> <INPUT TYPE="hidden" NAME="zdy1" value="自定义1"> 
        <INPUT NAME="PriceOrigintext" TYPE="hidden" id="PriceOrigintext" value="无"> 
        <INPUT NAME="PriceOrigin" TYPE="hidden" value="1"> <INPUT NAME="PriceListtext" TYPE="hidden" id="PriceListtext" value="无"> 
        <INPUT NAME="PriceList" TYPE="hidden" value="1"> <INPUT NAME="jifenname" TYPE="hidden" value="无">
        <INPUT NAME="Remark" TYPE="hidden" value="0"> <INPUT NAME="tejia" TYPE="hidden" id="tejia" value="0"> 
        <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


set rs = server.createobject("adodb.recordset")
sql="select * from bproduc1 where ProdNum in ("&delid&")"
rs.open sql,conn,1,3
do while not rs.eof
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 bproduc1 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("zidingyi1")=request.form("zidingyi1")'自定义一名称
rs("zdy1")=request.form("zdy1")'自定义一
rs("zidingyi2")=request.form("zidingyi2")'自定义一名称
rs("zdy2")=request.form("zdy2")'自定义一
rs("kaiguan1")=request.form("kaiguan1")'编号名称
rs("kaiguan2")=request.form("kaiguan2")'编号名称
rs("kaiguan3")=request.form("kaiguan3")'品名名称
rs("kaiguan4")=request.form("kaiguan4")'商品名称
rs("kaiguan5")=request.form("kaiguan5")'型号名称

rs("PriceOrigintext")=request.form("PriceOrigintext")'原价名称
rs("PriceOrigin")=request.form("PriceOrigin")'原价
rs("PriceListtext")=request.form("PriceListtext")'现价名称
rs("PriceList")=request.form("PriceList")'现价
rs("jifenname")=request.form("jifenname")'现价
rs("jifenzhi")=request.form("jifenzhi")'现价
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("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



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 bproduc1 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 height="5"><tr><td></td></tr></table>
<TABLE cellSpacing=0 cellPadding=0 width=95% border=0 style="BORDER-RIGHT: #b1bfee 1px solid; BORDER-TOP: #b1bfee 1px solid; BORDER-LEFT: #b1bfee 1px solid; BORDER-BOTTOM: #b1bfee 1px solid" 
>
  <TBODY>
    <TR>
      <TD width="90%" bgColor=#f4f5fd><font color="#000000">　<B><font color="#FF0000">&nbsp;编辑</font><font color="#000000"><B><font color="#FF0000">积分兑奖</font></B></font><font color="#FF0000">商品</font></B></font></TD>
      <TD bgColor=#f4f5fd height=30></TD>
    </TR>
  </TBODY>
</TABLE>
		  <table height="5"><tr><td></td></tr></table>
<%
     Set rsbp=Server.CreateObject("ADODB.Recordset")
	 sql="select * from bproduc1"
	 rsbp.open sql,conn,1,3
%>

<table width="95%"  border="0" cellpadding="0" cellspacing="1" bgcolor="#b1bfee">
  <!--表单提交程序中加入 page=<%=request("page")%> 是为了编辑商品后返回当前页-->
  <form name=prodtable method="post" action='prod_dj.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 bclass1 order by LarSeq,MIdSeq " 
rsmid.Open sqlmid,conn,1,1 
%>
    <TR bgcolor="#FFFFFF"> 
      <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 bgcolor="#FFFFFF"> 
      <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 bgcolor="#FFFFFF"> 
      <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 bgcolor="#FFFFFF"> 
      <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 bgcolor="#FFFFFF"> 
      <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 bgcolor="#FFFFFF"> 
      <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 bgcolor="#FFFFFF"> 
      <TD align=center>所需积分</td>
      <td><input name="jifenzhi" type="text" value="<%=rs("jifenzhi")%>" size="6" maxlength="10"></TD>
    </TR>
    <TR bgcolor="#FFFFFF"> 
      <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;</TD>
    </TR>
    <TR bgcolor="#FFFFFF"> 
      <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.mcvrlab.com/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>
    <TR bgcolor="#FFFFFF"> 
      <TD align=center valign="top">商品常规信息</td>
      <td>常规属性一： 
        <input type="radio" name="kaiguan1" value="1" <%if rs("kaiguan1")=1 then%>checked<%end if%>>
        引用&nbsp; <input type="radio" name="kaiguan1" value="0" <%if rs("kaiguan1")=0 then%>checked<%end if%>>
        不引用<br>
        常规属性二： 
        <input type="radio" name="kaiguan2" value="1" <%if rs("kaiguan2")=1 then%>checked<%end if%>>
        引用&nbsp; <input type="radio" name="kaiguan2" value="0" <%if rs("kaiguan2")=0 then%>checked<%end if%>>
        不引用<br>
        常规属性三： 
        <input type="radio" name="kaiguan3" value="1" <%if rs("kaiguan3")=1 then%>checked<%end if%>>
        引用&nbsp; <input type="radio" name="kaiguan3" value="0" <%if rs("kaiguan3")=0 then%>checked<%end if%>>
        不引用<br>
        常规属性四： 
        <input type="radio" name="kaiguan4" value="1" <%if rs("kaiguan4")=1 then%>checked<%end if%>>
        引用&nbsp; <input type="radio" name="kaiguan4" value="0" <%if rs("kaiguan4")=0 then%>checked<%end if%>>
        不引用<br>
        常规属性五： 
        <input type="radio" name="kaiguan5" value="1" <%if rs("kaiguan5")=1 then%>checked<%end if%>>
        引用&nbsp; <input type="radio" name="kaiguan5" value="0" <%if rs("kaiguan5")=0 then%>checked<%end if%>>
        不引用</TD>
    </TR>
    <TR bgcolor="#FFFFFF"> 
      <TD width=100 align=center valign="top"> <input name="Proddisctext" type="text" value="<%=rs("Proddisctext")%>" size=7> 
      </td>
      <td> <textarea name="ProdDisc" cols="60" rows="4" style="overflow:auto;"><%=rs("ProdDisc")%></textarea></TD>
    </TR>
    <TR bgcolor="#FFFFFF"> 
      <TD width=100 align=center valign="top"> <input name="MemoSpectext" type="text" value="<%=rs("MemoSpectext")%>" size=7> 
      </td>
      <td> <br> <textarea name="MemoSpec" style="display:none"><%=Server.HTMLEncode(rs("MemoSpec"))%></textarea> 
        <iframe ID="edit1" src="../edit/ewebeditor.asp?id=Memospec&style=putong" frameborder="0" scrolling="no" width="100%" HEIGHT="350"></iframe> 
      </TD>
    </TR>
    <TR bgcolor="#FFFFFF"> 
      <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 bgcolor="#FFFFFF"> 
      <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 bgcolor="#FFFFFF"> 
      <Td colspan=2><INPUT TYPE="hidden" name=modify value=ok> <INPUT TYPE="hidden" NAME="more_pic" value="0"> 
        <INPUT TYPE="hidden" NAME="zidingyi2" value="<%=rs("zidingyi2")%>"> <INPUT TYPE="hidden" NAME="zidingyi1" value="<%=rs("zidingyi1")%>"> 
        <INPUT NAME="zdy2" TYPE="hidden" id="zdy2" value="自定义2"> <INPUT NAME="zdy1" TYPE="hidden" id="zdy1" value="自定义1"> 
        <INPUT NAME="PriceOrigintext" TYPE="hidden" value="<%=rs("PriceOrigintext")%>"> 
        <INPUT NAME="PriceOrigin" TYPE="hidden" value="<%=rs("PriceOrigin")%>"> 
        <INPUT NAME="PriceListtext" TYPE="hidden" value="<%=rs("PriceListtext")%>"> 
        <INPUT NAME="PriceList" TYPE="hidden" value="<%=rs("PriceList")%>"> <INPUT NAME="jifenname" TYPE="hidden" value="<%=rsbp("jifenname")%>"> 
        <INPUT NAME="Remark" TYPE="hidden" id="Remark" value="0"> <INPUT NAME="tejia" TYPE="hidden" id="Remark2" value="0"> 
        <input type="submit" name="action" value="保存设置"></TD>
    </TR>
  </form>
</TABLE>

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


'推荐或取消推荐
sub tuijian()
set rs=server.createobject("adodb.recordset")
sql = "select * from bproduc1 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 bproduc1 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>
