Public Class Form1
    Private Sub datagr()
        DataGridView1.DataSource = r.FillingDataView("Select * from dd")
    End Sub
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

        Cn.Open()
        r.Start(Me)
        datagr()
    End Sub

    Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
        Dim v As Boolean = r.FindInPk(TxtFind.Text)

        If v = False Then MsgBox("not found")

        If r("Gender") = "Male" Then
            rmale.Checked = True
        Else
            rfemale.Checked = True
        End If
    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click

        If rfemale.Checked = True Then
            r("Gender") = rfemale.Text
        Else
            r("Gender") = rmale.Text
        End If


        r.AddNew()

        MsgBox("done")
        datagr()
    End Sub

    Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click
        r.Edit(Code.Text)
        MsgBox("ok")
        datagr()
    End Sub

    Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click

        r.Delete(Code.Text)
        MsgBox("deleted")
        datagr()
    End Sub

    Private Sub DataGridView1_CellDoubleClick(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles DataGridView1.CellDoubleClick
        TxtFind.Text = DataGridView1.Rows(e.RowIndex).Cells(0).Value
    End Sub
End Class
