📄 testclass.aspx.vb
字号:
Imports System.Data.SqlClient
Public Class TestClass
Inherits clsBiz
Protected WithEvents btnNewTestClass As System.Web.UI.WebControls.Button
Protected WithEvents drpTestClass As System.Web.UI.WebControls.DropDownList
Protected WithEvents btnAddTestProject As System.Web.UI.WebControls.Button
Protected WithEvents btnDelTestProject As System.Web.UI.WebControls.Button
Protected WithEvents lblErrorMessage As System.Web.UI.WebControls.Label
Protected WithEvents listAllProject As System.Web.UI.WebControls.ListBox
Protected WithEvents listCurrentProject As System.Web.UI.WebControls.ListBox
Protected WithEvents txtNewTestClass As System.Web.UI.WebControls.TextBox
Protected WithEvents btnDelTestClass As System.Web.UI.WebControls.Button
#Region " Web Form Designer Generated Code "
'This call is required by the Web Form Designer.
<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: This method call is required by the Web Form Designer
'Do not modify it using the code editor.
InitializeComponent()
End Sub
#End Region
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
If Not IsPostBack Then
Response.Cache.SetNoStore()
'显示所有的实验类别
DisplayTestClass(drpTestClass)
'显示没有分类的实验项目
DisplayNoClassifiedTestProject(listAllProject)
'显示当前类别的实验项目
DisplayCurrentTestProjectInListBox(drpTestClass.SelectedItem.Text.Trim, listCurrentProject)
End If
End Sub
Private Sub btnNewTestClass_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnNewTestClass.Click
If txtNewTestClass.Text.Trim() <> "" Then
'添加新类别
PubStrSql = "insert into TClass (testClass) values ('" & txtNewTestClass.Text.Trim() & "')"
PubSqlCmd.CommandText = PubStrSql
Try
PubSqlCmd.ExecuteNonQuery()
Catch sqlEx As SqlException
lblErrorMessage.Text = "*<u>" & txtNewTestClass.Text.Trim() _
& "</u>已经存在,请使用其它名称"
End Try
'显示类别
DisplayTestClass(drpTestClass)
'显示当前类别的项目
DisplayCurrentTestProjectInListBox(drpTestClass.SelectedItem.Text, listCurrentProject)
End If
End Sub
Private Sub drpTestClass_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles drpTestClass.SelectedIndexChanged
'显示当前类别的项目
DisplayCurrentTestProjectInListBox(drpTestClass.SelectedItem.Text, listCurrentProject)
End Sub
Private Sub btnDelTestClass_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDelTestClass.Click
'删除类别,该类别对应的项目由于外键约束自动删除
If drpTestClass.SelectedIndex <> -1 Then
PubStrSql = "delete from TClass where TestClass='" & drpTestClass.SelectedItem.Text & "'"
PubSqlCmd.CommandText = PubStrSql
PubSqlCmd.ExecuteNonQuery()
'显示类别和当前类别的项目
DisplayTestClass(drpTestClass)
DisplayCurrentTestProjectInListBox(drpTestClass.SelectedItem.Text, listCurrentProject)
'显示没有分类的项目
DisplayNoClassifiedTestProject(listAllProject)
End If
End Sub
Private Sub btnAddTestProject_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAddTestProject.Click
'向当前类别中增加项目
If listAllProject.SelectedIndex <> -1 And drpTestClass.SelectedIndex <> -1 Then
Dim strTestProject As String '选中的实验项目
strTestProject = listAllProject.SelectedItem.Text
PubStrSql = "insert into TestClass (testClass,project) values (@testClass,@project)"
With PubSqlCmd
.CommandText = PubStrSql
.Parameters.Add("@testClass", drpTestClass.SelectedItem.Value.Trim())
.Parameters.Add("@project", strTestProject)
.ExecuteNonQuery()
.Parameters.Clear()
End With
'显示当前的类别中的实验项目
DisplayCurrentTestProjectInListBox(drpTestClass.SelectedItem.Text, listCurrentProject)
'显示没有分类的实验项目
DisplayNoClassifiedTestProject(listAllProject)
End If
End Sub
Private Sub btnDelTestProject_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDelTestProject.Click
'从当前类别中删除实验项目
If listCurrentProject.SelectedIndex <> -1 And drpTestClass.SelectedIndex <> -1 Then
PubStrSql = "delete from TestClass where TestClass=@testClass and project=@project"
With PubSqlCmd
.CommandText = PubStrSql
.Parameters.Add("@testClass", drpTestClass.SelectedItem.Value.Trim())
.Parameters.Add("@project", listCurrentProject.SelectedItem.Text)
.ExecuteNonQuery()
.Parameters.Clear()
End With
'显示当前标准类别的项目
DisplayCurrentTestProjectInListBox(drpTestClass.SelectedItem.Text, listCurrentProject)
'显示没有分类的项目
DisplayNoClassifiedTestProject(listAllProject)
End If
End Sub
End Class
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -