?? t_class_infor.aspx.vb
字號:
Public Class t_class_infor
Inherits System.Web.UI.Page
#Region " Web 窗體設計器生成的代碼 "
'該調用是 Web 窗體設計器所必需的。
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
End Sub
Protected WithEvents Label2 As System.Web.UI.WebControls.Label
Protected WithEvents DataGrid1 As System.Web.UI.WebControls.DataGrid
Protected WithEvents Label1 As System.Web.UI.WebControls.Label
Protected WithEvents Button1 As System.Web.UI.WebControls.Button
Protected WithEvents DropDownList1 As System.Web.UI.WebControls.DropDownList
Protected WithEvents HyperLink1 As System.Web.UI.WebControls.HyperLink
Protected WithEvents HyperLink2 As System.Web.UI.WebControls.HyperLink
Protected WithEvents LinkButton1 As System.Web.UI.WebControls.LinkButton
Protected WithEvents Image1 As System.Web.UI.WebControls.Image
Protected WithEvents spWelMessage As System.Web.UI.HtmlControls.HtmlGenericControl
'注意: 以下占位符聲明是 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
Dim dsn As String
Dim conn As New SqlClient.SqlConnection
Dim cmd As New SqlClient.SqlCommand
Dim ds1 As DataSet = New DataSet
Dim mydap1 As New SqlClient.SqlDataAdapter
Dim teacher_id As String '取出教師登錄s_id
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'在此處放置初始化頁的用戶代碼
'1、取出cookie中的數據
Dim teacher_id As String = Request.Cookies("userInf").Values("userID")
If DateTime.Now.Hour >= 6 And DateTime.Now.Hour < 12 Then
spWelMessage.InnerHtml = "早上好," & Request.Cookies("userInf").Values("userID") & Request.Cookies("userInf").Values("userIdent")
ElseIf DateTime.Now.Hour >= 12 And DateTime.Now.Hour < 18 Then
spWelMessage.InnerHtml = "下午好," & Request.Cookies("userInf").Values("userID") & Request.Cookies("userInf").Values("userIdent")
Else
spWelMessage.InnerHtml = "晚上好," & Request.Cookies("userInf").Values("userID") & Request.Cookies("userInf").Values("userIdent")
End If
'連接數據庫()
dsn = ConfigurationSettings.AppSettings("DSN_teacher")
conn.ConnectionString = dsn
cmd.Connection = conn
mydap1.SelectCommand = cmd
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
'此函數完成的功能:將數據在datagrid1中顯示出來,并且計算該班的人數
'選擇班級,點擊此按鈕后顯示該班的學生名單
cmd.CommandText = "select student_infor.s_id,student_infor.s_name,group_id,seat_id from student_infor,class_student where student_infor.s_id=class_student.s_id and class_id='" + DropDownList1.SelectedItem.Value + "' order by seat_id asc"
Try
conn.Open()
mydap1.Fill(ds1, "student_class_infor")
DataGrid1.DataSource = ds1.Tables("student_class_infor")
DataGrid1.DataBind()
Catch
Label2.Text = "讀取數據庫失敗,可能是服務器出現錯誤,請稍后再試!非常抱歉影響了您的工作!"
Finally
conn.Close()
End Try
'計算該班的人數
cmd.CommandText = "select * from class_student where class_id='" + DropDownList1.SelectedItem.Value + "'"
Try
conn.Open()
mydap1.Fill(ds1, "class_student_count")
Label1.Text = ds1.Tables("class_student_count").Rows.Count
Catch
Label2.Text = "讀取班級學生表失敗,可能是服務器出現錯誤,請稍后再試!非常抱歉影響了您的工作!"
Finally
conn.Close()
End Try
End Sub
Private Sub LinkButton1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles LinkButton1.Click
Response.Redirect("../login.aspx")
End Sub
End Class
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -