我有下面提到的表格,我想显示一个报告,用户可以选择任何时间间隔,如下表所示,时间间隔为5分钟,但他希望每小时阅读一次,然后阅读9:00- - > 10:00 - > ...等等应显示但有可能跳过一些阅读 所以想要像那样显示
Date Time Temperature Remark
26/8/2016 09:05:00 2.3 Power Fail
26/8/2016 09:10:00 2.6 out of limit
26/8/2016 09:15:00 2.8 out of limit
26/8/2016 09:20:00 2.6 out of limit
26/8/2016 09:25:00 2.9 Power Fail
26/8/2016 09:30:00 3.1 Power Fail
26/8/2016 09:35:00 4.1 Power Fail
26/8/2016 09:40:00 5.4 out of limit
|
|
|
26/8/2016 23:50:00 6.7 out of limit
26/8/2016 13:55:00 5.3 out of limit
要执行相同的i尝试下面提到的代码,其中文本框一个内容时间间隔是数字
Dim da As New SqlDataAdapter("Select * From ref_1 where DATE_TIME between '" & DateTimePicker1.Value & "' and '" & DateTimePicker2.Value & "' ORDER BY DATE_TIME ASC", conn)
Dim da1 As New SqlDataAdapter("Select * from table_1 WHERE DATE_TIME between '" & DTP1.Value & "' and '" & DTP2.Value & "' ORDER BY DATE_TIME ASC", CON)
Dim ds As New DataSet()
da.Fill(ds, "Result")
Dim dt As System.Data.DataTable = ds.Tables("Result")
Dim dcol As New DataColumn()
dcol.Caption = "DT"
dcol.ColumnName = "DT"
dcol.DataType = System.Type.[GetType]("System.Int32")
dt.Columns.Add(dcol)
Dim x As Integer
x = 5
Dim xrow As Integer = Convert.ToInt32(TextBox1.Text / 5)
Dim xrow2 As Integer = TextBox1.Text / 5
Dim k As Integer
While k <> dt.Rows.Count
If xrow2 = xrow Then
dt.Rows(k)("DT") = xrow
xrow2 = 0
End If
xrow2 += 1
k += 1
End While
Dim dv As DataView = New DataView(dt)
dv.RowFilter = "DT=" & xrow
DataGridView1.DataSource = dv
Dim dt1 As New DataTable
With dt1
.Columns.Add("date_time")
.Columns.Add("R_1")
.Columns.Add("remark")
End With
For Each dr As DataGridViewRow In Me.DataGridView1.Rows
dt1.Rows.Add(dr.Cells("date_time").Value, dr.Cells("R_1").Value, dr.Cells("remark").Value)
Next
Dim rptdoc As CrystalReports.Engine.ReportDocument
rptdoc = New CrystalReport1
rptdoc.SetDataSource(dt1)
End sub