Public Class customer

    Private Sub btnloadall_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnloadall.Click
        mySQL_new("Select ID, custcode as [Customer Code],custname As [Customer],custcontact as [Contact Person],Address,custtel as [Telephone No] from tblcustomer", DataGridView1)

    End Sub

    Private Sub txtcustsearch_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtcustsearch.TextChanged
        mySQL_new("Select ID, custcode as [Customer Code],custname As [Customer], " & _
                    " custcontact as [Contact Person],Address,custtel as [Telephone No] " & _
                    " from tblcustomer where custcode like'%" & txtcustsearch.Text & "%' or custname like '%" & txtcustsearch.Text & "%'", DataGridView1)

    End Sub

    Private Sub btnuse_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnuse.Click
        Try
            With Rent
                .txtusername.Text = DataGridView1.CurrentRow.Cells(2).Value.ToString
               
            End With
            Rent.Show()
            Me.Close()
        Catch ex As Exception
            MsgBox("Please select a customer!", MsgBoxStyle.Exclamation)
        End Try

    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        GroupBox1.Enabled = True
    End Sub

    Private Sub customer_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        GroupBox1.Enabled = False
    End Sub

    Private Sub btncreate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btncreate.Click
        mySQL("Insert Into tblcustomer(custcode,custname,custcontact,Address,custtel) " & _
                    " Values('" & txtcustcode.Text & "','" & txtcustname.Text & "', " & _
                    " '" & txtcontact.Text & "','" & txtaddress.Text & "','" & txttell.Text & "')")
        Call btnloadall_Click(sender, e)


    End Sub
End Class