📄 webfrmachieve.aspx.vb
字号:
Public Class WebfrmAchieve
Inherits System.Web.UI.Page
#Region " Web 窗体设计器生成的代码 "
Protected WithEvents Image2 As System.Web.UI.WebControls.Image
Protected WithEvents Label1 As System.Web.UI.WebControls.Label
Protected WithEvents Image1 As System.Web.UI.WebControls.Image
Protected WithEvents HyperLink1 As System.Web.UI.WebControls.HyperLink
Protected WithEvents TextBox2 As System.Web.UI.WebControls.TextBox
Protected WithEvents TextBox1 As System.Web.UI.WebControls.TextBox
Protected WithEvents Label2 As System.Web.UI.WebControls.Label
Protected WithEvents TextBox3 As System.Web.UI.WebControls.TextBox
Protected WithEvents TextBox4 As System.Web.UI.WebControls.TextBox
Protected WithEvents Label4 As System.Web.UI.WebControls.Label
Protected WithEvents Label8 As System.Web.UI.WebControls.Label
Protected WithEvents Label9 As System.Web.UI.WebControls.Label
Protected WithEvents Label12 As System.Web.UI.WebControls.Label
Protected WithEvents Button4 As System.Web.UI.WebControls.Button
Protected WithEvents Button1 As System.Web.UI.WebControls.Button
Protected WithEvents Button2 As System.Web.UI.WebControls.Button
Protected WithEvents Button3 As System.Web.UI.WebControls.Button
Protected WithEvents Button5 As System.Web.UI.WebControls.Button
'该调用是 Web 窗体设计器所必需的。
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
End Sub
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 sqlstr As String
Public DS As DataSet
Private Sub Page_Load(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles MyBase.Load
'在此处放置初始化页的用户代码
If IsPostBack = False Then
DS = New DataSet()
DS.Clear()
DS = GetDataFromDB(sqlstr)
DS = GetAllData()
Indexs = 0
ShowData(Indexs)
End If
End Sub
Public Function GetAllData() As DataSet
sqlstr = "SELECT * FROM resultInfo"
DS = New DataSet()
DS.Clear()
DS = GetDataFromDB(sqlstr)
If Not DS Is Nothing Then
Return DS
End If
End Function
Public Sub ShowData(ByVal index As Integer)
DS = GetAllData()
If index < 0 Then
index = DS.Tables(0).Rows.Count - 1
End If
If index >= DS.Tables(0).Rows.Count Then
index = 0
End If
Me.TextBox1.Text = DS.Tables(0).Rows(index)("学号")
Me.TextBox2.Text = DS.Tables(0).Rows(index)("课程编号")
Me.TextBox3.Text = DS.Tables(0).Rows(index)("考试时间")
Me.TextBox4.Text = DS.Tables(0).Rows(index)("分数")
Me.Label12.Text = index + 1 & " OF " & DS.Tables(0).Rows.Count
End Sub
Private Sub Button4_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles Button4.Click
Indexs = Indexs + 1
ShowData(Indexs)
End Sub
Private Sub Button5_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles Button5.Click
Indexs = Indexs - 1
ShowData(Indexs)
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles Button1.Click
If IsPostBack Then
If GetDataFRomForm.Number = "" Then
Exit Sub
End If
If GetDataFRomForm.Curse = "" Then
Exit Sub
End If
If IsDate(GetDataFRomForm.TestDate) = False Then
Exit Sub
End If
Dim score As New Acheive()
score = GetDataFRomForm()
sqlstr = "INSERT INTO resultInfo (学号,课程编号,考试时间,分数)" & _
" VALUES ('" & score.Number & "','" & score.Curse & "'," & _
"'" & score.TestDate & "','" & score.Score & "')"
If UpdateDataBase(sqlstr) = True Then
GetAllData()
ShowData(0)
End If
End If
End Sub
Public Function GetDataFRomForm() As Acheive
Dim score As New Acheive()
score.Number = Trim(Me.TextBox1.Text)
score.Curse = Trim(Me.TextBox2.Text)
score.TestDate = Trim(Me.TextBox3.Text)
score.Score = CInt(Me.TextBox4.Text)
Return score
End Function
Private Sub Button2_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles Button2.Click
sqlstr = "UPDATE resultInfo SET 考试时间='" & Trim(Me.TextBox3.Text) & "'," & _
"分数='" & CInt(Me.TextBox4.Text) & "' WHERE 学号=" & _
"'" & Trim(Me.TextBox1.Text) & "' AND 课程编号='" & Trim(Me.TextBox2.Text) & "'"
If UpdateDataBase(sqlstr) = True Then
GetAllData()
ShowData(0)
End If
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles Button3.Click
sqlstr = "DELETE FROM resultInfo WHERE (学号='" & Trim(Me.TextBox1.Text) & "' " & _
"AND 课程编号='" & Trim(Me.TextBox2.Text) & "')"
If UpdateDataBase(sqlstr) = True Then
GetAllData()
ShowData(0)
End If
End Sub
End Class
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -