请教:如何用ASP实现打印功能
我在设计一个管理系统,在系统中要对一些报表进行打印,请各位支招在ASP中如何实现?[em04]
<!--#include file="conn.asp"-->
<!--#include file="inc/common.asp"-->
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<link href="qq020.css" rel="stylesheet" type="text/css">
<%if strUserName="" then
Conn.Close
Set Conn = Nothing
response.write "<script language=javascript>alert('对不起,请先注册或登录!');history.go(-1);</script>"
response.End
end if%>
<title><%=rsweb("webname")%>--订单详细资料</title>
<%dim goods,YourPrice
goods=SafeRequest("dan",1)
set rs=server.CreateObject("adodb.recordset")
rs.open "select product.id,product.name,product.amount,product.type,product.price1,product.price2,product." & LstPrice & ",product.vipprice,orders.actiondate,orders.UserSex,orders.ActionID,orders.remarks,orders.realname,orders.receipt,orders.goods,orders.postcode,,,orders.paymethord,orders.deliverymethord,orders.state,orders.paid,orders.score,orders.useremail,orders.usertel,orders.paid,orders.userid,orders.address,orders.productnum,orders.UserMemo,orders.AdminMemo,product.code from product inner join orders on product.id=orders.id where orders.username='"&strUserName&"' and goods='"&goods&"' ",conn,1,1
if rs.eof and rs.bof then
rs.Close
Set rs = Nothing
Conn.Close
Set Conn = Nothing
response.write "<center>此订单中有商品已被管理员删除,无法处理,请通知管理员或者重下订单!</center>"
response.End
end if
%>
<style media=print>
.Noprint{display:none;}
.PageNext{page-break-after: always;}
</style>
<style>
.tdp
{
border-bottom: 1 solid #000000;
border-left: 1 solid #000000;
border-right: 0 solid #ffffff;
border-top: 0 solid #ffffff;
}
.tabp
{
border-color: #000000 #000000 #000000 #000000;
border-style: solid;
border-top-width: 2px;
border-right-width: 2px;
border-bottom-width: 1px;
border-left-width: 1px;
}
.NOPRINT {
font-family: "宋体";
font-size: 9pt;
}
a:link {
text-decoration: none;
}
a:visited {
text-decoration: none;
}
a:hover {
text-decoration: none;
}
a:active {
text-decoration: none;
}
body,td,th {
font-family: Arial, Helvetica, sans-serif;
font-size: 12px;
}
.style1 {
font-size: 18px;
font-weight: bold;
}
</style>
<script language="javascript">
function SetPrintSettings() {
// -- advanced features
factory.printing.SetMarginMeasure(2) // measure margins in inches
factory.SetPageRange(false, 1, 3) // need pages from 1 to 3
factory.printing.printer = "HP DeskJet 870C"
factory.printing.copies = 2
factory.printing.collate = true
factory.printing.paperSize = "A4"
factory.printing.paperSource = "Manual feed"
// -- basic features
factory.printing.header = "This is MeadCo"
factory.printing.footer = "Advanced Printing by ScriptX"
factory.printing.portrait = false
factory.printing.leftMargin = 1.0
factory.printing.topMargin = 1.0
factory.printing.rightMargin = 1.0
factory.printing.bottomMargin = 1.0
}
function printsetup(){
// 打印页面设置
wb.execwb(8,1);
}
function printpreview(){
// 打印页面预览
wb.execwb(7,1);
}
function printit()
{
if (confirm('确定打印吗?')) {
wb.execwb(6,6)
}
}
</script>
<!--#include file="inc/TurnPage.asp"-->
<% dim num,nums
num=request.QueryString("pageno")
if num="" then
num=1
end if
nums=num-1
%>
<center class="Noprint" >
<OBJECT classid="CLSID:8856F961-340A-11D0-A96B-00C04FD705A2" height=0 id=wb name=wb width=0></OBJECT>
<input type="button" class="input_bot" onClick="javascript:printit()" value="打印订单">
<input type="button" class="input_bot" onClick="javascript:printsetup();" value="打印设置">
<input type="button" class="input_bot" onClick="javascript:printpreview();" value="打印预览">
</center> <br>
<table width="100%" border="0" cellpadding="0" cellspacing="3" bgcolor="#E3E3E3">
<tr>
<td align="center" bgcolor="#FFFFFF"><table width="99%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td align="center" class="cn20"><table width="100%" border="0" cellpadding="0" cellspacing="1" class="cn20">
<tr>
<td height="50" align="center"><span class="style1">广 州 市 办 公 用 品 销 售 单</span></td>
</tr>
<tr>
<td height="1" align="center" bgcolor="#CCCCCC"></td>
</tr>
<tr>
<td height="3"><img name="" src="" width="1" height="3" alt=""></td>
</tr>
</table></td>
</tr>
<tr>
<td><table width="100%" border="0" cellpadding="0" cellspacing="1" bgcolor="#FFFFFF">
<tr>
<td height="25" align="center" bgcolor="#F3F3F3" class="Cn12-big"><strong>订购电话</strong>:</td>
<td><table width="100%" border="0" cellpadding="0" cellspacing="3" class="en12-black">
<tr>
<td>8120 6732 </td>
<td>8120 6733 </td>
<td>8120 6290 </td>
<td>8120 6295 </td>
</tr>
</table></td>
<td align="center" bgcolor="#F3F3F3" class="en12-big"><strong>订购传真</strong>:</td>
<td><table width="100%" border="0" cellpadding="0" cellspacing="3" class="en12-black">
<tr>
<td>8120 6295 </td>
<td align="center" class="Cn12-big">网 址:</td>
<td>Http://WWW.
</tr>
</table></td>
</tr>
<tr>
<td height="25" align="center" bgcolor="#F3F3F3" class="Cn12-big"><strong>录单日期</strong>:</td>
<td class="en12-black">?<%=rs("actiondate")%></td>
<td align="center" bgcolor="#F3F3F3" class="en12-big"><strong>单据编号</strong>:</td>
<td class="en12-black">?XS-<%=goods+nums%></td>
</tr>
<tr>
<td height="25" align="center" bgcolor="#F3F3F3" class="Cn12-big"><strong>购货单位</strong>:</td>
<td class="en12-black">?<%=rs("company")%></td>
<td align="center" bgcolor="#F3F3F3" class="en12-big"><strong>联 系 人</strong>:</td>
<td class="en12-black">?<%=trim(rs("receipt"))%>
<%
if trim(rs("UserSex")) = 0 then
response.Write "?(先生)"
else
response.Write "?(女士)"
end if%></td>
</tr>
<tr>
<td height="25" align="center" bgcolor="#F3F3F3" class="Cn12-big"><strong>单位地址</strong>:</td>
<td class="en12-black">?<%=trim(rs("address"))%></td>
<td align="center" bgcolor="#F3F3F3" class="en12-big"><strong>联系电话</strong>:</td>
<td class="en12-black">?<%=trim(rs("usertel"))%></td>
</tr>
</table><div style="display:none">
<table width="100%" border="0" cellspacing="3" cellpadding="0">
<tr>
<td> <%dim RowCount
RowCount = 15
Call TurnPage(rs,RowCount)
'公共翻页模块结束
%></td>
</tr>
</table> </div></td>
</tr>
<tr>
<td><table width="100%" border="0" cellpadding="0" cellspacing="0" bgcolor="#CCCCCC" class="tabp">
<tr align="center" bgcolor="#FFFFFF" class="en12-big">
<td height="35" colspan="2" class="tdp">商 品 全 称</td>
<td class="tdp">单 位</td>
<td class="tdp">数 量</td>
<td class="tdp">单 价</td>
<td class="tdp">金 额</td>
<td class="tdp">备 注</td>
</tr>
<%
dim sum1,sums1
y=1
'循环开始
do while not rs.eof and RowCount>0
YourPrice = Round(rs("" & LstPrice & ""),2)
%>
<tr bgcolor="#FFFFFF" class="en12-black">
<td width="30" height="18" align="center" class="tdp"><%=y%></td>
<td width="400" class="tdp">?<a href=products.asp?id=<%=rs("id")%> target=_blank>
<%response.write trim(rs("name"))%>
</a></td>
<td align="center" class="tdp"><%=rs("type")%></td>
<td align="center" class="tdp"><%=rs("productnum")%></td>
<td align="center" class="tdp"><%if Round(YourPrice,2)<1 then response.write "0"&Round(YourPrice,2) else response.write Round(YourPrice,2) end if%></td>
<td align="center" class="tdp"><% if Round(rs("paid"),2)<1 then response.write "0"&Round(rs("paid"),2) else response.write Round(rs("paid"),2) end if%></td>
<td class="tdp">?</td>
</tr>
<%sum1=rs("paid")+sum1
sums1=sums1+rs("score")*rs("productnum")
y=y+1
RowCount = RowCount - 1
rs.movenext
loop
rs.movefirst
%>
<%dim rs2,LngFee
set rs2=server.CreateObject("adodb.recordset")
rs2.Open "select * from delivery where deliveryid="&int(rs("deliverymethord")),conn,1,1
if rs2.EOF and rs2.BOF then
'response.Write "此方式已经被删除"
A="此方式已经被删除"
'response.write "?附加费用:0元"
B="0元"
C="0%"
'response.write "??金额总计:"&sum1&" 元,获得积分"&sums1&"分"
D=sum1
E=sums1
else
Sum1 = Sum1*(1+rs2("payfee")/100)
IF webbj5 = 0 Then
LngFee = rs2("fee")
Else
If Sum1>=Webbj5 Then
LngFee = 0
Else
LngFee = rs2("fee")
End If
End IF
'response.Write trim(rs2("subject"))
A=trim(rs2("subject"))
B=LngFee&"元"
C=rs2("payfee")&"%"
D=Round((sum1+LngFee),2)
E=sums1&"分"
'response.write "?附加邮费:<font color=red>"&LngFee&"</font>元,方式加收<font color=red>"&rs2("payfee")&"%</font>"
'response.write "??金额总计:<font color=red>"&Round((sum1+LngFee),2)&"</font>?元,获得积分?<font color=red>"&sums1&"</font>?分"
end if
rs2.Close
set rs2=nothing
%>
<tr bgcolor="#FFFFFF" class="en12-big">
<td height="25" colspan="5" class="tdp">??总 额: ¥ <%=rmb(cdbl(D))%></td>
<td align="center" class="tdp">¥<%=D%> 元 </td>
<td align="center" class="tdp">含配送费用</td>
</tr>
</table></td>
</tr>
<tr>
<td height="50"><table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td align="left" bgcolor="#F3F3F3"><table width="100%" border="0" cellpadding="0" cellspacing="1" class="en12-black">
<tr>
<td width="50" align="center">注释:</td>
<td align="left">配送方式:<%=A%></td>
<td align="left">配送费用:<%=B%></td>
<td align="left">附加费用:<%=C%></td>
<td align="left">订单积分:<%=E%></td>
</tr>
</table>
<table width="100%" border="0" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF">
<tr>
<td><% RowCount = 15
Call TurnPage(rs,RowCount)
%></td>
</tr>
</table>
<table width="100%" border="0" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF">
<tr>
<td></td>
</tr>
</table></td>
</tr>
</table>
<table width="100%" border="0" cellpadding="0" cellspacing="3" class="en12-big">
<tr>
<td width="70%" align="left"> * 若对送货人态度不满及产品有任何异议,请致电 13729807333 投诉 </td>
<td>未付款签收人:</td>
</tr>
</table></td>
</tr>
</table></td>
</tr>
</table>
[[it] 本帖最后由 kira007 于 2008-1-31 11:44 编辑 [/it]]