Imports iMESExceptionManager
Imports Infragistics.Win.UltraWinGrid
Imports Infragistics.Win
Imports System.IO
Imports Newtonsoft.Json
Imports Newtonsoft.Json.Linq
Imports COM_ERP

''' <summary>
''' 修改:2012/06/15,sammi.新增多人加工處理.
''' 2016/12/26 YF, 增加新制多人加工(btnOperator), 先將舊有的多人加工隱藏(btnMultiUser)
''' </summary>
Public Class frmBR_L_CI_GEN
    Inherits System.Windows.Forms.Form

    '//Public Variables
    Public LotNo As String = defString
    Public UserId As String = defString
    Public UserName As String = defString

    Public EquipmentNo As String = defString
    Public LoadPort As Integer = defInteger
    Public PrivFunNo As String = defString

    '//Web Service相關變數
    Dim tmpStringReader As System.IO.StringReader
    Dim InXml, OutXml, strIdentity, strParameter, XmlData, XmlSchema As String

    '//資料表相關變數
    Dim dsWIP, dsTemp, dsINV, dsEQP As New DataSet
    Dim dtKeyIn, dtTmpLoginState, dtTmpMTLLotNo As DataTable
    Dim drAdd As DataRow
    Dim tblLotState, tblTAttrib, tblTMaterial, tblAreaEquipment, tblLotLoginState, tblMaterialLotNo,
        tblTmpMTLLotNo, tblMOMaterialState, tblWIPINVRaw, tblSubstituteMaterial, tblSWRJoinLog,
        tblMaterialBasis, tblTLotState, tblMaterialProperty, tblOPBasis, tblEQPDispatchState, tblWIPINVSEMI, tblCustomTestData As String
    '2016-12-19 系統參數資料表
    Dim dsDefine As New DataSet
    Dim tblSYSParam As String = ""
    Dim Execute_eSOP As Integer = 0 '2016-12-14, 是否啟用eSOP(0:false,1:true)

    '//其他共用變數
    Dim RevLotSerial As String = defString
    Dim LotSerial As String = defString
    Dim LogGroupSerial As String = defString
    Dim RevLotStamp As Long = defInteger
    Dim PhaseNo As Integer
    Dim datEventTime As DateTime = Now
    Dim ugrRow As Infragistics.Win.UltraWinGrid.UltraGridRow
    Dim blnGetAccessory As Boolean = True
    Dim drSelE As DataRow()
    Dim blnChamber As Boolean = False
    '2019/02/12 Eric 特殊生產需求是否有資料
    Dim blnShowSWR As Boolean = False

    '20091006 Seam 新增作業工序
    Dim tblSubOP As String

    '2010/03/08,yumei,iugKeyIn區塊新增清單選擇
    Dim strDefaultValue As String
    Dim editor As Infragistics.Win.DateTimeEditor

    ' 2016/08/30 YF, ObjectFile物件
    Dim ObjectFileHandler As COM_Utility.ObjectFileHandler
    '2016-12-20 XIANG
    Dim tblPRDeSOPBasis As String = ""
    Friend WithEvents chkUpdCheckInTime As CheckBox
    Friend WithEvents btnSWR As Infragistics.Win.Misc.UltraButton
    '傳給eSOP,紀錄資料數(ROW欄位)
    Dim intRow As Integer = 1
    Dim blnGumMaterialType As Boolean = False
    Dim aryGumMaterialType As Array
    Dim dtAllMTLLot As DataTable            '所有可用料批資料
    Dim tblTMaterialLot As String
    Friend WithEvents lblMaterialNo As Label
    Friend WithEvents txtMaterialNo As UltraWinEditors.UltraTextEditor
    Dim blnSelect As Boolean = False
    Dim blnByEQP As Boolean = False
    Dim blnCIMTLDBCheck As Boolean = False
    Dim blnLock As Boolean = False

    Dim ACCMin As Decimal = defInteger
    Dim ACCMax As Decimal = defInteger
    Dim ReFrozenFlag As Integer = defInteger
    Dim ReACCMin As Decimal = defInteger
    Dim ReACCMax As Decimal = defInteger
    Dim strTableName, strRaw As String

    Dim vlMaterialLevel As New ValueList

    Dim vlTestData21703 As New ValueList

    Dim ckhEQPDispatchRule As String

    ''新设备上料  14278
    Dim dsOE As New DataSet   '資料集：儲存取回之資料?
    Friend WithEvents iugCustomTab As UltraWinTabControl.UltraTabPageControl
    Friend WithEvents iugTestData21703 As iMESUltraGrid.iMESUltraGridControl
    Friend WithEvents UltraTabPageControl3 As UltraWinTabControl.UltraTabPageControl
    Friend WithEvents Label1 As Label
    Friend WithEvents UltraTextEditor1 As UltraWinEditors.UltraTextEditor
    Friend WithEvents Label2 As Label
    Friend WithEvents UltraTextEditor2 As UltraWinEditors.UltraTextEditor
    Friend WithEvents IMESUltraGridControl1 As iMESUltraGrid.iMESUltraGridControl
    Friend WithEvents UltraTabSharedControlsPage2 As UltraWinTabControl.UltraTabSharedControlsPage
    Friend WithEvents UltraTabControl2 As UltraWinTabControl.UltraTabControl
    Dim strMOList As String '儲存取回資料表的名稱?
#Region " Windows Form 設計工具產生的程式碼 "

    Public Sub New()
        MyBase.New()

        '此呼叫為 Windows Form 設計工具的必要項。

        InitializeComponent()

        '在 InitializeComponent() 呼叫之後加入所有的初始設定
        ' 2016/08/30 YF, 開另一條執行緒建立會使用到的物件
        Threading.ThreadPool.QueueUserWorkItem(New Threading.WaitCallback(
                Sub(pState As Object)
                    ' 呼叫COM_Utility.ObjectFileHandler建構子, 傳入要載入的ObjectID
                    Me.ObjectFileHandler = New COM_Utility.ObjectFileHandler("WP_OperatorLogIn_Lot", "WP_EQPConsumeReset", "WP_EQPCheckQCList", "WP_SWRBasisRead", "WP_MaterialQtyInput_Main")
                End Sub))

    End Sub

    'Form 覆寫 Dispose 以清除元件清單。

    Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
        If disposing Then
            If Not (components Is Nothing) Then
                components.Dispose()
            End If
        End If
        MyBase.Dispose(disposing)
    End Sub

    '為 Windows Form 設計工具的必要項
    Private components As System.ComponentModel.IContainer

    '注意: 以下為 Windows Form 設計工具所需的程序

    '您可以使用 Windows Form 設計工具進行修改。

    '請勿使用程式碼編輯器來修改這些程序。
    Friend WithEvents UltraTabPageControl1 As Infragistics.Win.UltraWinTabControl.UltraTabPageControl
    Friend WithEvents UltraTabPageControl2 As Infragistics.Win.UltraWinTabControl.UltraTabPageControl
    Friend WithEvents ToolTip1 As System.Windows.Forms.ToolTip
    Friend WithEvents UltraTabControl1 As Infragistics.Win.UltraWinTabControl.UltraTabControl
    Friend WithEvents UltraTabSharedControlsPage1 As Infragistics.Win.UltraWinTabControl.UltraTabSharedControlsPage
    Friend WithEvents utpMaterial As Infragistics.Win.UltraWinTabControl.UltraTabPageControl
    Friend WithEvents utpSubOP As Infragistics.Win.UltraWinTabControl.UltraTabPageControl
    Friend WithEvents iugSubOP As iMESUltraGrid.iMESUltraGridControl
    Friend WithEvents utpEquipment As Infragistics.Win.UltraWinTabControl.UltraTabPageControl
    Friend WithEvents IMESUltraGrid3 As iMESUltraGrid.iMESUltraGridControl
    Friend WithEvents SBar1 As System.Windows.Forms.StatusBar
    Friend WithEvents SBarPanel1 As System.Windows.Forms.StatusBarPanel
    Friend WithEvents SBarPanel4 As System.Windows.Forms.StatusBarPanel
    Friend WithEvents SBarPanel2 As System.Windows.Forms.StatusBarPanel
    Friend WithEvents SBarPanel3 As System.Windows.Forms.StatusBarPanel
    Friend WithEvents lblOPNo As System.Windows.Forms.Label
    Friend WithEvents lblLotNo As System.Windows.Forms.Label
    Friend WithEvents lblSysQty As System.Windows.Forms.Label
    Friend WithEvents lblCurQty As System.Windows.Forms.Label
    Friend WithEvents lblEmployeeNo As System.Windows.Forms.Label
    Friend WithEvents lblShiftNo As System.Windows.Forms.Label
    Friend WithEvents lblCustomerLotNo As System.Windows.Forms.Label
    Friend WithEvents lblPriority As System.Windows.Forms.Label
    Friend WithEvents txtOPNo As Infragistics.Win.UltraWinEditors.UltraTextEditor
    Friend WithEvents txtLotNo As Infragistics.Win.UltraWinEditors.UltraTextEditor
    Friend WithEvents txtCurQty As Infragistics.Win.UltraWinEditors.UltraTextEditor
    Friend WithEvents txtCurUnitNo As Infragistics.Win.UltraWinEditors.UltraTextEditor
    Friend WithEvents txtSysQty As Infragistics.Win.UltraWinEditors.UltraTextEditor
    Friend WithEvents txtSysUnitNo As Infragistics.Win.UltraWinEditors.UltraTextEditor
    Friend WithEvents txtPriority As Infragistics.Win.UltraWinEditors.UltraTextEditor
    Friend WithEvents txtAreaNo As Infragistics.Win.UltraWinEditors.UltraTextEditor
    Friend WithEvents txtEmployeeNo As Infragistics.Win.UltraWinEditors.UltraTextEditor
    Friend WithEvents txtShiftNo As Infragistics.Win.UltraWinEditors.UltraTextEditor
    Friend WithEvents txtCustomerLotNo As Infragistics.Win.UltraWinEditors.UltraTextEditor
    Friend WithEvents iugAttrib As iMESUltraGrid.iMESUltraGridControl
    Friend WithEvents iugMaterial As iMESUltraGrid.iMESUltraGridControl
    Friend WithEvents iugEquipment As iMESUltraGrid.iMESUltraGridControl
    Friend WithEvents btnClose As Infragistics.Win.Misc.UltraButton
    Friend WithEvents btnConfirm As Infragistics.Win.Misc.UltraButton
    Friend WithEvents lblEquipmentNo As System.Windows.Forms.Label
    Friend WithEvents txtEquipmentNo As Infragistics.Win.UltraWinEditors.UltraTextEditor
    Friend WithEvents iugKeyIn As iMESUltraGrid.iMESUltraGridControl
    Friend WithEvents lblProductNo As System.Windows.Forms.Label
    Friend WithEvents txtProductNo As Infragistics.Win.UltraWinEditors.UltraTextEditor
    Friend WithEvents lblAreaNo As System.Windows.Forms.Label
    Friend WithEvents txtOPDescription As Infragistics.Win.UltraWinEditors.UltraTextEditor
    Friend WithEvents lblOPDescription As System.Windows.Forms.Label
    Friend WithEvents lblLotRecord As System.Windows.Forms.Label
    Friend WithEvents txtLotRecord As System.Windows.Forms.RichTextBox
    Friend WithEvents txtMONo As Infragistics.Win.UltraWinEditors.UltraTextEditor
    Friend WithEvents lblMONo As System.Windows.Forms.Label
    Friend WithEvents gbxLotInfo As System.Windows.Forms.GroupBox
    Friend WithEvents lblupdcheckintime As System.Windows.Forms.Label
    Friend WithEvents dtpcheckintime As System.Windows.Forms.DateTimePicker
    Friend WithEvents btnQCList As Infragistics.Win.Misc.UltraButton
    Friend WithEvents btnEQPConsumeReset As Infragistics.Win.Misc.UltraButton
    Friend WithEvents txtOpName As Infragistics.Win.UltraWinEditors.UltraTextEditor
    Friend WithEvents btnMultiUser As Infragistics.Win.Misc.UltraButton
    Friend WithEvents lblMaterialLotNo As System.Windows.Forms.Label
    Friend WithEvents btnOperator As Misc.UltraButton
    Friend WithEvents txtMaterialLotNo As Infragistics.Win.UltraWinEditors.UltraTextEditor

    Friend WithEvents uegLotInfo As Misc.UltraExpandableGroupBox
    Friend WithEvents uplEquipment As Misc.UltraPanel
    Friend WithEvents uplAttrib As Misc.UltraPanel
    Friend WithEvents UltraExpandableGroupBoxPanel1 As Misc.UltraExpandableGroupBoxPanel
    Friend WithEvents UltraPanel1 As Misc.UltraPanel
    Friend WithEvents uplAttrib_Equipment As Misc.UltraPanel
    Friend WithEvents UltraSplitter1 As Misc.UltraSplitter
    Friend WithEvents uplMaterial_KeyIn As Misc.UltraPanel
    Friend WithEvents UltraSplitter2 As Misc.UltraSplitter
    Friend WithEvents uplMaterial As Misc.UltraPanel
    Friend WithEvents uplKeyIn As Misc.UltraPanel
    Friend WithEvents uplAll As Misc.UltraPanel
    Friend WithEvents uegMaterial_KeyIn2 As Misc.UltraExpandableGroupBox
    Friend WithEvents UltraExpandableGroupBoxPanel4 As Misc.UltraExpandableGroupBoxPanel
    Friend WithEvents UltraPanel4 As Misc.UltraPanel
    Friend WithEvents uegAttrib_Equipment As Misc.UltraExpandableGroupBox
    Friend WithEvents UltraExpandableGroupBoxPanel2 As Misc.UltraExpandableGroupBoxPanel
    Friend WithEvents UltraPanel2 As Misc.UltraPanel

    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
        Me.components = New System.ComponentModel.Container()
        Dim UltraTab2 As Infragistics.Win.UltraWinTabControl.UltraTab = New Infragistics.Win.UltraWinTabControl.UltraTab()
        Dim UltraTab3 As Infragistics.Win.UltraWinTabControl.UltraTab = New Infragistics.Win.UltraWinTabControl.UltraTab()
        Dim UltraTab5 As Infragistics.Win.UltraWinTabControl.UltraTab = New Infragistics.Win.UltraWinTabControl.UltraTab()
        Me.utpMaterial = New Infragistics.Win.UltraWinTabControl.UltraTabPageControl()
        Me.lblMaterialNo = New System.Windows.Forms.Label()
        Me.txtMaterialNo = New Infragistics.Win.UltraWinEditors.UltraTextEditor()
        Me.lblMaterialLotNo = New System.Windows.Forms.Label()
        Me.txtMaterialLotNo = New Infragistics.Win.UltraWinEditors.UltraTextEditor()
        Me.iugMaterial = New iMESUltraGrid.iMESUltraGridControl()
        Me.utpSubOP = New Infragistics.Win.UltraWinTabControl.UltraTabPageControl()
        Me.iugSubOP = New iMESUltraGrid.iMESUltraGridControl()
        Me.iugCustomTab = New Infragistics.Win.UltraWinTabControl.UltraTabPageControl()
        Me.iugTestData21703 = New iMESUltraGrid.iMESUltraGridControl()
        Me.uegLotInfo = New Infragistics.Win.Misc.UltraExpandableGroupBox()
        Me.UltraExpandableGroupBoxPanel1 = New Infragistics.Win.Misc.UltraExpandableGroupBoxPanel()
        Me.UltraPanel1 = New Infragistics.Win.Misc.UltraPanel()
        Me.gbxLotInfo = New System.Windows.Forms.GroupBox()
        Me.txtOpName = New Infragistics.Win.UltraWinEditors.UltraTextEditor()
        Me.txtOPNo = New Infragistics.Win.UltraWinEditors.UltraTextEditor()
        Me.txtProductNo = New Infragistics.Win.UltraWinEditors.UltraTextEditor()
        Me.txtCustomerLotNo = New Infragistics.Win.UltraWinEditors.UltraTextEditor()
        Me.txtMONo = New Infragistics.Win.UltraWinEditors.UltraTextEditor()
        Me.txtShiftNo = New Infragistics.Win.UltraWinEditors.UltraTextEditor()
        Me.txtEmployeeNo = New Infragistics.Win.UltraWinEditors.UltraTextEditor()
        Me.txtAreaNo = New Infragistics.Win.UltraWinEditors.UltraTextEditor()
        Me.txtPriority = New Infragistics.Win.UltraWinEditors.UltraTextEditor()
        Me.txtSysUnitNo = New Infragistics.Win.UltraWinEditors.UltraTextEditor()
        Me.txtSysQty = New Infragistics.Win.UltraWinEditors.UltraTextEditor()
        Me.txtCurUnitNo = New Infragistics.Win.UltraWinEditors.UltraTextEditor()
        Me.txtCurQty = New Infragistics.Win.UltraWinEditors.UltraTextEditor()
        Me.txtOPDescription = New Infragistics.Win.UltraWinEditors.UltraTextEditor()
        Me.txtLotNo = New Infragistics.Win.UltraWinEditors.UltraTextEditor()
        Me.lblPriority = New System.Windows.Forms.Label()
        Me.lblMONo = New System.Windows.Forms.Label()
        Me.lblShiftNo = New System.Windows.Forms.Label()
        Me.lblOPNo = New System.Windows.Forms.Label()
        Me.lblAreaNo = New System.Windows.Forms.Label()
        Me.lblSysQty = New System.Windows.Forms.Label()
        Me.lblCurQty = New System.Windows.Forms.Label()
        Me.lblProductNo = New System.Windows.Forms.Label()
        Me.lblOPDescription = New System.Windows.Forms.Label()
        Me.lblCustomerLotNo = New System.Windows.Forms.Label()
        Me.lblEmployeeNo = New System.Windows.Forms.Label()
        Me.lblLotNo = New System.Windows.Forms.Label()
        Me.UltraTabPageControl2 = New Infragistics.Win.UltraWinTabControl.UltraTabPageControl()
        Me.UltraTabPageControl1 = New Infragistics.Win.UltraWinTabControl.UltraTabPageControl()
        Me.SBar1 = New System.Windows.Forms.StatusBar()
        Me.SBarPanel1 = New System.Windows.Forms.StatusBarPanel()
        Me.SBarPanel2 = New System.Windows.Forms.StatusBarPanel()
        Me.SBarPanel3 = New System.Windows.Forms.StatusBarPanel()
        Me.SBarPanel4 = New System.Windows.Forms.StatusBarPanel()
        Me.iugAttrib = New iMESUltraGrid.iMESUltraGridControl()
        Me.iugEquipment = New iMESUltraGrid.iMESUltraGridControl()
        Me.btnClose = New Infragistics.Win.Misc.UltraButton()
        Me.btnConfirm = New Infragistics.Win.Misc.UltraButton()
        Me.lblEquipmentNo = New System.Windows.Forms.Label()
        Me.txtEquipmentNo = New Infragistics.Win.UltraWinEditors.UltraTextEditor()
        Me.lblLotRecord = New System.Windows.Forms.Label()
        Me.txtLotRecord = New System.Windows.Forms.RichTextBox()
        Me.lblupdcheckintime = New System.Windows.Forms.Label()
        Me.dtpcheckintime = New System.Windows.Forms.DateTimePicker()
        Me.btnEQPConsumeReset = New Infragistics.Win.Misc.UltraButton()
        Me.btnQCList = New Infragistics.Win.Misc.UltraButton()
        Me.ToolTip1 = New System.Windows.Forms.ToolTip(Me.components)
        Me.utpEquipment = New Infragistics.Win.UltraWinTabControl.UltraTabPageControl()
        Me.IMESUltraGrid3 = New iMESUltraGrid.iMESUltraGridControl()
        Me.btnMultiUser = New Infragistics.Win.Misc.UltraButton()
        Me.btnOperator = New Infragistics.Win.Misc.UltraButton()
        Me.chkUpdCheckInTime = New System.Windows.Forms.CheckBox()
        Me.btnSWR = New Infragistics.Win.Misc.UltraButton()
        Me.uplAttrib = New Infragistics.Win.Misc.UltraPanel()
        Me.uplEquipment = New Infragistics.Win.Misc.UltraPanel()
        Me.uplAttrib_Equipment = New Infragistics.Win.Misc.UltraPanel()
        Me.UltraSplitter1 = New Infragistics.Win.Misc.UltraSplitter()
        Me.uplMaterial_KeyIn = New Infragistics.Win.Misc.UltraPanel()
        Me.uplKeyIn = New Infragistics.Win.Misc.UltraPanel()
        Me.iugKeyIn = New iMESUltraGrid.iMESUltraGridControl()
        Me.UltraSplitter2 = New Infragistics.Win.Misc.UltraSplitter()
        Me.uplMaterial = New Infragistics.Win.Misc.UltraPanel()
        Me.UltraTabControl1 = New Infragistics.Win.UltraWinTabControl.UltraTabControl()
        Me.UltraTabSharedControlsPage1 = New Infragistics.Win.UltraWinTabControl.UltraTabSharedControlsPage()
        Me.uplAll = New Infragistics.Win.Misc.UltraPanel()
        Me.uegMaterial_KeyIn2 = New Infragistics.Win.Misc.UltraExpandableGroupBox()
        Me.UltraExpandableGroupBoxPanel4 = New Infragistics.Win.Misc.UltraExpandableGroupBoxPanel()
        Me.UltraPanel4 = New Infragistics.Win.Misc.UltraPanel()
        Me.uegAttrib_Equipment = New Infragistics.Win.Misc.UltraExpandableGroupBox()
        Me.UltraExpandableGroupBoxPanel2 = New Infragistics.Win.Misc.UltraExpandableGroupBoxPanel()
        Me.UltraPanel2 = New Infragistics.Win.Misc.UltraPanel()
        Me.UltraTabPageControl3 = New Infragistics.Win.UltraWinTabControl.UltraTabPageControl()
        Me.Label1 = New System.Windows.Forms.Label()
        Me.UltraTextEditor1 = New Infragistics.Win.UltraWinEditors.UltraTextEditor()
        Me.Label2 = New System.Windows.Forms.Label()
        Me.UltraTextEditor2 = New Infragistics.Win.UltraWinEditors.UltraTextEditor()
        Me.IMESUltraGridControl1 = New iMESUltraGrid.iMESUltraGridControl()
        Me.UltraTabSharedControlsPage2 = New Infragistics.Win.UltraWinTabControl.UltraTabSharedControlsPage()
        Me.UltraTabControl2 = New Infragistics.Win.UltraWinTabControl.UltraTabControl()
        Me.utpMaterial.SuspendLayout()
        CType(Me.txtMaterialNo, System.ComponentModel.ISupportInitialize).BeginInit()
        CType(Me.txtMaterialLotNo, System.ComponentModel.ISupportInitialize).BeginInit()
        Me.utpSubOP.SuspendLayout()
        Me.iugCustomTab.SuspendLayout()
        CType(Me.uegLotInfo, System.ComponentModel.ISupportInitialize).BeginInit()
        Me.uegLotInfo.SuspendLayout()
        Me.UltraExpandableGroupBoxPanel1.SuspendLayout()
        Me.UltraPanel1.ClientArea.SuspendLayout()
        Me.UltraPanel1.SuspendLayout()
        Me.gbxLotInfo.SuspendLayout()
        CType(Me.txtOpName, System.ComponentModel.ISupportInitialize).BeginInit()
        CType(Me.txtOPNo, System.ComponentModel.ISupportInitialize).BeginInit()
        CType(Me.txtProductNo, System.ComponentModel.ISupportInitialize).BeginInit()
        CType(Me.txtCustomerLotNo, System.ComponentModel.ISupportInitialize).BeginInit()
        CType(Me.txtMONo, System.ComponentModel.ISupportInitialize).BeginInit()
        CType(Me.txtShiftNo, System.ComponentModel.ISupportInitialize).BeginInit()
        CType(Me.txtEmployeeNo, System.ComponentModel.ISupportInitialize).BeginInit()
        CType(Me.txtAreaNo, System.ComponentModel.ISupportInitialize).BeginInit()
        CType(Me.txtPriority, System.ComponentModel.ISupportInitialize).BeginInit()
        CType(Me.txtSysUnitNo, System.ComponentModel.ISupportInitialize).BeginInit()
        CType(Me.txtSysQty, System.ComponentModel.ISupportInitialize).BeginInit()
        CType(Me.txtCurUnitNo, System.ComponentModel.ISupportInitialize).BeginInit()
        CType(Me.txtCurQty, System.ComponentModel.ISupportInitialize).BeginInit()
        CType(Me.txtOPDescription, System.ComponentModel.ISupportInitialize).BeginInit()
        CType(Me.txtLotNo, System.ComponentModel.ISupportInitialize).BeginInit()
        CType(Me.SBarPanel1, System.ComponentModel.ISupportInitialize).BeginInit()
        CType(Me.SBarPanel2, System.ComponentModel.ISupportInitialize).BeginInit()
        CType(Me.SBarPanel3, System.ComponentModel.ISupportInitialize).BeginInit()
        CType(Me.SBarPanel4, System.ComponentModel.ISupportInitialize).BeginInit()
        CType(Me.txtEquipmentNo, System.ComponentModel.ISupportInitialize).BeginInit()
        Me.utpEquipment.SuspendLayout()
        Me.uplAttrib.ClientArea.SuspendLayout()
        Me.uplAttrib.SuspendLayout()
        Me.uplEquipment.ClientArea.SuspendLayout()
        Me.uplEquipment.SuspendLayout()
        Me.uplAttrib_Equipment.ClientArea.SuspendLayout()
        Me.uplAttrib_Equipment.SuspendLayout()
        Me.uplMaterial_KeyIn.ClientArea.SuspendLayout()
        Me.uplMaterial_KeyIn.SuspendLayout()
        Me.uplKeyIn.ClientArea.SuspendLayout()
        Me.uplKeyIn.SuspendLayout()
        Me.uplMaterial.ClientArea.SuspendLayout()
        Me.uplMaterial.SuspendLayout()
        CType(Me.UltraTabControl1, System.ComponentModel.ISupportInitialize).BeginInit()
        Me.UltraTabControl1.SuspendLayout()
        Me.uplAll.ClientArea.SuspendLayout()
        Me.uplAll.SuspendLayout()
        CType(Me.uegMaterial_KeyIn2, System.ComponentModel.ISupportInitialize).BeginInit()
        Me.uegMaterial_KeyIn2.SuspendLayout()
        Me.UltraExpandableGroupBoxPanel4.SuspendLayout()
        Me.UltraPanel4.ClientArea.SuspendLayout()
        Me.UltraPanel4.SuspendLayout()
        CType(Me.uegAttrib_Equipment, System.ComponentModel.ISupportInitialize).BeginInit()
        Me.uegAttrib_Equipment.SuspendLayout()
        Me.UltraExpandableGroupBoxPanel2.SuspendLayout()
        Me.UltraPanel2.ClientArea.SuspendLayout()
        Me.UltraPanel2.SuspendLayout()
        Me.UltraTabPageControl3.SuspendLayout()
        CType(Me.UltraTextEditor1, System.ComponentModel.ISupportInitialize).BeginInit()
        CType(Me.UltraTextEditor2, System.ComponentModel.ISupportInitialize).BeginInit()
        CType(Me.UltraTabControl2, System.ComponentModel.ISupportInitialize).BeginInit()
        Me.UltraTabControl2.SuspendLayout()
        Me.SuspendLayout()
        '
        'utpMaterial
        '
        Me.utpMaterial.Controls.Add(Me.lblMaterialNo)
        Me.utpMaterial.Controls.Add(Me.txtMaterialNo)
        Me.utpMaterial.Controls.Add(Me.lblMaterialLotNo)
        Me.utpMaterial.Controls.Add(Me.txtMaterialLotNo)
        Me.utpMaterial.Controls.Add(Me.iugMaterial)
        Me.utpMaterial.Location = New System.Drawing.Point(-10000, -10000)
        Me.utpMaterial.Name = "utpMaterial"
        Me.utpMaterial.Size = New System.Drawing.Size(511, 187)
        '
        'lblMaterialNo
        '
        Me.lblMaterialNo.BackColor = System.Drawing.Color.Transparent
        Me.lblMaterialNo.Font = New System.Drawing.Font("Times New Roman", 9.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.lblMaterialNo.Location = New System.Drawing.Point(7, 11)
        Me.lblMaterialNo.Name = "lblMaterialNo"
        Me.lblMaterialNo.Size = New System.Drawing.Size(90, 16)
        Me.lblMaterialNo.TabIndex = 159
        Me.lblMaterialNo.Text = "Material No"
        '
        'txtMaterialNo
        '
        Me.txtMaterialNo.Location = New System.Drawing.Point(103, 7)
        Me.txtMaterialNo.Name = "txtMaterialNo"
        Me.txtMaterialNo.Size = New System.Drawing.Size(132, 22)
        Me.txtMaterialNo.TabIndex = 158
        '
        'lblMaterialLotNo
        '
        Me.lblMaterialLotNo.BackColor = System.Drawing.Color.Transparent
        Me.lblMaterialLotNo.Font = New System.Drawing.Font("Times New Roman", 9.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.lblMaterialLotNo.Location = New System.Drawing.Point(244, 11)
        Me.lblMaterialLotNo.Name = "lblMaterialLotNo"
        Me.lblMaterialLotNo.Size = New System.Drawing.Size(90, 16)
        Me.lblMaterialLotNo.TabIndex = 157
        Me.lblMaterialLotNo.Text = "Material Lot No"
        '
        'txtMaterialLotNo
        '
        Me.txtMaterialLotNo.Location = New System.Drawing.Point(340, 7)
        Me.txtMaterialLotNo.Name = "txtMaterialLotNo"
        Me.txtMaterialLotNo.Size = New System.Drawing.Size(132, 22)
        Me.txtMaterialLotNo.TabIndex = 156
        '
        'iugMaterial
        '
        Me.iugMaterial.Anchor = CType((((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Bottom) _
            Or System.Windows.Forms.AnchorStyles.Left) _
            Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
        Me.iugMaterial.EnterDirection = iMESUltraGrid.iMESUltraGridControl.EnterDirectionEnum.Down
        Me.iugMaterial.GroupBoxPromptText = "Drag a column header here to group by that column."
        Me.iugMaterial.GroupBoxTextForeColor = System.Drawing.Color.Red
        Me.iugMaterial.Identity = "IMes"
        Me.iugMaterial.IdentityForm = ""
        Me.iugMaterial.LayOutFilePath = ""
        Me.iugMaterial.Location = New System.Drawing.Point(2, 35)
        Me.iugMaterial.Name = "iugMaterial"
        Me.iugMaterial.PrintFitWidthToPages = 0
        Me.iugMaterial.PrintLandscape = True
        Me.iugMaterial.PrintPageFooter = ""
        Me.iugMaterial.PrintPageFooterHAlign = Infragistics.Win.HAlign.[Default]
        Me.iugMaterial.PrintPageFooterHeight = 20
        Me.iugMaterial.PrintPageHeader = ""
        Me.iugMaterial.PrintPageHeaderHAlign = Infragistics.Win.HAlign.[Default]
        Me.iugMaterial.PrintPageHeaderHeight = 20
        Me.iugMaterial.PrintZoom = 1.0R
        Me.iugMaterial.Size = New System.Drawing.Size(505, 172)
        Me.iugMaterial.TabIndex = 108
        Me.iugMaterial.UserNo = "IMes"
        '
        'utpSubOP
        '
        Me.utpSubOP.Controls.Add(Me.iugSubOP)
        Me.utpSubOP.Location = New System.Drawing.Point(-10000, -10000)
        Me.utpSubOP.Name = "utpSubOP"
        Me.utpSubOP.Size = New System.Drawing.Size(511, 187)
        '
        'iugSubOP
        '
        Me.iugSubOP.Anchor = CType((((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Bottom) _
            Or System.Windows.Forms.AnchorStyles.Left) _
            Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
        Me.iugSubOP.EnterDirection = iMESUltraGrid.iMESUltraGridControl.EnterDirectionEnum.Down
        Me.iugSubOP.GroupBoxPromptText = "Drag a column header here to group by that column."
        Me.iugSubOP.GroupBoxTextForeColor = System.Drawing.Color.Red
        Me.iugSubOP.Identity = "IMes"
        Me.iugSubOP.IdentityForm = ""
        Me.iugSubOP.LayOutFilePath = ""
        Me.iugSubOP.Location = New System.Drawing.Point(7, 3)
        Me.iugSubOP.Name = "iugSubOP"
        Me.iugSubOP.PrintFitWidthToPages = 0
        Me.iugSubOP.PrintLandscape = True
        Me.iugSubOP.PrintPageFooter = ""
        Me.iugSubOP.PrintPageFooterHAlign = Infragistics.Win.HAlign.[Default]
        Me.iugSubOP.PrintPageFooterHeight = 20
        Me.iugSubOP.PrintPageHeader = ""
        Me.iugSubOP.PrintPageHeaderHAlign = Infragistics.Win.HAlign.[Default]
        Me.iugSubOP.PrintPageHeaderHeight = 20
        Me.iugSubOP.PrintZoom = 1.0R
        Me.iugSubOP.Size = New System.Drawing.Size(465, 176)
        Me.iugSubOP.TabIndex = 1
        Me.iugSubOP.UserNo = "IMes"
        '
        'iugCustomTab
        '
        Me.iugCustomTab.Controls.Add(Me.iugTestData21703)
        Me.iugCustomTab.Location = New System.Drawing.Point(1, 23)
        Me.iugCustomTab.Name = "iugCustomTab"
        Me.iugCustomTab.Size = New System.Drawing.Size(511, 187)
        '
        'iugTestData21703
        '
        Me.iugTestData21703.Anchor = CType((((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Bottom) _
            Or System.Windows.Forms.AnchorStyles.Left) _
            Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
        Me.iugTestData21703.EnterDirection = iMESUltraGrid.iMESUltraGridControl.EnterDirectionEnum.Down
        Me.iugTestData21703.GroupBoxPromptText = "Drag a column header here to group by that column."
        Me.iugTestData21703.GroupBoxTextForeColor = System.Drawing.Color.Red
        Me.iugTestData21703.Identity = "IMes"
        Me.iugTestData21703.IdentityForm = ""
        Me.iugTestData21703.LayOutFilePath = ""
        Me.iugTestData21703.Location = New System.Drawing.Point(0, 3)
        Me.iugTestData21703.Name = "iugTestData21703"
        Me.iugTestData21703.PrintFitWidthToPages = 0
        Me.iugTestData21703.PrintLandscape = True
        Me.iugTestData21703.PrintPageFooter = ""
        Me.iugTestData21703.PrintPageFooterHAlign = Infragistics.Win.HAlign.[Default]
        Me.iugTestData21703.PrintPageFooterHeight = 20
        Me.iugTestData21703.PrintPageHeader = ""
        Me.iugTestData21703.PrintPageHeaderHAlign = Infragistics.Win.HAlign.[Default]
        Me.iugTestData21703.PrintPageHeaderHeight = 20
        Me.iugTestData21703.PrintZoom = 1.0R
        Me.iugTestData21703.Size = New System.Drawing.Size(505, 181)
        Me.iugTestData21703.TabIndex = 2
        Me.iugTestData21703.UserNo = "IMes"
        '
        'uegLotInfo
        '
        Me.uegLotInfo.Controls.Add(Me.UltraExpandableGroupBoxPanel1)
        Me.uegLotInfo.Dock = System.Windows.Forms.DockStyle.Top
        Me.uegLotInfo.ExpandedSize = New System.Drawing.Size(1013, 153)
        Me.uegLotInfo.Location = New System.Drawing.Point(0, 0)
        Me.uegLotInfo.Name = "uegLotInfo"
        Me.uegLotInfo.Size = New System.Drawing.Size(1013, 153)
        Me.uegLotInfo.TabIndex = 161
        Me.uegLotInfo.Text = "Lot Information"
        Me.uegLotInfo.ViewStyle = Infragistics.Win.Misc.GroupBoxViewStyle.Office2003
        '
        'UltraExpandableGroupBoxPanel1
        '
        Me.UltraExpandableGroupBoxPanel1.Controls.Add(Me.UltraPanel1)
        Me.UltraExpandableGroupBoxPanel1.Dock = System.Windows.Forms.DockStyle.Fill
        Me.UltraExpandableGroupBoxPanel1.Location = New System.Drawing.Point(2, 22)
        Me.UltraExpandableGroupBoxPanel1.Name = "UltraExpandableGroupBoxPanel1"
        Me.UltraExpandableGroupBoxPanel1.Size = New System.Drawing.Size(1009, 129)
        Me.UltraExpandableGroupBoxPanel1.TabIndex = 0
        '
        'UltraPanel1
        '
        '
        'UltraPanel1.ClientArea
        '
        Me.UltraPanel1.ClientArea.Controls.Add(Me.gbxLotInfo)
        Me.UltraPanel1.Dock = System.Windows.Forms.DockStyle.Fill
        Me.UltraPanel1.Location = New System.Drawing.Point(0, 0)
        Me.UltraPanel1.Name = "UltraPanel1"
        Me.UltraPanel1.Size = New System.Drawing.Size(1009, 129)
        Me.UltraPanel1.TabIndex = 0
        '
        'gbxLotInfo
        '
        Me.gbxLotInfo.Anchor = CType(((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Left) _
            Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
        Me.gbxLotInfo.Controls.Add(Me.txtOpName)
        Me.gbxLotInfo.Controls.Add(Me.txtOPNo)
        Me.gbxLotInfo.Controls.Add(Me.txtProductNo)
        Me.gbxLotInfo.Controls.Add(Me.txtCustomerLotNo)
        Me.gbxLotInfo.Controls.Add(Me.txtMONo)
        Me.gbxLotInfo.Controls.Add(Me.txtShiftNo)
        Me.gbxLotInfo.Controls.Add(Me.txtEmployeeNo)
        Me.gbxLotInfo.Controls.Add(Me.txtAreaNo)
        Me.gbxLotInfo.Controls.Add(Me.txtPriority)
        Me.gbxLotInfo.Controls.Add(Me.txtSysUnitNo)
        Me.gbxLotInfo.Controls.Add(Me.txtSysQty)
        Me.gbxLotInfo.Controls.Add(Me.txtCurUnitNo)
        Me.gbxLotInfo.Controls.Add(Me.txtCurQty)
        Me.gbxLotInfo.Controls.Add(Me.txtOPDescription)
        Me.gbxLotInfo.Controls.Add(Me.txtLotNo)
        Me.gbxLotInfo.Controls.Add(Me.lblPriority)
        Me.gbxLotInfo.Controls.Add(Me.lblMONo)
        Me.gbxLotInfo.Controls.Add(Me.lblShiftNo)
        Me.gbxLotInfo.Controls.Add(Me.lblOPNo)
        Me.gbxLotInfo.Controls.Add(Me.lblAreaNo)
        Me.gbxLotInfo.Controls.Add(Me.lblSysQty)
        Me.gbxLotInfo.Controls.Add(Me.lblCurQty)
        Me.gbxLotInfo.Controls.Add(Me.lblProductNo)
        Me.gbxLotInfo.Controls.Add(Me.lblOPDescription)
        Me.gbxLotInfo.Controls.Add(Me.lblCustomerLotNo)
        Me.gbxLotInfo.Controls.Add(Me.lblEmployeeNo)
        Me.gbxLotInfo.Controls.Add(Me.lblLotNo)
        Me.gbxLotInfo.Font = New System.Drawing.Font("Times New Roman", 9.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.gbxLotInfo.Location = New System.Drawing.Point(0, 0)
        Me.gbxLotInfo.Name = "gbxLotInfo"
        Me.gbxLotInfo.Size = New System.Drawing.Size(1009, 125)
        Me.gbxLotInfo.TabIndex = 0
        Me.gbxLotInfo.TabStop = False
        '
        'txtOpName
        '
        Me.txtOpName.Anchor = CType(((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Left) _
            Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
        Me.txtOpName.Location = New System.Drawing.Point(743, 69)
        Me.txtOpName.Name = "txtOpName"
        Me.txtOpName.ReadOnly = True
        Me.txtOpName.Size = New System.Drawing.Size(434, 22)
        Me.txtOpName.TabIndex = 109
        '
        'txtOPNo
        '
        Me.txtOPNo.Location = New System.Drawing.Point(609, 69)
        Me.txtOPNo.Name = "txtOPNo"
        Me.txtOPNo.ReadOnly = True
        Me.txtOPNo.Size = New System.Drawing.Size(137, 22)
        Me.txtOPNo.TabIndex = 7
        '
        'txtProductNo
        '
        Me.txtProductNo.Anchor = CType(((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Left) _
            Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
        Me.txtProductNo.Location = New System.Drawing.Point(609, 42)
        Me.txtProductNo.Name = "txtProductNo"
        Me.txtProductNo.ReadOnly = True
        Me.txtProductNo.Size = New System.Drawing.Size(434, 22)
        Me.txtProductNo.TabIndex = 13
        '
        'txtCustomerLotNo
        '
        Me.txtCustomerLotNo.Location = New System.Drawing.Point(87, 42)
        Me.txtCustomerLotNo.Name = "txtCustomerLotNo"
        Me.txtCustomerLotNo.ReadOnly = True
        Me.txtCustomerLotNo.Size = New System.Drawing.Size(179, 22)
        Me.txtCustomerLotNo.TabIndex = 8
        '
        'txtMONo
        '
        Me.txtMONo.Location = New System.Drawing.Point(341, 42)
        Me.txtMONo.Name = "txtMONo"
        Me.txtMONo.ReadOnly = True
        Me.txtMONo.Size = New System.Drawing.Size(179, 22)
        Me.txtMONo.TabIndex = 9
        '
        'txtShiftNo
        '
        Me.txtShiftNo.Location = New System.Drawing.Point(341, 69)
        Me.txtShiftNo.Name = "txtShiftNo"
        Me.txtShiftNo.ReadOnly = True
        Me.txtShiftNo.Size = New System.Drawing.Size(179, 22)
        Me.txtShiftNo.TabIndex = 15
        '
        'txtEmployeeNo
        '
        Me.txtEmployeeNo.Location = New System.Drawing.Point(87, 69)
        Me.txtEmployeeNo.Name = "txtEmployeeNo"
        Me.txtEmployeeNo.ReadOnly = True
        Me.txtEmployeeNo.Size = New System.Drawing.Size(179, 22)
        Me.txtEmployeeNo.TabIndex = 12
        '
        'txtAreaNo
        '
        Me.txtAreaNo.Anchor = CType(((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Left) _
            Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
        Me.txtAreaNo.Location = New System.Drawing.Point(609, 15)
        Me.txtAreaNo.Name = "txtAreaNo"
        Me.txtAreaNo.ReadOnly = True
        Me.txtAreaNo.Size = New System.Drawing.Size(434, 22)
        Me.txtAreaNo.TabIndex = 2
        '
        'txtPriority
        '
        Me.txtPriority.Location = New System.Drawing.Point(341, 15)
        Me.txtPriority.Name = "txtPriority"
        Me.txtPriority.ReadOnly = True
        Me.txtPriority.Size = New System.Drawing.Size(179, 22)
        Me.txtPriority.TabIndex = 1
        '
        'txtSysUnitNo
        '
        Me.txtSysUnitNo.Anchor = CType((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
        Me.txtSysUnitNo.Location = New System.Drawing.Point(962, 42)
        Me.txtSysUnitNo.Name = "txtSysUnitNo"
        Me.txtSysUnitNo.ReadOnly = True
        Me.txtSysUnitNo.Size = New System.Drawing.Size(40, 22)
        Me.txtSysUnitNo.TabIndex = 9
        '
        'txtSysQty
        '
        Me.txtSysQty.Anchor = CType((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
        Me.txtSysQty.Location = New System.Drawing.Point(860, 42)
        Me.txtSysQty.Name = "txtSysQty"
        Me.txtSysQty.ReadOnly = True
        Me.txtSysQty.Size = New System.Drawing.Size(102, 22)
        Me.txtSysQty.TabIndex = 8
        '
        'txtCurUnitNo
        '
        Me.txtCurUnitNo.Anchor = CType((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
        Me.txtCurUnitNo.Location = New System.Drawing.Point(962, 15)
        Me.txtCurUnitNo.Name = "txtCurUnitNo"
        Me.txtCurUnitNo.ReadOnly = True
        Me.txtCurUnitNo.Size = New System.Drawing.Size(40, 22)
        Me.txtCurUnitNo.TabIndex = 4
        '
        'txtCurQty
        '
        Me.txtCurQty.Anchor = CType((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
        Me.txtCurQty.Location = New System.Drawing.Point(860, 15)
        Me.txtCurQty.Name = "txtCurQty"
        Me.txtCurQty.ReadOnly = True
        Me.txtCurQty.Size = New System.Drawing.Size(102, 22)
        Me.txtCurQty.TabIndex = 3
        '
        'txtOPDescription
        '
        Me.txtOPDescription.Anchor = CType(((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Left) _
            Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
        Me.txtOPDescription.Font = New System.Drawing.Font("Times New Roman", 9.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.txtOPDescription.Location = New System.Drawing.Point(87, 96)
        Me.txtOPDescription.Name = "txtOPDescription"
        Me.txtOPDescription.ReadOnly = True
        Me.txtOPDescription.Size = New System.Drawing.Size(915, 22)
        Me.txtOPDescription.TabIndex = 10
        '
        'txtLotNo
        '
        Me.txtLotNo.Location = New System.Drawing.Point(87, 15)
        Me.txtLotNo.Name = "txtLotNo"
        Me.txtLotNo.ReadOnly = True
        Me.txtLotNo.Size = New System.Drawing.Size(179, 22)
        Me.txtLotNo.TabIndex = 0
        '
        'lblPriority
        '
        Me.lblPriority.Font = New System.Drawing.Font("Times New Roman", 9.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.lblPriority.Location = New System.Drawing.Point(271, 18)
        Me.lblPriority.Name = "lblPriority"
        Me.lblPriority.Size = New System.Drawing.Size(64, 15)
        Me.lblPriority.TabIndex = 85
        Me.lblPriority.Text = "Priority"
        Me.lblPriority.TextAlign = System.Drawing.ContentAlignment.MiddleRight
        '
        'lblMONo
        '
        Me.lblMONo.Font = New System.Drawing.Font("Times New Roman", 9.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.lblMONo.Location = New System.Drawing.Point(271, 45)
        Me.lblMONo.Name = "lblMONo"
        Me.lblMONo.Size = New System.Drawing.Size(64, 15)
        Me.lblMONo.TabIndex = 83
        Me.lblMONo.Text = "MONo"
        Me.lblMONo.TextAlign = System.Drawing.ContentAlignment.MiddleRight
        '
        'lblShiftNo
        '
        Me.lblShiftNo.Font = New System.Drawing.Font("Times New Roman", 9.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.lblShiftNo.Location = New System.Drawing.Point(271, 72)
        Me.lblShiftNo.Name = "lblShiftNo"
        Me.lblShiftNo.Size = New System.Drawing.Size(64, 15)
        Me.lblShiftNo.TabIndex = 79
        Me.lblShiftNo.Text = "Shift No"
        Me.lblShiftNo.TextAlign = System.Drawing.ContentAlignment.MiddleRight
        '
        'lblOPNo
        '
        Me.lblOPNo.Font = New System.Drawing.Font("Times New Roman", 9.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.lblOPNo.Location = New System.Drawing.Point(527, 72)
        Me.lblOPNo.Name = "lblOPNo"
        Me.lblOPNo.Size = New System.Drawing.Size(75, 15)
        Me.lblOPNo.TabIndex = 75
        Me.lblOPNo.Text = "OP No"
        Me.lblOPNo.TextAlign = System.Drawing.ContentAlignment.MiddleRight
        '
        'lblAreaNo
        '
        Me.lblAreaNo.Font = New System.Drawing.Font("Times New Roman", 9.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.lblAreaNo.Location = New System.Drawing.Point(527, 18)
        Me.lblAreaNo.Name = "lblAreaNo"
        Me.lblAreaNo.Size = New System.Drawing.Size(75, 15)
        Me.lblAreaNo.TabIndex = 71
        Me.lblAreaNo.Text = "Area No"
        Me.lblAreaNo.TextAlign = System.Drawing.ContentAlignment.MiddleRight
        '
        'lblSysQty
        '
        Me.lblSysQty.Anchor = CType((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
        Me.lblSysQty.Font = New System.Drawing.Font("Times New Roman", 9.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.lblSysQty.Location = New System.Drawing.Point(790, 45)
        Me.lblSysQty.Name = "lblSysQty"
        Me.lblSysQty.Size = New System.Drawing.Size(64, 15)
        Me.lblSysQty.TabIndex = 68
        Me.lblSysQty.Text = "Sys Qty"
        Me.lblSysQty.TextAlign = System.Drawing.ContentAlignment.MiddleRight
        '
        'lblCurQty
        '
        Me.lblCurQty.Anchor = CType((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
        Me.lblCurQty.Font = New System.Drawing.Font("Times New Roman", 9.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.lblCurQty.Location = New System.Drawing.Point(790, 18)
        Me.lblCurQty.Name = "lblCurQty"
        Me.lblCurQty.Size = New System.Drawing.Size(64, 15)
        Me.lblCurQty.TabIndex = 64
        Me.lblCurQty.Text = "Cur Qty"
        Me.lblCurQty.TextAlign = System.Drawing.ContentAlignment.MiddleRight
        '
        'lblProductNo
        '
        Me.lblProductNo.Font = New System.Drawing.Font("Times New Roman", 9.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.lblProductNo.Location = New System.Drawing.Point(527, 45)
        Me.lblProductNo.Name = "lblProductNo"
        Me.lblProductNo.Size = New System.Drawing.Size(75, 15)
        Me.lblProductNo.TabIndex = 107
        Me.lblProductNo.Text = "Product No"
        Me.lblProductNo.TextAlign = System.Drawing.ContentAlignment.MiddleRight
        '
        'lblOPDescription
        '
        Me.lblOPDescription.Font = New System.Drawing.Font("Times New Roman", 9.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.lblOPDescription.Location = New System.Drawing.Point(3, 97)
        Me.lblOPDescription.Name = "lblOPDescription"
        Me.lblOPDescription.Size = New System.Drawing.Size(80, 15)
        Me.lblOPDescription.TabIndex = 108
        Me.lblOPDescription.Text = "OP Description"
        Me.lblOPDescription.TextAlign = System.Drawing.ContentAlignment.MiddleRight
        '
        'lblCustomerLotNo
        '
        Me.lblCustomerLotNo.Font = New System.Drawing.Font("Times New Roman", 9.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.lblCustomerLotNo.Location = New System.Drawing.Point(3, 45)
        Me.lblCustomerLotNo.Name = "lblCustomerLotNo"
        Me.lblCustomerLotNo.Size = New System.Drawing.Size(80, 15)
        Me.lblCustomerLotNo.TabIndex = 81
        Me.lblCustomerLotNo.Text = "Customer Lot No"
        Me.lblCustomerLotNo.TextAlign = System.Drawing.ContentAlignment.MiddleRight
        '
        'lblEmployeeNo
        '
        Me.lblEmployeeNo.Font = New System.Drawing.Font("Times New Roman", 9.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.lblEmployeeNo.Location = New System.Drawing.Point(3, 72)
        Me.lblEmployeeNo.Name = "lblEmployeeNo"
        Me.lblEmployeeNo.Size = New System.Drawing.Size(80, 15)
        Me.lblEmployeeNo.TabIndex = 73
        Me.lblEmployeeNo.Text = "Employee No"
        Me.lblEmployeeNo.TextAlign = System.Drawing.ContentAlignment.MiddleRight
        '
        'lblLotNo
        '
        Me.lblLotNo.Font = New System.Drawing.Font("Times New Roman", 9.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.lblLotNo.Location = New System.Drawing.Point(3, 18)
        Me.lblLotNo.Name = "lblLotNo"
        Me.lblLotNo.Size = New System.Drawing.Size(80, 15)
        Me.lblLotNo.TabIndex = 62
        Me.lblLotNo.Text = "Lot No"
        Me.lblLotNo.TextAlign = System.Drawing.ContentAlignment.MiddleRight
        '
        'UltraTabPageControl2
        '
        Me.UltraTabPageControl2.Location = New System.Drawing.Point(-10000, -10000)
        Me.UltraTabPageControl2.Name = "UltraTabPageControl2"
        Me.UltraTabPageControl2.Size = New System.Drawing.Size(340, 100)
        '
        'UltraTabPageControl1
        '
        Me.UltraTabPageControl1.Location = New System.Drawing.Point(-10000, -10000)
        Me.UltraTabPageControl1.Name = "UltraTabPageControl1"
        Me.UltraTabPageControl1.Size = New System.Drawing.Size(340, 100)
        '
        'SBar1
        '
        Me.SBar1.Font = New System.Drawing.Font("Times New Roman", 9.75!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.SBar1.Location = New System.Drawing.Point(0, 707)
        Me.SBar1.Name = "SBar1"
        Me.SBar1.Panels.AddRange(New System.Windows.Forms.StatusBarPanel() {Me.SBarPanel1, Me.SBarPanel2, Me.SBarPanel3, Me.SBarPanel4})
        Me.SBar1.ShowPanels = True
        Me.SBar1.Size = New System.Drawing.Size(1008, 22)
        Me.SBar1.TabIndex = 68
        '
        'SBarPanel1
        '
        Me.SBarPanel1.Name = "SBarPanel1"
        '
        'SBarPanel2
        '
        Me.SBarPanel2.Name = "SBarPanel2"
        '
        'SBarPanel3
        '
        Me.SBarPanel3.AutoSize = System.Windows.Forms.StatusBarPanelAutoSize.Spring
        Me.SBarPanel3.Name = "SBarPanel3"
        Me.SBarPanel3.Width = 641
        '
        'SBarPanel4
        '
        Me.SBarPanel4.Alignment = System.Windows.Forms.HorizontalAlignment.Right
        Me.SBarPanel4.Name = "SBarPanel4"
        Me.SBarPanel4.Width = 150
        '
        'iugAttrib
        '
        Me.iugAttrib.Anchor = CType((((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Bottom) _
            Or System.Windows.Forms.AnchorStyles.Left) _
            Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
        Me.iugAttrib.EnterDirection = iMESUltraGrid.iMESUltraGridControl.EnterDirectionEnum.Down
        Me.iugAttrib.GroupBoxPromptText = "Drag a column header here to group by that column."
        Me.iugAttrib.GroupBoxTextForeColor = System.Drawing.Color.Red
        Me.iugAttrib.Identity = "IMes"
        Me.iugAttrib.IdentityForm = ""
        Me.iugAttrib.LayOutFilePath = ""
        Me.iugAttrib.Location = New System.Drawing.Point(4, 3)
        Me.iugAttrib.Name = "iugAttrib"
        Me.iugAttrib.PrintFitWidthToPages = 0
        Me.iugAttrib.PrintLandscape = True
        Me.iugAttrib.PrintPageFooter = ""
        Me.iugAttrib.PrintPageFooterHAlign = Infragistics.Win.HAlign.[Default]
        Me.iugAttrib.PrintPageFooterHeight = 20
        Me.iugAttrib.PrintPageHeader = ""
        Me.iugAttrib.PrintPageHeaderHAlign = Infragistics.Win.HAlign.[Default]
        Me.iugAttrib.PrintPageHeaderHeight = 20
        Me.iugAttrib.PrintZoom = 1.0R
        Me.iugAttrib.Size = New System.Drawing.Size(506, 214)
        Me.iugAttrib.TabIndex = 105
        Me.iugAttrib.UserNo = "IMes"
        '
        'iugEquipment
        '
        Me.iugEquipment.Anchor = CType((((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Bottom) _
            Or System.Windows.Forms.AnchorStyles.Left) _
            Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
        Me.iugEquipment.EnterDirection = iMESUltraGrid.iMESUltraGridControl.EnterDirectionEnum.Down
        Me.iugEquipment.GroupBoxPromptText = "Drag a column header here to group by that column."
        Me.iugEquipment.GroupBoxTextForeColor = System.Drawing.Color.Red
        Me.iugEquipment.Identity = "IMes"
        Me.iugEquipment.IdentityForm = ""
        Me.iugEquipment.LayOutFilePath = ""
        Me.iugEquipment.Location = New System.Drawing.Point(3, 46)
        Me.iugEquipment.Name = "iugEquipment"
        Me.iugEquipment.PrintFitWidthToPages = 0
        Me.iugEquipment.PrintLandscape = True
        Me.iugEquipment.PrintPageFooter = ""
        Me.iugEquipment.PrintPageFooterHAlign = Infragistics.Win.HAlign.[Default]
        Me.iugEquipment.PrintPageFooterHeight = 20
        Me.iugEquipment.PrintPageHeader = ""
        Me.iugEquipment.PrintPageHeaderHAlign = Infragistics.Win.HAlign.[Default]
        Me.iugEquipment.PrintPageHeaderHeight = 20
        Me.iugEquipment.PrintZoom = 1.0R
        Me.iugEquipment.Size = New System.Drawing.Size(477, 171)
        Me.iugEquipment.TabIndex = 107
        Me.iugEquipment.UserNo = "IMes"
        '
        'btnClose
        '
        Me.btnClose.Anchor = CType((System.Windows.Forms.AnchorStyles.Bottom Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
        Me.btnClose.Location = New System.Drawing.Point(925, 673)
        Me.btnClose.Name = "btnClose"
        Me.btnClose.Size = New System.Drawing.Size(80, 32)
        Me.btnClose.TabIndex = 144
        Me.btnClose.Text = "Close"
        '
        'btnConfirm
        '
        Me.btnConfirm.Anchor = CType((System.Windows.Forms.AnchorStyles.Bottom Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
        Me.btnConfirm.Location = New System.Drawing.Point(839, 673)
        Me.btnConfirm.Name = "btnConfirm"
        Me.btnConfirm.Size = New System.Drawing.Size(80, 32)
        Me.btnConfirm.TabIndex = 143
        Me.btnConfirm.Text = "Confirm"
        '
        'lblEquipmentNo
        '
        Me.lblEquipmentNo.Font = New System.Drawing.Font("Times New Roman", 9.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.lblEquipmentNo.Location = New System.Drawing.Point(20, 16)
        Me.lblEquipmentNo.Name = "lblEquipmentNo"
        Me.lblEquipmentNo.Size = New System.Drawing.Size(80, 16)
        Me.lblEquipmentNo.TabIndex = 147
        Me.lblEquipmentNo.Text = "Equipment No"
        '
        'txtEquipmentNo
        '
        Me.txtEquipmentNo.Location = New System.Drawing.Point(106, 12)
        Me.txtEquipmentNo.Name = "txtEquipmentNo"
        Me.txtEquipmentNo.Size = New System.Drawing.Size(132, 22)
        Me.txtEquipmentNo.TabIndex = 17
        '
        'lblLotRecord
        '
        Me.lblLotRecord.Anchor = CType((System.Windows.Forms.AnchorStyles.Bottom Or System.Windows.Forms.AnchorStyles.Left), System.Windows.Forms.AnchorStyles)
        Me.lblLotRecord.Font = New System.Drawing.Font("Times New Roman", 9.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.lblLotRecord.Location = New System.Drawing.Point(16, 634)
        Me.lblLotRecord.Name = "lblLotRecord"
        Me.lblLotRecord.Size = New System.Drawing.Size(64, 16)
        Me.lblLotRecord.TabIndex = 145
        Me.lblLotRecord.Text = "Lot Record"
        '
        'txtLotRecord
        '
        Me.txtLotRecord.Anchor = CType((System.Windows.Forms.AnchorStyles.Bottom Or System.Windows.Forms.AnchorStyles.Left), System.Windows.Forms.AnchorStyles)
        Me.txtLotRecord.Font = New System.Drawing.Font("Times New Roman", 9.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.txtLotRecord.Location = New System.Drawing.Point(88, 634)
        Me.txtLotRecord.Name = "txtLotRecord"
        Me.txtLotRecord.Size = New System.Drawing.Size(393, 35)
        Me.txtLotRecord.TabIndex = 18
        Me.txtLotRecord.Text = ""
        '
        'lblupdcheckintime
        '
        Me.lblupdcheckintime.Anchor = CType((System.Windows.Forms.AnchorStyles.Bottom Or System.Windows.Forms.AnchorStyles.Left), System.Windows.Forms.AnchorStyles)
        Me.lblupdcheckintime.Font = New System.Drawing.Font("Times New Roman", 9.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.lblupdcheckintime.Location = New System.Drawing.Point(8, 683)
        Me.lblupdcheckintime.Name = "lblupdcheckintime"
        Me.lblupdcheckintime.Size = New System.Drawing.Size(116, 14)
        Me.lblupdcheckintime.TabIndex = 62
        Me.lblupdcheckintime.Text = "Update CheckIn Time"
        '
        'dtpcheckintime
        '
        Me.dtpcheckintime.Anchor = CType((System.Windows.Forms.AnchorStyles.Bottom Or System.Windows.Forms.AnchorStyles.Left), System.Windows.Forms.AnchorStyles)
        Me.dtpcheckintime.CustomFormat = "yyyy/MM/dd HH:mm:ss"
        Me.dtpcheckintime.Format = System.Windows.Forms.DateTimePickerFormat.Custom
        Me.dtpcheckintime.Location = New System.Drawing.Point(152, 682)
        Me.dtpcheckintime.Name = "dtpcheckintime"
        Me.dtpcheckintime.Size = New System.Drawing.Size(128, 21)
        Me.dtpcheckintime.TabIndex = 151
        '
        'btnEQPConsumeReset
        '
        Me.btnEQPConsumeReset.Anchor = CType((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
        Me.btnEQPConsumeReset.Location = New System.Drawing.Point(282, 7)
        Me.btnEQPConsumeReset.Name = "btnEQPConsumeReset"
        Me.btnEQPConsumeReset.Size = New System.Drawing.Size(111, 32)
        Me.btnEQPConsumeReset.TabIndex = 152
        Me.btnEQPConsumeReset.Text = "EQPConsumeReset"
        '
        'btnQCList
        '
        Me.btnQCList.Anchor = CType((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
        Me.btnQCList.Location = New System.Drawing.Point(400, 7)
        Me.btnQCList.Name = "btnQCList"
        Me.btnQCList.Size = New System.Drawing.Size(80, 32)
        Me.btnQCList.TabIndex = 153
        Me.btnQCList.Text = "QC List"
        '
        'utpEquipment
        '
        Me.utpEquipment.Controls.Add(Me.IMESUltraGrid3)
        Me.utpEquipment.Location = New System.Drawing.Point(-10000, -10000)
        Me.utpEquipment.Name = "utpEquipment"
        Me.utpEquipment.Size = New System.Drawing.Size(772, 150)
        '
        'IMESUltraGrid3
        '
        Me.IMESUltraGrid3.Anchor = CType(((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Left) _
            Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
        Me.IMESUltraGrid3.EnterDirection = iMESUltraGrid.iMESUltraGridControl.EnterDirectionEnum.Down
        Me.IMESUltraGrid3.GroupBoxPromptText = "Drag a column header here to group by that column."
        Me.IMESUltraGrid3.GroupBoxTextForeColor = System.Drawing.Color.Red
        Me.IMESUltraGrid3.Identity = "IMes"
        Me.IMESUltraGrid3.IdentityForm = ""
        Me.IMESUltraGrid3.LayOutFilePath = ""
        Me.IMESUltraGrid3.Location = New System.Drawing.Point(11, 8)
        Me.IMESUltraGrid3.Name = "IMESUltraGrid3"
        Me.IMESUltraGrid3.PrintFitWidthToPages = 0
        Me.IMESUltraGrid3.PrintLandscape = True
        Me.IMESUltraGrid3.PrintPageFooter = ""
        Me.IMESUltraGrid3.PrintPageFooterHAlign = Infragistics.Win.HAlign.[Default]
        Me.IMESUltraGrid3.PrintPageFooterHeight = 20
        Me.IMESUltraGrid3.PrintPageHeader = ""
        Me.IMESUltraGrid3.PrintPageHeaderHAlign = Infragistics.Win.HAlign.[Default]
        Me.IMESUltraGrid3.PrintPageHeaderHeight = 20
        Me.IMESUltraGrid3.PrintZoom = 1.0R
        Me.IMESUltraGrid3.Size = New System.Drawing.Size(753, 136)
        Me.IMESUltraGrid3.TabIndex = 0
        Me.IMESUltraGrid3.UserNo = "IMes"
        '
        'btnMultiUser
        '
        Me.btnMultiUser.Anchor = CType((System.Windows.Forms.AnchorStyles.Bottom Or System.Windows.Forms.AnchorStyles.Left), System.Windows.Forms.AnchorStyles)
        Me.btnMultiUser.Location = New System.Drawing.Point(398, 673)
        Me.btnMultiUser.Name = "btnMultiUser"
        Me.btnMultiUser.Size = New System.Drawing.Size(80, 32)
        Me.btnMultiUser.TabIndex = 155
        Me.btnMultiUser.Text = "Multi User"
        Me.btnMultiUser.Visible = False
        '
        'btnOperator
        '
        Me.btnOperator.Anchor = CType((System.Windows.Forms.AnchorStyles.Bottom Or System.Windows.Forms.AnchorStyles.Left), System.Windows.Forms.AnchorStyles)
        Me.btnOperator.Location = New System.Drawing.Point(315, 673)
        Me.btnOperator.Name = "btnOperator"
        Me.btnOperator.Size = New System.Drawing.Size(80, 32)
        Me.btnOperator.TabIndex = 156
        Me.btnOperator.Text = "Operator"
        Me.btnOperator.Visible = False
        '
        'chkUpdCheckInTime
        '
        Me.chkUpdCheckInTime.Anchor = CType((System.Windows.Forms.AnchorStyles.Bottom Or System.Windows.Forms.AnchorStyles.Left), System.Windows.Forms.AnchorStyles)
        Me.chkUpdCheckInTime.AutoSize = True
        Me.chkUpdCheckInTime.Location = New System.Drawing.Point(130, 683)
        Me.chkUpdCheckInTime.Name = "chkUpdCheckInTime"
        Me.chkUpdCheckInTime.Size = New System.Drawing.Size(15, 14)
        Me.chkUpdCheckInTime.TabIndex = 157
        '
        'btnSWR
        '
        Me.btnSWR.Anchor = CType((System.Windows.Forms.AnchorStyles.Bottom Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
        Me.btnSWR.Location = New System.Drawing.Point(753, 673)
        Me.btnSWR.Name = "btnSWR"
        Me.btnSWR.Size = New System.Drawing.Size(80, 32)
        Me.btnSWR.TabIndex = 158
        Me.btnSWR.Text = "SWR"
        '
        'uplAttrib
        '
        '
        'uplAttrib.ClientArea
        '
        Me.uplAttrib.ClientArea.Controls.Add(Me.iugAttrib)
        Me.uplAttrib.Dock = System.Windows.Forms.DockStyle.Left
        Me.uplAttrib.Location = New System.Drawing.Point(0, 0)
        Me.uplAttrib.Name = "uplAttrib"
        Me.uplAttrib.Size = New System.Drawing.Size(515, 220)
        Me.uplAttrib.TabIndex = 0
        '
        'uplEquipment
        '
        '
        'uplEquipment.ClientArea
        '
        Me.uplEquipment.ClientArea.Controls.Add(Me.lblEquipmentNo)
        Me.uplEquipment.ClientArea.Controls.Add(Me.iugEquipment)
        Me.uplEquipment.ClientArea.Controls.Add(Me.txtEquipmentNo)
        Me.uplEquipment.ClientArea.Controls.Add(Me.btnEQPConsumeReset)
        Me.uplEquipment.ClientArea.Controls.Add(Me.btnQCList)
        Me.uplEquipment.Dock = System.Windows.Forms.DockStyle.Fill
        Me.uplEquipment.Location = New System.Drawing.Point(522, 0)
        Me.uplEquipment.Name = "uplEquipment"
        Me.uplEquipment.Size = New System.Drawing.Size(487, 220)
        Me.uplEquipment.TabIndex = 1
        '
        'uplAttrib_Equipment
        '
        '
        'uplAttrib_Equipment.ClientArea
        '
        Me.uplAttrib_Equipment.ClientArea.Controls.Add(Me.uplEquipment)
        Me.uplAttrib_Equipment.ClientArea.Controls.Add(Me.UltraSplitter1)
        Me.uplAttrib_Equipment.ClientArea.Controls.Add(Me.uplAttrib)
        Me.uplAttrib_Equipment.Dock = System.Windows.Forms.DockStyle.Fill
        Me.uplAttrib_Equipment.Location = New System.Drawing.Point(0, 0)
        Me.uplAttrib_Equipment.Name = "uplAttrib_Equipment"
        Me.uplAttrib_Equipment.Size = New System.Drawing.Size(1009, 220)
        Me.uplAttrib_Equipment.TabIndex = 162
        '
        'UltraSplitter1
        '
        Me.UltraSplitter1.Location = New System.Drawing.Point(515, 0)
        Me.UltraSplitter1.Name = "UltraSplitter1"
        Me.UltraSplitter1.RestoreExtent = 479
        Me.UltraSplitter1.Size = New System.Drawing.Size(7, 220)
        Me.UltraSplitter1.TabIndex = 1
        '
        'uplMaterial_KeyIn
        '
        '
        'uplMaterial_KeyIn.ClientArea
        '
        Me.uplMaterial_KeyIn.ClientArea.Controls.Add(Me.uplKeyIn)
        Me.uplMaterial_KeyIn.ClientArea.Controls.Add(Me.UltraSplitter2)
        Me.uplMaterial_KeyIn.ClientArea.Controls.Add(Me.uplMaterial)
        Me.uplMaterial_KeyIn.Dock = System.Windows.Forms.DockStyle.Fill
        Me.uplMaterial_KeyIn.Location = New System.Drawing.Point(0, 0)
        Me.uplMaterial_KeyIn.Name = "uplMaterial_KeyIn"
        Me.uplMaterial_KeyIn.Size = New System.Drawing.Size(1009, 216)
        Me.uplMaterial_KeyIn.TabIndex = 0
        '
        'uplKeyIn
        '
        '
        'uplKeyIn.ClientArea
        '
        Me.uplKeyIn.ClientArea.Controls.Add(Me.iugKeyIn)
        Me.uplKeyIn.Dock = System.Windows.Forms.DockStyle.Fill
        Me.uplKeyIn.Location = New System.Drawing.Point(522, 0)
        Me.uplKeyIn.Name = "uplKeyIn"
        Me.uplKeyIn.Size = New System.Drawing.Size(487, 216)
        Me.uplKeyIn.TabIndex = 4
        '
        'iugKeyIn
        '
        Me.iugKeyIn.Anchor = CType((((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Bottom) _
            Or System.Windows.Forms.AnchorStyles.Left) _
            Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
        Me.iugKeyIn.EnterDirection = iMESUltraGrid.iMESUltraGridControl.EnterDirectionEnum.Down
        Me.iugKeyIn.GroupBoxPromptText = "Drag a column header here to group by that column."
        Me.iugKeyIn.GroupBoxTextForeColor = System.Drawing.Color.Red
        Me.iugKeyIn.Identity = "IMes"
        Me.iugKeyIn.IdentityForm = ""
        Me.iugKeyIn.LayOutFilePath = ""
        Me.iugKeyIn.Location = New System.Drawing.Point(3, 3)
        Me.iugKeyIn.Name = "iugKeyIn"
        Me.iugKeyIn.PrintFitWidthToPages = 0
        Me.iugKeyIn.PrintLandscape = True
        Me.iugKeyIn.PrintPageFooter = ""
        Me.iugKeyIn.PrintPageFooterHAlign = Infragistics.Win.HAlign.[Default]
        Me.iugKeyIn.PrintPageFooterHeight = 20
        Me.iugKeyIn.PrintPageHeader = ""
        Me.iugKeyIn.PrintPageHeaderHAlign = Infragistics.Win.HAlign.[Default]
        Me.iugKeyIn.PrintPageHeaderHeight = 20
        Me.iugKeyIn.PrintZoom = 1.0R
        Me.iugKeyIn.Size = New System.Drawing.Size(477, 207)
        Me.iugKeyIn.TabIndex = 150
        Me.iugKeyIn.UserNo = "IMes"
        '
        'UltraSplitter2
        '
        Me.UltraSplitter2.Location = New System.Drawing.Point(515, 0)
        Me.UltraSplitter2.Name = "UltraSplitter2"
        Me.UltraSplitter2.RestoreExtent = 479
        Me.UltraSplitter2.Size = New System.Drawing.Size(7, 216)
        Me.UltraSplitter2.TabIndex = 3
        '
        'uplMaterial
        '
        '
        'uplMaterial.ClientArea
        '
        Me.uplMaterial.ClientArea.Controls.Add(Me.UltraTabControl1)
        Me.uplMaterial.Dock = System.Windows.Forms.DockStyle.Left
        Me.uplMaterial.Location = New System.Drawing.Point(0, 0)
        Me.uplMaterial.Name = "uplMaterial"
        Me.uplMaterial.Size = New System.Drawing.Size(515, 216)
        Me.uplMaterial.TabIndex = 0
        '
        'UltraTabControl1
        '
        Me.UltraTabControl1.Anchor = CType((((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Bottom) _
            Or System.Windows.Forms.AnchorStyles.Left) _
            Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
        Me.UltraTabControl1.Controls.Add(Me.utpMaterial)
        Me.UltraTabControl1.Controls.Add(Me.UltraTabSharedControlsPage1)
        Me.UltraTabControl1.Controls.Add(Me.utpSubOP)
        Me.UltraTabControl1.Controls.Add(Me.iugCustomTab)
        Me.UltraTabControl1.Location = New System.Drawing.Point(3, 3)
        Me.UltraTabControl1.Name = "UltraTabControl1"
        Me.UltraTabControl1.SharedControlsPage = Me.UltraTabSharedControlsPage1
        Me.UltraTabControl1.Size = New System.Drawing.Size(515, 213)
        Me.UltraTabControl1.TabIndex = 154
        Me.UltraTabControl1.TabLayoutStyle = Infragistics.Win.UltraWinTabs.TabLayoutStyle.MultiRowTabsPerRow
        UltraTab2.FixedWidth = 120
        UltraTab2.TabPage = Me.utpMaterial
        UltraTab2.Text = "Material"
        UltraTab3.FixedWidth = 120
        UltraTab3.TabPage = Me.utpSubOP
        UltraTab3.Text = "Sub OP"
        UltraTab5.FixedWidth = 120
        UltraTab5.TabPage = Me.iugCustomTab
        UltraTab5.Text = "TestData21703"
        Me.UltraTabControl1.Tabs.AddRange(New Infragistics.Win.UltraWinTabControl.UltraTab() {UltraTab2, UltraTab3, UltraTab5})
        '
        'UltraTabSharedControlsPage1
        '
        Me.UltraTabSharedControlsPage1.Location = New System.Drawing.Point(-10000, -10000)
        Me.UltraTabSharedControlsPage1.Name = "UltraTabSharedControlsPage1"
        Me.UltraTabSharedControlsPage1.Size = New System.Drawing.Size(511, 187)
        '
        'uplAll
        '
        Me.uplAll.Anchor = CType((((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Bottom) _
            Or System.Windows.Forms.AnchorStyles.Left) _
            Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
        '
        'uplAll.ClientArea
        '
        Me.uplAll.ClientArea.Controls.Add(Me.uegMaterial_KeyIn2)
        Me.uplAll.ClientArea.Controls.Add(Me.uegAttrib_Equipment)
        Me.uplAll.ClientArea.Controls.Add(Me.uegLotInfo)
        Me.uplAll.Location = New System.Drawing.Point(0, -1)
        Me.uplAll.Name = "uplAll"
        Me.uplAll.Size = New System.Drawing.Size(1013, 629)
        Me.uplAll.TabIndex = 165
        '
        'uegMaterial_KeyIn2
        '
        Me.uegMaterial_KeyIn2.Controls.Add(Me.UltraExpandableGroupBoxPanel4)
        Me.uegMaterial_KeyIn2.Dock = System.Windows.Forms.DockStyle.Fill
        Me.uegMaterial_KeyIn2.ExpandedSize = New System.Drawing.Size(1013, 236)
        Me.uegMaterial_KeyIn2.Location = New System.Drawing.Point(0, 393)
        Me.uegMaterial_KeyIn2.Name = "uegMaterial_KeyIn2"
        Me.uegMaterial_KeyIn2.Size = New System.Drawing.Size(1013, 236)
        Me.uegMaterial_KeyIn2.TabIndex = 163
        Me.uegMaterial_KeyIn2.ViewStyle = Infragistics.Win.Misc.GroupBoxViewStyle.Office2003
        '
        'UltraExpandableGroupBoxPanel4
        '
        Me.UltraExpandableGroupBoxPanel4.Controls.Add(Me.UltraPanel4)
        Me.UltraExpandableGroupBoxPanel4.Dock = System.Windows.Forms.DockStyle.Fill
        Me.UltraExpandableGroupBoxPanel4.Location = New System.Drawing.Point(2, 18)
        Me.UltraExpandableGroupBoxPanel4.Name = "UltraExpandableGroupBoxPanel4"
        Me.UltraExpandableGroupBoxPanel4.Size = New System.Drawing.Size(1009, 216)
        Me.UltraExpandableGroupBoxPanel4.TabIndex = 0
        '
        'UltraPanel4
        '
        '
        'UltraPanel4.ClientArea
        '
        Me.UltraPanel4.ClientArea.Controls.Add(Me.uplMaterial_KeyIn)
        Me.UltraPanel4.Dock = System.Windows.Forms.DockStyle.Fill
        Me.UltraPanel4.Location = New System.Drawing.Point(0, 0)
        Me.UltraPanel4.Name = "UltraPanel4"
        Me.UltraPanel4.Size = New System.Drawing.Size(1009, 216)
        Me.UltraPanel4.TabIndex = 0
        '
        'uegAttrib_Equipment
        '
        Me.uegAttrib_Equipment.Controls.Add(Me.UltraExpandableGroupBoxPanel2)
        Me.uegAttrib_Equipment.Dock = System.Windows.Forms.DockStyle.Top
        Me.uegAttrib_Equipment.ExpandedSize = New System.Drawing.Size(1013, 240)
        Me.uegAttrib_Equipment.Location = New System.Drawing.Point(0, 153)
        Me.uegAttrib_Equipment.Name = "uegAttrib_Equipment"
        Me.uegAttrib_Equipment.Size = New System.Drawing.Size(1013, 240)
        Me.uegAttrib_Equipment.TabIndex = 162
        Me.uegAttrib_Equipment.ViewStyle = Infragistics.Win.Misc.GroupBoxViewStyle.Office2003
        '
        'UltraExpandableGroupBoxPanel2
        '
        Me.UltraExpandableGroupBoxPanel2.Controls.Add(Me.UltraPanel2)
        Me.UltraExpandableGroupBoxPanel2.Dock = System.Windows.Forms.DockStyle.Fill
        Me.UltraExpandableGroupBoxPanel2.Location = New System.Drawing.Point(2, 18)
        Me.UltraExpandableGroupBoxPanel2.Name = "UltraExpandableGroupBoxPanel2"
        Me.UltraExpandableGroupBoxPanel2.Size = New System.Drawing.Size(1009, 220)
        Me.UltraExpandableGroupBoxPanel2.TabIndex = 0
        '
        'UltraPanel2
        '
        '
        'UltraPanel2.ClientArea
        '
        Me.UltraPanel2.ClientArea.Controls.Add(Me.uplAttrib_Equipment)
        Me.UltraPanel2.Dock = System.Windows.Forms.DockStyle.Fill
        Me.UltraPanel2.Location = New System.Drawing.Point(0, 0)
        Me.UltraPanel2.Name = "UltraPanel2"
        Me.UltraPanel2.Size = New System.Drawing.Size(1009, 220)
        Me.UltraPanel2.TabIndex = 0
        '
        'UltraTabPageControl3
        '
        Me.UltraTabPageControl3.Controls.Add(Me.Label1)
        Me.UltraTabPageControl3.Controls.Add(Me.UltraTextEditor1)
        Me.UltraTabPageControl3.Controls.Add(Me.Label2)
        Me.UltraTabPageControl3.Controls.Add(Me.UltraTextEditor2)
        Me.UltraTabPageControl3.Controls.Add(Me.IMESUltraGridControl1)
        Me.UltraTabPageControl3.Location = New System.Drawing.Point(-10000, -10000)
        Me.UltraTabPageControl3.Name = "UltraTabPageControl3"
        Me.UltraTabPageControl3.Size = New System.Drawing.Size(511, 187)
        '
        'Label1
        '
        Me.Label1.BackColor = System.Drawing.Color.Transparent
        Me.Label1.Font = New System.Drawing.Font("Times New Roman", 9.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.Label1.Location = New System.Drawing.Point(7, 11)
        Me.Label1.Name = "Label1"
        Me.Label1.Size = New System.Drawing.Size(90, 16)
        Me.Label1.TabIndex = 159
        Me.Label1.Text = "Material No"
        '
        'UltraTextEditor1
        '
        Me.UltraTextEditor1.Location = New System.Drawing.Point(103, 7)
        Me.UltraTextEditor1.Name = "UltraTextEditor1"
        Me.UltraTextEditor1.Size = New System.Drawing.Size(132, 21)
        Me.UltraTextEditor1.TabIndex = 158
        '
        'Label2
        '
        Me.Label2.BackColor = System.Drawing.Color.Transparent
        Me.Label2.Font = New System.Drawing.Font("Times New Roman", 9.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.Label2.Location = New System.Drawing.Point(244, 11)
        Me.Label2.Name = "Label2"
        Me.Label2.Size = New System.Drawing.Size(90, 16)
        Me.Label2.TabIndex = 157
        Me.Label2.Text = "Material Lot No"
        '
        'UltraTextEditor2
        '
        Me.UltraTextEditor2.Location = New System.Drawing.Point(340, 7)
        Me.UltraTextEditor2.Name = "UltraTextEditor2"
        Me.UltraTextEditor2.Size = New System.Drawing.Size(132, 21)
        Me.UltraTextEditor2.TabIndex = 156
        '
        'IMESUltraGridControl1
        '
        Me.IMESUltraGridControl1.Anchor = CType((((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Bottom) _
            Or System.Windows.Forms.AnchorStyles.Left) _
            Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
        Me.IMESUltraGridControl1.EnterDirection = iMESUltraGrid.iMESUltraGridControl.EnterDirectionEnum.Down
        Me.IMESUltraGridControl1.GroupBoxPromptText = "Drag a column header here to group by that column."
        Me.IMESUltraGridControl1.GroupBoxTextForeColor = System.Drawing.Color.Red
        Me.IMESUltraGridControl1.Identity = "IMes"
        Me.IMESUltraGridControl1.IdentityForm = ""
        Me.IMESUltraGridControl1.LayOutFilePath = ""
        Me.IMESUltraGridControl1.Location = New System.Drawing.Point(2, 35)
        Me.IMESUltraGridControl1.Name = "IMESUltraGridControl1"
        Me.IMESUltraGridControl1.PrintFitWidthToPages = 0
        Me.IMESUltraGridControl1.PrintLandscape = True
        Me.IMESUltraGridControl1.PrintPageFooter = ""
        Me.IMESUltraGridControl1.PrintPageFooterHAlign = Infragistics.Win.HAlign.[Default]
        Me.IMESUltraGridControl1.PrintPageFooterHeight = 20
        Me.IMESUltraGridControl1.PrintPageHeader = ""
        Me.IMESUltraGridControl1.PrintPageHeaderHAlign = Infragistics.Win.HAlign.[Default]
        Me.IMESUltraGridControl1.PrintPageHeaderHeight = 20
        Me.IMESUltraGridControl1.PrintZoom = 1.0R
        Me.IMESUltraGridControl1.Size = New System.Drawing.Size(506, 172)
        Me.IMESUltraGridControl1.TabIndex = 108
        Me.IMESUltraGridControl1.UserNo = "IMes"
        '
        'UltraTabSharedControlsPage2
        '
        Me.UltraTabSharedControlsPage2.Location = New System.Drawing.Point(-10000, -10000)
        Me.UltraTabSharedControlsPage2.Name = "UltraTabSharedControlsPage2"
        Me.UltraTabSharedControlsPage2.Size = New System.Drawing.Size(511, 187)
        '
        'UltraTabControl2
        '
        Me.UltraTabControl2.Anchor = CType((((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Bottom) _
            Or System.Windows.Forms.AnchorStyles.Left) _
            Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
        Me.UltraTabControl2.Controls.Add(Me.UltraTabPageControl3)
        Me.UltraTabControl2.Location = New System.Drawing.Point(0, 0)
        Me.UltraTabControl2.Name = "UltraTabControl2"
        Me.UltraTabControl2.SharedControlsPage = Me.UltraTabSharedControlsPage2
        Me.UltraTabControl2.Size = New System.Drawing.Size(200, 100)
        Me.UltraTabControl2.TabIndex = 0
        '
        'frmBR_L_CI_GEN
        '
        Me.AutoScaleBaseSize = New System.Drawing.Size(5, 14)
        Me.ClientSize = New System.Drawing.Size(1008, 729)
        Me.Controls.Add(Me.uplAll)
        Me.Controls.Add(Me.btnSWR)
        Me.Controls.Add(Me.chkUpdCheckInTime)
        Me.Controls.Add(Me.btnOperator)
        Me.Controls.Add(Me.btnMultiUser)
        Me.Controls.Add(Me.dtpcheckintime)
        Me.Controls.Add(Me.txtLotRecord)
        Me.Controls.Add(Me.lblLotRecord)
        Me.Controls.Add(Me.btnClose)
        Me.Controls.Add(Me.btnConfirm)
        Me.Controls.Add(Me.SBar1)
        Me.Controls.Add(Me.lblupdcheckintime)
        Me.Font = New System.Drawing.Font("Times New Roman", 9.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.MinimizeBox = False
        Me.Name = "frmBR_L_CI_GEN"
        Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen
        Me.Text = "General Check In"
        Me.utpMaterial.ResumeLayout(False)
        Me.utpMaterial.PerformLayout()
        CType(Me.txtMaterialNo, System.ComponentModel.ISupportInitialize).EndInit()
        CType(Me.txtMaterialLotNo, System.ComponentModel.ISupportInitialize).EndInit()
        Me.utpSubOP.ResumeLayout(False)
        Me.iugCustomTab.ResumeLayout(False)
        CType(Me.uegLotInfo, System.ComponentModel.ISupportInitialize).EndInit()
        Me.uegLotInfo.ResumeLayout(False)
        Me.UltraExpandableGroupBoxPanel1.ResumeLayout(False)
        Me.UltraPanel1.ClientArea.ResumeLayout(False)
        Me.UltraPanel1.ResumeLayout(False)
        Me.gbxLotInfo.ResumeLayout(False)
        Me.gbxLotInfo.PerformLayout()
        CType(Me.txtOpName, System.ComponentModel.ISupportInitialize).EndInit()
        CType(Me.txtOPNo, System.ComponentModel.ISupportInitialize).EndInit()
        CType(Me.txtProductNo, System.ComponentModel.ISupportInitialize).EndInit()
        CType(Me.txtCustomerLotNo, System.ComponentModel.ISupportInitialize).EndInit()
        CType(Me.txtMONo, System.ComponentModel.ISupportInitialize).EndInit()
        CType(Me.txtShiftNo, System.ComponentModel.ISupportInitialize).EndInit()
        CType(Me.txtEmployeeNo, System.ComponentModel.ISupportInitialize).EndInit()
        CType(Me.txtAreaNo, System.ComponentModel.ISupportInitialize).EndInit()
        CType(Me.txtPriority, System.ComponentModel.ISupportInitialize).EndInit()
        CType(Me.txtSysUnitNo, System.ComponentModel.ISupportInitialize).EndInit()
        CType(Me.txtSysQty, System.ComponentModel.ISupportInitialize).EndInit()
        CType(Me.txtCurUnitNo, System.ComponentModel.ISupportInitialize).EndInit()
        CType(Me.txtCurQty, System.ComponentModel.ISupportInitialize).EndInit()
        CType(Me.txtOPDescription, System.ComponentModel.ISupportInitialize).EndInit()
        CType(Me.txtLotNo, System.ComponentModel.ISupportInitialize).EndInit()
        CType(Me.SBarPanel1, System.ComponentModel.ISupportInitialize).EndInit()
        CType(Me.SBarPanel2, System.ComponentModel.ISupportInitialize).EndInit()
        CType(Me.SBarPanel3, System.ComponentModel.ISupportInitialize).EndInit()
        CType(Me.SBarPanel4, System.ComponentModel.ISupportInitialize).EndInit()
        CType(Me.txtEquipmentNo, System.ComponentModel.ISupportInitialize).EndInit()
        Me.utpEquipment.ResumeLayout(False)
        Me.uplAttrib.ClientArea.ResumeLayout(False)
        Me.uplAttrib.ResumeLayout(False)
        Me.uplEquipment.ClientArea.ResumeLayout(False)
        Me.uplEquipment.ClientArea.PerformLayout()
        Me.uplEquipment.ResumeLayout(False)
        Me.uplAttrib_Equipment.ClientArea.ResumeLayout(False)
        Me.uplAttrib_Equipment.ResumeLayout(False)
        Me.uplMaterial_KeyIn.ClientArea.ResumeLayout(False)
        Me.uplMaterial_KeyIn.ResumeLayout(False)
        Me.uplKeyIn.ClientArea.ResumeLayout(False)
        Me.uplKeyIn.ResumeLayout(False)
        Me.uplMaterial.ClientArea.ResumeLayout(False)
        Me.uplMaterial.ResumeLayout(False)
        CType(Me.UltraTabControl1, System.ComponentModel.ISupportInitialize).EndInit()
        Me.UltraTabControl1.ResumeLayout(False)
        Me.uplAll.ClientArea.ResumeLayout(False)
        Me.uplAll.ResumeLayout(False)
        CType(Me.uegMaterial_KeyIn2, System.ComponentModel.ISupportInitialize).EndInit()
        Me.uegMaterial_KeyIn2.ResumeLayout(False)
        Me.UltraExpandableGroupBoxPanel4.ResumeLayout(False)
        Me.UltraPanel4.ClientArea.ResumeLayout(False)
        Me.UltraPanel4.ResumeLayout(False)
        CType(Me.uegAttrib_Equipment, System.ComponentModel.ISupportInitialize).EndInit()
        Me.uegAttrib_Equipment.ResumeLayout(False)
        Me.UltraExpandableGroupBoxPanel2.ResumeLayout(False)
        Me.UltraPanel2.ClientArea.ResumeLayout(False)
        Me.UltraPanel2.ResumeLayout(False)
        Me.UltraTabPageControl3.ResumeLayout(False)
        Me.UltraTabPageControl3.PerformLayout()
        CType(Me.UltraTextEditor1, System.ComponentModel.ISupportInitialize).EndInit()
        CType(Me.UltraTextEditor2, System.ComponentModel.ISupportInitialize).EndInit()
        CType(Me.UltraTabControl2, System.ComponentModel.ISupportInitialize).EndInit()
        Me.UltraTabControl2.ResumeLayout(False)
        Me.ResumeLayout(False)
        Me.PerformLayout()

    End Sub

#End Region

    Private Sub frmBR_L_CI_GEN_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

        Cursor.Current = Cursors.WaitCursor

        Dim editorSettings As New Infragistics.Win.UltraWinEditors.DefaultEditorOwnerSettings
        editorSettings.DataType = GetType(System.DateTime)
        editorSettings.MaskInput = "yyyy/mm/dd hh:mm:ss"
        editor = New Infragistics.Win.DateTimeEditor(New Infragistics.Win.UltraWinEditors.DefaultEditorOwner(editorSettings))

        vlMaterialLevel = COM_Utility.ValueListProvider.GetInstance.GetValueList("TBLWIPTEMP_MATERIAL", "MATERIALLEVEL")

        vlTestData21703 = COM_Utility.ValueListProvider.GetInstance.GetValueList("TBLCUSTOMTESTDATA21703B", "ISSELECT")

        btnConfirm.Enabled = False
        btnMultiUser.Enabled = False

        '2017/11/06 KunYuan：變更開始加工時間checkbox預設不勾選
        chkUpdCheckInTime.Checked = False

        If LotNo = defString Or UserId = defString Then
            iMESExceptionManager.ExceptionManager.iMESMsgBoxShowDialog(ChgTranslateName_Msg("0000-200001", "[%LotNo%] [%or%] [%UserId%] [%CANNOTBEEMPTY%]"), MsgBoxStyle.Exclamation, Me.Text)
            Exit Sub
        End If

        ' 2016/01/05 YF, 左下角的時間預設為AP SERVER的時間
        Me.datEventTime = funGetAPServerTime()

        '1.取出生產批資訊 --------------------------------------------------------------------------------------------
        If funLoadLotState() Then Exit Sub

        If blnByEQP = True Then
            txtMaterialNo.Enabled = False
            txtMaterialLotNo.Enabled = False
        End If

        If dsWIP.Tables(tblLotState).Rows.Count = 0 Then
            iMESExceptionManager.ExceptionManager.iMESMsgBoxShowDialog(ChgTranslateName_Msg("0000-200003", "[%LotNo%]"), MsgBoxStyle.Exclamation, Me.Text)
            Exit Sub
        End If
        If funGetShift() Then Exit Sub
        If funLoadTemp_AttribJoinBasis() Then Exit Sub
        If funLoadTemp_Material() Then Exit Sub

        txtLotNo.Text = LotNo
        txtEmployeeNo.Text = UserId
        Call funLotInfo_Show()

        '自己添加20240118
        Call funLoadCustomTestData()

        Call funAddValueList_CustomTestData()


        '2.機台 -------------------------------------------------------------------------------------------------------

        '2023/07/25會議結論， 規格書規畫尚不清晰，此項目註解。
        '0138119: [6.0.7]recipe配方管理优化派工--配方关联设定, 2023/07/20, 19245
        'Dim intAvailable As Integer
        'If funGetSysParameter("RMS TYPE") = "0" Then '使用舊版設備配件
        'intAvailable = funLoadAvailableEquipment(LotNo)
        'Else '使用設備配方
        '    intAvailable = funLoadAvailableEquipmentInfo(LotNo)
        'End If

        'If intAvailable < 0 Then
        If funLoadAvailableEquipment(LotNo) < 0 Then
            Call btnClose_Click(sender, e) '清除trigger OP紀錄
            Me.Dispose()
            Exit Sub
        Else
            If EquipmentNo = defString Then
                dsWIP.Tables(tblAreaEquipment).DefaultView.Sort = "EquipmentType, EquipmentNo"
            Else '有指定機台,要強制使用.
                Dim drSel As DataRow()
                drSel = dsWIP.Tables(tblAreaEquipment).Select("EquipmentNo='" & EquipmentNo & "'")
                If drSel.Length = 0 Then
                    iMESExceptionManager.ExceptionManager.iMESMsgBoxShowDialog(ChgTranslateName_Msg("0000-203072", "[%EquipmentNo%]:" & EquipmentNo & " [%is not in area%]:" & txtAreaNo.Text & "!"), MsgBoxStyle.Exclamation, Me.Text)
                    Call btnClose_Click(sender, e) '清除trigger OP紀錄
                    Me.Dispose()
                    Exit Sub
                Else
                    If drSel(0)("AllowExecute") = 1 Then '可使用

                        drSel(0).BeginEdit()
                        drSel(0)("CheckFlag") = True
                        If LoadPort <> defInteger Then drSel(0)("LoadPort") = LoadPort
                        drSel(0).EndEdit()
                        '強制使用機台,故不提供此功能
                        txtEquipmentNo.Enabled = False
                    Else '不可使用
                        iMESExceptionManager.ExceptionManager.iMESMsgBoxShowDialog(ChgTranslateName_Msg("0000-203072", "[%EquipmentNo%]:" & EquipmentNo & " [%is not available%] " & drSel(0)("Description")), MsgBoxStyle.Exclamation, Me.Text)
                        Call btnClose_Click(sender, e) '清除trigger OP紀錄
                        Me.Dispose()
                        Exit Sub
                    End If
                End If
                drSel = Nothing
            End If
            iugEquipment.iMESUltraGrid.DataSource = dsWIP.Tables(tblAreaEquipment)

            'Modify on 2008/03/31 By OwenLiu, Auto Focus Assign EquipmentNo
            If Not EquipmentNo.Equals(defString) Then
                Dim ugrRow As Infragistics.Win.UltraWinGrid.UltraGridRow
                ugrRow = FindRecordPosition(iugEquipment, "EquipmentNo", EquipmentNo)
                If Not ugrRow Is Nothing Then
                    iugEquipment.iMESUltraGrid.ActiveRow = ugrRow
                End If
            End If

            '2021/3/18,Ning,點檢表檢查方式已調整, 不需在此帶入點檢類型
            ' 查詢可用設備，是否有指定點檢表，並將點檢表點檢類型帶入
            'Call funQueryEquipmentQCList()

            '20091006 seam 
            Call Me.funLoadSubOP()

        End If

        '3.生產參數 -------------------------------------------------------------------------------------------------------
        If Not dsWIP.Tables(tblTAttrib) Is Nothing Then
            '轉換抽樣參數
            If funGetSampleData() Then Exit Sub
            dsWIP.Tables(tblTAttrib).DefaultView.RowFilter = "AttribSource <> 0 And AttribSource <> 1 And (AttribPhase = " & PhaseNo & " Or AttribPhase = 99)"   'Source = Not KeyIn, Not Calculate ,Current and All Phase
            iugAttrib.iMESUltraGrid.DataSource = dsWIP.Tables(tblTAttrib).DefaultView
        End If

        '4.KeyIn Attrib ----------------------------------------------------------------------------------------------------
        If Not dsWIP.Tables(tblTAttrib) Is Nothing Then
            dtKeyIn = New DataTable("KeyIn")
            dtKeyIn.DefaultView.AllowNew = False
            dtKeyIn.DefaultView.AllowDelete = False
            dtKeyIn.DefaultView.AllowEdit = True
            '建立KeyIn Table的欄位
            dtKeyIn.Columns.Add("AttribNo", System.Type.GetType("System.String"))
            dtKeyIn.Columns.Add("AttribName", System.Type.GetType("System.String"))
            dtKeyIn.Columns.Add("AttribValue", System.Type.GetType("System.String"))
            dtKeyIn.Columns.Add("AttribSequence", System.Type.GetType("System.Int32"))
            dtKeyIn.Columns.Add("InputType", System.Type.GetType("System.Int32"))
            dtKeyIn.Columns.Add("DataType", System.Type.GetType("System.Int32"))
            dtKeyIn.Columns.Add("ValueType", System.Type.GetType("System.Int32"))
            dtKeyIn.Columns.Add("QCItemNo", System.Type.GetType("System.String"))    '2015-12-18, Joe, Add
            dtKeyIn.Columns.Add("OrgAttribValue", GetType(String))

            '取出KeyIn Attrib
            For Each dr As DataRow In dsWIP.Tables(tblTAttrib).Rows
                '將資料存入KeyIn Table
                If dr("AttribSource") = 0 AndAlso (dr("AttribPhase") = PhaseNo OrElse dr("AttribPhase") = 99) Then
                    drAdd = dtKeyIn.NewRow()
                    drAdd("AttribNo") = dr("AttribNo")
                    drAdd("AttribName") = dr("AttribName").ToString
                    drAdd("AttribSequence") = dr("AttribSequence")
                    drAdd("AttribValue") = dr("AttribValue")
                    drAdd("InputType") = dr("InputType")
                    drAdd("DataType") = dr("DataType")
                    drAdd("ValueType") = dr("ValueType")
                    drAdd("QCItemNo") = dr("QCItemNo")   '2015-12-18, Joe, Add
                    drAdd("OrgAttribValue") = dr("OrgAttribValue")   ' 2016/01/27 YF, 未轉換函式的特性值
                    dtKeyIn.Rows.Add(drAdd)
                End If
            Next

            iugKeyIn.iMESUltraGrid.DataSource = dtKeyIn.DefaultView

        End If

        '5.物料 -----------------------------------------------------------------------------------------------------------
        If Not dsWIP.Tables(tblTMaterial) Is Nothing Then
            '获取当前工单的物料清单 新设备上料14278
            Call funLoadMOMaterialList(txtMONo.Text, txtOPNo.Text)

            'Kevin 2013/1/2,加入替代料處理
            Dim drData As DataRow
            Dim drSelMaterialNo As DataRow()
            For i As Integer = dsWIP.Tables(tblTMaterial).Rows.Count - 1 To 0 Step -1
                '取得用料清單
                If funLoadSubstituteMaterial_Main(dsWIP.Tables(tblTMaterial).Rows(i)("LotNo"), dsWIP.Tables(tblTMaterial).Rows(i)("MaterialNo"), dsWIP.Tables(tblTMaterial).Rows(i)("UnitNo")) < 0 Then Exit Sub
                For Each dr As DataRow In dsWIP.Tables(tblSubstituteMaterial).Rows
                    drSelMaterialNo = dsWIP.Tables(tblTMaterial).Select("MaterialNo = '" & dr("MaterialNo") & "' And OrgMaterialNo = '" & dr("OrgMaterialNo") & "'")
                    If drSelMaterialNo.Length = 0 Then
                        drData = dsWIP.Tables(tblTMaterial).NewRow
                        drData("OrgMaterialNo") = dsWIP.Tables(tblTMaterial).Rows(i)("MaterialNo")     '紀錄原來的主物料
                        drData("MaterialNo") = dr("MaterialNo")
                        drData("MaterialType") = dr("SubstituteMaterialType")
                        drData("MaterialLevelShow") = dr("SubstituteMaterialLevel")
                        drData("CheckLotNo") = dr("CheckLotNo")
                        drData("PutInPlaceType") = dr("SubstitutePutInPlaceType")
                        drData("StdQty") = dr("SubstituteStdQty")
                        drData("StdUseQty") = Format(dsWIP.Tables(tblLotState).Rows(0)("CurQty") * dr("SubstituteStdQty") * (1 + dsWIP.Tables(tblTMaterial).Rows(i)("DecreaseRate")), "0.######")
                        drData("DecreaseRate") = dsWIP.Tables(tblTMaterial).Rows(i)("DecreaseRate")
                        drData("UnitNo") = dsWIP.Tables(tblTMaterial).Rows(i)("UnitNo")
                        dsWIP.Tables(tblTMaterial).Rows.Add(drData)
                    End If
                Next
            Next

            '產生MaterilaLotNo暫存表
            dtTmpMTLLotNo = New DataTable("TmpMTLLotNo")
            dtTmpMTLLotNo.Columns.Add("EquipmentNo", System.Type.GetType("System.String"))
            dtTmpMTLLotNo.Columns.Add("OrgMaterialNo", System.Type.GetType("System.String"))
            dtTmpMTLLotNo.Columns.Add("MaterialNo", System.Type.GetType("System.String"))
            dtTmpMTLLotNo.Columns.Add("SUBSTITUTEMATERIALNO", System.Type.GetType("System.String"))
            dtTmpMTLLotNo.Columns.Add("MaterialLotNo", System.Type.GetType("System.String"))
            dtTmpMTLLotNo.Columns.Add("Qty", System.Type.GetType("System.Decimal"))
            dtTmpMTLLotNo.Columns("Qty").DefaultValue = 0
            dsWIP.Tables.Add(dtTmpMTLLotNo)
            tblTmpMTLLotNo = "TmpMTLLotNo"
            dsWIP.Tables(tblTmpMTLLotNo).DefaultView.Sort = "MaterialLotNo"

            'Data(Relation)
            Dim parentCol(0) As DataColumn
            Dim childCol(0) As DataColumn
            parentCol(0) = dsWIP.Tables(tblTMaterial).Columns("MaterialNo")
            childCol(0) = dsWIP.Tables(tblTmpMTLLotNo).Columns("OrgMaterialNo")
            '建立主從關係(RelationName會影響WinForm資料的顯示)

            Dim tmpRe1 As DataRelation
            tmpRe1 = New DataRelation("MTLLotNo", parentCol, childCol, False)
            dsWIP.Relations.Add(tmpRe1)

            iugMaterial.iMESUltraGrid.DataSource = dsWIP.Tables(tblTMaterial)
            iugMaterial.iMESUltraGrid.Rows.ExpandAll(True)
        End If

        '6.OP Description--------------------------------------------------------------------------------------------------
        If funGetOPDescription(LotNo) Then Exit Sub

        '多人加上
        If funMultiUser() < 0 Then Exit Sub

        '7.Initialize
        Call funInitialize()

        '2019/09/06 Eric 取出系統參數GumMaterialType 哪些物料是屬於固晶膠類
        Dim strGumMaterialType As String = funLoadParameter("GumMaterialType")
        blnGumMaterialType = (strGumMaterialType <> "")
        aryGumMaterialType = If((strGumMaterialType <> ""), Split(strGumMaterialType, ","), {})

        Call funLoadAllMaterialLot()

        '8.語系切換
        Call ExeChangeResource(Me, gLanguageMode)

        txtEquipmentNo.Focus()
        btnSWR.Visible = False

        '判斷系統參數EnableSWR_CICO 0:否 1:是
        Dim strEnableSWR_CICO As String = funLoadParameter("EnableSWR_CICO")
        If strEnableSWR_CICO = "1" Then           '系統參數EnableSWR_CICO為1才需要顯示特殊生產需求

            '2019/02/12 Eric 無資料不顯示SWR視窗
            Call funLoadSWRJoinLog()
            If dsWIP.Tables(tblSWRJoinLog).Rows.Count > 0 Then

                blnShowSWR = True

                Dim Parameters As New Dictionary(Of String, Object)
                Parameters.Add("MONo", txtMONo.Text)
                Parameters.Add("CustomerLotNo", txtCustomerLotNo.Text)
                Parameters.Add("OPNo", txtOPNo.Text)
                Parameters.Add("LotNo", txtLotNo.Text)
                Parameters.Add("DeviceNo", dsWIP.Tables(tblLotState).Rows(0)("DeviceNo").ToString)
                Parameters.Add("CustomerNo", dsWIP.Tables(tblLotState).Rows(0)("CustomerNo").ToString)
                Parameters.Add("LogGroupSerial", dsWIP.Tables(tblLotState).Rows(0)("LogGroupSerial").ToString)
                Parameters.Add("blnCICo", True)
                Me.ObjectFileHandler.Execute("WP_SWRBasisRead", Parameters)

            End If

            btnSWR.Visible = True

        End If

        ExeGroupControlPriv(Me, PrivFunNo)
        Cursor.Current = Cursors.Default

    End Sub

    Private Sub frmBR_L_CI_GEN_Activated(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Activated

        txtEquipmentNo.Focus()

    End Sub

    Private Sub frmBR_L_CI_GEN_Closing(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles MyBase.Closing

        If Not dsWIP Is Nothing Then dsWIP.Dispose()
        If Not dtKeyIn Is Nothing Then dtKeyIn.Dispose()

        '2019/12/17 OwenLiu, Mantis:0063698, 修正強制關閉企業邏輯，未正確執行ReverseTriggerOP的問題
        'Call ExeReverseTriggerOP(UserId, LotNo, RevLotSerial, RevLotStamp)
        '2020/3/17,Ning,不啟用Reverse時的ReverseTriggerOP
        Call ExeReverseTriggerOP_NotUseUndo(UserId, LotNo, RevLotSerial, RevLotStamp)
    End Sub


#Region "Button Events"

    Private Sub btnQCList_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnQCList.Click

        If Not dsWIP.Tables(tblAreaEquipment).Rows.Count > 0 Then
            Exit Sub
        End If

        'Modify on 2008/03/31, By OwenLiu, 

        '先取得Actve Row
        Dim drSel() As DataRow
        drSel = funGetActiveRows()

        If drSel Is Nothing Then Exit Sub

        '檢查設備是否可使用
        If drSel(0)("AllowExecute") <> 1 Then
            iMESExceptionManager.ExceptionManager.iMESMsgBoxShowDialog(ChgTranslateName_Msg("0000-203064", "[%Equipment%]"), MsgBoxStyle.Exclamation, Me.Text)
            Exit Sub
        End If

        '檢查是否有定義機台點檢表
        If drSel(0)("QCListNo") Is DBNull.Value Then
            iMESExceptionManager.ExceptionManager.iMESMsgBoxShowDialog(ChgTranslateName_Msg("0000-203072", "[%QCListNo%]"), MsgBoxStyle.Exclamation, Me.Text)
            Exit Sub
        End If

        '檢查是否有被勾選
        If Not drSel(0)("CheckFlag") Then
            iMESExceptionManager.ExceptionManager.iMESMsgBoxShowDialog(ChgTranslateName_Msg("0000-103010", "[%Please select%] [%Equipment%]"), MsgBoxStyle.Exclamation, Me.Text)
            Exit Sub
        End If

        '檢查是否已點檢完成
        If Not drSel(0)("QCFinish") Is DBNull.Value Then
            iMESExceptionManager.ExceptionManager.iMESMsgBoxShowDialog(ChgTranslateName_Msg("0000-203072", "[%Equipment%] [%FINISHED%]"), MsgBoxStyle.Exclamation, Me.Text)
            Exit Sub
        End If

        '自動開立點檢務單
        Call funCheckEQPQCTask(drSel(0)("EquipmentNo"))

        '開始處理設備點檢
        ' 2016/08/30 YF, 不直接參考改用invoke叫用 
        Me.ObjectFileHandler.Execute(pObjectID:="WP_EQPCheckQCList",
                                     pParameters:=Nothing,
                                     pArgs:=New Object() {
                                     drSel(0)("EquipmentNo"), LotNo, LotSerial, LogGroupSerial})

    End Sub

    Private Sub btnConfirm_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnConfirm.Click

        Dim strResult As String

        Cursor.Current = Cursors.WaitCursor

        '1.基本檢查----------------------------------------------------------------------------------------------------------
        Dim drSel() As DataRow
        Dim drSelAcc As DataRow()
        If dsWIP.Tables(tblAreaEquipment).Rows.Count > 0 Then
            drSel = dsWIP.Tables(tblAreaEquipment).Select("AllowExecute=1")
            If drSel.Length = 0 Then
                iMESExceptionManager.ExceptionManager.iMESMsgBoxShowDialog(ChgTranslateName_Msg("0000-203064", "[%Equipment%]"), MsgBoxStyle.Exclamation, Me.Text)
                GoTo lblExitProcedure
            Else
                drSel = dsWIP.Tables(tblAreaEquipment).Select("CheckFlag=" & True)
                If drSel.Length = 0 Then
                    iMESExceptionManager.ExceptionManager.iMESMsgBoxShowDialog(ChgTranslateName_Msg("0000-103010", "[%Please select%] [%Equipment%]"), MsgBoxStyle.Exclamation, Me.Text)
                    GoTo lblExitProcedure
                Else
                    '檢查所有勾選的設備是否完成設備點檢
                    For i As Integer = 0 To drSel.Length - 1
                        '2021/3/17,Ning,87547: [6.0.5] 設備點檢支援可設定頻率_生產批進站設備點檢查核調整
                        Call funCheckEQPQCList(drSel(i)("EquipmentNo"), strResult)
                        If strResult <> "success" Then
                            '有設備未完成點檢
                            iMESExceptionManager.ExceptionManager.iMESMsgBoxShowDialog(ChgTranslateName_Msg("0000-103011", "[%EQP QCList OnLine Check%]" & vbCrLf & strResult & vbCrLf & "[%has not been completed%]"), MsgBoxStyle.Exclamation, Me.Text)
                            GoTo lblExitProcedure
                        End If
                    Next

                    '2013/12/25,Kevin,有顯示模治具才檢查
                    If Not dsWIP.Tables("AccState") Is Nothing Then
                        '如有設定產品-作業站-模治具,則這些模治具都一定要被選
                        If Not dsWIP.Tables("PRDAccessory") Is Nothing Then
                            If dsWIP.Tables("PRDAccessory").Rows.Count > 0 Then
                                Dim drAccState As DataRow()
                                Dim blnPRDAcc As Boolean = False  '是否有產品設定的模治具
                                Dim strAccessoryType As String = ""
                                Dim aryShowAccNo As New ArrayList
                                Dim aryShowAccType As New ArrayList
                                Dim blnAllowExecute As Boolean = True
                                Dim strDesc As String = ""

                                For Each dr As DataRow In drSel
                                    blnPRDAcc = False
                                    strAccessoryType = ""
                                    aryShowAccNo.Clear()
                                    aryShowAccType.Clear()
                                    blnAllowExecute = True
                                    strDesc = ""

                                    drAccState = dsWIP.Tables("AccState").Select("EquipmentNo = '" & dr("EquipmentNo") & "' And Select = True")
                                    If drAccState.Length > 0 Then
                                        '檢查設備是否都有掛產品指定之模治具，相同類別允許掛多個，但至少要有一個
                                        For Each drPRD As DataRow In dsWIP.Tables("PRDAccessory").Rows

                                            '檢查是否是同個模治具類別
                                            If strAccessoryType = drPRD("AccessoryType") Then
                                                If blnPRDAcc Then
                                                    '如果已有產品設定的模治具則跳至下一筆
                                                    GoTo lblAccCheck
                                                End If
                                            Else
                                                '第一個物料類別不判斷blnPRDAcc
                                                If strAccessoryType <> "" Then
                                                    '不同模治具類別時，如果上個模治具類別沒有符合的資料，則此設備不可用
                                                    If blnPRDAcc = False Then
                                                        '只要有一種類別模治具不符合就是False
                                                        blnAllowExecute = False
                                                    End If
                                                End If

                                                '記錄此次模治具類別
                                                strAccessoryType = drPRD("AccessoryType")
                                            End If

                                            If drPRD("AccessoryNo") = "*" Then
                                                '如果模治具編號為*代表只有指定模治具類別
                                                For Each drAcc As DataRow In drAccState
                                                    If drAcc("AccessoryType") = drPRD("AccessoryType") Then
                                                        '有符合的代表有掛指定的模治具類別
                                                        blnPRDAcc = True
                                                        '移除此次加入的類別
                                                        aryShowAccType.Remove(drPRD("AccessoryType"))
                                                        '有符合一筆即可
                                                        GoTo lblAccCheck
                                                    Else
                                                        blnPRDAcc = False
                                                        If Not aryShowAccType.Contains(drPRD("AccessoryType")) Then
                                                            aryShowAccType.Add(drPRD("AccessoryType"))
                                                        End If
                                                    End If
                                                Next
                                            Else
                                                '如果模治具編號不為*代表有指定模治具
                                                For Each drAcc As DataRow In drAccState
                                                    If drAcc("AccessoryType") = drPRD("AccessoryType") AndAlso drAcc("AccessoryNo") = drPRD("AccessoryNo") Then
                                                        '有符合的代表有掛指定的模治具類別
                                                        blnPRDAcc = True
                                                        '移除此次加入的編號
                                                        aryShowAccNo.Remove(drPRD("AccessoryNo"))
                                                        '有符合一筆即可
                                                        Exit For
                                                    Else
                                                        blnPRDAcc = False
                                                        If Not aryShowAccNo.Contains(drPRD("AccessoryNo")) Then
                                                            aryShowAccNo.Add(drPRD("AccessoryNo"))
                                                        End If
                                                    End If
                                                Next
                                            End If
lblAccCheck:
                                        Next

                                        '多判斷一次最後一個類別
                                        If blnPRDAcc = False Then
                                            '只要有一種類別模治具不符合就是False
                                            blnAllowExecute = False
                                        End If

                                        If blnAllowExecute = False Then
                                            If aryShowAccType.Count > 0 Then
                                                strDesc += vbCrLf & "[%AccessoryType%]："
                                                For k As Integer = 0 To aryShowAccType.Count - 1
                                                    strDesc += aryShowAccType(k) & ","
                                                Next
                                                strDesc = strDesc.TrimEnd(",")
                                            End If
                                            If aryShowAccNo.Count > 0 Then
                                                strDesc += vbCrLf & "[%AccessoryNo%]："
                                                For k As Integer = 0 To aryShowAccNo.Count - 1
                                                    strDesc += aryShowAccNo(k) & ","
                                                Next
                                                strDesc = strDesc.TrimEnd(",")
                                            End If

                                            iMESExceptionManager.ExceptionManager.iMESMsgBoxShowDialog(ChgTranslateName_Msg("0000-103010", "[%EquipmentNo%]：" & dr("EquipmentNo") & "[%ISNOTSELECTED%][%Product%][%Setup%][%Accessory%]" & strDesc), MsgBoxStyle.Exclamation, Me.Text)
                                            GoTo lblExitProcedure
                                        End If
                                    Else
                                        '設備沒掛模治具就一定沒有掛設定的必需模治具
                                        iMESExceptionManager.ExceptionManager.iMESMsgBoxShowDialog(ChgTranslateName_Msg("0000-103010", "[%EquipmentNo%]：" & dr("EquipmentNo") & "[%ISNOTSELECTED%][%Accessory%]"), MsgBoxStyle.Exclamation, Me.Text)
                                        GoTo lblExitProcedure
                                    End If
                                Next
                            End If
                        End If
                    End If
                End If
            End If
        End If

        If funGetSysParameter("CIMTLDBCheck") = "1" Then
            If dsWIP.Tables(tblTMaterial).Rows.Count > 0 Then
                If Not funCheckMTL() Then GoTo lblExitProcedure
            End If
        End If

        '2023/06/07 ,0135702: [6.0.7] SDD220425_01-03_進站設備派工查核調整,19245
        Try
            Dim strEQP As String = ""
            For Each dr As DataRow In dsWIP.Tables(tblAreaEquipment).Select("CheckFlag=" & True)
                strEQP += dr("EquipmentNo").ToString() & ","
            Next
            If (strEQP <> "") Then
                strEQP = strEQP.TrimEnd(",")
            Else
                strEQP = defString
            End If
            Call ChkCIEQPDispatch(strEQP, txtLotNo.Text)

            Dim showMSG As String = ""
            Dim arrayMsg As New ArrayList
            If Not IsNothing(dsEQP) Then
                For i = 0 To dsEQP.Tables.Count - 1
                    If dsEQP.Tables(i).Rows.Count > 0 Then
                        For Each drEQP As DataRow In dsEQP.Tables(i).Rows
                            If drEQP("Result").ToString <> "Success" Then
                                arrayMsg.Add(ChgTranslateName_Content(drEQP("Description").ToString))
                            End If
                        Next
                    End If
                Next
                If arrayMsg.Count > 0 Then
                    If funGetSysParameter("LotEQPDispatchLimit") = "1" Then '進站是否卡控生產批派工 參數為1
                        '是否確定執行?
                        For i As Integer = 0 To arrayMsg.Count - 1
                            showMSG += arrayMsg(i).ToString() & vbCrLf
                        Next
                        If iMESExceptionManager.ExceptionManager.iMESMsgBoxShowDialog(ChgTranslateName_Msg("0000-100004", showMSG), MsgBoxStyle.OkCancel + MsgBoxStyle.Question + MsgBoxStyle.DefaultButton2, Me.Text) = MsgBoxResult.Cancel Then
                            GoTo lblExitProcedure
                        End If
                    Else
                        '進站失敗，失敗原因:不滿足規則xx
                        showMSG = ChgTranslateName_Content("[%CHECK IN FAILED%], [%REASONS FOR FAILURE%]: [%Failure to meet rules%] " & vbCrLf)
                        For i As Integer = 0 To arrayMsg.Count - 1
                            showMSG += arrayMsg(i).ToString() & vbCrLf
                        Next
                        iMESExceptionManager.ExceptionManager.iMESMsgBoxShowDialog(ChgTranslateName_Content(showMSG), MsgBoxStyle.Critical, Me.Text)
                        GoTo lblExitProcedure
                    End If
                End If
            End If
        Catch ex As iMESException.MESException
            ExceptionManager.iMESShowDialog(ex.ErrorCode, ex.Message, ex.StackTrace)
        Catch ex As Exception
            ExceptionManager.iMESShowDialog(defWinErrCode, ex.Message, ex.StackTrace)
        Finally
        End Try


        '2020/02/26 Grace Mantis 67753 取得此批號於此作業站上的派工資料
        Call funLoadWIPEQPDispatchState(LotNo:=LotNo, OPNo:=txtOPNo.Text)

        If Not IsNothing(dsTemp.Tables(tblEQPDispatchState)) Then
            If dsTemp.Tables(tblEQPDispatchState).Rows.Count > 0 Then
                Dim aryMsg As New ArrayList
                Dim strCheckInDate As String = Now.ToString("yyyy/MM/dd") 'Check In 日期
                If chkUpdCheckInTime.Checked Then strCheckInDate = dtpcheckintime.Value.ToString("yyyy/MM/dd")

                '2020/03/02 Grace Mantis 67753, 68192 檢查所選擇的設備是否有相符的派工資料
                For Each dr As DataRow In dsWIP.Tables(tblAreaEquipment).Select("CheckFlag=" & True)

                    '1. 檢查是否有派工設備
                    Dim drSelEQP As DataRow() = dsTemp.Tables(tblEQPDispatchState).Select("EquipmentNo = '" & dr("EquipmentNo").ToString() & "'")
                    If drSelEQP.Count > 0 Then
                        '1-2. 有派工設備, 檢查派工設備的派工日期是否符合
                        Dim iCount As Integer = 0
                        Dim strDisDate As String = ""
                        For Each dr2 As DataRow In dsTemp.Tables(tblEQPDispatchState).Select("EquipmentNo = '" & dr("EquipmentNo").ToString() & "'", "DispatchOrder")
                            If Convert.ToDateTime(dr2("DispatchDate")).ToString("yyyy/MM/dd") = strCheckInDate Then
                                iCount += 1
                                Exit For
                            Else
                                If strDisDate = "" Then strDisDate = Convert.ToDateTime(dr2("DispatchDate")).ToString("yyyy/MM/dd")
                            End If
                        Next

                        If iCount > 0 Then
                            '1-2-1. 派工日期符合, 不顯示訊息
                        Else
                            '1-2-2. 派工日期不符合, 顯示訊息
                            '選擇的設備於[checkin日期]未派工, 設定的派工日期為[DispatchDate]
                            aryMsg.Add(ChgTranslateName_Content("[%EQUIPMENTNO%]:" & dr("EquipmentNo").ToString() & ", [%SelectedEQPAt%]" & strCheckInDate & "[%NoDispatch%], [%ActualDispatchDate%]" & strDisDate))
                        End If
                        '2020/11/05 Mantis:0081316:納標調整，派工順序卡控
                        If dr("DispatchOrder").ToString <> "1" Then
                            aryMsg.Add(ChgTranslateName_Content("[%EQUIPMENTNO%]:" & dr("EquipmentNo").ToString() & ", [%DispatchOrder is not top priority%]"))
                            'MsgBox(ChgTranslateName_Msg("0000-103010", "[%EquipmentNo%]：" & dr("EquipmentNo") & "[%DispatchOrder is not top priority%]"), MsgBoxStyle.Exclamation, Me.Text)
                            'GoTo lblExitProcedure
                        End If
                    Else
                        '1-3. 沒有派工設備, 檢查是否有符合的派工日期
                        Dim iCount As Integer = 0
                        Dim strEQPNo As String = ""
                        For Each dr4 As DataRow In dsTemp.Tables(tblEQPDispatchState).Rows
                            If Convert.ToDateTime(dr4("DispatchDate")).ToString("yyyy/MM/dd") = strCheckInDate Then
                                '若派工日期相符的設備資料並未勾選, 才顯示訊息
                                If dsWIP.Tables(tblAreaEquipment).Select("CheckFlag=" & True & " And EquipmentNo = '" & dr4("EquipmentNo") & "'").Count = 0 Then
                                    iCount += 1
                                    strEQPNo = dr4("EquipmentNo")
                                    Exit For
                                End If
                            End If
                        Next

                        If iCount > 0 Then
                            '1-3-1. 派工日期符合, 顯示訊息
                            '選擇的設備與派工設備不同
                            aryMsg.Add(ChgTranslateName_Content("[%EQUIPMENTNO%]:" & dr("EquipmentNo").ToString() & ", " & "[%SelectedEQPDispatchNotMatch%]!" & vbCrLf & "[%EQPDispatch%]:" & strEQPNo))
                        Else
                            '1-3-2. 派工日期不符合, 顯示訊息
                            '生產批號於作業站上無任何派工資料
                            aryMsg.Add(ChgTranslateName_Content("[%EQUIPMENTNO%]:" & dr("EquipmentNo").ToString() & ", [%AT%][%OP%]: " & txtOPNo.Text & " [%NoDispatchData%]"))
                        End If
                    End If
                Next

                '若有錯誤訊息, 一次顯示
                If aryMsg.Count > 0 Then
                    Dim strMsgMix As String = ""
                    For i As Integer = 0 To aryMsg.Count - 1
                        strMsgMix += aryMsg(i).ToString() & vbCrLf & vbCrLf
                    Next
                    If strMsgMix.Length > 0 Then
                        strMsgMix = strMsgMix & ChgTranslateName_Content("[%Sure2Confirm%]?") '是否確定執行?

                        If iMESExceptionManager.ExceptionManager.iMESMsgBoxShowDialog(ChgTranslateName_Msg("0000-100004", strMsgMix), MsgBoxStyle.OkCancel + MsgBoxStyle.Question + MsgBoxStyle.DefaultButton2, Me.Text) = MsgBoxResult.Cancel Then
                            GoTo lblExitProcedure
                        End If
                    End If
                End If
            Else
                '2020/05/08 Eric 註解派工提示訊息
                ''是否確定 / 生產批號(" & LotNo & ") 於作業站(" & txtOPNo.Text & ") 上無任何派工資料, 是否確定執行?
                'If iMESExceptionManager.ExceptionManager.iMESMsgBoxShowDialog(ChgTranslateName_Msg("0000-100004", "[%LOTNO%](" & LotNo & ") [%AT%][%OP%](" & txtOPNo.Text & ") [%NoDispatchData%], [%Sure2Confirm%]?"), MsgBoxStyle.OkCancel + MsgBoxStyle.Question + MsgBoxStyle.DefaultButton2, Me.Text) = MsgBoxResult.Cancel Then
                '    GoTo lblExitProcedure
                'End If
            End If
        Else
            '2020/05/08 Eric 註解派工提示訊息
            ''是否確定 / 生產批號(" & LotNo & ") 於作業站(" & txtOPNo.Text & ") 上無任何派工資料, 是否確定執行?
            'If iMESExceptionManager.ExceptionManager.iMESMsgBoxShowDialog(ChgTranslateName_Msg("0000-100004", "[%LOTNO%](" & LotNo & ") [%AT%][%OP%](" & txtOPNo.Text & ") [%NoDispatchData%], [%Sure2Confirm%]?"), MsgBoxStyle.OkCancel + MsgBoxStyle.Question + MsgBoxStyle.DefaultButton2, Me.Text) = MsgBoxResult.Cancel Then
            '    GoTo lblExitProcedure
            'End If
        End If

        Dim strMTLLot As String = ""
        For Each dr As DataRow In dsWIP.Tables(tblTmpMTLLotNo).Rows
            strMTLLot += CombineXMLValueTag(CombineXMLValue("materialno", dr("MaterialNo")) &
                       CombineXMLValue("materiallotno", dr("MaterialLotNo")))
        Next

        '2.格式化資料Attrib-----------------------------------------------------------------------------------------------
        Dim strAttrib As String = ""
        Dim strTemp As String

        If Not dsWIP.Tables(tblTAttrib) Is Nothing Then
            dsWIP.Tables(tblTAttrib).DefaultView.RowFilter = "(AttribPhase = " & PhaseNo & " or AttribPhase = 99) And AttribSource <> 0"              'CurPhase & All的所有Attrib,除了KeyIn
            For i As Integer = 0 To dsWIP.Tables(tblTAttrib).DefaultView.Count - 1
                strTemp = CombineXMLValue("attribno", CInput(dsWIP.Tables(tblTAttrib).DefaultView.Item(i)("AttribNo"))) &
                          CombineXMLValue("attribtype", dsWIP.Tables(tblTAttrib).DefaultView.Item(i)("AttribType")) &
                          CombineXMLValue("attribsequence", dsWIP.Tables(tblTAttrib).DefaultView.Item(i)("AttribSequence")) &
                          CombineXMLValue("attribsource", dsWIP.Tables(tblTAttrib).DefaultView.Item(i)("AttribSource")) &
                          CombineXMLValue("attribphase", dsWIP.Tables(tblTAttrib).DefaultView.Item(i)("AttribPhase")) &
                          CombineXMLValue("savetolotpropertyno", CInput(dsWIP.Tables(tblTAttrib).DefaultView.Item(i)("SaveToLotPropertyNo")))
                If IsDBNull(dsWIP.Tables(tblTAttrib).DefaultView.Item(i)("AttribValue")) Then
                    strTemp += CombineXMLValue("attribvalue", "")
                Else
                    strTemp += CombineXMLValue("attribvalue", CInput(dsWIP.Tables(tblTAttrib).DefaultView.Item(i)("AttribValue")))
                End If
                strAttrib += CombineXMLValueTag(strTemp)
            Next
            '還原顯示
            dsWIP.Tables(tblTAttrib).DefaultView.RowFilter = "AttribSource <> 0 And AttribSource <> 1 And (AttribPhase = " & PhaseNo & " or AttribPhase = 99)"    'Source = Not KeyIn, Not Calculate ,CurPhase and All

            'Temp:Attrib_KeyIn
            For i As Integer = 0 To dtKeyIn.Rows.Count - 1
                If IsDBNull(dtKeyIn.Rows(i)("AttribValue")) = True Then
                    dtKeyIn.Rows(i)("AttribValue") = ""
                End If

                ''edit by Zoe,2009/03/17:增加DBNull及Trim的比對
                ''If dtKeyIn.Rows(i)("AttribValue") = "" Then
                'R1102001 改由ChkControlRule時才判斷 By Acer 2011/02/21
                'If IsDBNull(dtKeyIn.Rows(i)("AttribValue")) OrElse Trim(dtKeyIn.Rows(i)("AttribValue")) = "" OrElse dtKeyIn.Rows(i)("AttribValue") = "" Then
                '    iMESExceptionManager.ExceptionManager.iMESMsgBoxShowDialog(ChgTranslateName_Msg("0000-200001", "[%AttribValue%] of [%AttribNo%]:" & dtKeyIn.Rows(i)("AttribNo") & " is empty!!"), MsgBoxStyle.Exclamation, Me.Text)
                '    GoTo lblExitProcedure
                'End If

                drSel = dsWIP.Tables(tblTAttrib).Select("AttribNo='" & dtKeyIn.Rows(i)("AttribNo") & "'")
                If drSel.Length = 0 Then
                    iMESExceptionManager.ExceptionManager.iMESMsgBoxShowDialog(ChgTranslateName_Msg("0000-203010", "[%AttribNo%]:" & dtKeyIn.Rows(i)("AttribNo")), MsgBoxStyle.Exclamation, Me.Text)
                    GoTo lblExitProcedure
                Else
                    strTemp = CombineXMLValue("attribno", CInput(dtKeyIn.Rows(i)("AttribNo"))) &
                            CombineXMLValue("attribtype", drSel(0)("AttribType")) &
                            CombineXMLValue("attribsequence", drSel(0)("AttribSequence")) &
                            CombineXMLValue("attribsource", drSel(0)("AttribSource")) &
                            CombineXMLValue("attribphase", drSel(0)("AttribPhase")) &
                            CombineXMLValue("attribvalue", CInput(dtKeyIn.Rows(i)("AttribValue"))) &
                            CombineXMLValue("savetolotpropertyno", CInput(drSel(0)("SaveToLotPropertyNo")))
                    '2015-12-18, Joe, Add QCItemNo
                    If IsDBNull(drSel(0)("QCItemNo")) Then
                        strTemp += CombineXMLValue("qcitemno", "")
                    Else
                        strTemp += CombineXMLValue("qcitemno", CInput(drSel(0)("QCItemNo")))
                    End If
                    strAttrib += CombineXMLValueTag(strTemp)
                End If
            Next
        End If

        '3.格式化資料Equipment-----------------------------------------------------------------------------------------------
        Dim strEquipment As String = ""

        '只有一筆

        drSel = dsWIP.Tables(tblAreaEquipment).Select("CheckFlag=" & True)
        If dsWIP.Tables(tblLotState).Rows(0)("MaterialOption").ToString = "1" AndAlso drSel.Length > 1 Then
            iMESExceptionManager.ExceptionManager.iMESMsgBoxShowDialog(ChgTranslateName_Msg("0000-103010", "[%MATERIALOPTIONISEQP%], [%Only Support One Equipment To Select%]"), MsgBoxStyle.Exclamation, Me.Text)
            GoTo lblExitProcedure
        End If

        'Modify On 2007/11/30 By OwenLiu, 修正 Equipment 多選後， 仍然只執行第一個設備的Bug
        For i As Integer = 0 To drSel.Length - 1
            If IsDBNull(drSel(i)("LoadPort")) Then
                strEquipment += CombineXMLValueTag(CombineXMLValue("equipmentno", CInput(drSel(i)("EquipmentNo"))))
                If Not ChkWIPEQPConsume(LotNo, CInt(Me.txtCurQty.Text), UserId, drSel(i)("EquipmentNo").ToString) Then GoTo lblExitProcedure
            Else
                If drSel(i)("LoadPort") = -1 Then '代表不選Port.
                    strEquipment += CombineXMLValueTag(CombineXMLValue("equipmentno", CInput(drSel(i)("EquipmentNo"))))
                    If Not ChkWIPEQPConsume(LotNo, CInt(Me.txtCurQty.Text), UserId, drSel(i)("EquipmentNo").ToString) Then GoTo lblExitProcedure
                Else
                    strEquipment += CombineXMLValueTag(
                        CombineXMLValue("equipmentno", CInput(drSel(i)("EquipmentNo"))) &
                        CombineXMLValue("loadport", drSel(i)("LoadPort")))
                    If Not ChkWIPEQPConsume(LotNo, CInt(Me.txtCurQty.Text), UserId, drSel(i)("EquipmentNo").ToString) Then GoTo lblExitProcedure
                End If
            End If
        Next

        '子設備資料
        Dim strEquipmentChamber = String.Empty
        If Not dsWIP.Tables("Chamber") Is Nothing Then
            drSel = dsWIP.Tables("Chamber").Select("SELECT1 = True")
            For Each dr As DataRow In drSel
                strEquipmentChamber += CombineXMLValueTag(
                        CombineXMLValue("equipmentno", CInput(dr("EquipmentNo"))) &
                        CombineXMLValue("belongequipmentno", dr("BelongEquipmentNo")))
            Next
        End If
        '格式化資料Accessory
        Dim strAccessory As String = ""
        If Not dsWIP.Tables("AccState") Is Nothing Then
            drSel = dsWIP.Tables("AccState").Select("Select=" & True)
            If drSel.Length > 0 Then
                For Each drAcc As DataRow In drSel
                    strAccessory += CombineXMLValueTag(
                                    CombineXMLValue("equipmentno", CInput(drAcc("EquipmentNo"))) &
                                    CombineXMLValue("accessoryno", CInput(drAcc("AccessoryNo"))) &
                                    CombineXMLValue("accessoryversion", CInput(drAcc("AccessoryVersion"))) &
                                    CombineXMLValue("accessorytype", CInput(drAcc("AccessoryType"))) &
                                    CombineXMLValue("accumulateqty", drAcc("AccumulateQty")))
                Next
            End If
        End If

        '20240119自己添加_格式化资料CustomInf
        Dim strCustomInf As String = ""
        drSel = dsWIP.Tables(tblCustomTestData).Select("CheckFlag=" & True)
        If drSel.Length > 0 Then
            For Each dr As DataRow In drSel
                strCustomInf += CombineXMLValueTag(
                                    CombineXMLValue("subopno", dr("SubOPNo")))


            Next
        End If


        ' 2016/12/27 YF, 取消舊制多人加工
        '3.多人加工-----------------------------------------------------------------------------------------------
        'Dim strLoginState As String = ""

        'For Each drTmp As DataRow In dtTmpLoginState.Rows
        '    'Kevin,2012/12/18,不取client端的時間作CI時間
        '    If drTmp("CheckInTime").ToString = "" Then
        '        drTmp("CheckInTime") = defDateTime
        '    End If
        '    strLoginState += CombineXMLValueTag(
        '                     CombineXMLValue("userno", CInput(drTmp("UserNo"))) &
        '                     CombineXMLValue("username", CInput(drTmp("UserName"))) &
        '                     CombineXMLValue("checkintime", Format(drTmp("CheckInTime"), "yyyy/MM/dd HH:mm:ss")))
        'Next

        '4.檢查是否允許執行-----------------------------------------------------------------------------------------------
        If ChkLotStamp(LotNo, UserId, dsWIP.Tables(tblLotState).Rows(0)("LotStamp")) < 0 Then GoTo lblExitProcedure

        '5.Control Rule Check --------------------------------------------------------------------------------------------
        Dim strLinkName, strMSG As String
        Dim strMailGroupNo As String = ""
        Dim strRuleNo As String = defString
        Dim intERFType As Integer = defInteger
        Dim dsTestValue As DataSet
        Dim strERFMsg As String

        If ChkControlRule(LotNo, UserId, dsWIP.Tables(tblLotState).Rows(0)("LotStamp"),
            strAttrib, strLinkName, strMSG, strRuleNo, intERFType, strMailGroupNo, , , , dsTestValue) < 0 Then GoTo lblExitProcedure

        '2015-12-17, Joe, Check SPC Contorl
        If funChkSPCControl_Var(LotNo, strAttrib, dsTestValue, strLinkName, intERFType, strERFMsg) < 0 Then GoTo lblExitProcedure
        strERFMsg = ChgTranslateErrorMsg(strERFMsg)

        '若是Hold詢問是否繼續
        If strLinkName = "HOLD" Then
            If iMESExceptionManager.ExceptionManager.iMESMsgBoxShowDialog(ChgTranslateName_Msg("0000-100103", "[%Lot%]"), MsgBoxStyle.DefaultButton2 + MsgBoxStyle.YesNo + MsgBoxStyle.Question, "Hold Inquire") = MsgBoxResult.No Then
                GoTo lblExitProcedure
            End If
        End If

        '6.ExecuteCheckIn ------------------------------------------------------------------------------------------------
        strIdentity = CombineXMLIdentity(gComputerName, UserId, Now)
        strParameter = CombineXMLParameter("lotno", "LotNo", "String", CInput(LotNo), "")
        strParameter += CombineXMLParameter("linkname", "LinkName", "String", CInput(strLinkName), "")
        strParameter += CombineXMLParameter("lotstamp", "LotStamp", "Long", dsWIP.Tables(tblLotState).Rows(0)("LotStamp"), "")
        strParameter += CombineXMLParameter("shiftno", "ShiftNo", "String", CInput(txtShiftNo.Text), "")
        strParameter += CombineXMLParameter("lotrecord", "LotRecord", "String", CInput(txtLotRecord.Text), "")
        'strParameter += CombineXMLParameter("checkintime", "CheckInTime", "String", dtpcheckintime.Value.ToString("yyyy/MM/dd HH:mm:ss"), "")     '2017/11/06 mark by KunYuan：移至下方處理
        strParameter += CombineXMLParameterMultiValue("attrib", "Attrib", "String", strAttrib, "")

        strParameter += CombineXMLParameterMultiValue("equipment", "Equipment", "String", strEquipment, "")
        strParameter += CombineXMLParameterMultiValue("equipmentchamber", "EquipmentChamber", "String", strEquipmentChamber, "")
        strParameter += CombineXMLParameter("ruleno", "RuleNo", "String", CInput(strRuleNo), "") 'Added by Jialing 2011/02/18
        'strParameter += CombineXMLParameterMultiValue("loginstate", "LoginState", "String", strLoginState, "") ' 2016/12/27 YF, 取消舊制多人加工

        '20240119自己添加
        strParameter += CombineXMLParameterMultiValue("custominf", "CustomInf", "String", strCustomInf, "")

        '2017/11/06 KunYuan：當有勾選『變更開始加工時間』，再傳入CheckInTime
        If chkUpdCheckInTime.Checked Then
            strParameter += CombineXMLParameter("checkintime", "CheckInTime", "String", dtpcheckintime.Value.ToString("yyyy/MM/dd HH:mm:ss"), "")
        End If

        '2013/12/25,Kevin,模治具資料有顯示才傳
        If blnGetAccessory Then
            strParameter += CombineXMLParameterMultiValue("accessory", "Accessory", "String", strAccessory, "")
        End If
        '2019/09/06 Eric
        If strMTLLot <> "" Then
            strParameter += CombineXMLParameterMultiValue("temp_materiallot", "Temp_MaterialLot", "String", strMTLLot, "")
        End If



        InXml = CombineXMLRequest(strIdentity, strParameter)
        Try
            '2019/06/20 Lena, Mantis: 0058845 [WIP] CI/CO執行時間紀錄
            '新增參數 LogOn = True, 記錄執行時間.
            OutXml = InvokeSrv("ABC.wsWIP_21703.Exe_CheckIn", InXml, LogOn:=True)


            Dim XmlDoc As New XmlDocument
            XmlDoc.LoadXml(OutXml)
            If ChkExecutionSuccess(XmlDoc) Then  '找出Exception訊並顯示出來
                '成功執行完成,避免再按下一次
                btnConfirm.Enabled = False

                '2017/11/06 KunYuan：變更開始加工時間checkbox預設不勾選
                chkUpdCheckInTime.Checked = False

                If strLinkName <> "HOLD" And strLinkName <> "WAIT" Then
                    iMESExceptionManager.ExceptionManager.iMESMsgBoxShowDialog(ChgTranslateName_Msg("0000-000001", "[%LotNo%]:" & LotNo & " [%Check In%] [%Successfully%]"), MsgBoxStyle.Information, Me.Text)
                End If
            Else
                If GetExceptionCode(XmlDoc) = "IPQCNO" Then
                    'ExceptionManager.iMESShowDialog("0000-103021", GetExceptionSysMsg(XmlDoc), GetExceptionStack(XmlDoc))
                    iMESExceptionManager.ExceptionManager.iMESMsgBoxShowDialog(ChgTranslateName_Msg("0000-200015", GetExceptionSysMsg(XmlDoc)), MsgBoxStyle.Information, Me.Text)
                    Dim Parameters As New Dictionary(Of String, Object)
                    Parameters.Add("defLotNo", LotNo)
                    Me.ObjectFileHandler.Execute("SC_IPQCForm", Parameters)
                Else
                    ExceptionManager.iMESShowDialog(GetExceptionCode(XmlDoc), GetExceptionSysMsg(XmlDoc), GetExceptionStack(XmlDoc))
                End If
                GoTo lblExitProcedure
            End If
            XmlDoc = Nothing

        Catch ex As iMESException.MESException
            ExceptionManager.iMESShowDialog(ex.ErrorCode, ex.Message, ex.StackTrace)
            GoTo lblExitProcedure
        Catch ex As Exception
            ExceptionManager.iMESShowDialog(defWinErrCode, ex.Message, ex.StackTrace)
            GoTo lblExitProcedure
        Finally
        End Try

        Me.Close()

        '7.Mail-------------------------------------------------------------------------------------------------------------
        '以下的執行,不管成功失敗,都讓FormClose,代表此BR已完成

        '2016-12-19 add 取得eSOP參數
        Execute_eSOP = funGetSysParameter("Execute_eSOP")
        If Execute_eSOP = 1 Then
            '讀取eSOP工位及檔案及頁碼
            Call funLoadPRDeSOP()
            '顯示作業指導書
            Call funDisplayProcess()
        End If
        If Execute_eSOP = 2 Then
            '組JSON
            Dim DataString, ResponsetJson As String
            Dim strProductNo, strProductVersion As String
            Try
                strProductNo = txtProductNo.Text
                strProductVersion = dsWIP.Tables(tblLotState).Rows(0)("ProductVersion").ToString
                Dim dic As New Dictionary(Of String, String)
                dic("userid") = gUserNo
                dic("languagemode") = gLanguageMode
                dic("computername") = gComputerName
                Dim Uri = Newtonsoft.Json.JsonConvert.SerializeObject(dic)

                dic = New Dictionary(Of String, String)
                dic("produc_no") = strProductNo
                dic("product_ver") = strProductVersion
                dic("op_no") = txtOPNo.Text
                Dim list As New List(Of String)
                Dim rows As DataRow() = dsWIP.Tables(tblAreaEquipment).Select("CheckFlag=" & True)
                If rows.Length > 0 Then
                    For Each dr As DataRow In dsWIP.Tables(tblAreaEquipment).Select("CheckFlag=" & True)
                        list.Add(dr("EQUIPMENTTYPE"))
                    Next
                    dic("eqp_type") = String.Join(""",""", list)
                Else
                    dic("eqp_type") = Nothing
                End If

                Dim Content = Newtonsoft.Json.JsonConvert.SerializeObject(dic)

                '呼叫EAI GeteSOPInfo_API
                Using wsEAI As New wsEAI.wsEAI
                    ResponsetJson = wsEAI.GeteSOPInfo_API(Uri, Content)
                End Using

                '呼叫WP_eSOPList.dll
                Dim Obj As Newtonsoft.Json.Linq.JObject = Newtonsoft.Json.JsonConvert.DeserializeObject(ResponsetJson)
                Dim dtResponsetJson As DataTable = JsonConvert.DeserializeObject(Of DataTable)(Obj.Item("ResultJson").ToString)
                Dim Parameters As New Dictionary(Of String, Object)
                Parameters.Add("dteSOP", dtResponsetJson)
                Me.ObjectFileHandler.Execute("WP_eSOPList", Parameters)
            Catch ex As iMESException.MESException
                ExceptionManager.iMESShowDialog(ex.ErrorCode, ex.Message, ex.StackTrace)
            End Try
        End If

        If strMailGroupNo <> "" Then
            Call SendEmailToERFGroup_NoneERF(LotNo, UserId, strMailGroupNo, strMSG,
                dsWIP.Tables(tblLotState).Rows(0)("OPNo"), dsWIP.Tables(tblLotState).Rows(0)("OPName"), dsWIP.Tables(tblLotState).Rows(0)("BRNo"))
        End If



        'C3:依LinkName決定是否Transfer Lot----------------------------------------------------------------------------------
        '以下的執行,不管成功失敗,都讓FormClose,代表此BR已完成
        '若再執行Confirm一次則不正確,同一BR會執行多次
        '2015-12-21, Joe, 加ERFMsg
        Call BRTransferLot(LotNo, UserId, strLinkName, intERFType, strRuleNo, , strERFMsg)


        gReturnKeyValue = LotNo


lblExitProcedure:

        Cursor.Current = Cursors.Default
        Exit Sub

    End Sub

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

        Cursor.Current = Cursors.WaitCursor

        Try
            '2019/12/17 OwenLiu, Mantis:0063698, ReverseTriggerOP統一呼叫 WIP_Kit共用函式
            'Call ExeReverseTriggerOP(UserId, LotNo, RevLotSerial, RevLotStamp)

            '2020/3/17,Ning,不啟用Reverse時的ReverseTriggerOP
            '2022/9/19,Ning, 116091: 各BR 在畫面關閉動作執行ReverseTriggerOP，若有執行失敗須把訊息顯示:統一在form_closing時處理
            'Call ExeReverseTriggerOP_NotUseUndo(UserId, LotNo, RevLotSerial, RevLotStamp)

        Catch e1 As Exception
        Finally
            Me.Close()
        End Try

        Cursor.Current = Cursors.Default


    End Sub

    Private Sub btnEQPConsumeReset_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnEQPConsumeReset.Click

        Try

            If Me.iugEquipment.iMESUltraGrid.ActiveRow Is Nothing Then Exit Sub

            ' 2016/08/30 YF, 不直接參考改用invoke叫用 
            Me.ObjectFileHandler.Execute(pObjectID:="WP_EQPConsumeReset",
                                         pParameters:=Nothing,
                                         pArgs:=New Object() {
                                         Me.iugEquipment.iMESUltraGrid.ActiveRow.Cells("EquipmentNo").Value.ToString})

        Catch ex As iMESException.MESException
            ExceptionManager.iMESShowDialog(ex.ErrorCode, ex.Message, ex.StackTrace)
        Catch ex As Exception
            ExceptionManager.iMESShowDialog(defWinErrCode, ex.Message, ex.StackTrace)
        End Try

    End Sub

    Private Sub btnMultiUser_Click(sender As System.Object, e As System.EventArgs) Handles btnMultiUser.Click

        ' 2016/08/30 YF, 不直接參考改用invoke叫用 
        Dim parameters As New Dictionary(Of String, Object)
        parameters.Add("CallType", 1)
        parameters.Add("UserID", UserId)
        parameters.Add("CheckInTime", dtpcheckintime.Value)
        parameters.Add("drLotInfo", dsWIP.Tables(tblLotState).Rows(0))
        parameters.Add("dtTmpLoginState", dtTmpLoginState)
        '2019/10/17 Grace 調整ObjectID 
        Me.ObjectFileHandler.Execute("WP_OperatorLogIn_Lot", parameters)

        dtTmpLoginState = parameters("dtTmpLoginState")

    End Sub


#End Region

    Protected Overrides Sub Finalize()
        MyBase.Finalize()
    End Sub

#Region "Control Enter,KeyPress"

    Private Sub txtLotNo_Enter(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtLotNo.Enter
        txtLotNo.SelectAll()
    End Sub
    Private Sub txtLotNo_KeyPress(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles txtLotNo.KeyPress
        If e.KeyChar = Convert.ToChar(13) Then
            SendKeys.Send("{TAB}")
        End If
    End Sub

    Private Sub txtPriority_Enter(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtPriority.Enter
        txtPriority.SelectAll()
    End Sub
    Private Sub txtPriority_KeyPress(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles txtPriority.KeyPress
        If e.KeyChar = Convert.ToChar(13) Then
            SendKeys.Send("{TAB}")
        End If
    End Sub

    Private Sub txtAreaNo_Enter(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtAreaNo.Enter
        txtAreaNo.SelectAll()
    End Sub
    Private Sub txtAreaNo_KeyPress(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles txtAreaNo.KeyPress
        If e.KeyChar = Convert.ToChar(13) Then
            SendKeys.Send("{TAB}")
        End If
    End Sub

    Private Sub txtCurQty_Enter(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtCurQty.Enter
        txtCurQty.SelectAll()
    End Sub
    Private Sub txtCurQty_KeyPress(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles txtCurQty.KeyPress
        If e.KeyChar = Convert.ToChar(13) Then
            SendKeys.Send("{TAB}")
        End If
    End Sub

    Private Sub txtCurUnitNo_Enter(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtCurUnitNo.Enter
        txtCurUnitNo.SelectAll()
    End Sub
    Private Sub txtCurUnitNo_KeyPress(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles txtCurUnitNo.KeyPress
        If e.KeyChar = Convert.ToChar(13) Then
            SendKeys.Send("{TAB}")
        End If
    End Sub

    Private Sub txtSysQty_Enter(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtSysQty.Enter
        txtSysQty.SelectAll()
    End Sub
    Private Sub txtSysQty_KeyPress(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles txtSysQty.KeyPress
        If e.KeyChar = Convert.ToChar(13) Then
            SendKeys.Send("{TAB}")
        End If
    End Sub

    Private Sub txtSysUnitNo_Enter(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtSysUnitNo.Enter
        txtSysUnitNo.SelectAll()
    End Sub
    Private Sub txtSysUnitNo_KeyPress(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles txtSysUnitNo.KeyPress
        If e.KeyChar = Convert.ToChar(13) Then
            SendKeys.Send("{TAB}")
        End If
    End Sub

    Private Sub txtOPNo_Enter(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtOPNo.Enter
        txtOPNo.SelectAll()
    End Sub
    Private Sub txtOPNo_KeyPress(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles txtOPNo.KeyPress
        If e.KeyChar = Convert.ToChar(13) Then
            SendKeys.Send("{TAB}")
        End If
    End Sub

    Private Sub txtOPDescription_Enter(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtOPDescription.Enter
        txtOPDescription.SelectAll()
    End Sub
    Private Sub txtOPDescription_KeyPress(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles txtOPDescription.KeyPress
        If e.KeyChar = Convert.ToChar(13) Then
            SendKeys.Send("{TAB}")
        End If
    End Sub

    Private Sub txtCustomerLotNo_Enter(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtCustomerLotNo.Enter
        txtCustomerLotNo.SelectAll()
    End Sub
    Private Sub txtCustomerLotNo_KeyPress(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles txtCustomerLotNo.KeyPress
        If e.KeyChar = Convert.ToChar(13) Then
            SendKeys.Send("{TAB}")
        End If
    End Sub

    Private Sub txtMONo_Enter(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtMONo.Enter
        txtMONo.SelectAll()
    End Sub
    Private Sub txtMONo_KeyPress(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles txtMONo.KeyPress
        If e.KeyChar = Convert.ToChar(13) Then
            SendKeys.Send("{TAB}")
        End If
    End Sub

    Private Sub txtEmployeeNo_Enter(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtEmployeeNo.Enter
        txtEmployeeNo.SelectAll()
    End Sub
    Private Sub txtEmployeeNo_KeyPress(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles txtEmployeeNo.KeyPress
        If e.KeyChar = Convert.ToChar(13) Then
            SendKeys.Send("{TAB}")
        End If
    End Sub

    Private Sub txtShiftNo_Enter(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtShiftNo.Enter
        txtShiftNo.SelectAll()
    End Sub
    Private Sub txtShiftNo_KeyPress(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles txtShiftNo.KeyPress
        If e.KeyChar = Convert.ToChar(13) Then
            SendKeys.Send("{TAB}")
        End If
    End Sub

    Private Sub txtLotRecord_Enter(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtLotRecord.Enter
        txtLotRecord.SelectAll()
    End Sub

    Private Sub txtProductNo_Enter(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtProductNo.Enter
        txtProductNo.SelectAll()
    End Sub
    Private Sub txtProductNo_KeyPress(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles txtProductNo.KeyPress
        If e.KeyChar = Convert.ToChar(13) Then
            SendKeys.Send("{TAB}")
        End If
    End Sub

    Private Sub txtMaterialLotNo_Enter(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtMaterialLotNo.Enter, UltraTextEditor2.Enter
        txtMaterialLotNo.SelectAll()
    End Sub

    Private Sub txtMaterialLotNo_KeyPress(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles txtMaterialLotNo.KeyPress, UltraTextEditor2.KeyPress

        Try
            If (e.KeyChar = Convert.ToChar(13)) Then
                funKeyInMaterialLotNo(txtMaterialNo.Text, txtMaterialLotNo.Text)
            End If

        Catch ex As iMESException.MESException
            ExceptionManager.iMESShowDialog(ex.ErrorCode, ex.Message, ex.StackTrace)
        Catch ex As Exception
            ExceptionManager.iMESShowDialog(defWinErrCode, ex.Message, ex.StackTrace)
        End Try

    End Sub
    Private Sub funKeyInMaterialLotNo(ByVal MaterialNo As String, ByVal MaterialLotNo As String)

        Try
            '2020/10/29 Grace 請先輸入物料編號
            If MaterialNo = "" Then
                iMESExceptionManager.ExceptionManager.iMESMsgBoxShowDialog(
                ChgTranslateName_Msg("0000-200005", "[%MaterialNo%]!"), MsgBoxStyle.Exclamation, Me.Text)
                Exit Sub
            End If

            MaterialLotNo = UCase(MaterialLotNo.Trim)
            If MaterialLotNo = "" Then Exit Sub

            If dsWIP.Tables(tblTMaterial).Rows.Count = 0 Then
                iMESExceptionManager.ExceptionManager.iMESMsgBoxShowDialog(
                ChgTranslateName_Msg("0000-103019", "[%Do not need to check%]!"), MsgBoxStyle.Exclamation, Me.Text)
                Exit Sub
            End If

            '相同料批只能加入某一個料，以避免上料錯誤
            '2020/10/29 Grace 依物料編號取得料批
            Dim drCheckMTLLotNo() As DataRow = dsWIP.Tables(tblTmpMTLLotNo).Select(
                "MaterialLotNo ='" & MaterialLotNo & "' And MaterialNo ='" & MaterialNo & "'")

            If drCheckMTLLotNo.Length > 0 Then
                iMESExceptionManager.ExceptionManager.iMESMsgBoxShowDialog(
                ChgTranslateName_Msg("0000-200004", "[%MaterialLotNo%]：" & MaterialLotNo), MsgBoxStyle.Exclamation, Me.Text)
                Exit Sub
            End If

            ' 2016/10/19 YF, 依作業站用料選項取出資料
            Select Case dsWIP.Tables(tblLotState).Rows(0)("MaterialOption").ToString
                Case "0"
                    ' 發料點(線邊倉或工單)
                    If (Not CheckMaterialByPutinPlace(dsWIP.Tables(tblLotState).Rows(0)("MONo").ToString, MaterialLotNo, MaterialNo)) Then
                        Exit Sub
                    End If

                Case "1"
                    ' 設備
                    'If (Not CheckMaterialByEquipment(MaterialLotNo, MaterialNo)) Then
                    '    Exit Sub
                    'End If

                    'Case "2"
                    ' 生產線, 待組裝版再實作

                    'Case "3"
                    ' 工位, 待組裝版再實作

                Case Else
                    iMESExceptionManager.ExceptionManager.iMESMsgBoxShowDialog(
                    ChgTranslateName_Msg("0000-003000", "[%MaterialOption%]：" & dsWIP.Tables(tblLotState).Rows(0)("MaterialOption").ToString &
                    " [%NOT DEFINE%]!"), MsgBoxStyle.Exclamation, Me.Text)
                    Exit Sub
            End Select

        Catch ex As Exception
            Throw ex

        Finally
            txtMaterialLotNo.Text = ""
            txtMaterialNo.Text = ""
            txtMaterialNo.Focus()
        End Try

    End Sub

    Private Sub txtMaterialLotNo_Leave(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtMaterialLotNo.Leave, UltraTextEditor2.Leave
        txtMaterialLotNo.Text = UCase(txtMaterialLotNo.Text)
    End Sub

#End Region

#Region "Ultra Grid"

    Private Sub iugAttrib_iMESUltraGrid_InitializeLayOut(ByVal sender As System.Object, ByVal e As Infragistics.Win.UltraWinGrid.InitializeLayoutEventArgs) Handles iugAttrib.iMESUltraGrid_InitializeLayOut

        Dim i As Integer

        With e.Layout
            For i = 0 To dsWIP.Tables(tblTAttrib).Columns.Count - 1
                Select Case dsWIP.Tables(tblTAttrib).Columns(i).ColumnName.ToUpper
                    Case "ATTRIBNO"
                        With .Bands(tblTAttrib).Columns("AttribNo")
                            .Header.Caption = "AttribNo"
                            .Width = 70
                            .Header.VisiblePosition = 1
                        End With
                    Case "ATTRIBNAME"
                        With .Bands(tblTAttrib).Columns("AttribName")
                            .Header.Caption = "AttribName"
                            .Width = 95
                            .Header.VisiblePosition = 2
                        End With
                    Case "ATTRIBVALUE"
                        With .Bands(tblTAttrib).Columns("AttribValue")
                            .Header.Caption = "AttribValue"
                            .Width = 80
                            .Header.VisiblePosition = 3
                        End With
                    Case "ATTRIBSOURCE"
                        With .Bands(tblTAttrib).Columns("AttribSource")
                            .Header.Caption = "AttribSource"
                            .Width = 65
                            .Header.VisiblePosition = 4
                            .ValueList = iugAttrib.iMESUltraGrid.DisplayLayout.ValueLists("ASource")
                        End With
                    Case Else
                        With .Bands(tblTAttrib).Columns(dsWIP.Tables(tblTAttrib).Columns(i).ColumnName.ToUpper)
                            .Hidden = True
                        End With
                End Select
            Next

        End With

    End Sub

    Private Sub iugAttrib_iMESUltraGrid_InitializeRow(ByVal sender As System.Object, ByVal e As Infragistics.Win.UltraWinGrid.InitializeRowEventArgs) Handles iugAttrib.iMESUltraGrid_InitializeRow

        Dim strAttribValue As String
        strAttribValue = e.Row.Cells("AttribValue").Value.ToString.Trim

        '\\Server\01A.pdf
        If Mid(strAttribValue, 1, 2) = "\\" Then
            e.Row.Cells("AttribValue").Style = ColumnStyle.Button
            e.Row.Cells("AttribValue").Appearance.BackColor = System.Drawing.Color.Pink
        End If

        '\\HTTP
        If Mid(strAttribValue.ToUpper, 1, 4) = "HTTP" Then
            e.Row.Cells("AttribValue").Style = ColumnStyle.Button
            e.Row.Cells("AttribValue").Appearance.BackColor = System.Drawing.Color.Pink
        End If
        '\\HTTPS
        If Mid(strAttribValue.ToUpper, 1, 5) = "HTTPS" Then
            e.Row.Cells("AttribValue").Style = ColumnStyle.Button
            e.Row.Cells("AttribValue").Appearance.BackColor = System.Drawing.Color.Pink
        End If

    End Sub

    Private Sub iugAttrib_iMESUltraGrid_ClickCellButton(ByVal sender As Object, ByVal e As Infragistics.Win.UltraWinGrid.CellEventArgs) Handles iugAttrib.iMESUltraGrid_ClickCellButton

        Cursor.Current = Cursors.WaitCursor

        Dim strFilePath As String

        strFilePath = e.Cell.Row.Cells("AttribValue").Value.ToString.Trim

        If strFilePath = "" Then Exit Sub

        Try
            Dim objProcess As New Process
            objProcess.Start(strFilePath)

        Catch ex As iMESException.MESException
            ExceptionManager.iMESShowDialog(ex.ErrorCode, ex.Message, ex.StackTrace)
        Catch ex As Exception
            ExceptionManager.iMESShowDialog(defWinErrCode, ex.Message, ex.StackTrace)
        End Try

        Cursor.Current = Cursors.Default

    End Sub

    Private Sub iugMaterial_iMESUltraGrid_InitializeLayOut(ByVal sender As System.Object, ByVal e As Infragistics.Win.UltraWinGrid.InitializeLayoutEventArgs) Handles iugMaterial.iMESUltraGrid_InitializeLayOut, IMESUltraGridControl1.iMESUltraGrid_InitializeLayOut

        Dim i As Integer

        With e.Layout
            For i = 0 To dsWIP.Tables(tblTMaterial).Columns.Count - 1
                With .Bands(tblTMaterial).Columns(i)
                    .Hidden = True
                    .Header.VisiblePosition = 99
                End With
            Next
            With .Bands(tblTMaterial).Columns("MaterialLevelShow")
                .Header.Caption = "MaterialLevelShow"
                .Hidden = False
                .CalculateAutoResizeWidth(PerformAutoSizeType.VisibleRows, True)
                .Header.VisiblePosition = 0
                .ValueList = vlMaterialLevel
            End With
            With .Bands(tblTMaterial).Columns("MaterialType")
                .Header.Caption = "MaterialType"
                .Width = 30
                .Hidden = False
                .Header.VisiblePosition = 1
            End With
            With .Bands(tblTMaterial).Columns("MaterialNo")
                .Header.Caption = "MaterialNo"
                .Width = 100
                .Hidden = False
                .Header.VisiblePosition = 2
            End With
            With .Bands(tblTMaterial).Columns("StdUseQty")
                .Header.Caption = "StdUseQty"
                .Width = 70
                .Hidden = False
                .Header.VisiblePosition = 3
                .Format = "0.########"
                .CellAppearance.TextHAlign = Infragistics.Win.HAlign.Right
            End With
            With .Bands(tblTMaterial).Columns("UnitNo")
                .Header.Caption = "UnitNo"
                .Width = 70
                .Hidden = False
                .Header.VisiblePosition = 4
            End With
            With .Bands(tblTMaterial).Columns("MTLLotNoSearch")
                .Header.Caption = ""
                .Width = 40
                .Hidden = blnByEQP
                .Header.VisiblePosition = 5
                .CellAppearance.TextHAlign = Infragistics.Win.HAlign.Center
                '20231106,13871,0148577: Online Help優化建議
                .Tag = New COM_Kit.TagInformation.clsGridColumnTag() With {.UseOnlineHelp = False}
                .Style = ColumnStyle.Button
                .CellAppearance.BackColor = System.Drawing.Color.Pink
                .CellButtonAppearance.BackColor = Color.Pink
                .CellButtonAppearance.BorderColor3DBase = Color.Pink
                .CellButtonAppearance.BackGradientStyle = GradientStyle.Rectangular
            End With

            With .Bands("MTLLotNo").Columns("EquipmentNo")
                If blnByEQP = True Then
                    .Hidden = False
                    .Width = 40
                Else
                    .Hidden = True
                End If
            End With
            With .Bands("MTLLotNo").Columns("OrgMaterialNo")
                .Hidden = True
            End With
            With .Bands("MTLLotNo").Columns("MaterialNo")
                .Hidden = True
            End With
            With .Bands("MTLLotNo").Columns("SUBSTITUTEMATERIALNO")
                .Hidden = False
            End With
            With .Bands("MTLLotNo").Columns("MaterialLotNo")
                .Hidden = False
            End With
            With .Bands("MTLLotNo").Columns("Qty")
                .Hidden = False
                .Format = "0.########"
                .Width = 50
                .CellAppearance.TextHAlign = Infragistics.Win.HAlign.Right
            End With
        End With

    End Sub

    Private Sub iugMaterial_iMESUltraGrid_InitializeRow(ByVal sender As System.Object, ByVal e As Infragistics.Win.UltraWinGrid.InitializeRowEventArgs) Handles iugMaterial.iMESUltraGrid_InitializeRow, IMESUltraGridControl1.iMESUltraGrid_InitializeRow

        If e.Row.Band.Key = tblTMaterial Then
            e.Row.Cells("MaterialLevelShow").Appearance.BackColor = System.Drawing.Color.Pink
            e.Row.Cells("MaterialType").Appearance.BackColor = System.Drawing.Color.Pink
            e.Row.Cells("MaterialNo").Appearance.BackColor = System.Drawing.Color.Pink
            e.Row.Cells("StdUseQty").Appearance.BackColor = System.Drawing.Color.Pink
            e.Row.Cells("UnitNo").Appearance.BackColor = System.Drawing.Color.Pink

            'e.Row.Cells("MTLLotNoSearch").Style = ColumnStyle.Button
            'e.Row.Cells("MTLLotNoSearch").Appearance.BackColor = System.Drawing.Color.Pink
            'e.Row.Cells("MTLLotNoSearch").ButtonAppearance.BackColor = Color.Pink
            'e.Row.Cells("MTLLotNoSearch").ButtonAppearance.BorderColor3DBase = Color.Pink
            'e.Row.Cells("MTLLotNoSearch").ButtonAppearance.BackGradientStyle = GradientStyle.Rectangular
            e.Row.Cells("MTLLotNoSearch").Value = "..."
            e.Row.Update()
        End If

    End Sub

    Private Sub iugMaterial_iMESUltraGrid_ClickCellButton(ByVal sender As Object, ByVal e As Infragistics.Win.UltraWinGrid.CellEventArgs) Handles iugMaterial.iMESUltraGrid_ClickCellButton, IMESUltraGridControl1.iMESUltraGrid_ClickCellButton

        Dim dvData As DataView

        Try
            If iugMaterial.iMESUltraGrid.ActiveRow Is Nothing Then Exit Sub

            Dim MaterialNo As String = iugMaterial.iMESUltraGrid.ActiveRow.Cells("MaterialNo").Value
            Dim drSel() As DataRow = dsWIP.Tables(tblTMaterial).Select("MaterialNo='" & MaterialNo & "'")
            If drSel.Length = 0 Then Exit Sub

            Dim dtMLot As DataTable = dsWIP.Tables(tblTmpMTLLotNo).Copy
            Dim drTMaterial As DataRow = drSel(0)
            Dim parameters As New Dictionary(Of String, Object) From {
                {"drMaterial", drTMaterial},
                {"dtMLot", dtMLot},
                {"blnCheckIn", True}
            }
            Me.ObjectFileHandler.Execute("WP_MaterialQtyInput_Main", parameters)

            drSel = dsWIP.Tables(tblTmpMTLLotNo).Select("OrgMaterialNo='" & MaterialNo & "'")
            For Each dr In drSel
                dr.Delete()
            Next
            dsWIP.Tables(tblTmpMTLLotNo).AcceptChanges()

            dtMLot = parameters("dtMLot")
            For Each drMLot As DataRow In dtMLot.Rows
                drSel = dsWIP.Tables(tblTmpMTLLotNo).Select(
                    "SubstituteMaterialNo='" & drMLot("SubstituteMaterialNo").ToString() & "' And 
                    MaterialLotNo='" & drMLot("MaterialLotNo").ToString() & "'")
                If drSel.Length > 0 Then Continue For

                Dim drAdd As DataRow = dsWIP.Tables(tblTmpMTLLotNo).NewRow
                For Each dcMLot As DataColumn In dtMLot.Columns
                    drAdd(dcMLot.ColumnName) = drMLot(dcMLot.ColumnName).ToString()
                Next
                dsWIP.Tables(tblTmpMTLLotNo).Rows.Add(drAdd)
            Next

        Catch ex As iMESException.MESException
            ExceptionManager.iMESShowDialog(ex.ErrorCode, ex.Message, ex.StackTrace)
        Catch ex As Exception
            ExceptionManager.iMESShowDialog(defWinErrCode, ex.Message, ex.StackTrace)
        End Try

    End Sub

    Private Sub iugEquipment_iMESUltraGrid_InitializeLayOut(ByVal sender As System.Object, ByVal e As Infragistics.Win.UltraWinGrid.InitializeLayoutEventArgs) Handles iugEquipment.iMESUltraGrid_InitializeLayOut

        Dim i As Integer

        Dim colShow As New Collection

        With e.Layout
            'Hide all, No Edit

            'Equipment
            For i = 0 To dsWIP.Tables(tblAreaEquipment).Columns.Count - 1
                Select Case dsWIP.Tables(tblAreaEquipment).Columns(i).ColumnName.ToUpper
                    Case "CHECKFLAG"
                        With .Bands(tblAreaEquipment).Columns("CheckFlag")
                            .Width = 50
                            .Header.VisiblePosition = 1
                            .Style = Infragistics.Win.UltraWinGrid.ColumnStyle.CheckBox
                            .CellAppearance.BackColor = System.Drawing.Color.White
                        End With
                    Case "EQUIPMENTNO"
                        With .Bands(tblAreaEquipment).Columns("EquipmentNo")
                            .Width = 100
                            .Header.VisiblePosition = 2
                            .CellActivation = Infragistics.Win.UltraWinGrid.Activation.ActivateOnly
                            .TabStop = False
                        End With
                    Case "EQUIPMENTNAME"
                        '[Mantis:80651]2020/10/27,Boyi,EquipmentDescription  => EquipmentName
                        ' dsWIP.Tables(tblAreaEquipment).Columns("EquipmentName").ColumnName = "EquipmentDescription"
                        With .Bands(tblAreaEquipment).Columns("EquipmentName")
                            .Header.Caption = "EquipmentName"
                            .Width = 150
                            .Header.VisiblePosition = 3
                            .CellActivation = Infragistics.Win.UltraWinGrid.Activation.ActivateOnly
                            .TabStop = False
                        End With
                    Case "RECIPEGROUP"
                        With .Bands(tblAreaEquipment).Columns("RecipeGroup")
                            .Width = 80
                            .Header.VisiblePosition = 4
                            .CellActivation = Infragistics.Win.UltraWinGrid.Activation.ActivateOnly
                            .TabStop = False
                        End With
                    Case "RECIPEVERSION"
                        With .Bands(tblAreaEquipment).Columns("RecipeVersion")
                            .Width = 50
                            .Header.VisiblePosition = 5
                            .CellActivation = Infragistics.Win.UltraWinGrid.Activation.ActivateOnly
                            .TabStop = False
                        End With
                    Case "DESCRIPTION"
                        With .Bands(tblAreaEquipment).Columns("Description")
                            .Width = 100
                            .Header.VisiblePosition = 6
                            .CellActivation = Infragistics.Win.UltraWinGrid.Activation.ActivateOnly
                            .TabStop = False
                        End With
                    Case "QCLISTNO"
                        With .Bands(tblAreaEquipment).Columns("QCListNo")
                            .Header.VisiblePosition = 7
                            .CellActivation = Infragistics.Win.UltraWinGrid.Activation.ActivateOnly
                            .TabStop = False
                        End With
                    Case "DISPATCHORDER"
                        With .Bands(tblAreaEquipment).Columns("DispatchOrder")
                            .CellActivation = Infragistics.Win.UltraWinGrid.Activation.ActivateOnly
                            .TabStop = False
                            .CellAppearance.TextHAlign = Infragistics.Win.HAlign.Right
                        End With
                    Case "DISPATCHDATE" ''2020/11/05 Steven Mantis:0081316: 手動派工，新增顯示欄位
                        With .Bands(tblAreaEquipment).Columns("DispatchDate")
                            .CellActivation = Infragistics.Win.UltraWinGrid.Activation.ActivateOnly
                            .TabStop = False
                            .Format = "yyyy/MM/dd"
                            .Width = 100
                        End With
                        '2023/07/25會議結論， 規格書規畫尚不清晰，此項目註解。
                        'Case "LOGICALRECIPENAME" '2023/07/20, 0138119: [6.0.7]recipe配方管理优化派工--配方关联设定, 19245
                        '    With .Bands(tblAreaEquipment).Columns("LogicalRecipeName")
                        '        .Width = 80
                        '        .Header.VisiblePosition = 4
                        '        .CellActivation = Infragistics.Win.UltraWinGrid.Activation.ActivateOnly
                        '        .TabStop = False
                        '    End With
                        'Case "LOGICALRECIPEVERSION" '2023/07/20, 0138119: [6.0.7]recipe配方管理优化派工--配方关联设定, 19245
                        '    With .Bands(tblAreaEquipment).Columns("LogicalRecipeVersion")
                        '        .Width = 100
                        '        .Header.VisiblePosition = 5
                        '        .CellActivation = Infragistics.Win.UltraWinGrid.Activation.ActivateOnly
                        '        .TabStop = False
                        '    End With
                    Case Else
                        With .Bands(tblAreaEquipment).Columns(dsWIP.Tables(tblAreaEquipment).Columns(i).ColumnName.ToUpper)
                            .Hidden = True
                        End With
                End Select
            Next
            'Chamber
            If Not dsWIP.Tables("Chamber") Is Nothing Then
                For i = 0 To dsWIP.Tables("Chamber").Columns.Count - 1
                    Select Case dsWIP.Tables("Chamber").Columns(i).ColumnName.ToUpper
                        Case "SELECT1"
                            With .Bands("Chamber").Columns("SELECT1")
                                .Width = 50
                                .Header.VisiblePosition = 1
                                .Style = Infragistics.Win.UltraWinGrid.ColumnStyle.CheckBox
                                .CellAppearance.BackColor = System.Drawing.Color.White
                            End With
                        Case "EQUIPMENTNO"
                            With .Bands("Chamber").Columns("EQUIPMENTNO")
                                .Width = 100
                                .Header.VisiblePosition = 2
                                .CellActivation = Infragistics.Win.UltraWinGrid.Activation.ActivateOnly
                                .TabStop = False
                            End With
                        Case "EQUIPMENTNAME"
                            With .Bands("Chamber").Columns("EQUIPMENTNAME")
                                .Header.Caption = "EquipmentName"
                                .Width = 150
                                .Header.VisiblePosition = 3
                                .CellActivation = Infragistics.Win.UltraWinGrid.Activation.ActivateOnly
                                .TabStop = False
                            End With
                        Case "DESCRIPTION"
                            With .Bands("Chamber").Columns("Description")
                                .Width = 100
                                .Header.VisiblePosition = 4
                                .CellActivation = Infragistics.Win.UltraWinGrid.Activation.ActivateOnly
                                .TabStop = False
                            End With
                        Case Else
                            With .Bands("Chamber").Columns(dsWIP.Tables("Chamber").Columns(i).ColumnName.ToUpper)
                                .Hidden = True
                            End With
                    End Select
                Next
            End If
            'For i = 1 To colShow.Count
            '    .Columns(CStr(colShow(i))).Hidden = False
            '    .Columns(CStr(colShow(i))).Header.VisiblePosition = i
            'Next

            colShow.Add("CHECKFLAG")
            colShow.Add("EQUIPMENTNO")
            colShow.Add("EQUIPMENTNAME")
            colShow.Add("RECIPEGROUP")
            colShow.Add("RECIPEVERSION")
            'colShow.Add("LOGICALRECIPENAME")  '2023/07/25會議結論， 規格書規畫尚不清晰，此項目註解。
            'colShow.Add("LOGICALRECIPEVERSION")
            colShow.Add("DESCRIPTION")
            colShow.Add("QCLISTNO")
            colShow.Add("DISPATCHDATE")
            colShow.Add("DISPATCHORDER")

            'Accessory
            If Not dsWIP.Tables("AccState") Is Nothing Then
                For i = 0 To dsWIP.Tables("AccState").Columns.Count - 1
                    Select Case dsWIP.Tables("AccState").Columns(i).ColumnName.ToUpper
                        Case "SELECT"
                            With .Bands("Accessory").Columns("SELECT")
                                .Width = 50
                                .Header.VisiblePosition = 1
                                .Style = Infragistics.Win.UltraWinGrid.ColumnStyle.CheckBox
                                .CellAppearance.BackColor = System.Drawing.Color.White
                            End With
                        Case "ACCESSORYNO"
                            With .Bands("Accessory").Columns("AccessoryNo")
                                .Width = 80
                                .Header.Appearance.BackColor = System.Drawing.Color.Yellow
                                .Header.VisiblePosition = 2
                                .CellActivation = Infragistics.Win.UltraWinGrid.Activation.ActivateOnly
                                .TabStop = False
                            End With
                        Case "ACCESSORYTYPE"
                            With .Bands("Accessory").Columns("AccessoryType")
                                .Width = 80
                                .Header.Appearance.BackColor = System.Drawing.Color.Yellow
                                .Header.VisiblePosition = 3
                                .CellActivation = Infragistics.Win.UltraWinGrid.Activation.ActivateOnly
                                .TabStop = False
                            End With
                        Case "STARTTIME"
                            With .Bands("Accessory").Columns("StartTime")
                                .Width = 120
                                .Header.Appearance.BackColor = System.Drawing.Color.Yellow
                                .Header.VisiblePosition = 4
                                .CellActivation = Infragistics.Win.UltraWinGrid.Activation.ActivateOnly
                                .TabStop = False
                                .Format = "yyyy/MM/dd HH:mm:ss"
                            End With
                        Case "ACCUMULATEQTY"
                            With .Bands("Accessory").Columns("AccumulateQty")
                                .Width = 80
                                .Header.Appearance.BackColor = System.Drawing.Color.Yellow
                                .Header.VisiblePosition = 5
                                .CellActivation = Infragistics.Win.UltraWinGrid.Activation.ActivateOnly
                                .CellAppearance.TextHAlign = Infragistics.Win.HAlign.Right
                                .TabStop = False
                                .Format = "0.######"
                            End With
                        Case "REPAIRCYCLE"
                            With .Bands("Accessory").Columns("RepairCycle")
                                .Width = 80
                                .Header.Appearance.BackColor = System.Drawing.Color.Yellow
                                .Header.VisiblePosition = 6
                                .CellActivation = Infragistics.Win.UltraWinGrid.Activation.ActivateOnly
                                .CellAppearance.TextHAlign = Infragistics.Win.HAlign.Right
                                .TabStop = False
                                .Format = "0.######"
                            End With
                        Case Else
                            With .Bands("Accessory").Columns(dsWIP.Tables("AccState").Columns(i).ColumnName.ToUpper)
                                .Hidden = True
                            End With
                    End Select
                Next
            End If

            'Recipe
            'Dim vlRecipeType As New ValueList '2023/07/25會議結論， 規格書規畫尚不清晰，此項目註解。
            'vlRecipeType = COM_Utility.ValueListProvider.GetInstance.GetValueList("TBLPRDMACHINERECIPEDETAIL", "RECIPETYPE", True)

            If Not dsWIP.Tables("RecipeDetail") Is Nothing Then
                For i = 0 To dsWIP.Tables("RecipeDetail").Columns.Count - 1
                    Select Case dsWIP.Tables("RecipeDetail").Columns(i).ColumnName.ToUpper
                        Case "RECIPENO"
                            With .Bands("Recipe").Columns("RecipeNo")
                                .Width = 80
                                .Header.Appearance.BackColor = System.Drawing.Color.Yellow
                                .Header.VisiblePosition = 1
                                .CellActivation = Infragistics.Win.UltraWinGrid.Activation.ActivateOnly
                                .TabStop = False
                            End With
                        Case "RECIPEVALUE"
                            With .Bands("Recipe").Columns("RecipeValue")
                                .Width = 100
                                .Header.Appearance.BackColor = System.Drawing.Color.Yellow
                                .Header.VisiblePosition = 2
                                .CellActivation = Infragistics.Win.UltraWinGrid.Activation.ActivateOnly
                                .TabStop = False
                            End With
                            '2023/07/25會議結論， 規格書規畫尚不清晰，此項目註解。
                            'Case "RECIPEPARAMETERNO" '0138119: [6.0.7]recipe配方管理优化派工--配方关联设定, 2023/07/20, 19245
                            '    With .Bands("Recipe").Columns("RecipeParameterNo")
                            '        .Width = 80
                            '        .Header.Appearance.BackColor = System.Drawing.Color.Yellow
                            '        .Header.VisiblePosition = 1
                            '        .CellActivation = Infragistics.Win.UltraWinGrid.Activation.ActivateOnly
                            '        .TabStop = False
                            '    End With
                            'Case "RECIPETYPE" '0138119: [6.0.7]recipe配方管理优化派工--配方关联设定, 2023/07/21, 19245
                            '    With .Bands("Recipe").Columns("RecipeType")
                            '        .Width = 80
                            '        .Header.Appearance.BackColor = System.Drawing.Color.Yellow
                            '        .Header.VisiblePosition = 2
                            '        .CellActivation = Infragistics.Win.UltraWinGrid.Activation.ActivateOnly
                            '        .TabStop = False
                            '        .ValueList = vlRecipeType
                            'End With

                        Case Else
                            With .Bands("Recipe").Columns(dsWIP.Tables("RecipeDetail").Columns(i).ColumnName.ToUpper)
                                .Hidden = True
                            End With
                    End Select
                Next
            End If
        End With

        'UltraGrid
        iugEquipment.iMESUltraGrid.DisplayLayout.Override.AllowUpdate = Infragistics.Win.DefaultableBoolean.True
        iugEquipment.iMESUltraGrid.Rows.ExpandAll(True)

    End Sub

    Private Sub iugEquipment_iMESUltraGrid_BeforeCellUpdate(ByVal sender As Object, ByVal e As Infragistics.Win.UltraWinGrid.BeforeCellUpdateEventArgs) Handles iugEquipment.iMESUltraGrid_BeforeCellUpdate
        Dim drTemp As DataRow()
        Dim strType As String
        Dim blnNeedSelect As Boolean
        '勾選設備後，才自動勾選模治具
        If e.Cell.Column.Key.ToUpper = "CHECKFLAG" AndAlso e.NewValue = True Then
            '預設選取每個類別第一個模治具
            For Each dr As DataRow In dsWIP.Tables(tblAreaEquipment).Select("EquipmentNo = '" & e.Cell.Row.Cells(1).Text & "'")
                strType = ""
                blnNeedSelect = True
                If dr("AllowExecute") = 1 Then '可使用
                    drTemp = dsWIP.Tables("AccState").Select("EquipmentNo = '" & dr("EquipmentNo") & "'")
                    For i = 0 To drTemp.Count - 1
                        If drTemp(i)("Select") = True Then blnNeedSelect = False
                    Next
                    If drTemp.Length > 0 AndAlso blnNeedSelect = True Then
                        '有掛模治具
                        For Each dr1 As DataRow In drTemp
                            If strType = "" Then
                                strType = dr1("AccessoryType")
                                dr1("Select") = True
                            ElseIf strType <> dr1("AccessoryType") Then
                                dr1("Select") = True
                                strType = dr1("AccessoryType")
                            End If
                        Next
                    End If
                End If
            Next
        End If
    End Sub
    Private Sub iugEquipment_iMESUltraGrid_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles iugEquipment.iMESUltraGrid_KeyPress
        If e.KeyChar = Convert.ToChar(13) Then
            SendKeys.Send("{TAB}")
        End If
    End Sub



    Private Sub iugEquipment_iMESUltraGrid_InitializeRow(ByVal sender As System.Object, ByVal e As Infragistics.Win.UltraWinGrid.InitializeRowEventArgs) Handles iugEquipment.iMESUltraGrid_InitializeRow

        If e.Row.Band.Key = tblAreaEquipment Then 'Equipment
            If e.Row.Cells("AllowExecute").Value = 0 Then     '不可使用
                e.Row.Cells("CheckFlag").Activation = Infragistics.Win.UltraWinGrid.Activation.Disabled
                e.Row.Cells("CheckFlag").Appearance.BackColor = System.Drawing.Color.Gainsboro
            ElseIf e.Row.Cells("AllowExecute").Value = 1 Then '可使用

                'CheckFlag
                If EquipmentNo = defString Then
                Else
                    '以機台下貨,關閉勾選介面.
                    e.Row.Cells("CheckFlag").Activation = Infragistics.Win.UltraWinGrid.Activation.Disabled
                    e.Row.Cells("CheckFlag").Appearance.BackColor = System.Drawing.Color.Gainsboro
                End If
            End If
        End If
        '子設備
        'TsungYu 2021/06/09
        If e.Row.Band.Key = "Chamber" Then 'Equipment
            If e.Row.Cells("AllowExecute").Value = 0 Then     '不可使用
                e.Row.Cells("Select1").Activation = Infragistics.Win.UltraWinGrid.Activation.Disabled
                e.Row.Cells("Select1").Appearance.BackColor = System.Drawing.Color.Gainsboro
            ElseIf e.Row.Cells("AllowExecute").Value = 1 Then '可使用
                'CheckFlag
                If EquipmentNo = defString Then
                Else
                    e.Row.Cells("Select1").Activation = Infragistics.Win.UltraWinGrid.Activation.Disabled
                    e.Row.Cells("Select1").Appearance.BackColor = System.Drawing.Color.Gainsboro
                End If
            End If
        End If
        If e.Row.Band.Key.ToUpper = "ACCESSORY" Then '模治具
            '2014/11/24 Kevin,如果是產品-作業站-模治具所設定的模治具則改變底色
            If Not dsWIP.Tables("PRDAccessory") Is Nothing Then
                Dim drSelPRD As DataRow()
                drSelPRD = dsWIP.Tables("PRDAccessory").Select("AccessoryNo = '" & e.Row.Cells("AccessoryNo").Value & "'")
                If drSelPRD.Length > 0 Then
                    e.Row.Appearance.BackColor = System.Drawing.Color.Yellow
                Else
                    '找不到的話再看一次模治具類別
                    drSelPRD = dsWIP.Tables("PRDAccessory").Select("AccessoryType = '" & e.Row.Cells("AccessoryType").Value & "' And AccessoryNo ='*'")
                    If drSelPRD.Length > 0 Then
                        e.Row.Appearance.BackColor = System.Drawing.Color.Yellow
                    End If
                End If
            End If
        End If

    End Sub


    Private Sub iugEquipment_iMESUltraGrid_AfterCellUpdate(sender As System.Object, e As Infragistics.Win.UltraWinGrid.CellEventArgs) Handles iugEquipment.iMESUltraGrid_AfterCellUpdate

        '如有點選模製具則將設備自動勾選
        If e.Cell.Column.Key.ToUpper = "SELECT" AndAlso e.Cell.Row.Cells("SELECT").Value Then
            drSelE = dsWIP.Tables(tblAreaEquipment).Select("EquipmentNo = '" & e.Cell.Row.Cells("EquipmentNo").Value & "'")
            For Each dr As DataRow In drSelE
                dr("CHECKFLAG") = True
            Next
        End If

        If e.Cell.Column.Key.ToUpper = "CHECKFLAG" AndAlso e.Cell.Row.Cells("CHECKFLAG").Value = False Then
            drSelE = dsWIP.Tables("AccState").Select("EquipmentNo = '" & iugEquipment.iMESUltraGrid.ActiveRow.Cells("EquipmentNo").Value & "'")
            For Each dr As DataRow In drSelE
                dr("Select") = False
            Next

            '2021/9/14 Mantis:0099587 當取消勾選設備時,此設備已開立的點檢單應刪除
            '自動開立點檢務單
            Call funCheckEQPQCTask(e.Cell.Row.Cells("EquipmentNo").Value, True)

            If blnByEQP = True Then
                DeleteTmpMTLLotNo(e.Cell.Row.Cells("EquipmentNo").Value)
            End If

        Else
            If blnByEQP = True Then
                Call LoadMaterialByEquipment(e.Cell.Row.Cells("EquipmentNo").Value)
            End If
        End If

        If Not dsWIP.Tables("Chamber") Is Nothing Then
            If dsWIP.Tables("Chamber").Rows.Count > 0 Then
                '如有點選子設備則將設備自動勾選
                If e.Cell.Column.Key.ToUpper = "SELECT1" AndAlso e.Cell.Row.Cells("SELECT1").Value Then
                    If Not String.IsNullOrEmpty(e.Cell.Row.Cells("BELONGEQUIPMENTNO").Value.ToString) Then
                        drSelE = dsWIP.Tables(tblAreaEquipment).Select("EquipmentNo = '" & e.Cell.Row.Cells("BelongEquipmentNo").Value & "'")
                        For Each dr As DataRow In drSelE
                            dr("CHECKFLAG") = True
                        Next
                    End If
                End If
                '設備取消時子設備的勾選也自動取消
                If e.Cell.Column.Key.ToUpper = "CHECKFLAG" AndAlso e.Cell.Row.Cells("CHECKFLAG").Value = False Then
                    drSelE = dsWIP.Tables("Chamber").Select("BelongEquipmentNo = '" & iugEquipment.iMESUltraGrid.ActiveRow.Cells("EquipmentNo").Value & "'")
                    For Each dr As DataRow In drSelE
                        dr("SELECT1") = False
                    Next
                    '設備勾選時自動勾選子設備
                ElseIf e.Cell.Column.Key.ToUpper = "CHECKFLAG" AndAlso e.Cell.Row.Cells("CHECKFLAG").Value Then
                    drSelE = dsWIP.Tables("Chamber").Select("BelongEquipmentNo = '" & iugEquipment.iMESUltraGrid.ActiveRow.Cells("EquipmentNo").Value & "' and AllowExecute = 1")
                    For Each dr As DataRow In drSelE
                        dr("SELECT1") = True
                    Next
                End If
            End If
        End If
        ' 2016/01/27 YF, 取得設備參數值
        e.Cell.Row.Update()

        funGetEquipmentRecipe()


    End Sub

    Private Sub iugEquipment_iMESUltraGrid_CellChange(sender As Object, e As Infragistics.Win.UltraWinGrid.CellEventArgs) Handles iugEquipment.iMESUltraGrid_CellChange
        ' CheckFlag被點選時, 可立即將結果異動回DataTable
        e.Cell.Row.Update()
        Me.iugEquipment.iMESUltraGrid.ActiveRow = e.Cell.Row
    End Sub

    Private Sub iugKeyIn_iMESUltraGrid_InitializeLayOut(ByVal sender As System.Object, ByVal e As Infragistics.Win.UltraWinGrid.InitializeLayoutEventArgs) Handles iugKeyIn.iMESUltraGrid_InitializeLayOut

        With e.Layout
            With .Bands("KeyIn").Columns("AttribNo")
                .Header.Caption = "AttribNo"
                .Width = 90
                .Header.VisiblePosition = 1
                .CellActivation = Infragistics.Win.UltraWinGrid.Activation.ActivateOnly
                .CellAppearance.BackColor = System.Drawing.Color.Gainsboro
                .TabStop = False
            End With
            With .Bands("KeyIn").Columns("AttribName")
                .Header.Caption = "AttribName"
                .Width = 150
                .Header.VisiblePosition = 2
                .CellActivation = Infragistics.Win.UltraWinGrid.Activation.ActivateOnly
                .CellAppearance.BackColor = System.Drawing.Color.Gainsboro
                .TabStop = False
            End With
            With .Bands("KeyIn").Columns("AttribValue")
                .Header.Caption = "AttribValue"
                .Width = 130
                .Header.VisiblePosition = 3
            End With
            '2015-12-18, Joe, Add
            With .Bands("KeyIn").Columns("QCItemNo")
                .Header.Caption = "QCItemNo"
                .Width = 90
                .Header.VisiblePosition = 4
                .CellActivation = Infragistics.Win.UltraWinGrid.Activation.ActivateOnly
                .CellAppearance.BackColor = System.Drawing.Color.Gainsboro
                .TabStop = False
            End With
            With .Bands("KeyIn").Columns("AttribSequence")
                .Hidden = True
            End With
            With .Bands("KeyIn").Columns("InputType")
                .Hidden = True
            End With
            With .Bands("KeyIn").Columns("DataType")
                .Hidden = True
            End With
            With .Bands("KeyIn").Columns("ValueType")
                .Hidden = True
            End With

            .Bands("KeyIn").Columns("OrgAttribValue").Hidden = True ' 2016/01/27 YF
        End With

        'UltraGrid
        iugKeyIn.iMESUltraGrid.DisplayLayout.Override.AllowUpdate = Infragistics.Win.DefaultableBoolean.True

    End Sub

    Private Sub iugKeyIn_iMESUltraGrid_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles iugKeyIn.iMESUltraGrid_KeyPress
        If e.KeyChar = Convert.ToChar(13) Then
            SendKeys.Send("{TAB}")
        End If
    End Sub

    Private Sub iugKeyIn_iMESUltraGrid_InitializeRow(ByVal sender As System.Object, ByVal e As Infragistics.Win.UltraWinGrid.InitializeRowEventArgs) Handles iugKeyIn.iMESUltraGrid_InitializeRow
        Dim strAttribValue As String

        Try

            'InputType=1  清單選擇
            If e.Row.Cells("InputType").Value = 1 Then
                e.Row.Cells("AttribValue").Style = ColumnStyle.Button
                e.Row.Cells("AttribValue").Appearance.BackColor = System.Drawing.Color.Pink
            ElseIf e.Row.Cells("DataType").Value = 3 Then
                e.Row.Cells("AttribValue").Style = ColumnStyle.DateTime
                e.Row.Cells("AttribValue").Editor = editor
                e.Row.Cells("AttribValue").Appearance.BackColor = Color.White
            End If

        Catch ex As iMESException.MESException
            ExceptionManager.iMESShowDialog(ex.ErrorCode, ex.Message, ex.StackTrace)
            Exit Sub
        Catch ex As Exception
            ExceptionManager.iMESShowDialog(defWinErrCode, ex.Message, ex.StackTrace)
            Exit Sub
        End Try

    End Sub

    Private Sub iugKeyIn_iMESUltraGrid_ClickCellButton(ByVal sender As Object, ByVal e As Infragistics.Win.UltraWinGrid.CellEventArgs) Handles iugKeyIn.iMESUltraGrid_ClickCellButton

        Dim intValueType As Integer

        Cursor.Current = Cursors.WaitCursor

        Try

            intValueType = iugKeyIn.iMESUltraGrid.ActiveRow.Cells("ValueType").Value

            If intValueType = 3 OrElse intValueType = 1 Then   'Reference System Parameter / Assign Valid Value
                If Not IsNothing(dsWIP.Tables(strDefaultValue)) Then
                    dsWIP.Tables.Remove(strDefaultValue)
                End If

                strIdentity = CombineXMLIdentity(gComputerName, gUserNo, GetNow())
                strParameter = CombineXMLParameter("elementno", "PropertyType", "String", iugKeyIn.iMESUltraGrid.ActiveRow.Cells("AttribNo").Value, "")
                InXml = CombineXMLRequest(strIdentity, strParameter)

                OutXml = InvokeSrv("wsSYS.LoadElementValue", InXml)

                Dim XmlDoc As New XmlDocument
                XmlDoc.LoadXml(OutXml)
                If ChkExecutionSuccess(XmlDoc) Then
                    '//取出Data
                    strDefaultValue = XmlDoc.GetElementsByTagName("returnvalue").Item(0).SelectNodes("loadelementvalue").Item(0).SelectNodes("name").Item(0).InnerXml
                    '取出Schema,dataset讀取Schema可防止Null Field及DateTime的問題
                    XmlSchema = XmlDoc.DocumentElement.GetElementsByTagName("loadelementvalue").Item(0).SelectNodes("schema").Item(0).InnerXml
                    If XmlSchema <> "" Then
                        '將XML讀入String Reader object中,因為Dataset讀入XML時必須透過String Reader物件
                        tmpStringReader = New System.IO.StringReader(XmlSchema)
                        dsWIP.ReadXmlSchema(tmpStringReader)
                        tmpStringReader.Close()
                    End If
                    XmlData = XmlDoc.DocumentElement.GetElementsByTagName("loadelementvalue").Item(0).SelectNodes("value").Item(0).InnerXml
                    If XmlData <> "" And XmlData <> "fail" Then
                        tmpStringReader = New System.IO.StringReader(XmlData)
                        dsWIP.ReadXml(tmpStringReader, XmlReadMode.InferSchema)

                        Dim fSearch As New frmCOMSearch
                        '如果 PropertyNo 的有效性檢查來自 MESParameter，則取出有效值提供選擇
                        fSearch.dvSearch = dsWIP.Tables(strDefaultValue).DefaultView
                        fSearch.strFindColumnName = dsWIP.Tables(strDefaultValue).Columns(0).ColumnName
                        '20221214,13871,右鍵 儲存設計 需要使用Owner(程式碼由程序建立)
                        fSearch.ShowDialog(Me)
                        fSearch.Dispose()

                        If Not drSearch Is Nothing Then
                            If Not IsDBNull(drSearch(0).ToString) Then
                                iugKeyIn.iMESUltraGrid.ActiveRow.Cells("AttribValue").Value = drSearch(0).ToString
                            End If
                        End If
                    End If
                Else
                    ExceptionManager.iMESShowDialog(GetExceptionCode(XmlDoc), GetExceptionSysMsg(XmlDoc), GetExceptionStack(XmlDoc))
                    Exit Sub
                End If

            End If

        Catch ex As iMESException.MESException
            ExceptionManager.iMESShowDialog(ex.ErrorCode, ex.Message, ex.StackTrace)
            Exit Sub
        Catch ex As Exception
            ExceptionManager.iMESShowDialog(defWinErrCode, ex.Message, ex.StackTrace)
            Exit Sub
        End Try

    End Sub

    Private Sub iugSubOP_iMESUltraGrid_InitializeLayOut(ByVal sender As System.Object, ByVal e As Infragistics.Win.UltraWinGrid.InitializeLayoutEventArgs) Handles iugSubOP.iMESUltraGrid_InitializeLayOut

        Dim i As Integer

        With e.Layout
            For i = 0 To dsWIP.Tables(tblSubOP).Columns.Count - 1
                Select Case dsWIP.Tables(tblSubOP).Columns(i).ColumnName.ToUpper
                    Case "SUBOPSEQUENCE"
                        With .Bands(tblSubOP).Columns("SubOPSequence")
                            .Header.Caption = "SubOPSequence"
                            .Width = 50
                            .Hidden = False
                            .Header.VisiblePosition = 1
                        End With
                    Case "SUBOPNO"
                        With .Bands(tblSubOP).Columns("SubOPNo")
                            .Header.Caption = "SubOPNo"
                            .Width = 80
                            .Header.VisiblePosition = 2
                        End With
                    Case "SUBOPNAME"
                        With .Bands(tblSubOP).Columns("SubOPName")
                            .Header.Caption = "SubOPName"
                            .Width = 180
                            .Header.VisiblePosition = 3
                        End With
                    Case "CREATOR"
                        With .Bands(tblSubOP).Columns("Creator")
                            .Header.Caption = "Creator"
                            .Width = 70
                            .Hidden = True
                            .Header.VisiblePosition = 4
                        End With
                    Case "CREATEDATE"
                        With .Bands(tblSubOP).Columns("CreateDate")
                            .Width = 120
                            .Header.VisiblePosition = 5
                            .Hidden = True
                            .Format = "yyyy/MM/dd HH:mm:ss"
                        End With
                    Case Else
                        With .Bands(tblSubOP).Columns(dsWIP.Tables(tblSubOP).Columns(i).ColumnName.ToUpper)
                            .Hidden = True
                        End With
                End Select
            Next

        End With

    End Sub

#End Region

#Region "Equipment"

    Private Sub txtEquipmentNo_Enter(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtEquipmentNo.Enter
        txtEquipmentNo.SelectAll()
    End Sub
    Private Sub txtEquipmentNo_KeyPress(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles txtEquipmentNo.KeyPress

        Cursor.Current = Cursors.WaitCursor

        '強制使用機台,故不提供此功能

        If EquipmentNo <> defString Then Exit Sub

        If e.KeyChar = Convert.ToChar(13) Then
            If txtEquipmentNo.Text.Trim <> "" Then
                Dim drSel() As DataRow
                Dim strEQPNo As String
                strEQPNo = txtEquipmentNo.Text.Trim.ToUpper
                '檢查EquipmentNo是否存在
                drSel = dsWIP.Tables(tblAreaEquipment).Select("EquipmentNo='" & strEQPNo & "'")
                If drSel.Length = 0 Then
                    iMESExceptionManager.ExceptionManager.iMESMsgBoxShowDialog(ChgTranslateName_Msg("0000-203072", "[%EquipmentNo%]:" & strEQPNo & " [%is not in area%]:" & txtAreaNo.Text & "!"), MsgBoxStyle.Exclamation, Me.Text)
                    txtEquipmentNo.SelectAll()
                    Exit Sub
                Else
                    If drSel(0)("AllowExecute") = 1 Then '可使用
                        drSel(0)("CheckFlag") = True
                        If blnByEQP = True Then
                            Call LoadMaterialByEquipment(strEQPNo)
                        End If

                    Else '不可使用
                        iMESExceptionManager.ExceptionManager.iMESMsgBoxShowDialog(ChgTranslateName_Msg("0000-203072", "[%EquipmentNo%]:" & strEQPNo & " [%is not available%] " & Chr(10) + Chr(13) & drSel(0)("Description")), MsgBoxStyle.Exclamation, Me.Text)
                        txtEquipmentNo.SelectAll()
                        Exit Sub
                    End If
                End If

                'Focus
                Dim ugrRow As Infragistics.Win.UltraWinGrid.UltraGridRow
                ugrRow = FindRecordPosition(iugEquipment, "EquipmentNo", strEQPNo)
                If Not ugrRow Is Nothing Then
                    iugEquipment.iMESUltraGrid.ActiveRow = ugrRow
                    iugEquipment.iMESUltraGrid.ActiveRow.Selected = True
                End If

                txtEquipmentNo.Text = ""
                txtEquipmentNo.Focus()
            End If
        End If

        Cursor.Current = Cursors.Default

    End Sub


#End Region

#Region "Load functions"

    Private Function funLoadLotState() As Integer

        funLoadLotState = -1

        '組InXml的字串
        strIdentity = CombineXMLIdentity(gComputerName, UserId, Now)
        strParameter = CombineXMLParameter("lotno", "LotNo", "String", LotNo, "")
        InXml = CombineXMLRequest(strIdentity, strParameter)

        Try
            OutXml = InvokeSrv("wsWIP.LoadLotBasisJoinState", InXml)

            Dim XmlDoc As New XmlDocument
            XmlDoc.LoadXml(OutXml)
            If ChkExecutionSuccess(XmlDoc) Then
                '讀取取出資料表之名稱
                tblLotState = XmlDoc.GetElementsByTagName("returnvalue").Item(0).SelectNodes("loadlotbasisjoinstate").Item(0).SelectNodes("name").Item(0).InnerXml
                '取出Schema,dataset讀取Schema可防止Null Field及DateTime的問題
                XmlSchema = XmlDoc.DocumentElement.GetElementsByTagName("loadlotbasisjoinstate").Item(0).SelectNodes("schema").Item(0).InnerXml
                If XmlSchema <> "" Then
                    '將XML讀入String Reader object中,因為Dataset讀入XML時必須透過String Reader物件
                    tmpStringReader = New System.IO.StringReader(XmlSchema)
                    dsWIP.ReadXmlSchema(tmpStringReader)
                    tmpStringReader.Close()
                End If
                '取出Data
                XmlData = XmlDoc.DocumentElement.GetElementsByTagName("loadlotbasisjoinstate").Item(0).SelectNodes("value").Item(0).InnerXml
                If XmlData <> "" Then
                    tmpStringReader = New System.IO.StringReader(XmlData)
                    dsWIP.ReadXml(tmpStringReader, XmlReadMode.InferSchema)
                    tmpStringReader.Close()
                End If
            Else
                ExceptionManager.iMESShowDialog(GetExceptionCode(XmlDoc), GetExceptionSysMsg(XmlDoc), GetExceptionStack(XmlDoc))
                Exit Function
            End If

            If dsWIP.Tables(tblLotState).Rows.Count > 0 Then
                If dsWIP.Tables(tblLotState).Rows(0)("MaterialOption").ToString = "1" Then
                    blnByEQP = True
                End If
            End If

            XmlDoc = Nothing

        Catch ex As iMESException.MESException
            ExceptionManager.iMESShowDialog(ex.ErrorCode, ex.Message, ex.StackTrace)
            Exit Function
        Catch ex As Exception
            ExceptionManager.iMESShowDialog(defWinErrCode, ex.Message, ex.StackTrace)
            Exit Function
        End Try

        funLoadLotState = 0

    End Function

    Private Function funLoadTemp_AttribJoinBasis() As Integer

        funLoadTemp_AttribJoinBasis = -1

        '組InXml的字串
        strIdentity = CombineXMLIdentity(gComputerName, UserId, Now)
        strParameter = CombineXMLParameter("lotno", "LotNo", "String", LotNo, "")
        InXml = CombineXMLRequest(strIdentity, strParameter)

        Try
            OutXml = InvokeSrv("wsWIP.LoadTemp_AttribJoinBasis", InXml)

            Dim XmlDoc As New XmlDocument
            XmlDoc.LoadXml(OutXml)
            If ChkExecutionSuccess(XmlDoc) Then
                tblTAttrib = XmlDoc.GetElementsByTagName("returnvalue").Item(0).SelectNodes("loadtemp_attrib").Item(0).SelectNodes("name").Item(0).InnerXml
                '取出Schema,dataset讀取Schema可防止Null Field及DateTime的問題
                XmlSchema = XmlDoc.DocumentElement.GetElementsByTagName("loadtemp_attrib").Item(0).SelectNodes("schema").Item(0).InnerXml
                If XmlSchema <> "" Then
                    '將XML讀入String Reader object中,因為Dataset讀入XML時必須透過String Reader物件
                    tmpStringReader = New System.IO.StringReader(XmlSchema)
                    dsWIP.ReadXmlSchema(tmpStringReader)
                    tmpStringReader.Close()
                End If
                XmlData = XmlDoc.DocumentElement.GetElementsByTagName("loadtemp_attrib").Item(0).SelectNodes("value").Item(0).InnerXml
                If XmlData <> "" Then
                    tmpStringReader = New System.IO.StringReader(XmlData)
                    dsWIP.ReadXml(tmpStringReader, XmlReadMode.InferSchema)
                    tmpStringReader.Close()
                End If

                Call funAddValueList_Attrib()
            Else
                ExceptionManager.iMESShowDialog(GetExceptionCode(XmlDoc), GetExceptionSysMsg(XmlDoc), GetExceptionStack(XmlDoc))
                Exit Function
            End If

            XmlDoc = Nothing

        Catch ex As iMESException.MESException
            ExceptionManager.iMESShowDialog(ex.ErrorCode, ex.Message, ex.StackTrace)
            Exit Function
        Catch ex As Exception
            ExceptionManager.iMESShowDialog(defWinErrCode, ex.Message, ex.StackTrace)
            Exit Function
        End Try

        funLoadTemp_AttribJoinBasis = 0


    End Function

    Private Function funLoadTemp_Material() As Integer

        funLoadTemp_Material = -1

        '組InXml的字串
        strIdentity = CombineXMLIdentity(gComputerName, UserId, Now)
        strParameter = CombineXMLParameter("lotno", "LotNo", "String", LotNo, "")
        InXml = CombineXMLRequest(strIdentity, strParameter)

        Try
            OutXml = InvokeSrv("wsWIP.LoadTemp_Material", InXml)

            Dim XmlDoc As New XmlDocument
            XmlDoc.LoadXml(OutXml)
            If ChkExecutionSuccess(XmlDoc) Then
                tblTMaterial = XmlDoc.GetElementsByTagName("returnvalue").Item(0).SelectNodes("loadtemp_material").Item(0).SelectNodes("name").Item(0).InnerXml
                '取出Schema,dataset讀取Schema可防止Null Field及DateTime的問題
                XmlSchema = XmlDoc.DocumentElement.GetElementsByTagName("loadtemp_material").Item(0).SelectNodes("schema").Item(0).InnerXml
                If XmlSchema <> "" Then
                    '將XML讀入String Reader object中,因為Dataset讀入XML時必須透過String Reader物件
                    tmpStringReader = New System.IO.StringReader(XmlSchema)
                    dsWIP.ReadXmlSchema(tmpStringReader)
                    tmpStringReader.Close()
                End If
                XmlData = XmlDoc.DocumentElement.GetElementsByTagName("loadtemp_material").Item(0).SelectNodes("value").Item(0).InnerXml
                If XmlData <> "" Then
                    tmpStringReader = New System.IO.StringReader(XmlData)
                    dsWIP.ReadXml(tmpStringReader, XmlReadMode.InferSchema)
                    tmpStringReader.Close()
                End If

                '新增OrgMaterialNo,紀錄原來的主物料用
                Dim colOrgMaterialNo As New DataColumn
                colOrgMaterialNo.ColumnName = "OrgMaterialNo"
                colOrgMaterialNo.DataType = System.Type.GetType("System.String")
                colOrgMaterialNo.DefaultValue = 0
                colOrgMaterialNo.AllowDBNull = False
                dsWIP.Tables(tblTMaterial).Columns.Add(colOrgMaterialNo)

                '加入標準用量欄位
                Dim colStdQty As New DataColumn
                colStdQty.ColumnName = "StdUseQty"
                colStdQty.DataType = System.Type.GetType("System.Decimal")
                colStdQty.DefaultValue = 0
                colStdQty.AllowDBNull = False
                dsWIP.Tables(tblTMaterial).Columns.Add(colStdQty)

                '計算標準使用量
                Dim decCurQty, decStdQty As Decimal
                Dim i As Integer

                'Rows(0)一定會有資料.
                decCurQty = dsWIP.Tables(tblLotState).Rows(0)("CurQty")
                For i = 0 To dsWIP.Tables(tblTMaterial).Rows.Count - 1
                    decStdQty = decCurQty * dsWIP.Tables(tblTMaterial).Rows(i)("StdQty") * (1 + dsWIP.Tables(tblTMaterial).Rows(i)("DecreaseRate"))
                    dsWIP.Tables(tblTMaterial).Rows(i)("StdUseQty") = Format(decStdQty, "0.######")

                    '紀錄原來的主物料
                    dsWIP.Tables(tblTMaterial).Rows(i)("OrgMaterialNo") = dsWIP.Tables(tblTMaterial).Rows(i)("MaterialNo")
                Next

                dsWIP.Tables(tblTMaterial).Columns("MaterialLevel").ColumnName = "MaterialLevelShow"

                '加入可供使用者點擊搜尋的欄位
                dsWIP.Tables(tblTMaterial).Columns.Add(New DataColumn("MTLLotNoSearch", System.Type.GetType("System.String")))
                dsWIP.Tables(tblTMaterial).DefaultView.RowFilter = "MaterialNo = OrgMaterialNo"
                dsWIP.Tables(tblTMaterial).DefaultView.Sort = "MaterialType,OrgMaterialNo,MaterialNo"
            Else
                ExceptionManager.iMESShowDialog(GetExceptionCode(XmlDoc), GetExceptionSysMsg(XmlDoc), GetExceptionStack(XmlDoc))
                Exit Function
            End If

            XmlDoc = Nothing

        Catch ex As iMESException.MESException
            ExceptionManager.iMESShowDialog(ex.ErrorCode, ex.Message, ex.StackTrace)
            Exit Function
        Catch ex As Exception
            ExceptionManager.iMESShowDialog(defWinErrCode, ex.Message, ex.StackTrace)
            Exit Function
        End Try

        funLoadTemp_Material = 0


    End Function

    Private Function funLoadAvailableEquipment(ByRef LotNo As String) As Integer

        funLoadAvailableEquipment = -1

        '組InXml的字串
        strIdentity = CombineXMLIdentity(gComputerName, UserId, Now)
        strParameter = CombineXMLParameter("lotno", "LotNo", "String", LotNo, "")
        strParameter += CombineXMLParameter("getrecipe", "GetRecipe", "Boolean", True, "")
        strParameter += CombineXMLParameter("getaccessory", "GetAccessory", "Boolean", blnGetAccessory, "")
        strParameter += CombineXMLParameter("multiqclist", "MultiQCList", "Boolean", True, "")
        InXml = CombineXMLRequest(strIdentity, strParameter)

        Try
            OutXml = InvokeSrv("wsWIP.LoadAvailableEquipment_All", InXml)

            Dim XmlDoc As New XmlDocument
            XmlDoc.LoadXml(OutXml)
            If ChkExecutionSuccess(XmlDoc) Then
                tblAreaEquipment = XmlDoc.GetElementsByTagName("returnvalue").Item(0).SelectNodes("loadavailableequipment_all").Item(0).SelectNodes("name").Item(0).InnerXml
                '取出Schema,dataset讀取Schema可防止Null Field及DateTime的問題
                XmlSchema = XmlDoc.DocumentElement.GetElementsByTagName("loadavailableequipment_all").Item(0).SelectNodes("schema").Item(0).InnerXml
                If XmlSchema <> "" Then
                    '將XML讀入String Reader object中,因為Dataset讀入XML時必須透過String Reader物件
                    tmpStringReader = New System.IO.StringReader(XmlSchema)
                    dsWIP.ReadXmlSchema(tmpStringReader)
                    tmpStringReader.Close()
                End If
                XmlData = XmlDoc.DocumentElement.GetElementsByTagName("loadavailableequipment_all").Item(0).SelectNodes("value").Item(0).InnerXml
                If XmlData <> "" Then
                    tmpStringReader = New System.IO.StringReader(XmlData)
                    dsWIP.ReadXml(tmpStringReader, XmlReadMode.InferSchema)
                    tmpStringReader.Close()
                End If

                '2023/12/21,Ning,154124: L_CI_GEN [語系未處理] 挑選設備後，彈窗訊息顯示 LoadPort is full.
                For Each drEQP As DataRow In dsWIP.Tables(tblAreaEquipment).Rows
                    If drEQP("Description").ToString <> "" Then
                        drEQP("Description") = ChgTranslateName_Content(drEQP("Description"))
                    End If
                Next

                '加入Check Field
                Dim colCheckFlag As New DataColumn
                colCheckFlag.ColumnName = "CheckFlag"
                colCheckFlag.DataType = System.Type.GetType("System.Boolean")
                colCheckFlag.DefaultValue = False
                colCheckFlag.AllowDBNull = False
                dsWIP.Tables(tblAreaEquipment).Columns.Add(colCheckFlag)
                '加入LoadPort
                Dim colPort As New DataColumn
                colPort.ColumnName = "LoadPort"
                colPort.DataType = System.Type.GetType("System.String")
                dsWIP.Tables(tblAreaEquipment).Columns.Add(colPort)

                '加入點檢識別欄位
                dsWIP.Tables(tblAreaEquipment).Columns.Add(New DataColumn("QCType", System.Type.GetType("System.Decimal")))
                dsWIP.Tables(tblAreaEquipment).Columns.Add(New DataColumn("QCFinish", System.Type.GetType("System.Decimal")))

                '開放可編輯
                dsWIP.Tables(tblAreaEquipment).DefaultView.AllowEdit = True

                If Not dsWIP.Tables("Chamber") Is Nothing Then
                    '加入勾選的按鈕
                    Dim colChamberCheckFlag As New DataColumn
                    colChamberCheckFlag.ColumnName = "SELECT1"
                    colChamberCheckFlag.DataType = System.Type.GetType("System.Boolean")
                    colChamberCheckFlag.DefaultValue = False
                    colChamberCheckFlag.AllowDBNull = False
                    dsWIP.Tables("Chamber").Columns.Add(colChamberCheckFlag)
                    dsWIP.Tables(tblAreaEquipment).DefaultView.AllowEdit = True
                End If
                'Kevin 20131223,如有模治具則開放用選取的方式
                If Not dsWIP.Tables("AccState") Is Nothing Then
                    '加入勾選的按鈕
                    Dim colSelect As New DataColumn
                    colSelect.ColumnName = "Select"
                    colSelect.DataType = System.Type.GetType("System.Boolean")
                    colSelect.DefaultValue = False
                    colSelect.AllowDBNull = False
                    dsWIP.Tables("AccState").Columns.Add(colSelect)

                    dsWIP.Tables("AccState").DefaultView.Sort = "AccessoryType,AccessoryNo"
                    Dim strType As String = ""
                    Dim drTemp As DataRow()

                    '預設選取每個類別第一個模治具
                    'For Each dr As DataRow In dsWIP.Tables(tblAreaEquipment).Rows
                    '    strType = ""
                    '    If dr("AllowExecute") = 1 Then '可使用
                    '        drTemp = dsWIP.Tables("AccState").Select("EquipmentNo = '" & dr("EquipmentNo") & "'")
                    '        If drTemp.Length > 0 Then
                    '            '有掛模治具
                    '            For Each dr1 As DataRow In drTemp
                    '                If strType = "" Then
                    '                    strType = dr1("AccessoryType")
                    '                    dr1("Select") = True
                    '                ElseIf strType <> dr1("AccessoryType") Then
                    '                    dr1("Select") = True
                    '                    strType = dr1("AccessoryType")
                    '                End If
                    '            Next
                    '        End If
                    '    End If
                    'Next
                    '2020/02/26 Grace Mantis 67753 取得此批號於此作業站上的派工資料
                    Call funLoadWIPEQPDispatchState(LotNo:=LotNo, OPNo:=txtOPNo.Text)
                    '增加顯示欄位:派工日期、派工順序
                    If dsWIP.Tables(tblAreaEquipment).Columns.Contains("DispatchOrder") Then
                        dsWIP.Tables(tblAreaEquipment).Columns.Remove("DispatchOrder")
                    End If
                    Dim colDispatchDate As New DataColumn
                    colDispatchDate.ColumnName = "DispatchDate"
                    colDispatchDate.DataType = System.Type.GetType("System.DateTime")
                    dsWIP.Tables(tblAreaEquipment).Columns.Add(colDispatchDate)
                    Dim colDispatchOrder As New DataColumn
                    colDispatchOrder.ColumnName = "DispatchOrder"
                    colDispatchOrder.DataType = System.Type.GetType("System.String")
                    dsWIP.Tables(tblAreaEquipment).Columns.Add(colDispatchOrder)

                    If Not IsNothing(dsTemp.Tables(tblEQPDispatchState)) Then
                        If dsTemp.Tables(tblEQPDispatchState).Rows.Count > 0 Then
                            Dim strCheckInDate As String = Now.ToString("yyyy/MM/dd") 'Check In 日期
                            '2020/11/05 Steven Mantis:0081316: '增加顯示欄位:派工日期、派工順序
                            For i As Integer = 0 To dsWIP.Tables(tblAreaEquipment).Rows.Count - 1
                                '1. 檢查是否有派工設備
                                Dim drSelEQP As DataRow() = dsTemp.Tables(tblEQPDispatchState).Select("EquipmentNo = '" &
                                dsWIP.Tables(tblAreaEquipment).Rows(i)("EquipmentNo").ToString() & "'And LotNo = '" & txtLotNo.Text & "'And DispatchDate = '" & strCheckInDate & "'")
                                If drSelEQP.Count > 0 Then '優先顯示派工日期為當天
                                    dsWIP.Tables(tblAreaEquipment).Rows(i)("DispatchOrder") = drSelEQP(0)("DispatchOrder").ToString
                                    If drSelEQP(0)("DispatchDate").ToString <> "" Then
                                        dsWIP.Tables(tblAreaEquipment).Rows(i)("DispatchDate") = drSelEQP(0)("DispatchDate")
                                    End If
                                Else '如非當天派工日期再顯示
                                    Dim drSelEQP2 As DataRow() = dsTemp.Tables(tblEQPDispatchState).Select("EquipmentNo = '" &
                                    dsWIP.Tables(tblAreaEquipment).Rows(i)("EquipmentNo").ToString() & "'And LotNo = '" & txtLotNo.Text & "'")
                                    If drSelEQP2.Length > 0 Then
                                        dsWIP.Tables(tblAreaEquipment).Rows(i)("DispatchOrder") = drSelEQP2(0)("DispatchOrder").ToString
                                        If drSelEQP2(0)("DispatchDate").ToString <> "" Then
                                            dsWIP.Tables(tblAreaEquipment).Rows(i)("DispatchDate") = drSelEQP2(0)("DispatchDate")
                                        End If
                                    End If
                                End If
                            Next
                        End If
                    End If
                End If
            Else
                ExceptionManager.iMESShowDialog(GetExceptionCode(XmlDoc), GetExceptionSysMsg(XmlDoc), GetExceptionStack(XmlDoc))
                Exit Function
            End If

            XmlDoc = Nothing

        Catch ex As iMESException.MESException
            ExceptionManager.iMESShowDialog(ex.ErrorCode, ex.Message, ex.StackTrace)
            Exit Function
        Catch ex As Exception
            ExceptionManager.iMESShowDialog(defWinErrCode, ex.Message, ex.StackTrace)
            Exit Function
        End Try

        funLoadAvailableEquipment = 0


    End Function

    '2023/07/25會議結論， 規格書規畫尚不清晰，此項目註解。
    '0138119: [6.0.7]recipe配方管理优化派工--配方关联设定, 2023-07-20, 19245
    'Private Function funLoadAvailableEquipmentInfo(ByRef LotNo As String) As Integer

    '    funLoadAvailableEquipmentInfo = -1

    '    '組InXml的字串
    '    strIdentity = CombineXMLIdentity(gComputerName, UserId, Now)
    '    strParameter = CombineXMLParameter("lotno", "LotNo", "String", LotNo, "")
    '    strParameter += CombineXMLParameter("getrecipe", "GetRecipe", "Boolean", True, "")
    '    strParameter += CombineXMLParameter("getaccessory", "GetAccessory", "Boolean", blnGetAccessory, "")
    '    strParameter += CombineXMLParameter("multiqclist", "MultiQCList", "Boolean", True, "")
    '    InXml = CombineXMLRequest(strIdentity, strParameter)

    '    Try
    '        OutXml = InvokeSrv("wsWIP.LoadAvailableEquipmentInfo", InXml)

    '        Dim XmlDoc As New XmlDocument
    '        XmlDoc.LoadXml(OutXml)
    '        If ChkExecutionSuccess(XmlDoc) Then
    '            tblAreaEquipment = XmlDoc.GetElementsByTagName("returnvalue").Item(0).SelectNodes("loadavailableequipmentinfo").Item(0).SelectNodes("name").Item(0).InnerXml
    '            '取出Schema,dataset讀取Schema可防止Null Field及DateTime的問題
    '            XmlSchema = XmlDoc.DocumentElement.GetElementsByTagName("loadavailableequipmentinfo").Item(0).SelectNodes("schema").Item(0).InnerXml
    '            If XmlSchema <> "" Then
    '                '將XML讀入String Reader object中,因為Dataset讀入XML時必須透過String Reader物件
    '                tmpStringReader = New System.IO.StringReader(XmlSchema)
    '                dsWIP.ReadXmlSchema(tmpStringReader)
    '                tmpStringReader.Close()
    '            End If
    '            XmlData = XmlDoc.DocumentElement.GetElementsByTagName("loadavailableequipmentinfo").Item(0).SelectNodes("value").Item(0).InnerXml
    '            If XmlData <> "" Then
    '                tmpStringReader = New System.IO.StringReader(XmlData)
    '                dsWIP.ReadXml(tmpStringReader, XmlReadMode.InferSchema)
    '                tmpStringReader.Close()
    '            End If

    '            '加入Check Field
    '            Dim colCheckFlag As New DataColumn
    '            colCheckFlag.ColumnName = "CheckFlag"
    '            colCheckFlag.DataType = System.Type.GetType("System.Boolean")
    '            colCheckFlag.DefaultValue = False
    '            colCheckFlag.AllowDBNull = False
    '            dsWIP.Tables(tblAreaEquipment).Columns.Add(colCheckFlag)
    '            '加入LoadPort
    '            Dim colPort As New DataColumn
    '            colPort.ColumnName = "LoadPort"
    '            colPort.DataType = System.Type.GetType("System.String")
    '            dsWIP.Tables(tblAreaEquipment).Columns.Add(colPort)

    '            '加入點檢識別欄位
    '            dsWIP.Tables(tblAreaEquipment).Columns.Add(New DataColumn("QCType", System.Type.GetType("System.Decimal")))
    '            dsWIP.Tables(tblAreaEquipment).Columns.Add(New DataColumn("QCFinish", System.Type.GetType("System.Decimal")))

    '            '開放可編輯
    '            dsWIP.Tables(tblAreaEquipment).DefaultView.AllowEdit = True

    '            If Not dsWIP.Tables("Chamber") Is Nothing Then
    '                '加入勾選的按鈕
    '                Dim colChamberCheckFlag As New DataColumn
    '                colChamberCheckFlag.ColumnName = "SELECT1"
    '                colChamberCheckFlag.DataType = System.Type.GetType("System.Boolean")
    '                colChamberCheckFlag.DefaultValue = False
    '                colChamberCheckFlag.AllowDBNull = False
    '                dsWIP.Tables("Chamber").Columns.Add(colChamberCheckFlag)
    '                dsWIP.Tables(tblAreaEquipment).DefaultView.AllowEdit = True
    '            End If
    '            'Kevin 20131223,如有模治具則開放用選取的方式
    '            If Not dsWIP.Tables("AccState") Is Nothing Then
    '                '加入勾選的按鈕
    '                Dim colSelect As New DataColumn
    '                colSelect.ColumnName = "Select"
    '                colSelect.DataType = System.Type.GetType("System.Boolean")
    '                colSelect.DefaultValue = False
    '                colSelect.AllowDBNull = False
    '                dsWIP.Tables("AccState").Columns.Add(colSelect)

    '                dsWIP.Tables("AccState").DefaultView.Sort = "AccessoryType,AccessoryNo"
    '                Dim strType As String = ""
    '                Dim drTemp As DataRow()

    '                '預設選取每個類別第一個模治具
    '                'For Each dr As DataRow In dsWIP.Tables(tblAreaEquipment).Rows
    '                '    strType = ""
    '                '    If dr("AllowExecute") = 1 Then '可使用
    '                '        drTemp = dsWIP.Tables("AccState").Select("EquipmentNo = '" & dr("EquipmentNo") & "'")
    '                '        If drTemp.Length > 0 Then
    '                '            '有掛模治具
    '                '            For Each dr1 As DataRow In drTemp
    '                '                If strType = "" Then
    '                '                    strType = dr1("AccessoryType")
    '                '                    dr1("Select") = True
    '                '                ElseIf strType <> dr1("AccessoryType") Then
    '                '                    dr1("Select") = True
    '                '                    strType = dr1("AccessoryType")
    '                '                End If
    '                '            Next
    '                '        End If
    '                '    End If
    '                'Next
    '                '2020/02/26 Grace Mantis 67753 取得此批號於此作業站上的派工資料
    '                Call funLoadWIPEQPDispatchState(LotNo:=LotNo, OPNo:=txtOPNo.Text)
    '                '增加顯示欄位:派工日期、派工順序
    '                If dsWIP.Tables(tblAreaEquipment).Columns.Contains("DispatchOrder") Then
    '                    dsWIP.Tables(tblAreaEquipment).Columns.Remove("DispatchOrder")
    '                End If
    '                Dim colDispatchDate As New DataColumn
    '                colDispatchDate.ColumnName = "DispatchDate"
    '                colDispatchDate.DataType = System.Type.GetType("System.DateTime")
    '                dsWIP.Tables(tblAreaEquipment).Columns.Add(colDispatchDate)
    '                Dim colDispatchOrder As New DataColumn
    '                colDispatchOrder.ColumnName = "DispatchOrder"
    '                colDispatchOrder.DataType = System.Type.GetType("System.String")
    '                dsWIP.Tables(tblAreaEquipment).Columns.Add(colDispatchOrder)

    '                If Not IsNothing(dsTemp.Tables(tblEQPDispatchState)) Then
    '                    If dsTemp.Tables(tblEQPDispatchState).Rows.Count > 0 Then
    '                        Dim strCheckInDate As String = Now.ToString("yyyy/MM/dd") 'Check In 日期
    '                        '2020/11/05 Steven Mantis:0081316: '增加顯示欄位:派工日期、派工順序
    '                        For i As Integer = 0 To dsWIP.Tables(tblAreaEquipment).Rows.Count - 1
    '                            '1. 檢查是否有派工設備
    '                            Dim drSelEQP As DataRow() = dsTemp.Tables(tblEQPDispatchState).Select("EquipmentNo = '" &
    '                            dsWIP.Tables(tblAreaEquipment).Rows(i)("EquipmentNo").ToString() & "'And LotNo = '" & txtLotNo.Text & "'And DispatchDate = '" & strCheckInDate & "'")
    '                            If drSelEQP.Count > 0 Then '優先顯示派工日期為當天
    '                                dsWIP.Tables(tblAreaEquipment).Rows(i)("DispatchOrder") = drSelEQP(0)("DispatchOrder").ToString
    '                                If drSelEQP(0)("DispatchDate").ToString <> "" Then
    '                                    dsWIP.Tables(tblAreaEquipment).Rows(i)("DispatchDate") = drSelEQP(0)("DispatchDate")
    '                                End If
    '                            Else '如非當天派工日期再顯示
    '                                Dim drSelEQP2 As DataRow() = dsTemp.Tables(tblEQPDispatchState).Select("EquipmentNo = '" &
    '                                dsWIP.Tables(tblAreaEquipment).Rows(i)("EquipmentNo").ToString() & "'And LotNo = '" & txtLotNo.Text & "'")
    '                                If drSelEQP2.Length > 0 Then
    '                                    dsWIP.Tables(tblAreaEquipment).Rows(i)("DispatchOrder") = drSelEQP2(0)("DispatchOrder").ToString
    '                                    If drSelEQP2(0)("DispatchDate").ToString <> "" Then
    '                                        dsWIP.Tables(tblAreaEquipment).Rows(i)("DispatchDate") = drSelEQP2(0)("DispatchDate")
    '                                    End If
    '                                End If
    '                            End If
    '                        Next
    '                    End If
    '                End If
    '            End If
    '        Else
    '            ExceptionManager.iMESShowDialog(GetExceptionCode(XmlDoc), GetExceptionSysMsg(XmlDoc), GetExceptionStack(XmlDoc))
    '            Exit Function
    '        End If

    '        XmlDoc = Nothing

    '    Catch ex As iMESException.MESException
    '        ExceptionManager.iMESShowDialog(ex.ErrorCode, ex.Message, ex.StackTrace)
    '        Exit Function
    '    Catch ex As Exception
    '        ExceptionManager.iMESShowDialog(defWinErrCode, ex.Message, ex.StackTrace)
    '        Exit Function
    '    End Try

    '    funLoadAvailableEquipmentInfo = 0


    'End Function

    Private Function funLoadAvailableEquipment_Chamber(ByRef LotNo As String) As Integer

        funLoadAvailableEquipment_Chamber = -1

        '組InXml的字串
        strIdentity = CombineXMLIdentity(gComputerName, UserId, Now)
        strParameter = CombineXMLParameter("lotno", "LotNo", "String", LotNo, "")
        strParameter += CombineXMLParameter("getrecipe", "GetRecipe", "Boolean", True, "")
        strParameter += CombineXMLParameter("getaccessory", "GetAccessory", "Boolean", blnGetAccessory, "")
        strParameter += CombineXMLParameter("multiqclist", "MultiQCList", "Boolean", True, "")
        InXml = CombineXMLRequest(strIdentity, strParameter)

        Try
            ' 2016 YF, OutXml = wsWIP.LoadAvailableEquipment_All(InXml)
            OutXml = InvokeSrv("wsWIP.LoadAvailableEquipment_All", InXml)

            Dim XmlDoc As New XmlDocument
            XmlDoc.LoadXml(OutXml)
            If ChkExecutionSuccess(XmlDoc) Then
                tblAreaEquipment = XmlDoc.GetElementsByTagName("returnvalue").Item(0).SelectNodes("loadavailableequipment_all").Item(0).SelectNodes("name").Item(0).InnerXml
                '取出Schema,dataset讀取Schema可防止Null Field及DateTime的問題
                XmlSchema = XmlDoc.DocumentElement.GetElementsByTagName("loadavailableequipment_all").Item(0).SelectNodes("schema").Item(0).InnerXml
                If XmlSchema <> "" Then
                    '將XML讀入String Reader object中,因為Dataset讀入XML時必須透過String Reader物件
                    tmpStringReader = New System.IO.StringReader(XmlSchema)
                    dsWIP.ReadXmlSchema(tmpStringReader)
                    tmpStringReader.Close()
                End If
                XmlData = XmlDoc.DocumentElement.GetElementsByTagName("loadavailableequipment_all").Item(0).SelectNodes("value").Item(0).InnerXml
                If XmlData <> "" Then
                    tmpStringReader = New System.IO.StringReader(XmlData)
                    dsWIP.ReadXml(tmpStringReader, XmlReadMode.InferSchema)
                    tmpStringReader.Close()
                End If

                '加入Check Field
                Dim colCheckFlag As New DataColumn
                colCheckFlag.ColumnName = "CheckFlag"
                colCheckFlag.DataType = System.Type.GetType("System.Boolean")
                colCheckFlag.DefaultValue = False
                colCheckFlag.AllowDBNull = False
                dsWIP.Tables(tblAreaEquipment).Columns.Add(colCheckFlag)
                '加入LoadPort
                Dim colPort As New DataColumn
                colPort.ColumnName = "LoadPort"
                colPort.DataType = System.Type.GetType("System.String")
                dsWIP.Tables(tblAreaEquipment).Columns.Add(colPort)

                '加入點檢識別欄位
                dsWIP.Tables(tblAreaEquipment).Columns.Add(New DataColumn("QCType", System.Type.GetType("System.Decimal")))
                dsWIP.Tables(tblAreaEquipment).Columns.Add(New DataColumn("QCFinish", System.Type.GetType("System.Decimal")))

                '開放可編輯
                dsWIP.Tables(tblAreaEquipment).DefaultView.AllowEdit = True

                'Kevin 20131223,如有模治具則開放用選取的方式
                If Not dsWIP.Tables("AccState") Is Nothing Then
                    '加入勾選的按鈕
                    Dim colSelect As New DataColumn
                    colSelect.ColumnName = "Select"
                    colSelect.DataType = System.Type.GetType("System.Boolean")
                    colSelect.DefaultValue = False
                    colSelect.AllowDBNull = False
                    dsWIP.Tables("AccState").Columns.Add(colSelect)

                    dsWIP.Tables("AccState").DefaultView.Sort = "AccessoryType,AccessoryNo"
                    Dim strType As String = ""
                    Dim drTemp As DataRow()

                    '預設選取每個類別第一個模治具
                    'For Each dr As DataRow In dsWIP.Tables(tblAreaEquipment).Rows
                    '    strType = ""
                    '    If dr("AllowExecute") = 1 Then '可使用
                    '        drTemp = dsWIP.Tables("AccState").Select("EquipmentNo = '" & dr("EquipmentNo") & "'")
                    '        If drTemp.Length > 0 Then
                    '            '有掛模治具
                    '            For Each dr1 As DataRow In drTemp
                    '                If strType = "" Then
                    '                    strType = dr1("AccessoryType")
                    '                    dr1("Select") = True
                    '                ElseIf strType <> dr1("AccessoryType") Then
                    '                    dr1("Select") = True
                    '                    strType = dr1("AccessoryType")
                    '                End If
                    '            Next
                    '        End If
                    '    End If
                    'Next
                End If
            Else
                ExceptionManager.iMESShowDialog(GetExceptionCode(XmlDoc), GetExceptionSysMsg(XmlDoc), GetExceptionStack(XmlDoc))
                Exit Function
            End If

            XmlDoc = Nothing

        Catch ex As iMESException.MESException
            ExceptionManager.iMESShowDialog(ex.ErrorCode, ex.Message, ex.StackTrace)
            Exit Function
        Catch ex As Exception
            ExceptionManager.iMESShowDialog(defWinErrCode, ex.Message, ex.StackTrace)
            Exit Function
        End Try

        funLoadAvailableEquipment_Chamber = 0


    End Function
    Private Function funGetShift() As Integer

        funGetShift = -1

        Dim strShiftNo As String = "N/A"
        '組InXml的字串
        strIdentity = CombineXMLIdentity(gComputerName, UserId, Now)
        strParameter = CombineXMLParameter("userno", "UserNo", "String", UserId, "")
        InXml = CombineXMLRequest(strIdentity, strParameter)

        Try
            OutXml = InvokeSrv("wsUSR.GetShift", InXml)

            Dim XmlDoc As New XmlDocument
            XmlDoc.LoadXml(OutXml)
            If ChkExecutionSuccess(XmlDoc) Then
                '取出ShiftNo
                If XmlDoc.GetElementsByTagName("shiftno").Item(0).SelectNodes("value").Count > 0 Then
                    strShiftNo = XmlDoc.DocumentElement.GetElementsByTagName("shiftno").Item(0).SelectNodes("value").Item(0).InnerText
                End If
            Else
                ExceptionManager.iMESShowDialog(GetExceptionCode(XmlDoc), GetExceptionSysMsg(XmlDoc), GetExceptionStack(XmlDoc))
                Exit Function
            End If

            XmlDoc = Nothing

        Catch ex As iMESException.MESException
            ExceptionManager.iMESShowDialog(ex.ErrorCode, ex.Message, ex.StackTrace)
            Exit Function
        Catch ex As Exception
            ExceptionManager.iMESShowDialog(defWinErrCode, ex.Message, ex.StackTrace)
            Exit Function
        End Try

        txtShiftNo.Text = strShiftNo

        funGetShift = 0

    End Function

    Private Function funGetOPDescription(ByRef LotNo As String) As Integer

        funGetOPDescription = -1

        '組InXml的字串
        strIdentity = CombineXMLIdentity(gComputerName, UserId, Now)
        strParameter = CombineXMLParameter("lotno", "LotNo", "String", LotNo, "")
        InXml = CombineXMLRequest(strIdentity, strParameter)

        Try
            OutXml = InvokeSrv("wsWIP.GetLotOPDescription", InXml)

            Dim XmlDoc As New XmlDocument
            XmlDoc.LoadXml(OutXml)
            If ChkExecutionSuccess(XmlDoc) Then
                If XmlDoc.GetElementsByTagName("opdescription").Count > 0 Then
                    If XmlDoc.GetElementsByTagName("opdescription").Item(0).SelectNodes("value").Count > 0 Then
                        txtOPDescription.Text = XmlDoc.DocumentElement.GetElementsByTagName("opdescription").Item(0).SelectNodes("value").Item(0).InnerText
                    End If
                End If
            Else
                ExceptionManager.iMESShowDialog(GetExceptionCode(XmlDoc), GetExceptionSysMsg(XmlDoc), GetExceptionStack(XmlDoc))
                Exit Function
            End If

            XmlDoc = Nothing

        Catch ex As iMESException.MESException
            ExceptionManager.iMESShowDialog(ex.ErrorCode, ex.Message, ex.StackTrace)
            Exit Function
        Catch ex As Exception
            ExceptionManager.iMESShowDialog(defWinErrCode, ex.Message, ex.StackTrace)
            Exit Function
        End Try

        funGetOPDescription = 0

    End Function

    Private Function funLoadSubOP() As Integer

        funLoadSubOP = -1

        '組InXml的字串
        strIdentity = CombineXMLIdentity(gComputerName, gUserNo, GetNow())

        '用opreference決定現在要用產品 or Module去抓,2011/04/08,by Sherry
        If dsWIP.Tables(tblLotState).Rows(0)("OPReference") = 1 Then 'Module
            strParameter = CombineXMLParameter("productno", "ProductNo", "String", CInput(dsWIP.Tables(tblLotState).Rows(0)("ModuleNo").ToString), "")
            strParameter += CombineXMLParameter("productversion", "ProductVersion", "String", CInput(dsWIP.Tables(tblLotState).Rows(0)("ModuleVersion").ToString), "")
        Else 'Product
            strParameter = CombineXMLParameter("productno", "ProductNo", "String", txtProductNo.Text, "")
            strParameter += CombineXMLParameter("productversion", "ProductVersion", "String", dsWIP.Tables(tblLotState).Rows(0)("ProductVersion").ToString, "")
        End If
        strParameter += CombineXMLParameter("opno", "OPNo", "String", CInput(txtOPNo.Text), "")   '將OPNo加上CInput轉換特殊字元,2010/04/08,by yumei

        InXml = CombineXMLRequest(strIdentity, strParameter)

        Try
            OutXml = InvokeSrv("wsPRD.LoadPRDOpSubOp", InXml)


            Dim XmlDoc As New XmlDocument
            XmlDoc.LoadXml(OutXml)
            If ChkExecutionSuccess(XmlDoc) Then
                '讀取取出資料表之名稱
                tblSubOP = XmlDoc.GetElementsByTagName("returnvalue").Item(0).SelectNodes("loadprdopsubop").Item(0).SelectNodes("name").Item(0).InnerXml
                '取出Schema,dataset讀取Schema可防止Null Field及DateTime的問題
                XmlSchema = XmlDoc.DocumentElement.GetElementsByTagName("loadprdopsubop").Item(0).SelectNodes("schema").Item(0).InnerXml
                If XmlSchema <> "" Then
                    '將XML讀入String Reader object中,因為Dataset讀入XML時必須透過String Reader物件
                    tmpStringReader = New System.IO.StringReader(XmlSchema)
                    dsWIP.ReadXmlSchema(tmpStringReader)
                    tmpStringReader.Close()
                End If
                '取出Data
                XmlData = XmlDoc.DocumentElement.GetElementsByTagName("loadprdopsubop").Item(0).SelectNodes("value").Item(0).InnerXml
                If XmlData <> "" Then
                    tmpStringReader = New System.IO.StringReader(XmlData)
                    dsWIP.ReadXml(tmpStringReader, XmlReadMode.InferSchema)
                    tmpStringReader.Close()
                End If
                dsWIP.Tables(tblSubOP).DefaultView.Sort = "SubOPNo"
                iugSubOP.iMESUltraGrid.DataSource = dsWIP.Tables(tblSubOP).DefaultView
            Else
                ExceptionManager.iMESShowDialog(GetExceptionCode(XmlDoc), GetExceptionSysMsg(XmlDoc), GetExceptionStack(XmlDoc))
                Exit Function
            End If

            XmlDoc = Nothing

        Catch ex As iMESException.MESException
            ExceptionManager.iMESShowDialog(ex.ErrorCode, ex.Message, ex.StackTrace)
            Exit Function
        Catch ex As Exception
            ExceptionManager.iMESShowDialog(defWinErrCode, ex.Message, ex.StackTrace)
            Exit Function
        End Try

        funLoadSubOP = 0

    End Function

    '自己添加20240118
    Private Function funLoadCustomTestData() As Integer

        funLoadCustomTestData = -1

        '組InXml的字串
        strIdentity = CombineXMLIdentity(gComputerName, gUserNo, GetNow())


        strParameter = CombineXMLParameter("subopno", "SubOpNo", "String", txtOPNo.Text, "")   '將OPNo加上CInput轉換特殊字元,2010/04/08,by yumei

        InXml = CombineXMLRequest(strIdentity, strParameter)

        Try
            OutXml = InvokeSrv("ABC.wsWIP_21703.LoadtblCustomTestData", InXml)


            Dim XmlDoc As New XmlDocument
            XmlDoc.LoadXml(OutXml)
            If ChkExecutionSuccess(XmlDoc) Then
                '讀取取出資料表之名稱
                tblCustomTestData = XmlDoc.GetElementsByTagName("returnvalue").Item(0).SelectNodes("loadTblCustomTestData").Item(0).SelectNodes("name").Item(0).InnerXml
                '取出Schema,dataset讀取Schema可防止Null Field及DateTime的問題
                XmlSchema = XmlDoc.DocumentElement.GetElementsByTagName("loadTblCustomTestData").Item(0).SelectNodes("schema").Item(0).InnerXml
                If XmlSchema <> "" Then
                    '將XML讀入String Reader object中,因為Dataset讀入XML時必須透過String Reader物件
                    tmpStringReader = New System.IO.StringReader(XmlSchema)
                    dsWIP.ReadXmlSchema(tmpStringReader)
                    tmpStringReader.Close()
                End If
                '取出Data
                XmlData = XmlDoc.DocumentElement.GetElementsByTagName("loadTblCustomTestData").Item(0).SelectNodes("value").Item(0).InnerXml
                If XmlData <> "" Then
                    tmpStringReader = New System.IO.StringReader(XmlData)
                    dsWIP.ReadXml(tmpStringReader, XmlReadMode.InferSchema)
                    tmpStringReader.Close()
                End If





                '加入Check Field
                Dim colCheckFlag As New DataColumn
                colCheckFlag.ColumnName = "CheckFlag"
                colCheckFlag.DataType = System.Type.GetType("System.Boolean")
                colCheckFlag.DefaultValue = False
                colCheckFlag.AllowDBNull = False
                dsWIP.Tables(tblCustomTestData).Columns.Add(colCheckFlag)

                '开放编辑
                dsWIP.Tables(tblCustomTestData).DefaultView.AllowEdit = True


                dsWIP.Tables(tblCustomTestData).DefaultView.Sort = "SubOPNo"
                iugTestData21703.iMESUltraGrid.DataSource = dsWIP.Tables(tblCustomTestData).DefaultView
            Else
                ExceptionManager.iMESShowDialog(GetExceptionCode(XmlDoc), GetExceptionSysMsg(XmlDoc), GetExceptionStack(XmlDoc))
                Exit Function
            End If

            XmlDoc = Nothing

        Catch ex As iMESException.MESException
            ExceptionManager.iMESShowDialog(ex.ErrorCode, ex.Message, ex.StackTrace)
            Exit Function
        Catch ex As Exception
            ExceptionManager.iMESShowDialog(defWinErrCode, ex.Message, ex.StackTrace)
            Exit Function
        End Try



        funLoadCustomTestData = 0

    End Function


    Private Function funLoadLotLoginState() As Integer

        funLoadLotLoginState = -1

        '組InXml的字串
        strIdentity = CombineXMLIdentity(gComputerName, UserId, Now)
        strParameter = CombineXMLParameter("lotno", "LotNo", "String", CInput(LotNo), "")
        strParameter += CombineXMLParameter("opno", "OPNo", "String", CInput(dsWIP.Tables(tblLotState).Rows(0)("OPNo").ToString), "")
        strParameter += CombineXMLParameter("userno", "UserNo", "String", CInput(UserId), "")
        Dim strAdditional As String
        strAdditional = CombineXMLAdditional(CombineAddXML_Condition("CheckOutTime is null"))
        strParameter += strAdditional

        InXml = CombineXMLRequest(strIdentity, strParameter)

        Try
            OutXml = InvokeSrv("wsWIP.LoadLotLoginState", InXml)

            Dim XmlDoc As New XmlDocument
            XmlDoc.LoadXml(OutXml)
            If ChkExecutionSuccess(XmlDoc) Then
                '讀取取出資料表之名稱
                tblLotLoginState = XmlDoc.GetElementsByTagName("returnvalue").Item(0).SelectNodes("loadlotloginstate").Item(0).SelectNodes("name").Item(0).InnerXml
                '取出Schema,dataset讀取Schema可防止Null Field及DateTime的問題
                XmlSchema = XmlDoc.DocumentElement.GetElementsByTagName("loadlotloginstate").Item(0).SelectNodes("schema").Item(0).InnerXml
                If XmlSchema <> "" Then
                    '將XML讀入String Reader object中,因為Dataset讀入XML時必須透過String Reader物件
                    tmpStringReader = New System.IO.StringReader(XmlSchema)
                    dsWIP.ReadXmlSchema(tmpStringReader)
                    tmpStringReader.Close()
                End If
                '取出Data
                XmlData = XmlDoc.DocumentElement.GetElementsByTagName("loadlotloginstate").Item(0).SelectNodes("value").Item(0).InnerXml
                If XmlData <> "" Then
                    tmpStringReader = New System.IO.StringReader(XmlData)
                    dsWIP.ReadXml(tmpStringReader, XmlReadMode.InferSchema)
                    tmpStringReader.Close()
                End If
            Else
                ExceptionManager.iMESShowDialog(GetExceptionCode(XmlDoc), GetExceptionSysMsg(XmlDoc), GetExceptionStack(XmlDoc))
                Exit Function
            End If

            XmlDoc = Nothing

        Catch ex As iMESException.MESException
            ExceptionManager.iMESShowDialog(ex.ErrorCode, ex.Message, ex.StackTrace)
            Exit Function
        Catch ex As Exception
            ExceptionManager.iMESShowDialog(defWinErrCode, ex.Message, ex.StackTrace)
            Exit Function
        End Try

        funLoadLotLoginState = 0

    End Function
    Private Function funLoadMOMaterialState(ByVal MONo As String,
                                            ByVal MaterialLotNo As String,
                                            Optional ByVal MaterialNo As String = defString) As Integer

        funLoadMOMaterialState = -1

        Dim XmlDoc As New XmlDocument

        '先判斷DS中是否已有相同名稱的資料表,若有需先remove,否則會有錯誤
        If Not IsNothing(dsWIP.Tables(tblMOMaterialState)) Then
            dsWIP.Tables.Remove(tblMOMaterialState)
        End If

        '組InXml的字串

        strIdentity = CombineXMLIdentity(gComputerName, gUserNo, GetNow())
        strParameter = CombineXMLParameter("mono", "MONo", "String", CInput(MONo), "")
        strParameter += CombineXMLParameter("materiallotno", "MaterialLotNo", "String", CInput(MaterialLotNo), "")
        If MaterialNo <> defString Then
            strParameter += CombineXMLParameter("materialno", "MaterialNo", "String", CInput(MaterialNo), "")
        End If
        InXml = CombineXMLRequest(strIdentity, strParameter)

        Try
            ' 2016 YF, Using wsOE As New wsOE.wsOE
            ' 2016 YF, wsOE.Url = LocalizeWebService(wsOE.Url.ToString)
            ' 2016 YF, wsOE.EnableDecompression = True
            ' 2016 YF, OutXml = wsOE.LoadMOMaterialState(InXml)
            OutXml = InvokeSrv("wsOE.LoadMOMaterialState", InXml)

            ' 2016 YF, End Using

            XmlDoc.LoadXml(OutXml)
            If ChkExecutionSuccess(XmlDoc) Then
                tblMOMaterialState = XmlDoc.GetElementsByTagName("returnvalue").Item(0).SelectNodes("loadmomaterialstate").Item(0).SelectNodes("name").Item(0).InnerXml
                '取出Schema,dataset讀取Schema可防止Null Field及DateTime的問題
                XmlSchema = XmlDoc.DocumentElement.GetElementsByTagName("loadmomaterialstate").Item(0).SelectNodes("schema").Item(0).InnerXml
                If XmlSchema <> "" Then
                    '將XML讀入String Reader object中,因為Dataset讀入XML時必須透過String Reader物件
                    tmpStringReader = New System.IO.StringReader(XmlSchema)
                    dsWIP.ReadXmlSchema(tmpStringReader)
                    tmpStringReader.Close()
                End If
                XmlData = XmlDoc.DocumentElement.GetElementsByTagName("loadmomaterialstate").Item(0).SelectNodes("value").Item(0).InnerXml
                If XmlData <> "" Then
                    tmpStringReader = New System.IO.StringReader(XmlData)
                    dsWIP.ReadXml(tmpStringReader, XmlReadMode.InferSchema)
                    tmpStringReader.Close()
                End If
            Else
                ExceptionManager.iMESShowDialog(GetExceptionCode(XmlDoc), GetExceptionSysMsg(XmlDoc), GetExceptionStack(XmlDoc))
                Exit Function
            End If

            XmlDoc = Nothing

        Catch ex As iMESException.MESException
            ExceptionManager.iMESShowDialog(ex.ErrorCode, ex.Message, ex.StackTrace)
            Exit Function
        Catch ex As Exception
            ExceptionManager.iMESShowDialog(defWinErrCode, ex.Message, ex.StackTrace)
            Exit Function
        End Try

        funLoadMOMaterialState = 0

    End Function

    Private Function funLoadWIPInventory_Raw(ByVal MaterialLotNo As String,
                                             Optional ByVal MaterialNo As String = defString,
                                             Optional ByVal InventoryNo As String = defString) As Integer

        funLoadWIPInventory_Raw = -1

        Dim XmlDoc As New XmlDocument

        '先判斷DS中是否已有相同名稱的資料表,若有需先remove,否則會有錯誤
        If Not IsNothing(dsWIP.Tables(tblWIPINVRaw)) Then
            dsWIP.Tables.Remove(tblWIPINVRaw)
        End If

        '組InXml的字串

        strIdentity = CombineXMLIdentity(gComputerName, gUserNo, GetNow())
        strParameter = CombineXMLParameter("materiallotno", "MaterialLotNo", "String", CInput(MaterialLotNo), "")
        '2019/06/17 Shih Kai, Mantis:0058359 多加入條件參數
        If MaterialNo <> defString Then
            strParameter += CombineXMLParameter("materialno", "MaterialNo", "String", CInput(MaterialNo), "")
        End If
        If InventoryNo <> defString Then
            strParameter += CombineXMLParameter("inventoryno", "InventoryNo", "String", CInput(InventoryNo), "")
        End If

        InXml = CombineXMLRequest(strIdentity, strParameter)

        Try
            OutXml = InvokeSrv("wsINV.LoadWIPInventory_Raw", InXml)

            XmlDoc.LoadXml(OutXml)
            If ChkExecutionSuccess(XmlDoc) Then
                tblWIPINVRaw = XmlDoc.GetElementsByTagName("returnvalue").Item(0).SelectNodes("loadwipinventory_raw").Item(0).SelectNodes("name").Item(0).InnerXml
                '取出Schema,dataset讀取Schema可防止Null Field及DateTime的問題
                XmlSchema = XmlDoc.DocumentElement.GetElementsByTagName("loadwipinventory_raw").Item(0).SelectNodes("schema").Item(0).InnerXml
                If XmlSchema <> "" Then
                    '將XML讀入String Reader object中,因為Dataset讀入XML時必須透過String Reader物件
                    tmpStringReader = New System.IO.StringReader(XmlSchema)
                    dsWIP.ReadXmlSchema(tmpStringReader)
                    tmpStringReader.Close()
                End If
                XmlData = XmlDoc.DocumentElement.GetElementsByTagName("loadwipinventory_raw").Item(0).SelectNodes("value").Item(0).InnerXml
                If XmlData <> "" Then
                    tmpStringReader = New System.IO.StringReader(XmlData)
                    dsWIP.ReadXml(tmpStringReader, XmlReadMode.InferSchema)
                    tmpStringReader.Close()
                End If
            Else
                ExceptionManager.iMESShowDialog(GetExceptionCode(XmlDoc), GetExceptionSysMsg(XmlDoc), GetExceptionStack(XmlDoc))
                Exit Function
            End If

            XmlDoc = Nothing

        Catch ex As iMESException.MESException
            ExceptionManager.iMESShowDialog(ex.ErrorCode, ex.Message, ex.StackTrace)
            Exit Function
        Catch ex As Exception
            ExceptionManager.iMESShowDialog(defWinErrCode, ex.Message, ex.StackTrace)
            Exit Function
        End Try

        funLoadWIPInventory_Raw = 0

    End Function

    Private Function funLoadWIPInventory_SEMI(ByVal LotNo As String,
                                             Optional ByVal ProductNo As String = defString,
                                             Optional ByVal InventoryNo As String = defString) As Integer

        funLoadWIPInventory_SEMI = -1

        Dim XmlDoc As New XmlDocument

        '先判斷DS中是否已有相同名稱的資料表,若有需先remove,否則會有錯誤
        If Not IsNothing(dsWIP.Tables(tblWIPINVSEMI)) Then
            dsWIP.Tables.Remove(tblWIPINVSEMI)
        End If

        '組InXml的字串

        strIdentity = CombineXMLIdentity(gComputerName, gUserNo, GetNow())
        strParameter = CombineXMLParameter("lotno", "LotNo", "String", CInput(LotNo), "")
        '2019/06/17 Shih Kai, Mantis:0058359 多加入條件參數
        If ProductNo <> defString Then
            strParameter += CombineXMLParameter("productno", "ProductNo", "String", CInput(ProductNo), "")
        End If
        If InventoryNo <> defString Then
            strParameter += CombineXMLParameter("inventoryno", "InventoryNo", "String", CInput(InventoryNo), "")
        End If

        InXml = CombineXMLRequest(strIdentity, strParameter)

        Try
            OutXml = InvokeSrv("wsWIP.LoadWIPInventory_SEMI", InXml)

            XmlDoc.LoadXml(OutXml)
            If ChkExecutionSuccess(XmlDoc) Then
                tblWIPINVSEMI = XmlDoc.GetElementsByTagName("returnvalue").Item(0).SelectNodes("loadwipinventory_semi").Item(0).SelectNodes("name").Item(0).InnerXml
                '取出Schema,dataset讀取Schema可防止Null Field及DateTime的問題
                XmlSchema = XmlDoc.DocumentElement.GetElementsByTagName("loadwipinventory_semi").Item(0).SelectNodes("schema").Item(0).InnerXml
                If XmlSchema <> "" Then
                    '將XML讀入String Reader object中,因為Dataset讀入XML時必須透過String Reader物件
                    tmpStringReader = New System.IO.StringReader(XmlSchema)
                    dsWIP.ReadXmlSchema(tmpStringReader)
                    tmpStringReader.Close()
                End If
                XmlData = XmlDoc.DocumentElement.GetElementsByTagName("loadwipinventory_semi").Item(0).SelectNodes("value").Item(0).InnerXml
                If XmlData <> "" Then
                    tmpStringReader = New System.IO.StringReader(XmlData)
                    dsWIP.ReadXml(tmpStringReader, XmlReadMode.InferSchema)
                    tmpStringReader.Close()
                End If
            Else
                ExceptionManager.iMESShowDialog(GetExceptionCode(XmlDoc), GetExceptionSysMsg(XmlDoc), GetExceptionStack(XmlDoc))
                Exit Function
            End If

            XmlDoc = Nothing

        Catch ex As iMESException.MESException
            ExceptionManager.iMESShowDialog(ex.ErrorCode, ex.Message, ex.StackTrace)
            Exit Function
        Catch ex As Exception
            ExceptionManager.iMESShowDialog(defWinErrCode, ex.Message, ex.StackTrace)
            Exit Function
        End Try

        funLoadWIPInventory_SEMI = 0

    End Function

    '取出用料清單
    Private Function funLoadSubstituteMaterial_Main(ByVal LotNo As String, ByVal MaterialNo As String,
                                                    ByVal UnitNo As String) As Integer
        funLoadSubstituteMaterial_Main = -1

        Dim XmlDoc As New XmlDocument                        '處理Xml字串之物件
        Dim tmpStringReader As System.IO.StringReader        '將字串轉換成可讀入DataSet的物件
        Dim InXml, OutXml, strIdentity, strParameter, XmlData, XmlSchema As String

        '先判斷DS中是否已有相同名稱的資料表,若有需先remove,否則會有錯誤
        If Not IsNothing(dsWIP.Tables(tblSubstituteMaterial)) Then
            dsWIP.Tables.Remove(tblSubstituteMaterial)
        End If

        '組InXml的字串

        strIdentity = CombineXMLIdentity(gComputerName, gUserNo, GetNow())
        strParameter = CombineXMLParameter("lotno", "LotNo", "String", CInput(LotNo), "")
        strParameter += CombineXMLParameter("materialno", "MaterialNo", "String", CInput(MaterialNo), "")
        strParameter += CombineXMLParameter("unitno", "UnitNo", "String", CInput(UnitNo), "")
        InXml = CombineXMLRequest(strIdentity, strParameter)

        Try
            OutXml = InvokeSrv("wsWIP.LoadSubstituteMaterial_Main", InXml)

            XmlDoc.LoadXml(OutXml)
            If ChkExecutionSuccess(XmlDoc) Then
                tblSubstituteMaterial = XmlDoc.GetElementsByTagName("returnvalue").Item(0).SelectNodes("loadsubstitutematerial_main").Item(0).SelectNodes("name").Item(0).InnerXml
                '取出Schema,dataset讀取Schema可防止Null Field及DateTime的問題
                XmlSchema = XmlDoc.DocumentElement.GetElementsByTagName("loadsubstitutematerial_main").Item(0).SelectNodes("schema").Item(0).InnerXml
                If XmlSchema <> "" Then
                    '將XML讀入String Reader object中,因為Dataset讀入XML時必須透過String Reader物件
                    tmpStringReader = New System.IO.StringReader(XmlSchema)
                    dsWIP.ReadXmlSchema(tmpStringReader)
                    tmpStringReader.Close()
                End If
                XmlData = XmlDoc.DocumentElement.GetElementsByTagName("loadsubstitutematerial_main").Item(0).SelectNodes("value").Item(0).InnerXml
                If XmlData <> "" Then
                    tmpStringReader = New System.IO.StringReader(XmlData)
                    dsWIP.ReadXml(tmpStringReader, XmlReadMode.InferSchema)
                    tmpStringReader.Close()
                End If
            Else
                ExceptionManager.iMESShowDialog(GetExceptionCode(XmlDoc), GetExceptionSysMsg(XmlDoc), GetExceptionStack(XmlDoc))
                Exit Function
            End If

        Catch ex As iMESException.MESException
            ExceptionManager.iMESShowDialog(ex.ErrorCode, ex.Message, ex.StackTrace)
            Exit Function
        Catch ex As Exception
            ExceptionManager.iMESShowDialog(defWinErrCode, ex.Message, ex.StackTrace)
            Exit Function
        Finally
            XmlDoc = Nothing
            tmpStringReader = Nothing
        End Try

        funLoadSubstituteMaterial_Main = 0

    End Function

    ''' <summary>
    ''' 2016/10/19 YF, 依設備及工單取出設備上料現況
    ''' </summary>
    ''' <param name="pEquipmentNo"></param>
    ''' <param name="pMONo"></param>
    ''' <param name="pTable"></param>
    ''' <param name="pPutInPlaceType">2：原物料線邊倉(RAW) 3：工單存料現況(MO) 4：半成品線邊倉(SEMI)</param>
    ''' <returns></returns>
    Private Function LoadEQPMaterialState(ByRef pTable As DataTable, Optional ByVal pEquipmentNo As String = defString,
                                          Optional ByVal pMONo As String = defString, Optional ByVal pMaterialNo As String = defString,
                                          Optional ByVal pPutInPlaceType As Integer = 3) As Boolean

        Dim result As Boolean = False
        Dim XmlDoc As New XmlDocument
        Dim dsTemp As New DataSet

        Try

            Cursor.Current = Cursors.WaitCursor

            '組InXml的字串
            strIdentity = CombineXMLIdentity(gComputerName, gUserNo, GetNow())
            strParameter = ""

            If (pEquipmentNo <> defString) Then
                strParameter += CombineXMLParameter("equipmentno", "EquipmentNo", "String", pEquipmentNo, "")
            End If

            '不需要工单 新设备上料14278
            'If (pMONo <> defString) Then
            '    strParameter += CombineXMLParameter("mono", "MONo", "String", CInput(pMONo), "")
            'End If

            If (pMaterialNo <> defString) Then
                strParameter += CombineXMLParameter("materialno", "MaterialNo", "String", CInput(pMaterialNo), "")
            End If

            ' 取出剩餘數量>0
            Dim strAdditional As String
            strAdditional = CombineXMLAdditional(CombineAddXML_Condition("Qty > 0"))
            strParameter += strAdditional

            InXml = CombineXMLRequest(strIdentity, strParameter)

            OutXml = InvokeSrv("wsWIP_Material.LoadWIPEQPMaterialState", InXml)

            XmlDoc.LoadXml(OutXml)

            If ChkExecutionSuccess(XmlDoc) Then

                '取出Schema,dataset讀取Schema可防止Null Field及DateTime的問題
                XmlSchema = XmlDoc.DocumentElement.GetElementsByTagName("loadwipeqpmaterialstate").Item(0).SelectNodes("schema").Item(0).InnerXml

                If XmlSchema <> "" Then
                    '將XML讀入String Reader object中,因為Dataset讀入XML時必須透過String Reader物件
                    tmpStringReader = New System.IO.StringReader(XmlSchema)
                    dsTemp.ReadXmlSchema(tmpStringReader)
                    tmpStringReader.Close()
                End If

                XmlData = XmlDoc.DocumentElement.GetElementsByTagName("loadwipeqpmaterialstate").Item(0).SelectNodes("value").Item(0).InnerXml

                If XmlData <> "" Then
                    tmpStringReader = New System.IO.StringReader(XmlData)
                    dsTemp.ReadXml(tmpStringReader, XmlReadMode.InferSchema)
                    tmpStringReader.Close()
                End If

                If (dsTemp.Tables.Count > 0) Then
                    pTable = dsTemp.Tables(0).Copy
                    result = True
                End If

            Else
                ExceptionManager.iMESShowDialog(GetExceptionCode(XmlDoc), GetExceptionSysMsg(XmlDoc), GetExceptionStack(XmlDoc))
            End If

        Catch ex As iMESException.MESException
            ExceptionManager.iMESShowDialog(ex.ErrorCode, ex.Message, ex.StackTrace)
        Catch ex As Exception
            ExceptionManager.iMESShowDialog(defWinErrCode, ex.Message, ex.StackTrace)
        Finally
            XmlDoc = Nothing
            dsTemp = Nothing
            Cursor.Current = Cursors.Default
        End Try

        Return result

    End Function

    '2019/01/18 Eric
    Private Function funLoadParameter(ByVal ParameterNo As String) As String

        Dim dsPara As New DataSet

        '組InXml的字串
        strIdentity = CombineXMLIdentity(gComputerName, gUserNo, GetNow())
        strParameter = CombineXMLParameter("parameterno", "ParameterNo", "String", CInput(ParameterNo), "")
        InXml = CombineXMLRequest(strIdentity, strParameter)

        Try
            OutXml = InvokeSrv("wsSYS.LoadParameter", InXml)

            Dim XmlDoc As New XmlDocument   '//處理Xml字串之物件
            XmlDoc.LoadXml(OutXml)
            If Not ChkExecutionSuccess(XmlDoc) Then
                ExceptionManager.iMESShowDialog(GetExceptionCode(XmlDoc), GetExceptionSysMsg(XmlDoc), GetExceptionStack(XmlDoc))
            End If

            Dim tblParameter As String = XmlDoc.GetElementsByTagName("returnvalue").Item(0).SelectNodes("loadparameter").Item(0).SelectNodes("name").Item(0).InnerXml
            '取出Schema,dataset讀取Schema可防止Null Field及DateTime的問題
            XmlSchema = XmlDoc.DocumentElement.GetElementsByTagName("loadparameter").Item(0).SelectNodes("schema").Item(0).InnerXml
            If XmlSchema <> "" Then
                '將XML讀入String Reader object中,因為Dataset讀入XML時必須透過String Reader物件
                tmpStringReader = New System.IO.StringReader(XmlSchema)
                dsPara.ReadXmlSchema(tmpStringReader)
                tmpStringReader.Close()
            End If

            XmlData = XmlDoc.DocumentElement.GetElementsByTagName("loadparameter").Item(0).SelectNodes("value").Item(0).InnerXml
            If XmlData <> "" Then
                tmpStringReader = New System.IO.StringReader(XmlData)
                dsPara.ReadXml(tmpStringReader, XmlReadMode.InferSchema)
                tmpStringReader.Close()
            End If

            If dsPara.Tables(tblParameter).Rows.Count > 0 Then
                Return dsPara.Tables(tblParameter).Rows(0)("PARAMETERVALUE").ToString
            End If

            Return ""

        Catch ex As Exception
            ExceptionManager.iMESShowDialog(defWinErrCode, ex.Message, ex.StackTrace)
        Finally
        End Try

    End Function

    '2020/10/29 Grace 料批查核，相同料批只能刷一個料號，增加料號刷入
    Private Sub txtMaterialNo_KeyPress(sender As Object, e As KeyPressEventArgs) Handles txtMaterialNo.KeyPress, UltraTextEditor1.KeyPress
        Try
            If (e.KeyChar <> Convert.ToChar(13)) Then
                Exit Sub
            End If
            txtMaterialLotNo.Focus()
        Catch ex As iMESException.MESException
            ExceptionManager.iMESShowDialog(ex.ErrorCode, ex.Message, ex.StackTrace)
        Catch ex As Exception
            ExceptionManager.iMESShowDialog(defWinErrCode, ex.Message, ex.StackTrace)
        End Try
    End Sub


    Private Sub iugMaterial_Click(sender As Object, e As EventArgs) Handles iugMaterial.Click, IMESUltraGridControl1.Click
        If iugMaterial.iMESUltraGrid.ActiveRow Is Nothing Then Exit Sub
        txtMaterialNo.Text = iugMaterial.iMESUltraGrid.ActiveRow.Cells("MaterialNo").Value
    End Sub

    Private Function funLoadTemp_LotState() As Integer

        funLoadTemp_LotState = -1

        '組InXml的字串
        strIdentity = CombineXMLIdentity(gComputerName, UserId, Now)
        strParameter = CombineXMLParameter("lotno", "LotNo", "String", CInput(LotNo), "")
        InXml = CombineXMLRequest(strIdentity, strParameter)

        Try
            OutXml = InvokeSrv("wsWIP.LoadTemp_LotState", InXml)

            Dim XmlDoc As New XmlDocument
            XmlDoc.LoadXml(OutXml)
            If ChkExecutionSuccess(XmlDoc) Then
                tblTLotState = XmlDoc.GetElementsByTagName("returnvalue").Item(0).SelectNodes("loadtemp_lotstate").Item(0).SelectNodes("name").Item(0).InnerXml
                '取出Schema,dataset讀取Schema可防止Null Field及DateTime的問題
                XmlSchema = XmlDoc.DocumentElement.GetElementsByTagName("loadtemp_lotstate").Item(0).SelectNodes("schema").Item(0).InnerXml
                If XmlSchema <> "" Then
                    '將XML讀入String Reader object中,因為Dataset讀入XML時必須透過String Reader物件
                    tmpStringReader = New System.IO.StringReader(XmlSchema)
                    dsWIP.ReadXmlSchema(tmpStringReader)
                    tmpStringReader.Close()
                End If
                XmlData = XmlDoc.DocumentElement.GetElementsByTagName("loadtemp_lotstate").Item(0).SelectNodes("value").Item(0).InnerXml
                If XmlData <> "" Then
                    tmpStringReader = New System.IO.StringReader(XmlData)
                    dsWIP.ReadXml(tmpStringReader, XmlReadMode.InferSchema)
                    tmpStringReader.Close()
                End If
            Else
                ExceptionManager.iMESShowDialog(GetExceptionCode(XmlDoc), GetExceptionSysMsg(XmlDoc), GetExceptionStack(XmlDoc))
                Exit Function
            End If

            XmlDoc = Nothing

        Catch ex As iMESException.MESException
            ExceptionManager.iMESShowDialog(ex.ErrorCode, ex.Message, ex.StackTrace)
            Exit Function
        Catch ex As Exception
            ExceptionManager.iMESShowDialog(defWinErrCode, ex.Message, ex.StackTrace)
            Exit Function
        End Try

        funLoadTemp_LotState = 0


    End Function

    Private Sub iugTestData21703_iMESUltraGrid_KeyPress(sender As Object, e As KeyPressEventArgs)
        If e.KeyChar = Convert.ToChar(13) Then
            SendKeys.Send("{TAB}")
        End If
    End Sub

    Private Sub iugSubOP_iMESUltraGrid_InitializeRow(sender As Object, e As InitializeRowEventArgs) Handles iugSubOP.iMESUltraGrid_InitializeRow
        If e.Row.Band.Key = tblAreaEquipment Then 'Equipment
            If e.Row.Cells("AllowExecute").Value = 0 Then     '不可使用
                e.Row.Cells("CheckFlag").Activation = Infragistics.Win.UltraWinGrid.Activation.Disabled
                e.Row.Cells("CheckFlag").Appearance.BackColor = System.Drawing.Color.Gainsboro
            ElseIf e.Row.Cells("AllowExecute").Value = 1 Then '可使用

                'CheckFlag
                If EquipmentNo = defString Then
                Else
                    '以機台下貨,關閉勾選介面.
                    e.Row.Cells("CheckFlag").Activation = Infragistics.Win.UltraWinGrid.Activation.Disabled
                    e.Row.Cells("CheckFlag").Appearance.BackColor = System.Drawing.Color.Gainsboro
                End If
            End If
        End If
    End Sub


    Private Sub iugTestData21703_iMESUltraGrid_AfterCellUpdate(sender As Object, e As CellEventArgs) Handles iugTestData21703.iMESUltraGrid_AfterCellUpdate
        If e.Cell.Row.Cells("CheckFlag").Value = True AndAlso e.Cell.Row.Cells("IsSelect").Value = 1 Then
            iMESExceptionManager.ExceptionManager.iMESMsgBoxShowDialog(ChgTranslateName_Msg("0000-200011", "已经被选择，不能再选择"), MsgBoxStyle.Exclamation, Me.Text)
            e.Cell.Row.Cells("CheckFlag").Value = False
        End If
    End Sub

    Private Sub iugTestData21703_iMESUltraGrid_InitializeLayOut(sender As Object, e As InitializeLayoutEventArgs) Handles iugTestData21703.iMESUltraGrid_InitializeLayOut
        Dim i As Integer

        With e.Layout
            For i = 0 To dsWIP.Tables(tblCustomTestData).Columns.Count - 1
                Select Case dsWIP.Tables(tblCustomTestData).Columns(i).ColumnName.ToUpper
                    Case "CHECKFLAG"
                        With .Bands(tblCustomTestData).Columns("CheckFlag")
                            .Width = 50
                            .Header.VisiblePosition = 1
                            .Style = Infragistics.Win.UltraWinGrid.ColumnStyle.CheckBox
                            .CellAppearance.BackColor = System.Drawing.Color.White
                        End With

                    Case "SUBOPNO"
                        With .Bands(tblCustomTestData).Columns("SubOPNo")
                            .Header.Caption = "SubOPNo"
                            .Width = 80
                            .Header.VisiblePosition = 2
                        End With
                    Case "ISSELECT"
                        With .Bands(tblCustomTestData).Columns("IsSelect")
                            .Header.Caption = "IsSelect"
                            .Width = 80
                            .Header.VisiblePosition = 3
                            .ValueList = vlTestData21703
                        End With
                    Case "LOTNO"
                        With .Bands(tblCustomTestData).Columns("LotNo")
                            .Header.Caption = "LotNo"
                            .Width = 80
                            .Header.VisiblePosition = 4
                        End With


                    Case Else
                        With .Bands(tblCustomTestData).Columns(dsWIP.Tables(tblCustomTestData).Columns(i).ColumnName.ToUpper)
                            .Hidden = True
                        End With
                End Select
            Next

            'UltraGrid
            iugTestData21703.iMESUltraGrid.DisplayLayout.Override.AllowUpdate = Infragistics.Win.DefaultableBoolean.True
            iugTestData21703.iMESUltraGrid.Rows.ExpandAll(True)

        End With
    End Sub

    Private Sub iugTestData21703_iMESUltraGrid_BeforeCellUpdate(sender As Object, e As BeforeCellUpdateEventArgs) Handles iugTestData21703.iMESUltraGrid_BeforeCellUpdate

    End Sub

    Private Sub iugTestData21703_iMESUltraGrid_CellChange(sender As Object, e As CellEventArgs) Handles iugTestData21703.iMESUltraGrid_CellChange
        ' CheckFlag被點選時, 可立即將結果異動回DataTable
        e.Cell.Row.Update()
        Me.iugTestData21703.iMESUltraGrid.ActiveRow = e.Cell.Row
    End Sub




    '2019/10/17 Grace 查詢作業站資料
    Private Sub funLoadOPBasis(ByVal OPNo As String)

        If Not IsNothing(dsTemp.Tables(tblOPBasis)) Then
            dsTemp.Tables.Remove(tblOPBasis)
        End If

        '組InXml的字串
        strIdentity = CombineXMLIdentity(gComputerName, gUserNo, GetNow())
        strParameter = CombineXMLParameter("opno", "OPNo", "String", CInput(OPNo), "")
        '2020/02/07 Grace 增加傳入GetXml_CLOB = false, 避免取回企業邏輯CLOB資料
        strParameter += CombineXMLParameter("getxml_clob", "GetXML_CLOB", "Boolean", False, "")
        InXml = CombineXMLRequest(strIdentity, strParameter)

        Dim XmlDoc As New XmlDocument

        Try
            ' 2016 YF, Using wsOP As New wsOP.wsOP
            ' 2016 YF, wsOP.Url = LocalizeWebService(wsOP.Url.ToString)
            ' 2016 YF, wsOP.EnableDecompression = True
            ' 2016 YF, OutXml = wsOP.LoadOPBasis(InXml)
            OutXml = InvokeSrv("wsOP.LoadOPBasis", InXml)

            ' 2016 YF, End Using

            '利用XmlDoc物件處理ReturnValue 
            XmlDoc.LoadXml(OutXml)
            If ChkExecutionSuccess(XmlDoc) Then
                '//取出 Tablename
                tblOPBasis = XmlDoc.GetElementsByTagName("returnvalue").Item(0).SelectNodes("loadopbasis").Item(0).SelectNodes("name").Item(0).InnerXml
                '//取出 Table Schma
                XmlSchema = XmlDoc.DocumentElement.GetElementsByTagName("loadopbasis").Item(0).SelectNodes("schema").Item(0).InnerXml
                If XmlSchema <> "" Then
                    tmpStringReader = New System.IO.StringReader(XmlSchema)
                    dsTemp.ReadXmlSchema(tmpStringReader)
                    tmpStringReader.Close()
                End If
                '//取出Attrib Data
                XmlData = XmlDoc.DocumentElement.GetElementsByTagName("loadopbasis").Item(0).SelectNodes("value").Item(0).InnerXml
                If XmlData <> "" Then
                    tmpStringReader = New System.IO.StringReader(XmlData)
                    dsTemp.ReadXml(tmpStringReader, XmlReadMode.InferSchema)
                    tmpStringReader.Close()
                End If
            Else
                ExceptionManager.iMESShowDialog(GetExceptionCode(XmlDoc), GetExceptionSysMsg(XmlDoc), GetExceptionStack(XmlDoc))
                Exit Sub
            End If

            XmlDoc = Nothing

        Catch ex As iMESException.MESException
            ExceptionManager.iMESShowDialog(ex.ErrorCode, ex.Message, ex.StackTrace)
            Exit Sub
        Catch ex As Exception
            ExceptionManager.iMESShowDialog(defWinErrCode, ex.Message, ex.StackTrace)
            Exit Sub
        End Try
    End Sub

    '2020/02/26 Grace 查詢設備派工資料
    Private Sub funLoadWIPEQPDispatchState(Optional ByVal EquipmentNo As String = defString, Optional ByVal LotNo As String = defString,
                                           Optional ByVal OPNo As String = defString, Optional ByVal DispatchDate As DateTime = defDateTime)

        If Not IsNothing(dsTemp.Tables(tblEQPDispatchState)) Then
            dsTemp.Tables.Remove(tblEQPDispatchState)
        End If

        '組InXml的字串
        strIdentity = CombineXMLIdentity(gComputerName, gUserNo, GetNow())
        strParameter = ""
        If EquipmentNo <> defString Then strParameter += CombineXMLParameter("equipmentno", "EquipmentNo", "String", CInput(EquipmentNo), "")
        If LotNo <> defString Then strParameter += CombineXMLParameter("lotno", "LotNo", "String", CInput(LotNo), "")
        If OPNo <> defString Then strParameter += CombineXMLParameter("opno", "OPNo", "String", CInput(OPNo), "")
        If chkUpdCheckInTime.Checked And DispatchDate <> defDateTime Then
            strParameter += CombineXMLParameter("dispatchdate", "DispatchDate", "String", dtpcheckintime.Value.ToString("yyyy/MM/dd HH:mm:ss"), "")
        End If

        InXml = CombineXMLRequest(strIdentity, strParameter)
        Dim XmlDoc As New XmlDocument

        Try
            ' 2016 YF, Using wsOP As New wsOP.wsOP
            ' 2016 YF, wsOP.Url = LocalizeWebService(wsOP.Url.ToString)
            ' 2016 YF, wsOP.EnableDecompression = True
            ' 2016 YF, OutXml = wsOP.LoadOPBasis(InXml)
            OutXml = InvokeSrv("wsWIP.LoadWIPEQPDispatchState", InXml)

            ' 2016 YF, End Using

            '利用XmlDoc物件處理ReturnValue 
            XmlDoc.LoadXml(OutXml)
            If ChkExecutionSuccess(XmlDoc) Then
                '//取出 Tablename
                tblEQPDispatchState = XmlDoc.GetElementsByTagName("returnvalue").Item(0).SelectNodes("loadwipeqpdispatchstate").Item(0).SelectNodes("name").Item(0).InnerXml
                '//取出 Table Schma
                XmlSchema = XmlDoc.DocumentElement.GetElementsByTagName("loadwipeqpdispatchstate").Item(0).SelectNodes("schema").Item(0).InnerXml
                If XmlSchema <> "" Then
                    tmpStringReader = New System.IO.StringReader(XmlSchema)
                    dsTemp.ReadXmlSchema(tmpStringReader)
                    tmpStringReader.Close()
                End If
                '//取出Attrib Data
                XmlData = XmlDoc.DocumentElement.GetElementsByTagName("loadwipeqpdispatchstate").Item(0).SelectNodes("value").Item(0).InnerXml
                If XmlData <> "" Then
                    tmpStringReader = New System.IO.StringReader(XmlData)
                    dsTemp.ReadXml(tmpStringReader, XmlReadMode.InferSchema)
                    tmpStringReader.Close()
                End If
            Else
                ExceptionManager.iMESShowDialog(GetExceptionCode(XmlDoc), GetExceptionSysMsg(XmlDoc), GetExceptionStack(XmlDoc))
                Exit Sub
            End If

            XmlDoc = Nothing
        Catch ex As iMESException.MESException
            ExceptionManager.iMESShowDialog(ex.ErrorCode, ex.Message, ex.StackTrace)
            Exit Sub
        Catch ex As Exception
            ExceptionManager.iMESShowDialog(defWinErrCode, ex.Message, ex.StackTrace)
            Exit Sub
        End Try
    End Sub


#End Region

#Region "Others"

    Private Function funInitialize()

        iugAttrib.iMESUltraGrid.Text = "Attrib"
        iugAttrib.iMESUltraGrid.DisplayLayout.GroupByBox.Hidden = True
        iugAttrib.iMESUltraGrid.ContextMenuStrip.Items.Clear()
        iugAttrib.iMESUltraGrid.DisplayLayout.Override.CellAppearance.BackColor = Drawing.Color.Gainsboro
        '20240119
        iugTestData21703.iMESUltraGrid.DisplayLayout.GroupByBox.Hidden = True

        'iugMaterial.iMESUltraGrid.Text = "Material"
        iugMaterial.iMESUltraGrid.DisplayLayout.GroupByBox.Hidden = True
        iugMaterial.iMESUltraGrid.ContextMenuStrip.Items.Clear()
        iugMaterial.iMESUltraGrid.DisplayLayout.Override.CellAppearance.BackColor = Drawing.Color.Gainsboro

        iugEquipment.iMESUltraGrid.Text = "Equipment"
        iugEquipment.iMESUltraGrid.DisplayLayout.GroupByBox.Hidden = True
        iugEquipment.iMESUltraGrid.ContextMenuStrip.Items.Clear()
        iugEquipment.iMESUltraGrid.UpdateMode = Infragistics.Win.UltraWinGrid.UpdateMode.OnCellChangeOrLostFocus
        iugEquipment.iMESUltraGrid.DisplayLayout.Override.CellAppearance.BackColor = Drawing.Color.Gainsboro

        '78912: 进站选择模治具时，如该机台领用多套模具，会默认选择第一套而不会选择产品作业站设定绑定使用的的模治具 
        '78879: 若PRD主檔有設定限定模治具，則勾選各類別限定模治具的第一筆，設定為星號亦同，若未設定則不預勾 Edison 2020/10/15
        '===========================================78879 Start ===========================================
        If Not dsWIP.Tables("AccState") Is Nothing Then
            For Each r As DataRow In dsWIP.Tables("AccState").Rows
                r("Select") = False
            Next r
        End If

        If Not dsWIP.Tables("PRDAccessory") Is Nothing AndAlso dsWIP.Tables("PRDAccessory").Rows.Count > 0 AndAlso Not dsWIP.Tables("AccState") Is Nothing Then
            Dim blnChkACC As Boolean = False

            Dim dtAccType As DataTable = dsWIP.Tables("PRDAccessory").DefaultView.ToTable(True, "AccessoryType")
            Dim drSelPRDACC() As DataRow
            Dim drSelAccState() As DataRow

            For Each r As DataRow In dtAccType.Rows
                drSelPRDACC = dsWIP.Tables("PRDAccessory").Select("AccessoryType = '" & r("AccessoryType") & "'")
                If drSelPRDACC.Length > 0 Then
                    If drSelPRDACC(0)("AccessoryNo") <> "*" Then
                        drSelAccState = dsWIP.Tables("AccState").Select("AccessoryType = '" & drSelPRDACC(0)("AccessoryType") & "' AND AccessoryNo = '" & drSelPRDACC(0)("AccessoryNo") & "'  ")
                        If drSelAccState.Length > 0 Then
                            drSelAccState(0)("Select") = True
                        End If
                    Else
                        drSelAccState = dsWIP.Tables("AccState").Select("AccessoryType = '" & drSelPRDACC(0)("AccessoryType") & "' ")
                        If drSelAccState.Length > 0 Then
                            drSelAccState(0)("Select") = True
                        End If
                    End If
                End If
            Next r

        End If
        '===========================================78879  End  ===========================================

        '78913: 【德瑞客户】CI画面放大画面后再缩小画面然后拉伸设备栏位会造成多个设备功能框 Edison 2020/09/24
        '================================ 78913 Start ================================
        '防止透過Scroll Bar分割Grid
        iugEquipment.iMESUltraGrid.DisplayLayout.MaxColScrollRegions = 1
        iugEquipment.iMESUltraGrid.DisplayLayout.MaxRowScrollRegions = 1
        '================================ 78913  End  ================================

        iugKeyIn.iMESUltraGrid.Text = "Key In"
        iugKeyIn.iMESUltraGrid.DisplayLayout.GroupByBox.Hidden = True
        iugKeyIn.iMESUltraGrid.ContextMenuStrip.Items.Clear()
        iugKeyIn.iMESUltraGrid.UpdateMode = Infragistics.Win.UltraWinGrid.UpdateMode.OnCellChangeOrLostFocus
        iugKeyIn.iMESUltraGrid.DisplayLayout.MaxColScrollRegions = 1
        iugKeyIn.iMESUltraGrid.DisplayLayout.MaxRowScrollRegions = 1

        'iugSubOP.iMESUltraGrid.Text = "Sub OP"
        iugSubOP.iMESUltraGrid.DisplayLayout.GroupByBox.Hidden = True
        iugSubOP.iMESUltraGrid.ContextMenuStrip.Items.Clear()
        iugSubOP.iMESUltraGrid.DisplayLayout.Override.CellAppearance.BackColor = Drawing.Color.Gainsboro

        SBar1.Panels(0).Text = "UserNo:" & UserId
        SBar1.Panels(3).Text = Format(datEventTime, "yyyy/MM/dd H:mm:ss")

        txtPriority.Appearance.TextHAlign = Infragistics.Win.HAlign.Right
        txtCurQty.Appearance.TextHAlign = Infragistics.Win.HAlign.Right
        txtSysQty.Appearance.TextHAlign = Infragistics.Win.HAlign.Right
        dtpcheckintime.Value = datEventTime

        btnConfirm.Enabled = True
        'btnMultiUser.Enabled = True

        '2019/10/17 Grace 依系統參數是否啟動多人加工, 且多人加工模式為生產批, 來決定是否顯示"多人加工"按鈕
        btnMultiUser.Visible = False
        btnMultiUser.Enabled = False

        If Val(funGetSysParameter("MultiOperator")) Then
            Call funLoadOPBasis(txtOPNo.Text)
            If Not IsNothing(dsTemp.Tables(tblOPBasis)) Then
                If dsTemp.Tables(tblOPBasis).Rows.Count > 0 Then
                    If dsTemp.Tables(tblOPBasis).Rows(0)("MultiOperatorMode").ToString = "5" Then
                        btnMultiUser.Visible = True
                        btnMultiUser.Enabled = True
                    End If
                End If
            End If
        End If


        ' 2016/12/26 YF, 依系統參數是否啟動多人加工來決定是否顯示"作業人員"按鈕
        Me.btnOperator.Visible = Val(funGetSysParameter("MultiOperator"))

    End Function

    Private Function funLotInfo_Show()

        RevLotSerial = dsWIP.Tables(tblLotState).Rows(0)("LotSerial")
        RevLotStamp = dsWIP.Tables(tblLotState).Rows(0)("LotStamp")
        LotSerial = dsWIP.Tables(tblLotState).Rows(0)("LotSerial")
        LogGroupSerial = dsWIP.Tables(tblLotState).Rows(0)("LogGroupSerial").ToString
        txtCurQty.Text = Format(dsWIP.Tables(tblLotState).Rows(0)("CurQty"), "0.####")
        txtCurUnitNo.Text = dsWIP.Tables(tblLotState).Rows(0)("CurUnitNo").ToString
        txtSysQty.Text = Format(dsWIP.Tables(tblLotState).Rows(0)("SysQty"), "0.####")
        txtSysUnitNo.Text = dsWIP.Tables(tblLotState).Rows(0)("SysUnitNo").ToString
        txtOPNo.Text = dsWIP.Tables(tblLotState).Rows(0)("OPNo").ToString
        txtOpName.Text = dsWIP.Tables(tblLotState).Rows(0)("OPName").ToString

        '2009/05/11 Sophia.Pan R0905002	作業站編號及名稱加上ToolTip
        ToolTip1.SetToolTip(Me.txtOPNo, dsWIP.Tables(tblLotState).Rows(0)("OPNo").ToString)
        ToolTip1.SetToolTip(Me.txtOpName, dsWIP.Tables(tblLotState).Rows(0)("OPName").ToString)

        txtAreaNo.Text = dsWIP.Tables(tblLotState).Rows(0)("AreaNo").ToString
        txtProductNo.Text = dsWIP.Tables(tblLotState).Rows(0)("ProductNo").ToString
        PhaseNo = dsWIP.Tables(tblLotState).Rows(0)("PhaseNo")

        txtPriority.Text = dsWIP.Tables(tblLotState).Rows(0)("Priority")
        If dsWIP.Tables(tblLotState).Rows(0)("Priority") = 1 Then
            txtPriority.BackColor = System.Drawing.Color.Red
        ElseIf dsWIP.Tables(tblLotState).Rows(0)("Priority") = 2 Then
            txtPriority.BackColor = System.Drawing.Color.Yellow
        ElseIf dsWIP.Tables(tblLotState).Rows(0)("Priority") = 3 Then
            txtPriority.BackColor = System.Drawing.Color.LimeGreen
        End If
        txtMONo.Text = dsWIP.Tables(tblLotState).Rows(0)("MONo").ToString
        txtCustomerLotNo.Text = dsWIP.Tables(tblLotState).Rows(0)("CustomerLotNo").ToString

    End Function

    Private Sub funAddValueList_Attrib()

        iugAttrib.iMESUltraGrid.DisplayLayout.ValueLists.Add("ASource")
        With iugAttrib.iMESUltraGrid.DisplayLayout.ValueLists("ASource").ValueListItems
            .Clear()
            .Add(0, "KeyIn")
            .Add(1, "Calculate")
            .Add(2, "System")
            .Add(3, "Setup")
        End With

    End Sub

    '20240119
    Private Sub funAddValueList_CustomTestData()

        iugTestData21703.iMESUltraGrid.DisplayLayout.ValueLists.Add("IsSelect")
        With iugTestData21703.iMESUltraGrid.DisplayLayout.ValueLists("IsSelect").ValueListItems
            .Clear()
            .Add(0, "否")
            .Add(1, "是")
        End With

    End Sub

    Private Function funGetSampleData()

        Cursor.Current = Cursors.WaitCursor

        '轉換抽樣參數
        Dim strAQLType, strAQL, strQCLevel, strTemp As String

        If dsWIP.Tables(tblTAttrib) Is Nothing Then Exit Function

        Dim drSel() As DataRow

        '若已轉換,不再轉
        drSel = dsWIP.Tables(tblTAttrib).Select("AttribNo = 'SampleQty'")
        If drSel.Length > 0 Then
            If Not IsDBNull(drSel(0)("AttribValue")) Then
                If drSel(0)("AttribValue") <> "" Then
                    Exit Function
                End If
            End If
        End If

        'AQLType
        drSel = dsWIP.Tables(tblTAttrib).Select("AttribNo = 'AQLType'")
        If drSel.Length > 0 Then
            strAQLType = drSel(0)("AttribValue")
        Else
            strAQLType = defString
        End If
        'AQL
        drSel = dsWIP.Tables(tblTAttrib).Select("AttribNo = 'AQL'")
        If drSel.Length > 0 Then
            strAQL = drSel(0)("AttribValue")
        Else
            strAQL = defString
        End If
        'QCLevel
        drSel = dsWIP.Tables(tblTAttrib).Select("AttribNo = 'QCLevel'")
        If drSel.Length > 0 Then
            strQCLevel = drSel(0)("AttribValue")
        Else
            strQCLevel = defString
        End If

        drSel = Nothing

        If strAQLType = defString Or strAQL = defString Or strQCLevel = defString Then Exit Function

        '取出抽樣數
        strIdentity = CombineXMLIdentity(gComputerName, UserId, Now)
        strParameter = CombineXMLParameter("aqltype", "AQLType", "String", strAQLType, "")
        strParameter += CombineXMLParameter("qty", "QTY", "Long", dsWIP.Tables(tblLotState).Rows(0)("CurQty"), "")
        strParameter += CombineXMLParameter("qclevel", "QCLevel", "String", strQCLevel, "")
        strParameter += CombineXMLParameter("aql", "AQL", "String", strAQL, "")
        InXml = CombineXMLRequest(strIdentity, strParameter)
        Try
            OutXml = InvokeSrv("wsQC.GetAQLQty", InXml)

            Dim XmlDoc As New XmlDocument
            XmlDoc.LoadXml(OutXml)
            If ChkExecutionSuccess(XmlDoc) Then
                'SampleQty
                If XmlDoc.GetElementsByTagName("sampleqty").Item(0).SelectNodes("value").Count > 0 Then
                    strTemp = XmlDoc.DocumentElement.GetElementsByTagName("sampleqty").Item(0).SelectNodes("value").Item(0).InnerText
                    If IsNumeric(strTemp) Then
                        drSel = dsWIP.Tables(tblTAttrib).Select("AttribNo = 'SampleQty'")
                        If drSel.Length > 0 Then
                            drSel(0).BeginEdit()
                            drSel(0)("AttribValue") = strTemp
                            drSel(0).EndEdit()
                        End If
                    Else
                        iMESExceptionManager.ExceptionManager.iMESMsgBoxShowDialog(ChgTranslateName_Msg("0000-200011", "[%SampleQty%]"), MsgBoxStyle.Exclamation, Me.Text)
                        Exit Function
                    End If
                End If
                'AcceptQty
                If XmlDoc.GetElementsByTagName("acceptqty").Item(0).SelectNodes("value").Count > 0 Then
                    strTemp = XmlDoc.DocumentElement.GetElementsByTagName("acceptqty").Item(0).SelectNodes("value").Item(0).InnerText
                    If IsNumeric(strTemp) Then
                        drSel = dsWIP.Tables(tblTAttrib).Select("AttribNo = 'AcceptQty'")
                        If drSel.Length > 0 Then
                            drSel(0).BeginEdit()
                            drSel(0)("AttribValue") = strTemp
                            drSel(0).EndEdit()
                        End If
                    Else
                        iMESExceptionManager.ExceptionManager.iMESMsgBoxShowDialog(ChgTranslateName_Msg("0000-200011", "[%AcceptQty%]"), MsgBoxStyle.Exclamation, Me.Text)
                        Exit Function
                    End If
                End If
                'RejectQty
                If XmlDoc.GetElementsByTagName("rejectqty").Item(0).SelectNodes("value").Count > 0 Then
                    strTemp = XmlDoc.DocumentElement.GetElementsByTagName("rejectqty").Item(0).SelectNodes("value").Item(0).InnerText
                    If IsNumeric(strTemp) Then
                        drSel = dsWIP.Tables(tblTAttrib).Select("AttribNo = 'RejectQty'")
                        If drSel.Length > 0 Then
                            drSel(0).BeginEdit()
                            drSel(0)("AttribValue") = strTemp
                            drSel(0).EndEdit()
                        End If
                    Else
                        iMESExceptionManager.ExceptionManager.iMESMsgBoxShowDialog(ChgTranslateName_Msg("0000-200011", "[%RejectQty%]"), MsgBoxStyle.Exclamation, Me.Text)
                        Exit Function
                    End If
                End If
            Else
                ExceptionManager.iMESShowDialog(GetExceptionCode(XmlDoc), GetExceptionSysMsg(XmlDoc), GetExceptionStack(XmlDoc))
                Exit Function
            End If

            XmlDoc = Nothing

        Catch ex As iMESException.MESException
            ExceptionManager.iMESShowDialog(ex.ErrorCode, ex.Message, ex.StackTrace)
            Exit Function
        Catch ex As Exception
            ExceptionManager.iMESShowDialog(defWinErrCode, ex.Message, ex.StackTrace)
            Exit Function
        End Try

        Cursor.Current = Cursors.Default

    End Function

    Private Function funGetActiveRows() As DataRow()
        Dim Rows As DataRow()
        Dim oRow As Infragistics.Win.UltraWinGrid.UltraGridRow
        oRow = iugEquipment.iMESUltraGrid.ActiveRow

        If oRow Is Nothing Then
            Return Nothing
        End If

        '找出DataSet中在目前游標列的資料列(DataRow)

        Rows = dsWIP.Tables(tblAreaEquipment).Select(
                        "EquipmentNo ='" & Replace(oRow.Cells("EquipmentNo").Value.ToString, "'", "''") & "'")

        If Rows.Length = 0 Then
            Return Nothing
        Else
            Return Rows
        End If
    End Function

    Private Function funMultiUser() As Integer

        funMultiUser = -1

        If funLoadLotLoginState() < 0 Then Exit Function

        '產生多人加工暫存表
        dtTmpLoginState = New DataTable("TmpLoginState")
        dtTmpLoginState.Columns.Add("UserNo", System.Type.GetType("System.String"))
        dtTmpLoginState.Columns.Add("UserName", System.Type.GetType("System.String"))
        dtTmpLoginState.Columns.Add("CheckInTime", System.Type.GetType("System.DateTime"))

        '檢查tblWIPLotLoginState內是否已有本站未登出的資料,若有,則不自動加入.
        If dsWIP.Tables(tblLotLoginState).Rows.Count = 0 Then
            drAdd = dtTmpLoginState.NewRow
            drAdd("UserNo") = UserId
            drAdd("UserName") = UserName
            'Kevin,2012/12/18,不取client端的時間作CI時間
            'drAdd("CheckInTime") = datEventTime
            dtTmpLoginState.Rows.Add(drAdd)
        End If

        funMultiUser = 0

    End Function

    Private Function funGetSysParameter(ByVal pParameterNo As String) As String

        funGetSysParameter = "0"

        '組InXml的字串
        strParameter = ""
        strIdentity = CombineXMLIdentity(gComputerName, gUserNo, GetNow())
        strParameter = CombineXMLParameter("parameterno", "ParameterNo", "String", CInput(pParameterNo), "")
        InXml = CombineXMLRequest(strIdentity, strParameter)

        Try
            Dim XmlDoc As New XmlDocument

            OutXml = InvokeSrv("wsSYS.GetParameter", InXml)

            XmlDoc.LoadXml(OutXml)
            If ChkExecutionSuccess(XmlDoc) Then
                If XmlDoc.DocumentElement.SelectNodes("returnvalue").Count > 0 Then
                    funGetSysParameter = XmlDoc.DocumentElement("returnvalue").InnerXml
                End If
            Else
                ExceptionManager.iMESShowDialog(GetExceptionCode(XmlDoc), GetExceptionSysMsg(XmlDoc), GetExceptionStack(XmlDoc))
                Exit Function
            End If

            XmlDoc = Nothing

        Catch ex As iMESException.MESException
            ExceptionManager.iMESShowDialog(ex.ErrorCode, ex.Message, ex.StackTrace)
            Exit Function
        Catch ex As Exception
            ExceptionManager.iMESShowDialog(defWinErrCode, ex.Message, ex.StackTrace)
            Exit Function
        End Try
    End Function

#End Region

#Region "取得設備參數"

    ' 2016/01/27 YF, 取得設備參數值
    Private Sub funGetEquipmentRecipe()

        Const FUNCTION_NAME As String = "#GETEQPRECIPE"

        Dim strEquipmentNo As String = ""
        Dim XmlDoc As New XmlDocument
        Dim SelRows() As DataRow

        Try

            ' 取出勾選的設備編號
            For Each row As DataRow In dsWIP.Tables(tblAreaEquipment).Select("CheckFlag = " & True, "EquipmentNo")
                strEquipmentNo += row("EquipmentNo").ToString & ","
            Next

            If (strEquipmentNo <> "") Then
                strEquipmentNo = strEquipmentNo.TrimEnd(",")
            End If

            strIdentity = CombineXMLIdentity(gComputerName, UserId, Now)

            ' 逐筆判斷特性值的函式是否為#GETEQPRECIPE, 若是則至後端取回參數值
            For Each row As DataRow In dsWIP.Tables(tblTAttrib).Rows

                If (Microsoft.VisualBasic.Left(row("OrgAttribValue").ToString, FUNCTION_NAME.Length).ToUpper <> FUNCTION_NAME) Then
                    Continue For
                End If

                ' 沒有挑選設備, 清空#GetEQPRecipe特性值
                If (strEquipmentNo = "") Then
                    row("AttribValue") = ""
                    Continue For
                End If

                ' 取回設備參數
                strParameter = CombineXMLParameter("equipmentno", "EquipmentNo", "String", strEquipmentNo, "")
                strParameter += CombineXMLParameter("recipescript", "RecipeScript", "String", row("OrgAttribValue").ToString, "")

                InXml = CombineXMLRequest(strIdentity, strParameter)

                OutXml = InvokeSrv("wsWIP.GetEquipmentRecipe", InXml)

                XmlDoc.LoadXml(OutXml)

                If ChkExecutionSuccess(XmlDoc) Then
                    If XmlDoc.GetElementsByTagName("itemvalue").Count > 0 Then
                        If XmlDoc.GetElementsByTagName("itemvalue").Item(0).SelectNodes("value").Count > 0 Then
                            row("AttribValue") = XmlDoc.DocumentElement.GetElementsByTagName("itemvalue").Item(0).SelectNodes("value").Item(0).InnerText

                            ' 更新KeyIn的特性值
                            SelRows = dtKeyIn.Select("AttribNo = '" & row("AttribNo") & "'")

                            If (SelRows.Length > 0) Then
                                SelRows(0)("AttribValue") = row("AttribValue")
                            End If

                        End If
                    End If
                Else
                    ExceptionManager.iMESShowDialog(GetExceptionCode(XmlDoc), GetExceptionSysMsg(XmlDoc), GetExceptionStack(XmlDoc))
                End If

            Next

        Catch ex As iMESException.MESException
            ExceptionManager.iMESShowDialog(ex.ErrorCode, ex.Message, ex.StackTrace)
        Catch ex As Exception
            ExceptionManager.iMESShowDialog(defWinErrCode, ex.Message, ex.StackTrace)
        Finally
            XmlDoc = Nothing
        End Try

    End Sub

#End Region

#Region "用料檢查"

    ''' <summary>
    ''' 2016/10/19 YF, 投料點用料檢查
    ''' </summary>
    ''' <returns></returns>
    Private Function CheckMaterialByPutinPlace(ByVal pMONo As String, ByVal pMaterialLotNo As String, ByVal pMaterialNo As String) As Boolean

        Dim PutinPlace As Integer
        Dim intInputFlag As Integer = 0
        Dim strTmpOrgMaterialNo As String = ""
        Dim strTmpMaterialNo As String = ""
        Dim strTmpMaterialLotNo As String = ""
        Dim decQty As Decimal = 0
        Dim strCheckPlaceMsg As String = ""


        '至工單發料區與線邊倉取出輸入的料批
        If funLoadMOMaterialState(dsWIP.Tables(tblLotState).Rows(0)("MONo").ToString, txtMaterialLotNo.Text) < 0 Then Exit Function
        If funLoadWIPInventory_Raw(pMaterialLotNo) < 0 Then Exit Function
        If funLoadWIPInventory_SEMI(pMaterialLotNo) < 0 Then Exit Function

        '檢查是否有符合的物料編號與投料點

        If dsWIP.Tables(tblMOMaterialState).Rows.Count > 0 Then  '工單發料區

            For Each drRaw As DataRow In dsWIP.Tables(tblMOMaterialState).Rows
                '2020/10/30 Grace 先檢查輸入的物料編號, 相符後再往下找物料批號
                If drRaw("MaterialNo") = pMaterialNo Then

                    'Kevin 2013/1/2,不同主料替代料有可能相同,先檢查游標所選的主物料
                    Dim drSelMTL As DataRow()

                    drSelMTL = dsWIP.Tables(tblTMaterial).Select("MaterialNo='" & drRaw("MaterialNo") & "'" &
                                                                     " And OrgMaterialNo ='" & iugMaterial.iMESUltraGrid.ActiveRow.Cells("OrgMaterialNo").Value & "'" &
                                                                     " And PutInPlaceType = 3 ")
                    If drSelMTL.Length > 0 Then
                        If intInputFlag <> 1 Then
                            strTmpOrgMaterialNo = drSelMTL(0)("OrgMaterialNo")
                            strTmpMaterialNo = drRaw("MaterialNo")
                            strTmpMaterialLotNo = drRaw("MaterialLotNo")
                            decQty = drRaw("Qty")
                        End If
                        intInputFlag = 1
                    Else
                        '全部主物料比對
                        For Each dr As DataRow In dsWIP.Tables(tblTMaterial).Rows
                            '檢查物料編號
                            If dr("MaterialNo") = drRaw("MaterialNo") Then
                                '檢查投料點
                                If dr("PutInPlaceType") = 3 Then
                                    Dim drSel() As DataRow
                                    drSel = dsWIP.Tables(tblTmpMTLLotNo).Select("MaterialNo='" & drRaw("MaterialNo") & "' And MaterialLotNo ='" & drRaw("MaterialLotNo") & "'")
                                    If drSel.Length = 0 Then
                                        If intInputFlag <> 1 Then
                                            strTmpOrgMaterialNo = dr("OrgMaterialNo")
                                            strTmpMaterialNo = drRaw("MaterialNo")
                                            strTmpMaterialLotNo = drRaw("MaterialLotNo")
                                            decQty = drRaw("Qty")
                                        End If
                                        intInputFlag = 1
                                    End If
                                Else
                                    strCheckPlaceMsg = "[%MaterialLotNo%]：" & pMaterialLotNo & ",[%MaterialNo%]：" &
                                                           dr("MaterialNo") & " [%PutInPlace%][%is not%][%MO%] !"
                                End If
                            End If
                        Next
                    End If

                End If
            Next
        End If

        If dsWIP.Tables(tblWIPINVRaw).Rows.Count > 0 Then   '線邊倉

            For Each drRaw As DataRow In dsWIP.Tables(tblWIPINVRaw).Rows

                '2020/10/30 Grace 先檢查輸入的物料編號, 相符後再往下找物料批號
                If drRaw("MaterialNo") = pMaterialNo Then

                    'Kevin 2013/1/2,不同主料替代料有可能相同,先檢查游標所選的主物料
                    Dim drSelMTL As DataRow()
                    drSelMTL = dsWIP.Tables(tblTMaterial).Select("MaterialNo='" & drRaw("MaterialNo") & "'" &
                                                                     " And OrgMaterialNo ='" & iugMaterial.iMESUltraGrid.ActiveRow.Cells("OrgMaterialNo").Value & "'" &
                                                                     " And PutInPlaceType = 2 ")
                    If drSelMTL.Length > 0 Then
                        If intInputFlag <> 1 Then
                            strTmpOrgMaterialNo = drSelMTL(0)("OrgMaterialNo")
                            strTmpMaterialNo = drRaw("MaterialNo")
                            strTmpMaterialLotNo = drRaw("MaterialLotNo")
                            decQty = drRaw("Qty")
                        End If
                        intInputFlag = 1
                    Else
                        '全部主物料比對
                        For Each dr As DataRow In dsWIP.Tables(tblTMaterial).Rows
                            '檢查物料編號
                            If dr("MaterialNo") = drRaw("MaterialNo") Then
                                '檢查投料點
                                If dr("PutInPlaceType") = 2 Then
                                    Dim drSel() As DataRow
                                    drSel = dsWIP.Tables(tblTmpMTLLotNo).Select("MaterialNo='" & drRaw("MaterialNo") & "' And MaterialLotNo ='" & drRaw("MaterialLotNo") & "'")
                                    If drSel.Length = 0 Then
                                        If intInputFlag <> 1 Then
                                            strTmpOrgMaterialNo = dr("OrgMaterialNo")
                                            strTmpMaterialNo = drRaw("MaterialNo")
                                            strTmpMaterialLotNo = drRaw("MaterialLotNo")
                                            decQty = drRaw("Qty")
                                        End If
                                        intInputFlag = 1
                                    End If
                                Else
                                    strCheckPlaceMsg = "[%MaterialLotNo%]：" & pMaterialLotNo & ",[%MaterialNo%]：" &
                                                           dr("MaterialNo") & " [%PutInPlace%][%is not%][%WIP INVENTORY%] !"
                                End If
                            End If
                        Next
                    End If

                End If
            Next
        End If

        If dsWIP.Tables(tblWIPINVSEMI).Rows.Count > 0 Then   '半成品線邊倉

            For Each drSEMI As DataRow In dsWIP.Tables(tblWIPINVSEMI).Rows

                '2020/10/30 Grace 先檢查輸入的物料編號, 相符後再往下找物料批號
                If drSEMI("ProductNo") = pMaterialNo Then

                    'Kevin 2013/1/2,不同主料替代料有可能相同,先檢查游標所選的主物料
                    Dim drSelMTL As DataRow()
                    drSelMTL = dsWIP.Tables(tblTMaterial).Select("MaterialNo='" & drSEMI("ProductNo") & "'" &
                                                                     " And OrgMaterialNo ='" & iugMaterial.iMESUltraGrid.ActiveRow.Cells("OrgMaterialNo").Value & "'" &
                                                                     " And PutInPlaceType = 4 ")
                    If drSelMTL.Length > 0 Then
                        If intInputFlag <> 1 Then
                            strTmpOrgMaterialNo = drSelMTL(0)("OrgMaterialNo")
                            strTmpMaterialNo = drSEMI("ProductNo")
                            strTmpMaterialLotNo = drSEMI("LotNo")
                            decQty = drSEMI("Qty")
                        End If
                        intInputFlag = 1
                    Else
                        '全部主物料比對
                        For Each dr As DataRow In dsWIP.Tables(tblTMaterial).Rows
                            '檢查物料編號
                            If dr("MaterialNo") = drSEMI("ProductNo") Then
                                '檢查投料點
                                If dr("PutInPlaceType") = 2 Then
                                    Dim drSel() As DataRow
                                    drSel = dsWIP.Tables(tblTmpMTLLotNo).Select("MaterialNo='" & drSEMI("ProductNo") & "' And MaterialLotNo ='" & drSEMI("LotNo") & "'")
                                    If drSel.Length = 0 Then
                                        If intInputFlag <> 1 Then
                                            strTmpOrgMaterialNo = dr("OrgMaterialNo")
                                            strTmpMaterialNo = drSEMI("ProductNo")
                                            strTmpMaterialLotNo = drSEMI("LotNo")
                                            decQty = drSEMI("Qty")
                                        End If
                                        intInputFlag = 1
                                    End If
                                Else
                                    strCheckPlaceMsg = "[%MaterialLotNo%]：" & pMaterialLotNo & ",[%MaterialNo%]：" &
                                                           dr("MaterialNo") & " [%PutInPlace%][%is not%][%WIP INVENTORY%] !"
                                End If
                            End If
                        Next
                    End If

                End If
            Next
        End If

        If intInputFlag = 1 Then

            '2019/06/18 Shih Kai, Mantis:0058359 ,若物料為指定用料, 則不可使用替代料
            If funGetSysParameter("CIMTLDBCheck") = "1" Then
                If dsWIP.Tables(tblTMaterial).Select("MaterialNo = '" & strTmpOrgMaterialNo & "' And Specified = 1").Length > 0 AndAlso
                   strTmpOrgMaterialNo <> strTmpMaterialNo Then
                    iMESExceptionManager.ExceptionManager.iMESMsgBoxShowDialog(ChgTranslateName_Msg("0000-203079", "[%MaterialNo%]:" & strTmpOrgMaterialNo), MsgBoxStyle.Exclamation, Me.Text)
                    Exit Function
                End If
            End If

            Dim drAdd As DataRow
            drAdd = dsWIP.Tables(tblTmpMTLLotNo).NewRow
            drAdd("OrgMaterialNo") = strTmpOrgMaterialNo
            drAdd("MaterialNo") = strTmpMaterialNo
            drAdd("SUBSTITUTEMATERIALNO") = strTmpMaterialNo
            drAdd("MaterialLotNo") = strTmpMaterialLotNo
            drAdd("Qty") = decQty
            dsWIP.Tables(tblTmpMTLLotNo).Rows.Add(drAdd)
        Else
            If strCheckPlaceMsg <> "" Then
                iMESExceptionManager.ExceptionManager.iMESMsgBoxShowDialog(ChgTranslateName_Msg("0000-200015", strCheckPlaceMsg), MsgBoxStyle.Exclamation, Me.Text)
                Exit Function
            Else
                iMESExceptionManager.ExceptionManager.iMESMsgBoxShowDialog(ChgTranslateName_Msg("0000-202104", "[%MaterialLotNo%]!"), MsgBoxStyle.Exclamation, Me.Text)
                Exit Function
            End If
        End If

        '選到新加入的列
        Dim Vals(1) As Object
        Dim PmyKey(1) As DataColumn
        PmyKey(0) = dsWIP.Tables(tblTmpMTLLotNo).Columns("MaterialNo")
        PmyKey(1) = dsWIP.Tables(tblTmpMTLLotNo).Columns("MaterialLotNo")
        Vals(0) = strTmpMaterialNo
        Vals(1) = strTmpMaterialLotNo

        ugrRow = FindRecordPosition_ByMutiCol(iugMaterial, PmyKey, Vals)
        If Not ugrRow Is Nothing Then
            iugMaterial.iMESUltraGrid.ActiveRow = ugrRow
            iugMaterial.iMESUltraGrid.ActiveRow.Selected = True
        End If

        Return True

    End Function

#End Region

#Region "物料數量檢查"

    Structure MethodNames
        ''' <summary>
        ''' 檢查物料數量
        ''' </summary>
        Const funCheckMTLQuantity = "funCheckMTLQuantity"
    End Structure

    Private Function funCheckMTL() As Boolean

        For Each row As DataRow In dsWIP.Tables(tblTMaterial).Rows
            If dsWIP.Tables(tblTmpMTLLotNo).Select("OrgMaterialNo = '" & row("OrgMaterialNo") & "'").Length <= 0 Then
                ExceptionManager.iMESMsgBoxShowDialog(ChgTranslateName_Msg("0000-203083",
                    row("MaterialNo") & "[%IS NOT ENOUGH%], [%PLEASE%][%EXECUTE%][%MOUNTMATERIAL%]"))
                Return False
            End If
        Next

        '組InXml的字串
        strIdentity = CombineXMLIdentity(gComputerName, UserId, Now)
        strParameter = CombineXMLParameter("lotno", "LotNo", "String", CInput(LotNo), "")
        strParameter &= CombineXMLParameter("checkin", "CheckIn", "Boolean", CInput(True), "")
        InXml = CombineXMLRequest(strIdentity, strParameter)

        Try
            OutXml = InvokeSrv("wsWIP_Material.CheckMTLForBR", InXml, dtTmpMTLLotNo.Copy)

            Dim XmlDoc As New XmlDocument
            XmlDoc.LoadXml(OutXml)

            If Not ChkExecutionSuccess(XmlDoc) Then
                ExceptionManager.iMESShowDialog(GetExceptionCode(XmlDoc), GetExceptionSysMsg(XmlDoc), GetExceptionStack(XmlDoc))
                Return False
            End If

            Dim xmlList As XmlNodeList = XmlDoc.GetElementsByTagName("message")
            If xmlList.Count > 0 Then
                xmlList = xmlList(0).SelectNodes("note")
                If xmlList.Count > 0 Then
                    For Each xmlNode As XmlNode In xmlList
                        If funProcessMessages(xmlNode) = False Then Return False
                    Next
                End If
            End If

            Return True

        Catch ex As iMESException.MESException
            ExceptionManager.iMESShowDialog(ex.ErrorCode, ex.Message, ex.StackTrace)

        Catch ex As Exception
            ExceptionManager.iMESShowDialog(defWinErrCode, ex.Message, ex.StackTrace)
        End Try

    End Function
    Private Function funProcessMessages(ByVal xmlNode As XmlNode) As Boolean

        Dim MCode, MType, MMsg As String
        MCode = xmlNode.SelectNodes("mcode").Item(0).InnerText
        MType = xmlNode.SelectNodes("mtype").Item(0).InnerText
        MMsg = xmlNode.SelectNodes("mmsg").Item(0).InnerText

        Dim methodName As String = ""
        If MMsg.Contains("{") AndAlso MMsg.Contains("}") Then
            Dim intStart As Int16 = MMsg.IndexOf("{")
            Dim intEnd As Int16 = MMsg.IndexOf("}")
            methodName = MMsg.Substring(intStart + 1, intEnd - intStart - 1)
            MMsg = MMsg.Substring(intEnd + 1, MMsg.Length - intEnd - 1)
        End If

        Select Case methodName
            Case MethodNames.funCheckMTLQuantity
                If ExceptionManager.iMESMsgBoxShowDialog(
                    ChgTranslateName_Msg("0000-100601", MMsg), MsgBoxStyle.YesNo + MsgBoxStyle.Question) = MsgBoxResult.No Then
                    Return False
                End If

            Case Else
                ExceptionManager.iMESMsgBoxShowDialog(ChgTranslateName_Msg(MCode, MMsg), MsgBoxStyle.Exclamation, Me.Text)
                Return False
        End Select

        Return True

    End Function
#End Region

    '取eSOP 工位及作業站 資料
    Private Function funLoadPRDeSOP() As Integer

        funLoadPRDeSOP = -1
        If Not IsNothing(dsDefine.Tables(tblPRDeSOPBasis)) Then dsDefine.Tables.Remove(tblPRDeSOPBasis)


        '組InXml的字串
        strIdentity = CombineXMLIdentity(gComputerName, gUserNo, GetNow())
        strParameter = ""
        strParameter += CombineXMLParameter("productno", "ProductNo", "String", CInput(txtProductNo.Text), "")
        strParameter += CombineXMLParameter("opno", "OPNo", "String", CInput(txtOPNo.Text), "")

        InXml = CombineXMLRequest(strIdentity, strParameter)
        Dim XmlDoc As New XmlDocument
        Try
            ' 2016 YF, OutXml = wsPRD.LoadPRDeSOPBasis(InXml)
            OutXml = InvokeSrv("wsPRD.LoadPRDeSOPBasis", InXml)

            '利用XmlDoc物件處理ReturnValue 
            XmlDoc.LoadXml(OutXml)

            If ChkExecutionSuccess(XmlDoc) Then
                tblPRDeSOPBasis = XmlDoc.GetElementsByTagName("returnvalue").Item(0).SelectNodes("loadprdesopbasis").Item(0).SelectNodes("name").Item(0).InnerXml
                XmlSchema = XmlDoc.DocumentElement.GetElementsByTagName("loadprdesopbasis").Item(0).SelectNodes("schema").Item(0).InnerXml

                If XmlSchema <> "" Then
                    '將XML讀入String Reader object中,因為Dataset讀入XML時必須透過String Reader物件
                    tmpStringReader = New System.IO.StringReader(XmlSchema)
                    dsDefine.ReadXmlSchema(tmpStringReader)
                    tmpStringReader.Close()
                End If

                '取出Data()
                XmlData = XmlDoc.DocumentElement.GetElementsByTagName("loadprdesopbasis").Item(0).SelectNodes("value").Item(0).InnerXml
                If XmlData <> "" Then
                    tmpStringReader = New System.IO.StringReader(XmlData)
                    dsDefine.ReadXml(tmpStringReader, XmlReadMode.InferSchema)
                    tmpStringReader.Close()
                End If

            Else
                ExceptionManager.iMESShowDialog(GetExceptionCode(XmlDoc), GetExceptionSysMsg(XmlDoc), GetExceptionStack(XmlDoc))
                Exit Function
            End If

        Catch ex As iMESException.MESException
            ExceptionManager.iMESShowDialog(ex.ErrorCode, ex.Message, ex.StackTrace)
            Exit Function
        Catch ex As Exception
            ExceptionManager.iMESShowDialog(defWinErrCode, ex.Message, ex.StackTrace)
            Exit Function
        Finally
            XmlDoc = Nothing

        End Try
        funLoadPRDeSOP = 0

    End Function
    '顯示作業指導書(eSOP) 2016-12-19
    Private Function funDisplayProcess() As Integer
        Dim XmlDoc As New XmlDocument()
        Dim InXml, OutXml As String
        Dim strTempRecord As String = String.Empty
        Dim arriveTime As DateTime = DateTime.Now
        Dim strERP_URL_eSOP As String
        Dim responseValue, code As String

        Dim strSplitFile() As String

        Try
            '---- InXml -----           
            Dim InXmlDoc As XmlDocument = New XmlDocument()

            '<param>
            Dim nodeParam As XmlElement = InXmlDoc.CreateElement("param")
            nodeParam.SetAttribute("key", "std_data")
            nodeParam.SetAttribute("type", "xml")
            InXmlDoc.AppendChild(nodeParam)

            '<data_request>
            Dim nodeDataRequest As XmlElement = InXmlDoc.CreateElement("data_request")
            nodeParam.AppendChild(nodeDataRequest)

            '<datainfo>
            Dim nodeDataInfo As XmlElement = InXmlDoc.CreateElement("datainfo")
            nodeDataRequest.AppendChild(nodeDataInfo)

            '<parameter>
            Dim nodeParameter As XmlElement = InXmlDoc.CreateElement("parameter")
            nodeParameter.SetAttribute("key", "sop_display")
            nodeParameter.SetAttribute("type", "data")
            nodeDataInfo.AppendChild(nodeParameter)

            '<data>
            Dim nodeData As XmlElement = InXmlDoc.CreateElement("data")
            nodeData.SetAttribute("name", "sop_display")
            nodeParameter.AppendChild(nodeData)

            For Each drData As DataRow In dsDefine.Tables(tblPRDeSOPBasis).Rows
                If drData("POSITIONNO") = "N/A" Then Continue For
                'sop no
                strSplitFile = Split(drData("SOPFILE"), ".")
                '顯示作業說明書必傳實體檔案,工位,執行時間
                '<row>
                Dim nodeRow As XmlElement = InXmlDoc.CreateElement("row")
                nodeRow.SetAttribute("seq", intRow)
                nodeData.AppendChild(nodeRow)

                Dim nodeDField As XmlElement
                ''sop編號
                nodeDField = InXmlDoc.CreateElement("field")
                nodeDField.SetAttribute("name", "sop_no")
                nodeDField.SetAttribute("type", "string")
                'nodeDField.InnerText = strSplitFile(0)
                nodeDField.InnerText = ""
                nodeRow.AppendChild(nodeDField)
                '指定版號: Y:指定  N:不指定
                nodeDField = InXmlDoc.CreateElement("field")
                nodeDField.SetAttribute("name", "sop_ver_assign")
                nodeDField.SetAttribute("type", "string")
                nodeDField.InnerText = ""
                nodeRow.AppendChild(nodeDField)
                '版本
                nodeDField = InXmlDoc.CreateElement("field")
                nodeDField.SetAttribute("name", "sop_ver")
                nodeDField.SetAttribute("type", "string")
                nodeDField.InnerText = ""
                nodeRow.AppendChild(nodeDField)
                '頁數
                nodeDField = InXmlDoc.CreateElement("field")
                nodeDField.SetAttribute("name", "sop_page")
                nodeDField.SetAttribute("type", "string")
                nodeDField.InnerText = drData("PAGENO")
                nodeRow.AppendChild(nodeDField)
                '工位編號
                nodeDField = InXmlDoc.CreateElement("field")
                nodeDField.SetAttribute("name", "station_no")
                nodeDField.SetAttribute("type", "string")
                nodeDField.InnerText = drData("POSITIONNO")
                nodeRow.AppendChild(nodeDField)
                '實體檔名
                nodeDField = InXmlDoc.CreateElement("field")
                nodeDField.SetAttribute("name", "sop_file")
                nodeDField.SetAttribute("type", "string")
                nodeDField.InnerText = drData("SOPFILE")
                nodeRow.AppendChild(nodeDField)
                '傳送時間
                nodeDField = InXmlDoc.CreateElement("field")
                nodeDField.SetAttribute("name", "report_datetime")
                nodeDField.SetAttribute("type", "date")
                nodeDField.SetAttribute("format", "yyyyMMddHHmmss")
                nodeDField.InnerText = Now.ToString("yyyyMMddHHmmss")
                nodeRow.AppendChild(nodeDField)
                '備註
                nodeDField = InXmlDoc.CreateElement("field")
                nodeDField.SetAttribute("name", "remark")
                nodeDField.SetAttribute("type", "string")
                nodeDField.InnerText = ""
                nodeRow.AppendChild(nodeDField)
                intRow = intRow + 1
            Next
            Using obj As New COM_ERP.clsEAI
                InXml = obj.funGenerateRequestXML(COM_ERP.clsEAI.ERPName.eSOP, InXmlDoc.InnerXml, "sop.display.process", False)
                strERP_URL_eSOP = obj.getERP_WSURL(COM_ERP.clsEAI.ERPName.eSOP)
            End Using

            '----- Call Web Service -----
            Using ws As New COM_ERP.wsESOP.eSOPService

                ws.Url = strERP_URL_eSOP
                OutXml = ws.sop_display_process(InXml)
            End Using

            code = "success"
        Catch ex As iMESException.MESException
            ExceptionManager.iMESShowDialog(ex.ErrorCode, ex.Message, ex.StackTrace)
            code = "fail"
        Catch ex As Exception
            ExceptionManager.iMESShowDialog(defWinErrCode, ex.Message, ex.StackTrace)
            code = "fail"
        Finally

            '紀錄TransactionLog
            COM_ERP.clsCommon.addTransactionLog_ErrorCode(InXml, OutXml, arriveTime.ToString("yyyyMMddHHmmssss"), "WIP", "station.get", My.Computer.Name,
                              gUserNo, arriveTime.ToString("yyyy/MM/dd HH:mm:ss"), code, "", "station.get", LogClass:="WIP")
        End Try
    End Function

#Region "作業人員"

    ''' <summary>
    ''' 2016/12/26 YF, 顯示作業人員現況資訊
    ''' </summary>
    ''' <param name="sender"></param>
    ''' <param name="e"></param>
    Private Sub btnOperator_Click(sender As Object, e As EventArgs) Handles btnOperator.Click

        Dim parameters As Dictionary(Of String, Object)
        Dim EquipmentNo As String = ""

        Try

            parameters = New Dictionary(Of String, Object)

            With dsWIP.Tables(tblLotState).Rows(0)

                Select Case .Item("MultiOperatorMode").ToString
                    Case "0"
                        ' 作業站
                        parameters.Add("OPNo", .Item("OPNo").ToString)
                    Case "1"
                        ' 區域
                        parameters.Add("AreaNo", .Item("AreaNo").ToString)
                    Case "2"
                        ' 設備 
                        For Each row As DataRow In dsWIP.Tables(tblAreaEquipment).Select("CheckFlag = True")
                            EquipmentNo += row("EquipmentNo") & ","
                        Next

                        If (EquipmentNo = "") Then
                            Throw New iMESException.MESException("0000-103010", "[%PLEASE SELECT%] [%EQUIPMENT%]!")
                        End If

                        EquipmentNo = EquipmentNo.TrimEnd(",")
                        parameters.Add("EquipmentNo", EquipmentNo)
                    Case "5" 'Mantis 63873: 增加判斷多人加工模式為生產批, 並傳入資料
                        ' 生產批
                        parameters.Add("LotNo", .Item("LotNo").ToString)
                    Case Else
                        Throw New iMESException.MESException("0000-003000", "[%MultiOperatorMode%]:" & .Item("MultiOperatorMode").ToString & " [%NOT DEFINE%]!")
                End Select

            End With

            parameters.Add("EnableSignOut", False)
            Me.ObjectFileHandler.Execute(pObjectID:="WP_OperatorOnline", pParameters:=parameters)

        Catch ex As iMESException.MESException
            ExceptionManager.iMESShowDialog(ex.ErrorCode, ex.Message, ex.StackTrace)
        Catch ex As Exception
            ExceptionManager.iMESShowDialog(defWinErrCode, ex.Message, ex.StackTrace)
        End Try

    End Sub

#End Region

    '2019/01/18 Eric 特殊生產需求顯示
    Private Sub btnSWR_Click(sender As System.Object, e As System.EventArgs) Handles btnSWR.Click
        '2019/02/12 Eric 加入判斷有無資料
        If blnShowSWR = True Then

            Dim Parameters As New Dictionary(Of String, Object)
            Parameters.Add("MONo", txtMONo.Text)
            Parameters.Add("CustomerLotNo", txtCustomerLotNo.Text)
            Parameters.Add("OPNo", txtOPNo.Text)
            Parameters.Add("LotNo", txtLotNo.Text)
            Parameters.Add("DeviceNo", dsWIP.Tables(tblLotState).Rows(0)("DeviceNo").ToString)
            Parameters.Add("CustomerNo", dsWIP.Tables(tblLotState).Rows(0)("CustomerNo").ToString)
            Parameters.Add("LogGroupSerial", dsWIP.Tables(tblLotState).Rows(0)("LogGroupSerial").ToString)
            Parameters.Add("blnCICo", False)
            Me.ObjectFileHandler.Execute("WP_SWRBasisRead", Parameters)

            btnSWR.Visible = True

        End If

    End Sub

    '2019/02/12 Eric 
    Private Sub funLoadSWRJoinLog()

        Cursor.Current = Cursors.WaitCursor


        If Not IsNothing(dsWIP.Tables(tblSWRJoinLog)) Then
            dsWIP.Tables.Remove(tblSWRJoinLog)
        End If

        '組InXml的字串
        strIdentity = CombineXMLIdentity(gComputerName, gUserNo, GetNow())
        strParameter = CombineXMLParameter("loggroupserial", "LogGroupSerial", "String", CInput(dsWIP.Tables(tblLotState).Rows(0)("LogGroupSerial").ToString), "")
        strParameter += CombineXMLParameter("customerno", "CustomerNo", "String", CInput(dsWIP.Tables(tblLotState).Rows(0)("CustomerNo").ToString), "")
        strParameter += CombineXMLParameter("lotno", "LotNo", "String", CInput(txtLotNo.Text), "")
        strParameter += CombineXMLParameter("deviceno", "DeviceNo", "String", CInput(dsWIP.Tables(tblLotState).Rows(0)("DeviceNo").ToString), "")
        strParameter += CombineXMLParameter("opno", "OPNo", "String", CInput(txtOPNo.Text), "")
        strParameter += CombineXMLParameter("customerlotno", "CustomerLotNo", "String", CInput(txtCustomerLotNo.Text), "")
        strParameter += CombineXMLParameter("mono", "MONo", "String", CInput(txtMONo.Text), "")
        strParameter += CombineXMLParameter("status", "Status", "Integer", 2, "")

        InXml = CombineXMLRequest(strIdentity, strParameter)

        Try

            OutXml = InvokeSrv("wsWIP.LoadSWRBasisJoinLog", InXml)

            Dim XmlDoc As New XmlDocument
            XmlDoc.LoadXml(OutXml)
            If ChkExecutionSuccess(XmlDoc) Then
                tblSWRJoinLog = XmlDoc.GetElementsByTagName("returnvalue").Item(0).SelectNodes("loadswrbasisjoinlog").Item(0).SelectNodes("name").Item(0).InnerXml
                '取出Schema,dataset讀取Schema可防止Null Field及DateTime的問題
                XmlSchema = XmlDoc.DocumentElement.GetElementsByTagName("loadswrbasisjoinlog").Item(0).SelectNodes("schema").Item(0).InnerXml
                If XmlSchema <> "" Then
                    '將XML讀入String Reader object中,因為Dataset讀入XML時必須透過String Reader物件
                    tmpStringReader = New System.IO.StringReader(XmlSchema)
                    dsWIP.ReadXmlSchema(tmpStringReader)
                    tmpStringReader.Close()
                End If
                '取出Data
                XmlData = XmlDoc.DocumentElement.GetElementsByTagName("loadswrbasisjoinlog").Item(0).SelectNodes("value").Item(0).InnerXml
                If XmlData <> "" Then
                    tmpStringReader = New System.IO.StringReader(XmlData)
                    dsWIP.ReadXml(tmpStringReader)
                    tmpStringReader.Close()
                End If

            Else
                ExceptionManager.iMESShowDialog(GetExceptionCode(XmlDoc), GetExceptionSysMsg(XmlDoc), GetExceptionStack(XmlDoc))
                Exit Sub
            End If

            XmlDoc = Nothing

        Catch ex As iMESException.MESException
            ExceptionManager.iMESShowDialog(ex.ErrorCode, ex.Message, ex.StackTrace)
            Exit Sub
        Catch ex As Exception
            ExceptionManager.iMESShowDialog(defWinErrCode, ex.Message, ex.StackTrace)
            Exit Sub
        End Try

        Cursor.Current = Cursors.Default

    End Sub

    Private Sub funLoadAllMaterialLot()

        Dim drAdd As DataRow
        Dim drSel As DataRow()
        Dim defNullDate As Date = CDate("9999/12/31")          '製造日期或保存期限為Null時, 填入9999/12/31, 以防步Null錯誤, 因Null表示不受管控, 可以較後使用, 故填入較大的值

        dtAllMTLLot = New DataTable("AllMTLLot")
        dtAllMTLLot.Columns.Add("MaterialNo", System.Type.GetType("System.String"))         '主料號
        dtAllMTLLot.Columns.Add("MaterialLotNo", System.Type.GetType("System.String"))
        dtAllMTLLot.Columns.Add("Qty", System.Type.GetType("System.Decimal"))
        dtAllMTLLot.Columns.Add("MFGDate", System.Type.GetType("System.DateTime"))
        dtAllMTLLot.Columns.Add("ExpireDate", System.Type.GetType("System.DateTime"))
        dtAllMTLLot.Columns.Add("InputDate", System.Type.GetType("System.DateTime"))

        dtAllMTLLot.Columns.Add("SubstituteMaterialNo", System.Type.GetType("System.String"))    '新增一替代料欄位,2010/03/26,by yumei, 實際用料的料號
        dtAllMTLLot.Columns.Add("SubstituteMaterialLevel", System.Type.GetType("System.Int16"))  '新增一替代料位階欄位,2013/01/08,by Kevin
        dtAllMTLLot.Columns.Add("SubstituteMaterialType", System.Type.GetType("System.String"))  '新增一替代料類型欄位,2013/01/08,by Kevin
        dtAllMTLLot.Columns.Add("SubstituteStdQty", System.Type.GetType("System.Decimal"))       '新增一替代料標準用量欄位,2013/01/08,by Kevin
        dtAllMTLLot.Columns.Add("CheckLotNo", System.Type.GetType("System.Int16"))               '新增一替代料是否檢查批號欄位,2013/01/08,by Kevin

        dtAllMTLLot.Columns.Add("SeqNo", System.Type.GetType("System.Int16"))           '記錄同料號間各料批應被使用的次序
        dtAllMTLLot.Columns.Add("blnExpireDate", System.Type.GetType("System.Boolean"))  '紀錄是否有超過有效期限 有:True 沒有:False

        Select Case dsWIP.Tables(tblLotState).Rows(0)("MaterialOption").ToString

            Case "0"          ' 發料點(線邊倉或工單)
                '將Temp_Material中各主料所有可用料批全數取出, 存入dtAllMTLLot中
                For Each drMTL As DataRow In dsWIP.Tables(tblTMaterial).Rows
                    If drMTL("LOTNO").ToString <> "" Then
                        Call funLoadSubstituteMaterial_Main(LotNo, drMTL("MaterialNo"), drMTL("UnitNo"))
                        For Each drMTLLot As DataRow In dsWIP.Tables(tblSubstituteMaterial).Rows
                            drAdd = dtAllMTLLot.NewRow
                            drAdd("MaterialNo") = drMTL("MaterialNo")           'BOM的主料號
                            drAdd("MaterialLotNo") = drMTLLot("MaterialLotNo")
                            drAdd("Qty") = drMTLLot("Qty")
                            'drAdd("MFGDate") = drMTLLot("ManufactureDate")
                            'drAdd("ExpireDate") = drMTLLot("ExpireDate")
                            If drMTLLot("ManufactureDate").ToString = "" Then
                                drAdd("MFGDate") = defNullDate
                            Else
                                drAdd("MFGDate") = drMTLLot("ManufactureDate")
                            End If
                            If drMTLLot("ExpireDate").ToString = "" Then
                                drAdd("ExpireDate") = defNullDate
                            Else
                                drAdd("ExpireDate") = drMTLLot("ExpireDate")
                            End If
                            If drMTLLot("InputDate").ToString = "" Then
                                drAdd("InputDate") = defNullDate
                            Else
                                drAdd("InputDate") = drMTLLot("InputDate")
                            End If

                            drAdd("SubstituteMaterialNo") = drMTLLot("MaterialNo")          '實際料號, 有可能與主料號同也有可能是替代料號
                            drAdd("SubstituteMaterialLevel") = drMTLLot("SubstituteMaterialLevel")
                            drAdd("SubstituteMaterialType") = drMTLLot("SubstituteMaterialType")
                            drAdd("SubstituteStdQty") = drMTLLot("SubstituteStdQty")
                            drAdd("CheckLotNo") = drMTLLot("CheckLotNo")
                            dtAllMTLLot.Rows.Add(drAdd)
                        Next
                    End If
                Next

                '計算同一料號各料批的使用次序
                Dim dvAllMTLLot, dvTemp As DataView
                Dim dtTemp As DataTable
                For Each drMTL As DataRow In dsWIP.Tables(tblTMaterial).Rows
                    If drMTL("LOTNO").ToString <> "" Then
                        'drSel = dtAllMTLLot.Select("MaterialNo = '" & drMTL("MaterialNo") & "'", "MFGDate, ExpireDate, InputDate")
                        'For idx As Integer = 0 To drSel.Length - 1
                        '    drSel(idx)("SeqNo") = idx + 1
                        'Next
                        dvAllMTLLot = New DataView(dtAllMTLLot)
                        dvAllMTLLot.RowFilter = "MaterialNo = '" & drMTL("MaterialNo") & "'"
                        dtTemp = dvAllMTLLot.ToTable(True, {"MFGDate", "ExpireDate", "InputDate"})          '對製造日期,有效日期,入庫日做Distinct篩選
                        dvTemp = dtTemp.DefaultView
                        dvTemp.Sort = "MFGDate, ExpireDate, InputDate"
                        '當MFGDate, ExpireDate, InputDate皆相同時, 需給予相同的SeqNo, 故以Distinct的三個日期下去跑Loop
                        For idx As Integer = 0 To dvTemp.Count - 1
                            drSel = dtAllMTLLot.Select("MaterialNo = '" & drMTL("MaterialNo") & "'" &
                                                       "And MFGDate = #" & Format(dvTemp(idx)("MFGDate"), "yyyy/MM/dd HH:mm:ss") & "#" &
                                                       " And ExpireDate = #" & Format(dvTemp(idx)("ExpireDate"), "yyyy/MM/dd HH:mm:ss") & "#" &
                                                       " And InputDate = #" & Format(dvTemp(idx)("InputDate"), "yyyy/MM/dd HH:mm:ss") & "#")
                            For j As Integer = 0 To drSel.Length - 1
                                drSel(j)("SeqNo") = idx + 1
                                If Now > CDate(drSel(j)("EXPIREDATE")) Then '判定是否超過有效期限
                                    drSel(j)("blnExpireDate") = True
                                Else
                                    drSel(j)("blnExpireDate") = False
                                End If
                            Next
                        Next
                    End If
                Next

        End Select

    End Sub

#Region "CheckEQPQCList"

    Private Function funCheckEQPQCList(ByVal EquipmentNo As String, ByRef CheckResult As String) As Integer

        funCheckEQPQCList = -1

        '組InXml的字串
        strIdentity = CombineXMLIdentity(gComputerName, UserId, Now)
        strParameter = CombineXMLParameter("equipmentno", "EquipmentNo", "String", CInput(EquipmentNo), "")
        strParameter += CombineXMLParameter("lotno", "LotNo", "String", CInput(LotNo), "")
        InXml = CombineXMLRequest(strIdentity, strParameter)

        Try
            OutXml = InvokeSrv("wsWIP.CheckEQPQCList", InXml)

            Dim XmlDoc As New XmlDocument
            XmlDoc.LoadXml(OutXml)
            If ChkExecutionSuccess(XmlDoc) Then
                '取出CheckResult
                If XmlDoc.GetElementsByTagName("checkresult").Item(0).SelectNodes("value").Count > 0 Then
                    CheckResult = XmlDoc.DocumentElement.GetElementsByTagName("checkresult").Item(0).SelectNodes("value").Item(0).InnerText
                End If
            Else
                ExceptionManager.iMESShowDialog(GetExceptionCode(XmlDoc), GetExceptionSysMsg(XmlDoc), GetExceptionStack(XmlDoc))
                Exit Function
            End If

            XmlDoc = Nothing

        Catch ex As iMESException.MESException
            ExceptionManager.iMESShowDialog(ex.ErrorCode, ex.Message, ex.StackTrace)
            Exit Function
        Catch ex As Exception
            ExceptionManager.iMESShowDialog(defWinErrCode, ex.Message, ex.StackTrace)
            Exit Function
        End Try

        funCheckEQPQCList = 0

    End Function

    Private Function funCheckEQPQCTask(ByVal EquipmentNo As String, Optional ByVal CancelUpdate As Boolean = False) As Integer

        funCheckEQPQCTask = -1

        '組InXml的字串
        strIdentity = CombineXMLIdentity(gComputerName, UserId, Now)
        strParameter = CombineXMLParameter("equipmentno", "EquipmentNo", "String", CInput(EquipmentNo), "")
        strParameter += CombineXMLParameter("lotno", "LotNo", "String", CInput(LotNo), "")
        strParameter += CombineXMLParameter("cancelupdate", "CancelUpdate", "Boolean", CancelUpdate, "")
        InXml = CombineXMLRequest(strIdentity, strParameter)

        Try
            OutXml = InvokeSrv("wsWIP.CheckEQPQCTask", InXml)

            Dim XmlDoc As New XmlDocument
            XmlDoc.LoadXml(OutXml)
            If ChkExecutionSuccess(XmlDoc) Then

            Else
                ExceptionManager.iMESShowDialog(GetExceptionCode(XmlDoc), GetExceptionSysMsg(XmlDoc), GetExceptionStack(XmlDoc))
                Exit Function
            End If

            XmlDoc = Nothing

        Catch ex As iMESException.MESException
            ExceptionManager.iMESShowDialog(ex.ErrorCode, ex.Message, ex.StackTrace)
            Exit Function
        Catch ex As Exception
            ExceptionManager.iMESShowDialog(defWinErrCode, ex.Message, ex.StackTrace)
            Exit Function
        End Try

        funCheckEQPQCTask = 0

    End Function

#End Region


#Region "ChkCIEQPDispatch"
    ''2023/05/29 ,0135702: [6.0.7] SDD220425_01-03_進站設備派工查核調整,19245
    Private Sub ChkCIEQPDispatch(ByVal EquipmentNo As String, ByVal LotNo As String, Optional OpNo As String = defString)

        If Not IsNothing(dsEQP) Then
            dsEQP.Clear()
            dsEQP.Dispose()
        End If

        '組InXml的字串
        strIdentity = CombineXMLIdentity(gComputerName, gUserNo, GetNow())
        strParameter = CombineXMLParameter("equipmentno", "EquipmentNo", "String", CInput(EquipmentNo), "")
        strParameter += CombineXMLParameter("lotno", "LotNo", "String", CInput(LotNo), "")

        InXml = CombineXMLRequest(strIdentity, strParameter)

        Dim XmlDoc As New XmlDocument
        Try
            OutXml = InvokeSrv("wsWIP.ChkCIEQPDispatch", InXml)

            '利用XmlDoc物件處理ReturnValue 
            XmlDoc.LoadXml(OutXml)
            If ChkExecutionSuccess(XmlDoc) Then
                ckhEQPDispatchRule = XmlDoc.GetElementsByTagName("returnvalue").Item(0).SelectNodes("chkcieqpdispatch").Item(0).SelectNodes("name").Item(0).InnerXml
                '取出Schema,dataset讀取Schema可防止Null Field及DateTime的問題
                XmlSchema = XmlDoc.DocumentElement.GetElementsByTagName("chkcieqpdispatch").Item(0).SelectNodes("schema").Item(0).InnerXml
                If XmlSchema <> "" Then
                    '將XML讀入String Reader object中,因為Dataset讀入XML時必須透過String Reader物件
                    tmpStringReader = New System.IO.StringReader(XmlSchema)
                    dsEQP.ReadXmlSchema(tmpStringReader)
                    tmpStringReader.Close()
                End If
                '取出Data
                XmlData = XmlDoc.DocumentElement.GetElementsByTagName("chkcieqpdispatch").Item(0).SelectNodes("value").Item(0).InnerXml
                If XmlData <> "" Then
                    tmpStringReader = New System.IO.StringReader(XmlData)
                    dsEQP.ReadXml(tmpStringReader)
                    tmpStringReader.Close()
                End If
            Else
                ExceptionManager.iMESShowDialog(GetExceptionCode(XmlDoc), GetExceptionSysMsg(XmlDoc), GetExceptionStack(XmlDoc))
                Exit Sub
            End If

            XmlDoc = Nothing

        Catch ex As iMESException.MESException
            ExceptionManager.iMESShowDialog(ex.ErrorCode, ex.Message, ex.StackTrace)
            Exit Sub
        Catch ex As Exception
            ExceptionManager.iMESShowDialog(defWinErrCode, ex.Message, ex.StackTrace)
            Exit Sub
        End Try
    End Sub

#End Region
    Private Sub DeleteTmpMTLLotNo(ByVal EquipmentNo As String)

        Dim drSelTmpMTL As DataRow() = dsWIP.Tables(tblTmpMTLLotNo).Select("EquipmentNo = '" & EquipmentNo & "'")
        For i As Integer = drSelTmpMTL.Count - 1 To 0 Step -1
            drSelTmpMTL(i).Delete()
        Next
        dsWIP.Tables(tblTmpMTLLotNo).AcceptChanges()

    End Sub
    Private Sub LoadMaterialByEquipment(ByVal EquipmentNo As String)

        Try
            DeleteTmpMTLLotNo(EquipmentNo)

            Dim MONo As String = dsWIP.Tables(tblLotState).Rows(0)("MONo").ToString
            Dim OrgMaterialNo As String
            ' 依設備及工單取出設備上料現況
            Dim dtMaterialState As DataTable
            If (Not LoadEQPMaterialState(dtMaterialState, EquipmentNo, MONo)) Then
                Exit Sub
            End If

            ' 寫入暫存表
            For Each r As DataRowView In dtMaterialState.DefaultView
                'Dim drSel() As DataRow = dsWIP.Tables(tblTMaterial).Select("MaterialNo = '" & r("MaterialNo") & "' ")
                '物料表中的materialno是* 改成InputMaterialNo 14278
                Dim drSel() As DataRow = dsWIP.Tables(tblTMaterial).Select("MaterialNo = '" & r("InputMaterialNo") & "' ")
                If drSel.Length > 0 Then
                    '根据实际用料 投料点 和检查料批 找到用料清单的数据 原物料--------
                    Dim drSel1() As DataRow = dsOE.Tables(strMOList).Select("SubstituteMaterialNo='" & r("InputMaterialNo").ToString & "' and PutInPlaceType='" & drSel(0)("PutInPlaceType") & "' AND CheckLotNo='" & drSel(0)("CHECKLOTNO") & "'")
                    If drSel1.Length > 0 Then
                        OrgMaterialNo = drSel1(0)("MATERIALNO").ToString()
                    End If
                    ''----------------------
                    If drSel(0)("PutInPlaceType") = 3 Then
                        If r("MONO").ToString.ToUpper = MONo.ToUpper Then
                            Dim drAdd As DataRow = dsWIP.Tables(tblTmpMTLLotNo).NewRow
                            drAdd("EquipmentNo") = r("EquipmentNo")
                            'drAdd("OrgMaterialNo") = r("MaterialNo").ToString 'Me.iugMaterial.iMESUltraGrid.ActiveRow.Cells("MaterialNo").Value
                            drAdd("OrgMaterialNo") = OrgMaterialNo 'Me.iugMaterial.iMESUltraGrid.ActiveRow.Cells("MaterialNo").Value
                            drAdd("SUBSTITUTEMATERIALNO") = r("InputMaterialNo").ToString
                            drAdd("MaterialNo") = r("InputMaterialNo").ToString 'Me.iugMaterial.iMESUltraGrid.ActiveRow.Cells("MaterialNo").Value
                            drAdd("MaterialLotNo") = r("MaterialLotNo").ToString 'pMaterialLotNo
                            drAdd("Qty") = r("Qty")
                            dsWIP.Tables(tblTmpMTLLotNo).Rows.Add(drAdd)
                        End If
                    ElseIf drSel(0)("PutInPlaceType") = 2 OrElse drSel(0)("PutInPlaceType") = 4 Then
                        If r("MONO").ToString.ToUpper = "N/A" Then
                            Dim drAdd As DataRow = dsWIP.Tables(tblTmpMTLLotNo).NewRow
                            drAdd("EquipmentNo") = r("EquipmentNo")
                            'drAdd("OrgMaterialNo") = r("MaterialNo").ToString 'Me.iugMaterial.iMESUltraGrid.ActiveRow.Cells("MaterialNo").Value
                            drAdd("OrgMaterialNo") = OrgMaterialNo 'Me.iugMaterial.iMESUltraGrid.ActiveRow.Cells("MaterialNo").Value
                            drAdd("SUBSTITUTEMATERIALNO") = r("InputMaterialNo").ToString
                            drAdd("MaterialNo") = r("InputMaterialNo").ToString 'Me.iugMaterial.iMESUltraGrid.ActiveRow.Cells("MaterialNo").Value
                            drAdd("MaterialLotNo") = r("MaterialLotNo").ToString 'pMaterialLotNo
                            drAdd("Qty") = r("Qty")
                            dsWIP.Tables(tblTmpMTLLotNo).Rows.Add(drAdd)
                        End If
                    End If
                End If
            Next

        Catch ex As iMESException.MESException
            ExceptionManager.iMESShowDialog(ex.ErrorCode, ex.Message, ex.StackTrace)
        Catch ex As Exception
            ExceptionManager.iMESShowDialog(defWinErrCode, ex.Message, ex.StackTrace)
        End Try

    End Sub

    Private Sub uegMaterial_KeyIn2_ExpandedStateChanged(sender As Object, e As EventArgs) Handles uegMaterial_KeyIn2.ExpandedStateChanged, uegAttrib_Equipment.ExpandedStateChanged

        If uegMaterial_KeyIn2.Expanded Then

            If uegAttrib_Equipment.Expanded Then
                uegMaterial_KeyIn2.Size = New System.Drawing.Size(uegMaterial_KeyIn2.Width, (uplAll.Height - uegLotInfo.Height) / 2 - 10)
                uegAttrib_Equipment.Size = New System.Drawing.Size(uegAttrib_Equipment.Width, (uplAll.Height - uegLotInfo.Height) / 2 - 10)
            End If

        Else

            If uegAttrib_Equipment.Expanded Then
                uegAttrib_Equipment.Size = New System.Drawing.Size(uegAttrib_Equipment.Width, uplAll.Height - uegLotInfo.Height - 20)
            End If

        End If

    End Sub
#Region "'//^_^ADD BY  H-14278 2023-12-29 新设备上料"
    ''' <summary>
    ''' 获取工单用料清单
    ''' </summary>
    ''' <param name="MONo"></param>
    ''' <param name="OPNo"></param>
    Private Sub funLoadMOMaterialList(ByVal MONo As String, ByVal OPNo As String) '//取出MO MaterialList資料


        Dim i, j As Integer

        If Not IsNothing(dsOE.Tables(strMOList)) Then         '修正用料清單多次查詢重複計算問題
            dsOE.Tables.Remove(strMOList)
        End If

        '組InXml的字串
        strIdentity = CombineXMLIdentity(gComputerName, gUserNo, GetNow())
        strParameter = CombineXMLParameter("mono", "MONo", "String", MONo.ToUpper, "")
        strParameter += CombineXMLParameter("opno", "OPNo", "String", OPNo.ToUpper, "")
        InXml = CombineXMLRequest(strIdentity, strParameter)

        Try
            ' 2016 YF, OutXml = wsOE.LoadMOMaterialListJoinMOBasis(InXml)
            OutXml = InvokeSrv("wsOE.LoadMOMaterialListJoinMOBasis", InXml)

            '利用XmlDoc物件處理ReturnValue 
            Dim XmlDoc As New XmlDocument
            XmlDoc.LoadXml(OutXml)
            If ChkExecutionSuccess(XmlDoc) Then
                '讀取取出資料表之名稱

                strMOList = XmlDoc.GetElementsByTagName("returnvalue").Item(0).SelectNodes("loadmomateriallistjoinmobasis").Item(0).SelectNodes("name").Item(0).InnerXml
                '取出Schema,dataset讀取Schema可防止Null Field及DateTime的問題
                XmlSchema = XmlDoc.DocumentElement.GetElementsByTagName("loadmomateriallistjoinmobasis").Item(0).SelectNodes("schema").Item(0).InnerXml
                If XmlSchema <> "" Then
                    '將XML讀入String Reader object中,因為Dataset讀入XML時必須透過String Reader物件
                    tmpStringReader = New System.IO.StringReader(XmlSchema)
                    dsOE.ReadXmlSchema(tmpStringReader)
                    tmpStringReader.Close()
                End If
                '取出Data
                XmlData = XmlDoc.DocumentElement.GetElementsByTagName("loadmomateriallistjoinmobasis").Item(0).SelectNodes("value").Item(0).InnerXml
                If XmlData <> "" Then
                    tmpStringReader = New System.IO.StringReader(XmlData)
                    dsOE.ReadXml(tmpStringReader, XmlReadMode.InferSchema)
                    tmpStringReader.Close()
                End If

                XmlDoc = Nothing
            Else
                ExceptionManager.iMESShowDialog(GetExceptionCode(XmlDoc), GetExceptionSysMsg(XmlDoc), GetExceptionStack(XmlDoc))
                Exit Sub
            End If

        Catch ex As Exception
            'MsgBox("Unexpected Error. Load MO Material List Failed," & e1.Message, MsgBoxStyle.Exclamation)
            ExceptionManager.iMESShowDialog(defWinErrCode, ex.Message, ex.StackTrace)

        Finally
            tmpStringReader = Nothing
        End Try

    End Sub

#End Region

End Class
