【机房】结账——SSTab的使用
        【摘要】 
                    
                        
                    
                    机房收费系统中管理员可以对操作员进行结账操作。 
窗体界面:  
结账用到了SSTab选项卡,SSTab的添加:添加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
  
 
 - 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
- 38
- 39
- 40
- 41
- 42
- 43
- 44
- 45
- 46
- 47
- 48
- 49
- 50
- 51
- 52
- 53
- 54
- 55
- 56
- 57
- 58
- 59
- 60
- 61
- 62
- 63
- 64
- 65
- 66
- 67
- 68
- 69
- 70
- 71
- 72
- 73
- 74
- 75
- 76
- 77
- 78
- 79
- 80
- 81
- 82
- 83
- 84
- 85
- 86
- 87
- 88
- 89
- 90
- 91
- 92
- 93
- 94
- 95
- 96
- 97
- 98
- 99
- 100
- 101
- 102
- 103
- 104
- 105
- 106
- 107
- 108
- 109
- 110
- 111
- 112
- 113
- 114
- 115
- 116
- 117
- 118
- 119
- 120
- 121
- 122
- 123
- 124
- 125
- 126
- 127
- 128
- 129
- 130
- 131
- 132
- 133
- 134
- 135
- 136
- 137
- 138
- 139
- 140
- 141
- 142
- 143
- 144
- 145
- 146
- 147
- 148
- 149
- 150
- 151
- 152
- 153
- 154
- 155
- 156
- 157
- 158
- 159
- 160
- 161
- 162
- 163
- 164
- 165
- 166
- 167
- 168
- 169
- 170
- 171
- 172
- 173
- 174
- 175
- 176
- 177
- 178
- 179
- 180
- 181
- 182
汇总选项卡下面还有一个结账的控件
结账的时候需要连接学生表、充值表和退卡表,综合上机的时间和卡里余额进行结账。
代码展示:
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
  
 
 - 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
- 38
- 39
- 40
- 41
- 42
- 43
- 44
感谢阅读~
文章来源: blog.csdn.net,作者:张艳伟_Laura,版权归原作者所有,如需转载,请联系作者。
原文链接:blog.csdn.net/Laura__zhang/article/details/107528088
        【版权声明】本文为华为云社区用户转载文章,如果您发现本社区中有涉嫌抄袭的内容,欢迎发送邮件进行举报,并提供相关证据,一经查实,本社区将立刻删除涉嫌侵权内容,举报邮箱:
            cloudbbs@huaweicloud.com
        
        
        
        
        
        
        - 点赞
- 收藏
- 关注作者
 
            
 
           
评论(0)