ASP控制每页打印行数

时间:2022-06-17 14:21:21
  1. <% 
  2. pagenum=55'指定打印行数 
  3. %> 
  4. <HTML> 
  5. <HEAD> 
  6. <meta http-equiv="Content-Type" content="text/html; charset=gb2312"
  7. <TITLE>销售利润明细报表打印</TITLE> 
  8. <style type="text/css"
  9. td {font-size:9pt; color:#000000} 
  10. A{text-decoration:none} 
  11. A:hover{color:#FF0000;text-decoration:derline}  
  12. .break{page-break-before:always} 
  13. </style> 
  14. </HEAD> 
  15. <script language="javascript"
  16. window.print() 
  17. </script> 
  18. <BODY style="border:none" topmargin="0" leftmargin="6" onload="javascrpt:pagesetup_default();"
  19. <script language="VbScript"
  20. dim hkey_root,hkey_path,hkey_key 
  21. hkey_root="HKEY_CURRENT_USER" 
  22. hkey_path="\Software\Microsoft\Internet Explorer\PageSetup" 
  23. function pagesetup_default() 
  24.     on error resume next 
  25.     Set RegWsh = CreateObject("WScript.Shell"
  26.     hkey_key="\header"     
  27.     RegWsh.RegWrite hkey_root+hkey_path+hkey_key,"&b页&p/&P" 
  28.     hkey_key="\footer" 
  29.     RegWsh.RegWrite hkey_root+hkey_path+hkey_key,"" 
  30. end function 
  31. </script> 
  32.  
  33. <% 
  34. kdname1=trim(request("kdname1")) 
  35. kdname2=trim(request("kdname2")) 
  36. keyword1=trim(request("keyword1")) 
  37. keyword2=trim(request("keyword2")) 
  38.  
  39.  if keyword1<>"" then 
  40.  today=keyword1 
  41.  else 
  42.  if kdname1="" then 
  43.  today=year(date())&"-"&month(date()) 
  44.  else 
  45.  today=kdname1&"至"&kdname2 
  46.  end if 
  47.  end if 
  48. %> 
  49.   <table border="0" cellspacing="0" cellpadding="0" align="center" width="740"  height="30"
  50.     <tr> 
  51.       <td align="center">销售利润汇总报表</td> 
  52.     </tr> 
  53.   </table> 
  54.  
  55. <%   
  56.  strSQL="select autoid,sellautoid,productxili,productname,productsize,productnum,productdan,productjia,chaoshi,tiaoma,youhui,fukuan,moncount1,gongshang,lirun1,username,indate,fudate from sell where officename='"&trim(request.cookies("Myoffice"))&"' and monthjie='0' and (year(indate)=year(getdate()) and month(indate)=month(getdate())) and zhuofei is null order by autoid desc"              
  57.  set rs1=server.createobject("adodb.recordset")               
  58.  rs1.open strSQL,conn,1,1  
  59. %>                
  60.   <table border="1" cellspacing="0" cellpadding="0" align="center" style="border-collapse: collapse"  bordercolor="#000000" width="740">              
  61.     <tr>              
  62.       <td align="center" height="20" bgcolor="#BDCBEE" width="70" >销售单号</td>              
  63.       <td align="center" height="20" bgcolor="#BDCBEE" width="168" >商品名称(规格)</td>              
  64.       <td align="center" height="20" bgcolor="#BDCBEE" width="121" >客户</td>              
  65.       <td align="center" height="20" bgcolor="#BDCBEE" width="30" >数量</td>              
  66.       <td align="center" height="20" bgcolor="#BDCBEE" width="24" >单位</td>              
  67.       <td align="center" height="20" bgcolor="#BDCBEE" width="50" >销售价</td>              
  68.       <td align="center" height="20" bgcolor="#BDCBEE" width="23" >折%</td>              
  69.       <td align="center" height="20" bgcolor="#BDCBEE" width="52" >进货价</td>              
  70.       <td align="center" height="20" bgcolor="#BDCBEE" width="55" >小计</td>              
  71.       <td align="center" height="20" bgcolor="#BDCBEE" width="45" >利润</td>              
  72.       <td align="center" height="20" bgcolor="#BDCBEE" width="25" >付款</td>              
  73.       <td align="center" height="20" bgcolor="#BDCBEE" width="61" >销售日期</td>              
  74.     </tr>  
  75.   </table> 
  76. <%              
  77.   moncount2=0              
  78.   moncount5=0              
  79.   Do while not rs1.eof   
  80. %> 
  81. <table border="1" cellpadding="0" cellspacing="0" width="740" align="center" style="border-collapse:collapse; font-size:10pt;color:#000000" bordercolor="#000000"
  82. <% 
  83. for i=1 to pagenum 
  84. if not rs1.eof then 
  85.   if trim(rs1("fukuan"))="欠款" then              
  86.   moncount6=Csng(rs1("lirun1"))              
  87.   moncount5=moncount5+moncount6              
  88.   else              
  89.   moncount3=Csng(rs1("lirun1"))              
  90.   moncount2=moncount2+moncount3              
  91.   end if   
  92. %>       
  93.     <tr>              
  94.       <td height="18" width="70"> <%=rs1("sellautoid")%></td>              
  95.       <td height="18" width="168"><%=Decode(rs1("productname"))%> <%=rs1("productsize")%></td>              
  96.       <td height="18" width="121"><%=left(rs1("gongshang"),9)%></td>             
  97.       <td height="18" width="30" align="center"><%=rs1("productnum")%></td>             
  98.       <td height="18" width="24" align="center"><%=rs1("productdan")%></td>             
  99.       <td height="18" width="50" align="right"><%=formatNumber(rs1("chaoshi"),varnum,-1)%></td>             
  100.       <td height="18" width="23" align="center"><%=rs1("youhui")%></td>             
  101.       <td height="18" width="52" align="right"><%=formatNumber(rs1("productjia"),varnum,-1)%></td>             
  102.       <td height="18" width="55" align="right"><%=formatNumber(rs1("moncount1"),varnum,-1)%></td>             
  103.       <td height="18" width="45" align="right"><%=formatNumber(rs1("lirun1"),varnum,-1)%></td>             
  104.       <td align="center" height="18" width="25"><%if trim(rs1("fukuan"))="欠款" then%><font color=blue><%=rs1("fukuan")%></font><%else%><%=rs1("fukuan")%><%end if%></td>             
  105.       <td height="18" width="61"><%=rs1("indate")%></td>             
  106.     </tr>  
  107. <% 
  108. rs1.movenext 
  109. end if 
  110. next 
  111. %> 
  112. </table> 
  113. <% 
  114. if not rs1.eof and i=pagenum+1 then '添加分页标记 
  115. %> 
  116.   <div class="break"> </div> 
  117.   <table border="0" cellpadding="0" cellspacing="0" width="740" height="12" align="center"><tr><td height="12"></td></tr></table> 
  118.   <table border="1" cellspacing="0" cellpadding="0" align="center" width="740" style="border-collapse: collapse"  bordercolor="#000000">  
  119.     <tr>              
  120.       <td align="center" height="20" bgcolor="#BDCBEE" width="70" >销售单号</td>              
  121.       <td align="center" height="20" bgcolor="#BDCBEE" width="168" >商品名称(规格)</td>              
  122.       <td align="center" height="20" bgcolor="#BDCBEE" width="121" >客户</td>              
  123.       <td align="center" height="20" bgcolor="#BDCBEE" width="30" >数量</td>              
  124.       <td align="center" height="20" bgcolor="#BDCBEE" width="24" >单位</td>              
  125.       <td align="center" height="20" bgcolor="#BDCBEE" width="50" >销售价</td>              
  126.       <td align="center" height="20" bgcolor="#BDCBEE" width="23" >折%</td>              
  127.       <td align="center" height="20" bgcolor="#BDCBEE" width="52" >进货价</td>              
  128.       <td align="center" height="20" bgcolor="#BDCBEE" width="55" >小计</td>              
  129.       <td align="center" height="20" bgcolor="#BDCBEE" width="45" >利润</td>              
  130.       <td align="center" height="20" bgcolor="#BDCBEE" width="25" >付款</td>              
  131.       <td align="center" height="20" bgcolor="#BDCBEE" width="61" >销售日期</td>              
  132.     </tr>  
  133. <% 
  134. end if 
  135. loop 
  136. rs1.close      
  137. set rs1=nothing      
  138. %>   
  139. </table>   
  140.   <table border="1" cellpadding="0" cellspacing="0" width="740" height="20" align="center" style="border-collapse: collapse"  bordercolor="#000000"
  141.     <tr>             
  142.        <td><font color="#FF0000"><b>现金利润:</b></font><b><%=formatNumber(moncount2,varnum,-1)%></b>   <%if moncount5<>"" then%><b><font color="#FF0000">欠款利润</font>:<%=formatNumber(moncount5,varnum,-1)%></b><%end if%>   <%if moncount5<>"" then%><b><font color="#FF0000">毛利合计:</font><%=formatNumber(moncount5+moncount2,varnum,-1)%></b><%end if%></td>             
  143.      </tr>    
  144.    </table>             
  145. <% 
  146. end if 
  147. conn.close  
  148. set conn=nothing  
  149. %>  
  150.  
  151. </BODY> 
  152. </HTML>