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

📄 editinfo.aspx.vb

📁 The Management Information System of Library using .NET
💻 VB
字号:
'本页用来修改读者的email和密码
Imports System.Data.SqlClient
Public Class editinfo
    Inherits System.Web.UI.Page

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

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

    End Sub
    Protected WithEvents Form1 As System.Web.UI.HtmlControls.HtmlForm
    Protected WithEvents txtPwd1 As System.Web.UI.WebControls.TextBox
    Protected WithEvents txtPwdE1 As System.Web.UI.WebControls.TextBox
    Protected WithEvents txtPwdE2 As System.Web.UI.WebControls.TextBox
    Protected WithEvents btnSubmit As System.Web.UI.WebControls.Button
    Protected WithEvents txtEmail As System.Web.UI.WebControls.TextBox
    Protected WithEvents btnEdit As System.Web.UI.WebControls.Button
    Protected WithEvents RequiredFieldValidator1 As System.Web.UI.WebControls.RequiredFieldValidator
    Protected WithEvents RequiredFieldValidator2 As System.Web.UI.WebControls.RequiredFieldValidator
    Protected WithEvents CompareValidator1 As System.Web.UI.WebControls.CompareValidator
    Protected WithEvents lblMsg As System.Web.UI.WebControls.Label
    Protected WithEvents lblgengg 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

    Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        '在此处放置初始化页的用户代码
        If Session("UID") Is Nothing Then
            Page.Response.Redirect("login.aspx")
        Else
            If Not IsPostBack Then

            End If
        End If
    End Sub


    Private Sub btnSubmit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSubmit.Click
        '服务端验证不用写
        If Session("UID") Is Nothing Then
            Page.Response.Redirect("login.aspx")
        End If
        Dim k As New CCheckLog(Session("UID"), Me.txtPwd1.Text)
        If k.IsLogSuc = False Then
            Me.lblMsg.Text = "密码错误!"
            Me.lblMsg.Visible = True
            Exit Sub
        End If

        Dim cn As New SqlConnection(ConfigurationSettings.AppSettings("cncstr"))
        Dim cmd As New SqlCommand

        With cmd
            .CommandType = CommandType.StoredProcedure
            .CommandText = "UpdateAuPwd"
            .Connection = cn
        End With
        Dim mAu_id As New SqlParameter("@Au_id", SqlDbType.NVarChar)
        Dim mAu_password As New SqlParameter("@Au_password", SqlDbType.NVarChar)
        Dim mAu_Newpassword As New SqlParameter("@Au_Newpassword", SqlDbType.NVarChar)
        With cmd.Parameters
            .Add(mAu_id)
            .Add(mAu_password)
            .Add(mAu_Newpassword)
        End With
        mAu_id.Value = Session("UID")
        mAu_password.Value = Me.txtPwd1.Text.Trim
        mAu_Newpassword.Value = Me.txtPwdE1.Text.Trim
        Try
            cn.Open()
            cmd.ExecuteNonQuery()
            Me.lblMsg.Text = "更改成功!"
            Me.lblMsg.Visible = True
        Catch ex As Exception
            Response.Redirect("error.aspx?errmsg=" + ex.Message)
        Finally
            cn.Close()
            If Not cn Is Nothing Then
                cn.Dispose()
            End If
        End Try
    End Sub

    Private Sub btnEdit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnEdit.Click
        '服务端验证不用写
        If Session("UID") Is Nothing Then
            Page.Response.Redirect("login.aspx")
        End If

        Dim cn As New SqlConnection(ConfigurationSettings.AppSettings("cncstr"))
        Dim cmd As New SqlCommand

        With cmd
            .CommandType = CommandType.StoredProcedure
            .CommandText = "UpdateAuEmail"
            .Connection = cn
        End With
        Dim mAu_id As New SqlParameter("@Au_id", SqlDbType.NVarChar)
        Dim mAu_email As New SqlParameter("@Au_email", SqlDbType.NVarChar)

        With cmd.Parameters
            .Add(mAu_id)
            .Add(mAu_email)
        End With
        mAu_id.Value = Session("UID")
        mAu_email.Value = Me.txtEmail.Text.Trim

        Try
            cn.Open()
            cmd.ExecuteNonQuery()
            Me.lblgengg.Text = "更改成功!"
            Me.lblgengg.Visible = True
        Catch ex As Exception
            Response.Redirect("error.aspx?errmsg=" + ex.Message)
        Finally
            cn.Close()
            If Not cn Is Nothing Then
                cn.Dispose()
            End If
        End Try
    End Sub
End Class

⌨️ 快捷键说明

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