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

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

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


    Public Sub New()
        MyBase.New()

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

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

    End Sub

    ' Form อAR“|[l“g๊——ษใ—๐ภsท้ฝ฿ษ dispose ๐I[o[ChตทB
    'Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
    '    If disposing Then
    '        If Not (components Is Nothing) Then
    '            components.Dispose()
    '        End If
    '    End If
    '    MyBase.Dispose(disposing)
    'End Sub

    ' Windows tH[€ fUCiล•K—vลทB
    'Private components As System.ComponentModel.IContainer

    '  : ศบฬvV[WอAWindows tH[€ fUCiล•K—vลทB
    'Windows tH[€ fUCi๐gมฤ•ฯXตฤญพณขB  
    ' R[h GfB^๐gมฤ•ฯXตศขลญพณขB
    'Friend WithEvents WarpFrame1 As WarpControl.WarpFrame
    'Friend WithEvents WarpBox1 As WarpControl.WarpBox
    'Friend WithEvents wfName As WarpControl.WarpField
    'Friend WithEvents wfSection As WarpControl.WarpField
    'Friend WithEvents wfKey As WarpControl.WarpField
    'Friend WithEvents WarpHWBcr1 As WarpControl.WarpHWBcr
    'Friend WithEvents wfTitle As WarpControl.WarpField
    '<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
    '    Me.WarpFrame1 = New WarpControl.WarpFrame()
    '    Me.wfTitle = New WarpControl.WarpField()
    '    Me.wfKey = New WarpControl.WarpField()
    '    Me.wfName = New WarpControl.WarpField()
    '    Me.WarpBox1 = New WarpControl.WarpBox()
    '    Me.wfSection = New WarpControl.WarpField()
    '    Me.WarpHWBcr1 = New WarpControl.WarpHWBcr()
    '    Me.WarpFrame1.SuspendLayout()
    '    Me.SuspendLayout()
    '    '
    '    'WarpFrame1
    '    '
    '    Me.WarpFrame1.Controls.Add(Me.wfTitle)
    '    Me.WarpFrame1.Controls.Add(Me.wfKey)
    '    Me.WarpFrame1.Controls.Add(Me.wfName)
    '    Me.WarpFrame1.Controls.Add(Me.WarpBox1)
    '    Me.WarpFrame1.Controls.Add(Me.wfSection)
    '    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 = ""
    '    '
    '    'wfTitle
    '    '
    '    Me.wfTitle.DecimalPointPosition = CType(0, Short)
    '    Me.wfTitle.Font = New System.Drawing.Font("lr SVbN", 28.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel)
    '    Me.wfTitle.FontSize = WarpControl.FontSizes.Small
    '    Me.wfTitle.Format = ""
    '    Me.wfTitle.Length = CType(15, Short)
    '    Me.wfTitle.Location = New System.Drawing.Point(7, 18)
    '    Me.wfTitle.MacroBcr = ""
    '    Me.wfTitle.MacroIn = ""
    '    Me.wfTitle.MacroKey = ""
    '    Me.wfTitle.MacroOut = ""
    '    Me.wfTitle.Name = "wfTitle"
    '    Me.wfTitle.Size = New System.Drawing.Size(225, 30)
    '    Me.wfTitle.TabIndex = CType(4, Short)
    '    '
    '    'wfKey
    '    '
    '    Me.wfKey.BcrFlag = True
    '    Me.wfKey.DecimalPointPosition = CType(0, Short)
    '    Me.wfKey.Font = New System.Drawing.Font("lr SVbN", 33.5!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel)
    '    Me.wfKey.Format = ""
    '    Me.wfKey.InputMode.Secret = True
    '    Me.wfKey.Length = CType(1, Short)
    '    Me.wfKey.Location = New System.Drawing.Point(204, 108)
    '    Me.wfKey.MacroBcr = ""
    '    Me.wfKey.MacroIn = ""
    '    Me.wfKey.MacroKey = ""
    '    Me.wfKey.MacroOut = ""
    '    Me.wfKey.Name = "wfKey"
    '    Me.wfKey.Size = New System.Drawing.Size(18, 36)
    '    Me.wfKey.TabIndex = CType(3, Short)
    '    '
    '    'wfName
    '    '
    '    Me.wfName.DecimalPointPosition = CType(0, Short)
    '    Me.wfName.Font = New System.Drawing.Font("lr SVbN", 22.5!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel)
    '    Me.wfName.FontSize = WarpControl.FontSizes.Small2
    '    Me.wfName.Format = ""
    '    Me.wfName.Length = CType(20, Short)
    '    Me.wfName.Location = New System.Drawing.Point(0, 216)
    '    Me.wfName.MacroBcr = ""
    '    Me.wfName.MacroIn = ""
    '    Me.wfName.MacroKey = ""
    '    Me.wfName.MacroOut = ""
    '    Me.wfName.Name = "wfName"
    '    Me.wfName.Size = New System.Drawing.Size(240, 24)
    '    Me.wfName.TabIndex = CType(2, Short)
    '    '
    '    'WarpBox1
    '    '
    '    Me.WarpBox1.BoxType = WarpControl.BoxTypes.Box
    '    Me.WarpBox1.DrawMode = WarpControl.DrawModes.Line
    '    Me.WarpBox1.Font = New System.Drawing.Font("lr SVbN", 33.5!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel)
    '    Me.WarpBox1.ForeColor = CType(15, Short)
    '    Me.WarpBox1.Image = "C:\H081-0110.jpg"
    '    Me.WarpBox1.Location = New System.Drawing.Point(0, 192)
    '    Me.WarpBox1.Name = "WarpBox1"
    '    Me.WarpBox1.Size = New System.Drawing.Size(240, 24)
    '    Me.WarpBox1.TabIndex = 1
    '    Me.WarpBox1.Text = "WarpBox1"
    '    '
    '    'wfSection
    '    '
    '    Me.wfSection.DecimalPointPosition = CType(0, Short)
    '    Me.wfSection.Font = New System.Drawing.Font("lr SVbN", 28.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel)
    '    Me.wfSection.FontSize = WarpControl.FontSizes.Small
    '    Me.wfSection.Format = ""
    '    Me.wfSection.Length = CType(15, Short)
    '    Me.wfSection.Location = New System.Drawing.Point(7, 72)
    '    Me.wfSection.MacroBcr = ""
    '    Me.wfSection.MacroIn = ""
    '    Me.wfSection.MacroKey = ""
    '    Me.wfSection.MacroOut = ""
    '    Me.wfSection.Name = "wfSection"
    '    Me.wfSection.Size = New System.Drawing.Size(225, 30)
    '    Me.wfSection.TabIndex = CType(0, Short)
    '    '
    '    '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)
    '    '
    '    'frm2015
    '    '
    '    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 = "frm2015"
    '    Me.Text = "Form1"
    '    Me.WarpFrame1.ResumeLayout(False)
    '    Me.ResumeLayout(False)

    'End Sub

#End Region

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

    Public mint2015status As Integer

    Private Sub frm2015_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
            mint2015status = M2015_STATUS.INIT
            gstrctPPDisp.initialize()
            't[€ฬI[v“
            'rtn = WarpFrame1.Open
            'If (rtn <> 0) Then
            '    Err.Raise(vbObjectError + 1, gAppName, "WarpError")
            'End If

            sDisp2015()

#If Not Debug Then
            'sSetImgFName(G_CONST_MID_H2015, WarpBox1)
#Else
            'WarpBox1.Text = "€”๕ชลซฝ็ENTL["
#End If
            ' tH[€EC“ ภs
            sMain()

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

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

            Exit Sub

        Catch ex As Exception
            gintStatus = PP_STATUS.QUIT
            sErrLog(gAppName, "frm2015_Load", ex.ToString)
            Me.Close()
            Exit Sub
        End Try
    End Sub
    '/*
    '|| ึ”–ผFsDisp2015
    '|| T—v  F2015ๆ–ส•\ฆ
    '*/
    Private Sub sDisp2015()

        'wfTitle.Puts(gstrctKDHT.strTitle)
        'wfSection.Puts(gstrctKDPP.strSectionName)
        'wfName.Puts(gstrctKDHT.strUserName)

        wfTitle.Text = gstrctKDHT.strTitle
        wfSection.Text = gstrctKDPP.strSectionName
        wfName.Text = gstrctKDHT.strUserName

    End Sub

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

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

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

        If rtn = 0 Then
            Select Case mint2015status
                Case M2015_STATUS.INIT

                    '์ฦๆ–สฬ•\ฆ

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

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

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

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

                    gintStatus = PP_STATUS.SECTION
                    Me.Close()
                    Exit Sub

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

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

            End Select

        Else

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

            MessageBox.Show(G_CONST_EM_DB, G_CONST_EMT_DB, MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1)

        End If



    End Sub
    ' t[€EC“
    Public Sub sMain()

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

        '        Try

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

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

        '                If WKey = WKY_ENT Then

        '                    'PACKCP์ฌJn
        '                    'gstrctKDPP.initialize()
        '                    gstrctPPDisp.initialize()
        '                    gstrctPPDispPart.initialize()
        '#If Not Debug Then
        '                    sSetImgFName(G_CONST_MID_H2017, WarpBox1)
        '                    WarpFrame1.Flush()
        '#End If
        '                    'fMakePackCP“เล๕ท้eํฬงฒูฬ—แOษึตฤอAeฬงฒูฬ—แO”ญถษ
        '                    'gstrctKDPP\‘ข‘ฬษดืฐ๎•๑๐พฏฤตฤๆ–ส•\ฆฬใA๚ปB
        '                    rtn = fMakePackCP()
        '                    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)
        '                        With gstrctKDPP
        '                            f0.WarpCtrl1.MessageBox(G_CONST_EMT_DB, fEditErrorInfo(RTrim(.lngBtrvStatus), RTrim(.strErrBtrvFile)), MWA_DB_WARNING, MWA_DB_OK)
        '                            .lngBtrvStatus = 0
        '                            .strErrBtrvFile = ""
        '                        End With
        '                        Exit Do
        '                    ElseIf rtn = -2 Then
        '                        '๕I—น
        '#If Not Debug Then
        '                        fFnc_WrpMsg("E", G_CONST_MID_E2E18, 1)
        '                        WarpFrame1.Flush()
        '#Else
        '                        WarpBox1.Text = "ซ•๏vๆฬ“วฑI—น"
        '#End If
        '                        gintStatus = PP_STATUS.SECTION
        '                        Exit Do
        '                    ElseIf rtn = -3 Then
        '                        'ฑธพฝๆ•ชXV‘าฟ

        '                        gintStatus = PP_STATUS.SECWAIT
        '                        Exit Do
        '                    ElseIf rtn = -4 Then
        '                        'ฑธพฝๆ•ชดืฐ

        '                        gintStatus = PP_STATUS.RETRYSEC
        '                        rtn = fUpdateHTCTRL()
        '                        If rtn = -1 Then
        '                            f0.WarpCtrl1.MessageBox(G_CONST_EMT_DB, fEditErrorInfo(RTrim(gclsDB.BtriveStatus), RTrim(gclsDB.ErrFile)), MWA_DB_WARNING, MWA_DB_OK)
        '                        End If
        '                        Exit Do
        '                    ElseIf rtn = -5 Then 'l”ฑฯฏมดืฐ(AP)
        '                        sBeepSound(modPublicHT.BEEP_TYPE.A, modPublicHT.BEEP_SELECTION.NG)
        '                        sOutputLog(gstrctPicsIni.strOutput_KDPL, "KDPL1E17", G_CONST_BC_PL, buf)
        '#If Not Debug Then
        '                        fFnc_WrpMsg("E", G_CONST_MID_H2018, "ND", 4)
        '#End If
        '                    ElseIf rtn = -6 Then 'APฬ์ฌษธ”s
        '#If Not Debug Then  'APฬ์ฌษธ”sตตฝB
        '                        fFnc_WrpMsg("E", G_CONST_MID_E2E19, 1)
        '                        WarpFrame1.Flush()
        '#Else
        '                        WarpBox1.Text = "PACKAPฬ์ฌษธ”s"
        '#End If
        '                    End If

        '                    rtn = fUpdateHTCTRL()
        '                    If rtn = -1 Then
        '                        f0.WarpCtrl1.MessageBox(G_CONST_EMT_DB, fEditErrorInfo(RTrim(gclsDB.BtriveStatus), RTrim(gclsDB.ErrFile)), MWA_DB_WARNING, MWA_DB_OK)

        '                        Exit Do
        '                    End If

        '                    sBeepSound(modPublicHT.BEEP_TYPE.B, modPublicHT.BEEP_SELECTION.NG)
        '                    gstrctPPDisp.intNumOfScanned = 0 '๚’lF0
        '                    gintStatus = PP_STATUS.HEADER
        '                    Exit Do

        '                ElseIf WKey = WKY_BCR Then

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

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

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

        '                    If rtn = 0 Then
        '                        Select Case mint2015status
        '                            Case M2015_STATUS.INIT

        '                                '์ฦๆ–สฬ•\ฆ

        '                                gintStatus = PP_STATUS.ENTKEY

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

        '                                gintStatus = PP_STATUS.SECTION

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

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

        '                        End Select

        '                    Else

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

        '                    End If
        '                    Exit Do

        '                ElseIf WKey = WKY_F1 Then


        '                ElseIf WKey = WKY_F2 Then


        '                ElseIf WKey = WKY_ERROR Then

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

        '                End If

        '            Loop

        '            Exit Sub

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

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

        fProcInput = -1

        Try

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

                mint2015status = M2015_STATUS.MENUBACK
                fProcInput = 0
                Exit Function

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

                mint2015status = M2015_STATUS.SHUTDOWN
                fProcInput = 0
                Exit Function

            Else

                mint2015status = M2015_STATUS.NOTCD
                fProcInput = 0
                Exit Function

            End If

            fProcInput = 0

            Exit Function

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

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

        Select Case e.KeyCode.ToString()
            Case "Return"
                rtn = fMakePackCP()
                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)
                    With gstrctKDPP
                        'f0.WarpCtrl1.MessageBox(G_CONST_EMT_DB, fEditErrorInfo(RTrim(.lngBtrvStatus), RTrim(.strErrBtrvFile)), MWA_DB_WARNING, MWA_DB_OK)
                        MessageBox.Show(G_CONST_EM_DB, G_CONST_EMT_DB, MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1)


                        .lngBtrvStatus = 0
                        .strErrBtrvFile = ""
                    End With
                ElseIf rtn = -2 Then
                    '๕I—น
#If Not Debug Then
                    fFnc_WrpMsg("E", G_CONST_MID_E2E18, 1)
                    'WarpFrame1.Flush()
#Else
                        'WarpBox1.Text = "ซ•๏vๆฬ“วฑI—น"
#End If
                    RemoveHandler btScanLib.OnScan, AddressOf btScanLib_OnScan
                    btScanLib.Disable()

                    gintStatus = PP_STATUS.SECTION
                    Me.Close()
                    Exit Sub
                ElseIf rtn = -3 Then
                    'ฑธพฝๆ•ชXV‘าฟ

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

                    gintStatus = PP_STATUS.SECWAIT
                    Me.Close()
                    Exit Sub
                ElseIf rtn = -4 Then
                    'ฑธพฝๆ•ชดืฐ

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

                    gintStatus = PP_STATUS.RETRYSEC
                    rtn = fUpdateHTCTRL()
                    If rtn = -1 Then
                        '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)

                    End If
                    Me.Close()
                    Exit Sub
                ElseIf rtn = -5 Then 'l”ฑฯฏมดืฐ(AP)
                    'sBeepSound(modPublicHT.BEEP_TYPE.A, modPublicHT.BEEP_SELECTION.NG)
                    sOutputLog(gstrctPicsIni.strOutput_KDPL, "KDPL1E17", G_CONST_BC_PL, buf)
#If Not Debug Then
                    fFnc_WrpMsg("E", G_CONST_MID_H2018, "ND", 4)
#End If
                ElseIf rtn = -6 Then 'APฬ์ฌษธ”s
#If Not Debug Then  'APฬ์ฌษธ”sตตฝB
                    fFnc_WrpMsg("E", G_CONST_MID_E2E19, 1)
                    'WarpFrame1.Flush()
#Else
                        'WarpBox1.Text = "PACKAPฬ์ฌษธ”s"
#End If
                End If

                rtn = fUpdateHTCTRL()
                If rtn = -1 Then
                    '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)

                End If

                'sBeepSound(modPublicHT.BEEP_TYPE.B, modPublicHT.BEEP_SELECTION.NG)
                gstrctPPDisp.intNumOfScanned = 0 '๚’lF0
                gintStatus = PP_STATUS.HEADER
                Me.Close()
                Exit Sub
            Case "F1"
            Case "F2"
                gintStatus = PP_STATUS.QUIT
                Me.Close()
                Exit Sub
        End Select

    End Sub

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