代码定义和清空:
![机房管理系统(二)之上下机 - 13期 杜宇航 - 杜宇航 廊坊师范学院信息技术提高班十三期](http://img1.ph.126.net/Oj7S4EyMw45fCAXimCRXag==/6631829727259327000.png)
判断卡号阶段:
txtSQL = "select * from student_Info where cardno='" & Trim(stutxtcardsno.Text) & "'"
Set mrc = ExecuteSQL(txtSQL, MsgText)
If stutxtcardsno.Text = "" Then '判断卡号是否为空
MsgBox "卡号不能为空", vbOKOnly + vbExclamation, "警告"
Else
If IsNumeric(stutxtcardsno.Text) = False Then
MsgBox "只能输入数字"
stutxtcardsno.Text = ""
stutxtcardsno.SetFocus
Else
If mrc.EOF Then '判断卡号是否注册
MsgBox "此卡尚未注册,请重新输入!", vbOKOnly + vbExclamation, "警告"
stutxtcardsno.Text = ""
Else
If Trim(mrc.Fields(10)) = Trim("不使用") Then
MsgBox "此卡尚未使用!", vbOKOnly + vbExclamation, "警告"
stutxtcardsno.Text = ""
Else
txtSQL = "select * from On
Set mrc = ExecuteSQL(txtSQL, MsgText)
If mrc.EOF = False Then '判断卡是否正在使用
MsgBox "此卡正在使用中", vbOKOnly + vbExclamation, "警告"
txtSQL = "select * from student_Info where cardno='" & Trim(stutxtcardsno.Text) & "'"
Set mrc = ExecuteSQL(txtSQL, MsgText)
stutxtcardsno.Text = Trim(mrc.Fields(0))
txtstuNo.Text = Trim(mrc.Fields(1))
txtstuName.Text = Trim(mrc.Fields(2))
txtstuSex.Text = Trim(mrc.Fields(3))
txt1.Text = Trim(mrc.Fields(4))
txtstutype.Text = Trim(mrc.Fields(14))
txtdataonline.Text = Date
txtonlinetime.Text = Time
txtstucharg.Text = Trim(mrc.Fields(7))
Else
txtSQL = "select * from student_Info where cardno='" & Trim(stutxtcardsno.Text) & "'"
Set mrc = ExecuteSQL(txtSQL, MsgText)
'判断卡内余额是否充足
If mrc.Fields(7) <= 0 Then
MsgBox "余额不足,请充值!", vbOKOnly, "温馨提示"
stutxtcardsno.Text = ""
确认无误后显示阶段:
![机房管理系统(二)之上下机 - 13期 杜宇航 - 杜宇航 廊坊师范学院信息技术提高班十三期](http://img2.ph.126.net/PKbzM4Jj2DlC1ryaB2iIlg==/6631763756561627921.png)
注显示阶段分为在文本上显示和在SQL上的on
下机:
定义阶段:
判断卡号:
结账计算阶段和显示:
然后是将上网记录保存在line 表中和将在线表记录删除:
最后就完成了上下机的操作!