Public Class frmInventory

    Private Sub frmInventory_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Try
            fillcbo("SELECT * FROM `tbldiagnosis`  ", cboDiagnosis, "DIAGNOSIS", "DIAGNOSISID")
        Catch ex As Exception

        End Try
    End Sub

    Private Sub rdoAdmitted_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles rdoAdmitted.CheckedChanged
        Try
            If rdoAdmitted.Checked Then
                condition = ""

                sql = " SELECT p.`CASENUM`, `FNAME`, `LNAME`, `MNAME`, `GENDER`,`DATEADMIT` ,`ADMITTINGDIAGNOSIS`,`DOCNAME`,`RNAME` FROM `tblpatient` p, `tbladmitting` a, `tblroom` r,`tbldoctor` d  WHERE p.`CASENUM`=a.`CASENUM`  AND a.`ROOMID`=r.`ROOMID` AND a.`DOCID`=d.`DOCID` " & condition
                RETRIEVEDTG(dtgList, sql)


            ElseIf rdoDischarge.Checked Then
                condition = ""
                sql = " SELECT p.`CASENUM` as 'Case #' , `FNAME` as 'FirstName', `LNAME` as 'LastName',  `MNAME` as 'MiddleName',   `GENDER` as 'Sex',`DISCHARGEDDATE` as 'Date' ,`FINALDIAGNOSIS` as 'FinalDiagnosis' ,`ICD_RUVCODE`, `DISPOSISTION`, `RESULT`  FROM `tblpatient` p,`tbladmitting` a ,`tbldischargesummary` d WHERE p.`CASENUM`=a.`CASENUM` AND a.`ADMITTINGID`=d.`ADMITTINGID`   " & condition
                RETRIEVEDTG(dtgList, sql)

            End If



        Catch ex As Exception

        End Try
    End Sub
    Dim condition As String
    Private Sub btnsearch_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnsearch.Click
        Try
            If rdoAdmitted.Checked Then
                If cboDiagnosis.Text = "" Then
                    
                Else
                    condition = ""

                End If

                sql = " SELECT p.`CASENUM`, `FNAME`, `LNAME`, `MNAME`, `GENDER`,`DATEADMIT` ,`ADMITTINGDIAGNOSIS`,`DOCNAME`,`RNAME` FROM `tblpatient` p, `tbladmitting` a, `tblroom` r,`tbldoctor` d  WHERE p.`CASENUM`=a.`CASENUM`  AND a.`ROOMID`=r.`ROOMID` AND a.`DOCID`=d.`DOCID` " & condition
                RETRIEVEDTG(dtgList, sql)

            ElseIf rdoDischarge.Checked Then
                condition = ""
                sql = "  SELECT p.`CASENUM` as 'Case #' , `FNAME` as 'FirstName', `LNAME` as 'LastName',  `MNAME` as 'MiddleName',   `GENDER` as 'Sex',`DISCHARGEDDATE` as 'Date' ,`FINALDIAGNOSIS` as 'FinalDiagnosis' ,`ICD_RUVCODE`, `DISPOSISTION`, `RESULT`  FROM `tblpatient` p,`tbladmitting` a ,`tbldischargesummary` d WHERE p.`CASENUM`=a.`CASENUM` AND a.`ADMITTINGID`=d.`ADMITTINGID`  " & condition
                RETRIEVEDTG(dtgList, sql)

            End If



        Catch ex As Exception

        End Try
    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Try
            If rdoAdmitted.Checked Then
    
                With frmcencus
                    sql = " SELECT p.`CASENUM`, `FNAME`, `LNAME`, `MNAME`, `GENDER`,`DATEADMIT` ,`ADMITTINGDIAGNOSIS`,`DOCNAME`,`RNAME` FROM `tblpatient` p, `tbladmitting` a, `tblroom` r,`tbldoctor` d  WHERE p.`CASENUM`=a.`CASENUM`  AND a.`ROOMID`=r.`ROOMID` AND a.`DOCID`=d.`DOCID`"
                    reports(sql, "Admittedpatient", .CrystalReportViewer1)

                    .Show()
                    .Focus()
                End With
            ElseIf rdoDischarge.Checked Then
            

                With frmcencus
                    sql = "   SELECT p.`CASENUM` as 'Case #' , `FNAME` as 'FirstName', `LNAME` as 'LastName',  `MNAME` as 'MiddleName',   `GENDER` as 'Sex',`DISCHARGEDDATE` as 'Date' ,`FINALDIAGNOSIS` as 'FinalDiagnosis' ,`ICD_RUVCODE`, `DISPOSISTION`, `RESULT`  FROM `tblpatient` p,`tbladmitting` a ,`tbldischargesummary` d WHERE p.`CASENUM`=a.`CASENUM` AND a.`ADMITTINGID`=d.`ADMITTINGID` "
                    reports(sql, "dischargepatience", .CrystalReportViewer1)

                    .Show()
                    .Focus()
                End With
            End If



        Catch ex As Exception

        End Try
    End Sub
End Class