⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 er_types.bas

📁 一款基于标准IC卡考勤数据读写操作示例的开发源程序。主要给需要开发IC卡和考勤系统的网友学习参考用
💻 BAS
字号:
Attribute VB_Name = "ER_Types"
'****************************************************************************
'人人为我,我为人人
'枕善居收藏整理
'发布日期:2008/03/08
'描    述:标准太平洋IC考勤机开发读写数据示例
'网    站:http://www.Mndsoft.com/  (VB6源码博客)
'网    站:http://www.VbDnet.com/   (VB.NET源码博客,主要基于.NET2005)
'e-mail  :Mndsoft@163.com
'e-mail  :Mndsoft@126.com
'OICQ    :88382850
'          如果您有新的好的代码别忘记给枕善居哦!
'****************************************************************************
Option Explicit

'{                                                                     }
'{     EastRiver Interface Program        }
'{                                                                     }
'{         Author:WuLiFeng                          }
'{                                                                     }
'{               2003.11.18                                 }
'{                                                                     }

'

' Declaration of the Type of catched
Dim PClockInfo() As TClockInfo
Type TClockInfo
  hPort As Long
  clock_id As Long
  clock_name As String
  Ver As String
  Mark As Byte
  bIs880 As Boolean
  ICID As Boolean
  Fireware As Double
  Port  As Long
  BaudRate As Long
  SelType As Long
  DeviceType As Long
  Clock_Type  As Long
  Mode As Long
  SystemMode As Long
  ExtraMode As Long
  Block As Long
  DispCardLen As Long
  CardLen As Long
  GroupStation As Long
  CmdVerify As Boolean
  GroupCheck As Boolean
  Connected As Boolean
End Type


'  here have some difference of the delphi defines,check it later
Dim PICCardNoStruct As TICCardNoStruct
Type TICCardNoStruct
  'ER-830C卡号部分
  CardNo As Long
  '只使用低20位
   'ER-830C卡号格式
  loCardNo  As String        '低16位卡号
  hiCardNo As Byte            '高4位卡号
  cardTimes As String       '加卡次数
  CardMoney As String   '消费卡金额
  flag As Byte                    '保留(设为0)
  'ER-880C卡号格式
  Bytes(0 To 7)   As Byte
End Type

Public PClockerTime As TClockerTime

Public Type TClockerTime
  StartTime As String * 6
  EndTime As String * 6
End Type

Type TRingTime
  hour        As Long
  minute      As Long
  second      As Long
  ringTimeLen As Long
End Type

Type TICRecord
  card       As String * 20     ' 卡号字符串
  TimeString   As String * 20   ' 14位刷卡时间字符串, 格式为yyyymmddhhnnss
  EmpId        As String * 10   ' 工号(只有ID卡机具支持)
  Mark       As Long            ' 读卡机标识字符
  flag       As Long            ' 存储卡的结果
         ' flag = 0:            ' 表示为正常卡
         ' flag.0 = 1 :         ' 表示为非法门禁卡
         ' flag.1 = 1 :         ' 表示为非法考勤卡
         ' flag.2 = 1 :         ' 表示为黑名单卡
  cardTimes As Long             ' 发卡次数, 0-15
  cardGroup As Long             ' 卡的组别, 0-255
End Type


'{新型一拖四门禁机 "ER-890" 新增函数}
Type TDoorTimePeriod           ' 局部结构表示一个时间点
  TimeHour As Long             ' 小时[0..23]
  TimeMinute As Long           ' 分钟[0..59]
End Type
  
Dim PDoorTimePeriods  As TDoorTimePeriods

Type TDoorTimePeriods          ' 门禁机时段结构
  StartTime As TDoorTimePeriod ' 时段的开始时间
  EndTime As TDoorTimePeriod   ' 时段的结束时间
  Right   As Long              ' 本时段的权限,依不同功能而不同
End Type


Public PCardInfo   As TCardInfo
Type TCardInfo
  CardNo As String * 18          '存储卡号
  IsIDCard As Boolean            '如果时ID卡为true,否则为false是IC卡
  NoCard As Boolean              '如果为true,则没有卡片在感应区,此结构其他数据无效
  Reader As Long                 '范围从1-4指几号读头
  flag As Long                   '打卡结果
  Mark As Long                   '打卡标志
End Type

Type TCardList
  CardNo As String
  EmpId As String
  EmpName As String
  Periods As String
  Pwd As String
  Auts As Long
End Type

Public PReadData As TReadData
Public Type TReadData
  Verify_Error As Byte          '此记录校验是否正确, 由用户处理,
                                '如果记录校验错误且需继续读返回一条记录则需重置为False
  CardNo      As String * 20    '卡号(20个字节,以0结束字符串)
  TimeString   As String * 20   '时间(20个字节,以0结束字符串)
  flag        As Integer        '打卡结果
        'flag = 0;              '表示正常记录
        'flag = 3;              '退还了误收金额的消费记录
        'flag = 7;              '表示此记录的卡片在写入金额时由于过早离开了感应区,有可能金额没有正常写入
  consume   As Integer          '消费金额,单位角
  balance     As Integer        '消费后余额,单位角
  Times       As Integer        '充值次数
  Record_Total As Long          '采集数据的总记录数
  Record_Index As Long          '当前记录是第几条记录
End Type

Public Function DataProcess(ByVal lpData As Long, ByVal ReadData As Long) As Boolean
  Dim strLine As String
  Dim lpReadData As TReadData
  Dim consume As Integer
  Dim balance As Integer
  
  CopyMemory lpReadData, ReadData, LenB(lpReadData)
  consume = lpReadData.consume
  balance = lpReadData.balance
  strLine = Format(clock_id, "00") + Format(lpReadData.TimeString, " 00000000000000") + Format(lpReadData.CardNo, " 0000000000")
  Form1.List1.AddItem strLine + "    C " + CStr(consume) + "    B " + CStr(balance) + "  Total " + CStr(lpReadData.Record_Total) + "   Index " + CStr(lpReadData.Record_Index)
  Print #1, strLine
  Form2.Label1.Caption = "Total " + CStr(lpReadData.Record_Total) + "   Index " + CStr(lpReadData.Record_Index)
  
  If Form2.bCancel = False Then
    DataProcess = True
  Else
    DataProcess = False
  End If
End Function

Public Sub WaitProc(ByVal p As Long, ByVal dwMilliseconds As Long)
  dwMilliseconds = 3000
  Form2.Msg.Caption = "正在采集数据"
  Form2.Refresh
End Sub

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -