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

Public Class frm5040
    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 wfCrtnFrom As WarpControl.WarpField
    'Friend WithEvents WarpField10 As WarpControl.WarpField
    'Friend WithEvents WarpField2 As WarpControl.WarpField
    'Friend WithEvents WarpField5 As WarpControl.WarpField
    'Friend WithEvents WarpField11 As WarpControl.WarpField
    'Friend WithEvents WarpField13 As WarpControl.WarpField
    'Friend WithEvents WarpField14 As WarpControl.WarpField
    'Friend WithEvents wfCL As WarpControl.WarpField
    'Friend WithEvents wfZ As WarpControl.WarpField
    'Friend WithEvents wfName As WarpControl.WarpField
    'Friend WithEvents wfLctn2 As WarpControl.WarpField
    'Friend WithEvents wfLctn1 As WarpControl.WarpField
    'Friend WithEvents WarpHWBcr1 As WarpControl.WarpHWBcr
    'Friend WithEvents WarpField1 As WarpControl.WarpField
    'Friend WithEvents WarpField6 As WarpControl.WarpField
    'Friend WithEvents WarpField7 As WarpControl.WarpField
    'Friend WithEvents WarpField9 As WarpControl.WarpField
    'Friend WithEvents wfKey As WarpControl.WarpField
    'Friend WithEvents wfQty1 As WarpControl.WarpField
    'Friend WithEvents wfQty2 As WarpControl.WarpField
    'Friend WithEvents wfPkg2 As WarpControl.WarpField
    'Friend WithEvents wfPkg1 As WarpControl.WarpField
    'Friend WithEvents wfInput As WarpControl.WarpField
    'Friend WithEvents wfPart As WarpControl.WarpField
    '<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
    '    Me.WarpFrame1 = New WarpControl.WarpFrame()
    '    Me.wfInput = New WarpControl.WarpField()
    '    Me.wfKey = New WarpControl.WarpField()
    '    Me.wfQty2 = New WarpControl.WarpField()
    '    Me.WarpField9 = New WarpControl.WarpField()
    '    Me.wfQty1 = New WarpControl.WarpField()
    '    Me.WarpField7 = New WarpControl.WarpField()
    '    Me.wfPkg2 = New WarpControl.WarpField()
    '    Me.WarpField6 = New WarpControl.WarpField()
    '    Me.wfPkg1 = New WarpControl.WarpField()
    '    Me.WarpField1 = New WarpControl.WarpField()
    '    Me.wfZ = New WarpControl.WarpField()
    '    Me.wfCL = New WarpControl.WarpField()
    '    Me.wfPart = New WarpControl.WarpField()
    '    Me.WarpField14 = New WarpControl.WarpField()
    '    Me.WarpField13 = New WarpControl.WarpField()
    '    Me.WarpField11 = New WarpControl.WarpField()
    '    Me.wfLctn2 = New WarpControl.WarpField()
    '    Me.WarpField5 = New WarpControl.WarpField()
    '    Me.wfLctn1 = New WarpControl.WarpField()
    '    Me.WarpField2 = New WarpControl.WarpField()
    '    Me.wfCrtnFrom = New WarpControl.WarpField()
    '    Me.WarpField10 = 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.wfInput)
    '    Me.WarpFrame1.Controls.Add(Me.wfKey)
    '    Me.WarpFrame1.Controls.Add(Me.wfQty2)
    '    Me.WarpFrame1.Controls.Add(Me.WarpField9)
    '    Me.WarpFrame1.Controls.Add(Me.wfQty1)
    '    Me.WarpFrame1.Controls.Add(Me.WarpField7)
    '    Me.WarpFrame1.Controls.Add(Me.wfPkg2)
    '    Me.WarpFrame1.Controls.Add(Me.WarpField6)
    '    Me.WarpFrame1.Controls.Add(Me.wfPkg1)
    '    Me.WarpFrame1.Controls.Add(Me.WarpField1)
    '    Me.WarpFrame1.Controls.Add(Me.wfZ)
    '    Me.WarpFrame1.Controls.Add(Me.wfCL)
    '    Me.WarpFrame1.Controls.Add(Me.wfPart)
    '    Me.WarpFrame1.Controls.Add(Me.WarpField14)
    '    Me.WarpFrame1.Controls.Add(Me.WarpField13)
    '    Me.WarpFrame1.Controls.Add(Me.WarpField11)
    '    Me.WarpFrame1.Controls.Add(Me.wfLctn2)
    '    Me.WarpFrame1.Controls.Add(Me.WarpField5)
    '    Me.WarpFrame1.Controls.Add(Me.wfLctn1)
    '    Me.WarpFrame1.Controls.Add(Me.WarpField2)
    '    Me.WarpFrame1.Controls.Add(Me.wfCrtnFrom)
    '    Me.WarpFrame1.Controls.Add(Me.WarpField10)
    '    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 = ""
    '    '
    '    'wfInput
    '    '
    '    Me.wfInput.BcrFlag = True
    '    Me.wfInput.DecimalPointPosition = CType(0, Short)
    '    Me.wfInput.Font = New System.Drawing.Font("lr SVbN", 16.5!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel)
    '    Me.wfInput.FontSize = WarpControl.FontSizes.Small4
    '    Me.wfInput.Format = ""
    '    Me.wfInput.InputMode.Secret = True
    '    Me.wfInput.Length = CType(1, Short)
    '    Me.wfInput.Location = New System.Drawing.Point(63, 78)
    '    Me.wfInput.MacroBcr = ""
    '    Me.wfInput.MacroIn = ""
    '    Me.wfInput.MacroKey = ""
    '    Me.wfInput.MacroOut = ""
    '    Me.wfInput.Name = "wfInput"
    '    Me.wfInput.Size = New System.Drawing.Size(9, 18)
    '    Me.wfInput.TabIndex = CType(46, Short)
    '    '
    '    'wfKey
    '    '
    '    Me.wfKey.BcrFlag = True
    '    Me.wfKey.DecimalPointPosition = CType(0, Short)
    '    Me.wfKey.Font = New System.Drawing.Font("lr SVbN", 16.5!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel)
    '    Me.wfKey.FontSize = WarpControl.FontSizes.Small4
    '    Me.wfKey.ForeColor = CType(15, Short)
    '    Me.wfKey.Format = ""
    '    Me.wfKey.Length = CType(1, Short)
    '    Me.wfKey.Location = New System.Drawing.Point(216, 12)
    '    Me.wfKey.MacroBcr = ""
    '    Me.wfKey.MacroIn = ""
    '    Me.wfKey.MacroKey = ""
    '    Me.wfKey.MacroOut = ""
    '    Me.wfKey.Name = "wfKey"
    '    Me.wfKey.Size = New System.Drawing.Size(9, 18)
    '    Me.wfKey.TabIndex = CType(45, Short)
    '    '
    '    'wfQty2
    '    '
    '    Me.wfQty2.DecimalPointPosition = CType(0, Short)
    '    Me.wfQty2.Font = New System.Drawing.Font("lr SVbN", 22.5!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel)
    '    Me.wfQty2.FontSize = WarpControl.FontSizes.Small2
    '    Me.wfQty2.Format = ""
    '    Me.wfQty2.InputMode.NumericOnly = True
    '    Me.wfQty2.InputMode.Right = True
    '    Me.wfQty2.Length = CType(5, Short)
    '    Me.wfQty2.Location = New System.Drawing.Point(168, 75)
    '    Me.wfQty2.MacroBcr = ""
    '    Me.wfQty2.MacroIn = ""
    '    Me.wfQty2.MacroKey = ""
    '    Me.wfQty2.MacroOut = ""
    '    Me.wfQty2.Name = "wfQty2"
    '    Me.wfQty2.Size = New System.Drawing.Size(60, 24)
    '    Me.wfQty2.TabIndex = CType(44, Short)
    '    Me.wfQty2.Text = "9"
    '    '
    '    'WarpField9
    '    '
    '    Me.WarpField9.DecimalPointPosition = CType(0, Short)
    '    Me.WarpField9.Font = New System.Drawing.Font("lr SVbN", 22.5!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel)
    '    Me.WarpField9.FontSize = WarpControl.FontSizes.Small2
    '    Me.WarpField9.Format = ""
    '    Me.WarpField9.Length = CType(1, Short)
    '    Me.WarpField9.Location = New System.Drawing.Point(156, 75)
    '    Me.WarpField9.MacroBcr = ""
    '    Me.WarpField9.MacroIn = ""
    '    Me.WarpField9.MacroKey = ""
    '    Me.WarpField9.MacroOut = ""
    '    Me.WarpField9.Name = "WarpField9"
    '    Me.WarpField9.Size = New System.Drawing.Size(12, 24)
    '    Me.WarpField9.TabIndex = CType(43, Short)
    '    Me.WarpField9.Text = "/"
    '    '
    '    'wfQty1
    '    '
    '    Me.wfQty1.DecimalPointPosition = CType(0, Short)
    '    Me.wfQty1.Font = New System.Drawing.Font("lr SVbN", 22.5!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel)
    '    Me.wfQty1.FontSize = WarpControl.FontSizes.Small2
    '    Me.wfQty1.Format = ""
    '    Me.wfQty1.InputMode.NumericOnly = True
    '    Me.wfQty1.InputMode.Right = True
    '    Me.wfQty1.Length = CType(5, Short)
    '    Me.wfQty1.Location = New System.Drawing.Point(96, 75)
    '    Me.wfQty1.MacroBcr = ""
    '    Me.wfQty1.MacroIn = ""
    '    Me.wfQty1.MacroKey = ""
    '    Me.wfQty1.MacroOut = ""
    '    Me.wfQty1.Name = "wfQty1"
    '    Me.wfQty1.Size = New System.Drawing.Size(60, 24)
    '    Me.wfQty1.TabIndex = CType(42, Short)
    '    Me.wfQty1.Text = "9"
    '    '
    '    '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(3, Short)
    '    Me.WarpField7.Location = New System.Drawing.Point(3, 78)
    '    Me.WarpField7.MacroBcr = ""
    '    Me.WarpField7.MacroIn = ""
    '    Me.WarpField7.MacroKey = ""
    '    Me.WarpField7.MacroOut = ""
    '    Me.WarpField7.Name = "WarpField7"
    '    Me.WarpField7.Size = New System.Drawing.Size(27, 18)
    '    Me.WarpField7.TabIndex = CType(41, Short)
    '    Me.WarpField7.Text = "Qty"
    '    '
    '    'wfPkg2
    '    '
    '    Me.wfPkg2.DecimalPointPosition = CType(0, Short)
    '    Me.wfPkg2.Font = New System.Drawing.Font("lr SVbN", 22.5!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel)
    '    Me.wfPkg2.FontSize = WarpControl.FontSizes.Small2
    '    Me.wfPkg2.Format = ""
    '    Me.wfPkg2.InputMode.NumericOnly = True
    '    Me.wfPkg2.InputMode.Right = True
    '    Me.wfPkg2.Length = CType(3, Short)
    '    Me.wfPkg2.Location = New System.Drawing.Point(192, 165)
    '    Me.wfPkg2.MacroBcr = ""
    '    Me.wfPkg2.MacroIn = ""
    '    Me.wfPkg2.MacroKey = ""
    '    Me.wfPkg2.MacroOut = ""
    '    Me.wfPkg2.Name = "wfPkg2"
    '    Me.wfPkg2.Size = New System.Drawing.Size(36, 24)
    '    Me.wfPkg2.TabIndex = CType(40, Short)
    '    Me.wfPkg2.Text = "9"
    '    '
    '    'WarpField6
    '    '
    '    Me.WarpField6.DecimalPointPosition = CType(0, Short)
    '    Me.WarpField6.Font = New System.Drawing.Font("lr SVbN", 22.5!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel)
    '    Me.WarpField6.FontSize = WarpControl.FontSizes.Small2
    '    Me.WarpField6.Format = ""
    '    Me.WarpField6.Length = CType(1, Short)
    '    Me.WarpField6.Location = New System.Drawing.Point(180, 165)
    '    Me.WarpField6.MacroBcr = ""
    '    Me.WarpField6.MacroIn = ""
    '    Me.WarpField6.MacroKey = ""
    '    Me.WarpField6.MacroOut = ""
    '    Me.WarpField6.Name = "WarpField6"
    '    Me.WarpField6.Size = New System.Drawing.Size(12, 24)
    '    Me.WarpField6.TabIndex = CType(39, Short)
    '    Me.WarpField6.Text = "/"
    '    '
    '    'wfPkg1
    '    '
    '    Me.wfPkg1.DecimalPointPosition = CType(0, Short)
    '    Me.wfPkg1.Font = New System.Drawing.Font("lr SVbN", 22.5!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel)
    '    Me.wfPkg1.FontSize = WarpControl.FontSizes.Small2
    '    Me.wfPkg1.Format = ""
    '    Me.wfPkg1.InputMode.NumericOnly = True
    '    Me.wfPkg1.InputMode.Right = True
    '    Me.wfPkg1.Length = CType(3, Short)
    '    Me.wfPkg1.Location = New System.Drawing.Point(144, 165)
    '    Me.wfPkg1.MacroBcr = ""
    '    Me.wfPkg1.MacroIn = ""
    '    Me.wfPkg1.MacroKey = ""
    '    Me.wfPkg1.MacroOut = ""
    '    Me.wfPkg1.Name = "wfPkg1"
    '    Me.wfPkg1.Size = New System.Drawing.Size(36, 24)
    '    Me.wfPkg1.TabIndex = CType(38, Short)
    '    Me.wfPkg1.Text = "1"
    '    '
    '    '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(10, Short)
    '    Me.WarpField1.Location = New System.Drawing.Point(3, 168)
    '    Me.WarpField1.MacroBcr = ""
    '    Me.WarpField1.MacroIn = ""
    '    Me.WarpField1.MacroKey = ""
    '    Me.WarpField1.MacroOut = ""
    '    Me.WarpField1.Name = "WarpField1"
    '    Me.WarpField1.Size = New System.Drawing.Size(90, 18)
    '    Me.WarpField1.TabIndex = CType(37, Short)
    '    Me.WarpField1.Text = "#ofPackage"
    '    '
    '    'wfZ
    '    '
    '    Me.wfZ.DecimalPointPosition = CType(0, Short)
    '    Me.wfZ.Font = New System.Drawing.Font("lr SVbN", 22.5!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel)
    '    Me.wfZ.FontSize = WarpControl.FontSizes.Small2
    '    Me.wfZ.Format = ""
    '    Me.wfZ.Length = CType(1, Short)
    '    Me.wfZ.Location = New System.Drawing.Point(217, 132)
    '    Me.wfZ.MacroBcr = ""
    '    Me.wfZ.MacroIn = ""
    '    Me.wfZ.MacroKey = ""
    '    Me.wfZ.MacroOut = ""
    '    Me.wfZ.Name = "wfZ"
    '    Me.wfZ.Size = New System.Drawing.Size(12, 24)
    '    Me.wfZ.TabIndex = CType(36, Short)
    '    Me.wfZ.Text = "X"
    '    '
    '    'wfCL
    '    '
    '    Me.wfCL.DecimalPointPosition = CType(0, Short)
    '    Me.wfCL.Font = New System.Drawing.Font("lr SVbN", 22.5!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel)
    '    Me.wfCL.FontSize = WarpControl.FontSizes.Small2
    '    Me.wfCL.Format = ""
    '    Me.wfCL.Length = CType(2, Short)
    '    Me.wfCL.Location = New System.Drawing.Point(171, 132)
    '    Me.wfCL.MacroBcr = ""
    '    Me.wfCL.MacroIn = ""
    '    Me.wfCL.MacroKey = ""
    '    Me.wfCL.MacroOut = ""
    '    Me.wfCL.Name = "wfCL"
    '    Me.wfCL.Size = New System.Drawing.Size(24, 24)
    '    Me.wfCL.TabIndex = CType(35, Short)
    '    Me.wfCL.Text = "XX"
    '    '
    '    'wfPart
    '    '
    '    Me.wfPart.DecimalPointPosition = CType(0, Short)
    '    Me.wfPart.Font = New System.Drawing.Font("lr SVbN", 22.5!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel)
    '    Me.wfPart.FontSize = WarpControl.FontSizes.Small2
    '    Me.wfPart.Format = ""
    '    Me.wfPart.Length = CType(12, Short)
    '    Me.wfPart.Location = New System.Drawing.Point(0, 132)
    '    Me.wfPart.MacroBcr = ""
    '    Me.wfPart.MacroIn = ""
    '    Me.wfPart.MacroKey = ""
    '    Me.wfPart.MacroOut = ""
    '    Me.wfPart.Name = "wfPart"
    '    Me.wfPart.Size = New System.Drawing.Size(144, 24)
    '    Me.wfPart.TabIndex = CType(30, Short)
    '    Me.wfPart.Text = "XXXX-XX-XXXX"
    '    '
    '    'WarpField14
    '    '
    '    Me.WarpField14.DecimalPointPosition = CType(0, Short)
    '    Me.WarpField14.Font = New System.Drawing.Font("lr SVbN", 16.5!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel)
    '    Me.WarpField14.FontSize = WarpControl.FontSizes.Small4
    '    Me.WarpField14.Format = ""
    '    Me.WarpField14.Length = CType(1, Short)
    '    Me.WarpField14.Location = New System.Drawing.Point(216, 108)
    '    Me.WarpField14.MacroBcr = ""
    '    Me.WarpField14.MacroIn = ""
    '    Me.WarpField14.MacroKey = ""
    '    Me.WarpField14.MacroOut = ""
    '    Me.WarpField14.Name = "WarpField14"
    '    Me.WarpField14.Size = New System.Drawing.Size(9, 18)
    '    Me.WarpField14.TabIndex = CType(29, Short)
    '    Me.WarpField14.Text = "Z"
    '    '
    '    'WarpField13
    '    '
    '    Me.WarpField13.DecimalPointPosition = CType(0, Short)
    '    Me.WarpField13.Font = New System.Drawing.Font("lr SVbN", 16.5!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel)
    '    Me.WarpField13.FontSize = WarpControl.FontSizes.Small4
    '    Me.WarpField13.Format = ""
    '    Me.WarpField13.Length = CType(2, Short)
    '    Me.WarpField13.Location = New System.Drawing.Point(168, 108)
    '    Me.WarpField13.MacroBcr = ""
    '    Me.WarpField13.MacroIn = ""
    '    Me.WarpField13.MacroKey = ""
    '    Me.WarpField13.MacroOut = ""
    '    Me.WarpField13.Name = "WarpField13"
    '    Me.WarpField13.Size = New System.Drawing.Size(18, 18)
    '    Me.WarpField13.TabIndex = CType(28, Short)
    '    Me.WarpField13.Text = "CL"
    '    '
    '    'WarpField11
    '    '
    '    Me.WarpField11.DecimalPointPosition = CType(0, Short)
    '    Me.WarpField11.Font = New System.Drawing.Font("lr SVbN", 16.5!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel)
    '    Me.WarpField11.FontSize = WarpControl.FontSizes.Small4
    '    Me.WarpField11.Format = ""
    '    Me.WarpField11.Length = CType(6, Short)
    '    Me.WarpField11.Location = New System.Drawing.Point(3, 108)
    '    Me.WarpField11.MacroBcr = ""
    '    Me.WarpField11.MacroIn = ""
    '    Me.WarpField11.MacroKey = ""
    '    Me.WarpField11.MacroOut = ""
    '    Me.WarpField11.Name = "WarpField11"
    '    Me.WarpField11.Size = New System.Drawing.Size(54, 18)
    '    Me.WarpField11.TabIndex = CType(27, Short)
    '    Me.WarpField11.Text = "PartNo"
    '    '
    '    'wfLctn2
    '    '
    '    Me.wfLctn2.DecimalPointPosition = CType(0, Short)
    '    Me.wfLctn2.Font = New System.Drawing.Font("lr SVbN", 28.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel)
    '    Me.wfLctn2.FontSize = WarpControl.FontSizes.Small
    '    Me.wfLctn2.Format = ""
    '    Me.wfLctn2.Length = CType(3, Short)
    '    Me.wfLctn2.Location = New System.Drawing.Point(183, 39)
    '    Me.wfLctn2.MacroBcr = ""
    '    Me.wfLctn2.MacroIn = ""
    '    Me.wfLctn2.MacroKey = ""
    '    Me.wfLctn2.MacroOut = ""
    '    Me.wfLctn2.Name = "wfLctn2"
    '    Me.wfLctn2.Size = New System.Drawing.Size(45, 30)
    '    Me.wfLctn2.TabIndex = CType(21, Short)
    '    Me.wfLctn2.Text = "XXX"
    '    '
    '    'WarpField5
    '    '
    '    Me.WarpField5.DecimalPointPosition = CType(0, Short)
    '    Me.WarpField5.Font = New System.Drawing.Font("lr SVbN", 28.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel)
    '    Me.WarpField5.FontSize = WarpControl.FontSizes.Small
    '    Me.WarpField5.Format = ""
    '    Me.WarpField5.Length = CType(1, Short)
    '    Me.WarpField5.Location = New System.Drawing.Point(163, 39)
    '    Me.WarpField5.MacroBcr = ""
    '    Me.WarpField5.MacroIn = ""
    '    Me.WarpField5.MacroKey = ""
    '    Me.WarpField5.MacroOut = ""
    '    Me.WarpField5.Name = "WarpField5"
    '    Me.WarpField5.Size = New System.Drawing.Size(15, 30)
    '    Me.WarpField5.TabIndex = CType(20, Short)
    '    Me.WarpField5.Text = "-"
    '    '
    '    'wfLctn1
    '    '
    '    Me.wfLctn1.DecimalPointPosition = CType(0, Short)
    '    Me.wfLctn1.Font = New System.Drawing.Font("lr SVbN", 28.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel)
    '    Me.wfLctn1.FontSize = WarpControl.FontSizes.Small
    '    Me.wfLctn1.Format = ""
    '    Me.wfLctn1.Length = CType(2, Short)
    '    Me.wfLctn1.Location = New System.Drawing.Point(129, 39)
    '    Me.wfLctn1.MacroBcr = ""
    '    Me.wfLctn1.MacroIn = ""
    '    Me.wfLctn1.MacroKey = ""
    '    Me.wfLctn1.MacroOut = ""
    '    Me.wfLctn1.Name = "wfLctn1"
    '    Me.wfLctn1.Size = New System.Drawing.Size(30, 30)
    '    Me.wfLctn1.TabIndex = CType(19, Short)
    '    Me.wfLctn1.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(8, Short)
    '    Me.WarpField2.Location = New System.Drawing.Point(3, 39)
    '    Me.WarpField2.MacroBcr = ""
    '    Me.WarpField2.MacroIn = ""
    '    Me.WarpField2.MacroKey = ""
    '    Me.WarpField2.MacroOut = ""
    '    Me.WarpField2.Name = "WarpField2"
    '    Me.WarpField2.Size = New System.Drawing.Size(72, 18)
    '    Me.WarpField2.TabIndex = CType(17, Short)
    '    Me.WarpField2.Text = "Location"
    '    '
    '    'wfCrtnFrom
    '    '
    '    Me.wfCrtnFrom.DecimalPointPosition = CType(0, Short)
    '    Me.wfCrtnFrom.Font = New System.Drawing.Font("lr SVbN", 28.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel)
    '    Me.wfCrtnFrom.FontSize = WarpControl.FontSizes.Small
    '    Me.wfCrtnFrom.Format = ""
    '    Me.wfCrtnFrom.Length = CType(5, Short)
    '    Me.wfCrtnFrom.Location = New System.Drawing.Point(129, 0)
    '    Me.wfCrtnFrom.MacroBcr = ""
    '    Me.wfCrtnFrom.MacroIn = ""
    '    Me.wfCrtnFrom.MacroKey = ""
    '    Me.wfCrtnFrom.MacroOut = ""
    '    Me.wfCrtnFrom.Name = "wfCrtnFrom"
    '    Me.wfCrtnFrom.Size = New System.Drawing.Size(75, 30)
    '    Me.wfCrtnFrom.TabIndex = CType(14, 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(8, Short)
    '    Me.WarpField10.Location = New System.Drawing.Point(3, 0)
    '    Me.WarpField10.MacroBcr = ""
    '    Me.WarpField10.MacroIn = ""
    '    Me.WarpField10.MacroKey = ""
    '    Me.WarpField10.MacroOut = ""
    '    Me.WarpField10.Name = "WarpField10"
    '    Me.WarpField10.Size = New System.Drawing.Size(72, 18)
    '    Me.WarpField10.TabIndex = CType(13, Short)
    '    Me.WarpField10.Text = "CartonNo"
    '    '
    '    '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(1, 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:\081-0030.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
    '    '
    '    '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)
    '    '
    '    'frm5040
    '    '
    '    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 = "frm5040"
    '    Me.Text = "Form1"
    '    Me.WarpFrame1.ResumeLayout(False)
    '    Me.ResumeLayout(False)

    'End Sub

#End Region

    Public Enum M5040_STATUS As Integer
        INIT = 0
        MENUBACK = 1
        NOTCD = 2
        NOTEXIST = 3
        DSCAN = 4
        DONE = 5
        RETRY = 6
    End Enum

    Public mint5040status As Integer

    Private Sub frm5040_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 = TR_STATUS.QUIT
                Me.Close()
                Exit Sub
        End Select
    End Sub

    Private Sub frm5040_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
            mint5040status = M5040_STATUS.INIT

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

#If Not Debug Then
            'sSetImgFName(G_CONST_MID_H5040, WarpBox1)
#End If
            sDisp5040()
            ' 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 = TR_STATUS.QUIT
            sErrLog(gAppName, "frm5040_Load", ex.ToString)
            Me.Close()
            Exit Sub
        End Try

    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_E5E25)
#End If
        End If

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

        If rtn = 0 Then
            Select Case mint5040status
                Case M5040_STATUS.INIT


                Case M5040_STATUS.MENUBACK


                Case M5040_STATUS.NOTCD               '
                    sBeepSound(modPublicHT.BEEP_TYPE.A, modPublicHT.BEEP_SELECTION.NG)
                    sOutputLog(gstrctPicsIni.strOutput_KDPP, "KDPP5E25", G_CONST_BC_PART, buf)
#If Not Debug Then
                    fFnc_WrpMsg("E", G_CONST_MID_E5E25)
#End If
                    Exit Sub
                Case M5040_STATUS.NOTEXIST           '
                    sBeepSound(modPublicHT.BEEP_TYPE.A, modPublicHT.BEEP_SELECTION.NG)
                    sOutputLog(gstrctPicsIni.strOutput_KDPP, "KDPP5E30", G_CONST_BC_PART, buf)
#If Not Debug Then
                    fFnc_WrpMsg("E", G_CONST_MID_E5E30)
#End If
                    Exit Sub
                Case M5040_STATUS.DSCAN           '
                    sBeepSound(modPublicHT.BEEP_TYPE.A, modPublicHT.BEEP_SELECTION.NG)
                    sOutputLog(gstrctPicsIni.strOutput_KDPP, "KDPP5E35", G_CONST_BC_PART, buf)
#If Not Debug Then
                    fFnc_WrpMsg("E", G_CONST_MID_E5E35)
#End If
                    Exit Sub
                Case M5040_STATUS.DONE
                    RemoveHandler btScanLib.OnScan, AddressOf btScanLib_OnScan
                    btScanLib.Disable()
                    gintStatus = TR_STATUS.RETRY2
                    Me.Close()
                    Exit Sub


                Case M5040_STATUS.RETRY
                    RemoveHandler btScanLib.OnScan, AddressOf btScanLib_OnScan
                    btScanLib.Disable()
                    gintStatus = TR_STATUS.RETRY3
                    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(wfInput)

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

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

        '                    If rtn = 0 Then
        '                        Select Case mint5040status
        '                            Case M5040_STATUS.INIT


        '                            Case M5040_STATUS.MENUBACK


        '                            Case M5040_STATUS.NOTCD               '
        '                                sBeepSound(modPublicHT.BEEP_TYPE.A, modPublicHT.BEEP_SELECTION.NG)
        '                                sOutputLog(gstrctPicsIni.strOutput_KDPP, "KDPP5E25", G_CONST_BC_PART, buf)
        '#If Not Debug Then
        '                                fFnc_WrpMsg("E", G_CONST_MID_E5E25)
        '#End If
        '                            Case M5040_STATUS.NOTEXIST           '
        '                                sBeepSound(modPublicHT.BEEP_TYPE.A, modPublicHT.BEEP_SELECTION.NG)
        '                                sOutputLog(gstrctPicsIni.strOutput_KDPP, "KDPP5E30", G_CONST_BC_PART, buf)
        '#If Not Debug Then
        '                                fFnc_WrpMsg("E", G_CONST_MID_E5E30)
        '#End If
        '                            Case M5040_STATUS.DSCAN           '
        '                                sBeepSound(modPublicHT.BEEP_TYPE.A, modPublicHT.BEEP_SELECTION.NG)
        '                                sOutputLog(gstrctPicsIni.strOutput_KDPP, "KDPP5E35", G_CONST_BC_PART, buf)
        '#If Not Debug Then
        '                                fFnc_WrpMsg("E", G_CONST_MID_E5E35)
        '#End If
        '                            Case M5040_STATUS.DONE

        '                                gintStatus = TR_STATUS.RETRY2
        '                                Exit Do

        '                            Case M5040_STATUS.RETRY

        '                                gintStatus = TR_STATUS.RETRY3
        '                                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
        '                    Exit Do

        '                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
        '            'gintStatus = TR_STATUS.QUIT
        '            sErrLog(gAppName, "sMain", ex.ToString)
        '        End Try

    End Sub

    '/*
    '|| ึ”–ผFsDisp5040
    '|| T—v  F5040ๆ–ส•\ฆ
    '*/
    Private Sub sDisp5040()


        With gstrctPPDisp
            'wfCrtnFrom.Puts(.strCrtnFrom)
            'wfCrtnTo.Puts(.strCrtnTo)
        End With

        If gstrctPPDispPart.bDisp Then

            With gstrctPPDispPart
                wfLctn1.Text = .strLocation1
                wfLctn2.Text = .strLocation2
                wfQty1.Text = gstrctPPDisp.fGetQty(.strItemInCode, 1)
                wfQty2.Text = gstrctPPDisp.fGetQty(.strItemInCode)
                wfPart.Text = .strPartNoDisp
                wfCL.Text = .strCL
                wfZ.Text = .strZ
                wfPkg1.Text = gstrctPPDisp.fGetPkg(.strItemInCode, 1)
                wfPkg2.Text = gstrctPPDisp.fGetPkg(.strItemInCode)
            End With

        Else
            wfLctn1.Text = " "
            wfLctn2.Text = " "
            wfQty1.Text = " "
            wfQty2.Text = " "
            wfPart.Text = " "
            wfCL.Text = " "
            wfZ.Text = " "
            wfPkg1.Text = " "
            wfPkg2.Text = " "
            gstrctPPDispPart.bDisp = True

        End If

        wfCrtnNo.Text = gstrctPPDisp.strCrtnNo
        wfName.Text = gstrctKDHT.strUserName

    End Sub

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

        Dim rtn As Integer
        Dim wintCnt As Integer

        Dim tmp As String

        fProcInput = -1

        Try

            If RTrim(pstrInput) = "OCMENUBACK" Then             'OCMENUBACKศ็ฮ

                mint5040status = M5040_STATUS.NOTCD
                fProcInput = 0
                Exit Function

            ElseIf pstrInput.StartsWith("P") Then        'ๆ“ชชPศ็ฮ

                If pstrInput.Length = G_CONST_LLEN_PRT1 Or pstrInput.Length = G_CONST_LLEN_PRT2 Then '•”•io[R[h

                Else '…”แข(KDPP5E25)
                    gstrctPPDispPart.bDisp = False
                    mint5040status = M5040_STATUS.NOTCD
                    fProcInput = 0
                    Exit Function
                End If

            Else

                gstrctPPDispPart.bDisp = False
                mint5040status = M5040_STATUS.NOTCD
                fProcInput = 0
                Exit Function

            End If
            '•\ฆ—p•”•iR[hฉ็“เ•”R[hึ•ฯท
            tmp = Mid(pstrInput, 1, 1) & fBackDispItem(Mid(pstrInput, 2, 10), True) & Mid(pstrInput, 12)
            rtn = fProcData4SRetry(tmp, wintCnt)

            'rtn = fProcData4SRetry(pstrInput, wintCnt)
            If rtn = -1 Then
                Exit Function
            ElseIf rtn = -2 Then
                gstrctPPDispPart.bDisp = False
                mint5040status = M5040_STATUS.NOTEXIST
                fProcInput = 0
                Exit Function
            ElseIf rtn = -3 Then
                mint5040status = M5040_STATUS.DSCAN
                fProcInput = 0
                Exit Function
            End If

            gstrctPPDisp.intNumOfScanned = wintCnt

            'c”ช5ศบษศมฝ็A‘SR[h•\ฆ
            If gstrctPPDisp.intNumOfPkg - gstrctPPDisp.intNumOfScanned < 6 Then
                rtn = fProcData4SRetry2("NOUPDATE", wintCnt)
                If rtn = -1 Then
                    Exit Function
                End If
                mint5040status = M5040_STATUS.RETRY
            Else
                mint5040status = M5040_STATUS.DONE
            End If

            fProcInput = 0
            Exit Function

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

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


