﻿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 KDPP2000.BtScanLib
Imports BTClientLib
Imports System.IO
Imports System.Reflection
Imports BtScan2

Public Class frm2055
    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 wfName As WarpControl.WarpField
    'Friend WithEvents WarpHWBcr1 As WarpControl.WarpHWBcr
    'Friend WithEvents wfKey As WarpControl.WarpField
    'Friend WithEvents wfScn As WarpControl.WarpField
    'Friend WithEvents WarpField1 As WarpControl.WarpField
    'Friend WithEvents WarpBox1 As WarpControl.WarpBox
    'Friend WithEvents wfTRM As WarpControl.WarpField
    'Friend WithEvents WarpField3 As WarpControl.WarpField
    'Friend WithEvents wfMsc2 As WarpControl.WarpField
    'Friend WithEvents WarpField9 As WarpControl.WarpField
    'Friend WithEvents wfPNT As WarpControl.WarpField
    'Friend WithEvents WarpField7 As WarpControl.WarpField
    'Friend WithEvents wfMsc1 As WarpControl.WarpField
    'Friend WithEvents WarpField5 As WarpControl.WarpField
    'Friend WithEvents wfCsNo3 As WarpControl.WarpField
    'Friend WithEvents WarpField11 As WarpControl.WarpField
    'Friend WithEvents wfCsNo2 As WarpControl.WarpField
    'Friend WithEvents WarpField4 As WarpControl.WarpField
    'Friend WithEvents wfCsNo1 As WarpControl.WarpField
    'Friend WithEvents WarpField8 As WarpControl.WarpField
    'Friend WithEvents wfCrtnTo As WarpControl.WarpField
    'Friend WithEvents WarpField12 As WarpControl.WarpField
    'Friend WithEvents wfCrtnFrom As WarpControl.WarpField
    'Friend WithEvents WarpField10 As WarpControl.WarpField
    '<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
    '    Me.WarpFrame1 = New WarpControl.WarpFrame()
    '    Me.wfCrtnTo = New WarpControl.WarpField()
    '    Me.WarpField12 = New WarpControl.WarpField()
    '    Me.wfCrtnFrom = New WarpControl.WarpField()
    '    Me.WarpField10 = New WarpControl.WarpField()
    '    Me.wfCsNo3 = New WarpControl.WarpField()
    '    Me.WarpField11 = New WarpControl.WarpField()
    '    Me.wfCsNo2 = New WarpControl.WarpField()
    '    Me.WarpField4 = New WarpControl.WarpField()
    '    Me.wfCsNo1 = New WarpControl.WarpField()
    '    Me.WarpField8 = New WarpControl.WarpField()
    '    Me.wfTRM = New WarpControl.WarpField()
    '    Me.WarpField3 = New WarpControl.WarpField()
    '    Me.wfMsc2 = New WarpControl.WarpField()
    '    Me.WarpField9 = New WarpControl.WarpField()
    '    Me.wfPNT = New WarpControl.WarpField()
    '    Me.WarpField7 = New WarpControl.WarpField()
    '    Me.wfMsc1 = New WarpControl.WarpField()
    '    Me.WarpField5 = New WarpControl.WarpField()
    '    Me.WarpBox1 = New WarpControl.WarpBox()
    '    Me.WarpField1 = New WarpControl.WarpField()
    '    Me.wfScn = New WarpControl.WarpField()
    '    Me.wfKey = New WarpControl.WarpField()
    '    Me.wfName = New WarpControl.WarpField()
    '    Me.WarpHWBcr1 = New WarpControl.WarpHWBcr()
    '    Me.WarpFrame1.SuspendLayout()
    '    Me.SuspendLayout()
    '    '
    '    'WarpFrame1
    '    '
    '    Me.WarpFrame1.Controls.Add(Me.wfCrtnTo)
    '    Me.WarpFrame1.Controls.Add(Me.WarpField12)
    '    Me.WarpFrame1.Controls.Add(Me.wfCrtnFrom)
    '    Me.WarpFrame1.Controls.Add(Me.WarpField10)
    '    Me.WarpFrame1.Controls.Add(Me.wfCsNo3)
    '    Me.WarpFrame1.Controls.Add(Me.WarpField11)
    '    Me.WarpFrame1.Controls.Add(Me.wfCsNo2)
    '    Me.WarpFrame1.Controls.Add(Me.WarpField4)
    '    Me.WarpFrame1.Controls.Add(Me.wfCsNo1)
    '    Me.WarpFrame1.Controls.Add(Me.WarpField8)
    '    Me.WarpFrame1.Controls.Add(Me.wfTRM)
    '    Me.WarpFrame1.Controls.Add(Me.WarpField3)
    '    Me.WarpFrame1.Controls.Add(Me.wfMsc2)
    '    Me.WarpFrame1.Controls.Add(Me.WarpField9)
    '    Me.WarpFrame1.Controls.Add(Me.wfPNT)
    '    Me.WarpFrame1.Controls.Add(Me.WarpField7)
    '    Me.WarpFrame1.Controls.Add(Me.wfMsc1)
    '    Me.WarpFrame1.Controls.Add(Me.WarpField5)
    '    Me.WarpFrame1.Controls.Add(Me.WarpBox1)
    '    Me.WarpFrame1.Controls.Add(Me.WarpField1)
    '    Me.WarpFrame1.Controls.Add(Me.wfScn)
    '    Me.WarpFrame1.Controls.Add(Me.wfKey)
    '    Me.WarpFrame1.Controls.Add(Me.wfName)
    '    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 = ""
    '    '
    '    'wfCrtnTo
    '    '
    '    Me.wfCrtnTo.DecimalPointPosition = CType(0, Short)
    '    Me.wfCrtnTo.DisplayAttribute.Bold = True
    '    Me.wfCrtnTo.Font = New System.Drawing.Font("lr SVbN", 33.5!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Pixel)
    '    Me.wfCrtnTo.Format = ""
    '    Me.wfCrtnTo.InputAttribute.Bold = True
    '    Me.wfCrtnTo.Length = CType(5, Short)
    '    Me.wfCrtnTo.Location = New System.Drawing.Point(145, 156)
    '    Me.wfCrtnTo.MacroBcr = ""
    '    Me.wfCrtnTo.MacroIn = ""
    '    Me.wfCrtnTo.MacroKey = ""
    '    Me.wfCrtnTo.MacroOut = ""
    '    Me.wfCrtnTo.Name = "wfCrtnTo"
    '    Me.wfCrtnTo.Size = New System.Drawing.Size(90, 36)
    '    Me.wfCrtnTo.TabIndex = CType(42, Short)
    '    Me.wfCrtnTo.Text = "XXXXX"
    '    '
    '    'WarpField12
    '    '
    '    Me.WarpField12.DecimalPointPosition = CType(0, Short)
    '    Me.WarpField12.Font = New System.Drawing.Font("lr SVbN", 33.5!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel)
    '    Me.WarpField12.Format = ""
    '    Me.WarpField12.Length = CType(1, Short)
    '    Me.WarpField12.Location = New System.Drawing.Point(108, 156)
    '    Me.WarpField12.MacroBcr = ""
    '    Me.WarpField12.MacroIn = ""
    '    Me.WarpField12.MacroKey = ""
    '    Me.WarpField12.MacroOut = ""
    '    Me.WarpField12.Name = "WarpField12"
    '    Me.WarpField12.Size = New System.Drawing.Size(18, 36)
    '    Me.WarpField12.TabIndex = CType(41, Short)
    '    Me.WarpField12.Text = "-"
    '    '
    '    'wfCrtnFrom
    '    '
    '    Me.wfCrtnFrom.DecimalPointPosition = CType(0, Short)
    '    Me.wfCrtnFrom.DisplayAttribute.Bold = True
    '    Me.wfCrtnFrom.Font = New System.Drawing.Font("lr SVbN", 33.5!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Pixel)
    '    Me.wfCrtnFrom.Format = ""
    '    Me.wfCrtnFrom.InputAttribute.Bold = True
    '    Me.wfCrtnFrom.Length = CType(5, Short)
    '    Me.wfCrtnFrom.Location = New System.Drawing.Point(6, 156)
    '    Me.wfCrtnFrom.MacroBcr = ""
    '    Me.wfCrtnFrom.MacroIn = ""
    '    Me.wfCrtnFrom.MacroKey = ""
    '    Me.wfCrtnFrom.MacroOut = ""
    '    Me.wfCrtnFrom.Name = "wfCrtnFrom"
    '    Me.wfCrtnFrom.Size = New System.Drawing.Size(90, 36)
    '    Me.wfCrtnFrom.TabIndex = CType(40, Short)
    '    Me.wfCrtnFrom.Text = "XXXXX"
    '    '
    '    '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(20, Short)
    '    Me.WarpField10.Location = New System.Drawing.Point(7, 136)
    '    Me.WarpField10.MacroBcr = ""
    '    Me.WarpField10.MacroIn = ""
    '    Me.WarpField10.MacroKey = ""
    '    Me.WarpField10.MacroOut = ""
    '    Me.WarpField10.Name = "WarpField10"
    '    Me.WarpField10.Size = New System.Drawing.Size(180, 18)
    '    Me.WarpField10.TabIndex = CType(39, Short)
    '    Me.WarpField10.Text = "CartonNo   from   To"
    '    '
    '    'wfCsNo3
    '    '
    '    Me.wfCsNo3.DecimalPointPosition = CType(0, Short)
    '    Me.wfCsNo3.Font = New System.Drawing.Font("lr SVbN", 22.5!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel)
    '    Me.wfCsNo3.FontSize = WarpControl.FontSizes.Small2
    '    Me.wfCsNo3.Format = ""
    '    Me.wfCsNo3.Length = CType(2, Short)
    '    Me.wfCsNo3.Location = New System.Drawing.Point(100, 103)
    '    Me.wfCsNo3.MacroBcr = ""
    '    Me.wfCsNo3.MacroIn = ""
    '    Me.wfCsNo3.MacroKey = ""
    '    Me.wfCsNo3.MacroOut = ""
    '    Me.wfCsNo3.Name = "wfCsNo3"
    '    Me.wfCsNo3.Size = New System.Drawing.Size(24, 24)
    '    Me.wfCsNo3.TabIndex = CType(38, Short)
    '    Me.wfCsNo3.Text = "99"
    '    '
    '    'WarpField11
    '    '
    '    Me.WarpField11.DecimalPointPosition = CType(0, Short)
    '    Me.WarpField11.Font = New System.Drawing.Font("lr SVbN", 22.5!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel)
    '    Me.WarpField11.FontSize = WarpControl.FontSizes.Small2
    '    Me.WarpField11.Format = ""
    '    Me.WarpField11.Length = CType(1, Short)
    '    Me.WarpField11.Location = New System.Drawing.Point(87, 103)
    '    Me.WarpField11.MacroBcr = ""
    '    Me.WarpField11.MacroIn = ""
    '    Me.WarpField11.MacroKey = ""
    '    Me.WarpField11.MacroOut = ""
    '    Me.WarpField11.Name = "WarpField11"
    '    Me.WarpField11.Size = New System.Drawing.Size(12, 24)
    '    Me.WarpField11.TabIndex = CType(37, Short)
    '    Me.WarpField11.Text = "-"
    '    '
    '    'wfCsNo2
    '    '
    '    Me.wfCsNo2.DecimalPointPosition = CType(0, Short)
    '    Me.wfCsNo2.Font = New System.Drawing.Font("lr SVbN", 22.5!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel)
    '    Me.wfCsNo2.FontSize = WarpControl.FontSizes.Small2
    '    Me.wfCsNo2.Format = ""
    '    Me.wfCsNo2.Length = CType(2, Short)
    '    Me.wfCsNo2.Location = New System.Drawing.Point(61, 103)
    '    Me.wfCsNo2.MacroBcr = ""
    '    Me.wfCsNo2.MacroIn = ""
    '    Me.wfCsNo2.MacroKey = ""
    '    Me.wfCsNo2.MacroOut = ""
    '    Me.wfCsNo2.Name = "wfCsNo2"
    '    Me.wfCsNo2.Size = New System.Drawing.Size(24, 24)
    '    Me.wfCsNo2.TabIndex = CType(36, Short)
    '    Me.wfCsNo2.Text = "XX"
    '    '
    '    'WarpField4
    '    '
    '    Me.WarpField4.DecimalPointPosition = CType(0, Short)
    '    Me.WarpField4.Font = New System.Drawing.Font("lr SVbN", 22.5!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel)
    '    Me.WarpField4.FontSize = WarpControl.FontSizes.Small2
    '    Me.WarpField4.Format = ""
    '    Me.WarpField4.Length = CType(1, Short)
    '    Me.WarpField4.Location = New System.Drawing.Point(49, 103)
    '    Me.WarpField4.MacroBcr = ""
    '    Me.WarpField4.MacroIn = ""
    '    Me.WarpField4.MacroKey = ""
    '    Me.WarpField4.MacroOut = ""
    '    Me.WarpField4.Name = "WarpField4"
    '    Me.WarpField4.Size = New System.Drawing.Size(12, 24)
    '    Me.WarpField4.TabIndex = CType(35, Short)
    '    Me.WarpField4.Text = "-"
    '    '
    '    'wfCsNo1
    '    '
    '    Me.wfCsNo1.DecimalPointPosition = CType(0, Short)
    '    Me.wfCsNo1.Font = New System.Drawing.Font("lr SVbN", 22.5!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel)
    '    Me.wfCsNo1.FontSize = WarpControl.FontSizes.Small2
    '    Me.wfCsNo1.Format = ""
    '    Me.wfCsNo1.Length = CType(3, Short)
    '    Me.wfCsNo1.Location = New System.Drawing.Point(13, 103)
    '    Me.wfCsNo1.MacroBcr = ""
    '    Me.wfCsNo1.MacroIn = ""
    '    Me.wfCsNo1.MacroKey = ""
    '    Me.wfCsNo1.MacroOut = ""
    '    Me.wfCsNo1.Name = "wfCsNo1"
    '    Me.wfCsNo1.Size = New System.Drawing.Size(36, 24)
    '    Me.wfCsNo1.TabIndex = CType(34, Short)
    '    Me.wfCsNo1.Text = "999"
    '    '
    '    '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(7, Short)
    '    Me.WarpField8.Location = New System.Drawing.Point(13, 84)
    '    Me.WarpField8.MacroBcr = ""
    '    Me.WarpField8.MacroIn = ""
    '    Me.WarpField8.MacroKey = ""
    '    Me.WarpField8.MacroOut = ""
    '    Me.WarpField8.Name = "WarpField8"
    '    Me.WarpField8.Size = New System.Drawing.Size(63, 18)
    '    Me.WarpField8.TabIndex = CType(33, Short)
    '    Me.WarpField8.Text = "Case-No"
    '    '
    '    'wfTRM
    '    '
    '    Me.wfTRM.DecimalPointPosition = CType(0, Short)
    '    Me.wfTRM.Font = New System.Drawing.Font("lr SVbN", 22.5!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel)
    '    Me.wfTRM.FontSize = WarpControl.FontSizes.Small2
    '    Me.wfTRM.Format = ""
    '    Me.wfTRM.Length = CType(3, Short)
    '    Me.wfTRM.Location = New System.Drawing.Point(195, 61)
    '    Me.wfTRM.MacroBcr = ""
    '    Me.wfTRM.MacroIn = ""
    '    Me.wfTRM.MacroKey = ""
    '    Me.wfTRM.MacroOut = ""
    '    Me.wfTRM.Name = "wfTRM"
    '    Me.wfTRM.Size = New System.Drawing.Size(36, 24)
    '    Me.wfTRM.TabIndex = CType(30, Short)
    '    Me.wfTRM.Text = "XXX"
    '    '
    '    'WarpField3
    '    '
    '    Me.WarpField3.DecimalPointPosition = CType(0, Short)
    '    Me.WarpField3.Font = New System.Drawing.Font("lr SVbN", 16.5!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel)
    '    Me.WarpField3.FontSize = WarpControl.FontSizes.Small4
    '    Me.WarpField3.Format = ""
    '    Me.WarpField3.Length = CType(3, Short)
    '    Me.WarpField3.Location = New System.Drawing.Point(192, 42)
    '    Me.WarpField3.MacroBcr = ""
    '    Me.WarpField3.MacroIn = ""
    '    Me.WarpField3.MacroKey = ""
    '    Me.WarpField3.MacroOut = ""
    '    Me.WarpField3.Name = "WarpField3"
    '    Me.WarpField3.Size = New System.Drawing.Size(27, 18)
    '    Me.WarpField3.TabIndex = CType(29, Short)
    '    Me.WarpField3.Text = "TRM"
    '    '
    '    'wfMsc2
    '    '
    '    Me.wfMsc2.DecimalPointPosition = CType(0, Short)
    '    Me.wfMsc2.Font = New System.Drawing.Font("lr SVbN", 22.5!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel)
    '    Me.wfMsc2.FontSize = WarpControl.FontSizes.Small2
    '    Me.wfMsc2.Format = ""
    '    Me.wfMsc2.Length = CType(3, Short)
    '    Me.wfMsc2.Location = New System.Drawing.Point(94, 61)
    '    Me.wfMsc2.MacroBcr = ""
    '    Me.wfMsc2.MacroIn = ""
    '    Me.wfMsc2.MacroKey = ""
    '    Me.wfMsc2.MacroOut = ""
    '    Me.wfMsc2.Name = "wfMsc2"
    '    Me.wfMsc2.Size = New System.Drawing.Size(36, 24)
    '    Me.wfMsc2.TabIndex = CType(28, Short)
    '    Me.wfMsc2.Text = "XXX"
    '    '
    '    'WarpField9
    '    '
    '    Me.WarpField9.DecimalPointPosition = CType(0, Short)
    '    Me.WarpField9.Font = New System.Drawing.Font("lr SVbN", 16.5!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel)
    '    Me.WarpField9.FontSize = WarpControl.FontSizes.Small4
    '    Me.WarpField9.Format = ""
    '    Me.WarpField9.Length = CType(3, Short)
    '    Me.WarpField9.Location = New System.Drawing.Point(130, 42)
    '    Me.WarpField9.MacroBcr = ""
    '    Me.WarpField9.MacroIn = ""
    '    Me.WarpField9.MacroKey = ""
    '    Me.WarpField9.MacroOut = ""
    '    Me.WarpField9.Name = "WarpField9"
    '    Me.WarpField9.Size = New System.Drawing.Size(27, 18)
    '    Me.WarpField9.TabIndex = CType(27, Short)
    '    Me.WarpField9.Text = "PNT"
    '    '
    '    'wfPNT
    '    '
    '    Me.wfPNT.DecimalPointPosition = CType(0, Short)
    '    Me.wfPNT.Font = New System.Drawing.Font("lr SVbN", 22.5!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel)
    '    Me.wfPNT.FontSize = WarpControl.FontSizes.Small2
    '    Me.wfPNT.Format = ""
    '    Me.wfPNT.Length = CType(3, Short)
    '    Me.wfPNT.Location = New System.Drawing.Point(142, 61)
    '    Me.wfPNT.MacroBcr = ""
    '    Me.wfPNT.MacroIn = ""
    '    Me.wfPNT.MacroKey = ""
    '    Me.wfPNT.MacroOut = ""
    '    Me.wfPNT.Name = "wfPNT"
    '    Me.wfPNT.Size = New System.Drawing.Size(36, 24)
    '    Me.wfPNT.TabIndex = CType(26, Short)
    '    Me.wfPNT.Text = "XXX"
    '    '
    '    'WarpField7
    '    '
    '    Me.WarpField7.DecimalPointPosition = CType(0, Short)
    '    Me.WarpField7.Font = New System.Drawing.Font("lr SVbN", 22.5!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel)
    '    Me.WarpField7.FontSize = WarpControl.FontSizes.Small2
    '    Me.WarpField7.Format = ""
    '    Me.WarpField7.Length = CType(1, Short)
    '    Me.WarpField7.Location = New System.Drawing.Point(70, 61)
    '    Me.WarpField7.MacroBcr = ""
    '    Me.WarpField7.MacroIn = ""
    '    Me.WarpField7.MacroKey = ""
    '    Me.WarpField7.MacroOut = ""
    '    Me.WarpField7.Name = "WarpField7"
    '    Me.WarpField7.Size = New System.Drawing.Size(12, 24)
    '    Me.WarpField7.TabIndex = CType(25, Short)
    '    Me.WarpField7.Text = "-"
    '    '
    '    'wfMsc1
    '    '
    '    Me.wfMsc1.DecimalPointPosition = CType(0, Short)
    '    Me.wfMsc1.Font = New System.Drawing.Font("lr SVbN", 22.5!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel)
    '    Me.wfMsc1.FontSize = WarpControl.FontSizes.Small2
    '    Me.wfMsc1.Format = ""
    '    Me.wfMsc1.Length = CType(4, Short)
    '    Me.wfMsc1.Location = New System.Drawing.Point(22, 61)
    '    Me.wfMsc1.MacroBcr = ""
    '    Me.wfMsc1.MacroIn = ""
    '    Me.wfMsc1.MacroKey = ""
    '    Me.wfMsc1.MacroOut = ""
    '    Me.wfMsc1.Name = "wfMsc1"
    '    Me.wfMsc1.Size = New System.Drawing.Size(48, 24)
    '    Me.wfMsc1.TabIndex = CType(24, Short)
    '    Me.wfMsc1.Text = "XXXX"
    '    '
    '    '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(10, 42)
    '    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(23, Short)
    '    Me.WarpField5.Text = "MSC"
    '    '
    '    '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:\081-0030.jpg"
    '    Me.WarpBox1.Location = New System.Drawing.Point(0, 208)
    '    Me.WarpBox1.Name = "WarpBox1"
    '    Me.WarpBox1.Size = New System.Drawing.Size(240, 25)
    '    Me.WarpBox1.TabIndex = 9
    '    '
    '    'WarpField1
    '    '
    '    Me.WarpField1.DecimalPointPosition = CType(0, Short)
    '    Me.WarpField1.Font = New System.Drawing.Font("lr SVbN", 28.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel)
    '    Me.WarpField1.FontSize = WarpControl.FontSizes.Small
    '    Me.WarpField1.Format = ""
    '    Me.WarpField1.Length = CType(8, Short)
    '    Me.WarpField1.Location = New System.Drawing.Point(12, 6)
    '    Me.WarpField1.MacroBcr = ""
    '    Me.WarpField1.MacroIn = ""
    '    Me.WarpField1.MacroKey = ""
    '    Me.WarpField1.MacroOut = ""
    '    Me.WarpField1.Name = "WarpField1"
    '    Me.WarpField1.Size = New System.Drawing.Size(120, 30)
    '    Me.WarpField1.TabIndex = CType(8, Short)
    '    Me.WarpField1.Text = "Tag Scan"
    '    '
    '    'wfScn
    '    '
    '    Me.wfScn.DecimalPointPosition = CType(0, Short)
    '    Me.wfScn.Font = New System.Drawing.Font("lr SVbN", 33.5!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel)
    '    Me.wfScn.Format = ""
    '    Me.wfScn.InputMode.NumericOnly = True
    '    Me.wfScn.InputMode.Right = True
    '    Me.wfScn.Length = CType(2, Short)
    '    Me.wfScn.Location = New System.Drawing.Point(156, 4)
    '    Me.wfScn.MacroBcr = ""
    '    Me.wfScn.MacroIn = ""
    '    Me.wfScn.MacroKey = ""
    '    Me.wfScn.MacroOut = ""
    '    Me.wfScn.Name = "wfScn"
    '    Me.wfScn.Size = New System.Drawing.Size(36, 36)
    '    Me.wfScn.TabIndex = CType(7, Short)
    '    Me.wfScn.Text = "99"
    '    '
    '    '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.Format = ""
    '    Me.wfKey.InputMode.Secret = True
    '    Me.wfKey.Length = CType(1, Short)
    '    Me.wfKey.Location = New System.Drawing.Point(204, 103)
    '    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(6, Short)
    '    '
    '    '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, 234)
    '    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)
    '    '
    '    'WarpHWBcr1
    '    '
    '    Me.WarpHWBcr1.CheckCode.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)
    '    '
    '    'frm2055
    '    '
    '    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 = "frm2055"
    '    Me.Text = "Form1"
    '    Me.WarpFrame1.ResumeLayout(False)
    '    Me.ResumeLayout(False)

    'End Sub

#End Region


    Public Enum M2055_STATUS As Integer
        INIT = 0
        MENUBACK = 1
        NOTCD = 2
        DONE = 3
        DBLSCN = 4
        ALLOK = 5
    End Enum

    Public mint2055status As Integer

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


    Private Sub frm2055_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

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

#If Not Debug Then
            'sSetImgFName(G_CONST_MID_H2055, WarpBox1)
#Else
            'WarpBox1.Text = "J[g“x๐XL“"
#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 = PP_STATUS.QUIT
            sErrLog(gAppName, "frm2055_Load", ex.ToString)
            Me.Close()
        End Try

    End Sub
    '/*
    '|| ึ”–ผFsDisp2055
    '|| T—v  F2055ๆ–ส•\ฆ
    '*/
    Private Sub sDisp2055()
        wfScn.Text = gstrctChkItemCode.intCount
        With gstrctPPDisp
            wfMsc1.Text = Mid(.strMsc, 1, 4)
            wfMsc2.Text = Mid(.strMsc, 5)
            wfPNT.Text = .strPNT
            wfTRM.Text = .strTRM
            wfCsNo1.Text = Mid(.strCaseNo, 1, 3)
            wfCsNo2.Text = Mid(.strCaseNo, 4, 2)
            wfCsNo3.Text = Mid(.strCaseNo, 6)
            wfCrtnFrom.Text = .strCrtnFrom
            wfCrtnTo.Text = .strCrtnTo
        End With

        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
#If Not Debug Then
            sBeepSound(modPublicHT.BEEP_TYPE.A, modPublicHT.BEEP_SELECTION.NG)
            fFnc_WrpMsg("E", G_CONST_MID_E2E85)
#End If
            Exit Sub
        End If

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

        If rtn = 0 Then
            Select Case mint2055status
                Case M2055_STATUS.INIT

                Case M2055_STATUS.NOTCD              'ูศ้o[R[h
                    sBeepSound(modPublicHT.BEEP_TYPE.A, modPublicHT.BEEP_SELECTION.NG)
                    sOutputLog(gstrctPicsIni.strOutput_KDPP, "KDPP2E86", G_CONST_BC_CRTN, buf)
#If Not Debug Then
                    fFnc_WrpMsg("E", G_CONST_MID_E2E86)
#End If
                    Exit Sub
                Case M2055_STATUS.DBLSCN            '_uXL“
                    sBeepSound(modPublicHT.BEEP_TYPE.A, modPublicHT.BEEP_SELECTION.NG)
#If Not Debug Then
                    fFnc_WrpMsg("E", G_CONST_MID_E2E35)
#End If
                    Exit Sub
                Case M2055_STATUS.DONE

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

                    gintStatus = PP_STATUS.CISCAN
                    Me.Close()
                    Exit Sub
                Case M2055_STATUS.ALLOK
                    rtn = fClearSKey()
                    If rtn <> 0 Then
                        '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

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

                    gintStatus = PP_STATUS.ENTKEY
                    Me.Close()
                    Exit Sub
            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


        '                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
        '#If Not Debug Then
        '                        sBeepSound(modPublicHT.BEEP_TYPE.A, modPublicHT.BEEP_SELECTION.NG)
        '                        fFnc_WrpMsg("E", G_CONST_MID_E2E85)
        '#End If
        '                        Exit Do
        '                    End If

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

        '                    If rtn = 0 Then
        '                        Select Case mint2055status
        '                            Case M2055_STATUS.INIT

        '                            Case M2055_STATUS.NOTCD              'ูศ้o[R[h
        '                                sBeepSound(modPublicHT.BEEP_TYPE.A, modPublicHT.BEEP_SELECTION.NG)
        '                                sOutputLog(gstrctPicsIni.strOutput_KDPP, "KDPP2E86", G_CONST_BC_CRTN, buf)
        '#If Not Debug Then
        '                                fFnc_WrpMsg("E", G_CONST_MID_E2E86)
        '#End If
        '                            Case M2055_STATUS.DBLSCN            '_uXL“
        '                                sBeepSound(modPublicHT.BEEP_TYPE.A, modPublicHT.BEEP_SELECTION.NG)
        '#If Not Debug Then
        '                                fFnc_WrpMsg("E", G_CONST_MID_E2E35)
        '#End If
        '                            Case M2055_STATUS.DONE
        '                                gintStatus = PP_STATUS.CISCAN
        '                                Exit Do
        '                            Case M2055_STATUS.ALLOK
        '                                rtn = fClearSKey()
        '                                If rtn <> 0 Then
        '                                    '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
        '                                gintStatus = PP_STATUS.ENTKEY
        '                                Exit Do
        '                        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

        '                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
        Dim ret As Integer
        fProcInput = -1

        Try
            If pstrInput.StartsWith("C") OrElse pstrInput.StartsWith("I") OrElse _
               pstrInput.StartsWith("B") OrElse pstrInput.StartsWith("N") Then  'J[g“x or xแx
                ret = fChkCountDown(Mid(pstrInput, 2, 25))
                If ret = -1 Then
                    mint2055status = M2055_STATUS.NOTCD
                ElseIf ret = -2 Then
                    mint2055status = M2055_STATUS.DBLSCN
                ElseIf ret = 0 Then
                    If gstrctChkItemCode.intCount = 0 Then
                        mint2055status = M2055_STATUS.ALLOK
                    Else
                        mint2055status = M2055_STATUS.DONE
                    End If
                End If
            Else
                mint2055status = M2055_STATUS.NOTCD
            End If

            fProcInput = 0

        Catch ex As Exception
            sErrLog(gAppName, "fProcInput", ex.ToString)
        End Try
    End Function
    '/*
    '|| ึ”–ผFfChkCountUp
    '|| T—v  F”ธ
    '|| ๘”@FItemCode
    '|| –฿่’lF-1(NG), 0(OK), -2(ภฬูฝทฌ)
    '*/
    Private Function fChkCountDown(ByVal pstrItemCode As String) As Integer
        Dim i As Integer
        fChkCountDown = -1
        Try

            For i = 0 To UBound(gstrctChkItemCode.arryOfChkItemCode)

                With gstrctChkItemCode.arryOfChkItemCode(i)
                    If (pstrItemCode = .strItemCode) Then
                        If .bScanned Then
                            fChkCountDown = -2
                            Exit Function
                        Else
                            .bScanned = True
                            gstrctChkItemCode.intCount -= 1
                            fChkCountDown = 0
                            Exit Function
                        End If
                    End If
                End With
            Next

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

    Private Sub frm2055_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
