|
本着时间过半任务过半的原则,我们今天完成mini网上商城的后台制作,其实截止到昨天为止,直接显示的页面我们都已经完成了,只是还少一个类似access中报表的那个东西,要能打印出相关订单明细,提供给仓库发货:
【直接输出窗体】
根据access的设计我们知道,报表来自于一个复杂的查询,同时还要再报表中进行分层和分组,而在asp.net中没有报表控件,我们用一些VB语句来直接控制数据的输出,让它出现分层和分组:
先添加一个web窗体,命名为saleinfo.aspx,然后再它的加载事件中先模拟一个订单号: Dim myid As String
myid = "200607040024"
然后建立加载过程:那个复杂的查询语句就来自于我们的access小样:通过Response.Write输出了一些带有html标记文本以及数据到页面上,这些html标记会被编译为要显示的控件: <A href=javascript:print()>打印</A>调用了ie浏览器上的打印按钮。
Sub BindRed(ByVal myid As String)
Dim mysql As String
mysql = "SELECT tab_Pinfo.pname,tab_Pinfo.pkinds, tab_Pinfo.price, tab_Pinfo.lprice ,tab_salerecord.pcount,tab_Pinfo.lprice*tab_salerecord.pcount AS msum" _
& ",tab_salerecord.lid, tab_salerecord.uid, tab_userinfo.uname,tab_userinfo.address" _
& " FROM (tab_Pinfo INNER JOIN tab_salerecord ON tab_Pinfo.id = tab_salerecord.pid) INNER JOIN tab_userinfo ON tab_salerecord.uid = tab_userinfo.Id" _
& " WHERE tab_salerecord.lid='" & myid & "'"
mycon.Open()
Dim mycmd As OleDb.OleDbDataAdapter = New OleDb.OleDbDataAdapter(mysql, mycon)
Dim dt As Data.DataSet = New Data.DataSet
mycmd.Fill(dt)
'输出到表
Dim ta As DataTable
ta = dt.Tables(0)
'输出
Response.Write("定单号:" & ta.Rows(0).Item("lid"))
Response.Write("<br>") '<br>是断行标签
Response.Write("姓名:" & ta.Rows(0).Item("uname"))
Response.Write("<br>")
Response.Write("地址:" & ta.Rows(0).Item("address"))
'建立表格
Dim i, j
Response.Write("<table Width=528px border=1 BorderColor=Black >")
Response.Write("<tr align=center>")
Response.Write("<td>商品名称")
Response.Write("</td>")
Response.Write("<td>种类")
Response.Write("</td>")
Response.Write("<td>单价")
Response.Write("</td>")
Response.Write("<td>折扣价")
Response.Write("</td>")
Response.Write("<td>数量")
Response.Write("</td>")
Response.Write("<td>金额")
Response.Write("</td>")
Response.Write("</tr>")
For i = 0 To ta.Rows.Count - 1 '用循环添加所有的行
Response.Write("<tr>")
Response.Write("<td>" & ta.Rows(i).Item(0)) '名称
Response.Write("</td>")
Response.Write("<td>" & ta.Rows(i).Item(1)) '种类
Response.Write("</td>")
Response.Write("<td>¥" & Format(ta.Rows(i).Item(2), "#.00")) '单价
Response.Write("</td>")
Response.Write("<td>¥" & Format(ta.Rows(i).Item(3), "#.00")) '折扣价
Response.Write("</td>")
Response.Write("<td>" & ta.Rows(i).Item(4)) '数量
Response.Write("</td>")
Response.Write("<td>¥" & Format(ta.Rows(i).Item(5), "#.00")) '金额
Response.Write("</td>")
Response.Write("</tr>")
Next i
Response.Write("<tr>") '行
Response.Write("<tr>")
Response.Write("<td>")
Response.Write("</td>")
Respons |
本帖子中包含更多资源
您需要 登录 才可以下载或查看,没有帐号?注册
x
|