【机房】结账——SSTab的使用

机房收费系统中管理员可以对操作员进行结账操作。

窗体界面:
在这里插入图片描述

结账用到了SSTab选项卡,SSTab的添加:添加SSTab选项卡

每一个选项下面对应的连接数据库和想要查询的内容都是不一样的。

代码展示:

Private Sub SSTab1_Click(PreviousTab As Integer)
    
    Dim txtSQL As String
    Dim MsgText As String
    Dim mrc As Recordset
    
     Select Case SSTab1.Tab
            
        Case 0      '显示购卡
            MSHFlexGrid1.Rows = 1
            With MSHFlexGrid1
                .CellAlignment = 4
                .TextMatrix(0, 0) = "学号"
                .TextMatrix(0, 1) = "卡号"
                .TextMatrix(0, 2) = "日期"
                .TextMatrix(0, 3) = "时间"
            End With
            
            '连接数据库 student 表
            txtSQL = "select * from student_info where UserID='" & Trim(ComboUserID.Text) & "'and Ischeck='" & "未结账" & "'"
            Set mrc = ExecuteSQL(txtSQL, MsgText)

            Do While Not mrc.EOF

                With MSHFlexGrid1
                    .Rows = .Rows + 1
                    .CellAlignment = 4
                    .TextMatrix(.Rows - 1, 0) = mrc.Fields(1)
                    .TextMatrix(.Rows - 1, 1) = mrc.Fields(0)
                    .TextMatrix(.Rows - 1, 2) = mrc.Fields(12)
                    .TextMatrix(.Rows - 1, 3) = mrc.Fields(13)
                    
                    '移动到下一条记录
                    mrc.MoveNext
                End With
            Loop
            mrc.Close
                
        Case 1      '显示充值
            MSHFlexGrid2.Rows = 1
            With MSHFlexGrid2
                .CellAlignment = 4
                .TextMatrix(0, 0) = "学号"
                .TextMatrix(0, 1) = "卡号"
                .TextMatrix(0, 2) = "充值金额"
                .TextMatrix(0, 3) = "日期"
                .TextMatrix(0, 4) = "时间"
            End With
            
            '连接数据库 Recharge 表
            txtSQL = "select * from Recharge_info where UserID='" & Trim(ComboUserID.Text) & "'and status='" & "未结账" & "'"
            Set mrc = ExecuteSQL(txtSQL, MsgText)

            Do While Not mrc.EOF

                With MSHFlexGrid2
                    .Rows = .Rows + 1
                    .CellAlignment = 4
                    .TextMatrix(.Rows - 1, 0) = mrc.Fields(1)
                    .TextMatrix(.Rows - 1, 1) = mrc.Fields(2)
                    .TextMatrix(.Rows - 1, 2) = mrc.Fields(3)
                    .TextMatrix(.Rows - 1, 3) = mrc.Fields(4)
                    .TextMatrix(.Rows - 1, 4) = mrc.Fields(5)
                    
                    '移动到下一条记录
                    mrc.MoveNext
                End With
            Loop
            mrc.Close
        
        Case 2      '显示退卡
            MSHFlexGrid3.Rows = 1
            With MSHFlexGrid3
                .CellAlignment = 4
                .TextMatrix(0, 0) = "学号"
                .TextMatrix(0, 1) = "卡号"
                .TextMatrix(0, 2) = "退卡金额"
                .TextMatrix(0, 3) = "日期"
                .TextMatrix(0, 4) = "时间"
            End With
            
            '连接数据库 CancelCard 表
            txtSQL = "select * from CancelCard_info where UserID='" & Trim(ComboUserID.Text) & "'and status='" & "未结账" & "'"
            Set mrc = ExecuteSQL(txtSQL, MsgText)

            Do While Not mrc.EOF

                With MSHFlexGrid3
                    .Rows = .Rows + 1
                    .CellAlignment = 4
                    .TextMatrix(.Rows - 1, 0) = mrc.Fields(0)
                    .TextMatrix(.Rows - 1, 1) = mrc.Fields(1)
                    .TextMatrix(.Rows - 1, 2) = mrc.Fields(2)   '退卡金额
                    .TextMatrix(.Rows - 1, 3) = mrc.Fields(3)   '日期
                    .TextMatrix(.Rows - 1, 4) = mrc.Fields(4)   '时间
                    
                    '移动到下一条记录
                    mrc.MoveNext
                End With
            Loop
            mrc.Close
            
        Case 3      '显示临时用户
            MSHFlexGrid4.Rows = 1
            With MSHFlexGrid4
                .CellAlignment = 4
                .TextMatrix(0, 0) = "学号"
                .TextMatrix(0, 1) = "卡号"
                .TextMatrix(0, 2) = "日期"
                .TextMatrix(0, 3) = "时间"
            End With
            
            '连接数据库 sutdent表 临时用户
            txtSQL = "select * from student_info where UserID='" & Trim(ComboUserID.Text) & "' and type='" & Trim(Label11.Caption) & "'"
            Set mrc = ExecuteSQL(txtSQL, MsgText)

            Do While Not mrc.EOF

                With MSHFlexGrid4
                    .Rows = .Rows + 1
                    .CellAlignment = 4
                    .TextMatrix(.Rows - 1, 0) = mrc.Fields(1)   '学号
                    .TextMatrix(.Rows - 1, 1) = mrc.Fields(0)   '卡号
                    .TextMatrix(.Rows - 1, 2) = mrc.Fields(12)   '日期
                    .TextMatrix(.Rows - 1, 3) = mrc.Fields(13)   '时间
                    
                    '移动到下一条记录
                    mrc.MoveNext
                End With
            Loop
            mrc.Close
        
        Case 4      '显示汇总
        
            Dim mrcStu As ADODB.Recordset       '连接student表
            Dim mrcCancel As ADODB.Recordset    '连接cancelCard表
            Dim mrcRe As ADODB.Recordset        '连接Rechange表
            
            '连接student表
            txtSQL = "select * from student_info where UserID='" & Trim(ComboUserID.Text) & "'and Ischeck='" & "未结账" & "'"
            Set mrcStu = ExecuteSQL(txtSQL, MsgText)
            
                txtSellCardSum.Text = mrcStu.RecordCount       '售卡张数
            
            '连接数据库 CancelCard 表
            txtSQL = "select * from CancelCard_info where UserID='" & Trim(ComboUserID.Text) & "'and status='" & "未结账" & "'"
            Set mrcCancel = ExecuteSQL(txtSQL, MsgText)
                
                txtBackCardSum.Text = mrcCancel.RecordCount       '退卡张数
                
                '退卡金额
                If mrcCancel.EOF = True Then
                    txtBackCardMoney.Text = "0"
                Else
                    txtBackCardMoney.Text = Val(mrcCancel.Fields(2))
                End If
            
            '连接数据库 Recharge 表
            txtSQL = "select sum(addmoney) from Recharge_info where UserID='" & Trim(ComboUserID.Text) & "'and status='" & "未结账" & "'"
            Set mrcRe = ExecuteSQL(txtSQL, MsgText)
                
'                mrcRe.Open
                '充值金额
                If IsNull(Trim(mrcRe.Fields(0))) Then
                    txtRecharge.Text = "0"
                Else
                    txtRecharge.Text = Val(mrcRe.Fields(0))
                End If
            
            '计算总售卡数与应收金额
            txtSellCardActual.Text = Val(txtSellCardSum.Text) - Val(txtBackCardSum.Text)    '总售卡张数
            txtCollectMoney.Text = Val(txtRecharge.Text) - Val(txtBackCardMoney.Text) '应收金额
        
        Case 5      '退出
            
            Unload Me
            
        End Select

End Sub


汇总选项卡下面还有一个结账的控件

结账的时候需要连接学生表、充值表和退卡表,综合上机的时间和卡里余额进行结账。

代码展示:

Private Sub cmdAccounts_Click()
    Dim txtSQL As String
    Dim MsgText As String
    Dim mrcStu As ADODB.Recordset       '连接student表
    Dim mrcCancel As ADODB.Recordset    '连接cancelCard表
    Dim mrcRe As ADODB.Recordset        '连接Rechange表
            
            '连接student表
    txtSQL = "select * from student_info where UserID='" & Trim(ComboUserID.Text) & "'"
    Set mrcStu = ExecuteSQL(txtSQL, MsgText)
            
        Do While Not mrcStu.EOF
            mrcStu!Ischeck = "结账"
            mrcStu.Update
            mrcStu.MoveNext
        Loop
            
        mrcStu.Close
            
    '连接数据库 CancelCard 表
    txtSQL = "select * from CancelCard_info where UserID='" & Trim(ComboUserID.Text) & "'"
    Set mrcCancel = ExecuteSQL(txtSQL, MsgText)
                
        Do While Not mrcCancel.EOF
            mrcCancel!Status = "结账"
            mrcCancel.Update
            mrcCancel.MoveNext
        Loop
        
        mrcCancel.Close
               
    '连接数据库 Recharge 表
    txtSQL = "select * from Recharge_info where UserID='" & Trim(ComboUserID.Text) & "'"
    Set mrcRe = ExecuteSQL(txtSQL, MsgText)
                
    Do While Not mrcRe.EOF
            mrcRe!Status = "结账"
            mrcRe.Update
            mrcRe.MoveNext
    Loop
    mrcRe.Close
    MsgBox "结账成功", 64, "温馨提示"
    Exit Sub
End Sub

感谢阅读~

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 5
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 5
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

张_Laura

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值