📄 foodact.asp
字号:
<!--#include file="conn.asp"-->
<!-- #include file="shopconn.asp" -->
<%
if Request.Cookies("NC")="" or Request.Cookies("NC")="访客" then
Response.Write("对不起,您不是社区用户,请先注册!")
Response.End
else
dim act,foodid,shopid
%><HTML><HEAD><title>超级市场 → 超市进货</title><%call shophead()
dim brs
shopid=request("shopid")
set brs=server.createobject("adodb.recordset")
sql="select boss from [shop] where id="&shopid
brs.open sql,connshop,1,1
if brs.eof then
response.write "<script>alert('别人的店都敢乱动,110可是免费的!');history.go(-1);</script>"
response.end
elseif brs(0)<>membername then
response.write "<script>alert('别人的店都敢乱动,110可是免费的!');history.go(-1);</script>"
response.end
end if
act=request("act")
select case act
case "input"
call foodinp()
case "clear"
call foodcle()
case "drop"
call fooddro()
case "foodout"
call foodout()
case "foodedit"
call foodedit()
case "foodin"
call foodin()
case "edited"
call edited()
case else
response.write "<script>alert('你想干什么???!!!');history.go(-1);</script>"
response.end
end select
%></center></body></html>
<%
end if
sub foodinp()
dim maxlist,currentpage,pcount,page_count,endpage
dim foodnum
dim fooduser
maxlist=20%>
<TABLE cellpadding="2" cellspacing="1" width=700 bgcolor="#F2F8FF">
<TBODY bgcolor="#B7D3FF">
<TR><TD colspan="6" align="center" height="25">
<%
set rs=server.createobject("adodb.recordset")
sql="select foodpic,foodtext,foodname,foodsx,foodvalue,foodmoney,foodlast,id from food"
rs.open sql,connshop,1,1
if rs.eof and rs.bof then%><BR>超市目前尚无任何商品可以进购<BR><BR><%else
foodnum=rs.recordcount
currentpage=trim(request("page"))
if currentpage="" or not isinteger(currentpage) then
currentpage=1
else
currentpage=clng(currentpage)
if err then
currentpage=1
err.clear
end if
end if
if foodnum mod maxlist=0 then
Pcount= foodnum \ maxlist
else
Pcount= foodnum \ maxlist+1
end if%>超市现提供商品 <font color=red><%=foodnum%></font> 类商品</TD></TR><TR>
<TD align="center" height="25">商品图例</TD>
<TD align="center">名称</TD>
<TD align="center">功能</TD>
<TD align="center">价格</TD>
<TD align="center">保质期</TD>
<TD align="center">操作</TD>
</TR>
<%rs.movefirst
if currentpage > Pcount then currentpage = Pcount
if currentpage<1 then currentpage=1
RS.Move (currentpage-1) * maxlist
page_count=0
do while not rs.eof and page_count < maxlist
select case rs("foodsx")
case "JYZ"
fooduser="经验"
case "ML"
fooduser="魅力"
case "FTS"
user="发帖数"
end select%>
<TR>
<TD align="center"><img src=<%=rs("foodpic")%> alt=<%=rs("foodtext")%>></TD>
<TD align="center"><%=rs("foodname")%></TD>
<TD align="center"><%=fooduser%>+<%=rs("foodvalue")%></TD>
<TD align="center"><%=rs("foodmoney")*0.8%></TD>
<TD align="center"><%=rs("foodlast")%></TD>
<form method=post action=?shopid=<%=shopid%>&foodid=<%=rs("id")%>&act=foodin><TD align="center">数量:<input name=foodnum type=text size=5 value=1> <input type=submit value=进货></TD></form>
</TR>
<%page_count=page_count+1
rs.movenext
loop
end if
%><tr><td colspan="6" align="center" height="25">页次:<b><%=currentpage%></b>/<b><%=Pcount%></b>页
每页:<b><%=maxlist%></b> 总数:<b><%=foodnum%></b> 分页:
<%if currentpage > 4 then%>
<a href="?shopid=<%=shopid%>&act=<%=act%>&page=1">[1]</a>...
<%
end if
if Pcount>currentpage+3 then
endpage=currentpage+3
else
endpage=Pcount
end if
for i=currentpage-3 to endpage
if not i<1 then
if i = clng(currentpage) then%><font color=red>[<%=i%>]</font><%else%>
<a href="?shopid=<%=shopid%>&act=<%=act%>&page=<%=i%>"&><%=i%></a>
<% end if
end if
next
if currentpage+3 < Pcount then%>... <a href=?shopid=<%=shopid%>&act=<%=act%>&page=<%=Pcount%>>[<%=Pcount%>]</a><%end if%>
</td></tr></TBODY></table>
rs.close
set rs=nothing
<%end sub
sub foodcle()
set rs=server.createobject("adodb.recordset")
sql="delete from food2 where shopid="&shopid
rs.open sql,connshop,1,3%>
<table><tr><td align=center>恭喜,操作成功!</td></tr>
<%response.write "<meta http-equiv=refresh content=""3;url=myshop.asp"">"%>
<tr><td>系统将自动在3秒后返回我的商店,您现在可以选择下面操作:
<UL><li><a href=/><font color=#000000>返回中央广场</font></a></li>
<li><a href=shoped.asp><font color=#000000>返回我的购物车</font></a></li>
<li><a href=shop.asp><font color=#000000>返回商店列表</font></a></li></UL>
</td></tr></table>
<%end sub
sub fooddro()
foodid=request("foodid")
set rs=server.createobject("adodb.recordset")
sql="delete from food2 where shopid="&shopid&" AND id="&foodid
rs.open sql,connshop,1,3
%>
<table><tr><td align=center>恭喜,操作成功!</td></tr>
<%response.write "<meta http-equiv=refresh content=""3;url=myshop.asp"">"%>
<tr><td>系统将自动在3秒后返回我的商店,您现在可以选择下面操作:
<UL><li><a href=/><font color=#000000>返回中央广场</font></a></li>
<li><a href=shoped.asp><font color=#000000>返回我的购物车</font></a></li>
<li><a href=shop.asp><font color=#000000>返回商店列表</font></a></li></UL>
</td></tr></table>
<%
end sub
sub foodout()
dim foodnum,foodmoney
dim brs
foodid=request("foodid")
set rs=server.createobject("adodb.recordset")
sql="select foodnum,foodmoney from food2 where shopid="&shopid&" AND id="&foodid
rs.open sql,connshop,1,1
foodnum=rs("foodnum")
foodmoney=rs("foodmoney")
rs.close
sql="delete from food2 where shopid="&shopid&" AND id="&foodid
rs.open sql,connshop,1,3
set brs=server.createobject("adodb.recordset")
sql="select JQ from [HY] where NC='"&membername&"'"
brs.open sql,conn,1,3
brs(0)=brs(0)+foodmoney*foodnum\2
brs.update
brs.close
set brs=nothing
%>
<table><tr><td align=center>恭喜,操作成功!</td></tr>
<%response.write "<meta http-equiv=refresh content=""3;url=myshop.asp"">"%>
<tr><td>系统将自动在3秒后返回我的商店,您现在可以选择下面操作:
<UL><li><a href=/><font color=#000000>返回中央广场</font></a></li>
<li><a href=shoped.asp><font color=#000000>返回我的购物车</font></a></li>
<li><a href=shop.asp><font color=#000000>返回商店列表</font></a></li></UL>
</td></tr></table>
<%
end sub
sub foodin()
dim foodnum,foodmoney
dim brs,usermoney
foodid=request("foodid")
if request("foodnum")=null or trim(request("foodnum"))="" then
response.write "<script>alert('请输入购买的数量!');history.go(-1);</script>"
response.end
elseif not(isnumeric(request("foodnum"))) then
response.write "<script>alert('请正确输入购买的数量!');history.go(-1);</script>"
response.end
elseif cint(request("foodnum"))<=0 then
response.write "<script>alert('请正确输入购买的数量!');history.go(-1);</script>"
response.end
else
set rs=server.createobject("adodb.recordset")
sql="select JQ from [HY] where NC='"&membername&"'"
rs.open sql,conn,1,1
usermoney=rs(0)
rs.close
set rs=nothing
foodnum=request("foodnum")
set rs=server.createobject("adodb.recordset")
sql="select * from food where id="&foodid
rs.open sql,connshop,1,1
foodmoney=rs("foodmoney")
if usermoney<foodnum*foodmoney/2 then
response.write "<script>alert('您的金钱不足!无法进货。');history.go(-1);</script>"
response.end
else
set brs=server.createobject("adodb.recordset")
sql="select JQ from [HY] where NC='"&membername&"'"
brs.open sql,conn,1,3
brs(0)=brs(0)-cdbl(foodmoney*foodnum*0.8)
brs.update
brs.close
set brs=nothing
set brs=server.createobject("adodb.recordset")
sql="select * from food2 where (id is null)"
brs.open sql,connshop,1,3
brs.AddNew
brs("foodname")=rs("foodname")
brs("foodsx")=rs("foodsx")
brs("foodvalue")=rs("foodvalue")
brs("foodpic")=rs("foodpic")
brs("foodmoney")=rs("foodmoney")
brs("foodtext")=rs("foodtext")
brs("shopid")=shopid
brs("foodnum")=foodnum
brs("boss")=membername
brs("fooddate")=date()
brs("foodlast")=rs("foodlast")
brs.update
brs.close
set brs=nothing
end if
%>
<table><tr><td align=center>恭喜,操作成功!</td></tr>
<%response.write "<meta http-equiv=refresh content=""3;url=myshop.asp"">"%>
<tr><td>系统将自动在3秒后返回我的商店,您现在可以选择下面操作:
<UL><li><a href=/><font color=#000000>返回中央广场</font></a></li>
<li><a href=shoped.asp><font color=#000000>返回我的购物车</font></a></li>
<li><a href=shop.asp><font color=#000000>返回商店列表</font></a></li></UL>
</td></tr></table>
<%
end if
end sub
sub foodedit()
foodid=request("foodid")
set rs=server.createobject("adodb.recordset")
sql="select foodname,foodpic,foodtext,foodmoney from food2 where id="&foodid
rs.open sql,connshop,1,3
%>
<TABLE width=700 bgcolor="#B7D3FF" cellpadding="0" cellspacing="0">
<TR>
<TD align="center" height="25" colspan="2"><font color=red><b>修改商品</b></font></td></tr>
<TR><form method=post action=?foodid=<%=foodid%>&shopid=<%=shopid%>&act=edited name=nowform>
<td width=30% height="25" align="right">名 称:</td>
<td width=70%><input type=text name=foodname size=8 value=<%=rs("foodname")%>></td>
</tr>
<tr>
<td height="25" align="right">图 例:</td>
<td><input type=text name=foodpic value=<%=rs("foodpic")%>> 请填写商品的图片地址</td>
</tr>
<tr>
<td height="25" align="right">说 明:</td>
<td><input type=text name=foodtext value=<%=rs("foodtext")%>></td>
</tr>
<tr>
<td height="25" align="right">价 格:</td>
<td><input type=text name=foodmoney size=5 value=<%=rs("foodmoney")%>> 商店进货的价格为设定价格的<font color=red>80%</font>,退货的价格为设定价格的<font color=red>50%</font>。</td>
</tr>
<tr><td align="center" height="25" colspan="2"><input type=submit value=修改> <input type=reset value=重置></td></form></tr></table>
<%
rs.close
set rs=nothing
end sub
sub edited()
if request("foodname")="" then
response.write "<script>alert('请输入商品名称!');history.go(-1);</script>"
elseif request("foodpic")="" then
response.write "<script>alert('请输入商品的图片地址!');history.go(-1);</script>"
elseif request("foodtext")="" then
response.write "<script>alert('请输入商品说明!');history.go(-1);</script>"
elseif request("foodmoney")="" then
response.write "<script>alert('请输入商品价格!');history.go(-1);</script>"
elseif not isnumeric(request("foodmoney")) then
response.write "<script>alert('请确认输入的价格为数值!');history.go(-1);</script>"
elseif cint(request("foodmoney"))<=0 then
response.write "<script>alert('请确认输入的价格大于0!');history.go(-1);</script>"
end if
foodid=request("foodid")
set rs=server.createobject("adodb.recordset")
sql="select foodname,foodpic,foodmoney,foodtext from food2 where id="&foodid
rs.open sql,connshop,1,3
rs("foodname")=request("foodname")
rs("foodpic")=request("foodpic")
rs("foodmoney")=request("foodmoney")
rs("foodtext")=request("foodtext")
rs.update
rs.close
%>
<table><tr><td align=center>恭喜,操作成功!</td></tr>
<%response.write "<meta http-equiv=refresh content=""3;url=myshop.asp"">"%>
<tr><td>系统将自动在3秒后返回我的商店,您现在可以选择下面操作:
<UL><li><a href=/><font color=#000000>返回中央广场</font></a></li>
<li><a href=shoped.asp><font color=#000000>返回我的购物车</font></a></li>
<li><a href=shop.asp><font color=#000000>返回商店列表</font></a></li></UL>
</td></tr></table>
<%
end sub
connshop.close
set connshop=nothing%>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -