?? register.aspx.vb
字號:
Public Class register
Inherits System.Web.UI.Page
#Region " Web 窗體設計器生成的代碼 "
'該調用是 Web 窗體設計器所必需的。
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
End Sub
Protected WithEvents email As System.Web.UI.WebControls.TextBox
Protected WithEvents phone As System.Web.UI.WebControls.TextBox
Protected WithEvents valid1 As System.Web.UI.WebControls.CompareValidator
Protected WithEvents password2 As System.Web.UI.WebControls.TextBox
Protected WithEvents rfd4 As System.Web.UI.WebControls.RequiredFieldValidator
Protected WithEvents password1 As System.Web.UI.WebControls.TextBox
Protected WithEvents rfd3 As System.Web.UI.WebControls.RequiredFieldValidator
Protected WithEvents username As System.Web.UI.WebControls.TextBox
Protected WithEvents rfd2 As System.Web.UI.WebControls.RequiredFieldValidator
Protected WithEvents realname As System.Web.UI.WebControls.TextBox
Protected WithEvents rfd1 As System.Web.UI.WebControls.RequiredFieldValidator
Protected WithEvents number As System.Web.UI.WebControls.TextBox
Protected WithEvents message As System.Web.UI.HtmlControls.HtmlGenericControl
Protected WithEvents Image1 As System.Web.UI.WebControls.Image
Protected WithEvents Button1 As System.Web.UI.WebControls.Button
Protected WithEvents Button2 As System.Web.UI.WebControls.Button
Protected WithEvents Label1 As System.Web.UI.WebControls.Label
Protected WithEvents Panel1 As System.Web.UI.WebControls.Panel
Protected WithEvents Panel2 As System.Web.UI.WebControls.Panel
Protected WithEvents HyperLink1 As System.Web.UI.WebControls.HyperLink
Protected WithEvents RegularExpressionValidator1 As System.Web.UI.WebControls.RegularExpressionValidator
Protected WithEvents HyperLink2 As System.Web.UI.WebControls.HyperLink
Protected WithEvents memo As System.Web.UI.WebControls.TextBox
'注意: 以下占位符聲明是 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
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'在此處放置初始化頁的用戶代碼
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
'提交注冊信息
Dim bool1 As Boolean = False
Dim bool2 As Boolean = False
Dim dsn As String = ConfigurationSettings.AppSettings("DSN_student")
Dim conn As New SqlClient.SqlConnection
conn.ConnectionString = dsn
Dim cmd As IDbCommand = conn.CreateCommand()
If Page.IsValid Then '頁面驗證成功
cmd.CommandText = "select * from student_infor where s_id='" + number.Text + "'"
Try
conn.Open()
Dim reader As IDataReader
reader = cmd.ExecuteReader()
If reader.Read Then '如果有此賬號
'比較填寫的真實姓名一欄的值和數據庫表項中的s_name內容
If Trim(realname.Text) = Trim(reader.Item("s_name")) Then
If reader.Item("s_iflogin") = True Then 's_iflogin字段表示學生是否已經注冊
Label1.Text = "該用戶已經注冊"
Else
bool1 = True
Label1.Text = ""
End If
Else
Label1.Text = "您所輸入的號碼和姓名不匹配,請重新填寫"
End If
Else
Label1.Text = "你所輸入的學號/老師號不存在,請重新填寫"
End If
reader.Close()
Catch
Label1.Text = "數據庫操作失敗,可能是服務器出現錯誤,請稍后再試!非常抱歉影響了您的工作!"
Finally
conn.Close()
End Try
Else
Label1.Text = "頁面有錯誤"
End If
'sql2表示插入語句中values中的值
Dim sql2 As String = "'" + number.Text + "','" + username.Text + "','" + password1.Text + "','" + DateTime.Now.Date + "','" + email.Text + "','" + phone.Text + "','" + memo.Text + "'"
If bool1 Then '如果此用戶賬號存在、并且未注冊
bool1 = False
'插入注冊信息
cmd.CommandText = "insert into student_login (S_ID,SL_NAME,SL_Pwd,SL_Date,SL_MailBox,SL_phone,sl_memo) values (" + sql2 + ")"
Try
conn.Open()
cmd.ExecuteReader()
bool2 = True
Catch
Label1.Text = "數據庫操作失敗,可能是服務器出現錯誤,請稍后再試!非常抱歉影響了您的工作!"
bool2 = False
Finally
conn.Close()
End Try
If bool2 Then '判斷在注冊是是否出現意外情況,
'將student_infor的對應項的s_iflogin置為1,表示已經注冊過了
cmd.CommandText = "UPDATE student_infor SET s_iflogin = '1' WHERE (s_id = '" + number.Text + "')"
Try
conn.Open()
cmd.ExecuteReader()
Catch
Label1.Text = "數據庫操作失敗,可能是服務器出現錯誤,請稍后再試!非常抱歉影響了您的工作!"
Finally
conn.Close()
End Try
'顯示注冊成功信息
Panel1.Visible = False
Panel2.Visible = True
End If
End If
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
'重置各項textbox內容為空
number.Text = ""
realname.Text = ""
username.Text = ""
password1.Text = ""
password2.Text = ""
phone.Text = ""
email.Text = ""
End Sub
End Class
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -