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

📄 form_kzc.frm

📁 射频卡收费系统 自主开发 可以用于任何商业收费场所
💻 FRM
字号:
VERSION 5.00
Object = "{648A5603-2C6E-101B-82B6-000000000014}#1.1#0"; "MSCOMM32.OCX"
Begin VB.Form Form_kzc 
   BorderStyle     =   1  'Fixed Single
   Caption         =   "卡注册"
   ClientHeight    =   2880
   ClientLeft      =   45
   ClientTop       =   330
   ClientWidth     =   7605
   LinkTopic       =   "Form4"
   MaxButton       =   0   'False
   MinButton       =   0   'False
   ScaleHeight     =   2880
   ScaleWidth      =   7605
   StartUpPosition =   2  '屏幕中心
   Begin VB.CommandButton Command1 
      Caption         =   "退 出"
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   14.25
         Charset         =   134
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   405
      Left            =   2640
      TabIndex        =   1
      Top             =   1800
      Width           =   1695
   End
   Begin VB.TextBox Text3 
      Alignment       =   1  'Right Justify
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   14.25
         Charset         =   134
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   405
      Left            =   2640
      TabIndex        =   0
      Top             =   960
      Width           =   1935
   End
   Begin MSCommLib.MSComm MSComm1 
      Left            =   480
      Top             =   1680
      _ExtentX        =   1005
      _ExtentY        =   1005
      _Version        =   393216
      DTREnable       =   -1  'True
   End
   Begin VB.Label Label8 
      AutoSize        =   -1  'True
      BackStyle       =   0  'Transparent
      Caption         =   "请划卡----"
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   14.25
         Charset         =   134
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   285
      Left            =   4800
      TabIndex        =   3
      Top             =   1080
      Width           =   1560
   End
   Begin VB.Label Label1 
      AutoSize        =   -1  'True
      BackStyle       =   0  'Transparent
      Caption         =   "卡编号"
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   14.25
         Charset         =   134
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   285
      Left            =   1440
      TabIndex        =   2
      Top             =   1080
      Width           =   900
   End
End
Attribute VB_Name = "Form_kzc"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim kayue_cn As New Connection
Dim yue As Recordset
Dim CardNumber As Double

Private Sub Command1_Click()
Unload Me

End Sub



Private Sub Form_Load()
MSComm1.CommPort = com_x '串口号,
MSComm1.Settings = "9600,N,8,1" '串口的属性
MSComm1.InputLen = 0 '接收缓冲区的大小
MSComm1.InputMode = comInputModeBinary '二进制接受方式
MSComm1.RThreshold = 7 '每7个字节响应消息
MSComm1.PortOpen = True '打开通信串口

    With kayue_cn
        .ConnectionString = dblianjie
        .Open
    End With
    Set yue = New Recordset
    
    yue.CursorLocation = adUseClient
    yue.CursorType = adOpenDynamic
     
    yue.Open "select * from 卡资料 order by 卡编号", kayue_cn
    If yue.RecordCount > 0 Then
        yue.MoveLast
        
        Text3.Text = Format(yue.Fields("卡编号") + 1, "0000")
    Else
        Text3.Text = "0001"
    End If
       
      
    yue.Close
    Set yue = Nothing
    
End Sub

Private Sub Form_Unload(Cancel As Integer)
    kayue_cn.Close
    Set kayue_cn = Nothing
    
    If (MSComm1.PortOpen) Then
        MSComm1.PortOpen = False
    End If
End Sub

Private Sub MSComm1_OnComm()
 Select Case MSComm1.CommEvent '串口事件
    Case comEvReceive '接收到数据
    Dim Buffer As Variant '存储数据的缓冲区
    Dim StringBuf(8) As String '数据数组
    
    Buffer = MSComm1.Input '清理接收缓冲区,此时,接收的字节数已经为0
    'Dim CardNumber As Long '卡号
    CardNumber = CDec(Buffer(3)) * 2 ^ 24 + (Buffer(4) * 2 ^ 16) + (Buffer(5) * 2 ^ 8) + Buffer(6) '单个字节数据左移
   '----------------------------------
    Set yue = New Recordset
    yue.CursorLocation = adUseClient
    yue.CursorType = adOpenDynamic
    yue.LockType = adLockOptimistic
    
    yue.Open "select * from 卡资料 where 卡号='" & CStr(CardNumber) & "'", kayue_cn
    If yue.RecordCount > 0 Then
      
       MsgBox "本卡已注册!", vbExclamation, "读卡提示"
    Else
       
        yue.AddNew
       
        yue.Fields("姓名") = ""
        yue.Fields("性别") = ""
        yue.Fields("身份证号") = ""
            
        yue.Fields("卡编号") = CStr(Text3.Text)
        yue.Fields("卡号") = CStr(CardNumber)
        yue.Fields("卡余额") = 0
        yue.Fields("时间") = Date + Time
        
        yue.Fields("卡状态") = "正常"
        yue.Fields("累计消费") = 0
        
        yue.Update
        
        If (MSComm1.PortOpen) Then
             MSComm1.PortOpen = False
        End If
        MsgBox "恭喜,注册成功!确定后可注册下一张卡。" & vbCr & "卡编号:  " & Format(Text3.Text, "0000"), vbExclamation, "注册成功"
        MSComm1.PortOpen = True
        Text3.Text = Format(Text3.Text + 1, "0000")
        
     
    End If
   
    yue.Close
    Set yue = Nothing

 End Select

End Sub


⌨️ 快捷键说明

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