📄 default.aspx.vb
字号:
Imports System.Web.Security
Imports System.Data.SqlClient
Public Class _default
Inherits System.Web.UI.Page
Protected WithEvents lbLogout As System.Web.UI.WebControls.LinkButton
Protected WithEvents dlAccountSummary As System.Web.UI.WebControls.DataList
Protected WithEvents hlMail As System.Web.UI.WebControls.HyperLink
Protected WithEvents lblTitle As System.Web.UI.WebControls.Label
#Region " Web Form Designer Generated Code "
'This call is required by the Web Form Designer.
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
End Sub
Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init
'CODEGEN: This method call is required by the Web Form Designer
'Do not modify it using the code editor.
InitializeComponent()
End Sub
#End Region
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
lblTitle.Text = "Welcome To " & Session("cname").ToString.ToUpper
Dim con As New SqlConnection(Application("cs"))
Try
con.Open()
DisplayAccountSummary(con)
DisplayMailsCount(con)
Catch ex As Exception
Finally
con.Close()
End Try
End Sub
Sub DisplayMailsCount(ByVal con As SqlConnection)
Dim cmd As New SqlCommand("select count(*) from mails where mailto = @acno", con)
cmd.Parameters.Add("@acno", SqlDbType.VarChar, 10).Value = Session("acno")
Dim cnt As Integer
cnt = cmd.ExecuteScalar()
hlMail.Text = "You have (" & cnt & ") mails."
End Sub
Sub DisplayAccountSummary(ByVal con As SqlConnection)
Try
Dim cmd As New SqlCommand("select acno,cname,branch, city, curbal, atype = case atype when 's' then 'Savings' else 'Current' End from accounts where acno = @acno", con)
cmd.Parameters.Add("@acno", SqlDbType.VarChar, 10).Value = Session("acno")
Dim dr As SqlDataReader
dr = cmd.ExecuteReader
' bind data to DataList
dlAccountSummary.DataSource = dr
dlAccountSummary.DataBind()
dr.Close()
Catch ex As Exception
End Try
End Sub
Private Sub lbLogout_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles lbLogout.Click
formsauthentication.signout()
Response.Redirect("default.aspx")
End Sub
End Class
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -