Imports System.IO.Ports

Public Class mainForm

    Public cnstr As String = loginForm.cnstr

    Private Sub ManualToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
        mcSeqForm.Show()
    End Sub

    Private Sub mainForm_FormClosed(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosedEventArgs) Handles Me.FormClosed
        loginForm.Close()
    End Sub

    Private Sub mainForm_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Me.WindowState = FormWindowState.Maximized
        ' Me.Text = "PCBA Issuance v2.3.9 Current User - " & loginForm.username
        Me.Text = "Kanban PCBA Issuance v.2023 Current User - " & loginForm.username

        Select Case loginForm.userType
            Case "Operator"
                MaintenanceToolStripMenuItem.Visible = False
                CheckRequestsToolStripMenuItem.Visible = False
                AdministrationToolStripMenuItem.Visible = False
            Case "Quality Control"
                AdministrationToolStripMenuItem.Visible = False
                CheckRequestsToolStripMenuItem.Visible = False
            Case "Engineer"
                CheckRequestsToolStripMenuItem.Visible = False
                AdministrationToolStripMenuItem.Visible = False
            Case "PPC"
                MountingToolStripMenuItem.Visible = False
                MaintenanceToolStripMenuItem.Visible = False
                AdministrationToolStripMenuItem.Visible = False
        End Select

        If loginForm.userType = "Supervisor" Or loginForm.userType = "Super Administrator" Or loginForm.userType = "Administrator" Or loginForm.userType = "Admin PP" Then
            ResetInventoryToolStripMenuItem.Visible = True
        Else
            ResetInventoryToolStripMenuItem.Visible = False
        End If
    End Sub

    Private Sub tsClose_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tsClose.Click
        Try
            Dim activeForm As String = ActiveMdiChild.Name
            Select Case activeForm
                Case "mcSeqForm"
                    mcSeqForm.Close()
                Case "uploadMcSeq"
                    uploadMcSeq.Close()
                Case "mountingForm"
                    mountingForm.Close()
                Case "machineForm"
                    machineForm.Close()
                Case "userForm"
                    userForm.Close()
                Case "requestForm"
                    requestForm.Close()
                Case "PPReceiveForm"
                    PPReceiveForm.Close()
                Case "PPReturnForm"
                    PPReturnForm.Close()
                Case "PPInventoryForm"
                    PPInventoryForm.Close()
                Case "PCBScanForm"
                    PCBScanForm.Close()
                Case "issuanceForm"
                    issuanceForm.Close()
                Case "Logs"
                    Logs.Close()
                Case "ThresholdMaintenance"
                    ThresholdMaintenance.Close()
                Case "ReworkIssuance"
                    ReworkissuanceForm.Close()
                Case "DIDhistory"
                    DIDhistory.Close()
                Case "DIDInquiry"
                    DIDInquiry.Close()
                Case "NewKitting"
                    NewKitting.Close()
            End Select
        Catch ex As Exception
        End Try
    End Sub

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

    Private Sub MountingToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MountingToolStripMenuItem.Click
        mountingForm.Show()
    End Sub

    Private Sub UsersToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles UsersToolStripMenuItem.Click
        userForm.Show()
    End Sub

    Private Sub tsFirst_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tsFirst.Click
        Try
            Dim activeForm As String = ActiveMdiChild.Name
            Select Case activeForm
                Case "machineForm"
                    machineForm.moveFirst()
                Case "userForm"
                    userForm.moveFirst()
            End Select
        Catch ex As Exception
        End Try
    End Sub

    Private Sub tsPrevious_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tsPrevious.Click
        Try
            Dim activeForm As String = ActiveMdiChild.Name
            Select Case activeForm
                Case "machineForm"
                    machineForm.movePrevious()
                Case "userForm"
                    userForm.movePrevious()
            End Select
        Catch ex As Exception
        End Try
    End Sub

    Private Sub tsNext_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tsNext.Click
        Try
            Dim activeForm As String = ActiveMdiChild.Name
            Select Case activeForm
                Case "machineForm"
                    machineForm.moveNext()
                Case "userForm"
                    userForm.moveNext()
            End Select
        Catch ex As Exception
        End Try
    End Sub

    Private Sub tsLast_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tsLast.Click
        Try
            Dim activeForm As String = ActiveMdiChild.Name
            Select Case activeForm
                Case "machineForm"
                    machineForm.moveLast()
                Case "userForm"
                    userForm.moveLast()
            End Select
        Catch ex As Exception
        End Try
    End Sub

    Private Sub MachineToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MachineToolStripMenuItem.Click
        machineForm.Show()
    End Sub

    Private Sub FileUploadToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles FileUploadToolStripMenuItem.Click
        mcSeqForm.Show()
    End Sub

    Private Sub CheckRequestsToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckRequestsToolStripMenuItem.Click
        requestForm.Show()
    End Sub

    Private Sub ReceiveToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ReceiveToolStripMenuItem.Click
        PPReceiveForm.Show()
    End Sub

    Private Sub ReturnToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ReturnToolStripMenuItem.Click
        PPReturnForm.Show()
    End Sub

    Private Sub InventoryToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles InventoryToolStripMenuItem.Click

    End Sub

    Private Sub PCBScanningToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PCBScanningToolStripMenuItem.Click
        PCBScanForm.Show()
    End Sub

    Private Sub PartNumbersToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PartNumbersToolStripMenuItem.Click
        partsForm.Show()
    End Sub

    Private Sub PlantToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
        PlantMaintenanceForm.Show()
    End Sub

    Private Sub IssuanceToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles IssuanceToolStripMenuItem.Click
        issuanceForm.Show()
    End Sub

    Private Sub ResetInventoryToolStripMenuItem_Click(sender As System.Object, e As System.EventArgs) Handles ResetInventoryToolStripMenuItem.Click
        If MessageBox.Show("Are you sure you want to reset the inventory?", "Warning", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) = Windows.Forms.DialogResult.Yes Then
            Dim p As New PartsRecords

            If p.reset Then
                MessageBox.Show("Inventory Successfully Reset!", "Message", MessageBoxButtons.OK, MessageBoxIcon.Information)
            Else
                MessageBox.Show("Something went wrong please contact your administrator!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
            End If
        End If


    End Sub

    Private Sub SerialOnlyToolStripMenuItem_Click(sender As System.Object, e As System.EventArgs) Handles SerialOnlyToolStripMenuItem.Click
        PPInventoryForm.serialOnly = True
        PPInventoryForm.Show()
    End Sub

    Private Sub PartNumberToolStripMenuItem_Click(sender As System.Object, e As System.EventArgs) Handles PartNumberToolStripMenuItem.Click
        PPInventoryForm.Show()
    End Sub

    Private Sub InventoryLogsToolStripMenuItem_Click(sender As System.Object, e As System.EventArgs) Handles InventoryLogsToolStripMenuItem.Click
        Logs.Show()
    End Sub

    Private Sub ThresholdMaintenanceToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles ThresholdMaintenanceToolStripMenuItem.Click
        ThresholdMaintenance.Show()
    End Sub

    Private Sub SerialOnlyToolStripMenuItem1_Click(sender As System.Object, e As System.EventArgs) Handles SerialOnlyToolStripMenuItem1.Click
        PPInventoryForm2.serialOnly = True
        PPInventoryForm2.Show()
    End Sub

    Private Sub PartnumberToolStripMenuItem1_Click(sender As System.Object, e As System.EventArgs) Handles PartnumberToolStripMenuItem1.Click
        PPInventoryForm2.Show()
    End Sub

    Private Sub InventoryLogsToolStripMenuItem1_Click(sender As System.Object, e As System.EventArgs) Handles InventoryLogsToolStripMenuItem1.Click
        LogsEnterprise.Show()
    End Sub

    Private Sub DIDHistoryToolStripMenuItem_Click(sender As System.Object, e As System.EventArgs) Handles DIDHistoryToolStripMenuItem.Click
        DIDhistory.Show()
    End Sub

    Private Sub AllRegisteredToolStripMenuItem_Click(sender As System.Object, e As System.EventArgs) Handles AllRegisteredToolStripMenuItem.Click
        DIDInquiry.Show()
    End Sub

    Private Sub ReworkIssuanceToolStripMenuItem_Click(sender As System.Object, e As System.EventArgs) Handles ReworkIssuanceToolStripMenuItem.Click
        ReworkissuanceForm.Show()
    End Sub

    Private Sub SPThawingToolStripMenuItem_Click(sender As System.Object, e As System.EventArgs) Handles SPThawingToolStripMenuItem.Click
        SPThawing.Show()
    End Sub

    Private Sub PartsStockInquiryToolStripMenuItem_Click(sender As System.Object, e As System.EventArgs) Handles PartsStockInquiryToolStripMenuItem.Click
        partsstock.Show()
    End Sub

    Private Sub KittingToolStripMenuItem_Click(sender As System.Object, e As System.EventArgs) Handles KittingToolStripMenuItem.Click
        NewKitting.Show()
    End Sub

    Private Sub TransactionsToolStripMenuItem_Click(sender As System.Object, e As System.EventArgs) Handles TransactionsToolStripMenuItem.Click

    End Sub
End Class
