VERSION 5.00
Object = "{7DEE6B45-AD1E-423B-BD71-12E477844358}#1.0#0"; "NeoRF13Ocxs.ocx"
Object = "{5E9E78A0-531B-11CF-91F6-C2863C385E30}#1.0#0"; "MSFLXGRD.OCX"
Begin VB.Form frmMain 
   Caption         =   "KIT Attendance Manager"
   ClientHeight    =   7710
   ClientLeft      =   120
   ClientTop       =   450
   ClientWidth     =   7575
   LinkTopic       =   "Form1"
   ScaleHeight     =   7710
   ScaleWidth      =   7575
   StartUpPosition =   3  'Windows 기본값
   Begin NeoRF13Ocxs.NeoRF13Ocx NeoRF13Ocx1 
      Height          =   495
      Left            =   0
      TabIndex        =   2
      Top             =   -120
      Width           =   1095
      Object.Visible         =   -1  'True
      AutoScroll      =   0   'False
      AutoSize        =   0   'False
      AxBorderStyle   =   0
      Caption         =   "NeoRF13Ocx"
      Color           =   -16777201
      BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
         Name            =   "MS Sans Serif"
         Size            =   8.25
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      KeyPreview      =   0   'False
      PixelsPerInch   =   96
      PrintScale      =   1
      Scaled          =   -1  'True
      DropTarget      =   0   'False
      HelpFile        =   ""
      ScreenSnap      =   0   'False
      SnapBuffer      =   10
      DoubleBuffered  =   0   'False
      Enabled         =   -1  'True
   End
   Begin MSFlexGridLib.MSFlexGrid grdData 
      Height          =   855
      Left            =   120
      TabIndex        =   19
      Top             =   3480
      Width           =   7335
      _ExtentX        =   12938
      _ExtentY        =   1508
      _Version        =   393216
      Cols            =   37
      FixedCols       =   0
      AllowUserResizing=   1
      FormatString    =   ""
   End
   Begin VB.CommandButton btnCheckOut 
      Caption         =   "퇴    실"
      Height          =   375
      Left            =   5760
      TabIndex        =   17
      Top             =   2760
      Width           =   1695
   End
   Begin VB.CommandButton btnCheckIn 
      Caption         =   "입    실"
      Height          =   375
      Left            =   5760
      TabIndex        =   16
      Top             =   2280
      Width           =   1695
   End
   Begin VB.CommandButton btnLoadInfo 
      Caption         =   "Load Info."
      Height          =   375
      Left            =   5760
      TabIndex        =   15
      Top             =   1080
      Width           =   1695
   End
   Begin VB.CommandButton btnMainReadUID 
      Caption         =   "Read UID"
      Height          =   375
      Left            =   5760
      TabIndex        =   9
      Top             =   600
      Width           =   1695
   End
   Begin VB.CommandButton btnExit 
      Caption         =   "EXIT"
      Height          =   495
      Left            =   5760
      TabIndex        =   8
      Top             =   6720
      Width           =   1695
   End
   Begin VB.TextBox txtMainOutTIme 
      Enabled         =   0   'False
      Height          =   375
      Left            =   1200
      TabIndex        =   7
      Top             =   2760
      Width           =   3735
   End
   Begin VB.TextBox txtMainInTime 
      Enabled         =   0   'False
      Height          =   375
      Left            =   1200
      TabIndex        =   6
      Top             =   2280
      Width           =   3735
   End
   Begin VB.TextBox txtMainName 
      Enabled         =   0   'False
      Height          =   375
      Left            =   1200
      TabIndex        =   5
      Top             =   1560
      Width           =   3735
   End
   Begin VB.TextBox txtMainUID 
      BackColor       =   &H80000000&
      Enabled         =   0   'False
      Height          =   375
      Left            =   1200
      TabIndex        =   4
      Top             =   600
      Width           =   3735
   End
   Begin VB.TextBox txtMainStdNo 
      Enabled         =   0   'False
      Height          =   375
      Left            =   1200
      TabIndex        =   3
      Top             =   1080
      Width           =   3735
   End
   Begin VB.CommandButton btnAddField 
      Caption         =   "AddField"
      Height          =   495
      Left            =   2160
      TabIndex        =   1
      Top             =   6720
      Width           =   1695
   End
   Begin VB.CommandButton btnRegist 
      Caption         =   "Regist Students"
      Height          =   495
      Left            =   240
      TabIndex        =   0
      Top             =   6720
      Width           =   1695
   End
   Begin VB.Frame Frame1 
      Caption         =   "Management"
      Height          =   1335
      Left            =   120
      TabIndex        =   18
      Top             =   6240
      Width           =   3975
   End
   Begin VB.Label lbMainOut 
      Alignment       =   1  '오른쪽 맞춤
      Caption         =   "퇴실시간"
      Height          =   255
      Left            =   240
      TabIndex        =   14
      Top             =   2760
      Width           =   855
   End
   Begin VB.Label lbMainIn 
      Alignment       =   1  '오른쪽 맞춤
      Caption         =   "입실시간"
      Height          =   255
      Left            =   240
      TabIndex        =   13
      Top             =   2280
      Width           =   855
   End
   Begin VB.Label lbMainUID 
      Alignment       =   1  '오른쪽 맞춤
      Caption         =   "UID"
      Height          =   255
      Left            =   720
      TabIndex        =   12
      Top             =   600
      Width           =   375
   End
   Begin VB.Label lbMainName 
      Alignment       =   1  '오른쪽 맞춤
      Caption         =   "성   명"
      Height          =   255
      Left            =   480
      TabIndex        =   11
      Top             =   1560
      Width           =   615
   End
   Begin VB.Label lbMainStdNum 
      Alignment       =   1  '오른쪽 맞춤
      Caption         =   "학   번"
      Height          =   255
      Left            =   480
      TabIndex        =   10
      Top             =   1080
      Width           =   615
   End
End
Attribute VB_Name = "frmMain"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim strTodayDate As String


Private Sub btnAddField_Click()
    If DBOpen = False Then
        MsgBox "Db Connection Failed.", vbExclamation, "Db Connection"
        Call DBClose
        End
    End If
    
    Dim sSql As String
    Dim msg
    Dim AddFieldName_1 As String
    Dim AddFieldName_2 As String
    
    strTodayDate = Format(Now, "yyyymmdd")
    
    AddFieldName_1 = strTodayDate & "_In"
    sSql = "ALTER TABLE KIT_ATT_DB ADD COLUMN " & AddFieldName_1 & " Text(255)"
    Call Execute_SQL(sSql)
    
    AddFieldName_2 = strTodayDate & "_Out"
    sSql = "ALTER TABLE KIT_ATT_DB ADD COLUMN " & AddFieldName_2 & " Text(255)"
    Call Execute_SQL(sSql)
    
    Call RsClose
    Call DBClose
    
End Sub

Private Sub btnCheckIn_Click()
    Dim TimeIn As String
    
    strTodayDate = Format(Now, "yyyymmdd")
    
    TimeIn = strTodayDate & "_In"
    
    strInTime = Format(Now, "yyyy-mm-dd-hh:mm:ss")
    
    If DBOpen = False Then
        MsgBox "Db Connection Failed.", vbExclamation, "Db Connection"
        Call DBClose
        End
    End If
    
    Dim sSql As String
    Dim sAddItem As String
    Dim iRow As Double
    Dim i As Integer
   
    txtMainInTime.Text = strInTime
    
    sSql = "SELECT * FROM KIT_ATT_DB WHERE strUID = '" & txtMainUID.Text & "'"
    Call Execute_SQL(sSql)
    If sSQLSuccess = False Then Exit Sub
    If Rs.RecordCount <= 0 Then
        MsgBox "학생 정보가 없습니다. 먼저 등록을 하세요.", vbInformation, "검색"
        Exit Sub
    Else
        sSql = "UPDATE KIT_ATT_DB SET " & _
        TimeIn & "='" & strInTime & "'" & _
        "where strUID = '" & txtMainUID.Text & "'"
        Call Execute_SQL(sSql)
        If sSQLSuccess = True Then
            MsgBox "입실처리 되었습니다.", vbInformation, "수정"
        End If
    End If
    
    
    Call RsClose
    Call DBClose
    
    Call GetData

End Sub

Private Sub btnRegExit_Click()
    Unload Me
End Sub

Private Sub btnRegReadUID_Click()
    txtRegStdNo.Text = ""
    txtRegName.Text = ""
    txtRegAddr.Text = ""
    txtRegPhone.Text = ""
    Call NeoRF13Ocx1.UID_Read
    
End Sub

Private Sub btnRegRegist_Click()
    If DBOpen = False Then
        MsgBox "Db Connection Failed.", vbExclamation, "Db Connection"
        Call DBClose
        End
    End If
    
    Dim sSql As String
    Dim msg
    Dim sDate As String
    
           
    
    If txtMainStdNo.Text = "" Then
        MsgBox "학번을 입력하세요.", vbInformation, "등록"
        Exit Sub
    End If
    If txtMainName.Text = "" Then
        MsgBox "이름을 입력하세요.", vbInformation, "등록"
        Exit Sub
    End If

    sSql = "SELECT * FROM KIT_ATT_DB WHERE strUID = '" & txtMainUID.Text & "'"
    Call Execute_SQL(sSql)
    If sSQLSuccess = False Then Exit Sub
    If Rs.RecordCount <= 0 Then
        msg = MsgBox("등록하시겠습니까?", vbQuestion + vbYesNo, "등록")
        If msg = vbNo Then Exit Sub
        
        sDate = Format(Now, "yyyy-mm-dd-hh:mm:ss")
        sSql = "INSERT INTO KIT_ATT_DB (strUID, strStdNumber, strName, strPhone, strAddress, strDate) VALUES('" & _
        txtRegUID.Text & "','" & _
        txtRegStdNo.Text & "','" & _
        txtRegName.Text & "','" & _
        txtRegPhone.Text & "','" & _
        txtRegAddr.Text & "','" & _
        sDate & "'" & _
        ")"
                
        Call Execute_SQL(sSql)
        If sSQLSuccess = True Then
            MsgBox "등록되었습니다.", vbInformation, "등록"
        End If
    End If
    
    
    Call RsClose
    Call DBClose
End Sub

Private Sub btnCheckOut_Click()
    Dim TimeOut As String
    
    strTodayDate = Format(Now, "yyyymmdd")
    
    TimeOut = strTodayDate & "_Out"
    
    strOutTime = Format(Now, "yyyy-mm-dd-hh:mm:ss")
    
    If DBOpen = False Then
        MsgBox "Db Connection Failed.", vbExclamation, "Db Connection"
        Call DBClose
        End
    End If
    
    Dim sSql As String
    Dim sAddItem As String
    Dim iRow As Double
    Dim i As Integer
   
    txtMainOutTIme.Text = strOutTime
    
    sSql = "SELECT * FROM KIT_ATT_DB WHERE strUID = '" & txtMainUID.Text & "'"
    Call Execute_SQL(sSql)
    If sSQLSuccess = False Then Exit Sub
    If Rs.RecordCount <= 0 Then
        MsgBox "학생 정보가 없습니다. 먼저 등록을 하세요.", vbInformation, "검색"
        Exit Sub
    Else
        sSql = "UPDATE KIT_ATT_DB SET " & _
        TimeOut & "='" & strOutTime & "'" & _
        "where strUID = '" & txtMainUID.Text & "'"
        Call Execute_SQL(sSql)
        If sSQLSuccess = True Then
            MsgBox "퇴실처리 되었습니다.", vbInformation, "수정"
        End If
    End If
    
    
    Call RsClose
    Call DBClose
    
    Call GetData
End Sub

Private Sub btnExit_Click()
    Unload Me
End Sub

Private Sub btnLoadInfo_Click()
    Call GetData
End Sub

Private Sub btnMainReadUID_Click()
    txtMainStdNo.Text = ""
    txtMainName.Text = ""
    txtMainInTime.Text = ""
    txtMainOutTIme.Text = ""
    
    Call NeoRF13Ocx1.UID_Read
End Sub

Private Sub btnRegist_Click()
    Load frmRegist
    
    frmRegist.Show
    
End Sub

Private Sub NeoRF13Ocx1_OnData(ByVal sData As String)
    txtMainUID.Text = sData
End Sub

Sub GetData()

    If DBOpen = False Then
        MsgBox "Db Connection Failed.", vbExclamation, "Db Connection"
        Call DBClose
        End
    End If
    
    Dim sSql As String
    Dim sAddItem As String
    Dim iRow As Double
    Dim i As Integer
    Dim strItem As String
    
    strItem = ""
       
    sSql = "SELECT * FROM KIT_ATT_DB WHERE strUID = '" & txtMainUID.Text & "'"
    Call Execute_SQL(sSql)
    If sSQLSuccess = False Then Exit Sub
    If Rs.RecordCount <= 0 Then
        MsgBox "검색 결과가 없습니다.", vbInformation, "검색"
        Exit Sub
    Else
        Rs.MoveFirst
            
        txtMainStdNo.Text = Rs.Fields(2)
        txtMainName.Text = Rs.Fields(3)
'        txtRegPhone.Text = Rs.Fields(4)
'        txtRegAddr.Text = Rs.Fields(5)

        Do While Not Rs.EOF
            On Error Resume Next
            sAddItem = ""
            For i = 0 To Rs.Fields.Count - 1
                grdData.ColWidth(i) = 2000
                grdData.ColAlignment(i) = 4
                grdData.TextMatrix(0, i) = Rs.Fields(i + 1).Name
                grdData.TextMatrix(1, i) = Rs.Fields(i + 1)
            Next
            Rs.MoveNext
        Loop
        
    End If
    
    
    Call RsClose
    Call DBClose

End Sub
