機房收費系統總結(四)
阿新 • • 發佈:2019-02-17
在做機房收費系統的時候它不同於學生管理系統的是多了報表這一功能,可以把資料通過印表機打印出來,這顯然是很方便的。那麼我就來總結一些報表的使用方法吧!
首先我們在部件裡邊選擇這個部件:
\]
然後我們下載一個Grid++Report報表設計器
步驟:
1.新建嚮導:
2.建立連線
、
3.建立SQL語句(記得把password加上)
4。在這裡我最想說的是報表中時間的問題
為了讓起止時間和終止時間與窗體的起止時間和終止時間對應,我可費了老大勁了,其實就這一個很簡單的問題。
插入靜態框輸入如圖所示的begin和end,然後右擊插入——引數,然後保證引數名和靜態框裡的名字一致。
程式碼部分:
賬單重新整理事件:
報表預覽以及報表列印:report.ParameterByName("begin").AsString = Format(DTPicker1.Value, "yyyy/MM/dd") report.ParameterByName("end").AsString = Format(DTPicker2.Value, "yyyy/MM/dd") txtSQL = "select * from checkweek_Info where date>= '" & DTPicker1.Value & "' and date<='" & DTPicker2.Value & "'" 'txtSQL1 = txtSQL & "select * from checkweek_Info where RemainCash= '" & Trim(Text1.Text) & "'" report.DetailGrid.Recordset.ConnectionString = connectstring() report.DetailGrid.Recordset.QuerySQL = txtSQL GRDisplayViewer1.Refresh
Private Sub Command1_Click()
report.[Print] (True)
End Sub
Private Sub Command2_Click()
report.PrintPreview (True)
報表初始化
報表我們以後還會用到,先學習一下吧!Dim txtSQL As String Dim msgtext As String Dim txtSQL1 As String txtSQL = "select * from checkweek_Info where date>= '" & DTPicker1.Value & "' and date<='" & DTPicker2.Value & "'" 'txtSQL1 = txtSQL & "select * from checkweek_Info where RemainCash= '" & Trim(Text1.Text) & "'" Set report = New grproLibCtl.GridppReport '例項化模板 report.LoadFromFile ("E:\機房\周彙總表.grf") '載入報表模板 '設定資料庫連線串 report.DetailGrid.Recordset.ConnectionString = connectstring() report.DetailGrid.Recordset.QuerySQL = txtSQL