机房收费系统之结账与报表

前端之家收集整理的这篇文章主要介绍了机房收费系统之结账与报表前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

@H_502_4@机房收费系统在几天前终于告一个段落了,这篇是关于最后阶段结账与报表的总结。@H_502_4@

@H_502_4@结账,首先清楚该窗体的作用是:管理员对每个操作员工作情况的查看。其中包括售卡数量,充值金额以及退还金额。@H_502_4@

@H_502_4@知道全局后,操作上就会简单不少了。我们需要做的就是将遍历学生信息表、充值信息表和退卡信息表后的该操作员和结账状态为“未结账”的所有金额总计。然后在单击结账后,将汇总后的信息写入结账表,将前面三个表中的结账状态标记为“已结账”。@H_502_4@

结账流程:@H_502_4@

Part One:@H_502_4@将所有操作员ID和Name提取出来,以供选择。(下面以选择姓名为例)@H_502_4@

  1. <strong><span style="font-family:KaiTi_GB2312;font-size:18px;"> '将数据库中操作员的UserName提供出来
  2. strTxtsql = "select UserID from tb_User where userlevel='操作员'"
  3. Set mrc = Executesql(strTxtsql,strMsgText)
  4.  
  5. '点击操作员姓名,相应地出现其ID
  6. strTxtsql = "select * from tb_User where username='" & comboOperatorName.Text & "'"
  7. Set mrc = Executesql(strTxtsql,strMsgText)
  8. comboOperatorID.Text = mrc.Fields(0)</span></strong>
Part Two:@H_502_4@从ID或Name中任意选择一个,便将该操作员的工作记录显示在SSTAB控件中,全部是“未结账”状态下的工作记录。(下面以充值选项为例)@H_502_4@
  1. <strong><span style="font-family:KaiTi_GB2312;font-size:18px;"> '充值选项
  2. RechargeFlexGrid.Visible = True
  3. '从充值表中查看是否有该操作员的充值工作记录
  4. strTxtsql = "select * from tb_Recharge where checkState = '未结账' and UserID= '" & Trim(comboOperatorID.Text) & "'"
  5. Set mrc = Executesql(strTxtsql,strMsgText)
  6. If mrc.EOF = True Then '该操作员没有充值工作记录
  7. With RechargeFlexGrid
  8. .Rows = 1
  9. .TextMatrix(0,0) = "卡号"
  10. .TextMatrix(0,1) = "学号"
  11. .TextMatrix(0,2) = "日期"
  12. .TextMatrix(0,3) = "时间"
  13. .TextMatrix(0,4) = "充值金额"
  14. End With
  15. Else
  16. With RechargeFlexGrid '该操作员充值工作记录显示
  17. .Rows = 1
  18. .TextMatrix(0,0) = "卡号"
  19. .TextMatrix(0,1) = "学号"
  20. .TextMatrix(0,2) = "日期"
  21. .TextMatrix(0,3) = "时间"
  22. .TextMatrix(0,4) = "充值金额"
  23. .ColWidth(0) = 800
  24. .ColWidth(1) = 800
  25. .ColWidth(2) = 2000
  26. .ColWidth(3) = 2000
  27. .ColWidth(4) = 2000
  28. Do While Not mrc.EOF
  29. .Rows = .Rows + 1
  30. .TextMatrix(.Rows - 1,0) = mrc.Fields(2)
  31. .TextMatrix(.Rows - 1,1) = mrc.Fields(1)
  32. .TextMatrix(.Rows - 1,2) = mrc.Fields(4)
  33. .TextMatrix(.Rows - 1,3) = mrc.Fields(5)
  34. .TextMatrix(.Rows - 1,4) = mrc.Fields(3)
  35. .ColWidth(0) = 800
  36. .ColWidth(1) = 800
  37. .ColWidth(2) = 2000
  38. .ColWidth(3) = 2000
  39. .ColWidth(4) = 2000
  40. '该操作员通过学生充值所获得的金额
  41. Rechargemoney = Rechargemoney + Trim(mrc.Fields(3))
  42. mrc.MoveNext
  43. Loop
  44. '该操作员的售卡金额
  45. txtRechargeSum.Text = Trim(Rechargemoney)
  46. mrc.Close
  47. End With
  48. '该操作员的注册、充值和退卡后的总金额
  49. txtSum.Text = Val(Trim(txtSum.Text)) + Val(Trim(txtRechargeSum.Text)) - Val(Trim(txtReturnCardSum.Text))
  50. End If</span></strong>
Part Three:@H_502_4@确认结账。将所有表中结账状态改变。(以充值表为例)@H_502_4@
  1. <strong><span style="font-family:KaiTi_GB2312;font-size:18px;">'将所有信息修改为“已结账”
  2. strTxtsql = "select * from tb_recharge where userid ='" & Trim(comboOperatorID.Text) & "'" & " and checkstate = '" & "未结账" & "'"
  3. Set mrc = Executesql(strTxtsql,strMsgText)
  4. Do While mrc.EOF = False
  5. mrc.Fields(7) = "已结账"
  6. mrc.Update
  7. mrc.MoveNext
  8. Loop
  9. mrc.Close</span></strong>
并将数据写入到结账表中。@H_502_4@
  1. <strong><span style="font-family:KaiTi_GB2312;font-size:18px;">'连接结账表,将新的信息写入表中
  2. '向结账表中添加数据
  3. strTxtsql = "select * from tb_checkout where userid='" & Trim(comboOperatorID.Text) & "'"
  4. Set mrc = Executesql(strTxtsql,strMsgText)
  5. '如果没有新的记录则提示
  6. If Trim(txtSaleCardCount.Text) = "0" And Trim(txtRechargeSum.Text) = "0" And _
  7. Trim(txtReturnCardCount.Text) = "0" And Trim(txtReturnCardSum.Text) = "0" And _
  8. Trim(txtSaleCardSum.Text) = "0" And Trim(txtSum.Text) = "0" Then
  9. MsgBox "数据未更新,结账操作无效!",vbOKOnly + vbExclamation,"结账提示"
  10. End If
  11. '如果有新的工作记录
  12. strTxtsql = "select * from tb_checkout where userid='" & Trim(comboOperatorID.Text) & "'"
  13. Set mrc = Executesql(strTxtsql,strMsgText)
  14. If mrc.EOF = True Then
  15. lastbalance = " 0"
  16. Else
  17. lastbalance = mrc.Fields(1)
  18. End If
  19. '向结账表中添加数据
  20. mrc.AddNew
  21. mrc.Fields(0) = frmLogin.txtUserName.Text
  22. mrc.Fields(1) = lastbalance
  23. mrc.Fields(2) = txtRechargeSum.Text
  24. mrc.Fields(3) = txtCasualSum.Text
  25. mrc.Fields(4) = txtReturnCardSum.Text
  26. mrc.Fields(5) = txtSum.Text
  27. mrc.Fields(6) = Date
  28. mrc.Fields(7) = "已结账"
  29. mrc.Update
  30. mrc.Close
  31.  
  32. MsgBox "已成功结账!","结账提示"</span></strong>
Part Four:@H_502_4@解决问题。如果按照上面的流程去做,那么在结账表中只会出现该管理员点击“结账”后的记录。如果该管理员某天休息,没有及时结账,那么这一天的数据变会丢失。那么账单中肯定会少钱了,这系统做的就不合格了。所以,在此之前,我将所有信息都先存在了另一个新表中,不管是该管理员结账了还是没结账,数据都写进去。@H_502_4@
  1. <strong><span style="font-family:KaiTi_GB2312;font-size:18px;"> '不管是否结账,都将该操作员的信息写入DayCheck中
  2. '向表DayCheck中添加数据
  3. strTxtsql = "select * from tb_daycheck where date ='" & Trim(Label10.Caption) & "'"
  4. Set mrc = Executesql(strTxtsql,strMsgText)
  5. If mrc.EOF = True Then
  6. Trim(lastbalance) = 0
  7. mrc.AddNew
  8. mrc.Fields(0) = lastbalance
  9. mrc.Fields(1) = txtRechargeSum.Text
  10. mrc.Fields(2) = txtCasualSum.Text
  11. mrc.Fields(3) = txtReturnCardSum.Text
  12. mrc.Fields(4) = txtSum.Text
  13. mrc.Fields(5) = Date
  14. mrc.Update
  15. mrc.Close
  16. Else
  17. mrc.MoveLast
  18. lastbalance = Trim(mrc.Fields(4))
  19. mrc.MoveNext
  20. mrc.AddNew
  21. mrc.Fields(0) = lastbalance
  22. mrc.Fields(1) = txtRechargeSum.Text
  23. mrc.Fields(2) = txtCasualSum.Text
  24. mrc.Fields(3) = txtReturnCardSum.Text
  25. mrc.Fields(4) = txtSum.Text
  26. mrc.Fields(5) = Date
  27. mrc.Update
  28. mrc.Close
  29. End If</span></strong>
Part Five:@H_502_4@制作报表,以便查询账单。@H_502_4@

@H_502_4@报表,一个以前没有接触的东西。刚开始,可能无从下手,不过我们可以站在巨人的肩膀上,如果你的报表还没有做,推荐一个师哥的博客:@H_502_4@

用VB做报表(一)http://www.jb51.cc/article/p-plxqmxhp-re.html@H_502_4@

用VB做报表(二)http://www.jb51.cc/article/p-afgqilmj-re.html@H_502_4@

很详细的讲解,一个报表,也可以轻松搞定。 最后,说说做这个部分的感受。还是感觉全局认识很重要,如果心中没有谱,肯定不知道如何下手。与其浪费时间坐在那瞎想,瞎敲,还不如花些时间把流程弄明白。这样会起到一个事半功倍的效果。@H_502_4@

猜你在找的VB相关文章