searchcgcount.asp

来自「创建和运行动态、交互的Web服务器应用程序」· ASP 代码 · 共 250 行

ASP
250
字号
<!--#include file="conn.asp"-->
<%
  dim action,s_year,s_month,rs_cg,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.searchcgcount.s_year.value==0) {
	document.searchcgcount.s_year.focus();
    alert("请选择要查询的年份!");
	return false;
  }  
  if(document.searchcgcount.s_month.value==0 && document.searchcgcount.s_day.value!=0){
	document.searchcgcount.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="searchcgcount" method="post" action="searchcgcount.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='searchcgcount.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='searchcgcount.asp?action=list_search&s_year=<%=year(now)%>'">
                          <td width="16%" bgcolor="#ece9d8" align="right">历史查询&nbsp;

                          <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">&nbsp;&nbsp;&nbsp;&nbsp;商品名称</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_cg=server.CreateObject("adodb.recordset")
                             rs_cg.open "SELECT shop_books.bookname,shop_books.bookid,shop_books.shichangjia,Sum(shop_cgaction.cgcount) AS shixiaocount, Sum(shop_cgaction.cgsy) as zonger   FROM shop_cgaction INNER JOIN shop_books ON shop_cgaction.bookid = shop_books.bookid WHERE (((shop_cgaction.cgcount)>0) AND ((year(shop_cgaction.cgdate))="&s_year&") AND ((Month(shop_cgaction.cgdate))="&s_month&") AND ((day(shop_cgaction.cgdate))="&s_day&")) GROUP BY shop_books.bookname,shop_books.chengjiaocount,shop_books.bookid,shop_books.shichangjia",conn,1,3
                          '//没选日
                          else
                             set rs_cg=server.CreateObject("adodb.recordset")
                             rs_cg.open "SELECT shop_books.bookname,shop_books.bookid,shop_books.shichangjia,Sum(shop_cgaction.cgcount) AS shixiaocount, Sum(shop_cgaction.cgsy) as zonger   FROM shop_cgaction INNER JOIN shop_books ON shop_cgaction.bookid = shop_books.bookid WHERE (((shop_cgaction.cgcount)>0) AND ((year(shop_cgaction.cgdate))="&s_year&") AND ((Month(shop_cgaction.cgdate))="&s_month&")) GROUP BY shop_books.bookname,shop_books.chengjiaocount,shop_books.bookid,shop_books.shichangjia",conn,1,3
                          end if
                       '//没选月
                       else
                          set rs_cg=server.CreateObject("adodb.recordset")
                          rs_cg.open "SELECT shop_books.bookname,shop_books.bookid,shop_books.shichangjia,Sum(shop_cgaction.cgcount) AS shixiaocount, Sum(shop_cgaction.cgsy) as zonger   FROM shop_cgaction INNER JOIN shop_books ON shop_cgaction.bookid = shop_books.bookid WHERE (((shop_cgaction.cgcount)>0) AND ((year(shop_cgaction.cgdate))="&s_year&")) GROUP BY shop_books.bookname,shop_books.chengjiaocount,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">&nbsp;&nbsp;&nbsp;&nbsp;商品名称</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_cg.bof and rs_cg.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_cg.eof 
                                ccount=ccount+rs_cg("shixiaocount")
                                scount=scount+rs_cg("zonger") 
                             rs_cg.MoveNext
                             loop

                             '/记录指针到第一条
                             rs_cg.Movefirst

                             '/分页显示上部分 
                             Page = rs_cg.AbsolutePage
                             rs_cg.PageSize=15
                             if Not IsEmpty(Request("Page")) then
                                Page = CInt(Request("Page"))
                                if Page > rs_cg.PageCount then 
                                   rs_cg.AbsolutePage = rs_cg.PageCount 
                                elseif Page <= 0 then 
                                   Page = 1 
                                else
                                   rs_cg.AbsolutePage = Page 
                                end if
                             else
                                Page = 1	
                             end if
                                                             
                              For i =0 to rs_cg.PageSize
                                  if rs_cg.EOF then Exit For
 
                                  
                       %>
                       <tr>
                          <td bgcolor="#ffffff"><div align="center"><%=rs_cg.bookmark%></div></td>
                          <td bgcolor="#ffffff" STYLE='PADDING-LEFT: 5px'><a href=../book.asp?id=<%=rs_cg("bookid")%> target=_blank><%=rs_cg("bookname")%></a></td>
                          <td bgcolor="#ffffff"><div align="center"><font color=blue><%=formatnumber(rs_cg("shichangjia"),2)%></font></div></td>
                          <td bgcolor="#ffffff"><div align="center"><font color=red><%=rs_cg("shixiaocount")%></font></div></td>
                          <td bgcolor="#ffffff"><div align="center"><font color=blue><%=formatnumber(rs_cg("zonger"),2)%></font></div></td>
                       </tr> 
                       <% '/分页显示下部分
                          rs_cg.MoveNext
                          next    

                           end if%>
                       <tr> 
                          <td colspan=5 bgcolor="#ece9d8" height=40><div align="center">共<font color=blue><%=rs_cg.recordcount%></font>条<font color=blue><%=rs_cg.pagecount%></font>页 
                          <%if request("page")>1 then%>
                               <a Href="searchcgcount.asp?action=list_search&s_year=<%=s_year%>&s_month=<%=s_month%>&s_day=<%=s_day%>&Page=<%=1%>">首页</a>&nbsp;&nbsp;<a Href="searchcgcount.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_cg.pagecount and page<rs_cg.pagecount then %>
                               <a Href="searchcgcount.asp?action=list_search&s_year=<%=s_year%>&s_month=<%=s_month%>&s_day=<%=s_day%>&Page=<% =page + 1%>">下一页</a>&nbsp;&nbsp;<a Href="searchcgcount.asp?action=list_search&s_year=<%=s_year%>&s_month=<%=s_month%>&s_day=<%=s_day%>&Page=<%=rs_cg.PageCount%>">尾页</a> 
                          <%end if
                          if rs_cg.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 + -
显示快捷键?