Imports System
Imports System.Data
Imports System.Data.SqlClient
Imports System.IO
Imports System.Text

Public Class mcSeqForm
    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("MachineSequence")
    Private i, limit As Integer
    Private oldMchName As String = String.Empty
    Private addMode, editMode As Integer
    Private currseq As String

    Private Sub mcSeqForm_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
        toNormalMode()

        getSequence()
        initializeDG()
    End Sub

    Public Sub getSequence()
        Dim sequence As New Sequence
        Dim sequenceList As New List(Of String)
        Dim i As Integer = 0

        cmbRev.Items.Clear()
        sequenceList = sequence.getAllSequence()
        cmbSeq.Items.Clear()
        While i < sequenceList.Count
            cmbSeq.Items.Add(sequenceList(i))
            i = i + 1
        End While
    End Sub

    Public Sub getRevisions()
        Dim rev As New Sequence
        Dim revList As New List(Of String)
        Dim i As Integer = 0

        revList = rev.getRevisions(cmbSeq.SelectedItem, cmbLine.SelectedItem, cmbModel.SelectedItem, cmbType.SelectedItem)
        cmbRev.Items.Clear()
        While i < revList.Count
            cmbRev.Items.Add(revList(i))
            i = i + 1
        End While
    End Sub

    Public Sub getModels()
        Dim rev As New Sequence
        Dim revList As New List(Of String)
        Dim i As Integer = 0

        revList = rev.getModel(cmbSeq.SelectedItem, cmbLine.SelectedItem)
        cmbModel.Items.Clear()
        While i < revList.Count
            cmbModel.Items.Add(revList(i))
            i = i + 1
        End While
    End Sub

    Public Sub getTypes()
        Dim rev As New Sequence
        Dim revList As New List(Of String)
        Dim i As Integer = 0

        revList = rev.getTypes(cmbSeq.SelectedItem, cmbLine.SelectedItem, cmbModel.SelectedItem)
        cmbType.Items.Clear()
        While i < revList.Count
            cmbType.Items.Add(revList(i))
            i = i + 1
        End While
    End Sub

    Public Sub getLines()
        Dim rev As New Sequence
        Dim revList As New List(Of String)
        Dim i As Integer = 0

        revList = rev.getLines(cmbSeq.SelectedItem)
        cmbLine.Items.Clear()
        While i < revList.Count
            cmbLine.Items.Add(revList(i))
            i = i + 1
        End While
    End Sub


    Private Sub fillDataSet(ByVal account As String, ByVal line As String, ByVal model As String, ByVal type As String, ByVal rev As String)
        Dim conn As New SqlConnection(cnstr)
        Dim seqNumber As String
        myQuery = "SELECT KSEQUENCENO FROM KSEQUENCE_HEADER " & _
                  "WHERE KSACCOUNT = '" & account & "' " & _
                  "AND KSQLINE = " & line & " " & _
                  "AND KSQMODEL = '" & model & "' " & _
                  "AND KSQPCBSIDE = '" & type & "' " & _
                  "AND KSQREVISION = '" & rev & "' "

        myCommand = New SqlCommand(myQuery, conn)

        Try
            conn.Open()

            Dim reader = myCommand.ExecuteReader
            reader.Read()
            seqNumber = reader("KSEQUENCENO")
            reader.Close()
            myQuery = "SELECT * FROM KSEQUENCE_DETAIL " & _
                  "WHERE KSEQUENCENO = '" & seqNumber & "' " & _
                  "ORDER BY KSQMODULE,KSQFEEDERNO"

            myCommand = New SqlCommand(myQuery, conn)
            adapter.SelectCommand = myCommand
            ds.Clear()
            adapter.Fill(ds)
            i = 0
            limit = ds.Tables(0).Rows.Count - 1
        Catch ex As Exception
            MessageBox.Show(ex.Message, "Fill Dataset Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
        Finally
            conn.Close()
            conn.Dispose()
        End Try
    End Sub

    Public Sub createView(ByVal kseqno As String)
        Dim conn As New SqlConnection(cnstr)
        myQuery = "CREATE VIEW [CTS" & kseqno & "] AS SELECT TOP (100) PERCENT temp.ModuleAndFeeder, temp.KSQPARTNO AS PartNo, " & _
            "(SELECT        SupplierPN " & _
        "                              FROM            [Toshiba_kanban].[dbo].[PartsRecords] " & _
        "                               WHERE        (SerialNum = t.KMTLABEL)) AS Supplier, " & _
        "                             (SELECT        Description " & _
        "                               FROM            [Toshiba_kanban].[dbo].[PartsRecords]  AS PartsRecords_1 " & _
        "                               WHERE        (SerialNum = t.KMTLABEL)) AS Description,t.KMTLOT as LOT, " & _
        "                             (SELECT        TOP (1) KMTLOT " & _
        "                               FROM            [Toshiba_kanban].[dbo].[KMOUNTING] AS KMOUNTING_1 " & _
        "                             WHERE        (KMTPARTNO = temp.KSQPARTNO) AND (KMTDATE > CAST(temp.dateAndtime AS datetime) - CAST('00:15' AS datetime)) AND  " & _
        "                                                        (KMTDATE < temp.dateAndtime) AND (KMT3PL = 'op-pass') " & _
            " ORDER BY KMTDATE DESC) AS Old_Lot,temp.KSQTOPSDLOC AS Location, " & _
"                      temp.dateAndtime AS DateAndTimeMounted, t.KMTOPERATOR AS Operator " & _
"FROM         (SELECT     seq.KSQMODULE + '-' + seq.KSQFEEDERNO AS ModuleAndFeeder, kmt.dateAndtime, seq.KSQPARTNO, seq.KSQTOPSDLOC" & _
"                       FROM          (SELECT     MAX(KMTDATE) AS dateAndtime, KMTFEEDER, KMTMACHINE" & _
"                                               FROM          [Toshiba_kanban].[dbo].[KMOUNTING] AS KMOUNTING" & _
"                                               WHERE     KMT3PL = 'op-pass' AND (KSEQUENCENO =" & _
"                                                                          (SELECT     KSEQUENCENO" & _
"                                                                            FROM          [Toshiba_kanban].[dbo].[KMOUNTING] AS KMOUNTING" & _
"                                                                            WHERE      (KMTDATE =" & _
"                                                                                                       (SELECT     MAX(KMTDATE) AS Expr1" & _
"                                                                                                         FROM          [Toshiba_kanban].[dbo].[KMOUNTING] AS KMOUNTING" & _
"                                                                                                         WHERE      (KSEQUENCENO = '" & kseqno & "')))))" & _
"                                               GROUP BY KMTFEEDER, KMTMACHINE) AS kmt RIGHT OUTER JOIN" & _
"                                              dbo.KSEQUENCE_DETAIL AS seq ON LTRIM(RTRIM(kmt.KMTMACHINE + '-' + kmt.KMTFEEDER)) " & _
"                                              = LTRIM(RTRIM(seq.KSQMODULE + '-' + seq.KSQFEEDERNO))" & _
"                       WHERE      (seq.KSEQUENCENO =" & _
"                                                  (SELECT     KSEQUENCENO" & _
"                                                    FROM          [Toshiba_kanban].[dbo].[KMOUNTING] AS KMOUNTING" & _
"                                                    WHERE      (KMTDATE =" & _
"                                                                               (SELECT     MAX(KMTDATE) AS Expr1" & _
"                                                                                 FROM         [Toshiba_kanban].[dbo].[KMOUNTING] AS KMOUNTING" & _
"                                                                                 WHERE      (KSEQUENCENO = '" & kseqno & "')))))) AS temp INNER JOIN " & _
"                      [Toshiba_kanban].[dbo].[KMOUNTING] AS t ON temp.ModuleAndFeeder = LTRIM(RTRIM(t.KMTMACHINE + '-' + t.KMTFEEDER)) AND temp.dateAndtime = t.KMTDATE " & _
"ORDER BY temp.ModuleAndFeeder"




        myCommand = New SqlCommand(myQuery, conn)

        Try
            conn.Open()
            myCommand.ExecuteNonQuery()
        Catch ex As Exception
            MessageBox.Show(ex.Message, "Create View Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
        Finally
            conn.Close()
            conn.Dispose()
        End Try
    End Sub

    Private Sub fillDataGridView()
        Dim i As Integer = 0

        dg_mtSeq.Rows.Clear()
        For i = 0 To ds.Tables(0).Rows.Count - 1
            dg_mtSeq.Rows.Add()
            dg_mtSeq.Rows(i).Cells(0).Value = Trim(ds.Tables(0).Rows(i).Item("KSQPARTNO"))
            dg_mtSeq.Rows(i).Cells(1).Value = Trim(ds.Tables(0).Rows(i).Item("KSQMODULE"))
            dg_mtSeq.Rows(i).Cells(2).Value = Trim(ds.Tables(0).Rows(i).Item("KSQFEEDERNO"))
            dg_mtSeq.Rows(i).Cells(3).Value = Trim(ds.Tables(0).Rows(i).Item("KSQFEEDERTYP"))
            dg_mtSeq.Rows(i).Cells(4).Value = Trim(ds.Tables(0).Rows(i).Item("KSQTOPSDLOC"))
            dg_mtSeq.Rows(i).Cells(5).Value = Trim(ds.Tables(0).Rows(i).Item("KSQFSBSQTY"))
            dg_mtSeq.Rows(i).Cells(6).Value = Trim(ds.Tables(0).Rows(i).Item("KSQDESC1"))
            dg_mtSeq.Rows(i).Cells(7).Value = Trim(ds.Tables(0).Rows(i).Item("KSQDESC2"))
            dg_mtSeq.Rows(i).Cells(8).Value = Trim(ds.Tables(0).Rows(i).Item("KSQTOPMARK"))
            dg_mtSeq.Rows(i).Cells(9).Value = Trim(ds.Tables(0).Rows(i).Item("KSQREMARKS"))
        Next
        dg_mtSeq.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells
    End Sub

    Private Sub initializeDG()
        Dim sequence As New DataGridViewTextBoxColumn
        Dim partNo As New DataGridViewTextBoxColumn
        Dim topSDLoc As New DataGridViewTextBoxColumn
        Dim fsbsQty As New DataGridViewTextBoxColumn
        Dim desc1 As New DataGridViewTextBoxColumn
        Dim desc2 As New DataGridViewTextBoxColumn
        Dim topMark As New DataGridViewTextBoxColumn
        Dim feeder As New DataGridViewTextBoxColumn
        Dim feederType As New DataGridViewTextBoxColumn
        Dim sqModule As New DataGridViewTextBoxColumn
        Dim remarks As New DataGridViewTextBoxColumn

        'sequence.HeaderText = "Sequence"
        partNo.HeaderText = "Part Number"
        sqModule.HeaderText = "Machine"
        feeder.HeaderText = "Feeder"
        feederType.HeaderText = "Feeder Type"
        topSDLoc.HeaderText = "Top Side Location"
        fsbsQty.HeaderText = "Quantity"
        desc1.HeaderText = "Desccription 1"
        desc2.HeaderText = "Description 2"
        topMark.HeaderText = "Top Mark"
        remarks.HeaderText = "Remarks"

        dg_mtSeq.Columns.Add(partNo)
        dg_mtSeq.Columns.Add(sqModule)
        dg_mtSeq.Columns.Add(feeder)
        dg_mtSeq.Columns.Add(feederType)
        dg_mtSeq.Columns.Add(topSDLoc)
        dg_mtSeq.Columns.Add(fsbsQty)
        dg_mtSeq.Columns.Add(desc1)
        dg_mtSeq.Columns.Add(desc2)
        dg_mtSeq.Columns.Add(topMark)
        dg_mtSeq.Columns.Add(remarks)

        dg_mtSeq.Columns(0).ReadOnly = True
        dg_mtSeq.Columns(1).ReadOnly = True
        dg_mtSeq.Columns(2).ReadOnly = True
        dg_mtSeq.Columns(3).ReadOnly = True
        dg_mtSeq.Columns(4).ReadOnly = True
        dg_mtSeq.Columns(5).ReadOnly = True
        dg_mtSeq.Columns(6).ReadOnly = True
        dg_mtSeq.Columns(7).ReadOnly = True
        dg_mtSeq.Columns(8).ReadOnly = True
        dg_mtSeq.Columns(9).ReadOnly = True

        dg_mtSeq.Columns(0).SortMode = DataGridViewColumnSortMode.Programmatic
        dg_mtSeq.Columns(1).SortMode = DataGridViewColumnSortMode.Programmatic
        dg_mtSeq.Columns(2).SortMode = DataGridViewColumnSortMode.Programmatic
        dg_mtSeq.Columns(3).SortMode = DataGridViewColumnSortMode.Programmatic
        dg_mtSeq.Columns(4).SortMode = DataGridViewColumnSortMode.Programmatic
        dg_mtSeq.Columns(5).SortMode = DataGridViewColumnSortMode.Programmatic
        dg_mtSeq.Columns(6).SortMode = DataGridViewColumnSortMode.Programmatic
        dg_mtSeq.Columns(7).SortMode = DataGridViewColumnSortMode.Programmatic
        dg_mtSeq.Columns(8).SortMode = DataGridViewColumnSortMode.Programmatic
        dg_mtSeq.Columns(9).SortMode = DataGridViewColumnSortMode.Programmatic
        
        'dg_mtSeq.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells
        dg_mtSeq.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.ColumnHeader

        dg_mtSeq.RowsDefaultCellStyle.BackColor = Color.AntiqueWhite
        dg_mtSeq.AlternatingRowsDefaultCellStyle.BackColor = Color.Beige
    End Sub

    Private Sub cmbSeq_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmbSeq.SelectedIndexChanged
       

        dg_mtSeq.Rows.Clear()
        getLines()
    End Sub

    Private Sub ts_find_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ts_find.Click
        find()
    End Sub

    Private Sub find()
        Dim sequence As New Sequence
        Dim verDet As List(Of String)

        Try
            currseq = sequence.getSequenceNo(cmbSeq.SelectedItem, cmbLine.SelectedItem, cmbModel.SelectedItem, cmbType.SelectedItem, cmbRev.Text)
            fillDataSet(cmbSeq.SelectedItem, cmbLine.SelectedItem, cmbModel.SelectedItem, cmbType.SelectedItem, cmbRev.SelectedItem)
            fillDataGridView()
            If sequence.isVerified(cmbSeq.SelectedItem, cmbLine.SelectedItem, cmbModel.SelectedItem, cmbType.SelectedItem, cmbRev.SelectedItem) Then
                btn_verify.Enabled = False
                verDet = sequence.verificationDetails(cmbSeq.SelectedItem, cmbLine.SelectedItem, cmbModel.SelectedItem, cmbType.SelectedItem, cmbRev.SelectedItem)
                txtVerBy.Text = verDet(0)
                txtVerDate.Text = CDate(verDet(1))
            Else
                If loginForm.userType = "Quality Control" Or loginForm.userType = "Administrator" Or loginForm.userType = "Super Administrator" Then
                    btn_verify.Enabled = True
                End If
                txtVerBy.Text = String.Empty
                txtVerDate.Text = String.Empty
            End If

            If loginForm.userType = "Engineer" Or loginForm.userType = "Administrator" Or loginForm.userType = "Super Administrator" Then
                ts_edit.Enabled = True
                ts_delete.Enabled = True
            End If
        Catch ex As Exception
            toNormalMode()
        End Try
    End Sub

    Private Sub ts_new_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ts_new.Click
        uploadMcSeq.Show()
    End Sub

    Private Sub ts_edit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ts_edit.Click
        'dg_mtSeq.Columns(0).ReadOnly = False
        'dg_mtSeq.Columns(1).ReadOnly = False
        'dg_mtSeq.Columns(2).ReadOnly = False
        dg_mtSeq.Columns(3).ReadOnly = False
        dg_mtSeq.Columns(4).ReadOnly = False
        dg_mtSeq.Columns(5).ReadOnly = False
        dg_mtSeq.Columns(6).ReadOnly = False
        dg_mtSeq.Columns(7).ReadOnly = False
        dg_mtSeq.Columns(8).ReadOnly = False
        dg_mtSeq.Columns(9).ReadOnly = False
        toEditMode()
    End Sub

    Private Sub ts_close_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
        Me.Close()
    End Sub

    Public Sub add()
        addMode = 1
        editMode = 0
        toAddMode()
    End Sub

    Public Sub edit()

        editMode = 1
        addMode = 0

        toEditMode()
    End Sub

    Public Sub toNormalMode()
        If loginForm.userType = "Engineer" Or loginForm.userType = "Administrator" Or loginForm.userType = "Super Administrator" Then
            ts_new.Enabled = True
        End If
        ts_edit.Enabled = False
        ts_delete.Enabled = False
        ts_find.Enabled = True
        ts_revert.Enabled = False
        ts_save.Enabled = False
    End Sub

    Public Sub toEditMode()
        ts_new.Enabled = False
        ts_edit.Enabled = False
        ts_delete.Enabled = False
        ts_find.Enabled = False
        ts_revert.Enabled = True
        ts_save.Enabled = True
        disableControls()
    End Sub

    Public Sub toAddMode()
        ts_new.Enabled = False
        ts_edit.Enabled = False
        ts_delete.Enabled = False
        ts_find.Enabled = False
        ts_revert.Enabled = True
        ts_save.Enabled = True
    End Sub

    Public Sub toSearchMode()
        ts_new.Enabled = False
        ts_edit.Enabled = False
        ts_delete.Enabled = False
        ts_find.Enabled = True
        ts_revert.Enabled = False
        ts_save.Enabled = False
    End Sub

    Private Sub enableControls()
        cmbRev.Enabled = True
        cmbSeq.Enabled = True
    End Sub

    Private Sub disableControls()
        cmbRev.Enabled = False
        cmbSeq.Enabled = False
    End Sub

    Private Sub clear()
        txtVerBy.Text = String.Empty
        txtVerDate.Text = String.Empty
    End Sub

    Private Sub btn_verify_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_verify.Click
        If MessageBox.Show("Are you sure you want to approve?" & vbCrLf & " Account: " & cmbSeq.SelectedItem & vbCrLf & " Line: " & cmbLine.SelectedItem & vbCrLf & " Model: " & cmbModel.SelectedItem & vbCrLf & " Type: " & cmbType.SelectedItem & vbCrLf & " Revision Number: " & cmbRev.Text, "Approve Sequence Number", MessageBoxButtons.YesNo, MessageBoxIcon.Question) = Windows.Forms.DialogResult.Yes Then
            Dim sequence As New Sequence
            sequence.sequenceno = currseq
            sequence.checkby = loginForm.username
            sequence.chkdate = DateTime.Now
            If sequence.approve() Then
                createView(currseq)
                MessageBox.Show("Successfully Approved.", "Approve Sequence Number", MessageBoxButtons.OK, MessageBoxIcon.Information)
                txtVerBy.Text = loginForm.username
                txtVerDate.Text = Date.Now
                btn_verify.Enabled = False
            End If
        End If
    End Sub

    Private Sub ts_delete_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ts_delete.Click
        If MessageBox.Show("Are you sure you want to delete?" & vbCrLf & " Account: " & cmbSeq.SelectedItem & vbCrLf & " Line: " & cmbLine.SelectedItem & vbCrLf & " Model: " & cmbModel.SelectedItem & vbCrLf & " Type: " & cmbType.SelectedItem & vbCrLf & " Revision Number: " & cmbRev.Text, "Delete Sequence Number", MessageBoxButtons.YesNo, MessageBoxIcon.Question) = Windows.Forms.DialogResult.Yes Then
            Dim sequence As New Sequence

            sequence.sequenceno = currseq
            sequence.deleteDetail()
            sequence.deleteHeader()
            MessageBox.Show("Successfully Deleted.", "Delete Sequence Number", MessageBoxButtons.OK, MessageBoxIcon.Information)

            getSequence()
            cmbRev.Items.Clear()
            dg_mtSeq.Rows.Clear()
            clear()
            toNormalMode()
        End If
    End Sub

    Private Sub ts_revert_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ts_revert.Click
        fillDataSet(cmbSeq.SelectedItem, cmbLine.SelectedItem, cmbModel.SelectedItem, cmbType.SelectedItem, cmbRev.Text)
        fillDataGridView()
        dg_mtSeq.Columns(0).ReadOnly = True
        dg_mtSeq.Columns(1).ReadOnly = True
        dg_mtSeq.Columns(2).ReadOnly = True
        dg_mtSeq.Columns(3).ReadOnly = True
        dg_mtSeq.Columns(4).ReadOnly = True
        dg_mtSeq.Columns(5).ReadOnly = True
        dg_mtSeq.Columns(6).ReadOnly = True
        dg_mtSeq.Columns(7).ReadOnly = True
        dg_mtSeq.Columns(8).ReadOnly = True
        dg_mtSeq.Columns(9).ReadOnly = True
        toNormalMode()
        enableControls()
    End Sub

    Private Sub save()
        Dim seq As New Sequence()
        Dim i As Integer = 0

        seq.sequenceno = currseq

        seq.checkby = String.Empty
        seq.chkdate = Nothing
        If seq.disApprove() Then
            seq.deleteDetail()

            While i < dg_mtSeq.Rows.Count
                seq.partno = dg_mtSeq.Rows(i).Cells(0).Value
                seq.modules = dg_mtSeq.Rows(i).Cells(1).Value
                seq.feeder = dg_mtSeq.Rows(i).Cells(2).Value
                seq.feederType = dg_mtSeq.Rows(i).Cells(3).Value
                seq.topsdloc = dg_mtSeq.Rows(i).Cells(4).Value
                seq.fsbsqty = dg_mtSeq.Rows(i).Cells(5).Value
                seq.desc1 = dg_mtSeq.Rows(i).Cells(6).Value
                seq.desc2 = dg_mtSeq.Rows(i).Cells(7).Value
                seq.topmark = dg_mtSeq.Rows(i).Cells(8).Value
                seq.remarks = dg_mtSeq.Rows(i).Cells(9).Value
                seq.addDetail()
                i = i + 1
            End While
        End If
    End Sub

    Private Sub ts_save_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ts_save.Click
        If MessageBox.Show("Are you sure you want to save the updates to this Sequence Number: " & cmbSeq.SelectedItem & " with Revision Number: " & cmbRev.SelectedItem & "?", "Delete Sequence Number", MessageBoxButtons.YesNo, MessageBoxIcon.Question) = Windows.Forms.DialogResult.Yes Then
            save()
            MessageBox.Show("Successfully Saved.", "Save Sequence Number", MessageBoxButtons.OK, MessageBoxIcon.Information)
            toNormalMode()
            find()
        End If
    End Sub

    Private Sub cmbRev_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmbRev.SelectedIndexChanged
        If cmbSeq.SelectedItem <> "" And cmbLine.SelectedItem <> "" And cmbRev.SelectedItem <> "" And cmbModel.SelectedItem <> "" And cmbType.SelectedItem <> "" Then
            find()
        End If
    End Sub

    Private Sub cmbPlant_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs)
        getSequence()
    End Sub

   
    Private Sub cmbModel_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs)
       
    End Sub

    Private Sub cmbMachine_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs)
        If cmbSeq.SelectedItem <> "" And cmbLine.SelectedItem <> "" And cmbRev.SelectedItem <> "" Then
            find()
        End If
    End Sub

    Private Sub cmbLine_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmbLine.SelectedIndexChanged
        dg_mtSeq.Rows.Clear()
        getModels()
    End Sub

    Private Sub cmbModel_SelectedIndexChanged_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmbModel.SelectedIndexChanged
        dg_mtSeq.Rows.Clear()
        getTypes()
    End Sub

    Private Sub cmbType_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmbType.SelectedIndexChanged
        dg_mtSeq.Rows.Clear()
        getRevisions()
    End Sub
End Class