Public Class frmDiagnosis

    Private Sub btnSave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSave.Click
        Try

            If lblid.Text = "" Then

                sql = "INSERT INTO `tbldiagnosis` (`DIAGNOSIS`, `DESCRIPTION`) VALUES ('" & txtDiagnosis.Text & "','" & txtDescription.Text & "')"
                CUD(sql)
                MsgBox("New Diagnosis has been saved.")
             
            Else
                sql = "UPDATE `tbldiagnosis` SET `DIAGNOSIS`='" & txtDiagnosis.Text & _
                "', `DESCRIPTION`='" & txtDescription.Text & "'  WHERE  DIAGNOSISID = " & lblid.Text
                CUD(sql)
                MsgBox("Diagnosis has been updated.")
            End If
            sql = "SELECT * FROM `tbldiagnosis` "
            RETRIEVEDTG(dtglist, sql)
            dtglist.Columns(0).Visible = False
            txtDescription.Clear()
            txtDiagnosis.Clear()
            lblid.Text = ""
        Catch ex As Exception
            MsgBox(ex.Message)
        End Try
    End Sub

    Private Sub btnList_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnList.Click
        Try
            sql = "SELECT * FROM `tbldiagnosis` "
            RETRIEVEDTG(dtglist, sql)
            dtglist.Columns(0).Visible = False
            txtDescription.Clear()
            txtDiagnosis.Clear()
            lblid.Text = ""

        Catch ex As Exception

        End Try
    End Sub

    Private Sub dtglist_DoubleClick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles dtglist.DoubleClick
        Try
            With dtglist
                lblid.Text = .CurrentRow.Cells(0).Value()
                txtDiagnosis.Text = .CurrentRow.Cells(1).Value()
                txtDescription.Text = .CurrentRow.Cells(2).Value
            End With
        Catch ex As Exception

        End Try
    End Sub
End Class