📄 user_result.aspx.vb
字号:
Imports System.Data
Imports System.Data.SqlClient
Public Class user_result
Inherits System.Web.UI.Page
#Region " Web 窗体设计器生成的代码 "
'该调用是 Web 窗体设计器所必需的。
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
End Sub
Protected WithEvents Panel1 As System.Web.UI.WebControls.Panel
Protected WithEvents LinkButton1 As System.Web.UI.WebControls.LinkButton
Protected WithEvents LinkButton2 As System.Web.UI.WebControls.LinkButton
Protected WithEvents Label1 As System.Web.UI.WebControls.Label
'注意: 以下占位符声明是 Web 窗体设计器所必需的。
'不要删除或移动它。
Private designerPlaceholderDeclaration As System.Object
Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init
'CODEGEN: 此方法调用是 Web 窗体设计器所必需的
'不要使用代码编辑器修改它。
InitializeComponent()
End Sub
#End Region
Public Sub message(ByVal str As String)
Dim strscript As String = "<script language=javascript>alert('" & str & "')</script>"
RegisterClientScriptBlock("系统消息", strscript)
End Sub
Public Sub Sub_load()
Dim q As New SqlClass
q.Open()
Dim str As String
Dim dxi As Integer
Dim mxi As Integer
Dim pdi As Integer
Dim pxi As Integer
str = "select * from 试卷名称表 where 试卷名称='" & Session("table") & "'"
Dim myreader As SqlDataReader = q.GetDataReader(str)
myreader.Read()
dxi = myreader("单项选择题量")
mxi = myreader("多项选择题量")
pdi = myreader("判断题量")
pxi = myreader("排序题量")
myreader.Close()
str = "select * from " & Session("table") & Session("username") & "暂时"
myreader = q.GetDataReader(str)
Dim q2 As New SqlClass
q2.Open()
Dim i As Integer
Panel1.Width = New Unit(700)
Dim l As New Literal
Dim sum As Integer = 0
l.Text = "一、单项选择题" & "<br>"
Panel1.Controls.Add(l)
For i = 0 To dxi - 1
myreader.Read()
Dim tm As String = myreader("试题")
Dim fs As Integer = myreader("试题分数")
Dim an As String = myreader("答案")
Dim user_an As String
If myreader("用户答案") Is DBNull.Value Then
user_an = "没有回答 "
Else
user_an = myreader("用户答案")
End If
If an = user_an Then
str = "update " & Session("table") & Session("username") & "暂时 set 用户得分=" & fs & " where ID=" & i + 1
q2.ExecuteSQL(str)
sum += fs
Else
str = "update " & Session("table") & Session("username") & "暂时 set 用户得分=0 where ID=" & i + 1
q2.ExecuteSQL(str)
End If
Dim t As New Label
t.Width = New Unit(700)
t.Text = (i + 1).ToString() & ". " & tm & " (" & fs & "分)"
Panel1.Controls.Add(t)
Dim t2 As New Label
t2.Width = New Unit(300)
t2.Text = "正确答案:" & "<br>" & an
Panel1.Controls.Add(t2)
Dim t3 As New Label
t3.Width = New Unit(300)
t3.Text = "你的答案:" & "<br>" & user_an
Panel1.Controls.Add(t3)
Dim t8 As New Literal
t8.Text = "<br>" & "<br>"
Panel1.Controls.Add(t8)
Next
Dim l1 As New Literal
l1.Text = "<br>" & "二、多项选择题" & "<br>"
Panel1.Controls.Add(l1)
For i = 0 To mxi - 1
myreader.Read()
Dim tm As String = myreader("试题")
Dim fs As String = myreader("试题分数")
Dim an As String = myreader("答案")
Dim user_an As String
If myreader("用户答案") Is DBNull.Value Then
user_an = "没有回答 "
Else
user_an = myreader("用户答案")
End If
If an = user_an Then
str = "update " & Session("table") & Session("username") & "暂时 set 用户得分=" & fs & " where ID=" & dxi + i + 1
q2.ExecuteSQL(str)
sum += fs
Else
str = "update " & Session("table") & Session("username") & "暂时 set 用户得分=0 where ID=" & dxi + i + 1
q2.ExecuteSQL(str)
End If
Dim t As New Label
t.Width = New Unit(700)
t.Text = (i + 1).ToString() & ". " & tm & " (" & fs & "分)"
Panel1.Controls.Add(t)
Dim t2 As New Label
t2.Width = New Unit(300)
t2.Text = "正确答案:" & "<br>" & an
Panel1.Controls.Add(t2)
Dim t3 As New Label
t3.Width = New Unit(300)
t3.Text = "你的答案:" & "<br>" & user_an
Panel1.Controls.Add(t3)
Dim t8 As New Literal
t8.Text = "<br>" & "<br>"
Panel1.Controls.Add(t8)
Next
Dim l2 As New Literal
l2.Text = "<br>" & "三、判断题" & "<br>"
Panel1.Controls.Add(l2)
For i = 0 To pdi - 1
myreader.Read()
Dim tm As String = myreader("试题")
Dim fs As String = myreader("试题分数")
Dim an As String = myreader("答案")
Dim user_an As String
If myreader("用户答案") Is DBNull.Value Then
user_an = "没有回答 "
Else
user_an = myreader("用户答案")
End If
If an = user_an Then
str = "update " & Session("table") & Session("username") & "暂时 set 用户得分=" & fs & " where ID=" & dxi + mxi + i + 1
q2.ExecuteSQL(str)
sum += fs
Else
str = "update " & Session("table") & Session("username") & "暂时 set 用户得分=0 where ID=" & dxi + mxi + i + 1
q2.ExecuteSQL(str)
End If
Dim t As New Label
t.Width = New Unit(700)
t.Text = (i + 1).ToString() & ". " & tm & " (" & fs & "分)"
Panel1.Controls.Add(t)
Dim t2 As New Label
t2.Width = New Unit(300)
t2.Text = "正确答案:" & "<br>" & an
Panel1.Controls.Add(t2)
Dim t3 As New Label
t3.Width = New Unit(300)
t3.Text = "你的答案:" & "<br>" & user_an
Panel1.Controls.Add(t3)
Dim t8 As New Literal
t8.Text = "<br>" & "<br>"
Panel1.Controls.Add(t8)
Next
Dim l3 As New Literal
l3.Text = "<br>" & "四、排序题" & "<br>"
Panel1.Controls.Add(l3)
For i = 0 To pxi - 1
myreader.Read()
Dim tm As String = myreader("试题")
Dim fs As String = myreader("试题分数")
Dim an As String = myreader("答案")
Dim user_an As String
If myreader("用户答案") Is DBNull.Value Then
user_an = "没有回答 "
Else
user_an = myreader("用户答案")
End If
If an = user_an Then
str = "update " & Session("table") & Session("username") & "暂时 set 用户得分=" & fs & " where ID=" & dxi + mxi + pdi + i + 1
q2.ExecuteSQL(str)
sum += fs
Else
str = "update " & Session("table") & Session("username") & "暂时 set 用户得分=0 where ID=" & dxi + mxi + pdi + i + 1
q2.ExecuteSQL(str)
End If
Dim t As New Label
t.Width = New Unit(700)
t.Text = (i + 1).ToString() & ". " & tm & " (" & fs & "分)"
Panel1.Controls.Add(t)
Dim t2 As New Label
t2.Width = New Unit(300)
t2.Text = "正确答案:" & "<br>" & an
Panel1.Controls.Add(t2)
Dim t3 As New Label
t3.Width = New Unit(300)
t3.Text = "你的答案:" & "<br>" & user_an
Panel1.Controls.Add(t3)
Dim t8 As New Literal
t8.Text = "<br>" & "<br>"
Panel1.Controls.Add(t8)
Next
myreader.Close()
str = "update 成绩登记表 set 成绩=" & sum & ",当前状态='已交卷' where 试卷名称='" & Session("table") & Session("username") & "' and 当前状态='正在考试'"
q.ExecuteSQL(str)
q.close()
q2.close()
Label1.Text = Label1.Text & sum
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
End If
Sub_load()
End Sub
Private Sub LinkButton2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles LinkButton2.Click
Dim q As New SqlClass
q.Open()
Dim str As String
str = "if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[" & Session("table") & Session("username") & "]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)drop table [dbo].[" & Session("table") & Session("username") & "]"
q.ExecuteSQL(str)
str = "create table " & Session("table") & Session("username") & "([ID] [int] NOT NULL , [试题] [varchar] (400) COLLATE Chinese_PRC_CI_AS NOT NULL ,[试题分数] [int] NOT NULL ,[答案] [varchar] (50) COLLATE Chinese_PRC_CI_AS NULL ,[试题ID] [int] NOT NULL ,[用户答案] [varchar] (50) COLLATE Chinese_PRC_CI_AS NULL ,[用户得分] [int] NULL ,[试题题型] [varchar] (50) COLLATE Chinese_PRC_CI_AS NOT NULL ,[附加参数] [int] NULL ) ON [PRIMARY]"
q.ExecuteSQL(str)
Dim q1 As New SqlClass
q1.Open()
Dim str1 As String = "select * from " & Session("table") & Session("username") & "暂时"
Dim myreader As SqlDataReader = q1.GetDataReader(str1)
While (myreader.Read())
str = "insert into " & Session("table") & Session("username") & " values (" & myreader("ID") & ",'" & myreader("试题") & "'," & myreader("试题分数") & ",'" & myreader("答案") & "'," & myreader("试题ID") & ",'" & myreader("用户答案") & "'," & myreader("用户得分") & ",'" & myreader("试题题型") & "'," & myreader("附加参数") & ")"
q.ExecuteSQL(str)
End While
Response.Redirect("mainselect.aspx")
str = "drop table " & Session("table") & Session("username")
q.ExecuteSQL(str)
Response.Redirect("mainselect.aspx")
str = "drop table " & Session("table") & Session("username") & "暂时"
q.ExecuteSQL(str)
q.close()
q1.close()
End Sub
Private Sub LinkButton1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles LinkButton1.Click
Dim q As New SqlClass
q.Open()
Response.Redirect("mainselect.aspx")
Dim str As String
Str = "drop table " & Session("table") & Session("username")
q.ExecuteSQL(str)
str = "drop table " & Session("table") & Session("username") & "暂时"
q.ExecuteSQL(str)
q.close()
End Sub
End Class
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -