学生系统之查:查询成绩信息流程

查询成绩信息流程图:

这里写图片描述

查询成绩信息代码部分

一、myflesgrid数据加载

 With myflexgrid
        .CellAlignment = 4           '对齐方式中中对齐
        .TextMatrix(1, 0) = "考试编号"
        .TextMatrix(1, 1) = "学号"
        .TextMatrix(1, 2) = "姓名"
        .TextMatrix(1, 3) = "班号"
        .TextMatrix(1, 4) = "课程名称"
        .TextMatrix(1, 5) = "分数"
    End With

二、检测查询方式

txtSQL = "select * from result_Info where "
    If Check1(0).Value Then
    ......
    End If

    If Check1(1).Value Then
    ......
    End If

     If Check1(2).Value Then
    ......
    End If

三、判断文本框是否为空,是否为数字

If Trim(txtSID.Text) = "" Then
            sMeg = "学号不能为空"
            MsgBox sMeg, vbOKOnly + vbExclamation, "警告"
            txtSID.SetFocus
            Exit Sub
        Else
            If Not IsNumeric(Trim(txtSID.Text)) Then
                MsgBox "请输入数字!", vbOKOnly + vbExclamation, "警告"
                Exit Sub
                txtSID.SetFocus
            End If
            dd(0) = True
            txtSQL = txtSQL & "student_ID='" & Trim(txtSID.Text) & "'"
        End If

四、各查询方式的叠加

Dim dd(4) As Boolean
    If Check1(0).Value Then
        If ...
        Else...
            dd(0) = True
            txtSQL = txtSQL & "student_ID='" & Trim(txtSID.Text) & "'"
        End If
    End If

    If Check1(1).Value Then
        If...
        Else...
            dd(1) = True
            If dd(0) Then
                txtSQL = txtSQL & "and student_Name='" & txtName.Text & "'"
            Else
                txtSQL = txtSQL & "student_Name='" & txtName.Text & "'"
            End If
        End If
    End If

    If Check1(2).Value Then
        If ...
        Else
            dd(2) = True
            If dd(0) Or dd(1) Then
                txtSQL = txtSQL & "and course_Name='" & txtCourse.Text & "'"
            Else
                txtSQL = txtSQL & "course_Name='" & txtCourse.Text & "'"
            End If
        End If
    End If

    If Not (dd(0) Or dd(1) Or dd(2) Or dd(3)) Then
        MsgBox "请设置查询方式!", vbOKOnly + vbExclamation, "警告"
        Exit Sub
    End If

查询成绩信息窗体的特点:多项选择的查询。

这就涉及到了多项查询数据库内多个内容的衔接,它的逻辑是我们要着重梳理的。

猜你喜欢

转载自blog.csdn.net/elsa15/article/details/80286898