【机房收费系统】问题集锦

太过爱你忘了你带给我的痛 2022-08-04 10:42 197阅读 0赞

敲机房的时候感觉有一些的问题需要改进所以就相应的做了一些的更改

1、当卡号中余额为0的时候自动下机

  1. Dim mrc As ADODB.Recordset '选择在线online表
  2. Dim txtSQl, MsgText As String
  3. Dim mr As ADODB.Recordset '选择学生表提取金额
  4. Dim m As ADODB.Recordset '选择基本数据表用于固定用户和临时用户开销
  5. Dim mrr As ADODB.Recordset
  6. txtSQl = "select * from online_info"
  7. Set mrc = ExecuteSQL(txtSQl, MsgText)
  8. txtSQl = "select * from BasicData_Info"
  9. Set m = ExecuteSQL(txtSQl, MsgText)
  10. Do While Not mrc.EOF
  11. txtSQl = "select * from student_Info where cardno='" & Trim(mrc.Fields(0)) & "'"
  12. Set mr = ExecuteSQL(txtSQl, MsgText)
  13. mrc.Fields(10) = Trim(mrc.Fields(10)) + 1
  14. mrc.Update
  15. If Trim(mr.Fields(14)) = "固定用户" Then
  16. txtTime.Text = mr.Fields(7) / m.Fields(1) * 60 - mrc.Fields(10)
  17. alltime.Text = mr.Fields(7) / m.Fields(1) * 60
  18. Else
  19. txtTime.Text = mr.Fields(7) / m.Fields(0) * 60 - mrc.Fields(10)
  20. alltime.Text = mr.Fields(7) / m.Fields(0) * 60
  21. End If
  22. txtadd.Text = DateDiff("n", mrc.Fields(6), Format(Now, "yyyy-mm-dd")) '计算相差分钟数
  23. txtadd.Text = txtadd.Text + DateDiff("n", Trim(mrc.Fields(7)), Format(Now, "hh:mm:ss"))
  24. If Int(txtadd.Text) > Int(alltime) Then
  25. MsgBox ("卡号" & mrc.Fields(0) & "已经没有费了"), vbOKOnly + vbExclamation, "提示"
  26. mr.Fields(7) = 0
  27. mr.Fields(6) = "不使用"
  28. mr.Update
  29. End If
  30. If txtTime.Text < 10 And txtTime.Text > 8 Then
  31. MsgBox ("卡号" & Trim(mrc.Fields(0)) & "余额不足,十分钟后将自动下机,请尽快提示充值")
  32. End If
  33. If txtTime.Text = 1 Then
  34. MsgBox ("卡号" & Trim(mrc.Fields(0)) & "即将在1分钟后自动下机")
  35. End If
  36. If txtTime.Text = 0 Then
  37. MsgBox ("卡号" & Trim(mrc.Fields(0)) & "余额为0,欢迎下次再来")
  38. mr.Fields(10) = "不使用"
  39. mr.Update
  40. End If
  41. If Trim(mr.Fields(6)) = "不使用" Then
  42. txtSQl = "delete from online_info where cardno='" & mr.Fields(10) & "'"
  43. Set mrr = ExecuteSQL(txtSQl, MsgText)
  44. End If
  45. mrc.MoveNext
  46. Loop

2、对于上机来说是比较容易的但是下机是最难搞定的 (需要想很多的东西)

  1. 首先就是卡号是否为空、卡号要是数字、卡号是否还在使用、此卡是否正在上机

再次计时计算时间,根据消费的时间算出相应的花销

最后就是更新Line_info 中的数据库 删除Online_info中下机的卡号的信息

  1. <span style="font-size:18px;">Dim mrc As ADODB.Recordset
  2. Dim mrcc As ADODB.Recordset
  3. Dim mrcd As ADODB.Recordset
  4. Dim mrce As ADODB.Recordset
  5. Dim txtSQl As String
  6. Dim MsgText As String
  7. Dim Usetime, UnitNumber, a, b, c As String
  8. '判断下机卡号是否为空
  9. If txtCardID.Text = "" Then '判断卡号是否为空
  10. MsgBox "请输入卡号!", 0 + 48, "提示"
  11. Exit Sub
  12. txtCardID.SetFocus
  13. txtCardID.Text = ""
  14. End If
  15. '判断下机卡号是否是数字
  16. If Not IsNumeric(txtCardID.Text) Then '判断卡号是否为数字
  17. MsgBox "卡号请输入数字!", 0 + 48, "提示"
  18. txtCardID.SetFocus
  19. txtCardID.Text = ""
  20. Exit Sub
  21. End If
  22. '判断卡号是否还在使用
  23. txtSQl = "select * from student_Info where cardno ='" & Trim(txtCardID.Text) & "'"
  24. Set mrcd = ExecuteSQL(txtSQl, MsgText)
  25. If mrcd.EOF Then
  26. MsgBox "卡号不存在或者已经不用了", 0 + 48, "提示" '判断卡号是否被使用
  27. Exit Sub
  28. End If
  29. '判断输入的卡号是否在上机
  30. txtSQl = "select * from OnLine_Info where cardno = '" & Trim(txtCardID.Text) & "'"
  31. Set mrce = ExecuteSQL(txtSQl, MsgText)
  32. If mrce.EOF Then
  33. MsgBox "此卡号没有上机,请重新选择!", vbOKOnly + vbExclamation, "警告"
  34. txtID.Text = ""
  35. txtDepartment.Text = ""
  36. txtType.Text = ""
  37. txtName.Text = ""
  38. txtSex.Text = ""
  39. txtOndate.Text = ""
  40. txtOntime.Text = ""
  41. txtCash.Text = ""
  42. txtOffdate.Text = ""
  43. txtOfftime.Text = ""
  44. txtCosttime.Text = ""
  45. txtCost.Text = ""
  46. txtCardID.Text = ""
  47. Exit Sub
  48. Else
  49. '此卡正在上机
  50. txtID.Text = mrcd.Fields(1)
  51. txtDepartment.Text = mrcd.Fields(4)
  52. txtType.Text = mrcd.Fields(14)
  53. txtName.Text = mrcd.Fields(2)
  54. txtSex.Text = mrcd.Fields(3)
  55. txtOndate.Text = mrce.Fields(6)
  56. txtOntime.Text = mrce.Fields(7)
  57. c = mrce.Fields(7)
  58. txtOntime.Text = c
  59. mrce.Delete
  60. Label4.Caption = mrce.RecordCount
  61. End If
  62. txtOffdate.Text = Format(Date, "yyyy-mm-dd")
  63. txtOfftime.Text = Format(time, "hh:mm")
  64. b = Abs(DateDiff("n", txtOfftime, c)) '计算上机时间
  65. txtCosttime.Text = b
  66. '计算上机时间
  67. txtSQl = "select * from BasicData_Info"
  68. Set mrc = ExecuteSQL(txtSQl, MsgText)
  69. '第一种情况:上机时间<准备时间
  70. If Val(txtCosttime.Text) < Val(mrc.Fields(4)) Then '上机时间小于准备时间
  71. txtCost.Text = 0
  72. txtCosttime.Text = 0
  73. '第二种情况:准备时间<上机时间<最下上机时间
  74. ElseIf Val(mrc.Fields(4)) <= Val(txtCosttime.Text) And Val(txtCosttime.Text) <= Val(mrc.Fields(3)) Then '准备时间<上机时间<最少上机时间
  75. txtCost.Text = 1
  76. txtCash.Text = Val(mrcd.Fields(7)) - 1
  77. mrcd.Fields(7) = Trim(txtCash.Text)
  78. mrcd.Update
  79. '第二种情况:上机时间>最小上机时间
  80. ElseIf Val(txtCosttime.Text) > Val(mrc.Fields(3)) Then '上机时间>最小上机时间
  81. Usetime = Val(txtCosttime.Text) - Val(mrc.Fields(4))
  82. UnitNumber = Usetime Mod Val(mrc.Fields(2))
  83. If UnitNumber = 0 Then '用时小于周期
  84. UnitNumber = Int(Usetime / Val(mrc.Fields(2))) 'int是取整函数,取证原则是比括号中的数值小的最接近的整数,不进行四舍五入。 所以 比-2.9还小的整数是-3,同样分析知道,int(2.9)=2
  85. Else '用时大于周期 如 90/60=1.5 int(1.5)=1 说以要+1
  86. UnitNumber = Int(Usetime / Val(mrc.Fields(2))) + 1
  87. End If
  88. End If
  89. '判断此时用户类别
  90. If mrcd.Fields(14) = "固定用户" Then
  91. a = Val(mrc.Fields(0))
  92. Else
  93. a = Val(mrc.Fields(1))
  94. End If
  95. '计算最后的花销
  96. txtCost.Text = Format(UnitNumber * a, "0.0") '计算最后的花费
  97. txtCash.Text = Val(mrcd.Fields(7)) - Val(txtCost.Text)
  98. mrcd.Fields(7) = Trim(txtCash.Text)
  99. mrcd.Update
  100. txtSQl = "select * from Line_Info " '‘where '正常上机' and cardno ='" & Trim(txtCardID.Text) & "'"
  101. Set mrcc = ExecuteSQL(txtSQl, MsgText)
  102. mrcc.AddNew
  103. mrcc.Fields(1) = Trim(txtCardID.Text)
  104. mrcc.Fields(2) = Trim(txtID.Text)
  105. mrcc.Fields(3) = Trim(txtName.Text)
  106. mrcc.Fields(4) = Trim(txtDepartment.Text)
  107. mrcc.Fields(5) = Trim(txtSex.Text)
  108. mrcc.Fields(6) = txtOndate.Text
  109. mrcc.Fields(7) = txtOntime.Text
  110. mrcc.Fields(14) = Trim(VBA.Environ("computername")) '获取计算机名
  111. mrcc.Fields(11) = Trim(txtCost.Text)
  112. mrcc.Fields(12) = Trim(txtCash.Text)
  113. mrcc.Fields(8) = Trim(txtOffdate.Text)
  114. mrcc.Fields(9) = Trim(txtOfftime.Text)
  115. mrcc.Fields(10) = Trim(txtCosttime.Text)
  116. mrcc.Fields(13) = Trim("正常下机")
  117. mrcc.Update</span>

3、关于报表

  1. '日结账单刷新
  2. Dim txtSQl As String
  3. Dim mrc As ADODB.Recordset
  4. Dim MsgText As String
  5. GRDisplayViewer1.Stop
  6. txtSQl = "select * from CheckDay_info"
  7. '创建报表对象
  8. Set Report = New grproLibCtl.GridppReport
  9. '载入报表模版文件
  10. Report.LoadFromFile (App.Path & "\daycheck.grf")
  11. '设置数据连接串
  12. Report.DetailGrid.Recordset.ConnectionString = ConnectString
  13. Report.DetailGrid.Recordset.QuerySQL = txtSQl
  14. '显示报表中的内容
  15. ' GRDisplayViewer1.Refresh '刷新
  16. GRDisplayViewer1.Report = Report
  17. GRDisplayViewer1.Start
  18. ' 给报表赋值
  19. Report.ParameterByName("EndDate").Value = Format(Now, "yyyy-mm-dd")
  20. Report.ParameterByName("XX").Value = Trim(Username)
  21. Report.ParameterByName("OPT").Value = Trim(Username)

最后机房已经完成的差不多了,就更新到这里吧!机房给我的教训就是以后再做一个系统之前一定要先理清思路。

发表评论

表情:
评论列表 (有 0 条评论,197人围观)

还没有评论,来说两句吧...

相关阅读

    相关 机房收费系统———总结

        经历了这么长的时间,机房收费系统总算告一段落了。期间的各种痛苦与折磨、辛酸与泪水也都已经成为过去。不管过程如何,结果是Vb版的机房收费系统结束了。     我做的机房

    相关 机房收费系统总结

      历时两个多月,机房收费系统终于完成了,师傅验收还算满意,当然也还存在一些问题,好好总结一下吧,好歹也是两个多月的努力。   从一般用户开始,查看余额和修改密码比较简单,在

    相关 机房收费系统—心得

            从开学到现在,机房经历了两个月的时间,其实真正踏下心来做的时间超不过三个星期。那些没有进展的时间也不是说完全浪费掉了。应该说理思路,了解系统,系统流程逐渐清晰的

    相关 机房收费系统——结账

        机房收费系统的逻辑性很强。师傅也说了,第一次做机房,首要的是理清思路,明白它的逻辑。     做到结账这里,跟大家分享一下我对结账的一点理解: ![SouthEas

    相关 机房收费系统(一)

    1.在MDI窗体上不能使用控件,需要用一个容器来放控件,比如使用picturebox控件来当做容器,这时真能体会到巨人的力量,这时我查到了另外一种方法。用一个窗体做容器,把这些