default.aspx.vb
来自「Website for Training and Palcement Offic」· VB 代码 · 共 108 行
VB
108 行
Imports System.Data
Imports System.Data.SqlClient
Partial Class _Default
Inherits System.Web.UI.Page
Dim cs As String = "Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\Database.mdf;Integrated Security=True;User Instance=True"
Protected Sub bnLogin_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles bnLogin.Click
Page.Validate("vg1")
If Page.IsValid() Then
Dim con As SqlConnection = New SqlConnection(cs)
Dim pass1 As String = txbPass.Text.ToString()
Dim pass2 As String = ""
Dim sw As String = drlType.SelectedValue()
Select Case sw
Case "1"
Dim command As SqlCommand = New SqlCommand("select PASS from TPOPASSTAB where (UID=@uid) and (PASS=@pass)", con)
command.Parameters.AddWithValue("@uid", txbUID.Text())
command.Parameters.AddWithValue("@pass", txbPass.Text())
con.Open()
Dim dr As SqlDataReader = command.ExecuteReader()
If dr.Read() Then
'lb.Text = dr.GetValue(0).ToString()
'pass2 = lb.Text.ToString()
con.Close()
'If String.Equals(pass1, pass2) Then
Dim url As String = "~/tpo/TpoHome.aspx?ID=" + txbUID.Text.ToString()
Response.Redirect(url)
'Else
lbStatus.Text = "Password or UserID may be incorrect "
'End If
Else
lbStatus.Text = "The login ID or account type or password may not be correct"
End If
Case "2"
Dim command As SqlCommand = New SqlCommand("select PASS from CORDPASSTAB where (UID=@uid)and(PASS=@pass)", con)
command.Parameters.AddWithValue("@uid", txbUID.Text())
command.Parameters.AddWithValue("@pass", txbPass.Text())
con.Open()
Dim dr As SqlDataReader = command.ExecuteReader()
If dr.Read() Then
'pass2 = dr.GetString(0)
con.Close()
'If Equals(pass1, pass2) Then
Dim url As String = "~/co-ordinator/CordHome.aspx?ID=" + txbUID.Text.ToString()
Response.Redirect(url)
'Else
'lbStatus.Text = "Password or UserID may be incorrect "
'End If
Else
lbStatus.Text = "The login ID or account type or password may not be correct"
End If
Case "3"
Dim command As SqlCommand = New SqlCommand("select PASS from STUDPASSTAB where (UID=@uid)and (PASS=@pass)", con)
command.Parameters.AddWithValue("@uid", txbUID.Text())
command.Parameters.AddWithValue("@pass", txbPass.Text())
con.Open()
Dim dr As SqlDataReader = command.ExecuteReader()
If dr.Read() Then
'pass2 = dr.GetString(0)
con.Close()
'If Equals(pass1, pass2) Then
Dim url As String = "~/student/StudentHome.aspx?ID=" + txbUID.Text.ToString()
Response.Redirect(url)
Else
'lbStatus.Text = "Password or UserID may be incorrect "
'End If
'Else
lbStatus.Text = "The login ID, Password or account type may not be correct"
End If
Case "4"
Dim command As SqlCommand = New SqlCommand("select PASS from HRPASSTAB where (UID=@uid) and(PASS=@pass)", con)
command.Parameters.AddWithValue("@uid", txbUID.Text())
command.Parameters.AddWithValue("@pass", txbPass.Text())
con.Open()
Dim dr As SqlDataReader = command.ExecuteReader()
If dr.Read() Then
'pass2 = dr.GetString(0)
con.Close()
'If Equals(pass1, pass2) Then
Dim url As String = "~/HR/HRHome.aspx?ID=" + txbUID.Text.ToString()
Response.Redirect(url)
Else
'lbStatus.Text = "Password or UserID may be incorrect "
'End If
'Else
lbStatus.Text = "The login ID, Password or account type may not be correct"
End If
Case Else
lbStatus.Text = "Please select account type"
End Select
Else
lbStatus.Text = "Plese enter UID and Password"
End If
End Sub
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
End Sub
Protected Sub txbPass_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles txbPass.TextChanged
End Sub
Protected Sub drlType_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles drlType.SelectedIndexChanged
End Sub
End Class
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?