⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 login.aspx.vb

📁 用户登录新闻发布系统
💻 VB
字号:
Imports System.Data.SqlClient
Public Class login1
    Inherits System.Web.UI.Page

#Region " Web 窗体设计器生成的代码 "

    '该调用是 Web 窗体设计器所必需的。
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()

    End Sub
    Protected WithEvents Label1 As System.Web.UI.WebControls.Label
    Protected WithEvents Label2 As System.Web.UI.WebControls.Label
    Protected WithEvents t1 As System.Web.UI.WebControls.TextBox
    Protected WithEvents Label3 As System.Web.UI.WebControls.Label
    Protected WithEvents t2 As System.Web.UI.WebControls.TextBox
    Protected WithEvents Label4 As System.Web.UI.WebControls.Label
    Protected WithEvents t3 As System.Web.UI.WebControls.TextBox
    Protected WithEvents Label5 As System.Web.UI.WebControls.Label
    Protected WithEvents t4 As System.Web.UI.WebControls.TextBox
    Protected WithEvents b2 As System.Web.UI.WebControls.Button
    Protected WithEvents b1 As System.Web.UI.WebControls.Button
    Protected WithEvents b3 As System.Web.UI.WebControls.Button
    Protected WithEvents Label6 As System.Web.UI.WebControls.Label
    Protected WithEvents Label7 As System.Web.UI.WebControls.Label
    Protected WithEvents Label8 As System.Web.UI.WebControls.Label
    Protected WithEvents Label9 As System.Web.UI.WebControls.Label
    Protected WithEvents Label10 As System.Web.UI.WebControls.Label
    Protected WithEvents l1 As System.Web.UI.WebControls.Label
    Protected WithEvents l2 As System.Web.UI.WebControls.Label
    Protected WithEvents l3 As System.Web.UI.WebControls.Label

    '注意: 以下占位符声明是 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 sqlstr As String = "server=cs007;uid=sa;pwd=;database=tt"
    Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        l1.Visible = False
        l2.Visible = False
        l3.Visible = False
    End Sub

    Private Sub b1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles b1.Click
        t1.Text = ""
        t2.Text = ""
        t3.Text = ""
        t4.Text = ""
        l1.Visible = False
        l2.Visible = False
        l3.Visible = False
    End Sub

    Private Sub b3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles b3.Click
        l1.Visible = False
        l2.Visible = False
        l3.Visible = False
        checkuser()
    End Sub
    Private Sub b2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles b2.Click
        If t1.Text = "" Or t2.Text = "" Or t3.Text = "" Or t4.Text = "" Then
        Else
            l1.Visible = False
            l2.Visible = False
            l3.Visible = False
            checkpwd()
        End If
    End Sub
    Sub checkpwd()
        If t1.Text = "" Then
        Else
            Dim comm As SqlCommand
            Dim conn As New SqlConnection(sqlstr)
            conn.Open()
            comm = New SqlCommand("select * from admin where username='" & t1.Text & "'", conn)
            Dim commread As SqlDataReader = comm.ExecuteReader
            If commread.Read Then
                l1.Visible = True
                conn.Close()
            Else

                If t2.Text = t3.Text Then
                    Dim comm1 As SqlCommand
                    Dim conn2 As New SqlConnection(sqlstr)
                    conn2.Open()
                    comm1 = New SqlCommand("insert into admin (username,userpws,email) values('" & t1.Text & "','" & t2.Text & "','" & t4.Text & "')", conn2)
                    comm1.ExecuteNonQuery()
                    Me.Response.Redirect("loginsuccessed.aspx")
                    conn2.Close()
                Else
                    l2.Visible = True
                End If
            End If
        End If
    End Sub
    Sub checkuser()
        If t1.Text = "" Then
        Else
            Dim comm As SqlCommand
            Dim conn As New SqlConnection(sqlstr)
            conn.Open()
            comm = New SqlCommand("select * from admin where username='" & t1.Text & "'", conn)
            Dim commread As SqlDataReader = comm.ExecuteReader
            If commread.Read Then
                l1.Visible = True
            Else
                l3.Visible = True
                l1.Visible = False
            End If
            conn.Close()
        End If
    End Sub
End Class

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -