﻿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

Public Class frm5E65
    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 WarpCtrl1 As WarpControl.WarpCtrl
    'Friend WithEvents WarpFrame1 As WarpControl.WarpFrame
    'Friend WithEvents WarpHWBcr1 As WarpControl.WarpHWBcr
    'Friend WithEvents WarpBox1 As WarpControl.WarpBox
    'Friend WithEvents wfName As WarpControl.WarpField
    'Friend WithEvents wfInput As WarpControl.WarpField
    'Friend WithEvents WarpField1 As WarpControl.WarpField
    'Friend WithEvents WarpField2 As WarpControl.WarpField
    'Friend WithEvents WarpField3 As WarpControl.WarpField
    'Friend WithEvents wfCL As WarpControl.WarpField
    'Friend WithEvents wfZ As WarpControl.WarpField
    'Friend WithEvents WarpField100 As WarpControl.WarpField
    'Friend WithEvents wfQty1 As WarpControl.WarpField
    'Friend WithEvents wfQty2 As WarpControl.WarpField
    'Friend WithEvents WarpField8 As WarpControl.WarpField
    'Friend WithEvents wfPart As WarpControl.WarpField

    '<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
    '    Me.WarpFrame1 = New WarpControl.WarpFrame()
    '    Me.WarpField8 = New WarpControl.WarpField()
    '    Me.wfQty2 = New WarpControl.WarpField()
    '    Me.wfQty1 = New WarpControl.WarpField()
    '    Me.WarpField100 = New WarpControl.WarpField()
    '    Me.wfZ = New WarpControl.WarpField()
    '    Me.wfCL = New WarpControl.WarpField()
    '    Me.wfPart = New WarpControl.WarpField()
    '    Me.WarpField3 = New WarpControl.WarpField()
    '    Me.WarpField2 = New WarpControl.WarpField()
    '    Me.WarpField1 = New WarpControl.WarpField()
    '    Me.wfInput = New WarpControl.WarpField()
    '    Me.WarpBox1 = New WarpControl.WarpBox()
    '    Me.wfName = New WarpControl.WarpField()
    '    Me.WarpHWBcr1 = New WarpControl.WarpHWBcr()
    '    Me.WarpFrame1.SuspendLayout()
    '    Me.SuspendLayout()
    '    '
    '    'WarpFrame1
    '    '
    '    Me.WarpFrame1.Controls.Add(Me.WarpField8)
    '    Me.WarpFrame1.Controls.Add(Me.wfQty2)
    '    Me.WarpFrame1.Controls.Add(Me.wfQty1)
    '    Me.WarpFrame1.Controls.Add(Me.WarpField100)
    '    Me.WarpFrame1.Controls.Add(Me.wfZ)
    '    Me.WarpFrame1.Controls.Add(Me.wfCL)
    '    Me.WarpFrame1.Controls.Add(Me.wfPart)
    '    Me.WarpFrame1.Controls.Add(Me.WarpField3)
    '    Me.WarpFrame1.Controls.Add(Me.WarpField2)
    '    Me.WarpFrame1.Controls.Add(Me.WarpField1)
    '    Me.WarpFrame1.Controls.Add(Me.wfInput)
    '    Me.WarpFrame1.Controls.Add(Me.WarpBox1)
    '    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 = ""
    '    '
    '    'WarpField8
    '    '
    '    Me.WarpField8.DecimalPointPosition = CType(0, Short)
    '    Me.WarpField8.Font = New System.Drawing.Font("lr SVbN", 22.5!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel)
    '    Me.WarpField8.FontSize = WarpControl.FontSizes.Small2
    '    Me.WarpField8.Format = ""
    '    Me.WarpField8.Length = CType(1, Short)
    '    Me.WarpField8.Location = New System.Drawing.Point(130, 72)
    '    Me.WarpField8.MacroBcr = ""
    '    Me.WarpField8.MacroIn = ""
    '    Me.WarpField8.MacroKey = ""
    '    Me.WarpField8.MacroOut = ""
    '    Me.WarpField8.Name = "WarpField8"
    '    Me.WarpField8.Size = New System.Drawing.Size(12, 24)
    '    Me.WarpField8.TabIndex = CType(18, Short)
    '    Me.WarpField8.Text = "/"
    '    '
    '    '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.Length = CType(5, Short)
    '    Me.wfQty2.Location = New System.Drawing.Point(154, 72)
    '    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(17, Short)
    '    Me.wfQty2.Text = "ZZZZ9"
    '    '
    '    '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.Length = CType(5, Short)
    '    Me.wfQty1.Location = New System.Drawing.Point(58, 72)
    '    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(16, Short)
    '    Me.wfQty1.Text = "ZZZZ9"
    '    '
    '    'WarpField100
    '    '
    '    Me.WarpField100.DecimalPointPosition = CType(0, Short)
    '    Me.WarpField100.Font = New System.Drawing.Font("lr SVbN", 22.5!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel)
    '    Me.WarpField100.FontSize = WarpControl.FontSizes.Small2
    '    Me.WarpField100.Format = ""
    '    Me.WarpField100.Length = CType(3, Short)
    '    Me.WarpField100.Location = New System.Drawing.Point(0, 72)
    '    Me.WarpField100.MacroBcr = ""
    '    Me.WarpField100.MacroIn = ""
    '    Me.WarpField100.MacroKey = ""
    '    Me.WarpField100.MacroOut = ""
    '    Me.WarpField100.Name = "WarpField100"
    '    Me.WarpField100.Size = New System.Drawing.Size(36, 24)
    '    Me.WarpField100.TabIndex = CType(15, Short)
    '    Me.WarpField100.Text = "Qty"
    '    '
    '    '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, 37)
    '    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(14, 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(184, 39)
    '    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(13, 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(3, 36)
    '    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(8, Short)
    '    Me.wfPart.Text = "XXXX-XX-XXXX"
    '    '
    '    'WarpField3
    '    '
    '    Me.WarpField3.DecimalPointPosition = CType(0, Short)
    '    Me.WarpField3.Font = New System.Drawing.Font("lr SVbN", 22.5!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel)
    '    Me.WarpField3.FontSize = WarpControl.FontSizes.Small2
    '    Me.WarpField3.Format = ""
    '    Me.WarpField3.Length = CType(1, Short)
    '    Me.WarpField3.Location = New System.Drawing.Point(219, 12)
    '    Me.WarpField3.MacroBcr = ""
    '    Me.WarpField3.MacroIn = ""
    '    Me.WarpField3.MacroKey = ""
    '    Me.WarpField3.MacroOut = ""
    '    Me.WarpField3.Name = "WarpField3"
    '    Me.WarpField3.Size = New System.Drawing.Size(12, 24)
    '    Me.WarpField3.TabIndex = CType(7, Short)
    '    Me.WarpField3.Text = "Z"
    '    '
    '    '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(2, Short)
    '    Me.WarpField2.Location = New System.Drawing.Point(180, 12)
    '    Me.WarpField2.MacroBcr = ""
    '    Me.WarpField2.MacroIn = ""
    '    Me.WarpField2.MacroKey = ""
    '    Me.WarpField2.MacroOut = ""
    '    Me.WarpField2.Name = "WarpField2"
    '    Me.WarpField2.Size = New System.Drawing.Size(24, 24)
    '    Me.WarpField2.TabIndex = CType(6, Short)
    '    Me.WarpField2.Text = "CL"
    '    '
    '    'WarpField1
    '    '
    '    Me.WarpField1.DecimalPointPosition = CType(0, Short)
    '    Me.WarpField1.Font = New System.Drawing.Font("lr SVbN", 22.5!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel)
    '    Me.WarpField1.FontSize = WarpControl.FontSizes.Small2
    '    Me.WarpField1.Format = ""
    '    Me.WarpField1.Length = CType(6, Short)
    '    Me.WarpField1.Location = New System.Drawing.Point(0, 12)
    '    Me.WarpField1.MacroBcr = ""
    '    Me.WarpField1.MacroIn = ""
    '    Me.WarpField1.MacroKey = ""
    '    Me.WarpField1.MacroOut = ""
    '    Me.WarpField1.Name = "WarpField1"
    '    Me.WarpField1.Size = New System.Drawing.Size(72, 24)
    '    Me.WarpField1.TabIndex = CType(5, Short)
    '    Me.WarpField1.Text = "PartNo"
    '    '
    '    '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(154, 37)
    '    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(4, Short)
    '    '
    '    'WarpBox1
    '    '
    '    Me.WarpBox1.BoxType = WarpControl.BoxTypes.Box
    '    Me.WarpBox1.DrawMode = WarpControl.DrawModes.Paint
    '    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 = ""
    '    Me.WarpBox1.Location = New System.Drawing.Point(0, 100)
    '    Me.WarpBox1.Name = "WarpBox1"
    '    Me.WarpBox1.Size = New System.Drawing.Size(240, 96)
    '    Me.WarpBox1.TabIndex = 3
    '    '
    '    'wfName
    '    '
    '    Me.wfName.DecimalPointPosition = CType(0, Short)
    '    Me.wfName.Font = New System.Drawing.Font("lr SVbN", 22.5!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel)
    '    Me.wfName.FontSize = WarpControl.FontSizes.Small2
    '    Me.wfName.Format = ""
    '    Me.wfName.Length = CType(20, Short)
    '    Me.wfName.Location = New System.Drawing.Point(0, 216)
    '    Me.wfName.MacroBcr = ""
    '    Me.wfName.MacroIn = ""
    '    Me.wfName.MacroKey = ""
    '    Me.wfName.MacroOut = ""
    '    Me.wfName.Name = "wfName"
    '    Me.wfName.Size = New System.Drawing.Size(240, 24)
    '    Me.wfName.TabIndex = CType(2, Short)
    '    '
    '    'WarpHWBcr1
    '    '
    '    Me.WarpHWBcr1.Decode.UPC_EAN_JAN = 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)
    '    '
    '    'frm5E65
    '    '
    '    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 = "frm5E65"
    '    Me.Text = "Form1"
    '    Me.WarpFrame1.ResumeLayout(False)
    '    Me.ResumeLayout(False)

    'End Sub

#End Region


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

            ' 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_E5E65, WarpBox1, 1)
#End If
            sDisp5E65()

            ' 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, "frm5E65_Load", ex.ToString)
            Me.Close()
            Exit Sub
        End Try

    End Sub

    ' t[€EC“
    Public Sub sMain()

        'Dim WKey As Short
        'Dim buf As String
        'Dim rtn As Integer
        'Dim wintCnt As Integer

        'Try

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

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

        '        If WKey = WKY_ENT Then

        '            rtn = fZeroPicked()

        '            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)
        '                Exit Do
        '            End If

        '            'gstrctKDPP.intIndex += 1
        '            rtn = fSearchPackCP(2)
        '            If rtn = -1 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)
        '            ElseIf rtn = -2 Then
        '                'If gstrctKDPP.bRetry Then
        '                '    gintStatus = TR_STATUS.RETRY1
        '                'Else
        '                rtn = fUpdatePackPlan()
        '                If rtn = -1 Then
        '                    sErrLog(gAppName, "fProcInput", "ERROR ON UPDATING PACKPLAN")
        '                    'Exit Function
        '                End If
        '                gintStatus = TR_STATUS.PRINT
        '                'End If
        '            Else
        '                gintStatus = TR_STATUS.PART
        '            End If
        '            Exit Do

        '        ElseIf WKey = WKY_BCR Then

        '        ElseIf WKey = WKY_F1 Then

        '            gintStatus = TR_STATUS.PART
        '            Exit Do

        '        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

    '/*
    '|| ึ”–ผFsDisp5E65
    '|| T—v  F5E65ๆ–ส•\ฆ
    '*/
    Private Sub sDisp5E65()

        Dim wstrLctnPartNo As String

        With gstrctPPDispPart
            wstrLctnPartNo = gstrctPPDisp.strCrtnNo & .strLocation & RTrim(.strItemInCode)
            wfPart.Text = .strPartNoDisp
            wfCL.Text = .strCL
            wfZ.Text = .strZ

            wfQty1.Text = gstrctPPDisp.fGetQty(RTrim(wstrLctnPartNo), 1)
            wfQty2.Text = gstrctPPDisp.fGetQty(RTrim(wstrLctnPartNo), 0)
        End With
        wfName.Text = gstrctKDHT.strUserName

    End Sub
    '/*
    '|| ึ”–ผFfZeroPicked
    '|| T—v  Foื”[ฎ—น
    '*/
    Private Function fZeroPicked()

        Dim wstrPKcpKey(2) As String
        Dim wstrPKcpKeyValue(2) As String
        Dim wstrStkKey(7) As String
        Dim wstrStkKeyValue(7) As String
        Dim wstrLctnPartNo As String
        Dim rtn2 As Integer
        Const KEY01 = "UPD01"
        Const KEY02 = "UPD02"
        Dim values As Dictionary(Of String, String) = New Dictionary(Of String, String)

        fZeroPicked = -1

        Try


            'ภัXV—

            '—\–๑VA๕—p
            With gstrctPPDispPart
                wstrPKcpKey(0) = "ItemCode" : wstrPKcpKeyValue(0) = .strItemCode
                wstrPKcpKey(1) = "ItemInCode" : wstrPKcpKeyValue(1) = .strItemInCode
                wstrPKcpKey(2) = "PlanSerial" : wstrPKcpKeyValue(2) = .strSerial
            End With

            rtn2 = fOpenPackCP(G_CONST_KEY_PACKCPKEY06, KEY01, wstrPKcpKey, wstrPKcpKeyValue)
            If rtn2 <> 0 Then
                'DBG[
                'gclsDB.fCloseRecord(KEY01)
                Exit Function
            End If

            If gstrctPPDispPart.strLocation = "?????" Then

                If fUpdProc(KEY01, KEY02, 3) <> 0 Then
                    'XVธ”s
                    'gclsDB.fCloseRecord(KEY01)
                    Exit Function
                End If

            Else

                Dim values1 As Dictionary(Of String, String) = New Dictionary(Of String, String)
                Dim sPicsType As String = ""
                Dim sCstmid As String = ""
                Dim sCstmCode As String = ""
                Dim sCenterCode As String = ""
                Dim sBhk As String = ""
                Dim sItemInID As String = ""
                Dim sItemInCode1 As String = ""
                Dim sPlanSerial As String = ""

                If tmpStrCP.Count > 0 Then

                    values1 = tmpStrCP(0)

                    Dim result As String = Nothing
                    If values1.TryGetValue("PicsType", result) Then
                        sPicsType = RTrim(result)
                    End If
                    If values1.TryGetValue("Cstmid", result) Then
                        sCstmid = RTrim(result)
                    End If
                    If values1.TryGetValue("CstmCode", result) Then
                        sCstmCode = RTrim(result)
                    End If
                    If values1.TryGetValue("CenterCode", result) Then
                        sCenterCode = RTrim(result)
                    End If
                    If values1.TryGetValue("Bhk", result) Then
                        sBhk = RTrim(result)
                    End If
                    If values1.TryGetValue("ItemInID", result) Then
                        sItemInID = RTrim(result)
                    End If
                    If values1.TryGetValue("ItemInCode", result) Then
                        sItemInCode1 = RTrim(result)
                    End If
                    If values1.TryGetValue("PlanSerial", result) Then
                        sPlanSerial = RTrim(result)
                    End If

                    wstrStkKey(0) = "PicsType" : wstrStkKeyValue(0) = RTrim(sPicsType)
                    wstrStkKey(1) = "Cstmid" : wstrStkKeyValue(1) = RTrim(sCstmid)
                    wstrStkKey(2) = "CstmCode" : wstrStkKeyValue(2) = RTrim(sCstmCode)
                    wstrStkKey(3) = "CenterCode" : wstrStkKeyValue(3) = RTrim(sCenterCode)
                    wstrStkKey(4) = "Bhk" : wstrStkKeyValue(4) = RTrim(sBhk)
                    wstrStkKey(5) = "Itemid" : wstrStkKeyValue(5) = RTrim(sItemInID)
                    wstrStkKey(6) = "ItemCode" : wstrStkKeyValue(6) = RTrim(sItemInCode1)
                    wstrStkKey(7) = "SerialNo" : wstrStkKeyValue(7) = RTrim(sPlanSerial)


                    rtn2 = fOpenStock(G_CONST_KEY_STOCKKEY00, KEY02, wstrStkKey, wstrStkKeyValue, 0)


                    If rtn2 <> 0 Then
                        'DBG[
                        'gclsDB.fCloseRecord(KEY01)
                        Exit Function
                    End If

                    If fUpdProc(KEY01, KEY02, 1) <> 0 Then
                        'XVธ”s
                        'gclsDB.fCloseRecord(KEY01)
                        Exit Function
                    End If
                    'gclsDB.fCloseRecord(KEY02)


                End If

            End If

            values = New Dictionary(Of String, String)
            Dim sStockLctn As String = ""
            Dim sItemInCode As String = ""
            Dim sPackQtyJ As String = ""

            If tmpStrCP.Count > 0 Then

                values = tmpStrCP(0)

                Dim result As String = Nothing
                If values.TryGetValue("StockLctn", result) Then
                    'Console.WriteLine("RESULT: {0}", result)
                    sStockLctn = result
                End If
                If values.TryGetValue("ItemInCode", result) Then
                    'Console.WriteLine("RESULT: {0}", result)
                    sItemInCode = result
                End If
                If values.TryGetValue("PackQtyJ", result) Then
                    'Console.WriteLine("RESULT: {0}", result)
                    sPackQtyJ = result
                End If

                wstrLctnPartNo = gstrctPPDisp.strCrtnNo & sStockLctn & sItemInCode
                gstrctPPDisp.fSetQty(wstrLctnPartNo, sPackQtyJ, 1)
                gstrctPPDisp.fSetPkg(wstrLctnPartNo, 1, 1)

                gstrctPPDisp.intNumOfScanned += 1

                fZeroPicked = 0

            End If

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






        'Dim wstrPKcpKey(2) As String
        'Dim wstrPKcpKeyValue(2) As String
        'Dim wstrStkKey(7) As String
        'Dim wstrStkKeyValue(7) As String
        'Dim wstrLctnPartNo As String
        'Dim rtn2 As Integer
        'Const KEY01 = "UPD01"
        'Const KEY02 = "UPD02"

        'fZeroPicked = -1

        'Try


        '    'ภัXV—

        '    '—\–๑VA๕—p
        '    With gstrctPPDispPart
        '        wstrPKcpKey(0) = "ItemCode" : wstrPKcpKeyValue(0) = .strItemCode
        '        wstrPKcpKey(1) = "ItemInCode" : wstrPKcpKeyValue(1) = .strItemInCode
        '        wstrPKcpKey(2) = "PlanSerial" : wstrPKcpKeyValue(2) = .strSerial
        '    End With

        '    rtn2 = fOpenPackCP(G_CONST_KEY_PACKCPKEY06, KEY01, wstrPKcpKey, wstrPKcpKeyValue)
        '    If rtn2 <> 0 Then
        '        'DBG[
        '        gclsDB.fCloseRecord(KEY01)
        '        Exit Function
        '    End If

        '    If gstrctPPDispPart.strLocation = "?????" Then

        '        If fUpdProc(KEY01, KEY02, 3) <> 0 Then
        '            'XVธ”s
        '            gclsDB.fCloseRecord(KEY01)
        '            Exit Function
        '        End If

        '    Else

        '        '—\–๑STOCK๕—p
        '        With gclsDB.Records(KEY01)
        '            wstrStkKey(0) = "PicsType" : wstrStkKeyValue(0) = RTrim(.Item("PicsType"))
        '            wstrStkKey(1) = "Cstmid" : wstrStkKeyValue(1) = RTrim(.Item("Cstmid"))
        '            wstrStkKey(2) = "CstmCode" : wstrStkKeyValue(2) = RTrim(.Item("CstmCode"))
        '            wstrStkKey(3) = "CenterCode" : wstrStkKeyValue(3) = RTrim(.Item("CenterCode"))
        '            wstrStkKey(4) = "Bhk" : wstrStkKeyValue(4) = RTrim(.Item("Bhk"))
        '            wstrStkKey(5) = "Itemid" : wstrStkKeyValue(5) = RTrim(.Item("ItemInID"))
        '            wstrStkKey(6) = "ItemCode" : wstrStkKeyValue(6) = RTrim(.Item("ItemInCode"))
        '            wstrStkKey(7) = "SerialNo" : wstrStkKeyValue(7) = RTrim(.Item("PlanSerial"))

        '        End With

        '        rtn2 = fOpenStock(G_CONST_KEY_STOCKKEY00, KEY02, wstrStkKey, wstrStkKeyValue, 0)

        '        If rtn2 <> 0 Then
        '            'DBG[
        '            gclsDB.fCloseRecord(KEY01)
        '            Exit Function
        '        End If

        '        If fUpdProc(KEY01, KEY02, 1) <> 0 Then
        '            'XVธ”s
        '            gclsDB.fCloseRecord(KEY01)
        '            Exit Function
        '        End If
        '        gclsDB.fCloseRecord(KEY02)

        '    End If

        '    With gclsDB.Records(KEY01)
        '        wstrLctnPartNo = gstrctPPDisp.strCrtnNo & .Item("StockLctn") & .Item("ItemInCode")
        '        gstrctPPDisp.fSetQty(wstrLctnPartNo, .Item("PackQtyJ"), 1)
        '        gstrctPPDisp.fSetPkg(wstrLctnPartNo, 1, 1)
        '    End With
        '    gstrctPPDisp.intNumOfScanned += 1

        '    gclsDB.fCloseRecord(KEY01)
        '    fZeroPicked = 0

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

    Private Sub frm5E65_KeyDown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles MyBase.KeyDown
        Dim rtn As Integer

        Select Case e.KeyCode.ToString()
            Case "Return"
                rtn = fZeroPicked()

                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

                'gstrctKDPP.intIndex += 1
                rtn = fSearchPackCP(2)
                If rtn = -1 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)

                ElseIf rtn = -2 Then
                    'If gstrctKDPP.bRetry Then
                    '    gintStatus = TR_STATUS.RETRY1
                    'Else
                    rtn = fUpdatePackPlan()
                    If rtn = -1 Then
                        sErrLog(gAppName, "fProcInput", "ERROR ON UPDATING PACKPLAN")
                        'Exit Function
                    End If
                    gintStatus = TR_STATUS.PRINT
                    Me.Close()
                    'End If
                Else
                    gintStatus = TR_STATUS.PART
                    Me.Close()
                End If
                Exit Sub
            Case "F1"
                gintStatus = TR_STATUS.PART
                Me.Close()
                Exit Sub
            Case "F2"
        End Select
    End Sub
End Class
