﻿Imports System
Imports System.Linq
Imports System.Collections.Generic
Imports System.ComponentModel
Imports System.Data
Imports System.Drawing
Imports System.Text
Imports System.Windows.Forms
Imports System.Runtime.InteropServices
Imports Bt
Imports Bt.ScanLib
'Imports KDPL1000.BtScanLib
Imports BTClientLib
Imports System.IO
Imports System.Reflection
Imports Newtonsoft
Imports Microsoft.WindowsCE.Forms
Imports BtScan2

Public Class frm1017
    Inherits System.Windows.Forms.Form
    Private btScanLib As BtScanLib
    Private scanHandler As Boolean = False
    'Private dbClient As BtrieveDbClient
    Private tmpStr As List(Of Dictionary(Of String, String))
    Private affected_rows As Integer

#Region " Windows tH[€ fUCiลถฌณ๊ฝR[h "


    Public Sub New()
        MyBase.New()

        ' ฑฬฤัoตอ Windows tH[€ fUCiล•K—vลทB
        InitializeComponent()

        ' InitializeComponent() ฤัoตฬใษ๚ป๐’วมตทB

    End Sub

    ' Form อAR“|[l“g๊——ษใ—๐ภsท้ฝ฿ษ dispose ๐I[o[ChตทB
    '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 tH[€ fUCiล•K—vลทB
    'Private components As System.ComponentModel.IContainer

    '  : ศบฬvV[WอAWindows tH[€ fUCiล•K—vลทB
    'Windows tH[€ fUCi๐gมฤ•ฯXตฤญพณขB  
    ' R[h GfB^๐gมฤ•ฯXตศขลญพณขB
    'Friend WithEvents WarpFrame1 As WarpControl.WarpFrame
    'Friend WithEvents WarpBox1 As WarpControl.WarpBox
    'Friend WithEvents wfName As WarpControl.WarpField
    'Friend WithEvents WarpHWBcr1 As WarpControl.WarpHWBcr
    'Friend WithEvents WarpField1 As WarpControl.WarpField
    'Friend WithEvents WarpField2 As WarpControl.WarpField
    'Friend WithEvents WarpField5 As WarpControl.WarpField
    'Friend WithEvents wfMsc As WarpControl.WarpField
    'Friend WithEvents WarpField6 As WarpControl.WarpField
    'Friend WithEvents wfPNT As WarpControl.WarpField
    'Friend WithEvents WarpField8 As WarpControl.WarpField
    'Friend WithEvents wfTRM As WarpControl.WarpField
    'Friend WithEvents WarpField7 As WarpControl.WarpField
    'Friend WithEvents WarpField10 As WarpControl.WarpField
    'Friend WithEvents wfSeq As WarpControl.WarpField
    'Friend WithEvents wfLine As WarpControl.WarpField
    'Friend WithEvents wfCntOfCase As WarpControl.WarpField
    'Friend WithEvents wfCaseNo As WarpControl.WarpField
    'Friend WithEvents wfKey As WarpControl.WarpField
    'Friend WithEvents wfLine2 As WarpControl.WarpField
    'Friend WithEvents WarpField3 As WarpControl.WarpField
    '<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
    '    Me.WarpFrame1 = New WarpControl.WarpFrame()
    '    Me.wfKey = New WarpControl.WarpField()
    '    Me.WarpField3 = New WarpControl.WarpField()
    '    Me.wfLine2 = New WarpControl.WarpField()
    '    Me.wfCntOfCase = New WarpControl.WarpField()
    '    Me.WarpField10 = New WarpControl.WarpField()
    '    Me.wfCaseNo = New WarpControl.WarpField()
    '    Me.WarpField7 = New WarpControl.WarpField()
    '    Me.wfTRM = New WarpControl.WarpField()
    '    Me.WarpField8 = New WarpControl.WarpField()
    '    Me.wfPNT = New WarpControl.WarpField()
    '    Me.WarpField6 = New WarpControl.WarpField()
    '    Me.wfMsc = New WarpControl.WarpField()
    '    Me.WarpField5 = New WarpControl.WarpField()
    '    Me.wfSeq = New WarpControl.WarpField()
    '    Me.wfLine = New WarpControl.WarpField()
    '    Me.WarpField2 = New WarpControl.WarpField()
    '    Me.WarpField1 = New WarpControl.WarpField()
    '    Me.wfName = New WarpControl.WarpField()
    '    Me.WarpBox1 = New WarpControl.WarpBox()
    '    Me.WarpHWBcr1 = New WarpControl.WarpHWBcr()
    '    Me.WarpFrame1.SuspendLayout()
    '    Me.SuspendLayout()
    '
    'WarpFrame1
    '
    'Me.WarpFrame1.Controls.Add(Me.wfKey)
    'Me.WarpFrame1.Controls.Add(Me.WarpField3)
    'Me.WarpFrame1.Controls.Add(Me.wfLine2)
    'Me.WarpFrame1.Controls.Add(Me.wfCntOfCase)
    'Me.WarpFrame1.Controls.Add(Me.WarpField10)
    'Me.WarpFrame1.Controls.Add(Me.wfCaseNo)
    'Me.WarpFrame1.Controls.Add(Me.WarpField7)
    'Me.WarpFrame1.Controls.Add(Me.wfTRM)
    'Me.WarpFrame1.Controls.Add(Me.WarpField8)
    'Me.WarpFrame1.Controls.Add(Me.wfPNT)
    'Me.WarpFrame1.Controls.Add(Me.WarpField6)
    'Me.WarpFrame1.Controls.Add(Me.wfMsc)
    'Me.WarpFrame1.Controls.Add(Me.WarpField5)
    'Me.WarpFrame1.Controls.Add(Me.wfSeq)
    'Me.WarpFrame1.Controls.Add(Me.wfLine)
    'Me.WarpFrame1.Controls.Add(Me.WarpField2)
    'Me.WarpFrame1.Controls.Add(Me.WarpField1)
    'Me.WarpFrame1.Controls.Add(Me.wfName)
    'Me.WarpFrame1.Controls.Add(Me.WarpBox1)
    'Me.WarpFrame1.Font = New System.Drawing.Font("MS UI Gothic", 9.0!)
    'Me.WarpFrame1.Location = New System.Drawing.Point(0, 0)
    'Me.WarpFrame1.Name = "WarpFrame1"
    'Me.WarpFrame1.Size = New System.Drawing.Size(240, 296)
    'Me.WarpFrame1.TabIndex = 1
    'Me.WarpFrame1.Text = "WarpFrame1"
    'Me.WarpFrame1.UseMacro = False
    'Me.WarpFrame1.UseMacroFileName = ""
    '
    'wfKey
    '
    'Me.wfKey.BcrFlag = True
    'Me.wfKey.DecimalPointPosition = CType(0, Short)
    'Me.wfKey.Font = New System.Drawing.Font("lr SVbN", 33.5!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel)
    'Me.wfKey.ForeColor = CType(15, Short)
    'Me.wfKey.Format = ""
    'Me.wfKey.InputMode.Secret = True
    'Me.wfKey.Length = CType(1, Short)
    'Me.wfKey.Location = New System.Drawing.Point(144, 36)
    'Me.wfKey.MacroBcr = ""
    'Me.wfKey.MacroIn = ""
    'Me.wfKey.MacroKey = ""
    'Me.wfKey.MacroOut = ""
    'Me.wfKey.Name = "wfKey"
    'Me.wfKey.Size = New System.Drawing.Size(18, 36)
    'Me.wfKey.TabIndex = CType(19, Short)
    '
    'WarpField3
    '
    'Me.WarpField3.DecimalPointPosition = CType(0, Short)
    'Me.WarpField3.Font = New System.Drawing.Font("lr SVbN", 33.5!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel)
    'Me.WarpField3.Format = ""
    'Me.WarpField3.Length = CType(1, Short)
    'Me.WarpField3.Location = New System.Drawing.Point(70, 27)
    'Me.WarpField3.MacroBcr = ""
    'Me.WarpField3.MacroIn = ""
    'Me.WarpField3.MacroKey = ""
    'Me.WarpField3.MacroOut = ""
    'Me.WarpField3.Name = "WarpField3"
    'Me.WarpField3.Size = New System.Drawing.Size(18, 36)
    'Me.WarpField3.TabIndex = CType(21, Short)
    'Me.WarpField3.Text = "-"
    '
    'wfLine2
    '
    'Me.wfLine2.DecimalPointPosition = CType(0, Short)
    'Me.wfLine2.Font = New System.Drawing.Font("lr SVbN", 33.5!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel)
    'Me.wfLine2.Format = ""
    'Me.wfLine2.Length = CType(2, Short)
    'Me.wfLine2.Location = New System.Drawing.Point(96, 27)
    'Me.wfLine2.MacroBcr = ""
    'Me.wfLine2.MacroIn = ""
    'Me.wfLine2.MacroKey = ""
    'Me.wfLine2.MacroOut = ""
    'Me.wfLine2.Name = "wfLine2"
    'Me.wfLine2.Size = New System.Drawing.Size(36, 36)
    'Me.wfLine2.TabIndex = CType(20, Short)
    'Me.wfLine2.Text = "XX"
    '
    'wfCntOfCase
    '
    'Me.wfCntOfCase.DecimalPointPosition = CType(0, Short)
    'Me.wfCntOfCase.Font = New System.Drawing.Font("lr SVbN", 22.5!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel)
    'Me.wfCntOfCase.FontSize = WarpControl.FontSizes.Small2
    'Me.wfCntOfCase.Format = ""
    'Me.wfCntOfCase.InputMode.Right = True
    'Me.wfCntOfCase.Length = CType(5, Short)
    'Me.wfCntOfCase.Location = New System.Drawing.Point(168, 156)
    'Me.wfCntOfCase.MacroBcr = ""
    'Me.wfCntOfCase.MacroIn = ""
    'Me.wfCntOfCase.MacroKey = ""
    'Me.wfCntOfCase.MacroOut = ""
    'Me.wfCntOfCase.Name = "wfCntOfCase"
    'Me.wfCntOfCase.Size = New System.Drawing.Size(60, 24)
    'Me.wfCntOfCase.TabIndex = CType(18, Short)
    'Me.wfCntOfCase.Text = "ZZZZ9"
    '
    'WarpField10
    '
    'Me.WarpField10.DecimalPointPosition = CType(0, Short)
    'Me.WarpField10.Font = New System.Drawing.Font("lr SVbN", 16.5!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel)
    'Me.WarpField10.FontSize = WarpControl.FontSizes.Small4
    'Me.WarpField10.Format = ""
    'Me.WarpField10.Length = CType(7, Short)
    'Me.WarpField10.Location = New System.Drawing.Point(144, 133)
    'Me.WarpField10.MacroBcr = ""
    'Me.WarpField10.MacroIn = ""
    'Me.WarpField10.MacroKey = ""
    'Me.WarpField10.MacroOut = ""
    'Me.WarpField10.Name = "WarpField10"
    'Me.WarpField10.Size = New System.Drawing.Size(63, 18)
    'Me.WarpField10.TabIndex = CType(17, Short)
    'Me.WarpField10.Text = "#ofCase"
    '
    'wfCaseNo
    '
    'Me.wfCaseNo.DecimalPointPosition = CType(0, Short)
    'Me.wfCaseNo.Font = New System.Drawing.Font("lr SVbN", 22.5!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel)
    'Me.wfCaseNo.FontSize = WarpControl.FontSizes.Small2
    'Me.wfCaseNo.Format = ""
    'Me.wfCaseNo.Length = CType(9, Short)
    'Me.wfCaseNo.Location = New System.Drawing.Point(9, 141)
    'Me.wfCaseNo.MacroBcr = ""
    'Me.wfCaseNo.MacroIn = ""
    'Me.wfCaseNo.MacroKey = ""
    'Me.wfCaseNo.MacroOut = ""
    'Me.wfCaseNo.Name = "wfCaseNo"
    'Me.wfCaseNo.Size = New System.Drawing.Size(108, 24)
    'Me.wfCaseNo.TabIndex = CType(16, Short)
    'Me.wfCaseNo.Text = "999-XX-99"
    '
    'WarpField7
    '
    'Me.WarpField7.DecimalPointPosition = CType(0, Short)
    'Me.WarpField7.Font = New System.Drawing.Font("lr SVbN", 16.5!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel)
    'Me.WarpField7.FontSize = WarpControl.FontSizes.Small4
    'Me.WarpField7.Format = ""
    'Me.WarpField7.Length = CType(6, Short)
    'Me.WarpField7.Location = New System.Drawing.Point(0, 120)
    'Me.WarpField7.MacroBcr = ""
    'Me.WarpField7.MacroIn = ""
    'Me.WarpField7.MacroKey = ""
    'Me.WarpField7.MacroOut = ""
    'Me.WarpField7.Name = "WarpField7"
    'Me.WarpField7.Size = New System.Drawing.Size(54, 18)
    'Me.WarpField7.TabIndex = CType(15, Short)
    'Me.WarpField7.Text = "CaseNo"
    '
    'wfTRM
    '
    'Me.wfTRM.DecimalPointPosition = CType(0, Short)
    'Me.wfTRM.Font = New System.Drawing.Font("lr SVbN", 28.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel)
    'Me.wfTRM.FontSize = WarpControl.FontSizes.Small
    'Me.wfTRM.Format = ""
    'Me.wfTRM.Length = CType(3, Short)
    'Me.wfTRM.Location = New System.Drawing.Point(192, 93)
    'Me.wfTRM.MacroBcr = ""
    'Me.wfTRM.MacroIn = ""
    'Me.wfTRM.MacroKey = ""
    'Me.wfTRM.MacroOut = ""
    'Me.wfTRM.Name = "wfTRM"
    'Me.wfTRM.Size = New System.Drawing.Size(45, 30)
    'Me.wfTRM.TabIndex = CType(14, Short)
    'Me.wfTRM.Text = "XXX"
    '
    'WarpField8
    '
    'Me.WarpField8.DecimalPointPosition = CType(0, Short)
    'Me.WarpField8.Font = New System.Drawing.Font("lr SVbN", 16.5!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel)
    'Me.WarpField8.FontSize = WarpControl.FontSizes.Small4
    'Me.WarpField8.Format = ""
    'Me.WarpField8.Length = CType(3, Short)
    'Me.WarpField8.Location = New System.Drawing.Point(180, 72)
    'Me.WarpField8.MacroBcr = ""
    'Me.WarpField8.MacroIn = ""
    'Me.WarpField8.MacroKey = ""
    'Me.WarpField8.MacroOut = ""
    'Me.WarpField8.Name = "WarpField8"
    'Me.WarpField8.Size = New System.Drawing.Size(27, 18)
    'Me.WarpField8.TabIndex = CType(13, Short)
    'Me.WarpField8.Text = "TRM"
    '
    'wfPNT
    '
    'Me.wfPNT.DecimalPointPosition = CType(0, Short)
    'Me.wfPNT.Font = New System.Drawing.Font("lr SVbN", 28.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel)
    'Me.wfPNT.FontSize = WarpControl.FontSizes.Small
    'Me.wfPNT.Format = ""
    'Me.wfPNT.Length = CType(3, Short)
    'Me.wfPNT.Location = New System.Drawing.Point(132, 93)
    'Me.wfPNT.MacroBcr = ""
    'Me.wfPNT.MacroIn = ""
    'Me.wfPNT.MacroKey = ""
    'Me.wfPNT.MacroOut = ""
    'Me.wfPNT.Name = "wfPNT"
    'Me.wfPNT.Size = New System.Drawing.Size(45, 30)
    'Me.wfPNT.TabIndex = CType(12, Short)
    'Me.wfPNT.Text = "XXX"
    '
    'WarpField6
    '
    'Me.WarpField6.DecimalPointPosition = CType(0, Short)
    'Me.WarpField6.Font = New System.Drawing.Font("lr SVbN", 16.5!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel)
    'Me.WarpField6.FontSize = WarpControl.FontSizes.Small4
    'Me.WarpField6.Format = ""
    'Me.WarpField6.Length = CType(3, Short)
    'Me.WarpField6.Location = New System.Drawing.Point(120, 72)
    'Me.WarpField6.MacroBcr = ""
    'Me.WarpField6.MacroIn = ""
    'Me.WarpField6.MacroKey = ""
    'Me.WarpField6.MacroOut = ""
    'Me.WarpField6.Name = "WarpField6"
    'Me.WarpField6.Size = New System.Drawing.Size(27, 18)
    'Me.WarpField6.TabIndex = CType(11, Short)
    'Me.WarpField6.Text = "PNT"
    '
    'wfMsc
    '
    'Me.wfMsc.DecimalPointPosition = CType(0, Short)
    'Me.wfMsc.Font = New System.Drawing.Font("lr SVbN", 28.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel)
    'Me.wfMsc.FontSize = WarpControl.FontSizes.Small
    'Me.wfMsc.Format = ""
    'Me.wfMsc.Length = CType(8, Short)
    'Me.wfMsc.Location = New System.Drawing.Point(0, 93)
    'Me.wfMsc.MacroBcr = ""
    'Me.wfMsc.MacroIn = ""
    'Me.wfMsc.MacroKey = ""
    'Me.wfMsc.MacroOut = ""
    'Me.wfMsc.Name = "wfMsc"
    'Me.wfMsc.Size = New System.Drawing.Size(120, 30)
    'Me.wfMsc.TabIndex = CType(10, Short)
    'Me.wfMsc.Text = "XXXX-XXX"
    '
    'WarpField5
    '
    'Me.WarpField5.DecimalPointPosition = CType(0, Short)
    'Me.WarpField5.Font = New System.Drawing.Font("lr SVbN", 16.5!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel)
    'Me.WarpField5.FontSize = WarpControl.FontSizes.Small4
    'Me.WarpField5.Format = ""
    'Me.WarpField5.Length = CType(3, Short)
    'Me.WarpField5.Location = New System.Drawing.Point(0, 72)
    'Me.WarpField5.MacroBcr = ""
    'Me.WarpField5.MacroIn = ""
    'Me.WarpField5.MacroKey = ""
    'Me.WarpField5.MacroOut = ""
    'Me.WarpField5.Name = "WarpField5"
    'Me.WarpField5.Size = New System.Drawing.Size(27, 18)
    'Me.WarpField5.TabIndex = CType(9, Short)
    'Me.WarpField5.Text = "MSC"
    '
    'wfSeq
    '
    'Me.wfSeq.DecimalPointPosition = CType(0, Short)
    'Me.wfSeq.Font = New System.Drawing.Font("lr SVbN", 33.5!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel)
    'Me.wfSeq.Format = ""
    'Me.wfSeq.Length = CType(3, Short)
    'Me.wfSeq.Location = New System.Drawing.Point(168, 27)
    'Me.wfSeq.MacroBcr = ""
    'Me.wfSeq.MacroIn = ""
    'Me.wfSeq.MacroKey = ""
    'Me.wfSeq.MacroOut = ""
    'Me.wfSeq.Name = "wfSeq"
    'Me.wfSeq.Size = New System.Drawing.Size(54, 36)
    'Me.wfSeq.TabIndex = CType(8, Short)
    'Me.wfSeq.Text = "999"
    '
    'wfLine
    '
    'Me.wfLine.DecimalPointPosition = CType(0, Short)
    'Me.wfLine.Font = New System.Drawing.Font("lr SVbN", 33.5!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel)
    'Me.wfLine.Format = ""
    'Me.wfLine.Length = CType(2, Short)
    'Me.wfLine.Location = New System.Drawing.Point(24, 27)
    'Me.wfLine.MacroBcr = ""
    'Me.wfLine.MacroIn = ""
    'Me.wfLine.MacroKey = ""
    'Me.wfLine.MacroOut = ""
    'Me.wfLine.Name = "wfLine"
    'Me.wfLine.Size = New System.Drawing.Size(36, 36)
    'Me.wfLine.TabIndex = CType(7, Short)
    'Me.wfLine.Text = "XX"
    '
    'WarpField2
    '
    'Me.WarpField2.DecimalPointPosition = CType(0, Short)
    'Me.WarpField2.Font = New System.Drawing.Font("lr SVbN", 16.5!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel)
    'Me.WarpField2.FontSize = WarpControl.FontSizes.Small4
    'Me.WarpField2.Format = ""
    'Me.WarpField2.Length = CType(3, Short)
    'Me.WarpField2.Location = New System.Drawing.Point(156, 3)
    'Me.WarpField2.MacroBcr = ""
    'Me.WarpField2.MacroIn = ""
    'Me.WarpField2.MacroKey = ""
    'Me.WarpField2.MacroOut = ""
    'Me.WarpField2.Name = "WarpField2"
    'Me.WarpField2.Size = New System.Drawing.Size(27, 18)
    'Me.WarpField2.TabIndex = CType(6, Short)
    'Me.WarpField2.Text = "Seq"
    '
    'WarpField1
    '
    'Me.WarpField1.DecimalPointPosition = CType(0, Short)
    'Me.WarpField1.Font = New System.Drawing.Font("lr SVbN", 16.5!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel)
    'Me.WarpField1.FontSize = WarpControl.FontSizes.Small4
    'Me.WarpField1.Format = ""
    'Me.WarpField1.Length = CType(4, Short)
    'Me.WarpField1.Location = New System.Drawing.Point(12, 3)
    'Me.WarpField1.MacroBcr = ""
    'Me.WarpField1.MacroIn = ""
    'Me.WarpField1.MacroKey = ""
    'Me.WarpField1.MacroOut = ""
    'Me.WarpField1.Name = "WarpField1"
    'Me.WarpField1.Size = New System.Drawing.Size(36, 18)
    'Me.WarpField1.TabIndex = CType(5, Short)
    'Me.WarpField1.Text = "Line"
    '
    'wfName
    '
    'Me.wfName.DecimalPointPosition = CType(0, Short)
    'Me.wfName.Font = New System.Drawing.Font("lr SVbN", 22.5!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel)
    'Me.wfName.FontSize = WarpControl.FontSizes.Small2
    'Me.wfName.Format = ""
    'Me.wfName.Length = CType(20, Short)
    'Me.wfName.Location = New System.Drawing.Point(0, 216)
    'Me.wfName.MacroBcr = ""
    'Me.wfName.MacroIn = ""
    'Me.wfName.MacroKey = ""
    'Me.wfName.MacroOut = ""
    'Me.wfName.Name = "wfName"
    'Me.wfName.Size = New System.Drawing.Size(240, 24)
    'Me.wfName.TabIndex = CType(2, Short)
    '
    'WarpBox1
    '
    'Me.WarpBox1.BoxType = WarpControl.BoxTypes.Box
    'Me.WarpBox1.DrawMode = WarpControl.DrawModes.Line
    'Me.WarpBox1.Font = New System.Drawing.Font("lr SVbN", 33.5!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel)
    'Me.WarpBox1.ForeColor = CType(15, Short)
    'Me.WarpBox1.Image = "C:\H081-0110.jpg"
    'Me.WarpBox1.Location = New System.Drawing.Point(0, 192)
    'Me.WarpBox1.Name = "WarpBox1"
    'Me.WarpBox1.Size = New System.Drawing.Size(240, 24)
    'Me.WarpBox1.TabIndex = 0
    'Me.WarpBox1.Text = "WarpBox1"
    '
    'WarpHWBcr1
    '
    'Me.WarpHWBcr1.Decode.Code39 = True
    'Me.WarpHWBcr1.DiscreteFirstLen = CType(0, Short)
    'Me.WarpHWBcr1.DiscreteSecondLen = CType(0, Short)
    'Me.WarpHWBcr1.InterleavedFirstLen = CType(0, Short)
    'Me.WarpHWBcr1.InterleavedSecondLen = CType(0, Short)
    '
    'frm1017
    '
    'Me.AutoScaleBaseSize = New System.Drawing.Size(5, 12)
    'Me.ClientSize = New System.Drawing.Size(240, 296)
    'Me.Controls.Add(Me.WarpFrame1)
    'Me.Font = New System.Drawing.Font("MS UI Gothic", 9.0!)
    'Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None
    'Me.Name = "frm1017"
    'Me.Text = "Form1"
    'Me.WarpFrame1.ResumeLayout(False)
    'Me.ResumeLayout(False)

    'End Sub

#End Region

    Public Enum M1017_STATUS As Integer
        INIT = 0
        MENUBACK = 1
        SHUTDOWN = 2
        NOTCD = 3
        DONE = 4
    End Enum

    Public mint1017status As Integer

    Private Sub frm1017_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles MyBase.KeyDown
        Select Case e.KeyCode.ToString()
            Case "Return"
                Exit Sub
            Case "F1"
            Case "F2"
                gintStatus = PL_STATUS.QUIT
                Me.Close()
                Exit Sub
        End Select
    End Sub

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

        '// Case QVGA -> resolution to 1/2
        If System.Windows.Forms.Screen.PrimaryScreen.Bounds.Width = 240 Then
            Call resolution.VGAtoQVGA(Me)
        End If

        Dim wstrImage As String
        Dim rtn As Integer = 0

        Try
            mint1017status = M1017_STATUS.INIT
            't[€ฬI[v“
            'rtn = WarpFrame1.Open
            'If (rtn <> 0) Then
            '    Err.Raise(vbObjectError + 1, gAppName, "WarpError")
            'End If

            sDisp1017()

#If Not Debug Then
            'sSetImgFName(G_CONST_MID_H1017, WarpBox1)
#Else
            'WarpBox1.Text = "€”๕ชo—ฝ็EntL["
#End If
            ' tH[€EC“ ภs
            sMain()

            ' t[€ฬN[Y
            'rtn = WarpFrame1.Close()
            'If (rtn <> 0) Then
            '    Err.Raise(vbObjectError + 1, gAppName, "WarpError")
            'End If

            ' tH[€EN[Y
            'Me.Close()

            Exit Sub

        Catch ex As Exception
            gintStatus = PL_STATUS.QUIT
            sErrLog(gAppName, "frm1017_Load", ex.ToString)
            Me.Close()
        End Try
    End Sub

    '/*
    '|| ึ”–ผFsDisp1017
    '|| T—v  F1017ๆ–ส•\ฆ
    '*/
    Private Sub sDisp1017()
        With gstrctAicCase
            'wfLine.Puts(.Line)
            'wfLine2.Puts(.KasoLine)
            'wfSeq.Puts(CInt(.PackSeq))
            'wfMsc.Puts(.Msc_Disp)
            'wfPNT.Puts(.Pnt)
            'wfTRM.Puts(.Trm)
            'wfCaseNo.Puts(.CaseNo)
            'wfCntOfCase.Puts(gstrctPLDispHead.intNumOfScan)

            wfLine.Text = .Line
            wfLine2.Text = .KasoLine
            wfSeq.Text = CInt(.PackSeq)
            wfMsc.Text = .Msc_Disp
            wfPNT.Text = .Pnt
            wfTRM.Text = .Trm
            wfCaseNo.Text = .CaseNo
            wfCntOfCase.Text = gstrctPLDispHead.intNumOfScan

        End With
        'wfName.Puts(gstrctKDHT.strUserName)

        wfName.Text = gstrctKDHT.strUserName
    End Sub

    Private Sub btScanLib_OnScan(ByVal result As String)
        Dim buf As String = result
        Dim rtn As Integer

        If (Not fCheckCode(buf)) Then
            sBeepSound(modPublicHT.BEEP_TYPE.A, modPublicHT.BEEP_SELECTION.NG)
#If Not Debug Then
                                fFnc_WrpMsg("E", G_CONST_MID_E1E05)
#End If
            Exit Sub
        End If

        '“—อ—
        rtn = fProcInput(RTrim(buf))

        If rtn = 0 Then
            Select Case mint1017status
                Case M1017_STATUS.INIT

                    '์ฦๆ–สฬ•\ฆ

                    RemoveHandler btScanLib.OnScan, AddressOf btScanLib_OnScan
                    btScanLib.Disable()

                    gintStatus = PL_STATUS.ENTKEY
                    Me.Close()
                    Exit Sub

                Case M1017_STATUS.MENUBACK          'HTCTRL.ExeName๐มตฤI—น

                    RemoveHandler btScanLib.OnScan, AddressOf btScanLib_OnScan
                    btScanLib.Disable()

                    gintStatus = PL_STATUS.PALETTESCN
                    Me.Close()
                    Exit Sub

                Case M1017_STATUS.SHUTDOWN          'HTCTRL.ExeName๐มตฤI—น
                    sFinishApp()
                    gintStatus = PL_STATUS.QUIT
                    Me.Close()
                    Exit Sub

                Case M1017_STATUS.NOTCD              'ูศ้o[R[h

            End Select

        Else

            'f0.WarpCtrl1.MessageBox(G_CONST_EMT_DB, G_CONST_EM_DB, MWA_DB_WARNING, MWA_DB_OK)
            'f0.WarpCtrl1.MessageBox(G_CONST_EMT_DB, fEditErrorInfo(gclsDB.BtriveStatus, gclsDB.ErrFile), MWA_DB_WARNING, MWA_DB_OK)
            MessageBox.Show(G_CONST_EM_DB, G_CONST_EMT_DB, MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1)

        End If

    End Sub

    ' t[€EC“
    Public Sub sMain()
        '        Dim WKey As Short
        '        Dim buf As String
        '        Dim rtn As Integer

        '        Try

        '            ' t[€ฬ—๐ฑฑษLqตทB
        '            Do While (True)

        '                ' R[h“—อ
        '                WKey = WarpFrame1.Input(wfKey)

        '                If WKey = WKY_ENT Then

        '                    'sBeepSound(modPublicHT.BEEP_TYPE.B, modPublicHT.BEEP_SELECTION.NG)
        '                    gintStatus = PL_STATUS.PCSCAN
        '                    Exit Do

        '                ElseIf WKey = WKY_BCR Then

        '                    'สฐบฐฤ“—อฬๆ“พ
        '                    rtn = WarpHWBcr1.Get(buf)
        '                    sBeepSound(modPublicHT.BEEP_TYPE.A, modPublicHT.BEEP_SELECTION.OK)
        '                    If (rtn <> 0) Then
        '                        Err.Raise(vbObjectError + 1, gAppName, "WarpError")
        '                    End If

        '                    'มชฏธรจผฏฤ
        '                    If (Not fCheckCode(buf)) Then
        '                        sBeepSound(modPublicHT.BEEP_TYPE.A, modPublicHT.BEEP_SELECTION.NG)
        '#If Not Debug Then
        '                        fFnc_WrpMsg("E", G_CONST_MID_E1E05)
        '#End If
        '                        Exit Do
        '                    End If

        '                    '“—อ—
        '                    rtn = fProcInput(RTrim(buf))

        '                    If rtn = 0 Then
        '                        Select Case mint1017status
        '                            Case M1017_STATUS.INIT

        '                                '์ฦๆ–สฬ•\ฆ

        '                                gintStatus = PL_STATUS.ENTKEY

        '                            Case M1017_STATUS.MENUBACK          'HTCTRL.ExeName๐มตฤI—น

        '                                gintStatus = PL_STATUS.PALETTESCN

        '                            Case M1017_STATUS.SHUTDOWN          'HTCTRL.ExeName๐มตฤI—น
        '                                sFinishApp()
        '                                gintStatus = PL_STATUS.QUIT

        '                            Case M1017_STATUS.NOTCD              'ูศ้o[R[h

        '                        End Select

        '                    Else

        '                        'f0.WarpCtrl1.MessageBox(G_CONST_EMT_DB, G_CONST_EM_DB, MWA_DB_WARNING, MWA_DB_OK)
        '                        f0.WarpCtrl1.MessageBox(G_CONST_EMT_DB, fEditErrorInfo(gclsDB.BtriveStatus, gclsDB.ErrFile), MWA_DB_WARNING, MWA_DB_OK)

        '                    End If
        '                    Exit Do

        '                ElseIf WKey = WKY_F1 Then

        '                ElseIf WKey = WKY_F2 Then

        '                ElseIf WKey = WKY_ERROR Then

        '                    f0.WarpCtrl1.MessageBox(G_CONST_EMT_WARP, G_CONST_EM_WARP, MWA_DB_WARNING, MWA_DB_OK)

        '                End If

        '            Loop

        '            Exit Sub

        '        Catch ex As Exception
        '            sErrLog(gAppName, "sMain", ex.ToString)
        '        End Try

    End Sub
    '/*
    '|| ึ”–ผFfProcInput
    '|| T—v  F“—อ—
    '*/
    Private Function fProcInput(ByVal pstrInput As String) As Integer

        fProcInput = -1

        Try

            If pstrInput = "OCMENUBACK" Then             'OCMENUBACKศ็ฮ

                mint1017status = M1017_STATUS.MENUBACK
                fProcInput = 0
                Exit Function

            ElseIf pstrInput = "OCSHUTDOWN" Then             'OCSHUTDOWNศ็ฮ

                mint1017status = M1017_STATUS.SHUTDOWN
                fProcInput = 0
                Exit Function

            Else

                mint1017status = M1017_STATUS.NOTCD
                fProcInput = 0
                Exit Function

            End If

            fProcInput = 0

            Exit Function

        Catch ex As Exception
            sErrLog(gAppName, "fProcInput", ex.ToString)
        End Try
    End Function

    Private Sub frm1017_Activated(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Activated
        ' Enable BTScanLib
        If Not scanHandler Then
            btScanLib = btScanLib.getInstance()
            AddHandler btScanLib.OnScan, AddressOf btScanLib_OnScan
            scanHandler = True
            btScanLib.Debug = False
            btScanLib.Enable()
        End If
    End Sub
End Class
