﻿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 frm5000
    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 WarpField1 As WarpControl.WarpField
    'Friend WithEvents wfName As WarpControl.WarpField

    '<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
    '    Me.WarpCtrl1 = New WarpControl.WarpCtrl
    '    Me.WarpFrame1 = New WarpControl.WarpFrame
    '    Me.WarpField1 = New WarpControl.WarpField
    '    Me.WarpBox1 = New WarpControl.WarpBox
    '    Me.wfName = New WarpControl.WarpField
    '    Me.WarpHWBcr1 = New WarpControl.WarpHWBcr
    '    Me.WarpFrame1.SuspendLayout()
    '    Me.SuspendLayout()
    '    '
    '    'WarpCtrl1
    '    '
    '    Me.WarpCtrl1.Location = New System.Drawing.Point(0, 0)
    '    Me.WarpCtrl1.MachineType = WarpControl.MachineLists.finpad700f
    '    Me.WarpCtrl1.Name = "WarpCtrl1"
    '    Me.WarpCtrl1.Option.CmdTimeout = 3
    '    Me.WarpCtrl1.Option.StatTimeout = 60
    '    Me.WarpCtrl1.Size = New System.Drawing.Size(50, 50)
    '    Me.WarpCtrl1.TabIndex = 0
    '    Me.WarpCtrl1.Text = "WarpCtrl1"
    '    '
    '    'WarpFrame1
    '    '
    '    Me.WarpFrame1.Controls.Add(Me.WarpField1)
    '    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 = ""
    '    '
    '    'WarpField1
    '    '
    '    Me.WarpField1.DecimalPointPosition = CType(0, Short)
    '    Me.WarpField1.Font = New System.Drawing.Font("lr SVbN", 33.5!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel)
    '    Me.WarpField1.Format = ""
    '    Me.WarpField1.InputMode.Secret = True
    '    Me.WarpField1.Length = CType(1, Short)
    '    Me.WarpField1.Location = New System.Drawing.Point(204, 156)
    '    Me.WarpField1.MacroBcr = ""
    '    Me.WarpField1.MacroIn = ""
    '    Me.WarpField1.MacroKey = ""
    '    Me.WarpField1.MacroOut = ""
    '    Me.WarpField1.Name = "WarpField1"
    '    Me.WarpField1.Size = New System.Drawing.Size(18, 36)
    '    Me.WarpField1.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, 60)
    '    Me.WarpBox1.Name = "WarpBox1"
    '    Me.WarpBox1.Size = New System.Drawing.Size(240, 24)
    '    Me.WarpBox1.TabIndex = 3
    '    '
    '    'wfName
    '    '
    '    Me.wfName.BcrFlag = True
    '    Me.wfName.DecimalPointPosition = CType(0, Short)
    '    Me.wfName.Font = New System.Drawing.Font("lr SVbN", 28.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel)
    '    Me.wfName.FontSize = WarpControl.FontSizes.Small
    '    Me.wfName.Format = ""
    '    Me.wfName.InputAttribute.Reverse = True
    '    Me.wfName.InputMode.Clear = True
    '    Me.wfName.Length = CType(12, Short)
    '    Me.wfName.Location = New System.Drawing.Point(48, 204)
    '    Me.wfName.MacroBcr = ""
    '    Me.wfName.MacroIn = ""
    '    Me.wfName.MacroKey = ""
    '    Me.wfName.MacroOut = ""
    '    Me.wfName.Name = "wfName"
    '    Me.wfName.Size = New System.Drawing.Size(180, 30)
    '    Me.wfName.TabIndex = CType(2, 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)
    '    '
    '    'frm5000
    '    '
    '    Me.AutoScaleBaseSize = New System.Drawing.Size(5, 12)
    '    Me.ClientSize = New System.Drawing.Size(240, 296)
    '    Me.Controls.Add(Me.WarpFrame1)
    '    Me.Controls.Add(Me.WarpCtrl1)
    '    Me.Font = New System.Drawing.Font("MS UI Gothic", 9.0!)
    '    Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None
    '    Me.Name = "frm5000"
    '    Me.Text = "Form1"
    '    Me.WarpFrame1.ResumeLayout(False)
    '    Me.ResumeLayout(False)

    'End Sub

#End Region


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

            rtn = fGetCountry()
            If (rtn <> 0) Then
                'WarpCtrl1.MessageBox(G_CONST_EMT_DB, G_CONST_EM_DB, MWA_DB_WARNING, MWA_DB_OK)
                MessageBox.Show(G_CONST_EM_DB, G_CONST_EMT_DB, MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1)

                gintStatus = LOCA_STATUS.QUIT
                Me.Close()
                Exit Sub
            End If

            rtn = fGetTitle()
            If (rtn = -2) Then
                fFnc_WrpMsg("E", G_CONST_MID_E5E03)
                Exit Sub
            ElseIf (rtn <> 0) Then
                'WarpCtrl1.MessageBox(G_CONST_EMT_DB, G_CONST_EM_DB, MWA_DB_WARNING, MWA_DB_OK)
                MessageBox.Show(G_CONST_EM_DB, G_CONST_EMT_DB, MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1)

                gintStatus = LOCA_STATUS.QUIT
                Me.Close()
                Exit Sub
            End If

            If (Not gstrctKDHT.strUserNo Is Nothing) Then
                rtn = fGetEmplName(gstrctKDHT.strUserNo)
                If (rtn = 0) Then
                    '###(2017/01/26 T. SHIMOKUBO)### UPD_ST [—v–]‘ฮ]
                    'gintStatus = LOCA_STATUS.LOCATION
                    gintStatus = LOCA_STATUS.NAME
                    Me.Close()
                    '###(2017/01/26 T. SHIMOKUBO)### UPD_ED [—v–]‘ฮ]
                ElseIf (rtn = -1) Then
                    'WarpCtrl1.MessageBox(G_CONST_EMT_DB, G_CONST_EM_DB, MWA_DB_WARNING, MWA_DB_OK)
                    MessageBox.Show(G_CONST_EM_DB, G_CONST_EMT_DB, MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1)

                    gintStatus = LOCA_STATUS.QUIT
                    Me.Close()
                    Exit Sub
                ElseIf (rtn = -2) Then
                    gintStatus = LOCA_STATUS.NAME
                    Me.Close()
                End If
            Else
                gintStatus = LOCA_STATUS.NAME
                Me.Close()
            End If

            ' tH[€EC“ ภs
            'sMain()

            Exit Sub

        Catch ex As Exception
            gintStatus = LOCA_STATUS.QUIT
            sErrLog(gAppName, "frm5000_Load", ex.ToString)
            Me.Close()
        End Try

    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(WarpField1)


        '        If WKey = WKY_ENT Then

        '            gintStatus = LOCA_STATUS.NAME
        '            Exit Do

        '        ElseIf WKey = WKY_F1 Then

        '        ElseIf WKey = WKY_F2 Then

        '        ElseIf WKey = WKY_ERROR Then

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

    End Sub

    '<StructLayout(LayoutKind.Sequential, pack:=4)> _
    Public Structure MWA_STARTUP
        <MarshalAs(UnmanagedType.ByValTStr, SizeConst:=17)> _
        Public term_dev As String

        <MarshalAs(UnmanagedType.ByValTStr, SizeConst:=17)> _
        Public proc_dev As String

        <MarshalAs(UnmanagedType.ByValTStr, SizeConst:=4097)> _
        Public proc_path As String
    End Structure

    '/*
    '|| ึ”–ผFfGetCountry
    '|| T—v  F‘R[hๆ“พ
    '*/
    Private Function fGetCountry() As Integer

        '’[––IDm”F•‘บฐฤ“—อ
        Dim si As New MWA_STARTUP
        Dim wintCnt As Integer
        Dim wstrWhere As String
        Dim wstrCount As String
        Dim wstrUserNo As String
        Dim wstrKeyFlg As String
        Dim wstrKey(0) As String, wstrKeyValue(0) As String
        Dim sSQL As String

        fGetCountry = -1

        Try

            'WarpCtrl1.GetStartupInfo(si)

            gstrctKDHT.strHdNo = si.term_dev      ' ’[––IDl“พ

            'BtLib.Transaction.Begin()

            wstrWhere = ""
            wstrWhere = "HTNumber" & " = '" & gstrctKDHT.strHdNo & "'"


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

            Dim values As Dictionary(Of String, String) = New Dictionary(Of String, String)
            Dim sCountry As String = ""
            Dim sEmplCode As String = ""
            Dim sSectionID As String = ""
            Dim sSection As String = ""
            Dim sCstmid As String = ""
            Dim sCstmCode As String = ""
            Dim sPackType As String = ""
            Dim sS6030 As String = ""
            Dim sSearchKey As String = ""


            If tmpStr.Count > 0 Then
                values = tmpStr(0)
                Dim result As String = Nothing
                If values.TryGetValue("Country", result) Then
                    sCountry = RTrim(result)
                    Console.WriteLine("RESULT: {0}", result)
                End If
                If values.TryGetValue("EmplCode", result) Then
                    sEmplCode = RTrim(result)
                    Console.WriteLine("RESULT: {0}", result)
                End If
                If values.TryGetValue("SectionID", result) Then
                    sSectionID = RTrim(result)
                    Console.WriteLine("RESULT: {0}", result)
                End If
                If values.TryGetValue("Section", result) Then
                    sSection = RTrim(result)
                    Console.WriteLine("RESULT: {0}", result)
                End If
                If values.TryGetValue("Cstmid", result) Then
                    sCstmid = RTrim(result)
                    Console.WriteLine("RESULT: {0}", result)
                End If
                If values.TryGetValue("CstmCode", result) Then
                    sCstmCode = RTrim(result)
                    Console.WriteLine("RESULT: {0}", result)
                End If
                If values.TryGetValue("PackType", result) Then
                    sPackType = RTrim(result)
                    Console.WriteLine("RESULT: {0}", result)
                End If
                If values.TryGetValue("S6030", result) Then
                    sS6030 = RTrim(result)
                    Console.WriteLine("RESULT: {0}", result)
                End If
                If values.TryGetValue("SearchKey", result) Then
                    sSearchKey = RTrim(result)
                    Console.WriteLine("RESULT: {0}", result)
                End If

                wstrCount = fstrZeroput(3, sCountry)    '‘OZero–฿
                wstrUserNo = sEmplCode
                gstrctKDHT.strSectionID = sSectionID
                gstrctKDHT.strSection = sSection
                gstrctKDHT.strCstmid = sCstmid
                gstrctKDHT.strCstmCode = sCstmCode
                gstrctKDHT.strPackType = sPackType
                'gstrctKDHT.strS6030 = sS6030
                ''gstrctKDPL.initialize()
                'gstrctKDPL.strSectionID = RTrim(sSectionID)
                'gstrctKDPL.strSection = RTrim(sSection)
                'gstrctKDPL.strSearchKey = RTrim(sSearchKey)

                If wstrCount <> "000" Then        '‘บฐฤช“—อณ๊ฤข้

                    gstrctKDHT.strCountry = wstrCount
                    gstrctKDHT.strUserNo = wstrUserNo
                    fGetCountry = 0
                    Exit Function

                ElseIf wstrCount = "000" Then     '‘บฐฤช“—อณ๊ฤขศฏ๊ฮ"001"๐“—อท้

                    wstrCount = "001"
                    wstrKeyFlg = "0"

                End If


            Else

                wstrCount = "001"
                wstrKeyFlg = "1"


            End If

            gstrctKDHT.strCountry = "001"

            Select Case wstrKeyFlg

                Case "0"        'XVรฐภ

                    'gclsDB.Setcolumn = ("Country")          '“o^/XV‘ฮ—๑–ผ
                    'gclsDB.SetData = (gstrctKDHT.strCountry)      '“o^/XVf[^

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

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


                    sSQL = "UPDATE " + G_CONST_TBL_HTCTRL + " SET Country='" _
                                                         + gstrctKDHT.strCountry _
                                                         + "' WHERE " + wstrWhere

                    affected_rows = dbClient.Execute(sSQL)




                Case "1"        'VKรฐภ

                    sSQL = "INSERT INTO " & G_CONST_TBL_HTCTRL & " (HTNumber,Country) VALUES ('" _
                            & gstrctKDHT.strHdNo & "','" & gstrctKDHT.strCountry & "')"

                    affected_rows = dbClient.Execute(sSQL)

                    'gclsDB.Setcolumn = ("HTNumber,Country")          '“o^/XV‘ฮ—๑–ผ
                    'gclsDB.SetData = (gstrctKDHT.strHdNo & "," & gstrctKDHT.strCountry)      '“o^/XVf[^

                    'If gclsDB.fInsRecord(G_CONST_TBL_HTCTRL) = -1 Then
                    '    BtLib.Transaction.Abort()

                    'End If

            End Select


            fGetCountry = 0

            Exit Function

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




        '    wstrWhere = ""
        '    wstrWhere = "@HTNumber = " & gstrctKDHT.strHdNo
        '    wintCnt = gclsDB.fGetData(G_CONST_TBL_HTCTRL, G_CONST_KEY_HTCTRLKEY00, wstrWhere, "HTCTRL1")

        '    If wintCnt > 0 Then             'รฐภช ๊ฮ‘บฐฤ๐๕

        '        With gclsDB.Extended("HTCTRL1")

        '            wstrCount = fstrZeroput(3, .Item("Country"))    '‘OZero–฿
        '            wstrUserNo = .Item("EmplCode")
        '            gstrctKDHT.strSectionID = .Item("SectionID")
        '            gstrctKDHT.strSection = .Item("Section")
        '            gstrctKDHT.strCstmid = .Item("Cstmid")
        '            gstrctKDHT.strCstmCode = .Item("CstmCode")
        '            gstrctKDHT.strPackType = .Item("PackType")

        '            If wstrCount <> "000" Then        '‘บฐฤช“—อณ๊ฤข้

        '                gstrctKDHT.strCountry = wstrCount
        '                gstrctKDHT.strUserNo = wstrUserNo
        '                gclsDB.fCloseRecord("HTCTRL1")
        '                fGetCountry = 0
        '                Exit Function

        '            ElseIf wstrCount = "000" Then     '‘บฐฤช“—อณ๊ฤขศฏ๊ฮ"001"๐“—อท้

        '                wstrCount = "001"
        '                wstrKeyFlg = "0"

        '            End If
        '        End With

        '    ElseIf wintCnt = 0 Then       'รฐภชศฏ๊ฮ’[––”ิE‘บฐฤ("001")๐’วมท้

        '        With gclsDB.Extended("HTCTRL1")
        '            wstrCount = "001"
        '            wstrKeyFlg = "1"
        '        End With

        '    ElseIf wintCnt = -1 Then

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

        '    End If

        '    gclsDB.fCloseRecord("HTCTRL1")

        '    'XVรฐภAVKรฐภ๐DBษ“o^
        '    gstrctKDHT.strCountry = "001"
        '    Select Case wstrKeyFlg

        '        Case "0"        'XVรฐภ

        '            gclsDB.Setcolumn = ("Country")          '“o^/XV‘ฮ—๑–ผ
        '            gclsDB.SetData = (gstrctKDHT.strCountry)      '“o^/XVf[^

        '            wstrKey(0) = "HTNumber"
        '            wstrKeyValue(0) = gstrctKDHT.strHdNo
        '            If gclsDB.fUpdRecords(G_CONST_TBL_HTCTRL, G_CONST_KEY_HTCTRLKEY00, wstrKey, wstrKeyValue) = -1 Then
        '                BtLib.Transaction.Abort()

        '            End If

        '        Case "1"        'VKรฐภ
        '            gclsDB.Setcolumn = ("HTNumber,Country")          '“o^/XV‘ฮ—๑–ผ
        '            gclsDB.SetData = (gstrctKDHT.strHdNo & "," & gstrctKDHT.strCountry)      '“o^/XVf[^

        '            If gclsDB.fInsRecord(G_CONST_TBL_HTCTRL) = -1 Then
        '                BtLib.Transaction.Abort()

        '            End If

        '    End Select

        '    BtLib.Transaction.End()

        '    fGetCountry = 0

        '    Exit Function

        'Catch ex As Exception
        '    BtLib.Transaction.Abort()
        '    sErrLog(gAppName, "fGetCountry", ex.ToString)
        'End Try

    End Function


    '/*
    '|| ึ”–ผFfGetTitle
    '|| T—v  F^CgR[hๆ“พ
    '*/
    Private Function fGetTitle() As Integer

        Dim wstrWhere As String
        Dim wstrCount As String
        Dim wintCnt As Integer
        Dim wstrKey(0) As String, wstrKeyValue(0) As String
        Dim sSQL As String

        fGetTitle = -1

        Try

            'BtLib.Transaction.Begin()

            wstrWhere = ""
            wstrWhere = "Country" & " = '" & gstrctKDHT.strCountry & "'"
            wstrWhere &= " and " & "PrgID" & " = '" & gstrctKDHT.strPrgID & "'"

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

            Dim values As Dictionary(Of String, String) = New Dictionary(Of String, String)
            Dim sTitle As String = ""

            If tmpStr.Count > 0 Then
                values = tmpStr(0)
                Dim result As String = Nothing
                If values.TryGetValue("Title", result) Then
                    sTitle = RTrim(result)
                End If

                gstrctKDHT.strTitle = sTitle

            Else
                fGetTitle = -2

                Exit Function

            End If

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

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

            sSQL = "UPDATE " + G_CONST_TBL_HTCTRL + " SET ExeName='" _
                                                         + gstrctKDHT.strPrgID _
                                                         + "' WHERE " + wstrWhere

            affected_rows = dbClient.Execute(sSQL)


            fGetTitle = 0

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




        '    wstrWhere = ""
        '    wstrWhere = "@Country = " & gstrctKDHT.strCountry
        '    wstrWhere &= " & @PrgID = " & gstrctKDHT.strPrgID

        '    wintCnt = gclsDB.fGetData(G_CONST_TBL_HTTITLE, G_CONST_KEY_HTTITLEKEY00, wstrWhere, "TITLE1")

        '    If wintCnt > 0 Then

        '        gstrctKDHT.strTitle = gclsDB.Extended("TITLE1").Item("Title")

        '    ElseIf wintCnt = 0 Then
        '        gclsDB.fCloseRecord("TITLE1")
        '        fGetTitle = -2
        '        Exit Function

        '    ElseIf wintCnt = -1 Then
        '        gclsDB.fCloseRecord("TITLE1")
        '        fGetTitle = -1
        '        Exit Function

        '    End If

        '    gclsDB.fCloseRecord("TITLE1")

        '    gclsDB.Setcolumn = ("ExeName")              '“o^/XV‘ฮ—๑–ผ
        '    gclsDB.SetData = (gstrctKDHT.strPrgID)     '“o^/XVf[^

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

        '    If gclsDB.fUpdRecords(G_CONST_TBL_HTCTRL, G_CONST_KEY_HTCTRLKEY00, wstrKey, wstrKeyValue) = -1 Then
        '        BtLib.Transaction.Abort()

        '    End If

        '    BtLib.Transaction.End()

        '    fGetTitle = 0

        'Catch ex As Exception
        '    BtLib.Transaction.Abort()
        '    sErrLog(gAppName, "fGetTitle", ex.ToString)
        'End Try

    End Function


    '/*
    '|| ึ”–ผFfGetEmplName
    '|| T—v  F์ฦา–ผๆ“พ
    '*/
    Private Function fGetEmplName(ByVal pstrUserNo As String) As Integer

        Dim rtn As Integer
        Dim wstrWhere As String
        Dim wintCnt As Integer

        fGetEmplName = -1

        Try

            wstrWhere = ""
            wstrWhere = "EmplCode" & " = '" & pstrUserNo & "'"

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

            Dim values As Dictionary(Of String, String) = New Dictionary(Of String, String)
            Dim sEmplName As String = ""

            If tmpStr.Count > 0 Then

                values = tmpStr(0)

                Dim result As String = Nothing
                If values.TryGetValue("EmplName", result) Then
                    sEmplName = RTrim(result)
                End If

                gstrctKDHT.strUserName = sEmplName

            Else

                fGetEmplName = -2
                Exit Function

            End If

            fGetEmplName = 0

            Exit Function

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


            '๕๐Jnตท
        '    wstrWhere = ""
        '    wstrWhere = "@EmplCode = " & pstrUserNo

        '    wintCnt = gclsDB.fGetData(G_CONST_TBL_PICSUSER, G_CONST_KEY_PICSUSERKEY00, wstrWhere, "USER1")
        '    If wintCnt > 0 Then

        '        gstrctKDHT.strUserName = gclsDB.Extended("USER1").Item("EmplName")

        '    ElseIf wintCnt = 0 Then

        '        fGetEmplName = -2
        '        gclsDB.fCloseRecord("USER1")
        '        Exit Function

        '    ElseIf wintCnt = -1 Then

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

        '    End If

        '    gclsDB.fCloseRecord("USER1")
        '    fGetEmplName = 0

        '    Exit Function

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

    End Function

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