Public Class frmListMaintenance
    Private Sub frmListMaintenance_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

        Try
            ' sql = "SELECT ItemID, `Barcode`, i.`Description`,`Parts`,`Brand`,`ComputerSet`,`Location` FROM `tblbrand` b,`tblitems` i, `tblparts` p, `tbllocation` l,tblcompset c WHERE b.`BrandID`=i.`BrandID` AND i.`PartsID`=p.`PartsID` AND i.`LocationID`=l.`LocationID` AND i.CompSetID=c.CompSetID AND Status='Maintenance'"
            sql = "SELECT a.AssignedID, a.`Barcode`, a.`Description`,`Parts`,`ComputerSet`,`Location`,MaintenanceQuantity as 'Qty' FROM `tblassigneditems` a,`tbllocation` l,`tblcompset` c, `tblmaintenance` m WHERE a.`LocationID`=l.`LocationID` AND a.CompSetID=c.CompSetID AND a.`AssignedID`=m.`AssignedID` AND MSTATUS='Maintenance'"
            reloadDtg(sql, dtglist)
            dtglist.Columns(0).Visible = False
        Catch ex As Exception

        End Try

    End Sub

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

            sql = "UPDATE `tblmaintenance` SET `MSTATUS`='Good' WHERE `AssignedID`=" & dtglist.CurrentRow.Cells(0).Value
            updates(sql)


            sql = "UPDATE  `tblassigneditems` SET `AssignedOnhandQty`=`AssignedOnhandQty`+'" & dtglist.CurrentRow.Cells(6).Value & "' WHERE `AssignedID`=" & dtglist.CurrentRow.Cells(0).Value
            updates(sql)

            MsgBox("The Item has been repaired.")


            Call frmListMaintenance_Load(sender, e)

        Catch ex As Exception

        End Try
    End Sub

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

    Private Sub txtSearch_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtSearch.TextChanged
        'sql = "SELECT ItemID, `Barcode`, i.`Description`,`Parts`,`Brand`,`ComputerSet`,`Location` FROM `tblbrand` b,`tblitems` i, `tblparts` p, `tbllocation` l,tblcompset c WHERE b.`BrandID`=i.`BrandID` AND i.`PartsID`=p.`PartsID` AND i.`LocationID`=l.`LocationID` AND i.CompSetID=c.CompSetID AND Status='Maintenance' AND (Barcode='" & txtSearch.Text & "' OR  i.`Description` LIKE '%" & txtSearch.Text & "%')"
        sql = "SELECT a.AssignedID, a.`Barcode`, a.`Description`,`Parts`,`ComputerSet`,`Location` FROM `tblassigneditems` a,`tbllocation` l,`tblcompset` c, `tblmaintenance` m WHERE a.`LocationID`=l.`LocationID` AND a.CompSetID=c.CompSetID AND a.`AssignedID`=m.`AssignedID` AND MSTATUS='Maintenance' AND (a.Barcode='" & txtSearch.Text & "' OR  a.`Description` LIKE '%" & txtSearch.Text & "%')"
        reloadDtg(sql, dtglist)
        dtglist.Columns(0).Visible = False

    End Sub
End Class