﻿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 BTClientLib
Imports System.IO
Imports System.Reflection
Imports Newtonsoft
Imports Microsoft.WindowsCE.Forms

Public Class frm1040
    Inherits System.Windows.Forms.Form
    '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 wfKey As WarpControl.WarpField
    'Friend WithEvents wfLine As WarpControl.WarpField
    'Friend WithEvents wfSeq As WarpControl.WarpField
    'Friend WithEvents wfSerial4 As WarpControl.WarpField
    'Friend WithEvents wfSerial5 As WarpControl.WarpField
    'Friend WithEvents wfSerial2 As WarpControl.WarpField
    'Friend WithEvents wfSerial3 As WarpControl.WarpField
    'Friend WithEvents wfPartNo5 As WarpControl.WarpField
    'Friend WithEvents wfPartNo4 As WarpControl.WarpField
    'Friend WithEvents wfPartNo3 As WarpControl.WarpField
    'Friend WithEvents wfPartNo2 As WarpControl.WarpField
    'Friend WithEvents wfNo5 As WarpControl.WarpField
    'Friend WithEvents wfNo4 As WarpControl.WarpField
    'Friend WithEvents wfNo3 As WarpControl.WarpField
    'Friend WithEvents wfNo2 As WarpControl.WarpField
    'Friend WithEvents wfNo1 As WarpControl.WarpField
    'Friend WithEvents wfSerial1 As WarpControl.WarpField
    'Friend WithEvents wfPartNo1 As WarpControl.WarpField
    'Friend WithEvents WarpHWBcr1 As WarpControl.WarpHWBcr
    'Friend WithEvents WarpField2 As WarpControl.WarpField
    'Friend WithEvents wfTotal2 As WarpControl.WarpField
    'Friend WithEvents WarpField1 As WarpControl.WarpField
    'Friend WithEvents WarpField3 As WarpControl.WarpField
    'Friend WithEvents WarpField4 As WarpControl.WarpField
    'Friend WithEvents wfCrntPG As WarpControl.WarpField
    'Friend WithEvents WarpField5 As WarpControl.WarpField
    'Friend WithEvents wfTotalPG As WarpControl.WarpField
    '<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
    '    Me.WarpFrame1 = New WarpControl.WarpFrame()
    '    Me.wfTotalPG = New WarpControl.WarpField()
    '    Me.WarpField5 = New WarpControl.WarpField()
    '    Me.wfCrntPG = New WarpControl.WarpField()
    '    Me.WarpField4 = New WarpControl.WarpField()
    '    Me.WarpField3 = New WarpControl.WarpField()
    '    Me.WarpField1 = New WarpControl.WarpField()
    '    Me.wfTotal2 = New WarpControl.WarpField()
    '    Me.WarpField2 = New WarpControl.WarpField()
    '    Me.wfSerial1 = New WarpControl.WarpField()
    '    Me.wfSerial4 = New WarpControl.WarpField()
    '    Me.wfSerial5 = New WarpControl.WarpField()
    '    Me.wfSerial2 = New WarpControl.WarpField()
    '    Me.wfSerial3 = New WarpControl.WarpField()
    '    Me.wfPartNo5 = New WarpControl.WarpField()
    '    Me.wfPartNo4 = New WarpControl.WarpField()
    '    Me.wfPartNo3 = New WarpControl.WarpField()
    '    Me.wfPartNo2 = New WarpControl.WarpField()
    '    Me.wfNo5 = New WarpControl.WarpField()
    '    Me.wfNo4 = New WarpControl.WarpField()
    '    Me.wfNo3 = New WarpControl.WarpField()
    '    Me.wfNo2 = New WarpControl.WarpField()
    '    Me.wfNo1 = New WarpControl.WarpField()
    '    Me.wfSeq = New WarpControl.WarpField()
    '    Me.wfLine = New WarpControl.WarpField()
    '    Me.wfPartNo1 = New WarpControl.WarpField()
    '    Me.wfName = New WarpControl.WarpField()
    '    Me.WarpBox1 = New WarpControl.WarpBox()
    '    Me.wfKey = New WarpControl.WarpField()
    '    Me.WarpHWBcr1 = New WarpControl.WarpHWBcr()
    '    Me.WarpFrame1.SuspendLayout()
    '    Me.SuspendLayout()
    '
    'WarpFrame1
    '
    'Me.WarpFrame1.Controls.Add(Me.wfTotalPG)
    'Me.WarpFrame1.Controls.Add(Me.WarpField5)
    'Me.WarpFrame1.Controls.Add(Me.wfCrntPG)
    'Me.WarpFrame1.Controls.Add(Me.WarpField4)
    'Me.WarpFrame1.Controls.Add(Me.WarpField3)
    'Me.WarpFrame1.Controls.Add(Me.WarpField1)
    'Me.WarpFrame1.Controls.Add(Me.wfTotal2)
    'Me.WarpFrame1.Controls.Add(Me.WarpField2)
    'Me.WarpFrame1.Controls.Add(Me.wfSerial1)
    'Me.WarpFrame1.Controls.Add(Me.wfSerial4)
    'Me.WarpFrame1.Controls.Add(Me.wfSerial5)
    'Me.WarpFrame1.Controls.Add(Me.wfSerial2)
    'Me.WarpFrame1.Controls.Add(Me.wfSerial3)
    'Me.WarpFrame1.Controls.Add(Me.wfPartNo5)
    'Me.WarpFrame1.Controls.Add(Me.wfPartNo4)
    'Me.WarpFrame1.Controls.Add(Me.wfPartNo3)
    'Me.WarpFrame1.Controls.Add(Me.wfPartNo2)
    'Me.WarpFrame1.Controls.Add(Me.wfNo5)
    'Me.WarpFrame1.Controls.Add(Me.wfNo4)
    'Me.WarpFrame1.Controls.Add(Me.wfNo3)
    'Me.WarpFrame1.Controls.Add(Me.wfNo2)
    'Me.WarpFrame1.Controls.Add(Me.wfNo1)
    'Me.WarpFrame1.Controls.Add(Me.wfSeq)
    'Me.WarpFrame1.Controls.Add(Me.wfLine)
    'Me.WarpFrame1.Controls.Add(Me.wfPartNo1)
    'Me.WarpFrame1.Controls.Add(Me.wfName)
    'Me.WarpFrame1.Controls.Add(Me.WarpBox1)
    'Me.WarpFrame1.Controls.Add(Me.wfKey)
    '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 = ""
    '
    'wfTotalPG
    '
    'Me.wfTotalPG.DecimalPointPosition = CType(0, Short)
    'Me.wfTotalPG.Font = New System.Drawing.Font("lr SVbN", 22.5!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel)
    'Me.wfTotalPG.FontSize = WarpControl.FontSizes.Small2
    'Me.wfTotalPG.Format = ""
    'Me.wfTotalPG.InputMode.Right = True
    'Me.wfTotalPG.Length = CType(3, Short)
    'Me.wfTotalPG.Location = New System.Drawing.Point(199, 4)
    'Me.wfTotalPG.MacroBcr = ""
    'Me.wfTotalPG.MacroIn = ""
    'Me.wfTotalPG.MacroKey = ""
    'Me.wfTotalPG.MacroOut = ""
    'Me.wfTotalPG.Name = "wfTotalPG"
    'Me.wfTotalPG.Size = New System.Drawing.Size(36, 24)
    'Me.wfTotalPG.TabIndex = CType(93, Short)
    'Me.wfTotalPG.Text = "ZZ9"
    '
    'WarpField5
    '
    'Me.WarpField5.DecimalPointPosition = CType(0, Short)
    'Me.WarpField5.Font = New System.Drawing.Font("lr SVbN", 22.5!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel)
    'Me.WarpField5.FontSize = WarpControl.FontSizes.Small2
    'Me.WarpField5.Format = ""
    'Me.WarpField5.Length = CType(1, Short)
    'Me.WarpField5.Location = New System.Drawing.Point(180, 4)
    'Me.WarpField5.MacroBcr = ""
    'Me.WarpField5.MacroIn = ""
    'Me.WarpField5.MacroKey = ""
    'Me.WarpField5.MacroOut = ""
    'Me.WarpField5.Name = "WarpField5"
    'Me.WarpField5.Size = New System.Drawing.Size(12, 24)
    'Me.WarpField5.TabIndex = CType(92, Short)
    'Me.WarpField5.Text = "/"
    '
    'wfCrntPG
    '
    'Me.wfCrntPG.DecimalPointPosition = CType(0, Short)
    'Me.wfCrntPG.Font = New System.Drawing.Font("lr SVbN", 22.5!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel)
    'Me.wfCrntPG.FontSize = WarpControl.FontSizes.Small2
    'Me.wfCrntPG.Format = ""
    'Me.wfCrntPG.InputMode.Right = True
    'Me.wfCrntPG.Length = CType(3, Short)
    'Me.wfCrntPG.Location = New System.Drawing.Point(136, 4)
    'Me.wfCrntPG.MacroBcr = ""
    'Me.wfCrntPG.MacroIn = ""
    'Me.wfCrntPG.MacroKey = ""
    'Me.wfCrntPG.MacroOut = ""
    'Me.wfCrntPG.Name = "wfCrntPG"
    'Me.wfCrntPG.Size = New System.Drawing.Size(36, 24)
    'Me.wfCrntPG.TabIndex = CType(91, Short)
    'Me.wfCrntPG.Text = "ZZ9"
    '
    'WarpField4
    '
    'Me.WarpField4.DecimalPointPosition = CType(0, Short)
    'Me.WarpField4.Font = New System.Drawing.Font("lr SVbN", 16.5!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel)
    'Me.WarpField4.FontSize = WarpControl.FontSizes.Small4
    'Me.WarpField4.Format = ""
    'Me.WarpField4.Length = CType(2, Short)
    'Me.WarpField4.Location = New System.Drawing.Point(0, 37)
    'Me.WarpField4.MacroBcr = ""
    'Me.WarpField4.MacroIn = ""
    'Me.WarpField4.MacroKey = ""
    'Me.WarpField4.MacroOut = ""
    'Me.WarpField4.Name = "WarpField4"
    'Me.WarpField4.Size = New System.Drawing.Size(18, 18)
    'Me.WarpField4.TabIndex = CType(90, Short)
    'Me.WarpField4.Text = "ID"
    '
    '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(8, Short)
    'Me.WarpField3.Location = New System.Drawing.Point(166, 39)
    'Me.WarpField3.MacroBcr = ""
    'Me.WarpField3.MacroIn = ""
    'Me.WarpField3.MacroKey = ""
    'Me.WarpField3.MacroOut = ""
    'Me.WarpField3.Name = "WarpField3"
    'Me.WarpField3.Size = New System.Drawing.Size(72, 18)
    'Me.WarpField3.TabIndex = CType(89, Short)
    'Me.WarpField3.Text = "Type/S.N"
    '
    '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(15, Short)
    'Me.WarpField1.Location = New System.Drawing.Point(30, 39)
    'Me.WarpField1.MacroBcr = ""
    'Me.WarpField1.MacroIn = ""
    'Me.WarpField1.MacroKey = ""
    'Me.WarpField1.MacroOut = ""
    'Me.WarpField1.Name = "WarpField1"
    'Me.WarpField1.Size = New System.Drawing.Size(135, 18)
    'Me.WarpField1.TabIndex = CType(88, Short)
    'Me.WarpField1.Text = "Carton/Item"
    '
    'wfTotal2
    '
    'Me.wfTotal2.DecimalPointPosition = CType(0, Short)
    'Me.wfTotal2.Font = New System.Drawing.Font("lr SVbN", 22.5!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel)
    'Me.wfTotal2.FontSize = WarpControl.FontSizes.Small2
    'Me.wfTotal2.Format = ""
    'Me.wfTotal2.InputMode.Right = True
    'Me.wfTotal2.Length = CType(5, Short)
    'Me.wfTotal2.Location = New System.Drawing.Point(174, 159)
    'Me.wfTotal2.MacroBcr = ""
    'Me.wfTotal2.MacroIn = ""
    'Me.wfTotal2.MacroKey = ""
    'Me.wfTotal2.MacroOut = ""
    'Me.wfTotal2.Name = "wfTotal2"
    'Me.wfTotal2.Size = New System.Drawing.Size(60, 24)
    'Me.wfTotal2.TabIndex = CType(87, Short)
    'Me.wfTotal2.Text = "ZZZZ9"
    '
    'WarpField2
    '
    'Me.WarpField2.DecimalPointPosition = CType(0, Short)
    'Me.WarpField2.Font = New System.Drawing.Font("lr SVbN", 22.5!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel)
    'Me.WarpField2.FontSize = WarpControl.FontSizes.Small2
    'Me.WarpField2.Format = ""
    'Me.WarpField2.Length = CType(5, Short)
    'Me.WarpField2.Location = New System.Drawing.Point(99, 159)
    'Me.WarpField2.MacroBcr = ""
    'Me.WarpField2.MacroIn = ""
    'Me.WarpField2.MacroKey = ""
    'Me.WarpField2.MacroOut = ""
    'Me.WarpField2.Name = "WarpField2"
    'Me.WarpField2.Size = New System.Drawing.Size(60, 24)
    'Me.WarpField2.TabIndex = CType(86, Short)
    'Me.WarpField2.Text = "Total"
    '
    'wfSerial1
    '
    'Me.wfSerial1.DecimalPointPosition = CType(0, Short)
    'Me.wfSerial1.Font = New System.Drawing.Font("lr SVbN", 16.5!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel)
    'Me.wfSerial1.FontSize = WarpControl.FontSizes.Small4
    'Me.wfSerial1.Format = ""
    'Me.wfSerial1.Length = CType(6, Short)
    'Me.wfSerial1.Location = New System.Drawing.Point(184, 57)
    'Me.wfSerial1.MacroBcr = ""
    'Me.wfSerial1.MacroIn = ""
    'Me.wfSerial1.MacroKey = ""
    'Me.wfSerial1.MacroOut = ""
    'Me.wfSerial1.Name = "wfSerial1"
    'Me.wfSerial1.Size = New System.Drawing.Size(54, 18)
    'Me.wfSerial1.TabIndex = CType(64, Short)
    'Me.wfSerial1.Text = "XXXXXX"
    '
    'wfSerial4
    '
    'Me.wfSerial4.DecimalPointPosition = CType(0, Short)
    'Me.wfSerial4.Font = New System.Drawing.Font("lr SVbN", 16.5!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel)
    'Me.wfSerial4.FontSize = WarpControl.FontSizes.Small4
    'Me.wfSerial4.Format = ""
    'Me.wfSerial4.Length = CType(6, Short)
    'Me.wfSerial4.Location = New System.Drawing.Point(184, 118)
    'Me.wfSerial4.MacroBcr = ""
    'Me.wfSerial4.MacroIn = ""
    'Me.wfSerial4.MacroKey = ""
    'Me.wfSerial4.MacroOut = ""
    'Me.wfSerial4.Name = "wfSerial4"
    'Me.wfSerial4.Size = New System.Drawing.Size(54, 18)
    'Me.wfSerial4.TabIndex = CType(85, Short)
    'Me.wfSerial4.Text = "XXXXXX"
    '
    'wfSerial5
    '
    'Me.wfSerial5.DecimalPointPosition = CType(0, Short)
    'Me.wfSerial5.Font = New System.Drawing.Font("lr SVbN", 16.5!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel)
    'Me.wfSerial5.FontSize = WarpControl.FontSizes.Small4
    'Me.wfSerial5.Format = ""
    'Me.wfSerial5.Length = CType(6, Short)
    'Me.wfSerial5.Location = New System.Drawing.Point(184, 139)
    'Me.wfSerial5.MacroBcr = ""
    'Me.wfSerial5.MacroIn = ""
    'Me.wfSerial5.MacroKey = ""
    'Me.wfSerial5.MacroOut = ""
    'Me.wfSerial5.Name = "wfSerial5"
    'Me.wfSerial5.Size = New System.Drawing.Size(54, 18)
    'Me.wfSerial5.TabIndex = CType(84, Short)
    'Me.wfSerial5.Text = "XXXXXX"
    '
    'wfSerial2
    '
    'Me.wfSerial2.DecimalPointPosition = CType(0, Short)
    'Me.wfSerial2.Font = New System.Drawing.Font("lr SVbN", 16.5!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel)
    'Me.wfSerial2.FontSize = WarpControl.FontSizes.Small4
    'Me.wfSerial2.Format = ""
    'Me.wfSerial2.Length = CType(6, Short)
    'Me.wfSerial2.Location = New System.Drawing.Point(184, 76)
    'Me.wfSerial2.MacroBcr = ""
    'Me.wfSerial2.MacroIn = ""
    'Me.wfSerial2.MacroKey = ""
    'Me.wfSerial2.MacroOut = ""
    'Me.wfSerial2.Name = "wfSerial2"
    'Me.wfSerial2.Size = New System.Drawing.Size(54, 18)
    'Me.wfSerial2.TabIndex = CType(83, Short)
    'Me.wfSerial2.Text = "XXXXXX"
    '
    'wfSerial3
    '
    'Me.wfSerial3.DecimalPointPosition = CType(0, Short)
    'Me.wfSerial3.Font = New System.Drawing.Font("lr SVbN", 16.5!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel)
    'Me.wfSerial3.FontSize = WarpControl.FontSizes.Small4
    'Me.wfSerial3.Format = ""
    'Me.wfSerial3.Length = CType(6, Short)
    'Me.wfSerial3.Location = New System.Drawing.Point(184, 97)
    'Me.wfSerial3.MacroBcr = ""
    'Me.wfSerial3.MacroIn = ""
    'Me.wfSerial3.MacroKey = ""
    'Me.wfSerial3.MacroOut = ""
    'Me.wfSerial3.Name = "wfSerial3"
    'Me.wfSerial3.Size = New System.Drawing.Size(54, 18)
    'Me.wfSerial3.TabIndex = CType(82, Short)
    'Me.wfSerial3.Text = "XXXXXX"
    '
    'wfPartNo5
    '
    'Me.wfPartNo5.DecimalPointPosition = CType(0, Short)
    'Me.wfPartNo5.Font = New System.Drawing.Font("lr SVbN", 16.5!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel)
    'Me.wfPartNo5.FontSize = WarpControl.FontSizes.Small4
    'Me.wfPartNo5.Format = ""
    'Me.wfPartNo5.Length = CType(15, Short)
    'Me.wfPartNo5.Location = New System.Drawing.Point(30, 139)
    'Me.wfPartNo5.MacroBcr = ""
    'Me.wfPartNo5.MacroIn = ""
    'Me.wfPartNo5.MacroKey = ""
    'Me.wfPartNo5.MacroOut = ""
    'Me.wfPartNo5.Name = "wfPartNo5"
    'Me.wfPartNo5.Size = New System.Drawing.Size(135, 18)
    'Me.wfPartNo5.TabIndex = CType(81, Short)
    'Me.wfPartNo5.Text = "XXX-XX-XX"
    '
    'wfPartNo4
    '
    'Me.wfPartNo4.DecimalPointPosition = CType(0, Short)
    'Me.wfPartNo4.Font = New System.Drawing.Font("lr SVbN", 16.5!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel)
    'Me.wfPartNo4.FontSize = WarpControl.FontSizes.Small4
    'Me.wfPartNo4.Format = ""
    'Me.wfPartNo4.Length = CType(15, Short)
    'Me.wfPartNo4.Location = New System.Drawing.Point(30, 118)
    'Me.wfPartNo4.MacroBcr = ""
    'Me.wfPartNo4.MacroIn = ""
    'Me.wfPartNo4.MacroKey = ""
    'Me.wfPartNo4.MacroOut = ""
    'Me.wfPartNo4.Name = "wfPartNo4"
    'Me.wfPartNo4.Size = New System.Drawing.Size(135, 18)
    'Me.wfPartNo4.TabIndex = CType(80, Short)
    'Me.wfPartNo4.Text = "XXX-XX-XX"
    '
    'wfPartNo3
    '
    'Me.wfPartNo3.DecimalPointPosition = CType(0, Short)
    'Me.wfPartNo3.Font = New System.Drawing.Font("lr SVbN", 16.5!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel)
    'Me.wfPartNo3.FontSize = WarpControl.FontSizes.Small4
    'Me.wfPartNo3.Format = ""
    'Me.wfPartNo3.Length = CType(15, Short)
    'Me.wfPartNo3.Location = New System.Drawing.Point(30, 97)
    'Me.wfPartNo3.MacroBcr = ""
    'Me.wfPartNo3.MacroIn = ""
    'Me.wfPartNo3.MacroKey = ""
    'Me.wfPartNo3.MacroOut = ""
    'Me.wfPartNo3.Name = "wfPartNo3"
    'Me.wfPartNo3.Size = New System.Drawing.Size(135, 18)
    'Me.wfPartNo3.TabIndex = CType(79, Short)
    'Me.wfPartNo3.Text = "XXX-XX-XX"
    '
    'wfPartNo2
    '
    'Me.wfPartNo2.DecimalPointPosition = CType(0, Short)
    'Me.wfPartNo2.Font = New System.Drawing.Font("lr SVbN", 16.5!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel)
    'Me.wfPartNo2.FontSize = WarpControl.FontSizes.Small4
    'Me.wfPartNo2.Format = ""
    'Me.wfPartNo2.Length = CType(15, Short)
    'Me.wfPartNo2.Location = New System.Drawing.Point(30, 76)
    'Me.wfPartNo2.MacroBcr = ""
    'Me.wfPartNo2.MacroIn = ""
    'Me.wfPartNo2.MacroKey = ""
    'Me.wfPartNo2.MacroOut = ""
    'Me.wfPartNo2.Name = "wfPartNo2"
    'Me.wfPartNo2.Size = New System.Drawing.Size(135, 18)
    'Me.wfPartNo2.TabIndex = CType(78, Short)
    'Me.wfPartNo2.Text = "XXX-XX-XX"
    '
    'wfNo5
    '
    'Me.wfNo5.DecimalPointPosition = CType(0, Short)
    'Me.wfNo5.Font = New System.Drawing.Font("lr SVbN", 16.5!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel)
    'Me.wfNo5.FontSize = WarpControl.FontSizes.Small4
    'Me.wfNo5.Format = ""
    'Me.wfNo5.Length = CType(3, Short)
    'Me.wfNo5.Location = New System.Drawing.Point(0, 139)
    'Me.wfNo5.MacroBcr = ""
    'Me.wfNo5.MacroIn = ""
    'Me.wfNo5.MacroKey = ""
    'Me.wfNo5.MacroOut = ""
    'Me.wfNo5.Name = "wfNo5"
    'Me.wfNo5.Size = New System.Drawing.Size(27, 18)
    'Me.wfNo5.TabIndex = CType(77, Short)
    'Me.wfNo5.Text = "5"
    '
    'wfNo4
    '
    'Me.wfNo4.DecimalPointPosition = CType(0, Short)
    'Me.wfNo4.Font = New System.Drawing.Font("lr SVbN", 16.5!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel)
    'Me.wfNo4.FontSize = WarpControl.FontSizes.Small4
    'Me.wfNo4.Format = ""
    'Me.wfNo4.Length = CType(3, Short)
    'Me.wfNo4.Location = New System.Drawing.Point(0, 118)
    'Me.wfNo4.MacroBcr = ""
    'Me.wfNo4.MacroIn = ""
    'Me.wfNo4.MacroKey = ""
    'Me.wfNo4.MacroOut = ""
    'Me.wfNo4.Name = "wfNo4"
    'Me.wfNo4.Size = New System.Drawing.Size(27, 18)
    'Me.wfNo4.TabIndex = CType(76, Short)
    'Me.wfNo4.Text = "4"
    '
    'wfNo3
    '
    'Me.wfNo3.DecimalPointPosition = CType(0, Short)
    'Me.wfNo3.Font = New System.Drawing.Font("lr SVbN", 16.5!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel)
    'Me.wfNo3.FontSize = WarpControl.FontSizes.Small4
    'Me.wfNo3.Format = ""
    'Me.wfNo3.Length = CType(3, Short)
    'Me.wfNo3.Location = New System.Drawing.Point(0, 97)
    'Me.wfNo3.MacroBcr = ""
    'Me.wfNo3.MacroIn = ""
    'Me.wfNo3.MacroKey = ""
    'Me.wfNo3.MacroOut = ""
    'Me.wfNo3.Name = "wfNo3"
    'Me.wfNo3.Size = New System.Drawing.Size(27, 18)
    'Me.wfNo3.TabIndex = CType(75, Short)
    'Me.wfNo3.Text = "3"
    '
    'wfNo2
    '
    'Me.wfNo2.DecimalPointPosition = CType(0, Short)
    'Me.wfNo2.Font = New System.Drawing.Font("lr SVbN", 16.5!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel)
    'Me.wfNo2.FontSize = WarpControl.FontSizes.Small4
    'Me.wfNo2.Format = ""
    'Me.wfNo2.Length = CType(3, Short)
    'Me.wfNo2.Location = New System.Drawing.Point(0, 76)
    'Me.wfNo2.MacroBcr = ""
    'Me.wfNo2.MacroIn = ""
    'Me.wfNo2.MacroKey = ""
    'Me.wfNo2.MacroOut = ""
    'Me.wfNo2.Name = "wfNo2"
    'Me.wfNo2.Size = New System.Drawing.Size(27, 18)
    'Me.wfNo2.TabIndex = CType(74, Short)
    'Me.wfNo2.Text = "2"
    '
    'wfNo1
    '
    'Me.wfNo1.DecimalPointPosition = CType(0, Short)
    'Me.wfNo1.Font = New System.Drawing.Font("lr SVbN", 16.5!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel)
    'Me.wfNo1.FontSize = WarpControl.FontSizes.Small4
    'Me.wfNo1.Format = ""
    'Me.wfNo1.Length = CType(3, Short)
    'Me.wfNo1.Location = New System.Drawing.Point(0, 57)
    'Me.wfNo1.MacroBcr = ""
    'Me.wfNo1.MacroIn = ""
    'Me.wfNo1.MacroKey = ""
    'Me.wfNo1.MacroOut = ""
    'Me.wfNo1.Name = "wfNo1"
    'Me.wfNo1.Size = New System.Drawing.Size(27, 18)
    'Me.wfNo1.TabIndex = CType(73, Short)
    'Me.wfNo1.Text = "1"
    '
    '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.InputMode.Right = True
    'Me.wfSeq.Length = CType(3, Short)
    'Me.wfSeq.Location = New System.Drawing.Point(49, 3)
    '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(72, 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(1, 3)
    '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(69, Short)
    'Me.wfLine.Text = "XX"
    '
    'wfPartNo1
    '
    'Me.wfPartNo1.DecimalPointPosition = CType(0, Short)
    'Me.wfPartNo1.Font = New System.Drawing.Font("lr SVbN", 16.5!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel)
    'Me.wfPartNo1.FontSize = WarpControl.FontSizes.Small4
    'Me.wfPartNo1.Format = ""
    'Me.wfPartNo1.Length = CType(15, Short)
    'Me.wfPartNo1.Location = New System.Drawing.Point(30, 57)
    'Me.wfPartNo1.MacroBcr = ""
    'Me.wfPartNo1.MacroIn = ""
    'Me.wfPartNo1.MacroKey = ""
    'Me.wfPartNo1.MacroOut = ""
    'Me.wfPartNo1.Name = "wfPartNo1"
    'Me.wfPartNo1.Size = New System.Drawing.Size(135, 18)
    'Me.wfPartNo1.TabIndex = CType(62, Short)
    'Me.wfPartNo1.Text = "XXX-XX-XX"
    '
    '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
    '
    'wfKey
    '
    '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.InputMode.Secret = True
    'Me.wfKey.Length = CType(1, Short)
    'Me.wfKey.Location = New System.Drawing.Point(114, 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)
    '
    'WarpHWBcr1
    '
    'Me.WarpHWBcr1.DiscreteFirstLen = CType(0, Short)
    'Me.WarpHWBcr1.DiscreteSecondLen = CType(0, Short)
    'Me.WarpHWBcr1.InterleavedFirstLen = CType(0, Short)
    'Me.WarpHWBcr1.InterleavedSecondLen = CType(0, Short)
    '
    'frm1040
    '
    '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 = "frm1040"
    'Me.Text = "Form1"
    'Me.WarpFrame1.ResumeLayout(False)
    'Me.ResumeLayout(False)

    'End Sub

#End Region

    'c”•\ฆป•\ฆ•ลAล‘ๅ•\ฆ•ล”
    Private mintCrntPage, mintMaxPage As Integer

    'c”
    Private mintTotalCnt As Integer


    Private Sub frm1040_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, rtn2 As Integer
        Dim wstrData() As PLLIST_STR
        Try

            '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_H1040, WarpBox1)
#End If
            With gstrctAicCase
                rtn2 = wfLoadFromAP(.AicCaseNo & .YYYYMMDD, wstrData, mintTotalCnt)
                Select Case rtn2
                    Case 1
                        '>>> ADD ST  2006.03.07 >>>
                        mintMaxPage = mintTotalCnt / 5
                        If mintTotalCnt > mintMaxPage * 5 Then
                            mintMaxPage += 1
                        End If

                        sClrDisp1040()
                        sDisp1040(wstrData)
                        ' tH[€EC“ ภs
                        sMain(wstrData)
                        '<<< ADD END 2006.03.07 <<<
                    Case 0
                        gintStatus = PL_STATUS.PCSCAN
                        Me.Close()
                        Exit Sub
                    Case -1
                        'f0.WarpCtrl1.MessageBox(G_CONST_EMT_DB, fEditErrorInfo(RTrim(gclsDB.BtriveStatus), RTrim(gclsDB.ErrFile)), MWA_DB_WARNING, MWA_DB_OK)
                        MessageBox.Show(G_CONST_EM_DB, G_CONST_EMT_DB, MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1)

                        gintStatus = PL_STATUS.PCSCAN  'XL“ๆ–สึ‘”๐
                        Me.Close()
                        Exit Sub
                End Select
            End With
        Catch ex As Exception
            sErrLog(gAppName, "frm1040_Load", ex.ToString)
        Finally
            ' t[€ฬN[Y
            Try
                If rtn = 0 Then
                    'rtn = WarpFrame1.Close()
                    If (rtn <> 0) Then
                        Err.Raise(vbObjectError + 1, gAppName, "WarpError")
                    End If
                End If
            Catch ex As Exception
                sErrLog(gAppName, "frm1040_Load Fially", ex.ToString)
            End Try
            ' tH[€EN[Y
            Me.Close()
        End Try
    End Sub

    '/*
    '|| ึ”–ผFsDisp1040
    '|| T—v  F1040ๆ–ส•\ฆ
    '*/
    Private Sub sDisp1040(ByVal wstrData() As PLLIST_STR, Optional ByVal pintPageCnt As Integer = 0)
        Dim i As Integer
        Dim wintStartIdx As Integer

        wintStartIdx = pintPageCnt * 5

        For i = wintStartIdx To (wintStartIdx + 5) - 1
            If wstrData.Length > i Then
                Select Case (i Mod 5)
                    Case 0
                        If wstrData(i).bAtrFlg Then
                            'wfNo1.SetAtr(MWA_ATR_REV, MWA_ATR_REV)
                            'wfPartNo1.SetAtr(MWA_ATR_REV, MWA_ATR_REV)
                            'wfSerial1.SetAtr(MWA_ATR_REV, MWA_ATR_REV)
                        End If
                        'wfNo1.Puts(CStr(i + 1))
                        'wfPartNo1.Puts(wstrData(i).strData1)
                        'wfSerial1.Puts(wstrData(i).strData2)
                        wfNo1.Text = CStr(i + 1)
                        wfPartNo1.Text = wstrData(i).strData1
                        wfSerial1.Text = wstrData(i).strData2
                    Case 1
                        If wstrData(i).bAtrFlg Then
                            'wfNo2.SetAtr(MWA_ATR_REV, MWA_ATR_REV)
                            'wfPartNo2.SetAtr(MWA_ATR_REV, MWA_ATR_REV)
                            'wfSerial2.SetAtr(MWA_ATR_REV, MWA_ATR_REV)
                        End If
                        'wfNo2.Puts(CStr(i + 1))
                        'wfPartNo2.Puts(wstrData(i).strData1)
                        'wfSerial2.Puts(wstrData(i).strData2)
                        wfNo2.Text = CStr(i + 1)
                        wfPartNo2.Text = wstrData(i).strData1
                        wfSerial2.Text = wstrData(i).strData2
                    Case 2
                        'wfNo3.Puts(CStr(i + 1))
                        wfNo3.Text = CStr(i + 1)
                        If wstrData(i).bAtrFlg Then
                            'wfNo3.SetAtr(MWA_ATR_REV, MWA_ATR_REV)
                            'wfPartNo3.SetAtr(MWA_ATR_REV, MWA_ATR_REV)
                            'wfSerial3.SetAtr(MWA_ATR_REV, MWA_ATR_REV)
                        End If
                        'wfNo3.Puts(CStr(i + 1))
                        'wfPartNo3.Puts(wstrData(i).strData1)
                        'wfSerial3.Puts(wstrData(i).strData2)
                        wfNo3.Text = CStr(i + 1)
                        wfPartNo3.Text = wstrData(i).strData1
                        wfSerial3.Text = wstrData(i).strData2
                    Case 3
                        If wstrData(i).bAtrFlg Then
                            'wfNo4.SetAtr(MWA_ATR_REV, MWA_ATR_REV)
                            'wfPartNo4.SetAtr(MWA_ATR_REV, MWA_ATR_REV)
                            'wfSerial4.SetAtr(MWA_ATR_REV, MWA_ATR_REV)
                        End If
                        'wfNo4.Puts(CStr(i + 1))
                        'wfPartNo4.Puts(wstrData(i).strData1)
                        'wfSerial4.Puts(wstrData(i).strData2)
                        wfNo4.Text = CStr(i + 1)
                        wfPartNo4.Text = wstrData(i).strData1
                        wfSerial4.Text = wstrData(i).strData2
                    Case 4
                        If wstrData(i).bAtrFlg Then
                            'wfNo5.SetAtr(MWA_ATR_REV, MWA_ATR_REV)
                            'wfPartNo5.SetAtr(MWA_ATR_REV, MWA_ATR_REV)
                            'wfSerial5.SetAtr(MWA_ATR_REV, MWA_ATR_REV)
                        End If
                        'wfNo5.Puts(CStr(i + 1))
                        'wfPartNo5.Puts(wstrData(i).strData1)
                        'wfSerial5.Puts(wstrData(i).strData2)
                        wfNo5.Text = CStr(i + 1)
                        wfPartNo5.Text = wstrData(i).strData1
                        wfSerial5.Text = wstrData(i).strData2
                End Select
            Else
                Exit For
            End If
        Next
        With gstrctAicCase
            'wfLine.Puts(.Line)
            'wfSeq.Puts(CInt(.PackSeq))
            wfSeq.Text = CInt(.PackSeq)
        End With
        'wfCrntPG.Puts(mintCrntPage + 1)
        'wfTotalPG.Puts(mintMaxPage)
        'wfTotal2.Puts(gstrctPLDispData.intTotalCnt - gstrctPLDispData.intCheckCnt)
        'wfName.Puts(gstrctKDHT.strUserName)
        wfCrntPG.Text = mintCrntPage + 1
        wfTotalPG.Text = mintMaxPage
        wfTotal2.Text = gstrctPLDispData.intTotalCnt - gstrctPLDispData.intCheckCnt
        wfName.Text = gstrctKDHT.strUserName
    End Sub

    '/*
    '|| ึ”–ผFsClrDisp1040
    '|| T—v  F1040ๆ–ส๚ป—
    '*/
    Private Sub sClrDisp1040()
        'wfNo1.Puts("") : wfNo1.SetAtr(MWA_ATR_NOM, MWA_ATR_NOM) : wfPartNo1.Puts("") : wfPartNo1.SetAtr(MWA_ATR_NOM, MWA_ATR_NOM) : wfSerial1.Puts("") : wfSerial1.SetAtr(MWA_ATR_NOM, MWA_ATR_NOM)
        'wfNo2.Puts("") : wfNo2.SetAtr(MWA_ATR_NOM, MWA_ATR_NOM) : wfPartNo2.Puts("") : wfPartNo2.SetAtr(MWA_ATR_NOM, MWA_ATR_NOM) : wfSerial2.Puts("") : wfSerial2.SetAtr(MWA_ATR_NOM, MWA_ATR_NOM)
        'wfNo3.Puts("") : wfNo3.SetAtr(MWA_ATR_NOM, MWA_ATR_NOM) : wfPartNo3.Puts("") : wfPartNo3.SetAtr(MWA_ATR_NOM, MWA_ATR_NOM) : wfSerial3.Puts("") : wfSerial3.SetAtr(MWA_ATR_NOM, MWA_ATR_NOM)
        'wfNo4.Puts("") : wfNo4.SetAtr(MWA_ATR_NOM, MWA_ATR_NOM) : wfPartNo4.Puts("") : wfPartNo4.SetAtr(MWA_ATR_NOM, MWA_ATR_NOM) : wfSerial4.Puts("") : wfSerial4.SetAtr(MWA_ATR_NOM, MWA_ATR_NOM)
        'wfNo5.Puts("") : wfNo5.SetAtr(MWA_ATR_NOM, MWA_ATR_NOM) : wfPartNo5.Puts("") : wfPartNo5.SetAtr(MWA_ATR_NOM, MWA_ATR_NOM) : wfSerial5.Puts("") : wfSerial5.SetAtr(MWA_ATR_NOM, MWA_ATR_NOM)

        wfNo1.Text = ""
        wfNo2.Text = ""
        wfNo3.Text = ""
        wfNo4.Text = ""
        wfNo5.Text = ""

        wfPartNo1.Text = ""
        wfPartNo1.Text = ""
        wfPartNo1.Text = ""
        wfPartNo1.Text = ""
        wfPartNo1.Text = ""

        wfSerial1.Text = ""
        wfSerial2.Text = ""
        wfSerial3.Text = ""
        wfSerial4.Text = ""
        wfSerial5.Text = ""

    End Sub

    ' t[€EC“
    Private Sub sMain(ByVal pstrData() As PLLIST_STR)

        'Dim WKey As Short

        'Try

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

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

        '        If WKey = WKY_ENT Then

        '        ElseIf WKey = WKY_BCR Then

        '        ElseIf WKey = WKY_ERROR Then

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

        '        ElseIf WKey = WKY_PGUP Then
        '            If mintCrntPage > 0 Then
        '                mintCrntPage -= 1
        '                sClrDisp1040()
        '                sDisp1040(pstrData, mintCrntPage)
        '            End If
        '        ElseIf WKey = WKY_PGDOWN Then
        '            'ล‘ๅ•ล”ฬๆ“พ
        '            If mintCrntPage < mintMaxPage - 1 Then
        '                mintCrntPage += 1
        '                sClrDisp1040()
        '                sDisp1040(pstrData, mintCrntPage)
        '            End If
        '        ElseIf WKey = WKY_F2 Then 'ถฐฤ/•”•iฝทฌึ•A
        '            gintStatus = PL_STATUS.PCSCAN
        '            Exit Do
        '        End If
        '    Loop

        'Catch ex As Exception
        '    sErrLog(gAppName, "sMain", ex.ToString)
        'End Try
    End Sub
    '*******************************************************************************
    '* @”\     : PACKAP“ว—
    '* ๘”     : 1.ฝทฌรฐภ(R) 2.–พืรฐภ(W) 3.‘ฝทฌ‘ฮ”
    '* –฿่’l   : -1:DBฺ‘ฑG[  1:ณํI—น 0:Not Found
    '* ”๕l     : ศต
    '*******************************************************************************
    Private Function wfLoadFromAP(ByVal pstrItemGr As String, ByRef wstrData() As PLLIST_STR, ByRef pintTotalCnt As Integer) As Integer
        Dim wstrKey(6) As String
        Dim wstrKeyValue(6) As String
        Dim rtn As Integer = -1
        Dim wintCnt As Integer
        Dim wstrCrtn As String
        Dim wstrWhere As String
        wfLoadFromAP = -1

        Try
            'wstrKey(0) = "Flag"
            'wstrKey(1) = "PaletteID"
            'wstrKey(2) = "ItemGr"
            'wstrKey(3) = "ItemInID"
            'wstrKey(4) = "ItemInCodeDisp"
            'wstrKey(5) = "ItemInCode"
            'wstrKey(6) = "ItemID"
            'wstrKey(7) = "ItemCode"
            'wstrKey(8) = "TempSerial"

            'wstrKeyValue(0) = "1"
            'wstrKeyValue(1) = "A"
            'wstrKeyValue(2) = pstrItemGr
            'wstrKeyValue(3) = Space(1)
            'wstrKeyValue(4) = Space(30)
            'wstrKeyValue(5) = Space(30)
            'wstrKeyValue(6) = Space(1)
            'wstrKeyValue(7) = Space(30)
            'wstrKeyValue(8) = Space(6)

            With gstrctAicCase
                wstrKey(0) = "PaletteID" : wstrKeyValue(0) = "A"
                wstrKey(1) = "ItemGr" : wstrKeyValue(1) = .AicCaseNo & .YYYYMMDD
                wstrKey(2) = "ItemID" : wstrKeyValue(2) = Space(1)
                wstrKey(3) = "ItemCode" : wstrKeyValue(3) = Space(30)
                wstrKey(4) = "ItemInID" : wstrKeyValue(4) = Space(1)
                wstrKey(5) = "ItemInCode" : wstrKeyValue(5) = Space(30)
                wstrKey(6) = "TempSerial" : wstrKeyValue(6) = Space(6)
            End With


            wstrWhere = ""
            wstrWhere = wstrKey(0) & " = '" & wstrKeyValue(0) & "'"
            wstrWhere &= " and " & wstrKey(1) & " = '" & wstrKeyValue(1) & "'"
            wstrWhere &= " and " & wstrKey(2) & " = '" & wstrKeyValue(2) & "'"
            wstrWhere &= " and " & wstrKey(3) & " = '" & wstrKeyValue(3) & "'"
            wstrWhere &= " and " & wstrKey(4) & " = '" & wstrKeyValue(4) & "'"
            wstrWhere &= " and " & wstrKey(5) & " = '" & wstrKeyValue(5) & "'"
            wstrWhere &= " and " & wstrKey(6) & " = '" & wstrKeyValue(6) & "'"

            tmpStr = dbClient.Query("SELECT * FROM " + G_CONST_TBL_PACKAP + " WHERE " + wstrWhere)

            Dim values As Dictionary(Of String, String) = New Dictionary(Of String, String)
            Dim sPaletteID As String = ""
            Dim sItemGr As String = ""
            Dim sItemCode As String = ""
            Dim sItemID As String = ""
            Dim sItemInCode As String = ""
            Dim sSerialNo As String = ""
            Dim sCartonType As String = ""
            Dim sFlag As String = ""
            Dim i As Integer = 0

            If tmpStr.Count > 0 Then

                Do
                    values = tmpStr(i)

                    Dim result As String = Nothing
                    If values.TryGetValue("PaletteID", result) Then
                        sPaletteID = RTrim(result)
                    End If
                    If values.TryGetValue("ItemGr", result) Then
                        sItemGr = RTrim(result)
                    End If
                    If values.TryGetValue("ItemCode", result) Then
                        sItemCode = RTrim(result)
                    End If
                    If values.TryGetValue("ItemID", result) Then
                        sItemID = RTrim(result)
                    End If
                    If values.TryGetValue("ItemInCode", result) Then
                        sItemInCode = RTrim(result)
                    End If
                    If values.TryGetValue("SerialNo", result) Then
                        sSerialNo = RTrim(result)
                    End If
                    If values.TryGetValue("CartonType", result) Then
                        sCartonType = RTrim(result)
                    End If
                    If values.TryGetValue("Flag", result) Then
                        sFlag = RTrim(result)
                    End If


                    If wstrKeyValue(0) = RTrim(sPaletteID) AndAlso wstrKeyValue(1) = RTrim(sItemGr) Then
                        ReDim Preserve wstrData(wintCnt)
                        wstrCrtn = Mid(sItemCode, 21, 5)
                        'If wstrCrtn = "00000" Then
                        '<--- ADD ST 2006/02/07 ---> 
                        If wstrCrtn = "00000" OrElse sItemID = "B" Then
                            '<--- ADD END 2006/02/07 ---> 
                            wstrData(wintCnt).strData1 = fDispItemChg(modConst.DispItemChg.ToMazda, RTrim(sItemInCode))
                            'wstrData(wintCnt).strData2 = .Item("TempSerial")
                            wstrData(wintCnt).strData2 = sSerialNo
                        Else
                            If IsNumeric(wstrCrtn) Then
                                wstrCrtn = CLng(wstrCrtn)
                            End If
                            wstrData(wintCnt).strData1 = wstrCrtn.PadLeft(6)
                            wstrData(wintCnt).strData2 = sCartonType
                        End If
                        If RTrim(sFlag) = "1" Then
                            wstrData(wintCnt).bAtrFlg = False
                        Else
                            wstrData(wintCnt).bAtrFlg = True
                        End If
                        wintCnt += 1

                    Else
                        Exit Do
                    End If

                    i = i + 1

                    If tmpStr.Count = i Then
                        Exit Do
                    End If

                Loop

                pintTotalCnt = wintCnt
                wfLoadFromAP = 1


            Else

                wfLoadFromAP = 0

            End If


       

        Catch ex As Exception
            sErrLog(gAppName, "wfLoadFromAP", ex.ToString)
        Finally
            
        End Try


        'rtn = gclsDB.fOpenRecord(G_CONST_TBL_PACKAP, G_CONST_KEY_PACKAPKEY04, "PKAP00", wstrKey, wstrKeyValue, BtLib.Operation.GetGreaterOrEqual)
        'rtn = gclsDB.fOpenRecord(G_CONST_TBL_PACKAP, G_CONST_KEY_PACKAPKEY00, "PKAP00", wstrKey, wstrKeyValue, BtLib.Operation.GetGreaterOrEqual)
        'If rtn = -1 Then
        '    Exit Function
        'ElseIf rtn = 0 Then
        '    wintCnt = 0
        '    Do
        '        With gclsDB.Records("PKAP00")
        '            If wstrKeyValue(0) = RTrim(.Item("PaletteID")) AndAlso wstrKeyValue(1) = RTrim(.Item("ItemGr")) Then
        '                ReDim Preserve wstrData(wintCnt)
        '                wstrCrtn = Mid(.Item("ItemCode"), 21, 5)
        '                'If wstrCrtn = "00000" Then
        '                '<--- ADD ST 2006/02/07 ---> 
        '                If wstrCrtn = "00000" OrElse .Item("ItemID") = "B" Then
        '                    '<--- ADD END 2006/02/07 ---> 
        '                    wstrData(wintCnt).strData1 = fDispItemChg(modConst.DispItemChg.ToMazda, RTrim(.Item("ItemInCode")))
        '                    'wstrData(wintCnt).strData2 = .Item("TempSerial")
        '                    wstrData(wintCnt).strData2 = .Item("SerialNo")
        '                Else
        '                    If IsNumeric(wstrCrtn) Then
        '                        wstrCrtn = CLng(wstrCrtn)
        '                    End If
        '                    wstrData(wintCnt).strData1 = wstrCrtn.PadLeft(6)
        '                    wstrData(wintCnt).strData2 = .Item("CartonType")
        '                End If
        '                If RTrim(.Item("Flag")) = "1" Then
        '                    wstrData(wintCnt).bAtrFlg = False
        '                Else
        '                    wstrData(wintCnt).bAtrFlg = True
        '                End If
        '                wintCnt += 1
        '                If .Read(BtLib.Operation.GetNext) <> 0 Then
        '                    Exit Do
        '                End If
        '            Else
        '                Exit Do
        '            End If
        '        End With
        '    Loop
        '    pintTotalCnt = wintCnt
        '    wfLoadFromAP = 1
        'Else
        '    wfLoadFromAP = 0
        'End If
        'Catch ex As Exception
        '    sErrLog(gAppName, "wfLoadFromAP", ex.ToString)
        'Finally
        '    If rtn <> -1 Then
        '        gclsDB.fCloseRecord("PKAP00")
        '    End If
        'End Try
    End Function

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


