Imports System
Imports System.Data
Imports System.Data.SqlClient
Imports System.IO
Imports System.Text
Public Class PPInventoryForm

    Private cnstr = mainForm.cnstr
    Private conn As New SqlConnection(cnstr)
    Private myQuery As String = String.Empty
    Private myCommand As SqlCommand
    Private adapter As SqlDataAdapter = New SqlDataAdapter()
    Private ds As New DataSet("Machines")
    Private i, limit As Integer
    Private oldMchCode As String = String.Empty
    Private addMode, editMode As Integer
    Private row As Integer
    Private partnumber, statuses, currstat As String
    Private rawData As Boolean = False
    Public serialOnly As Boolean = False
    Private status() = New String() {"WHS", "PDN", "SMT", "Hold", "Scrap"}


    Private Sub PPInventoryForm_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Me.MdiParent = mainForm
        Control.CheckForIllegalCrossThreadCalls = False
        Me.Top = 0
        Me.Left = 0

        If serialOnly Then
            initializeDG_inventory3()
            fillDataSet_inventory2()
            fillDataGridView_inventory3()
        Else
            initializeDG_inventory()
            fillDataSet_inventory()
            fillDataGridView_inventory()
        End If
    End Sub

    Private Sub initializeDG_inventory()
        Dim partno As New DataGridViewTextBoxColumn
        Dim received As New DataGridViewLinkColumn
        Dim mounted As New DataGridViewLinkColumn
        Dim returned As New DataGridViewLinkColumn
        Dim hold As New DataGridViewLinkColumn
        Dim scrap As New DataGridViewLinkColumn

        partno.HeaderText = "Part Number"
        received.HeaderText = "Received"
        mounted.HeaderText = "Mounted"
        returned.HeaderText = "Issued"
        hold.HeaderText = "Hold"
        scrap.HeaderText = "Scrap"

        received.LinkColor = Color.Black
        mounted.LinkColor = Color.Black
        returned.LinkColor = Color.Black
        hold.LinkColor = Color.Black
        scrap.LinkColor = Color.Black

        dg_inventory.Columns.Add(partno)
        dg_inventory.Columns.Add(received)
        dg_inventory.Columns.Add(returned)
        dg_inventory.Columns.Add(mounted)
        dg_inventory.Columns.Add(hold)
        dg_inventory.Columns.Add(scrap)

        dg_inventory.Columns(0).ReadOnly = True
        dg_inventory.Columns(1).ReadOnly = True
        dg_inventory.Columns(2).ReadOnly = True
        dg_inventory.Columns(3).ReadOnly = True
        dg_inventory.Columns(4).ReadOnly = True
        dg_inventory.Columns(5).ReadOnly = True

        dg_inventory.Columns(0).Width = 150
        dg_inventory.Columns(1).Width = 150
        dg_inventory.Columns(2).Width = 120
        dg_inventory.Columns(3).Width = 150
        dg_inventory.Columns(4).Width = 150
        dg_inventory.Columns(5).Width = 150

        dg_inventory.SelectionMode = DataGridViewSelectionMode.FullRowSelect

        dg_inventory.Columns(0).SortMode = DataGridViewColumnSortMode.Programmatic
        dg_inventory.Columns(1).SortMode = DataGridViewColumnSortMode.Programmatic
        dg_inventory.Columns(2).SortMode = DataGridViewColumnSortMode.Programmatic
        dg_inventory.Columns(3).SortMode = DataGridViewColumnSortMode.Programmatic
        dg_inventory.Columns(4).SortMode = DataGridViewColumnSortMode.Programmatic
        dg_inventory.Columns(5).SortMode = DataGridViewColumnSortMode.Programmatic
    End Sub

    Private Sub initializeDG_inventory2(ByVal status As String)
        Dim partno As New DataGridViewTextBoxColumn
        Dim received As New DataGridViewTextBoxColumn
        Dim mounted As New DataGridViewTextBoxColumn
        Dim returned As New DataGridViewTextBoxColumn
        Dim qty As New DataGridViewTextBoxColumn
        Dim line As New DataGridViewTextBoxColumn
        Dim model As New DataGridViewTextBoxColumn
        Dim time As New DataGridViewTextBoxColumn
        Dim opt As New DataGridViewTextBoxColumn
        Dim invoice As New DataGridViewTextBoxColumn


        partno.HeaderText = "Serial No."
        received.HeaderText = "Ionics PN"
        mounted.HeaderText = "Toshiba PN"
        returned.HeaderText = "Supplier Name"
        qty.HeaderText = "Quantity"
        line.HeaderText = "Line"
        model.HeaderText = "Model"
        time.HeaderText = "Time"
        opt.HeaderText = "Operator"
        invoice.HeaderText = "Invoice"


        dg_inventory.Columns.Add(partno)
        dg_inventory.Columns.Add(received)
        dg_inventory.Columns.Add(returned)
        dg_inventory.Columns.Add(mounted)
        dg_inventory.Columns.Add(qty)
        
        dg_inventory.Columns(0).ReadOnly = True
        dg_inventory.Columns(1).ReadOnly = True
        dg_inventory.Columns(2).ReadOnly = True
        dg_inventory.Columns(3).ReadOnly = True
        dg_inventory.Columns(4).ReadOnly = True

        dg_inventory.Columns(0).Width = 150
        dg_inventory.Columns(1).Width = 150
        dg_inventory.Columns(2).Width = 120
        dg_inventory.Columns(3).Width = 150
        dg_inventory.Columns(4).Width = 150

        dg_inventory.SelectionMode = DataGridViewSelectionMode.FullRowSelect

        dg_inventory.Columns(0).SortMode = DataGridViewColumnSortMode.Programmatic
        dg_inventory.Columns(1).SortMode = DataGridViewColumnSortMode.Programmatic
        dg_inventory.Columns(2).SortMode = DataGridViewColumnSortMode.Programmatic
        dg_inventory.Columns(3).SortMode = DataGridViewColumnSortMode.Programmatic
        dg_inventory.Columns(4).SortMode = DataGridViewColumnSortMode.Programmatic

        If status = "SMT" Then
            dg_inventory.Columns.Add(line)
            dg_inventory.Columns.Add(model)
            dg_inventory.Columns.Add(time)
            dg_inventory.Columns.Add(opt)
            dg_inventory.Columns(5).ReadOnly = True
            dg_inventory.Columns(6).ReadOnly = True
            dg_inventory.Columns(7).ReadOnly = True
            dg_inventory.Columns(8).ReadOnly = True
            dg_inventory.Columns(5).Width = 150
            dg_inventory.Columns(6).Width = 150
            dg_inventory.Columns(7).Width = 150
            dg_inventory.Columns(8).Width = 150
            dg_inventory.Columns(5).SortMode = DataGridViewColumnSortMode.Programmatic
            dg_inventory.Columns(6).SortMode = DataGridViewColumnSortMode.Programmatic
            dg_inventory.Columns(7).SortMode = DataGridViewColumnSortMode.Programmatic
            dg_inventory.Columns(8).SortMode = DataGridViewColumnSortMode.Programmatic
            dg_inventory.Columns.Add(invoice)
            dg_inventory.Columns(9).ReadOnly = True
            dg_inventory.Columns(9).Width = 150
            dg_inventory.Columns(9).SortMode = DataGridViewColumnSortMode.Programmatic
        Else

            dg_inventory.Columns.Add(invoice)
            dg_inventory.Columns(5).ReadOnly = True
            dg_inventory.Columns(5).Width = 150
            dg_inventory.Columns(5).SortMode = DataGridViewColumnSortMode.Programmatic
        End If



    End Sub

    Private Sub initializeDG_inventory3()
        Dim partno As New DataGridViewTextBoxColumn
        Dim received As New DataGridViewTextBoxColumn
        Dim mounted As New DataGridViewTextBoxColumn
        Dim returned As New DataGridViewTextBoxColumn
        Dim qty As New DataGridViewTextBoxColumn
        Dim line As New DataGridViewTextBoxColumn
        Dim model As New DataGridViewTextBoxColumn
        Dim time As New DataGridViewTextBoxColumn
        Dim opt As New DataGridViewTextBoxColumn
        Dim invoice As New DataGridViewTextBoxColumn


        partno.HeaderText = "Serial No."
        received.HeaderText = "Ionics PN"
        mounted.HeaderText = "Toshiba PN"
        returned.HeaderText = "Supplier Name"
        qty.HeaderText = "Quantity"
        line.HeaderText = "Line"
        model.HeaderText = "Model"
        time.HeaderText = "Time"
        opt.HeaderText = "Operator"
        invoice.HeaderText = "Invoice"


        dg_inventory.Columns.Add(partno)
        dg_inventory.Columns.Add(received)
        dg_inventory.Columns.Add(returned)
        dg_inventory.Columns.Add(mounted)
        dg_inventory.Columns.Add(qty)

        dg_inventory.Columns(0).ReadOnly = True
        dg_inventory.Columns(1).ReadOnly = True
        dg_inventory.Columns(2).ReadOnly = True
        dg_inventory.Columns(3).ReadOnly = True
        dg_inventory.Columns(4).ReadOnly = True

        dg_inventory.Columns(0).Width = 150
        dg_inventory.Columns(1).Width = 150
        dg_inventory.Columns(2).Width = 120
        dg_inventory.Columns(3).Width = 150
        dg_inventory.Columns(4).Width = 150

        dg_inventory.SelectionMode = DataGridViewSelectionMode.FullRowSelect

        dg_inventory.Columns(0).SortMode = DataGridViewColumnSortMode.Programmatic
        dg_inventory.Columns(1).SortMode = DataGridViewColumnSortMode.Programmatic
        dg_inventory.Columns(2).SortMode = DataGridViewColumnSortMode.Programmatic
        dg_inventory.Columns(3).SortMode = DataGridViewColumnSortMode.Programmatic
        dg_inventory.Columns(4).SortMode = DataGridViewColumnSortMode.Programmatic
        dg_inventory.Columns.Add(line)
        dg_inventory.Columns.Add(model)
        dg_inventory.Columns.Add(time)
        dg_inventory.Columns.Add(opt)
        dg_inventory.Columns(5).ReadOnly = True
        dg_inventory.Columns(6).ReadOnly = True
        dg_inventory.Columns(7).ReadOnly = True
        dg_inventory.Columns(8).ReadOnly = True
        dg_inventory.Columns(5).Width = 150
        dg_inventory.Columns(6).Width = 150
        dg_inventory.Columns(7).Width = 150
        dg_inventory.Columns(8).Width = 150
        dg_inventory.Columns(5).SortMode = DataGridViewColumnSortMode.Programmatic
        dg_inventory.Columns(6).SortMode = DataGridViewColumnSortMode.Programmatic
        dg_inventory.Columns(7).SortMode = DataGridViewColumnSortMode.Programmatic
        dg_inventory.Columns(8).SortMode = DataGridViewColumnSortMode.Programmatic


        dg_inventory.Columns.Add(invoice)
        dg_inventory.Columns(9).ReadOnly = True
        dg_inventory.Columns(9).Width = 150
        dg_inventory.Columns(9).SortMode = DataGridViewColumnSortMode.Programmatic
    End Sub

    Private Sub fillDataSet_inventory()
        Dim conn As New SqlConnection(cnstr)

        myQuery = "SELECT s.[IonicsPN] AS PartNumber " &
      ",COALESCE((SELECT SUM(CAST(QTY AS BIGINT)) FROM [Toshiba_kanban].[dbo].[PartsRecords] a WHERE a.Status = 'WHS' AND a.ionicsPN = s.IonicsPN),0) as [Received] " &
      ",COALESCE((SELECT SUM(CAST(QTY AS BIGINT)) FROM [Toshiba_kanban].[dbo].[PartsRecords] a WHERE a.Status = 'PDN' AND a.ionicsPN = s.IonicsPN),0) as [Issued] " &
      ",COALESCE((SELECT SUM(CAST(QTY AS BIGINT)) FROM [Toshiba_kanban].[dbo].[PartsRecords] a WHERE a.Status = 'SMT' AND a.ionicsPN = s.IonicsPN),0) as [Mounted] " &
      ",COALESCE((SELECT SUM(CAST(QTY AS BIGINT)) FROM [Toshiba_kanban].[dbo].[PartsRecords] a WHERE a.Status = 'Hold' AND a.ionicsPN = s.IonicsPN),0) as [Hold] " &
      ",COALESCE((SELECT SUM(CAST(QTY AS BIGINT)) FROM [Toshiba_kanban].[dbo].[PartsRecords] a WHERE a.Status = 'Scrap' AND a.ionicsPN = s.IonicsPN),0) as [Scrap] " &
      "FROM [dbo].[PartsRecords] s WHERE s.[IonicsPN] LIKE '%" & txtSearch.Text & "%' AND s.[Family] = 'Mobile'" &
      "GROUP BY s.[IonicsPN]"

        myCommand = New SqlCommand(myQuery, conn)

        Try
            conn.Open()
            adapter.SelectCommand = myCommand
            ds.Clear()
            adapter.Fill(ds)
        Catch ex As Exception
            MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
        Finally
            conn.Close()
            conn.Dispose()
        End Try
    End Sub

    Private Sub fillDataSet_inventory2()
        Dim conn As New SqlConnection(cnstr)
        myQuery = "SELECT [SerialNum],[IonicsPN],[ToshibaPN],[SupplierPN] AS [Supplier_Name],[Qty],d.[KSQLINE] AS [Line],d.[KSQREVISION] AS [Model],d.[KMTDATE] AS [Date],d.[KMTOPERATOR] AS [Operator],[InvoiceNum] FROM [Toshiba_kanban].[dbo].[PartsRecords] k " & _
                  "LEFT JOIN (SELECT b.KSQLINE " & _
                    ",a.KMTOPERATOR,b.KSQREVISION " & _
                    ",[KMTLABEL],a.KMTDATE " & _
                    " FROM [Toshiba_kanban].[dbo].[KMOUNTING] a  " & _
                    "INNER JOIN [Toshiba_kanban].[dbo].[KSEQUENCE_HEADER] b ON a.KSEQUENCENO = b.KSEQUENCENO " & _
                    "where KMT3PL = 'op-pass' " & _
                    "GROUP BY  b.KSQLINE,a.KMTLABEL,b.KSQREVISION,a.KMTOPERATOR,a.KMTDATE ) d ON d.KMTLABEL = k.SerialNum " & _
                  "WHERE [SerialNum] LIKE '%" & txtSearch.Text & "%' AND k.[Family] = 'Mobile'"

        myCommand = New SqlCommand(myQuery, conn)

        Try
            conn.Open()
            adapter.SelectCommand = myCommand
            ds.Clear()
            adapter.Fill(ds)
        Catch ex As Exception
            MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
        Finally
            conn.Close()
            conn.Dispose()
        End Try
    End Sub

    Private Sub fillDataSet_inventory(ByVal partnumber As String, ByVal status As String)
        Dim conn As New SqlConnection(cnstr)
        Me.partnumber = partnumber
        Me.statuses = status
        myQuery = "SELECT [SerialNum],[IonicsPN],[ToshibaPN],[SupplierPN] AS [Supplier_Name],[Qty],d.[KSQLINE] AS [Line],d.[KSQREVISION] AS [Model],d.[KMTDATE] AS [Date],d.[KMTOPERATOR] AS [Operator],[InvoiceNum] FROM [Toshiba_kanban].[dbo].[PartsRecords] k " &
                  "LEFT JOIN (SELECT b.KSQLINE " &
                    ",a.KMTOPERATOR,b.KSQREVISION " &
                    ",[KMTLABEL],a.KMTDATE " &
                    " FROM [Toshiba_kanban].[dbo].[KMOUNTING] a  " &
                    "INNER JOIN[Toshiba_kanban].[dbo].[KSEQUENCE_HEADER] b ON a.KSEQUENCENO = b.KSEQUENCENO " &
                    "where KMT3PL = 'op-pass' " &
                    "GROUP BY  b.KSQLINE,a.KMTLABEL,b.KSQREVISION,a.KMTOPERATOR,a.KMTDATE ) d ON d.KMTLABEL = k.SerialNum " &
                  "WHERE [IonicsPN] = '" & partnumber & "' AND [Status] = '" & status & "' AND k.[Family] = 'Mobile'"

        myCommand = New SqlCommand(myQuery, conn)

        Try
            conn.Open()
            adapter.SelectCommand = myCommand
            ds.Clear()
            adapter.Fill(ds)
        Catch ex As Exception
            MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
        Finally
            conn.Close()
            conn.Dispose()
        End Try
    End Sub

    Private Sub fillDataSet_inventory(ByVal partnumber As String, ByVal serial As String, ByVal status As String)
        Dim conn As New SqlConnection(cnstr)
        Me.partnumber = partnumber
        Me.statuses = status
        myQuery = "SELECT [SerialNum],[IonicsPN],[ToshibaPN],[SupplierPN] AS [Supplier_Name],[Qty],d.[KSQLINE] AS [Line],d.[KSQREVISION] AS [Model],d.[KMTDATE] AS [Date],d.[KMTOPERATOR] AS [Operator],[InvoiceNum] FROM [Toshiba_kanban].[dbo].[PartsRecords] k " &
                  "LEFT JOIN (SELECT b.KSQLINE " &
                    ",a.KMTOPERATOR,b.KSQREVISION " &
                    ",[KMTLABEL],a.KMTDATE " &
                    " FROM [Toshiba_kanban].[dbo].[KMOUNTING] a  " &
                    "INNER JOIN [Toshiba_kanban].[dbo].[KSEQUENCE_HEADER] b ON a.KSEQUENCENO = b.KSEQUENCENO " &
                    "where KMT3PL = 'op-pass' " &
                    "GROUP BY  b.KSQLINE,a.KMTLABEL,b.KSQREVISION,a.KMTOPERATOR,a.KMTDATE ) d ON d.KMTLABEL = k.SerialNum " &
                  "WHERE [IonicsPN] = '" & partnumber & "' AND [Status] = '" & status & "' AND [SerialNum] LIKE '%" & serial & "%'  AND k.[Family] = 'Mobile'"

        myCommand = New SqlCommand(myQuery, conn)

        Try
            conn.Open()
            adapter.SelectCommand = myCommand
            ds.Clear()
            adapter.Fill(ds)
        Catch ex As Exception
            MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
        Finally
            conn.Close()
            conn.Dispose()
        End Try
    End Sub

    Private Sub fillDataGridView_inventory()
        Dim i As Integer = 0

        dg_inventory.Rows.Clear()
        For i = 0 To ds.Tables(0).Rows.Count - 1
            row = dg_inventory.Rows.Add()
            dg_inventory.Rows(row).Cells(0).Value = ds.Tables(0).Rows(row).Item("PartNumber")
            dg_inventory.Rows(row).Cells(1).Value = ds.Tables(0).Rows(row).Item("Received")
            dg_inventory.Rows(row).Cells(2).Value = ds.Tables(0).Rows(row).Item("Issued")
            dg_inventory.Rows(row).Cells(3).Value = ds.Tables(0).Rows(row).Item("Mounted")
            dg_inventory.Rows(row).Cells(4).Value = ds.Tables(0).Rows(row).Item("Hold")
            dg_inventory.Rows(row).Cells(5).Value = ds.Tables(0).Rows(row).Item("Scrap")

            If (ds.Tables(0).Rows(row).Item("Received") = 0) Then
                dg_inventory.Rows(row).Cells(1).Style.BackColor = Color.LightCoral
            ElseIf (ds.Tables(0).Rows(row).Item("Issued") = 0) Then
                dg_inventory.Rows(row).Cells(2).Style.BackColor = Color.LightCoral
            ElseIf (ds.Tables(0).Rows(row).Item("Mounted") = 0) Then
                dg_inventory.Rows(row).Cells(3).Style.BackColor = Color.LightCoral
            ElseIf (ds.Tables(0).Rows(row).Item("Hold") = 0) Then
                dg_inventory.Rows(row).Cells(4).Style.BackColor = Color.LightCoral
            ElseIf (ds.Tables(0).Rows(row).Item("Scrap") = 0) Then
                dg_inventory.Rows(row).Cells(5).Style.BackColor = Color.LightCoral
            End If
        Next
    End Sub

    Private Sub fillDataGridView_inventory2(ByVal status As String)
        Dim i As Integer = 0

        dg_inventory.Rows.Clear()
        For i = 0 To ds.Tables(0).Rows.Count - 1
            row = dg_inventory.Rows.Add()
            dg_inventory.Rows(row).Cells(0).Value = ds.Tables(0).Rows(row).Item("SerialNum")
            dg_inventory.Rows(row).Cells(1).Value = ds.Tables(0).Rows(row).Item("IonicsPN")
            dg_inventory.Rows(row).Cells(2).Value = ds.Tables(0).Rows(row).Item("ToshibaPN")
            dg_inventory.Rows(row).Cells(3).Value = ds.Tables(0).Rows(row).Item("Supplier_Name")
            dg_inventory.Rows(row).Cells(4).Value = ds.Tables(0).Rows(row).Item("Qty")

            If status = "SMT" Then
                dg_inventory.Rows(row).Cells(5).Value = ds.Tables(0).Rows(row).Item("Line")
                dg_inventory.Rows(row).Cells(6).Value = ds.Tables(0).Rows(row).Item("Model")
                dg_inventory.Rows(row).Cells(7).Value = ds.Tables(0).Rows(row).Item("Date")
                dg_inventory.Rows(row).Cells(8).Value = ds.Tables(0).Rows(row).Item("Operator")
                dg_inventory.Rows(row).Cells(9).Value = ds.Tables(0).Rows(row).Item("InvoiceNum")
            Else

                dg_inventory.Rows(row).Cells(5).Value = ds.Tables(0).Rows(row).Item("InvoiceNum")
            End If
        Next
    End Sub

    Private Sub fillDataGridView_inventory3()
        Dim i As Integer = 0

        dg_inventory.Rows.Clear()
        For i = 0 To ds.Tables(0).Rows.Count - 1
            row = dg_inventory.Rows.Add()
            dg_inventory.Rows(row).Cells(0).Value = ds.Tables(0).Rows(row).Item("SerialNum")
            dg_inventory.Rows(row).Cells(1).Value = ds.Tables(0).Rows(row).Item("IonicsPN")
            dg_inventory.Rows(row).Cells(2).Value = ds.Tables(0).Rows(row).Item("ToshibaPN")
            dg_inventory.Rows(row).Cells(3).Value = ds.Tables(0).Rows(row).Item("Supplier_Name")
            dg_inventory.Rows(row).Cells(4).Value = ds.Tables(0).Rows(row).Item("Qty")
            dg_inventory.Rows(row).Cells(5).Value = ds.Tables(0).Rows(row).Item("Line")
            dg_inventory.Rows(row).Cells(6).Value = ds.Tables(0).Rows(row).Item("Model")
            dg_inventory.Rows(row).Cells(7).Value = ds.Tables(0).Rows(row).Item("Date")
            dg_inventory.Rows(row).Cells(8).Value = ds.Tables(0).Rows(row).Item("Operator")
            dg_inventory.Rows(row).Cells(9).Value = ds.Tables(0).Rows(row).Item("InvoiceNum")
        Next
    End Sub

    Private Sub dg_inventory_CellClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles dg_inventory.CellClick

    End Sub

    Private Sub dg_inventory_CellContentClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles dg_inventory.CellContentClick

        If Not serialOnly Then
            If rawData = False Then
                If e.RowIndex >= 0 And e.ColumnIndex <> 0 Then
                    btnBack.Visible = True
                    rawData = True
                    currstat = status(e.ColumnIndex - 1)
                    fillDataSet_inventory(dg_inventory.Rows(e.RowIndex).Cells(0).Value, currstat)
                    dg_inventory.Columns.Clear()
                    initializeDG_inventory2(currstat)
                    fillDataGridView_inventory2(currstat)

                    txtSearch.Text = Nothing
                End If
            End If
        End If
    End Sub

    Private Sub btnBack_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnBack.Click

        rawData = False
        dg_inventory.Columns.Clear()
        initializeDG_inventory()
        fillDataSet_inventory()
        fillDataGridView_inventory()
        txtSearch.Text = Nothing
        btnBack.Visible = False
        Me.partnumber = Nothing
        Me.statuses = Nothing
    End Sub

    Private Sub txtSearch_TextChanged(sender As System.Object, e As System.EventArgs) Handles txtSearch.TextChanged
        
    End Sub

    Private Sub txtSearch_KeyPress(sender As System.Object, e As System.Windows.Forms.KeyPressEventArgs) Handles txtSearch.KeyPress
        If Asc(e.KeyChar) = 13 Then

            If serialOnly Then

                dg_inventory.Columns.Clear()
                initializeDG_inventory3()
                fillDataSet_inventory2()
                fillDataGridView_inventory3()
            Else
                If (rawData) Then
                    fillDataSet_inventory(Me.partnumber, Me.statuses)
                    dg_inventory.Columns.Clear()
                    initializeDG_inventory2(currstat)
                    fillDataGridView_inventory2(currstat)
                Else
                    dg_inventory.Columns.Clear()
                    initializeDG_inventory()
                    fillDataSet_inventory()
                    fillDataGridView_inventory()
                End If
            End If
        End If

    End Sub


 
End Class