<%
set request2=new UpLoadClass
request2.FileType="gif/jpg/rar/zip"
request2.SavePath="UpLoadFile/"
request2.open()
if request2.form("action")="add" then
usercode=sqlesc(session("usercode"))
productName=sqlesc(request2.form("name"))
bigCategory=sqlesc(request2.form("bigCategory"))
smallCategory=sqlesc(request2.form("smallCategory"))
addtime=sqlesc(request2.form("addtime"))
info=sqlesc(request2.form("info"))
If Not IsDate(addtime) Then response.write "添加时间格式不正确":response.End
If usercode="" then response.redirect "../logout.asp"
If productName="" then response.write "请填写产品名称":response.End
If bigCategory="" then response.write "请选择产品大类":response.End
if info="" then response.write "请填写产品介绍":response.End
sql="insert into products (iMUID,cUserCode,cProductBigCategory,cProductSmallCategory,cProductName, cProductInfo, dAddTime) values"
sql=sql&"(0,'"&usercode&"','"&bigCategory&"','"&smallCategory&"','"&productName&"','"&info&"','"&addtime&"')"
echo sql
'response.End
conn.execute sql
for intTemp=1 to Ubound(request2.FileItem)
'显示文件保存状态
select case request2.form(formName&"_Err")
case -1:
response.write "没有文件上传<br>"
case 0:
response.write "上传文件成功<br>"
intCount=intCount+1
case 1:
response.write "文件太大,拒绝上传<br>"
case 2:
response.write "文件格式不对,拒绝上传<br>"
case 3:
response.write "文件太大且格式不对,拒绝上传<br>"
end select
if request2.form(formName)<>"" then
sql="insert into productImg (curl, dAddTime) values"
sql=sql&" ('"&request2.SavePath&request2.form(formName)&"','"&addtime&"')"
echo sql
'response.End
conn.execute sql
end if
next
'----列出所有上传了的文件结束----
response.write "<br>"&intCount&" 个文件上传成功! "
response.write "[<a href=""javascript:history.back();"">返回</a>]"
set request2=nothing
Response.Write("<script>alert('添加成功');location.href=""product.asp"";</script>")
elseif request2.form("action")="modify" then
usercode=sqlesc(session("usercode"))
productName=sqlesc(request2.form("name"))
bigCategory=sqlesc(request2.form("bigCategory"))
smallCategory=sqlesc(request2.form("smallCategory"))
addtime=sqlesc(request2.form("addtime"))
info=sqlesc(request2.form("info"))
pid=sqlesc(request2.form("pid"))
If Not IsDate(addtime) Then response.write "添加时间格式不正确":response.End
If productName="" then response.write "请填写产品名称":response.End
If bigCategory="" then response.write "请选择产品大类":response.End
if info="" then response.write "请填写产品介绍":response.End
sql="update products set "
sql=sql&" cProductName='"&productName&"',"
sql=sql&" cProductBigCategory='"&bigCategory&"',"
sql=sql&" cProductSmallCategory='"&smallCategory&"',"
sql=sql&" cProductInfo='"&info&"',"
sql=sql&" dAddTime='"&addtime&"'"
sql=sql&" where iPID='"&pid&"'"
echo sql
'response.End
conn.execute sql
for intTemp=1 to Ubound(request2.FileItem)
pid=sqlesc(Request.QueryString("id"))
if pid<>"" then
sql="delete from productImg where daddTime in (SELECT dAddTime FROM Products WHERE (iPID = "&pid&"))"
echo sql
conn.execute sql
sql="delete from products where iPID in ("&pid&")"
echo sql
conn.execute sql
Response.Write("<script>alert('删除成功');location.href=""product.asp"";</script>")
conn.execute sql
end if
picid=sqlesc(request.QueryString("picid"))
if picid<>"" then
sql="delete from productImg where iimgId in ("&picid&")"
echo sql
conn.execute sql
Response.Write("<script>alert('删除成功');location.href=""product.asp?action=modify&id="&request("did")&"""</script>")
'response.redirect "product.asp?action=modify&id="&request("did")&""
end if
<table width=800 border="0" align=center cellpadding="3" cellspacing="1" bgcolor="#FFFFFF">
<tr bgcolor="#e5eef5">
<td colspan="8"><div align="center" style="FONT-WEIGHT: bold;COLOR: #369;">产品列表</div></td>
</tr>
<tr bgcolor="f0f0f0">
<td width="30">序号</td>
<td width="110">产品大类</td>
<td width="116">产品小类</td>
<td width="227">产品名称</td>
<td width="227">发布时间</td>
<td width="47">操作</td>
</tr>
<%
ii=(page-1)*sizeperpage+1
For i = 1 to rs.PageSize
if rs.EOF then
Exit For
end if '利用for next 循环依次读出记录
%>
<tr bgcolor="f0f0f0">
<td><%=ii%></td>
<td><%=rs("cProductBigCategory")%></td>
<td><%if rs("cProductSmallCategory")="" then
echo "无小类"
else
echo rs("cProductSmallCategory")
end if
%></td>
<td><%=rs("cProductName")%></td>
<td><%=rs("dAddTime")%></td>
<td><a title="修改" href="product.asp?action=modify&id=<%=rs("iPID")%>
<%if not isempty(request("page")) then response.write "&page="&request("page")%>">
<img src="images/edit.gif" width="18" height="13" border="0"></a>
<a title="删除" href="#" onClick="checkdelete(<%=rs("iPID")%>)">
<img src="images/delete2.gif" width="18" height="13" border="0"></a></td>
</tr>
<%
rs.movenext
ii=ii+1
next %>
<tr bgcolor="#e5eef5">
<td height="20" colspan="8">
<%call fenye("product.asp",urlstr)%></td>
</tr>
</table>
<%end if 'rs.eof and rs.bof%>
<%
if request("action")="modify" then
set rs = server.createobject("adodb.recordset")
sql="select * from Products where cUserCode='"&session("usercode")&"' and iPID="&request("id")
'response.write sql
rs.open sql,conn,1,1
if rs.bof and rs.eof then
response.write "没有记录!"
response.end
end if
end if
%>
<%if request("action")="modify" then
sql="select * from productimg where daddTime='"&rs("daddTime")&"'"
set rsImg = server.createobject("adodb.recordset")
rsImg.open sql,conn,1,1
if rsImg.eof then urlnull="该产品还没有图片信息"
dim imgNum,url()
m=rsImg.RecordCount
redim url(m)
imgNum = 0
%>
<Script LANGUAGE="JavaScript" type="text/JavaScript">
var jsurl = new Array(<%=m%>);
var picid = new Array(<%=m%>);
</SCRIPT>
<%while not rsImg.eof%>
<Script LANGUAGE="JavaScript" type="text/JavaScript">
jsurl[<%=imgNum%>]="<%=rsImg("curl")%>";
picid[<%=imgNum%>]=<%=rsImg("iimgId")%>;
</SCRIPT>
<%
url(imgNum)=rsImg("curl")
rsImg.movenext
imgNum=imgNum+1
wend
%>
<Script LANGUAGE="JavaScript" type="text/JavaScript">
var num=1 //设置图片数初始值
var nummax=<%=m%> //图片数,可根据实际数更改
function img(sta){
obj=document.getElementById("img1");
objnum=document.getElementById("picnum");
if (obj.filters.item(0).Transition==23) // 这部分语句是用于改变切换样式,在23种样式中循环。
obj.filters.item(0).Transition=1;
else
obj.filters.item(0).transition++;
obj.filters.item(0).Apply();
if (sta==1) //以下部分用于切换图片和更新当前显示的图片号
num=num+1
else num=num-1
if (num>nummax) num=1
if (num<1) num=nummax