Dim sql As String = "Select * from system"
Dim d_a As SqlDataAdapter
Dim d_s As New DataSet
d_a = New SqlDataAdapter(sql, SqlConnection1)
d_a.Fill(d_s, "s")
DataGrid_sys.DataSource = d_s.Tables("s")
' Exit Sub
'====================================================================================================================
Dim i As Integer
For Each dgvr As DataGridViewRow In DataGrid_sys.Rows
For i = 0 To DataGrid_sys.Rows.Count - 1
Dim sql2 As String = "Select count (*)as count from view_Treated_System Where TreatedDate BETWEEN '" & _
dtp_Start.Value.Month & "/" & dtp_Start.Value.Day & "/" & dtp_Start.Value.Year & "' and '" & _
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'"
Dim d_a2 As SqlDataAdapter
Dim d_s2 As New DataSet
Dim d_row() As DataRow
d_a2 = New SqlDataAdapter(sql2, SqlConnection1)
d_a2.Fill(d_s2, "ts")
If d_s2.Tables("ts").Rows.Count <> 0 Then
d_row = d_s2.Tables("ts").Select
DOG.Text = CStr(d_row(0)("count"))
DataGrid_ts.Rows.Add()
DataGrid_ts.Rows(i).Cells(0).Value = DataGrid_sys.Rows(i).Cells(0).Value
DataGrid_ts.Rows(i).Cells(1).Value = DataGrid_sys.Rows(i).Cells(1).Value
DataGrid_ts.Rows(i).Cells(2).Value = CDbl(DOG.Text)
End If
Dim sql3 As String = "Select count (*)as count from view_Treated_System Where TreatedDate BETWEEN '" & _
dtp_Start.Value.Month & "/" & dtp_Start.Value.Day & "/" & dtp_Start.Value.Year & "' and '" & _
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'"
Dim d_a3 As SqlDataAdapter
Dim d_s3 As New DataSet
Dim d_row2() As DataRow
d_a3 = New SqlDataAdapter(sql3, SqlConnection1)
d_a3.Fill(d_s3, "ts")
If d_s3.Tables("ts").Rows.Count <> 0 Then
d_row2 = d_s3.Tables("ts").Select
CAT.Text = CStr(d_row2(0)("count"))
DataGrid_ts.Rows(i).Cells(3).Value = CDbl(CAT.Text)
End If
Dim sum As Integer
sum = CDbl(DOG.Text) + CDbl(CAT.Text)
DataGrid_ts.Rows(i).Cells(4).Value = sum.ToString
Next
For j = 0 To DataGrid_ts.Rows.Count - 1
rptTreated.SetParameterValue("SySName", DataGrid_ts.Rows(j).Cells(1).Value.ToString)
rptTreated.SetParameterValue("Num_Dog", DataGrid_ts.Rows(j).Cells(2).Value.ToString)
rptTreated.SetParameterValue("Num_Cat", DataGrid_ts.Rows(j).Cells(3).Value.ToString)
rptTreated.SetParameterValue("Sum", DataGrid_ts.Rows(j).Cells(4).Value.ToString)
Next
CrystalReportViewer1.ReportSource = rptTreated
'rptTreated.SetDataSource(d_set.Tables("ts"))
rptTreated.SetParameterValue("dtp_Start", dtp_Start.Value)
rptTreated.SetParameterValue("dtp_End", dtp_End.Value)
With CrystalReportViewer1
.ReportSource = rptTreated
.DisplayStatusBar = True
.DisplayToolbar = True
.DisplayGroupTree = False
End With
'Next
Exit Sub
Next