机房收费系统之余额查询

                  机房收费系统中有几个窗体用到查询。

    查询需要解决2个问题:

    1、卡号已注册,即存在该怎样做   

    2、卡号未注册,即不存在该怎样做    

          

   下面以 学生查询余额窗体为例


          机房收费系统之余额查询_第1张图片


<span style="font-size:18px;">Private Sub Command1_Click()
   Dim txtSQL As String
   Dim MsgText As String
   Dim mrc As ADODB.Recordset
   
   '判断卡号收是否为空,是否是数字
   If Trim(Text1.Text) = "" Then
          
         MsgBox "卡号不能为空!", vbOKOnly + vbExclamation, "警告"
         Text1.SetFocus
         Exit Sub
      End If
      
    If Not IsNumeric(Text1.Text) Then
          MsgBox "请输入数字!", vbOKOnly + vbExclamation, "警告"
          Exit Sub
          Text1.SetFocus
    End If
   txtSQL = "select * from student_Info where cardno= '" & Text1.Text & "'"
   Set mrc = ExecuteSQL(txtSQL, MsgText)
   
   '检查卡号是否存在
   If mrc.EOF Then
        MsgBox "没有此卡号,请注册!", vbOKOnly + vbExclamation, "提示"     ' 若不存在,弹出提示框并清空文本框中内容
        Text2.Text = ""
        Text3.Text = ""
        Text4.Text = ""
        Text5.Text = ""
        Text6.Text = ""
        Text7.Text = ""
        Text7.Text = ""
        Text8.Text = ""
        Text9.Text = ""
        Text10.Text = ""
        
    Else
        Text2.Text = mrc.Fields(1)                                          ' 若存在,进行查询
        Text3.Text = mrc.Fields(2)
        Text4.Text = mrc.Fields(3)
        Text5.Text = mrc.Fields(4)
        Text6.Text = mrc.Fields(5)
        Text7.Text = mrc.Fields(6)
        Text8.Text = mrc.Fields(10)
        Text9.Text = mrc.Fields(8)
        Text10.Text = mrc.Fields(7)
    End If
   
   mrc.Close                                                                 '关闭数据库

End Sub</span>


  

 
 

你可能感兴趣的:(机房收费系统之余额查询)