【机房】学生上机状态查看

举报
Laura_张 发表于 2022/08/27 00:04:00 2022/08/27
【摘要】 机房收费系统中的操作者可以查看学生上机状态 窗体界面: 查询 查询学生上机信息,用到了组合查询,点击阅读:组合查询 显示全部 在这里可以查看所有的上机账户 若是当前没有上机用户,那么就提示当...

机房收费系统中的操作者可以查看学生上机状态

窗体界面:

在这里插入图片描述

查询

查询学生上机信息,用到了组合查询,点击阅读:组合查询

显示全部

在这里可以查看所有的上机账户
若是当前没有上机用户,那么就提示当前没有人员上机,并且后面的上机管理直接隐藏不可见。

Private Sub showAll_Click()
    Dim txtSQL As String
    Dim MsgText As String
    Dim mrc As ADODB.Recordset
    
    MSHFlexGrid1.Rows = 1
     
    txtSQL = "select * from online_info"
    Set mrc = ExecuteSQL(txtSQL, MsgText)
    
    
    '添加表头
    With MSHFlexGrid1
        .CellAlignment = 4
        .TextMatrix(0, 0) = "卡号"
        .TextMatrix(0, 1) = "姓名"
        .TextMatrix(0, 2) = "上机日期"
        .TextMatrix(0, 3) = "上机时间"
        .TextMatrix(0, 4) = "机器号"
        .TextMatrix(0, 5) = "选中标记"
    End With
    
    If mrc.EOF = True Then
        MsgBox "当前没有人员上机", 64, "温馨提示"
        computerManagement.Visible = False
    Else
        
        '判断是否移动到数据集对象的最后一条记录
        Do While Not mrc.EOF
        
            With MSHFlexGrid1
            
                .Rows = .Rows + 1
                .CellAlignment = 4
                .TextMatrix(.Rows - 1, 0) = mrc.Fields(0)
                .TextMatrix(.Rows - 1, 1) = mrc.Fields(3)
                .TextMatrix(.Rows - 1, 2) = mrc.Fields(6)
                .TextMatrix(.Rows - 1, 3) = mrc.Fields(7)
                .TextMatrix(.Rows - 1, 4) = mrc.Fields(8)
                mrc.MoveNext
                
            End With
        Loop
        mrc.Close
    End If
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

上机管理

上机管理包括所有同学下机,选中同学下机

进行下机操作的时候,需要先判断是否有正在上机的人员,如果没有上机的人员就没有办法进行下机操作(需要连接数据库).
下机操作还需要判断用户类型,然后计算上机时长、计算费用。


Private Sub allOffLine_Click()
    Rem:连接Online表判断是否有上机的人员
    txtSQL = "select * from Online_info"
    Set mrcOnLine = ExecuteSQL(txtSQL, MsgText)
    
    Do While Not MSHFlexGrid1.Rows = 1
    
    If mrcOnLine.EOF = True Then
        MsgBox "没有人员上机,无法进行下机操作", 64, "温馨提示"
    Else
        
        '查询上机表
        txtSQL = "select * from Online_info where cardno='" & MSHFlexGrid1.TextMatrix(1, 0) & "'"
        Set mrcOnLine = ExecuteSQL(txtSQL, MsgText)
        
        '计算消费时长。运用到了DateDiff函数
        Day = DateDiff("d", mrcOnLine.Fields(6), Date)       '计算上机下机的日期差
        Minute = DateDiff("n", mrcOnLine.Fields(7), Time)        '计算上机下机的同日时间差
        ConsumeTime = 1440 * Val(Day) + Minute             '计算总时间差,分钟为单位

        '查询学生表
        txtSQLStu = "select * from student_Info where cardno='" & MSHFlexGrid1.TextMatrix(1, 0) & "'"
        Set mrcStu = ExecuteSQL(txtSQLStu, MsgtextStu)
        
        '查询基础数据表
        txtSQLBasic = "select * from Basicdata_info"
        Set mrcBasic = ExecuteSQL(txtSQLBasic, MsgtextBasic)
            
            '判断用户类型,扣钱
            If Trim(mrcOnLine.Fields(1)) = "固定用户" Then
                Money = Round((mrcBasic.Fields(0) / 60 * ConsumeTime)) '计算固定用户金额
                Balance = Val(mrcStu.Fields(7)) - Val(Money)
            Else
                Money = Round((mrcBasic.Fields(1) / 60 * ConsumeTime)) '计算固定用户金额
                Balance = Val(mrcStu.Fields(7)) - Val(Money)
               
               '修改student表中的余额
                mrcStu.Fields(7) = Trim(Balance)
                mrcStu.Fields(11) = "未结账"
            End If
             mrcOnLine.Delete
            MSHFlexGrid1.RemoveItem 1    '删除控件中的本行数据
    End If
    Loop
    MsgBox "下机成功", 64, "温馨提示"
    frmMain.lblPeople.Caption = 0
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

选中的同学下机

这个时候不需要判断是否有人员上机了,需要连接数据库查询上机表,计算消费时长,计算费用。
需要注意这些被下机的账户是未结账状态。

Private Sub chooseOffLine_Click()
    Dim m, a As Integer
    
    m = MSHFlexGrid1.Rows - 1
    For a = 1 To m
            
    If MSHFlexGrid1.TextMatrix(m, 5) = "√" Then
                
    '查询上机表
        txtSQL = "select * from Online_info where cardno='" & MSHFlexGrid1.TextMatrix(m, 0) & "'"
        
        Set mrcOnLine = ExecuteSQL(txtSQL, MsgText)
            
            '计算消费时长。运用到了DateDiff函数
            Day = DateDiff("d", mrcOnLine.Fields(6), Date)       '计算上机下机的日期差
            Minute = DateDiff("n", mrcOnLine.Fields(7), Time)        '计算上机下机的同日时间差
            ConsumeTime = 1440 * Val(Day) + Minute             '计算总时间差,分钟为单位
        
            '查询学生表
            txtSQLStu = "select * from student_Info where cardno='" & MSHFlexGrid1.TextMatrix(m, 0) & "'"
            
            Set mrcStu = ExecuteSQL(txtSQLStu, MsgtextStu)
                
                '查询基础数据表
                txtSQLBasic = "select * from Basicdata_info"
                
                Set mrcBasic = ExecuteSQL(txtSQLBasic, MsgtextBasic)
                    
                    '判断用户类型,扣钱
                    If Trim(mrcOnLine.Fields(1)) = "固定用户" Then
                        Money = Round((mrcBasic.Fields(0) / 60 * ConsumeTime)) '计算固定用户金额
                        Balance = Val(mrcStu.Fields(7)) - Val(Money)
                    Else
                        Money = Round((mrcBasic.Fields(1) / 60 * ConsumeTime)) '计算固定用户金额
                        Balance = Val(mrcStu.Fields(7)) - Val(Money)
                       
                       '修改student表中的余额
                        mrcStu.Fields(7) = Trim(Balance)
                        mrcStu.Fields(11) = "未结账"
                    End If
                        MsgBox "下机成功", 64, "温馨提示"
                        mrcOnLine.Delete
                        frmMain.lblPeople.Caption = mrcOnLine.RecordCount  '显示当前上机人数

                        MSHFlexGrid1.RemoveItem m
                        
                    m = m - 1
    Else
    m = m - 1
    End If
Next
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

下机成功之后还需要将上机记录写进line表

Rem:将上机记录写进line表
            txtSQLLine = "select * from line_info where cardno='" & MSHFlexGrid1.TextMatrix(1, 0) & "'"
            Set mrcLine = ExecuteSQL(txtSQLLine, MsgtextLine)
                mrcLine.AddNew
                mrcLine.Fields(1) = mrcOnLine.Fields(0)         '卡号
                mrcLine.Fields(2) = mrcOnLine.Fields(2)      '学号
                mrcLine.Fields(3) = mrcOnLine.Fields(3)      '姓名
                mrcLine.Fields(4) = mrcOnLine.Fields(1)        '系别
                mrcLine.Fields(5) = mrcOnLine.Fields(5)        '性别
                mrcLine.Fields(6) = mrcOnLine.Fields(6)       '上机日期
                mrcLine.Fields(7) = mrcOnLine.Fields(7)        '上机时间
                mrcLine.Fields(8) = Date        '下机日期
                mrcLine.Fields(9) = Time        '下机时间
                mrcLine.Fields(10) = ConsumeTime       '消费时间
                mrcLine.Fields(11) = Money        '消费金额
                mrcLine.Fields(12) = Balance       '余额
                mrcLine.Fields(13) = "正常下机"
                mrcLine.Fields(14) = Trim(VBA.Environ("computername"))
                mrcLine.Update
            

  
 
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20

在选中用户的时候有一个标记
选中的账户改变颜色,并且可以跨行选中

Private Sub MSHFlexGrid1_MouseDown(Button As Integer, Shift As Integer, x As Single, y As Single)
    
    '获取选中不连续行的权限,及实现多行选中
    Dim col As Integer
    
    If MSHFlexGrid1.TextMatrix(MSHFlexGrid1.Row, 5) = "√" Then
        MSHFlexGrid1.TextMatrix(MSHFlexGrid1.Row, 5) = ""
        
        '改变行颜色(变为没选中之前的)
        For col = 0 To MSHFlexGrid1.Cols - 1
            MSHFlexGrid1.col = col
            MSHFlexGrid1.CellBackColor = vbWhite
        Next col
    Else
        MSHFlexGrid1.TextMatrix(MSHFlexGrid1.Row, 5) = "√"
        '改变行颜色(选中后的颜色)
        For col = 0 To MSHFlexGrid1.Cols - 1
            MSHFlexGrid1.col = col
            MSHFlexGrid1.CellBackColor = vbYellow
        Next col
    End If
End Sub

  
 
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22

感谢阅读,欢迎斧正~

文章来源: blog.csdn.net,作者:张艳伟_Laura,版权归原作者所有,如需转载,请联系作者。

原文链接:blog.csdn.net/Laura__zhang/article/details/107463865

【版权声明】本文为华为云社区用户转载文章,如果您发现本社区中有涉嫌抄袭的内容,欢迎发送邮件进行举报,并提供相关证据,一经查实,本社区将立刻删除涉嫌侵权内容,举报邮箱: cloudbbs@huaweicloud.com
  • 点赞
  • 收藏
  • 关注作者

评论(0

0/1000
抱歉,系统识别当前为高风险访问,暂不支持该操作

全部回复

上滑加载中

设置昵称

在此一键设置昵称,即可参与社区互动!

*长度不超过10个汉字或20个英文字符,设置后3个月内不可修改。

*长度不超过10个汉字或20个英文字符,设置后3个月内不可修改。