📄 account.aspx
字号:
<%@ Page language="VB" %>
<%@ Register TagPrefix="ASPNETBank" TagName="Header" src="header.ascx" %>
<%@ Register TagPrefix="ASPNETBank" TagName="Menu" src="nav.ascx" %>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.OleDb" %>
<script runat="server">
'*******************************************************
'
' Account.aspx: lists account summaries and current balances
' for the current user
'
'*******************************************************
'declare connection object
dim Conn as new OleDbConnection("Provider=" & _
"Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=C:\ASPNET\data\banking.mdb")
'*******************************************************
' When the page loads, display a welcome message in the
' and the current balance of the account, as well as
' any transactions
'*******************************************************
sub Page_Load(obj as object, e as eventargs)
GetBalance()
GetTransactions()
end sub
'*******************************************************
' This function returns the balance of the account with
' the specified user ID (stored in the cookie created
' by forms authentication) and displays the value
' in a label
'*******************************************************
sub GetBalance
dim decBalance as decimal
dim objCmd as OleDbCommand = new OleDbCommand _
("spRetrieveBalance", Conn)
objCmd.CommandType = CommandType.StoredProcedure
'set parameters for stored procedure
dim objParam as OleDbParameter
objParam = objCmd.Parameters.Add("@UserID", _
OleDbType.BSTR)
objParam.Direction = ParameterDirection.Input
objParam.Value = Request.Cookies("Account").Value
try
objCmd.Connection.Open()
decBalance = CType(objCmd.ExecuteScalar, Decimal)
objCmd.Connection.Close
catch ex as OleDbException
lblMessage.Text = ex.Message
end try
lblBalance.Text = "<b>$" & decBalance.ToString & "</b>"
end sub
'*******************************************************
' Returns all transactions for a given user id (stored
' in the cookie created by forms authentication), and
' displays them in a datagrid
'*******************************************************
sub GetTransactions
dim objCmd as OleDbCommand = new OleDbCommand _
("spGetTransactions", Conn)
objCmd.CommandType = CommandType.StoredProcedure
dim objReader as OleDbDataReader
'set parameters for stored procedure
dim objParam as OleDbParameter
objParam = objCmd.Parameters.Add("@UserID", _
OleDbType.BSTR)
objParam.Direction = ParameterDirection.Input
objParam.Value = Request.Cookies("Account").Value
try
objCmd.Connection.Open()
objReader = objCmd.ExecuteReader
dgTransactions.DataSource = objReader
dgTransactions.DataBind()
catch ex as OleDbException
lblMessage.Text = ex.Message
end try
end sub
</script>
<html><body>
<ASPNETBank:Header runat="server" />
<table>
<tr>
<td valign="top" width="150">
<ASPNETBank:Menu runat="server" />
</td>
<td width="550" valign="top">
<font face="arial">
<asp:Label id="lblMessage" runat="server"/>
<form runat="server">
<table>
<tr>
<td width="10">
</td>
<td width="100%">
<font face="arial">
<p>
Your balance is:
<asp:Label id="lblBalance" runat="server"/>
<p>
<b>Transactions:</b><br>
<asp:DataGrid id="dgTransactions"
runat="server" BorderColor="black"
GridLines="Vertical" cellpadding="4"
cellspacing="0" width="100%"
Font-Name="Arial" Font-Size="8pt"
AutoGenerateColumns=false >
<Columns>
<asp:BoundColumn HeaderText="Check #"
DataField="CheckNumber" />
<asp:BoundColumn HeaderText="Date"
DataField="DatePosted" />
<asp:BoundColumn HeaderText="Payee"
DataField="Payee" />
<asp:BoundColumn HeaderText="Amount"
DataField="Amount" />
</Columns>
</asp:DataGrid>
</font>
</td>
</tr>
</table>
</form>
</font>
</td>
</tr>
</table>
</font>
</body></html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -