?? down_report_sell.asp
字號:
<!--#include file="../conn.asp"-->
<!--#include file="../isuser.asp"-->
<!--#include file="../pub_fun.asp"-->
<html>
<HEAD>
<META NAME="Keywords" CONTENT="FastReport"/>
<META NAME="Description" CONTENT="The FastReport report"/>
<LINK href="../css.css" rel="stylesheet" type="text/css" media="all">
<title>銷售信息查詢結果下載</title>
</head>
<body >
<%
''獲取查詢語句
textSql=decrypt(trim(request("sql")))
'組成查詢語句
sql="SELECT SellID, MAX(SellTopic) AS selltopic, MAX(SellClientID) AS sellclientid, MAX(SellOrderNum) AS SellOrderNum, SellDate, MAX(SellProduct) AS sellproduct, MAX(SellProductprice) AS sellproductprice, MAX(SellProductnum) AS SellProductnum, MAX(Sellmoney) AS sellmoney"
sql=sql&" from sell"
sql=sql&" where (sellCreatorID="&session("Session_User")&"or sellopenflag='1' ) "&textsql
sql=sql&"GROUP BY SellTopic, SellClientID, SellDate, SellID"
sql=sql&" ORDER BY SellClientID "
'創建文件名
strFileName = "r_sell_" & GetAutoID() & ".csv"
strFullFileName = server.mappath("../data/" & strFileName) '帶路徑
''創建文件對象
SET objMyFile = Server.Createobject("scripting.filesystemobject")
SET objNewsFile = objMyFile.createtextfile(strFullFileName)
''從數據庫中讀出相應的記錄
SET Rs = Server.CreateObject("Adodb.RecordSet")
Rs.Open Sql,conn,3
intRC = Rs.RecordCount
strTitle = "相關客戶,,主題,,訂單/合同號,,銷售日期"
'寫入表頭
objNewsFile.writeline(strTitle)
''獲取上一條記錄的相關客戶編號和銷售主題
rs.moveprevious
if not rs.bof then
last_id=(rs("sellclientid"))
last_topic=(rs("selltopic"))
end if
rs.movenext
'寫入標題
if not rs.eof then
''利用for循環顯示詳細信息
for i=1 to intRC
if rs.eof then exit for
''判斷該信息和上一條信息是否為一個銷售單元,如果是則寫入銷售的公共信息
if rs("sellclientid")<>last_id or (rs("selltopic"))<> last_topic then
strLineString=showclientname(rs("sellclientid"))&",,"
strLineString= strLineString&rs("selltopic")&",,"
strLineString= strLineString&rs("sellordernum")&",,"
strLineString= strLineString&rs("selldate")
objNewsFile.writeline(strLineString)
''然后寫入產品的標題
strLineString= ",產品名稱,單價,數量,金額"
objNewsFile.writeline(strLineString)
''最后是該條記錄的產品信息
strLineString=","&rs("SellProduct")&","
strLineString= strLineString&rs("SellProductprice")&","
strLineString= strLineString&rs("SellProductnum")&","
strLineString= strLineString&rs("Sellmoney")
objNewsFile.writeline(strLineString)
else
''如果是同一個單元,則直接寫入產品的信息
strLineString=","&rs("SellProduct")&","
strLineString= strLineString&rs("SellProductprice")&","
strLineString= strLineString&rs("SellProductnum")&","
strLineString= strLineString&rs("Sellmoney")
objNewsFile.writeline(strLineString)
end if
''判斷下一條記錄是否和本記錄是一銷售單元
if rs.eof then exit for
last_id=rs("sellclientid")
last_topic=(rs("selltopic"))
rs.movenext
if rs.eof then
lastflag=1
else
if rs("sellclientid")<>last_id or (rs("selltopic"))<>last_topic then
lastflag=1
else
lastflag=0
end if
end if
''根據lastflag判斷是否寫入小計
if (lastflag=1) then
strLineString= ",,,小計:,"& showsellsum_x(last_id,trim(last_topic))
objNewsFile.writeline(strLineString)
end if
next
end if
Rs.Close
SET Rs = NOTHING
objNewsFile.close
SET objNewsFile = NOTHING
SET objMyFile = NOTHING
%>
<div align="center">
<center>
<table border="0" cellpadding="0" cellspacing="0" bordercolor="#111111" width="380" height="207">
<tr class="CListTTL" >
<td height="29" ><font color = yellow ><b>下載銷售查詢結果數據</b></FONT></td>
</tr>
<tr CLASS=cROW>
<td width="100%" height="177">
<center>
<table border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="72%" id="AutoNumber2">
<tr align="center" CLASS=cROW>
<td nowrap><a href="../data/<%=strFileName%>" onMouseDown="javascript:if (event.button==1) alert('請用鼠標右鍵點擊鏈接\n選擇目標另存為!')"><font color=blue><strong>下 載</strong></font></a></td>
</tr>
<tr align="center" CLASS=cROW>
<td nowrap><br><br><br><font color = red>說明:用鼠標右鍵點擊“下載”,選擇“目標另存為...”功能</font></td>
</tr>
</table>
</center>
</td>
</tr>
</table>
</center>
</div>
</BODY>
</HTML>
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -