小言_互联网的博客

机房收费系统——上机

591人阅读  评论(0)

还在敲学生信息管理系统的时候,就被师哥师姐告知机房有点儿难,尤其是什么上下机,动态显示金额还有强制下机部分。所以开始机房收费系统之后,我就先把上下机这几部分跳过了,等把别的窗体敲完调试好之后,发现上下机中,实际上上机还是比较简单的,就是逻辑性相对于其他窗体来说强一点,但是如果我们把上机的流程画到图上可能更清楚一些。

部分代码展示:

逻辑流程


  
  1. '查询卡号是否存在
  2. Dim onsql As String
  3. Dim onmrc As ADODB.Recordset
  4. Dim onmsgtext As String
  5. onsql = "select * from student_Info where cardno='" & txtcardno.Text & "'" '根据条件查询
  6. Set onmrc = ExecuteSQL(onsql, onmsgtext)
  7. '判断卡号是否存在
  8. If onmrc.EOF = False Then
  9. '如果存在,判断是否已经退卡
  10. '给cash赋值
  11. cash = Trim(onmrc.Fields( 7))
  12. If Trim(onmrc.Fields( 10)) = "使用" Then
  13. '没有退卡
  14. '判断卡号是否正在上机
  15. Dim upsql As String
  16. Dim upmrc As ADODB.Recordset
  17. Dim upmsgtext As String
  18. '查询正在上机表
  19. upsql = "select * from online_Info where cardno='" & txtcardno.Text & "'" '查询指定用户
  20. Set upmrc = ExecuteSQL(upsql, upmsgtext)
  21. '判断用户是已经上机
  22. If upmrc.EOF = False Then
  23. MsgBox "此卡号已上机,请重新输入卡号!", vbOKOnly + vbExclamation, "警告"
  24. txtcardno.Text = Trim(onmrc.Fields( 0))
  25. txtsid.Text = Trim(onmrc.Fields( 1))
  26. txtdept.Text = Trim(onmrc.Fields( 4))
  27. txtondate.Text = Trim(upmrc.Fields( 6))
  28. txtbalance.Text = Trim(onmrc.Fields( 7))
  29. txttype.Text = Trim(onmrc.Fields( 14))
  30. txtname.Text = Trim(onmrc.Fields( 2))
  31. txtsex.Text = Trim(onmrc.Fields( 3))
  32. txtontime.Text = Trim(upmrc.Fields( 7))
  33. '显示上机人数
  34. Dim txtsql, Msgtext As String
  35. Dim onw1 As adodb.Recordset '判断卡号是否正在上机
  36. txtsql = "select*from OnLine_Info"
  37. Set onw1 = ExecuteSQL(txtsql, Msgtext)
  38. lblUser.Caption = onw1.RecordCount
  39. onw1.Closef
  40. Else
  41. '调用baiscdata获取limintcash
  42. Call baiscdata
  43. '判断cash是否大于limitcash
  44. If cash > limitcash Then
  45. '显示卡号信息
  46. txtcardno.Text = Trim(onmrc.Fields( 0))
  47. txtsid.Text = Trim(onmrc.Fields( 1))
  48. txtdept.Text = Trim(onmrc.Fields( 4))
  49. txtondate.Text = Trim( Date)
  50. txtbalance.Text = Trim(onmrc.Fields( 7))
  51. txttype.Text = Trim(onmrc.Fields( 14))
  52. txtname.Text = Trim(onmrc.Fields( 2))
  53. txtsex.Text = Trim(onmrc.Fields( 3))
  54. txtontime.Text = Trim( Time)
  55. lblUser.Caption = upmrc.RecordCount
  56. txtctime.Text = "" '每次登陆清空上次用户登陆的消费时间和金额
  57. txtCMoney.Text = ""
  58. onmrc.Update
  59. upmrc.Close '关闭数据集
  60. onmrc.Close '关闭数据集
  61. '更新Oline表和line表
  62. Call online
  63. Else
  64. '小于最小上机余额,直接退出
  65. MsgBox "余额小于,最小上机余额!", vbOKOnly + vbExclamation, "警告"
  66. Exit Sub
  67. End If
  68. End If
  69. Else
  70. '已退卡
  71. MsgBox "卡号已经退卡,不可登录!", vbOKOnly + vbExclamation, "警告"
  72. txtcardno.Text = ""
  73. txtcardno.SetFocus
  74. End If
  75. Else
  76. MsgBox "卡号不存在,请先注册!", vbOKOnly + vbExclamation, "警告"
  77. txtcardno.Text = ""
  78. txtcardno.SetFocus
  79. End If

更新正在上机online_info表


  
  1. '更新正在上机表
  2. Dim onsql As String
  3. Dim onmrc As ADODB.Recordset
  4. Dim onmsgtext As String
  5. '获取正在上机表
  6. onsql = "select * from online_Info"
  7. Set onmrc = ExecuteSQL(onsql, onmsgtext)
  8. onmrc.AddNew '添加新纪录
  9. onmrc.Fields( 0) = Trim(txtcardno.Text)
  10. onmrc.Fields( 1) = Trim(txttype.Text)
  11. onmrc.Fields( 2) = Trim(txtsid.Text)
  12. onmrc.Fields( 3) = Trim(txtname.Text)
  13. onmrc.Fields( 4) = Trim(txtdept.Text)
  14. onmrc.Fields( 5) = Trim(txtsex.Text)
  15. onmrc.Fields( 6) = Trim( Date)
  16. onmrc.Fields( 7) = Trim( Time)
  17. onmrc.Fields( 8) = Trim(ComputerName)
  18. onmrc.Fields( 9) = Trim( Date)
  19. onmrc.Update '更新
  20. onmrc.Close '关闭数据集

 


转载:https://blog.csdn.net/mumuxi709/article/details/106305866
查看评论
* 以上用户言论只代表其个人观点,不代表本网站的观点或立场