VERSION 5.00
Object = "{86CF1D34-0C5F-11D2-A9FC-0000F8754DA1}#2.0#0"; "MSCOMCT2.OCX"
Begin VB.Form frmholiday 
   Caption         =   "Form1"
   ClientHeight    =   5880
   ClientLeft      =   60
   ClientTop       =   450
   ClientWidth     =   6555
   LinkTopic       =   "Form1"
   ScaleHeight     =   5880
   ScaleWidth      =   6555
   StartUpPosition =   2  'ÆÁÄ»ÖÐÐÄ
   Begin VB.CommandButton cmdDelete 
      Caption         =   "Delete"
      Height          =   495
      Left            =   2280
      TabIndex        =   37
      Top             =   5160
      Width           =   1215
   End
   Begin VB.CommandButton cmdclean 
      Caption         =   "Clean"
      Height          =   495
      Left            =   3720
      TabIndex        =   36
      Top             =   5160
      Width           =   1215
   End
   Begin VB.CommandButton cmdRead 
      Caption         =   "Read"
      Height          =   510
      Left            =   120
      TabIndex        =   34
      Top             =   5160
      Width           =   1005
   End
   Begin VB.CommandButton cmdWrite 
      Caption         =   "Write"
      Height          =   510
      Left            =   1200
      TabIndex        =   33
      Top             =   5160
      Width           =   885
   End
   Begin VB.CommandButton cmdExit 
      Caption         =   "Exit"
      Height          =   510
      Left            =   5040
      TabIndex        =   32
      Top             =   5160
      Width           =   1485
   End
   Begin VB.Frame Frame1 
      Caption         =   "enroll id"
      Height          =   3015
      Left            =   120
      TabIndex        =   11
      Top             =   2040
      Width           =   6375
      Begin VB.TextBox txtEnrollnumber 
         Height          =   375
         Index           =   19
         Left            =   4800
         TabIndex        =   31
         Text            =   "20"
         Top             =   2040
         Width           =   975
      End
      Begin VB.TextBox txtEnrollnumber 
         Height          =   375
         Index           =   18
         Left            =   3720
         TabIndex        =   30
         Text            =   "19"
         Top             =   2040
         Width           =   975
      End
      Begin VB.TextBox txtEnrollnumber 
         Height          =   375
         Index           =   17
         Left            =   2520
         TabIndex        =   29
         Text            =   "18"
         Top             =   2040
         Width           =   975
      End
      Begin VB.TextBox txtEnrollnumber 
         Height          =   375
         Index           =   16
         Left            =   1320
         TabIndex        =   28
         Text            =   "17"
         Top             =   2040
         Width           =   975
      End
      Begin VB.TextBox txtEnrollnumber 
         Height          =   375
         Index           =   15
         Left            =   120
         TabIndex        =   27
         Text            =   "15"
         Top             =   2040
         Width           =   975
      End
      Begin VB.TextBox txtEnrollnumber 
         Height          =   375
         Index           =   14
         Left            =   4800
         TabIndex        =   26
         Text            =   "15"
         Top             =   1560
         Width           =   975
      End
      Begin VB.TextBox txtEnrollnumber 
         Height          =   375
         Index           =   13
         Left            =   3720
         TabIndex        =   25
         Text            =   "14"
         Top             =   1560
         Width           =   975
      End
      Begin VB.TextBox txtEnrollnumber 
         Height          =   375
         Index           =   12
         Left            =   2520
         TabIndex        =   24
         Text            =   "13"
         Top             =   1560
         Width           =   975
      End
      Begin VB.TextBox txtEnrollnumber 
         Height          =   375
         Index           =   11
         Left            =   1320
         TabIndex        =   23
         Text            =   "12"
         Top             =   1560
         Width           =   975
      End
      Begin VB.TextBox txtEnrollnumber 
         Height          =   375
         Index           =   10
         Left            =   120
         TabIndex        =   22
         Text            =   "11"
         Top             =   1560
         Width           =   975
      End
      Begin VB.TextBox txtEnrollnumber 
         Height          =   375
         Index           =   9
         Left            =   4800
         TabIndex        =   21
         Text            =   "10"
         Top             =   960
         Width           =   975
      End
      Begin VB.TextBox txtEnrollnumber 
         Height          =   375
         Index           =   8
         Left            =   3720
         TabIndex        =   20
         Text            =   "9"
         Top             =   960
         Width           =   975
      End
      Begin VB.TextBox txtEnrollnumber 
         Height          =   375
         Index           =   7
         Left            =   2520
         TabIndex        =   19
         Text            =   "8"
         Top             =   960
         Width           =   975
      End
      Begin VB.TextBox txtEnrollnumber 
         Height          =   375
         Index           =   6
         Left            =   1320
         TabIndex        =   18
         Text            =   "7"
         Top             =   960
         Width           =   975
      End
      Begin VB.TextBox txtEnrollnumber 
         Height          =   375
         Index           =   5
         Left            =   120
         TabIndex        =   17
         Text            =   "6"
         Top             =   960
         Width           =   975
      End
      Begin VB.TextBox txtEnrollnumber 
         Height          =   375
         Index           =   4
         Left            =   4800
         TabIndex        =   16
         Text            =   "5"
         Top             =   360
         Width           =   975
      End
      Begin VB.TextBox txtEnrollnumber 
         Height          =   375
         Index           =   3
         Left            =   3720
         TabIndex        =   15
         Text            =   "4"
         Top             =   360
         Width           =   975
      End
      Begin VB.TextBox txtEnrollnumber 
         Height          =   375
         Index           =   2
         Left            =   2520
         TabIndex        =   14
         Text            =   "3"
         Top             =   360
         Width           =   975
      End
      Begin VB.TextBox txtEnrollnumber 
         Height          =   375
         Index           =   1
         Left            =   1320
         TabIndex        =   13
         Text            =   "2"
         Top             =   360
         Width           =   975
      End
      Begin VB.TextBox txtEnrollnumber 
         Height          =   375
         Index           =   0
         Left            =   120
         TabIndex        =   12
         Text            =   "1"
         Top             =   360
         Width           =   975
      End
      Begin VB.Label Label2 
         Caption         =   "enroll id, those id users on this holiday can access ,others can not;max 3000 users"
         Height          =   375
         Left            =   1200
         TabIndex        =   35
         Top             =   2520
         Width           =   3975
      End
   End
   Begin VB.TextBox txtaccessidcount 
      Height          =   375
      Left            =   1800
      TabIndex        =   9
      Text            =   "20"
      Top             =   1560
      Width           =   975
   End
   Begin VB.TextBox txtName 
      BeginProperty Font 
         Name            =   "Courier New"
         Size            =   10.5
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   405
      Left            =   840
      MaxLength       =   32
      TabIndex        =   1
      Text            =   "Children's day"
      Top             =   840
      Width           =   2175
   End
   Begin VB.ComboBox cmbholidayindex 
      Height          =   300
      ItemData        =   "frmholiday.frx":0000
      Left            =   840
      List            =   "frmholiday.frx":005E
      TabIndex        =   0
      Text            =   "0"
      Top             =   480
      Width           =   735
   End
   Begin MSComCtl2.DTPicker dtpEnddate 
      Height          =   375
      Left            =   4560
      TabIndex        =   5
      Top             =   960
      Width           =   1575
      _ExtentX        =   2778
      _ExtentY        =   661
      _Version        =   393216
      Format          =   21430273
      CurrentDate     =   43360
   End
   Begin MSComCtl2.DTPicker dtpStartdate 
      Height          =   375
      Left            =   4560
      TabIndex        =   6
      Top             =   480
      Width           =   1575
      _ExtentX        =   2778
      _ExtentY        =   661
      _Version        =   393216
      Format          =   21430273
      CurrentDate     =   43360
   End
   Begin VB.Label Label3 
      Caption         =   "can set0~3000,but less 20 for demo"
      Height          =   375
      Left            =   2880
      TabIndex        =   38
      Top             =   1560
      Width           =   3135
   End
   Begin VB.Label Label1 
      Caption         =   "ACCESS ID COUNT:"
      Height          =   255
      Left            =   120
      TabIndex        =   10
      Top             =   1680
      Width           =   1575
   End
   Begin VB.Label Label11 
      Caption         =   "Start date:"
      Height          =   255
      Left            =   3480
      TabIndex        =   8
      Top             =   480
      Width           =   1095
   End
   Begin VB.Label Label12 
      Caption         =   "End date:"
      Height          =   255
      Left            =   3600
      TabIndex        =   7
      Top             =   960
      Width           =   855
   End
   Begin VB.Label lblMessage 
      Alignment       =   2  'Center
      BorderStyle     =   1  'Fixed Single
      Caption         =   "Message"
      BeginProperty Font 
         Name            =   "Times New Roman"
         Size            =   14.25
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   420
      Left            =   0
      TabIndex        =   4
      Top             =   0
      Width           =   6240
   End
   Begin VB.Label Label7 
      Caption         =   "index"
      Height          =   255
      Index           =   1
      Left            =   120
      TabIndex        =   3
      Top             =   480
      Width           =   735
   End
   Begin VB.Label lbName 
      AutoSize        =   -1  'True
      Caption         =   "Name :"
      BeginProperty Font 
         Name            =   "Times New Roman"
         Size            =   12
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   285
      Left            =   120
      TabIndex        =   2
      Top             =   840
      Width           =   660
   End
End
Attribute VB_Name = "frmholiday"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Dim mMachineNumber As Long
Dim mlngaccessid(3000) As Long


Private Sub cmdclean_Click()
 Dim vRet As Boolean
    Dim vErrorCode As Long
    
    lblMessage.Caption = "Working..."
    DoEvents
    
    vRet = frmMain.FP_CLOCK1.EnableDevice(mMachineNumber, False)
    If vRet = False Then
        lblMessage.Caption = gstrNoDevice
        Exit Sub
    End If
    
    vRet = frmMain.FP_CLOCK1.CleanHoliday(mMachineNumber)
   If vRet = True Then
        lblMessage.Caption = "CleanHoliday OK"
    Else
        frmMain.FP_CLOCK1.GetLastError vErrorCode
        lblMessage.Caption = ErrorPrint(vErrorCode)
    End If
    frmMain.FP_CLOCK1.EnableDevice mMachineNumber, True
End Sub

Private Sub cmdDelete_Click()
Dim holidayindex As Long
   
    Dim vRet As Boolean
    Dim vErrorCode As Long
    
    lblMessage.Caption = "Working..."
    DoEvents
    
    holidayindex = CInt(cmbholidayindex.Text)
    
    
    vRet = frmMain.FP_CLOCK1.EnableDevice(mMachineNumber, False)
    If vRet = False Then
        lblMessage.Caption = gstrNoDevice
        Exit Sub
    End If
    
    
    vRet = frmMain.FP_CLOCK1.DeleteHoliday(mMachineNumber, holidayindex)
   If vRet = True Then
        lblMessage.Caption = "DeleteHoliday:" + cmbholidayindex.Text + " OK"
    Else
        frmMain.FP_CLOCK1.GetLastError vErrorCode
        lblMessage.Caption = ErrorPrint(vErrorCode)
    End If
    
    frmMain.FP_CLOCK1.EnableDevice mMachineNumber, True
End Sub

Private Sub cmdExit_Click()
 Unload Me
    frmMain.Visible = True
End Sub

Private Sub cmdRead_Click()
     Dim vRet As Boolean
    Dim vErrorCode As Long
    Dim holidayname As Variant
    Dim holidayindex As Long
    Dim nSyear As Long
    Dim nSmonth As Long
    Dim nSday As Long
    Dim nEyear As Long
    Dim nEmonth As Long
    Dim nEday As Long
    Dim accessidcount As Long

    holidayindex = CInt(cmbholidayindex.Text)

    lblMessage.Caption = "Waiting..."
    DoEvents
    
    If frmMain.FP_CLOCK1.EnableDevice(mMachineNumber, False) = False Then
        lblMessage.Caption = gstrNoDevice
        Exit Sub
    End If
    
    vRet = frmMain.FP_CLOCK1.GetHoliday(mMachineNumber, holidayindex, holidayname, nSyear, nSmonth, nSday, nEyear, nEmonth, nEday, accessidcount, mlngaccessid(0))
    If vRet = True Then
        Dim t_date As Date
        t_date = nSyear & "-" & nSmonth & "-" & nSday
        dtpStartdate.Value = t_date
        t_date = nEyear & "-" & nEmonth & "-" & nEday
        dtpEnddate.Value = t_date
        
        txtName.Text = holidayname
        
        txtaccessidcount.Text = accessidcount
        
    Dim i As Long
    Dim DISCOUNT As Long
    
    If accessidcount > 20 Then
        DISCOUNT = 20
    Else
        DISCOUNT = accessidcount
    End If

    For i = 0 To DISCOUNT - 1
        txtEnrollnumber(i).Text = mlngaccessid(i)
    Next i
    
        
        lblMessage.Caption = "Success!"
    Else
        frmMain.FP_CLOCK1.GetLastError vErrorCode
        lblMessage.Caption = ErrorPrint(vErrorCode)
    End If

    frmMain.FP_CLOCK1.EnableDevice mMachineNumber, True
End Sub

Private Sub cmdWrite_Click()
    Dim holidayname As Variant
    Dim holidayindex As Long
    Dim nSyear As Long
    Dim nSmonth As Long
    Dim nSday As Long
    Dim nEyear As Long
    Dim nEmonth As Long
    Dim nEday As Long
    
    Dim vRet As Boolean
    Dim vErrorCode As Long
    
    Dim accessidcount As Long
    
    lblMessage.Caption = "Working..."
    DoEvents
    
    
    
    vRet = frmMain.FP_CLOCK1.EnableDevice(mMachineNumber, False)
    If vRet = False Then
        lblMessage.Caption = gstrNoDevice
        Exit Sub
    End If
    
    holidayindex = CInt(cmbholidayindex.Text)
    holidayname = txtName.Text
    accessidcount = CInt(txtaccessidcount.Text)
    
    nSyear = Val(dtpStartdate.Year)
    nSmonth = Val(dtpStartdate.Month)
    nSday = Val(dtpStartdate.Day)
        
    nEyear = Val(dtpEnddate.Year)
    nEmonth = Val(dtpEnddate.Month)
    nEday = Val(dtpEnddate.Day)
    
    Dim i As Long
    Dim DISCOUNT As Long
    
    If accessidcount > 20 Then
        accessidcount = 20
    End If

    For i = 0 To accessidcount - 1
        mlngaccessid(i) = txtEnrollnumber(i).Text
    Next i
    
    vRet = frmMain.FP_CLOCK1.SetHoliday(mMachineNumber, holidayindex, holidayname, nSyear, nSmonth, nSday, nEyear, nEmonth, nEday, accessidcount, mlngaccessid(0))
   If vRet = True Then
        lblMessage.Caption = "SetUserctrl OK"
    Else
        frmMain.FP_CLOCK1.GetLastError vErrorCode
        lblMessage.Caption = ErrorPrint(vErrorCode)
    End If
    
    frmMain.FP_CLOCK1.EnableDevice mMachineNumber, True
End Sub

Private Sub Form_Load()
mMachineNumber = frmMain.gMachineNumber
End Sub
