一、逻辑图
先理清楚上下机的逻辑过程,再去实现代码
①上机模块
②下机模块
二、代码
①上机模块
Private Sub cmdOnLine_Click()
Dim mrc As ADODB.Recordset
Dim msgtext As String
Dim txtSQL As String
Dim mrcBasicData As ADODB.Recordset
Dim mrcline As ADODB.Recordset
Dim mrccash As ADODB.Recordset
txtDownTime.Text = ""
txtDownTime.Text = ""
txtBalance.Text = ""
txtExpenseTime.Text = ""
txtExpenseCash.Text = ""
'判断是否为空
If Not Testtxt(txtCardNo.Text) Then
MsgBox "请输入上机卡号!", vbOKOnly + vbExclamation, "提示"
txtCardNo.SetFocus
Exit Sub
Else
If Not IsNumeric(Trim(txtCardNo.Text)) Then
MsgBox "卡号必须输入数字!", vbOKOnly + vbExclamation, "提示"
txtCardNo.Text = ""
txtCardNo.SetFocus
Exit Sub
End If
End If
'判断卡号是否注册
txtSQL = "select*from student_Info where cardno='" & Trim(txtCardNo.Text) & "'"
Set mrc = ExecuteSQL(txtSQL, msgtext)
If mrc.BOF And mrc.EOF Then
MsgBox "该卡号未注册,请先注册信息!", vbOKOnly + vbExclamation, "提示"
txtCardNo.Text = ""
txtCardNo.SetFocus
Exit Sub
Else
If Trim(mrc.Fields(10)) = "不使用" Then
MsgBox "该卡已经退卡", vbOKCancel + vbInformation, "提示"
txtCardNo.Text = ""
txtCardNo.SetFocus
Exit Sub
End If
End If
'查BasicData_Info,判断余额是否小于最小金额
txtSQL = "select*from BasicData_Info"
Set mrcBasicData = ExecuteSQL(txtSQL, msgtext)
mrcBasicData.MoveFirst
If Val(mrc.Fields(7)) < Val(mrcBasicData.Fields(5)) Then
MsgBox "余额不足,请充值后上机", vbOKOnly + vbExclamation, "提示"
txtCardNo.Text = ""
txtCardNo.SetFocus
Else
'查OnLine_Info,看该卡是否在上机
txtSQL = "select*from OnLine_Info where cardno='" & Trim(txtCardNo.Text) & "'"
Set mrc = ExecuteSQL(txtSQL, msgtext)
If mrc.EOF = False Th