VB机房收费系统08——结账
2018-01-09 15:11
369 查看
前言
结账对于笔者也是一块新知识,首先是这个控件,他显示信息是什么原理,我就看了好多博客......正文
如图,中间的控件叫做SSTab。SSTab控件提供了一组选项卡,每个都充当一个容器,包含了其他的控件。
本窗体的运行原理是当我们选择操作员用户名后,显示操作员真实姓名。显示此人的工作记录在下面五个栏目中:购卡、充值、退卡、临时用户、汇总。
这里有个重点,计算总的售卡数,总的收款金额。我们计算时需要用到Val函数,把字符串型的代码转换成数值型。
代码实现全过程如下:
Private Sub comboid_Click() '购卡 Dim txtsql As String Dim msgtext As String Dim mrc As ADODB.Recordset '查找管理员 txtsql = "select * from User_Info where userID='" & comboid.Text & "'" Set mrc = ExecuteSQL(txtsql, msgtext) comboname.Text = mrc.Fields(3) mrc.Close txtsql = "select * from student_Info where UserID='" & comboid.Text & "'" Set mrc1 = ExecuteSQL(txtsql, msgtext) '显示购卡信息 With MSFlexGrid1 .Rows = 1 .CellAlignment = 4 .TextMatrix(0, 0) = "学号" .TextMatrix(0, 1) = "卡号" .TextMatrix(0, 2) = "日期" .TextMatrix(0, 3) = "时间" Do While Not mrc1.EOF .Rows = .Rows + 1 .CellAlignment = 4 .TextMatrix(.Rows - 1, 0) = Trim(mrc1.Fields(1)) .TextMatrix(.Rows - 1, 1) = Trim(mrc1.Fields(0)) .TextMatrix(.Rows - 1, 2) = Trim(mrc1.Fields(12)) .TextMatrix(.Rows - 1, 3) = Trim(mrc1.Fields(13)) mrc1.MoveNext Loop .Rows = .Rows - 1 Text1.Text = Int(.Rows - 1) '汇总:售卡张数 End With mrc1.Close '充值 Dim mrcrecharge As ADODB.Recordset '查找管理员 txtsql = "select * from ReCharge_Info where userID='" & comboid.Text & "'" Set mrcrecharge = ExecuteSQL(txtsql, msgtext) '显示购卡信息 With MSFlexGrid2 .Rows = 1 .CellAlignment = 4 .TextMatrix(0, 0) = "学号" .TextMatrix(0, 1) = "卡号" .TextMatrix(0, 2) = "充值金额" .TextMatrix(0, 3) = "日期" .TextMatrix(0, 4) = "时间" Do While Not mrcrecharge.EOF .Rows = .Rows + 1 .CellAlignment = 4 .TextMatrix(.Rows - 1, 0) = Trim(mrcrecharge.Fields(1)) .TextMatrix(.Rows - 1, 1) = Trim(mrcrecharge.Fields(2)) .TextMatrix(.Rows - 1, 2) = Trim(mrcrecharge.Fields(3)) .TextMatrix(.Rows - 1, 3) = Trim(mrcrecharge.Fields(4)) .TextMatrix(.Rows - 1, 4) = Trim(mrcrecharge.Fields(5)) Text3.Text = Val(.TextMatrix(.Rows - 1, 2)) + Val(Text3.Text) '汇总:充值金额 mrcrecharge.MoveNext Loop End With mrcrecharge.Close '退卡 Dim mrccancelcard As ADODB.Recordset '查找管理员 txtsql = "select * from CancelCard_Info where userID='" & comboid.Text & "'" Set mrccancelcard = ExecuteSQL(txtsql, msgtext) '显示购卡信息 With MSFlexGrid3 .Rows = 1 .CellAlignment = 4 .TextMatrix(0, 0) = "学号" .TextMatrix(0, 1) = "卡号" .TextMatrix(0, 2) = "日期" .TextMatrix(0, 3) = "时间" .TextMatrix(0, 4) = "退卡金额" Do While Not mrccancelcard.EOF .Rows = .Rows + 1 .CellAlignment = 4 .TextMatrix(.Rows - 1, 0) = Trim(mrccancelcard.Fields(0)) .TextMatrix(.Rows - 1, 1) = Trim(mrccancelcard.Fields(1)) .TextMatrix(.Rows - 1, 2) = Trim(mrccancelcard.Fields(3)) .TextMatrix(.Rows - 1, 3) = Trim(mrccancelcard.Fields(4)) .TextMatrix(.Rows - 1, 4) = Trim(mrccancelcard.Fields(2)) Text5.Text = Val(mrccancelcard.Fields(2)) + Val(Text5.Text) '汇总:退卡金额 mrccancelcard.MoveNext Loop .Rows = .Rows - 1 Text2.Text = Int(.Rows - 1) '汇总:退卡张数 End With mrccancelcard.Close '临时用户 txtsql = "select * from student_Info where UserID='" & comboid.Text & "'" & " " & "and type ='" & "临时用户" & "'" Set mrc1 = ExecuteSQL(txtsql, msgtext) '显示购卡信息 With MSFlexGrid4 .Rows = 1 .CellAlignment = 4 .TextMatrix(0, 0) = "学号" .TextMatrix(0, 1) = "卡号" .TextMatrix(0, 2) = "日期" .TextMatrix(0, 3) = "时间" Do While Not mrc1.EOF .Rows = .Rows + 1 .CellAlignment = 4 .TextMatrix(.Rows - 1, 0) = Trim(mrc1.Fields(1)) .TextMatrix(.Rows - 1, 1) = Trim(mrc1.Fields(0)) .TextMatrix(.Rows - 1, 2) = Trim(mrc1.Fields(12)) .TextMatrix(.Rows - 1, 3) = Trim(mrc1.Fields(13)) Text4.Text = Val(mrc1.Fields(7)) + Val(Text4.Text) '汇总:临时收费金额 mrc1.MoveNext Loop End With mrc1.Close Text6.Text = Val(Text1.Text) - Val(Text2.Text) '汇总:总售卡数 Text7.Text = Val(Text3.Text) - Val(Text5.Text) '汇总: 应收金额 End Sub Private Sub Command1_Click() '结账 Dim txtsql As String Dim msgtext As String Dim mrc As ADODB.Recordset txtsql = "select * from student_Info where UserID='" & comboid.Text & "'" & " " & "and Ischeck ='" & "未结账" & "'" Set mrc = ExecuteSQL(txtsql, msgtext) mrc.Fields(11) = "结账" mrc.Update mrc.Close MsgBox "结账成功!", vbonly + vbExclamation, "提示" Text1.Text = "" Text2.Text = "" Text3.Text = "" Text4.Text = "" Text5.Text = "" Text6.Text = "" Text7.Text = "" End Sub Private Sub Form_Load() comboid.AddItem "12" End Sub '退出 Private Sub SSTab1_Click(PreviousTab As Integer) Select Case SSTab1.Tab Case 5 Unload Me End Select End Sub
相关文章推荐
- VB查询数据库之结账——机房收费系统总结(五)
- VB查询数据库之结账——机房收费系统总结(五)
- 机房收费系统之结账与报表(三)VB与报表代码《一学就会傻瓜版》
- 【VB与数据库】——机房收费系统之结账
- VB机房收费系统09——日结账单和周结账单
- 【机房收费系统——报表与vb交互之日结账和周结账】
- 【VB与数据库】机房收费系统设计阶段之结账
- vb.net机房收费系统-错误是我们的必由之路
- 机房收费系统vb.net之打包与部署(二)
- VB.NET机房收费系统之报表制作(绑定数据源)(一)
- 机房收费系统之结账
- 【机房收费系统】VB中增删改查实践探索
- 【机房收费系统】VB中如何将数据导入excel2013
- 模板方法模式——【VB.NET机房收费系统(组合查询)】
- 小结:VB.NET机房收费系统个人版
- VB.NET<机房收费系统个人重构版>你都学会了什么(之一)
- 【VB与数据库】机房收费系统--跨窗体传值
- VB与数据库(三)之迟到的机房收费系统总结
- 机房收费系统(VB.NET)——超详细的报表制作过程
- 机房收费系统 之结账