📄 登录.aspx.vb
字号:
Imports System
Imports System.Reflection
Imports System.Runtime.InteropServices
Imports System.Data.SqlClient
Imports System.IO
Imports System.Data
Partial Class _Default
Inherits System.Web.UI.Page
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Session("empno") = TextBox1.Text
Session("loginmode") = DropDownList1.Text
End Sub
Protected Sub LinkButton1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles LinkButton1.Click
If Trim(TextBox1.Text) = "" Or Trim(TextBox2.Text) = "" Then
MsgBox("用户名或密码不能为空!")
Else
If Asc(TextBox1.Text) < 48 Or Asc(TextBox1.Text) > 57 Or Asc(TextBox2.Text) < 48 Or (Asc(TextBox2.Text) > 90 And Asc(TextBox2.Text) < 97) Or (Asc(TextBox2.Text) < 65 And Asc(TextBox2.Text) > 57) Or Asc(TextBox2.Text) > 122 Then
MsgBox("登陆失败,用户名或密码错误!")
Else
Dim sqlConnectString As String = "data source=localhost; database=users;Integrated Security=SSPI; user Id=sa;password='';connection TimeOut=30;"
Dim dCon = New SqlConnection(sqlConnectString)
dCon.Open()
Dim name As String = Me.TextBox1.Text.ToString()
Dim password As String = Me.TextBox2.Text.ToString()
Dim status As String = Me.DropDownList1.Text.ToString()
If status = "领导" Then
Dim sql As String
sql = "select count(*) from userinfo where empno='" + name + "'and userpwd='" + password + "'and loginmode='领导'"
Dim comm = New SqlCommand(sql, dCon)
Dim count As Short
count = CShort(comm.ExecuteScalar())
If count > 0 Then
Response.Redirect("领导进入.aspx")
'LinkButton1.PostBackUrl = "~/领导进入.aspx"
Else
MsgBox("登陆失败,用户名或密码错误!")
End If
ElseIf status = "管理员" Then
Dim sql As String
sql = "select count(*) from userinfo where empno='" + name + "'and userpwd='" + password + "'and loginmode='管理员'"
Dim comm = New SqlCommand(sql, dCon)
Dim count As Short
count = CShort(comm.ExecuteScalar())
If count > 0 Then
Response.Redirect("管理员进入.aspx")
'LinkButton1.PostBackUrl = "~/管理员进入.aspx"
Else
MsgBox("登陆失败,用户名或密码错误!")
End If
Else
Dim sql As String
sql = "select count(*) from userinfo where empno='" + name + "'and userpwd='" + password + "'and loginmode='职工'"
Dim comm = New SqlCommand(sql, dCon)
Dim count As Short
count = CShort(comm.ExecuteScalar())
If count > 0 Then
Response.Redirect("职工进入.aspx")
' LinkButton1.PostBackUrl = "~/职工进入.aspx"
Else
MsgBox("登陆失败,用户名或密码错误!")
End If
End If
End If
End If
End Sub
Protected Sub LinkButton2_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles LinkButton2.Click
Response.Redirect("注册.aspx")
End Sub
End Class
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -