前言
结账对于笔者也是一块新知识,首先是这个控件,他显示信息是什么原理,我就看了好多博客......
正文
代码实现全过程如下:
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,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,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,3) = "时间" do while Not mrc1.EOF .Rows = .Rows + 1 .CellAlignment = 4 .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
原文地址:https://www.jb51.cc/vb/256204.html
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。