01.
Dim
sql
As
String
=
"Select * from system"
02.
Dim
d_a
As
SqlDataAdapter
03.
Dim
d_s
As
New
DataSet
04.
d_a =
New
SqlDataAdapter(sql, SqlConnection1)
05.
d_a.Fill(d_s,
"s"
)
06.
DataGrid_sys.DataSource = d_s.Tables(
"s"
)
07.
08.
09.
Dim
i
As
Integer
10.
11.
For
Each
dgvr
As
DataGridViewRow
In
DataGrid_sys.Rows
12.
For
i = 0
To
DataGrid_sys.Rows.Count - 1
13.
Dim
sql2
As
String
=
"Select count (*)as count from view_Treated_System Where TreatedDate BETWEEN '"
& _
14.
dtp_Start.Value.Month &
"/"
& dtp_Start.Value.Day &
"/"
& dtp_Start.Value.Year &
"' and '"
& _
15.
dtp_End.Value.Month &
"/"
& dtp_End.Value.Day &
"/"
& dtp_End.Value.Year &
"' and SysID = '"
& DataGrid_sys.Rows(i).Cells(0).Value.ToString &
"' And PetType = 'D'"
16.
17.
Dim
d_a2
As
SqlDataAdapter
18.
Dim
d_s2
As
New
DataSet
19.
Dim
d_row()
As
DataRow
20.
d_a2 =
New
SqlDataAdapter(sql2, SqlConnection1)
21.
d_a2.Fill(d_s2,
"ts"
)
22.
23.
If
d_s2.Tables(
"ts"
).Rows.Count <> 0
Then
24.
d_row = d_s2.Tables(
"ts"
).
Select
25.
DOG.Text =
CStr
(d_row(0)(
"count"
))
26.
DataGrid_ts.Rows.Add()
27.
DataGrid_ts.Rows(i).Cells(0).Value = DataGrid_sys.Rows(i).Cells(0).Value
28.
DataGrid_ts.Rows(i).Cells(1).Value = DataGrid_sys.Rows(i).Cells(1).Value
29.
DataGrid_ts.Rows(i).Cells(2).Value =
CDbl
(DOG.Text)
30.
31.
End
If
32.
Dim
sql3
As
String
=
"Select count (*)as count from view_Treated_System Where TreatedDate BETWEEN '"
& _
33.
dtp_Start.Value.Month &
"/"
& dtp_Start.Value.Day &
"/"
& dtp_Start.Value.Year &
"' and '"
& _
34.
dtp_End.Value.Month &
"/"
& dtp_End.Value.Day &
"/"
& dtp_End.Value.Year &
"' and SysID = '"
& DataGrid_sys.Rows(i).Cells(0).Value.ToString &
"' And PetType = 'C'"
35.
Dim
d_a3
As
SqlDataAdapter
36.
Dim
d_s3
As
New
DataSet
37.
Dim
d_row2()
As
DataRow
38.
d_a3 =
New
SqlDataAdapter(sql3, SqlConnection1)
39.
d_a3.Fill(d_s3,
"ts"
)
40.
If
d_s3.Tables(
"ts"
).Rows.Count <> 0
Then
41.
d_row2 = d_s3.Tables(
"ts"
).
Select
42.
CAT.Text =
CStr
(d_row2(0)(
"count"
))
43.
DataGrid_ts.Rows(i).Cells(3).Value =
CDbl
(CAT.Text)
44.
End
If
45.
46.
Dim
sum
As
Integer
47.
sum =
CDbl
(DOG.Text) +
CDbl
(CAT.Text)
48.
DataGrid_ts.Rows(i).Cells(4).Value = sum.ToString
49.
50.
Next
51.
For
j = 0
To
DataGrid_ts.Rows.Count - 1
52.
rptTreated.SetParameterValue(
"SySName"
, DataGrid_ts.Rows(j).Cells(1).Value.ToString)
53.
rptTreated.SetParameterValue(
"Num_Dog"
, DataGrid_ts.Rows(j).Cells(2).Value.ToString)
54.
rptTreated.SetParameterValue(
"Num_Cat"
, DataGrid_ts.Rows(j).Cells(3).Value.ToString)
55.
rptTreated.SetParameterValue(
"Sum"
, DataGrid_ts.Rows(j).Cells(4).Value.ToString)
56.
Next
57.
CrystalReportViewer1.ReportSource = rptTreated
58.
59.
60.
61.
rptTreated.SetParameterValue(
"dtp_Start"
, dtp_Start.Value)
62.
rptTreated.SetParameterValue(
"dtp_End"
, dtp_End.Value)
63.
64.
65.
With
CrystalReportViewer1
66.
.ReportSource = rptTreated
67.
.DisplayStatusBar =
True
68.
.DisplayToolbar =
True
69.
.DisplayGroupTree =
False
70.
End
With
71.
72.
73.
Exit
Sub
74.
Next