第一次机房收费系统—选择下机

     选择机房的思路是先将表控件中的文件进行的标记,对选择的卡号做标记,进行选择下机操作后,要判断是否存在做标记的卡号,将卡号一次赋值与变量,当前卡号下机完成后,将表中本条记录删除,判断表中是否还存在做标记的卡号,有,则继续进行下机操作,直到无记录,显示下机成功。
 

机房选择下机顺序

otxtSQL = "select * from Online_info where cardno='" & MSFlexGrid1.TextMatrix(1, 0) & "'"
            Set omrc = ExecuteSQL(otxtSQL, omsgText)
            
            
     If omrc.EOF Then
          MsgBox "没有学生上机", , "提示"
          Exit Sub
     Else
            
        Do While Not MSFlexGrid1.Rows = 1
            
            otxtSQL = "select * from Online_info where cardno='" & MSFlexGrid1.TextMatrix(1, 0) & "'"
            Set omrc = ExecuteSQL(otxtSQL, omsgText)
            
            stxtSQL = "select * from student_info where cardno='" & MSFlexGrid1.TextMatrix(1, 0) & "'"
            Set Smrc = ExecuteSQL(stxtSQL, smsgText)
            
            consumetime = DateDiff("n", omrc.Fields(7), Time)
            
            '判断用户
            
           If Trim(Smrc.Fields(14)) = "固定用户" Then
                consume = consumetime / 2
            Else
                consume = consumetime / 3
           End If
            
            i = Trim(Trim(Smrc.Fields(7))) - consume
            
                   If Val(i) < 0 Then
                MsgBox "余额不足,不能下机,请充值后下机", , "提示"
                Exit Sub
                End If
            
            '更新 stuednt表中的余额
            updatestxtSQL = "update student_info set cash=" & i & " where cardno='" & MSFlexGrid1.TextMatrix(1, 0) & "'"
            Set updatesmrc = ExecuteSQL(updatestxtSQL, updatesMsgText)
            
            '更新line 表中的数据
            ltxtSQL = "select * from Line_info where cardno='" & MSFlexGrid1.TextMatrix(1, 0) & "'" & "and ontime='" & omrc.Fields(7) & "'"
            Set lmrc = ExecuteSQL(ltxtSQL, lmsgText)
            

                lmrc.Fields(8) = Format(Now(), "yyyy-MM-dd")
                lmrc.Fields(9) = Format(Now(), "HH:mm:ss")
                lmrc.Fields(10) = Trim(consumetime)
                lmrc.Fields(11) = Trim(consume)
                lmrc.Fields(12) = i
                lmrc.Fields(13) = "正常下机"
                lmrc.Fields(14) = "GUO"
        
                lmrc.Update
                '删除online 表中的数据
                deleotxtSQL = "delete from online_info where cardno='" & MSFlexGrid1.TextMatrix(1, 0) & "'"
                Set deleomrc = ExecuteSQL(deleotxtSQL, deleomsgText)
                
                MSFlexGrid1.RemoveItem 1
     

        Loop
        
        
        
         omrc.Close
         Smrc.Close
         lmrc.Close
        MsgBox "全部下机成功", vbOKOnly + vbExclamation, "提示"
    End If

猜你喜欢

转载自blog.csdn.net/qq_42428269/article/details/97619367