科密KD-36考勤机二次开发技术详解

项目详细:科密KD-36 delphi接口 VB 6.0程序读取数据

KD-36



 

界面一

 

界面二

程序:

Private Sub Cmd_CheckNet_Click()    ' 检查网络
Dim ECHO As ICMP_ECHO_REPLY
Dim Pos As Long
Dim Success As Long
Dim IP As String
 
IPAddress = Trim(txtIPAddress.Text)
PortNumber = Trim(txtPortNumber.Text)
PassWord = Trim(txtPassWord.Text)
MacNo = Trim(txtMacNo.Text)

If IPAddress = "" Then
MsgBox "请先输入IP地址,再检查网络!", vbInformation, Jxjr
txtIPAddress.SetFocus
Else
   If SocketsInitialize() Then
          Success = Pings(IPAddress, MyIP, ECHO)
          If Success = 0 Then
              'MsgBox "考勤机网络连接正常!", vbInformation, Jxjr
              If MacNo = "" Then
              MsgBox "机号不能为空!", vbInformation, Jxjr
              Else
                If kd.OpenCommPort(MacNo) = True Then
                Call kd.EnableDevice(MacNo, 1)
                Call kd.CloseCommPort
                MsgBox "考勤机网络连接正常!", vbInformation, Jxjr
                Else
                MsgBox "考勤机机号错误,请重新输入!", vbInformation, Jxjr
                txtMacNo.SetFocus
                End If
             End If
          Else
              MsgBox "考勤机网络连接不正常,请检查IP和网络连接!", vbInformation, Jxjr
          End If
          SocketsCleanup
    End If
End If
End Sub

Private Sub Cmd_GetAllData_Click()     '得到全部数据
Dim TMacNo As Long
Dim EnrollNo As Long
Dim EMacNo As Long
Dim VerMode As Long
Dim kdYear As Long
Dim kdMonth As Long
Dim kdDay As Long
Dim kdHour As Long
Dim kdMinute As Long
Dim kddate As Date
Dim kdtime As String
Dim MacPr As Long
Dim EnrollNumber As Variant
Dim EnrollWord As Long
Dim SqlEnrollWord As String

Dim OldNum As Integer
Dim i As Integer


MacPr = 3   '用户的权限

Dim iSql As String

IPAddress = GetSetting("jxjr", "jrhr", "ipaddress", IPAddress)
PortNumber = GetSetting("jxjr", "jrhr", "portnumber", PortNumber)
PassWord = GetSetting("jxjr", "jrhr", "password", PassWord)
MacNo = GetSetting("jxjr", "jrhr", "macno", MacNo)

If kd.SetIPAddress(IPAddress, PortNumber, PassWord) = True Then
    If kd.OpenCommPort(MacNo) = True Then
       Call kd.EnableDevice(MacNo, 0)
       Call kd.ReadAllGLogData(MacNo)
       If kd.GetAllGLogData(MacNo, TMacNo, EnrollNo, EMacNo, VerMode, kdYear, kdMonth, kdDay, kdHour, kdMinute) = True Then
            Do Until kd.GetAllGLogData(MacNo, TMacNo, EnrollNo, EMacNo, VerMode, kdYear, kdMonth, kdDay, kdHour, kdMinute) = False
                 Call kd.GetEnrollData(MacNo, EnrollNo, TMacNo, 11, MacPr, EnrollNumber, EnrollWord)
                 SqlEnrollWord = CStr(EnrollWord)
                 OldNum = Len(SqlEnrollWord)
                 For i = 0 To 9 - OldNum
                 SqlEnrollWord = "0" + CStr(SqlEnrollWord)
                 Next i
                 'kd.ReadMark = False
                 'Call kd.GetAllGLogData(MacNo, TMacNo, EnrollNo, EMacNo, VerMode, kdYear, kdMonth, kdDay, kdHour, kdMinute)
                 kdtime = kdYear & "-" & kdMonth & "-" & kdDay & " " & kdHour & ":" & kdMinute & ":" & "00" & "." & "000"
                 iSql = "insert into HR_ATS_OriginalityCard(FCardID,FHostName,FCardDateTime)values('" & SqlEnrollWord & "','" & MacNo & "','" & kdtime & "')"
                 Pcnn.Execute (iSql)
            Loop
            MsgBox "全部考勤记录读取成功!", vbInformation, Jxjr
            Call kd.EnableDevice(MacNo, 1)
            Call kd.CloseCommPort
        Else
        MsgBox "没有考勤记录!", vbInformation, Jxjr
        End If
    Else
    MsgBox "终端机号[" & MacNo & "]打开失败!", vbInformation, Jxjr
    End If
Else
    MsgBox "连接设置错误!", vbInformation, Jxjr
End If
End Sub

Private Sub Cmd_GetNewData_Click()    '得到{zx1}数据
Dim TMacNo As Long
Dim EnrollNo As Long
Dim EMacNo As Long
Dim VerMode As Long
Dim kdYear As Long
Dim kdMonth As Long
Dim kdDay As Long
Dim kdHour As Long
Dim kdMinute As Long
Dim kddate As Date
Dim kdtime As String
Dim MacPr As Long
Dim EnrollNumber As Variant
Dim EnrollWord As Long
Dim SqlEnrollWord As String

Dim OldNum As Integer
Dim i As Integer

MacPr = 3   '用户的权限

Dim iSql As String

IPAddress = GetSetting("jxjr", "jrhr", "ipaddress", IPAddress)
PortNumber = GetSetting("jxjr", "jrhr", "portnumber", PortNumber)
PassWord = GetSetting("jxjr", "jrhr", "password", PassWord)
MacNo = GetSetting("jxjr", "jrhr", "macno", MacNo)

If kd.SetIPAddress(IPAddress, PortNumber, PassWord) = True Then
    If kd.OpenCommPort(MacNo) = True Then
       Call kd.EnableDevice(MacNo, 0)
       Call kd.ReadGeneralLogData(MacNo)
            If kd.GetGeneralLogData(MacNo, TMacNo, EnrollNo, EMacNo, VerMode, kdYear, kdMonth, kdDay, kdHour, kdMinute) = True Then
                 Do Until kd.GetGeneralLogData(MacNo, TMacNo, EnrollNo, EMacNo, VerMode, kdYear, kdMonth, kdDay, kdHour, kdMinute) = False
                      Call kd.GetEnrollData(MacNo, EnrollNo, TMacNo, 11, MacPr, EnrollNumber, EnrollWord)
                      SqlEnrollWord = CStr(EnrollWord)
                      OldNum = Len(SqlEnrollWord)
                      For i = 0 To 9 - OldNum
                      SqlEnrollWord = "0" + CStr(SqlEnrollWord)
                      Next i
                      'kd.ReadMark = False
                      'Call kd.GetAllGLogData(MacNo, TMacNo, EnrollNo, EMacNo, VerMode, kdYear, kdMonth, kdDay, kdHour, kdMinute)
                      kdtime = kdYear & "-" & kdMonth & "-" & kdDay & " " & kdHour & ":" & kdMinute & ":" & "00" & "." & "000"
                      iSql = "insert into HR_ATS_OriginalityCard(FCardID,FHostName,FCardDateTime)values('" & SqlEnrollWord & "','" & MacNo & "','" & kdtime & "')"
                      Pcnn.Execute (iSql)
                 Loop
                 MsgBox "{zx1}考勤记录读取成功!", vbInformation, Jxjr
             Else
             MsgBox "没有{zx1}的考勤记录!", vbInformation, Jxjr
             End If
        Call kd.EnableDevice(MacNo, 1)
        Call kd.CloseCommPort
    Else
    MsgBox "终端机号[" & MacNo & "]打开失败!", vbInformation, Jxjr
    End If
Else
    MsgBox "连接设置错误!", vbInformation, Jxjr
End If
End Sub

Private Sub Cmd_SetIP_Click()     '设置IP信息

IPAddress = Trim(txtIPAddress.Text)
PortNumber = Trim(txtPortNumber.Text)
PassWord = Trim(txtPassWord.Text)
MacNo = Trim(txtMacNo.Text)

If IPAddress = "" Then
MsgBox "IP地址不能为空!", vbInformation, Jxjr
txtIPAddress.SetFocus
Else
    If PortNumber = "" Then
    MsgBox "端口号不能为空!", vbInformation, Jxjr
    txtPortNumber.SetFocus
    Else
        If PassWord = "" Then
        MsgBox "密码不能为空!", vbInformation, Jxjr
        txtPassWord.SetFocus
        Else
            If MacNo = "" Then
            MsgBox "机号不能为空!", vbInformation, Jxjr
            txtMacNo.SetFocus
            Else
               SaveSetting "jxjr", "jrhr", "ipaddress", IPAddress
               SaveSetting "jxjr", "jrhr", "portnumber", PortNumber
               SaveSetting "jxjr", "jrhr", "password", PassWord
               SaveSetting "jxjr", "jrhr", "macno", MacNo
               If kd.SetIPAddress(IPAddress, PortNumber, PassWord) = True Then
                  MsgBox "连接数据设置成功!", vbInformation, Jxjr
               Else
                  MsgBox "无法设置连接数据!", vbInformation, Jxjr
               End If
            End If
        End If
    End If
End If

End Sub

Private Sub Cmd_SetMacTime_Click()  '设置系统时间
IPAddress = GetSetting("jxjr", "jrhr", "ipaddress", IPAddress)
PortNumber = GetSetting("jxjr", "jrhr", "portnumber", PortNumber)
PassWord = GetSetting("jxjr", "jrhr", "password", PassWord)
MacNo = GetSetting("jxjr", "jrhr", "macno", MacNo)

If kd.SetIPAddress(IPAddress, PortNumber, PassWord) = True Then
    If kd.OpenCommPort(MacNo) = True Then
       Call kd.EnableDevice(MacNo, 0)
          If kd.SetDeviceTime(MacNo) = True Then
          MsgBox "考勤机时间同步成功!", vbInformation, Jxjr
          Else
          MsgBox "考勤机时间同步失败,请检查!", vbInformation, Jxjr
          End If
       Call kd.EnableDevice(MacNo, 1)
       Call kd.CloseCommPort
    Else
    MsgBox "终端机号[" & MacNo & "]打开失败!", vbInformation, Jxjr
    End If
Else
    MsgBox "连接设置错误!", vbInformation, Jxjr
End If
End Sub

Private Sub Com_ClearData_Click()     'xx记录数据
IPAddress = GetSetting("jxjr", "jrhr", "ipaddress", IPAddress)
PortNumber = GetSetting("jxjr", "jrhr", "portnumber", PortNumber)
PassWord = GetSetting("jxjr", "jrhr", "password", PassWord)
MacNo = GetSetting("jxjr", "jrhr", "macno", MacNo)

If kd.SetIPAddress(IPAddress, PortNumber, PassWord) = True Then
    If kd.OpenCommPort(MacNo) = True Then
       Call kd.EnableDevice(MacNo, 0)
            If kd.EmptyGeneralLogData(MacNo) = True Then
            MsgBox "所有记录清空成功!", vbInformation, Jxjr
            Else
            MsgBox "清空失败,请检查!", vbInformation, Jxjr
            End If
       Call kd.EnableDevice(MacNo, 1)
       Call kd.CloseCommPort
    Else
    MsgBox "终端机号[" & MacNo & "]打开失败!", vbInformation, Jxjr
    End If
Else
    MsgBox "连接设置错误!", vbInformation, Jxjr
End If
End Sub

Private Sub Com_DeleteAll_Click()   'xx全部数据
IPAddress = GetSetting("jxjr", "jrhr", "ipaddress", IPAddress)
PortNumber = GetSetting("jxjr", "jrhr", "portnumber", PortNumber)
PassWord = GetSetting("jxjr", "jrhr", "password", PassWord)
MacNo = GetSetting("jxjr", "jrhr", "macno", MacNo)

If kd.SetIPAddress(IPAddress, PortNumber, PassWord) = True Then
    If kd.OpenCommPort(MacNo) = True Then
       Call kd.EnableDevice(MacNo, 0)
            If kd.EmptyEnrollData(MacNo) = True Then
            MsgBox "所有信息清空成功!", vbInformation, Jxjr
            Else
            MsgBox "清空失败,请检查!", vbInformation, Jxjr
            End If
       Call kd.EnableDevice(MacNo, 1)
       Call kd.CloseCommPort
    Else
    MsgBox "终端机号[" & MacNo & "]打开失败!", vbInformation, Jxjr
    End If
Else
    MsgBox "连接设置错误!", vbInformation, Jxjr
End If
End Sub

Private Sub Com_TimeSet_Click()
Dim dblReturn As Double
dblReturn = Shell("rundll32.exe   shell32.dll,Control_RunDLL   timedate.cpl", 5)
End Sub

Private Sub Form_Load()
txtIPAddress.Text = GetSetting("jxjr", "jrhr", "ipaddress", IPAddress)
txtPortNumber.Text = GetSetting("jxjr", "jrhr", "portnumber", PortNumber)
txtPassWord.Text = GetSetting("jxjr", "jrhr", "password", PassWord)
txtMacNo.Text = GetSetting("jxjr", "jrhr", "macno", MacNo)
Timer.Interval = 500
End Sub

Private Sub Timer_Timer()
LbTime = Year(Date) & "年" & Month(Date) & "月" & Day(Date) & "日  星期" & GetWeekDay(Weekday(Date)) & "" & Format$(Time, "hh:mm:ss")
    '"xx年xx月xx日 星期几 系统时间hh:mm:ss"
End Sub

郑重声明:资讯 【科密KD-36考勤机二次开发技术详解】由 发布,版权归原作者及其所在单位,其原创性以及文中陈述文字和内容未经(企业库qiyeku.com)证实,请读者仅作参考,并请自行核实相关内容。若本文有侵犯到您的版权, 请你提供相关证明及申请并与我们联系(qiyeku # qq.com)或【在线投诉】,我们审核后将会尽快处理。
—— 相关资讯 ——