⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 test1.aspx.vb

📁 VB.NET和SQLSERver2000编写在线考试系统
💻 VB
📖 第 1 页 / 共 2 页
字号:
        For i = 0 To dxi - 1
            myreader.Read()
            Dim tm As String = myreader("试题")
            Dim fs As Integer = myreader("试题分数")
            Dim an As String = myreader("答案")
            Dim t As New Label
            t.Width = New Unit(700)
            t.Text = (i + 1).ToString() & ".  " & tm & "   (" & fs & "分)"
            Panel2.Controls.Add(t)
            Dim r As New RadioButtonList
            r.Items.Add("A")
            r.Items.Add("B")
            r.Items.Add("C")
            r.Items.Add("D")
            r.RepeatDirection = RepeatDirection.Horizontal
            dxt_result.Add(r)
            Panel2.Controls.Add(r)
            Dim t8 As New Literal
            t8.Text = "<br>" & "<br>"
            Panel2.Controls.Add(t8)
        Next
        For i = 0 To mxi - 1
            myreader.Read()
            Dim tm As String = myreader("试题")
            Dim fs As String = myreader("试题分数")
            Dim an As String = myreader("答案")
            Dim t As New Label
            t.Width = New Unit(700)
            t.Text = (i + 1).ToString() & ".  " & tm & "   (" & fs & "分)"
            Panel3.Controls.Add(t)
            Dim x As New Literal
            x.Text = "请输入答案:  "
            Dim t2 As New TextBox
            Panel3.Controls.Add(x)
            mxt_result.Add(t2)
            Panel3.Controls.Add(t2)
            Dim t8 As New Literal
            t8.Text = "<br>" & "<br>"
            Panel3.Controls.Add(t8)
        Next
        For i = 0 To pdi - 1
            myreader.Read()
            Dim tm As String = myreader("试题")
            Dim fs As String = myreader("试题分数")
            Dim an As String = myreader("答案")
            Dim t As New Label
            t.Width = New Unit(700)
            t.Text = (i + 1).ToString() & ".  " & tm & "   (" & fs & "分)"
            Panel4.Controls.Add(t)
            Dim r As New RadioButtonList
            r.Items.Add("对")
            r.Items.Add("错")
            r.RepeatDirection = RepeatDirection.Horizontal
            pdt_result.Add(r)
            Panel4.Controls.Add(r)
            Dim t8 As New Literal
            t8.Text = "<br>" & "<br>"
            Panel4.Controls.Add(t8)
        Next
        For i = 0 To pxi - 1
            myreader.Read()
            Dim tm As String = myreader("试题")
            Dim fs As String = myreader("试题分数")
            Dim an As String = myreader("答案")
            Dim t As New Label
            t.Width = New Unit(700)
            t.Text = (i + 1).ToString() & ".  " & tm & "   (" & fs & "分)"
            Panel5.Controls.Add(t)
            Dim x As New Literal
            x.Text = "请输入答案:  "
            Panel3.Controls.Add(x)
            Dim t2 As New TextBox
            pxt_result.Add(t2)
            Panel5.Controls.Add(t2)
            Dim t8 As New Literal
            t8.Text = "<br>" & "<br>"
            Panel5.Controls.Add(t8)
        Next
        myreader.Close()
        q.close()
    End Sub
    Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        '在此处放置初始化页的用户代码
        If Not IsPostBack Then
            Try
                If (Session("userpower") <> 1) Then
                    Response.End()
                End If
            Catch ex As Exception
                Response.Write("您还登录,请您先登录<a href='Login.aspx'>首页</a>")
                Response.End()
            End Try
            first_load()
        End If
        first()

        Label1.Text = Session("table")
    End Sub

    Private Sub LinkButton1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles LinkButton1.Click
        Panel2.Visible = True
        Panel3.Visible = False
        Panel4.Visible = False
        Panel5.Visible = False
        Session("time") = (CInt(Hour.Text) * 3600 + CInt(Minute.Text) * 60 + CInt(Second.Text)).ToString()
    End Sub

    Private Sub LinkButton2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles LinkButton2.Click
        Panel3.Visible = True
        Panel2.Visible = False
        Panel4.Visible = False
        Panel5.Visible = False
        Session("time") = (CInt(Hour.Text) * 3600 + CInt(Minute.Text) * 60 + CInt(Second.Text)).ToString()
    End Sub

   

  
    Public Sub save()
        Dim q As New SqlClass
        q.Open()
        Dim str As String
        Dim i As Integer
        For i = 0 To dxt_result.Count - 1
            If dxt_result(i).selectedindex <> -1 Then
                str = "update " & Session("table") & Session("username") & "暂时 set 用户答案='" & dxt_result(i).selectedvalue & "' where ID=" & i + 1
                q.ExecuteSQL(str)
            End If
        Next
        Dim sum As Integer = dxt_result.Count
        For i = 0 To mxt_result.Count - 1
            If mxt_result(i).text <> "" Then
                str = "update " & Session("table") & Session("username") & "暂时 set 用户答案='" & mxt_result(i).text & "' where ID=" & sum + i + 1
                q.ExecuteSQL(str)
            End If
        Next
        sum += mxt_result.Count
        For i = 0 To pdt_result.Count - 1
            If pdt_result(i).selectedindex <> -1 Then
                str = "update " & Session("table") & Session("username") & "暂时 set 用户答案='" & pdt_result(i).selectedvalue & "' where ID=" & sum + i + 1
                q.ExecuteSQL(str)
            End If
        Next
        sum += pdt_result.Count
        For i = 0 To pxt_result.Count - 1
            If dxt_result(i).text <> "" Then
                str = "update " & Session("table") & Session("username") & "暂时 set 用户答案='" & pxt_result(i).text & "' where ID=" & sum + i + 1
                q.ExecuteSQL(str)
            End If
        Next
        str = "select 时间 from 试卷名称表 where 试卷名称='" & Session("table") & "'"
        Dim ti As Integer = q.GetInt(str)
        Session("time") = (CInt(Hour.Text) * 3600 + CInt(Minute.Text) * 60 + CInt(Second.Text)).ToString()
        str = "update 成绩登记表 " & " set 时间=" & ti - Session("time") & " where 试卷名称='" & Session("table") & Session("username") & "' and   当前状态='正在考试'"
        q.ExecuteSQL(str)

        q.close()
    End Sub
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        save()
        Session("time") = (CInt(Hour.Text) * 3600 + CInt(Minute.Text) * 60 + CInt(Second.Text)).ToString()
        message("保存成功")
    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        save()
        Session("time") = (CInt(Hour.Text) * 3600 + CInt(Minute.Text) * 60 + CInt(Second.Text)).ToString()
        Response.Redirect("user_result.aspx")
    End Sub

    Private Sub LinkButton3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles LinkButton3.Click
        Panel2.Visible = False
        Panel3.Visible = False
        Panel4.Visible = True
        Panel5.Visible = False
        Session("time") = (CInt(Hour.Text) * 3600 + CInt(Minute.Text) * 60 + CInt(Second.Text)).ToString()
    End Sub

    Private Sub LinkButton4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles LinkButton4.Click
        Panel2.Visible = False
        Panel3.Visible = False
        Panel4.Visible = False
        Panel5.Visible = True
        Session("time") = (CInt(Hour.Text) * 3600 + CInt(Minute.Text) * 60 + CInt(Second.Text)).ToString()
    End Sub
End Class

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -