Imports System.Data.SqlClient
Imports CrystalDecisions.CrystalReports.Engine
Imports CrystalDecisions.Shared
Imports System.Data
Public Class frm6

    Private Sub frm6_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        loduser()
    End Sub
    Public Sub loduser()
        Call main()
        Con.Open()
        Dim i As Integer
        Dim cmdUser As New SqlCommand
        Dim daUser As New SqlDataAdapter
        Dim dsUser As New DataSet
        Dim dtUser As New DataTable
        Try

            cmdUser = Con.CreateCommand
            cmdUser.CommandText = "SELECT patient_id FROM Radiological"
            daUser.SelectCommand = cmdUser
            daUser.Fill(dsUser, "Radiological")
            dtUser = dsUser.Tables("Radiological")

            For i = 0 To dtUser.Rows.Count - 1
                txtsearch.Items.Add(dtUser.Rows(i).Item(0))

            Next

        Catch ex As Exception
            MsgBox("Error: " & ex.Source & ": " & ex.Message, MsgBoxStyle.OkOnly, "Error conection!!")
        End Try
        Con.Close()


    End Sub
    Private Sub ToolStripButton1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripButton1.Click
        Dim cryRpt As New ReportDocument
        cryRpt.Load("C:\Users\P.P.C.I\Documents\Visual Studio 2008\Projects\PCGHsystem\PCGHsystem\Report\Report6.rpt")

        Dim crParameterFieldDefinitions As ParameterFieldDefinitions
        Dim crParameterFieldDefinition As ParameterFieldDefinition
        Dim crParameterValues As New ParameterValues
        Dim crParameterDiscreteValue As New ParameterDiscreteValue

        crParameterDiscreteValue.Value = txtsearch.Text
        crParameterFieldDefinitions = cryRpt.DataDefinition.ParameterFields
        crParameterFieldDefinition = crParameterFieldDefinitions.Item("patientid")
        crParameterValues = crParameterFieldDefinition.CurrentValues

        crParameterValues.Clear()
        crParameterValues.Add(crParameterDiscreteValue)
        crParameterFieldDefinition.ApplyCurrentValues(crParameterValues)



        CrystalReportViewer1.ReportSource = cryRpt
        CrystalReportViewer1.Refresh()
    End Sub
End Class