searchtscount.asp
来自「创建和运行动态、交互的Web服务器应用程序」· ASP 代码 · 共 249 行
ASP
249 行
<!--#include file="conn.asp"-->
<%
dim action,s_year,s_month,rs_ts,ccount,scount,i,ii,page
action = request("action")
ccount=0:scount=0:page=1
%>
<html>
<head>
<title>销售统计</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<link href="../images/css2.css" rel="stylesheet" type="text/css">
<SCRIPT LANGUAGE="JavaScript">
<!--
function checksearch()
{
if(document.searchtscount.s_year.value==0) {
document.searchtscount.s_year.focus();
alert("请选择要查询的年份!");
return false;
}
if(document.searchtscount.s_month.value==0 && document.searchtscount.s_day.value!=0){
document.searchtscount.s_month.focus();
alert("请选择要查询的月份!");
return false;
}
}
//-->
</script>
</head>
<table width="90%" height="450" border="0" cellpadding="0" cellspacing="0">
<tr>
<td bgcolor="#ece9d8"><br><table width="98%" border="0" align="center" cellpadding="0" cellspacing="0">
<tr><td>
<table width=77 border="0" cellpadding="0" cellspacing="0">
<tr valign=bottom>
<td background=images/get_img.gif width=77 height=26><P style='PADDING-LEFT: 7px'><div align="center"><font color=#ffffff>退书查询</font></div></td>
</tr>
</table>
<table width="98%" border="1" cellspacing="0" cellpadding="0" bordercolordark="#ffffff" bordercolorlight="#666666">
<tr><td><table width="100%" border="1" cellspacing="0" cellpadding="0"><tr><td>
<table width="100%" border="0" align="center" cellpadding="0" cellspacing="0">
<form name="searchtscount" method="post" action="searchtscount.asp?action=list_search" >
<tr height=25>
<td width="16%" bgcolor="#ece9d8" align="center"><input type="button" name="b_month" class="bt4" value="本月退书" onClick="location.href='searchtscount.asp?action=list_search&s_year=<%=year(now)%>&s_month=<%=month(now)%>'">
<td width="16%" bgcolor="#ece9d8" align="center"><input type="button" name="b_year" class="bt4" value="本年退书" onClick="location.href='searchtscount.asp?action=list_search&s_year=<%=year(now)%>'">
<td width="16%" bgcolor="#ece9d8" align="right">历史查询
<td width="10%" bgcolor="#ece9d8">
<select name="s_year" id="s_year">
<option value="0" selected>选择年</option>
<%for ii=2000 to 2010%>
<option value=<%=ii%>><%=ii%></option>
<%next%>
</select>
<td width="10%" bgcolor="#ece9d8">
<select name="s_month" id="s_month">
<option value="0" selected>选择月</option>
<%for ii=1 to 12%>
<option value=<%=ii%>><%=ii%></option>
<%next%>
</select>
<td width="10%" bgcolor="#ece9d8">
<select name="s_day" id="s_day">
<option value="0" selected>选择日</option>
<%for ii=1 to 31%>
<option value=<%=ii%>><%=ii%></option>
<%next%>
</select>
<td bgcolor="#ece9d8" align="center"><input type="submit" name="Submit" class="bt3" value="查 询" onClick="return checksearch();">
<td bgcolor="#ece9d8" align="center"><input type="button" name="Submit4" class="bt3" value="打 印" onclick="javascript:window.print()">
</tr>
</form>
</table>
<%select case action
case ""%>
<tr><td height=300 valign="top">
<table width="100%" border="0" align="center" cellpadding="1" cellspacing="1" bgcolor="#666666">
<tr>
<td width="6%" bgcolor="#ece9d8"><div align="center">序号</div></td>
<td bgcolor="#ece9d8"> 商品名称</td>
<td bgcolor="#ece9d8"><div align="center">定价</div></td>
<td bgcolor="#ece9d8"><div align="center">退书数</div></td>
<td bgcolor="#ece9d8"><div align="center">退书实洋</div></td>
</tr>
<tr>
<td width="6%" bgcolor="#ffffff" height=22></tr>
<td bgcolor="#ffffff"></td>
<td bgcolor="#ffffff"></td>
<td bgcolor="#ffffff"></td>
<td bgcolor="#ffffff"></td>
</tr>
</table>
<%
case "list_search"
s_year = request("s_year")
s_month = request("s_month")
s_day = request("s_day")
'//选月了
if s_month<>0 then
'//选日了
if s_day<>0 then
set rs_ts=server.CreateObject("adodb.recordset")
rs_ts.open "SELECT shop_books.bookname,shop_books.bookid,shop_books.shichangjia,Sum(shop_tsaction.tscount) AS shixiaocount, Sum(shop_tsaction.tssy) as zonger FROM shop_tsaction INNER JOIN shop_books ON shop_tsaction.bookid = shop_books.bookid WHERE (((year(shop_tsaction.tsdate))="&s_year&") AND ((Month(shop_tsaction.tsdate))="&s_month&") AND ((day(shop_tsaction.tsdate))="&s_day&")) GROUP BY shop_books.bookname,shop_books.bookid,shop_books.shichangjia",conn,1,3
'//没选日
else
set rs_ts=server.CreateObject("adodb.recordset")
rs_ts.open "SELECT shop_books.bookname,shop_books.bookid,shop_books.shichangjia,Sum(shop_tsaction.tscount) AS shixiaocount, Sum(shop_tsaction.tssy) as zonger FROM shop_tsaction INNER JOIN shop_books ON shop_tsaction.bookid = shop_books.bookid WHERE (((year(shop_tsaction.tsdate))="&s_year&") AND ((Month(shop_tsaction.tsdate))="&s_month&")) GROUP BY shop_books.bookname,shop_books.bookid,shop_books.shichangjia",conn,1,3
end if
'//没选月
else
set rs_ts=server.CreateObject("adodb.recordset")
rs_ts.open "SELECT shop_books.bookname,shop_books.bookid,shop_books.shichangjia,Sum(shop_tsaction.tscount) AS shixiaocount, Sum(shop_tsaction.tssy) as zonger FROM shop_tsaction INNER JOIN shop_books ON shop_tsaction.bookid = shop_books.bookid WHERE (((year(shop_tsaction.tsdate))="&s_year&")) GROUP BY shop_books.bookname,shop_books.bookid,shop_books.shichangjia",conn,1,3
end if
%>
<tr><td height=300 valign="top">
<table width="100%" border="0" align="center" cellpadding="1" cellspacing="1" bgcolor="#666666">
<tr>
<td width="6%" bgcolor="#ece9d8"><div align="center">序号</div></td>
<td bgcolor="#ece9d8"> 商品名称</td>
<td bgcolor="#ece9d8"><div align="center">定价</div></td>
<td bgcolor="#ece9d8"><div align="center">退书数</div></td>
<td bgcolor="#ece9d8"><div align="center">退书实洋</div></td>
</tr>
<% if rs_ts.bof and rs_ts.eof then
response.write "<tr><td colspan=5 align=center bgcolor=#ffffff><div align=center><font color=blue>没有你要查询的记录!</font></td></tr>"
else
'/先计算出总数量和总码洋
do while not rs_ts.eof
ccount=ccount+rs_ts("shixiaocount")
scount=scount+rs_ts("zonger")
rs_ts.MoveNext
loop
'/记录指针到第一条
rs_ts.Movefirst
'/分页显示上部分
Page = rs_ts.AbsolutePage
rs_ts.PageSize=15
if Not IsEmpty(Request("Page")) then
Page = CInt(Request("Page"))
if Page > rs_ts.PageCount then
rs_ts.AbsolutePage = rs_ts.PageCount
elseif Page <= 0 then
Page = 1
else
rs_ts.AbsolutePage = Page
end if
else
Page = 1
end if
For i =0 to rs_ts.PageSize
if rs_ts.EOF then Exit For
%>
<tr>
<td bgcolor="#ffffff"><div align="center"><%=rs_ts.bookmark%></div></td>
<td bgcolor="#ffffff" STYLE='PADDING-LEFT: 5px'><a href=../book.asp?id=<%=rs_ts("bookid")%> target=_blank><%=rs_ts("bookname")%></a></td>
<td bgcolor="#ffffff"><div align="center"><font color=blue><%=formatnumber(rs_ts("shichangjia"),2)%></font></div></td>
<td bgcolor="#ffffff"><div align="center"><font color=red><%=-(rs_ts("shixiaocount"))%></font></div></td>
<td bgcolor="#ffffff"><div align="center"><font color=blue><%=-(formatnumber(rs_ts("zonger"),2))%></font></div></td>
</tr>
<% '/分页显示下部分
rs_ts.MoveNext
next
end if%>
<tr>
<td colspan=5 bgcolor="#ece9d8" height=40><div align="center">共<font color=blue><%=rs_ts.recordcount%></font>条<font color=blue><%=rs_ts.pagecount%></font>页
<%if request("page")>1 then%>
<a Href="searchtscount.asp?action=list_search&s_year=<%=s_year%>&s_month=<%=s_month%>&s_day=<%=s_day%>&Page=<%=1%>">首页</a> <a Href="searchtscount.asp?action=list_search&s_year=<%=s_year%>&s_month=<%=s_month%>&s_day=<%=s_day%>&Page=<%=page-1%>">上一页</a>
<%end if %>
<%if request("page")<>rs_ts.pagecount and page<rs_ts.pagecount then %>
<a Href="searchtscount.asp?action=list_search&s_year=<%=s_year%>&s_month=<%=s_month%>&s_day=<%=s_day%>&Page=<% =page + 1%>">下一页</a> <a Href="searchtscount.asp?action=list_search&s_year=<%=s_year%>&s_month=<%=s_month%>&s_day=<%=s_day%>&Page=<%=rs_ts.PageCount%>">尾页</a>
<%end if
if rs_ts.pagecount>0 then %>
第<font color="#FF3300"><%=page%></font>页
<%end if%></font></div></td>
</tr>
</table>
<table width="100%" border="0" align="center" cellpadding="0" cellspacing="0">
<tr height=30>
<%
if s_month=0 then
if s_day=0 then
response.write "<td width=40% align=center>统计日期:<b><font color=red>"&s_year&"</font></b> 年 <b><font color=red> 全年</font></b>"
end if
else
if s_day=0 then
response.write "<td width=40% align=center>统计日期:<b><font color=red>"&s_year&"</font></b> 年 <b><font color=red>"&s_month&"</font></b> 月"
else
response.write "<td width=40% align=center>统计日期:<b><font color=red>"&s_year&"</font></b> 年 <b><font color=red>"&s_month&"</font></b> 月 <b><font color=red>"&s_day&"</font></b> 日"
end if
end if
response.write "<td>合计数量:<b><font color=red>"&-ccount&"</font></b> 册"
if scount=0 then
response.write "<td>合计实洋:<b><font color=red>0:00</font></b> 元"
else
response.write "<td>合计实洋:<b><font color=red>"&-formatnumber((scount),2)&"</font></b> 元"
end if
%>
</tr>
</table>
<%end select%>
</tr>
</table>
</tr>
</table>
</tr>
</table>
</tr>
</table>
</body>
</html>
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?