📄 order_stat.asp
字号:
<!--#include file="conn.asp"-->
<%call time_out()%>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>商品销售统计</title>
</head>
<body>
<%pro_name=trim(request("pro_name"))
action=trim(request("action"))
if request("start_year")<>"" then
start_year=int(request("start_year"))
start_month=int(request("start_month"))
start_date=int(request("start_date"))
start_day=start_year & "-" & start_month & "-" & start_date & " 00:00:00"
end_year=int(request("end_year"))
end_month=int(request("end_month"))
end_date=int(request("end_date"))
end_day=end_year & "-" & end_month & "-" & end_date & " 23:59:00"
else
start_year=year(now())
start_month=month(now())
start_date=day(now())
end_year=year(now())
end_month=month(now())
end_date=day(now())
start_day=date() & " 00:00:00"
end_day=date() & " 23:59:00"
end if
%>
<table width="100%" border="0" cellpadding="0" cellspacing="1" bgcolor="6699cc">
<tr>
<td height="25" align="center">请输入统计条件</td>
</tr>
<tr>
<td align="center" bgcolor="#FFFFFF">
<table width="60%" border="0" cellspacing="0" cellpadding="0">
<form name="form1" method="post" action="order_stat.asp?action=search">
<tr>
<td width="40%" height="25" align="right">商品名称:</td>
<td width="60%"><input name="pro_name" type="text" id="pro_name" size="30"> </td>
</tr>
<tr>
<td height="25" align="right">开始时间:</td>
<td><select name="start_year" size="1">
<%for syear=2002 to 2020%>
<option <%if start_year=syear then%>selected<%end if%> value=<%=syear%>><%=syear%></option>
<%
if syear>2020 then exit for
next
%>
</select>
年
<select name="start_month" size="1">
<%for smonth=1 to 12%>
<option <%if smonth=start_month then%>selected<%end if%> value=<%=smonth%>><%=smonth%></option>
<%
if smonth>12 then exit for
next
%>
</select>
月
<select name="start_date" size="1">
<%for sdate=1 to 31%>
<option <%if start_date=sdate then%>selected<%end if%> value=<%=sdate%>><%=sdate%></option>
<%
if sdate>31 then exit for
next
%>
</select>
日</td>
</tr>
<tr>
<td height="25" align="right">结束时间:</td>
<td><select name="end_year" size="1">
<%for eyear=2002 to 2010%>
<option <%if eyear=end_year then%>selected<%end if%> value=<%=eyear%>><%=eyear%></option>
<%
if eyear>2010 then exit for
next
%>
</select>
年
<select name="end_month" size="1">
<%for emonth=1 to 12%>
<option <%if emonth=end_month then%>selected<%end if%> value=<%=emonth%>><%=emonth%></option>
<%
if emonth>12 then exit for
next
%>
</select>
月
<select name="end_date" size="1">
<%for edate=1 to 31%>
<option <%if edate=end_date then%>selected<%end if%> value=<%=edate%>><%=edate%></option>
<%
if edate>31 then exit for
next
%>
</select>
日</td>
</tr>
<tr>
<td height="25" colspan="2" align="center"><input type="submit" name="Submit" value="开始查询"></td>
</tr>
</form>
</table>
</td>
</tr>
</table>
<table width="100%" border="0" cellspacing="1" cellpadding="0">
<tr align="center" bgcolor="6699cc">
<td height="25">商品名称</td>
<td>销售量</td>
<td>销售额</td>
</tr>
<%
set rs=server.createobject("adodb.recordset")
if action="search" then
sql="select pid,sum(shuliang) as totalnum,sum(zonge) as totalmoney from [order] where 1=1"
if pro_name<>"" then
set rsv=conn.execute("select pid,pro_name from product where pro_name = '"&pro_name&"'")
if rsv.eof and rsv.bof then
pid=0
else
pid=rsv("pid")
end if
rsv.close:set rsv=nothing
sql=sql & " and pid = "&pid
end if
sql = sql & " and ( addtime between #"&start_day&"# and #"&end_day&"#) group by pid order by sum(zonge) desc"
else
sql="select pid,sum(shuliang) as totalnum,sum(zonge) as totalmoney from [order] where ( addtime between #"&start_day&"# and #"&end_day&"#) group by pid order by sum(zonge) desc"
end if
rs.open sql,conn,1,1
if rs.eof and rs.bof then%>
<tr><td colspan="3" height="25">未找到符合条件的记录</td></tr>
<%
else
rs.pagesize=18
page = cint(request("page"))
if page = "" then page = 1
if not(isnumeric(page)) then page=1
if page<1 then page=1
if page >= rs.pagecount then page = rs.pagecount
rs.absolutepage = page
for j=1 to rs.PageSize
if (j mod 2)<>0 then
bgcolor="ffffff"
else
bgcolor="CBDDE7"
end if
%>
<tr align="center" bgcolor="<%=bgcolor%>">
<td height="25">
<%
set rsv=server.createobject("adodb.recordset")
sqlv="select pid,pro_name from product where pid="&rs("pid")
rsv.open sqlv,conn,1,1
%>
<%=rsv("pro_name")%>
<%rsv.close:set rsv=nothing%>
</td>
<td><%=rs("totalnum")%> 件</td>
<td><%=rs("totalmoney")%> 元</td>
</tr>
<%rs.movenext
if rs.eof then exit for
next
%>
<tr>
<td height="25" colspan="6" align="center">
<p align="center">共有记录<%=rs.recordcount%>条
<%=page%>/<%=rs.pagecount%> <A href="<%request.servervariables("document_name")%>?page=<%=page-1%>&action=<%=action%>&pro_name=<%=pro_name%>&start_year=<%=start_year%>&start_month=<%=start_month%>&start_date=<%=start_date%>&end_year=<%=end_year%>&end_month=<%=end_month%>&end_date=<%=end_date%>">上一页</A> <A href="<%request.servervariables("document_name")%>?page=<%=page+1%>&action=<%=action%>&pro_name=<%=pro_name%>&start_year=<%=start_year%>&start_month=<%=start_month%>&start_date=<%=start_date%>&end_year=<%=end_year%>&end_month=<%=end_month%>&end_date=<%=end_date%>">下一页</A> 转到第 <SELECT onChange="window.location='?action=<%=action%>&pro_name=<%=pro_name%>&start_year=<%=start_year%>&start_month=<%=start_month%>&start_date=<%=start_date%>&end_year=<%=end_year%>&end_month=<%=end_month%>&end_date=<%=end_date%>&page='+this.value" name=gopage>
<%for x=1 to rs.pagecount%>
<OPTION <%if x=page then%>selected<%end if%> value=<%=x%>><%=x%></OPTION>
<%next%>
</SELECT> 页 </td>
</tr>
<%
end if
rs.close
set rs=nothing
%>
</table>
</body>
</html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -