Public Class frmListItems

    Private Sub frmListItems_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        sql = "SELECT ItemID, `Barcode`, i.`Description`,`Parts`,`Brand`, `Quantity` FROM `tblbrand` b,`tblitems` i, `tblparts` p WHERE b.`BrandID`=i.`BrandID` AND i.`PartsID`=p.`PartsID`  "
        reloadDtg(sql, DataGridView1)
        DataGridView1.Columns(0).Visible = False
    End Sub

    Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtSearch.TextChanged
        sql = "SELECT ItemID, `Barcode`, i.`Description`,`Parts`,`Brand`, `Quantity` FROM `tblbrand` b,`tblitems` i, `tblparts` p   " &
        " WHERE b.`BrandID`=i.`BrandID` AND i.`PartsID`=p.`PartsID`  AND (Barcode Like '%" & txtSearch.Text & "%' OR Parts Like '%" _
         & txtSearch.Text & "%' OR Brand Like '%" & txtSearch.Text & "%' OR i.Description Like '%" _
         & txtSearch.Text & "%')"
        reloadDtg(sql, DataGridView1)
        DataGridView1.Columns(0).Visible = False
    End Sub

    Private Sub btnEdit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnEdit.Click
        With frmEditItems
            cbo_fill(.cboParts, "Parts", "PartsID", "tblparts")
            cbo_fill(.cboBrand, "Brand", "BrandID", "tblbrand")
            cbo_fill(.cboSupplier, "Supplier", "SupplierId", "tblsupplier")
            .ItemID = DataGridView1.CurrentRow.Cells(0).Value
            sql = "SELECT *,i.Description as 'Desc'  FROM `tblbrand` b,`tblitems` i, `tblparts` p " _
            & "WHERE b.`BrandID`=i.`BrandID` AND i.`PartsID`=p.`PartsID` AND ItemID=" & DataGridView1.CurrentRow.Cells(0).Value
            reloadtxt(sql)
            .txtBarcode.Text = dt.Rows(0).Item("Barcode")
            .cboParts.Text = dt.Rows(0).Item("Parts")
            .cboBrand.Text = dt.Rows(0).Item("Brand")
            .txtPrice.Text = dt.Rows(0).Item("Price")
            .cboSupplier.Text = dt.Rows(0).Item("Supplier")
            .txtDescription.Text = dt.Rows(0).Item("Desc")

            .Show()
            .Focus()

        End With
    End Sub
    Private Sub btnClose_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnClose.Click
        Me.Close()

    End Sub

    Private Sub btnAddQty_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAddQty.Click
        With frmaddItemQuantity
            .txtItemId.Text = DataGridView1.CurrentRow.Cells(0).Value
            .Show()
            .Focus()
            .txtQty.Focus()
        End With
    End Sub

    Private Sub btnView_Click(sender As Object, e As EventArgs) Handles btnView.Click
        With frmViewItems
            .txtBarcode .Text = DataGridView1 .CurrentRow .Cells (1).Value 
            .Show()
            .Focus()
        End With
    End Sub
End Class