还在敲学生信息管理系统的时候,就被师哥师姐告知机房有点儿难,尤其是什么上下机,动态显示金额还有强制下机部分。所以开始机房收费系统之后,我就先把上下机这几部分跳过了,等把别的窗体敲完调试好之后,发现上下机中,实际上上机还是比较简单的,就是逻辑性相对于其他窗体来说强一点,但是如果我们把上机的流程画到图上可能更清楚一些。
部分代码展示:
逻辑流程
-
'查询卡号是否存在
-
Dim onsql As
String
-
Dim onmrc As ADODB.Recordset
-
Dim onmsgtext As
String
-
onsql =
"select * from student_Info where cardno='" & txtcardno.Text &
"'"
'根据条件查询
-
Set onmrc = ExecuteSQL(onsql, onmsgtext)
-
'判断卡号是否存在
-
If onmrc.EOF =
False
Then
-
'如果存在,判断是否已经退卡
-
'给cash赋值
-
cash =
Trim(onmrc.Fields(
7))
-
If
Trim(onmrc.Fields(
10)) =
"使用"
Then
-
'没有退卡
-
'判断卡号是否正在上机
-
Dim upsql As
String
-
Dim upmrc As ADODB.Recordset
-
Dim upmsgtext As
String
-
'查询正在上机表
-
upsql =
"select * from online_Info where cardno='" & txtcardno.Text &
"'"
'查询指定用户
-
Set upmrc = ExecuteSQL(upsql, upmsgtext)
-
'判断用户是已经上机
-
If upmrc.EOF =
False
Then
-
MsgBox
"此卡号已上机,请重新输入卡号!", vbOKOnly + vbExclamation,
"警告"
-
txtcardno.Text =
Trim(onmrc.Fields(
0))
-
txtsid.Text =
Trim(onmrc.Fields(
1))
-
txtdept.Text =
Trim(onmrc.Fields(
4))
-
txtondate.Text =
Trim(upmrc.Fields(
6))
-
txtbalance.Text =
Trim(onmrc.Fields(
7))
-
txttype.Text =
Trim(onmrc.Fields(
14))
-
txtname.Text =
Trim(onmrc.Fields(
2))
-
txtsex.Text =
Trim(onmrc.Fields(
3))
-
txtontime.Text =
Trim(upmrc.Fields(
7))
-
'显示上机人数
-
Dim txtsql, Msgtext As
String
-
Dim onw1 As adodb.Recordset
'判断卡号是否正在上机
-
txtsql =
"select*from OnLine_Info"
-
Set onw1 = ExecuteSQL(txtsql, Msgtext)
-
lblUser.Caption = onw1.RecordCount
-
onw1.Closef
-
-
Else
-
'调用baiscdata获取limintcash
-
Call baiscdata
-
'判断cash是否大于limitcash
-
If cash > limitcash
Then
-
'显示卡号信息
-
txtcardno.Text =
Trim(onmrc.Fields(
0))
-
txtsid.Text =
Trim(onmrc.Fields(
1))
-
txtdept.Text =
Trim(onmrc.Fields(
4))
-
txtondate.Text =
Trim(
Date)
-
txtbalance.Text =
Trim(onmrc.Fields(
7))
-
txttype.Text =
Trim(onmrc.Fields(
14))
-
txtname.Text =
Trim(onmrc.Fields(
2))
-
txtsex.Text =
Trim(onmrc.Fields(
3))
-
txtontime.Text =
Trim(
Time)
-
lblUser.Caption = upmrc.RecordCount
-
txtctime.Text =
""
'每次登陆清空上次用户登陆的消费时间和金额
-
txtCMoney.Text =
""
-
onmrc.Update
-
upmrc.Close
'关闭数据集
-
onmrc.Close
'关闭数据集
-
'更新Oline表和line表
-
Call online
-
Else
-
'小于最小上机余额,直接退出
-
MsgBox
"余额小于,最小上机余额!", vbOKOnly + vbExclamation,
"警告"
-
Exit
Sub
-
End
If
-
End
If
-
Else
-
'已退卡
-
MsgBox
"卡号已经退卡,不可登录!", vbOKOnly + vbExclamation,
"警告"
-
txtcardno.Text =
""
-
txtcardno.SetFocus
-
End
If
-
Else
-
MsgBox
"卡号不存在,请先注册!", vbOKOnly + vbExclamation,
"警告"
-
txtcardno.Text =
""
-
txtcardno.SetFocus
-
End
If
更新正在上机online_info表
-
'更新正在上机表
-
Dim onsql As
String
-
Dim onmrc As ADODB.Recordset
-
Dim onmsgtext As
String
-
'获取正在上机表
-
onsql =
"select * from online_Info"
-
Set onmrc = ExecuteSQL(onsql, onmsgtext)
-
onmrc.AddNew
'添加新纪录
-
onmrc.Fields(
0) =
Trim(txtcardno.Text)
-
onmrc.Fields(
1) =
Trim(txttype.Text)
-
onmrc.Fields(
2) =
Trim(txtsid.Text)
-
onmrc.Fields(
3) =
Trim(txtname.Text)
-
onmrc.Fields(
4) =
Trim(txtdept.Text)
-
onmrc.Fields(
5) =
Trim(txtsex.Text)
-
onmrc.Fields(
6) =
Trim(
Date)
-
onmrc.Fields(
7) =
Trim(
Time)
-
onmrc.Fields(
8) =
Trim(ComputerName)
-
onmrc.Fields(
9) =
Trim(
Date)
-
onmrc.Update
'更新
-
onmrc.Close
'关闭数据集
转载:https://blog.csdn.net/mumuxi709/article/details/106305866
查看评论