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

Public Class frm7010
    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 WarpHWBcr1 As WarpControl.WarpHWBcr
    'Friend WithEvents WarpBox1 As WarpControl.WarpBox
    'Friend WithEvents WarpFrame1 As WarpControl.WarpFrame
    'Friend WithEvents wfName As WarpControl.WarpField
    'Friend WithEvents wfSection As WarpControl.WarpField
    'Friend WithEvents wfInput As WarpControl.WarpField
    '<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
    '    Me.WarpFrame1 = New WarpControl.WarpFrame()
    '    Me.wfInput = New WarpControl.WarpField()
    '    Me.wfSection = New WarpControl.WarpField()
    '    Me.wfName = New WarpControl.WarpField()
    '    Me.WarpBox1 = New WarpControl.WarpBox()
    '    Me.WarpHWBcr1 = New WarpControl.WarpHWBcr()
    '    Me.WarpFrame1.SuspendLayout()
    '    Me.SuspendLayout()
    '    '
    '    'WarpFrame1
    '    '
    '    Me.WarpFrame1.Controls.Add(Me.wfInput)
    '    Me.WarpFrame1.Controls.Add(Me.wfSection)
    '    Me.WarpFrame1.Controls.Add(Me.wfName)
    '    Me.WarpFrame1.Controls.Add(Me.WarpBox1)
    '    Me.WarpFrame1.Font = New System.Drawing.Font("MS UI Gothic", 9.0!)
    '    Me.WarpFrame1.Location = New System.Drawing.Point(0, 0)
    '    Me.WarpFrame1.Name = "WarpFrame1"
    '    Me.WarpFrame1.Size = New System.Drawing.Size(240, 296)
    '    Me.WarpFrame1.TabIndex = 1
    '    Me.WarpFrame1.UseMacro = False
    '    Me.WarpFrame1.UseMacroFileName = ""
    '    '
    '    'wfInput
    '    '
    '    Me.wfInput.BcrFlag = True
    '    Me.wfInput.DecimalPointPosition = CType(0, Short)
    '    Me.wfInput.Font = New System.Drawing.Font("lr SVbN", 33.5!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel)
    '    Me.wfInput.Format = ""
    '    Me.wfInput.InputMode.Secret = True
    '    Me.wfInput.Length = CType(1, Short)
    '    Me.wfInput.Location = New System.Drawing.Point(204, 132)
    '    Me.wfInput.MacroBcr = ""
    '    Me.wfInput.MacroIn = ""
    '    Me.wfInput.MacroKey = ""
    '    Me.wfInput.MacroOut = ""
    '    Me.wfInput.Name = "wfInput"
    '    Me.wfInput.Size = New System.Drawing.Size(18, 36)
    '    Me.wfInput.TabIndex = CType(3, Short)
    '    '
    '    'wfSection
    '    '
    '    Me.wfSection.BcrFlag = True
    '    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, 36)
    '    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(2, 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(1, 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 = "C:\H081-0070.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
    '    Me.WarpBox1.Text = "WarpBox1"
    '    '
    '    '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)
    '    '
    '    'frm7010
    '    '
    '    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 = "frm7010"
    '    Me.Text = "Form2"
    '    Me.WarpFrame1.ResumeLayout(False)
    '    Me.ResumeLayout(False)

    'End Sub

#End Region

    Public Enum M3010_STATUS As Integer
        INIT = 0
        MENUBACK = 1
        SHUTDOWN = 2
        NOTG = 3
        NOTEXIST = 4
        DONE = 5
    End Enum

    Public mint3010status As Integer

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

    Private Sub frm3010_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
            mint3010status = M3010_STATUS.INIT

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

#If Not Debug Then
            'sSetImgFName(G_CONST_MID_H3010, WarpBox1)
#Else
            'WarpBox1.Text = "ZNV“๐XL“"
#End If
            sDisp3010()
            ' 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

        End Try

    End Sub
    '/*
    '|| ึ”–ผFsDisp3010
    '|| T—v  F3010ๆ–ส•\ฆ
    '*/
    Private Sub sDisp3010()

        'wfName.Puts(gstrctKDHT.strUserName)

        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_E3E15)
#End If
            Exit Sub
        End If

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

        If rtn = 0 Then
            Select Case mint3010status
                Case M3010_STATUS.INIT

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

                    gintStatus = OM_STATUS.SECTION
                    Me.Close()
                    '                                gintStatus = OM_STATUS.LOCATION
                    Exit Sub
                Case M3010_STATUS.MENUBACK          'HTCTRL.ExeName๐มตฤI—น

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

                    gintStatus = OM_STATUS.NAME
                    Me.Close()
                    Exit Sub

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

                Case M3010_STATUS.NOTG              'GศOศฬลดืฐาฏพฐผ

                    sBeepSound(modPublicHT.BEEP_TYPE.A, modPublicHT.BEEP_SELECTION.NG)
                    sOutputLog(gstrctPicsIni.strOutput_KDPP, "KDPP3E15", G_CONST_BC_SEC, buf)
#If Not Debug Then
                                fFnc_WrpMsg("E", G_CONST_MID_E3E15)
#End If
                    Exit Sub
                Case M3010_STATUS.NOTEXIST          'Qฦรฐภษ–ณขฬลดืฐาฏพฐผ
                    sBeepSound(modPublicHT.BEEP_TYPE.A, modPublicHT.BEEP_SELECTION.NG)
#If Not Debug Then
                                fFnc_WrpMsg("E", G_CONST_MID_E3E20)
#End If
                    Exit Sub
                Case M3010_STATUS.DONE              'ณํษQฦลซฝ

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

                    gintStatus = OM_STATUS.CLSCAN
                    Me.Close()
                    Exit Sub
            End Select

        Else

            'f0.WarpCtrl1.MessageBox(G_CONST_EMT_DB, G_CONST_EM_DB, MWA_DB_WARNING, MWA_DB_OK)
            'f0.WarpCtrl1.MessageBox(G_CONST_EMT_DB, fEditErrorInfo(gclsDB.BtriveStatus, gclsDB.ErrFile), MWA_DB_WARNING, MWA_DB_OK)
            MessageBox.Show(G_CONST_EM_DB, G_CONST_EMT_DB, MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1)

        End If



    End Sub


    ' t[€EC“
    Public Sub sMain()

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

        '        Try

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

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

        '                If WKey = WKY_ENT Then

        '                    'fSakusei2()

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

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

        '                    If rtn = 0 Then
        '                        Select Case mint3010status
        '                            Case M3010_STATUS.INIT
        '                                gintStatus = OM_STATUS.SECTION
        '                                '                                gintStatus = OM_STATUS.LOCATION
        '                                Exit Sub
        '                            Case M3010_STATUS.MENUBACK          'HTCTRL.ExeName๐มตฤI—น

        '                                gintStatus = OM_STATUS.NAME
        '                                Exit Sub

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

        '                            Case M3010_STATUS.NOTG              'GศOศฬลดืฐาฏพฐผ

        '                                sBeepSound(modPublicHT.BEEP_TYPE.A, modPublicHT.BEEP_SELECTION.NG)
        '                                sOutputLog(gstrctPicsIni.strOutput_KDPP, "KDPP3E15", G_CONST_BC_SEC, buf)
        '#If Not Debug Then
        '                                fFnc_WrpMsg("E", G_CONST_MID_E3E15)
        '#End If
        '                            Case M3010_STATUS.NOTEXIST          'Qฦรฐภษ–ณขฬลดืฐาฏพฐผ
        '                                sBeepSound(modPublicHT.BEEP_TYPE.A, modPublicHT.BEEP_SELECTION.NG)
        '#If Not Debug Then
        '                                fFnc_WrpMsg("E", G_CONST_MID_E3E20)
        '#End If
        '                            Case M3010_STATUS.DONE              'ณํษQฦลซฝ
        '                                gintStatus = OM_STATUS.CLSCAN
        '                                Exit Sub
        '                        End Select

        '                    Else

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

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

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

        Dim rtn As Integer
        Dim wstrEmplCode As String
        Dim wstrSecKey(2) As String
        Dim wstrSecKeyValue(2) As String
        Dim wstrCenterCode As String
        Dim wintCnt As Integer
        Dim wintCnt2 As Integer
        Dim wstrWhere As String
        Dim wstrKey(0) As String, wstrKeyValue(0) As String
        Dim sSQL As String

        fProcInput = -1

        Try

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

                mint3010status = M3010_STATUS.MENUBACK
                fProcInput = 0
                Exit Function

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

                mint3010status = M3010_STATUS.SHUTDOWN
                fProcInput = 0
                Exit Function

            ElseIf pstrInput.StartsWith("G") Then        'ๆ“ชชGศ็ฮ
                '๕๐Jnตท
                wstrSecKey(0) = "CenterCode"
                wstrSecKey(1) = "SectionID"
                wstrSecKey(2) = "Section"
                wstrSecKeyValue(0) = RTrim(Mid(pstrInput, 2, 5))
                wstrSecKeyValue(1) = RTrim(Mid(pstrInput, 7, 1))
                wstrSecKeyValue(2) = RTrim(Mid(pstrInput, 8))

                wstrWhere = ""
                wstrWhere = wstrKey(0) & " = '" & wstrKeyValue(0) & "'"
                wstrWhere &= " and " & wstrKey(1) & " = '" & wstrKeyValue(1) & "'"
                wstrWhere &= " and " & wstrKey(2) & " = '" & wstrKeyValue(2) & "'"

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

                Dim values As Dictionary(Of String, String) = New Dictionary(Of String, String)
                Dim sCenterCode As String = ""
                Dim sSectionID As String = ""
                Dim sSection As String = ""
                Dim sBhk As String = ""
                Dim sName As String = ""

                If tmpStr.Count > 0 Then

                    values = tmpStr(0)

                    Dim result As String = Nothing
                    If values.TryGetValue("CenterCode", result) Then
                        Console.WriteLine("RESULT: {0}", result)
                        sCenterCode = result
                    End If
                    If values.TryGetValue("SectionID", result) Then
                        Console.WriteLine("RESULT: {0}", result)
                        sSectionID = result
                    End If
                    If values.TryGetValue("Section", result) Then
                        Console.WriteLine("RESULT: {0}", result)
                        sSection = result
                    End If
                    If values.TryGetValue("Bhk", result) Then
                        Console.WriteLine("RESULT: {0}", result)
                        sBhk = result
                    End If
                    If values.TryGetValue("Name", result) Then
                        Console.WriteLine("RESULT: {0}", result)
                        sName = result
                    End If


                    If wstrSecKeyValue(0) = RTrim(sCenterCode) And wstrSecKeyValue(1) = RTrim(sSectionID) And wstrSecKeyValue(2) = RTrim(sSection) Then

                        gstrctKDHT.strSectionID = RTrim(sSectionID)
                        gstrctKDHT.strSection = RTrim(sSection)
                        gstrctKDPP.strCenterCode = RTrim(sCenterCode)

                        gstrctKDPP.strBhk = RTrim(sBhk)
                        gstrctKDPP.strSectionID = gstrctKDHT.strSectionID
                        gstrctKDPP.strSection = gstrctKDHT.strSection
                        gstrctKDPP.strSectionName = RTrim(sName)

                        wstrKey(0) = "HTNumber"
                        wstrKeyValue(0) = gstrctKDHT.strHdNo

                        wstrWhere = ""
                        wstrWhere = wstrKey(0) & " = '" & wstrKeyValue(0) & "'"

                        sSQL = "UPDATE " + G_CONST_TBL_HTCTRL + " SET SectionID='" _
                                                         + gstrctKDHT.strSectionID _
                                                         + "' and Section='" _
                                                         + gstrctKDHT.strSection _
                                                         + "' WHERE " + wstrWhere


                        affected_rows = dbClient.Execute(sSQL)

                        If affected_rows = 0 Then
                            Exit Function
                        End If

                        fProcInput = 0
                        mint3010status = M3010_STATUS.DONE

                    Else

                        mint3010status = M3010_STATUS.NOTEXIST
                        fProcInput = 0
                        Exit Function

                    End If


                Else

                    mint3010status = M3010_STATUS.NOTEXIST
                    fProcInput = 0
                    Exit Function


                End If


                fProcInput = 0

                Exit Function

            Else

                mint3010status = M3010_STATUS.NOTG
                fProcInput = 0
                Exit Function

            End If

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




                'wintCnt = gclsDB.fGetData(G_CONST_TBL_SECTION, G_CONST_KEY_SECTIONKEY00, wstrWhere, "SEC1")
        '        wintCnt = gclsDB.fOpenRecord(G_CONST_TBL_SECTION, G_CONST_KEY_SECTIONKEY00, "SEC1", wstrSecKey, wstrSecKeyValue, BtLib.Operation.GetEqual)

        '        If wintCnt = 0 Then
        '            With gclsDB.Records("SEC1")
        '                If wstrSecKeyValue(0) = RTrim(.Item("CenterCode")) And wstrSecKeyValue(1) = RTrim(.Item("SectionID")) And wstrSecKeyValue(2) = RTrim(.Item("Section")) Then

        '                    gstrctKDHT.strSectionID = RTrim(.Item("SectionID"))
        '                    gstrctKDHT.strSection = RTrim(.Item("Section"))
        '                    gstrctKDPP.strCenterCode = RTrim(.Item("CenterCode"))

        '                    gstrctKDPP.strBhk = RTrim(.Item("Bhk"))
        '                    gstrctKDPP.strSectionID = gstrctKDHT.strSectionID
        '                    gstrctKDPP.strSection = gstrctKDHT.strSection
        '                    gstrctKDPP.strSectionName = RTrim(.Item("Name"))

        '                    'ZNV“ฬXV
        '                    gclsDB.Setcolumn = ("SectionID,Section")                                     '“o^/XV‘ฮ—๑–ผ
        '                    gclsDB.SetData = (gstrctKDHT.strSectionID & "," & gstrctKDHT.strSection)     '“o^/XVf[^
        '                    wstrKey(0) = "HTNumber"
        '                    wstrKeyValue(0) = gstrctKDHT.strHdNo
        '                    BtLib.Transaction.BeginConCurrent()
        '                    If gclsDB.fUpdRecords(G_CONST_TBL_HTCTRL, G_CONST_KEY_HTCTRLKEY00, wstrKey, wstrKeyValue) = -1 Then
        '                        BtLib.Transaction.Abort()
        '                    End If
        '                    BtLib.Transaction.End()

        '                    fProcInput = 0
        '                    mint3010status = M3010_STATUS.DONE

        '                Else

        '                    mint3010status = M3010_STATUS.NOTEXIST
        '                    fProcInput = 0
        '                    gclsDB.fCloseRecord("SEC1")
        '                    Exit Function

        '                End If

        '            End With

        '        ElseIf wintCnt = -1 Then

        '            gclsDB.fCloseRecord("SEC1")
        '            Exit Function

        '        Else

        '            mint3010status = M3010_STATUS.NOTEXIST
        '            fProcInput = 0
        '            gclsDB.fCloseRecord("SEC1")
        '            Exit Function

        '        End If

        '        gclsDB.fCloseRecord("SEC1")
        '        fProcInput = 0

        '        Exit Function

        '    Else

        '        mint3010status = M3010_STATUS.NOTG
        '        fProcInput = 0
        '        Exit Function

        '    End If

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

    End Function

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