C#语言编程设计课程实验报告实验银行客户服务系统Word下载.docx
《C#语言编程设计课程实验报告实验银行客户服务系统Word下载.docx》由会员分享,可在线阅读,更多相关《C#语言编程设计课程实验报告实验银行客户服务系统Word下载.docx(23页珍藏版)》请在冰豆网上搜索。
若选择注销功能,消除Session值,跳转到登陆页面
图10
数据库样例:
图11
4.说明体会
本人熟悉web开发,之前一直使用php在appache环境下做网站,数组库使用的是mysql,也在iis下做过asp,这次有机会使用ASP.NET,让我感触很多。
首先,.net允许你使用多种不同编程语言的框架,你可以在你的网站中嵌入各种语言,然后,他还有出色的面向对象编程模型,强大的类库为用户带来了很多方便,还有,ASP.NET起初运行于IIS,现在也可以运行于Apache,这将给.net的安全性带来不少改进。
由于接触时间不长,在使用方面不是很熟悉。
通过这次实验我对.net有了进一步了解,以后会继续努力学习钻研!
5.附录
源代码:
//index.aspx
//登陆页面
<
%@PageLanguage="
C#"
AutoEventWireup="
true"
CodeFile="
index.aspx.cs"
Inherits="
index"
%>
!
DOCTYPEhtmlPUBLIC"
-//W3C//DTDXHTML1.0Transitional//EN"
"
http:
//www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"
>
htmlxmlns="
//www.w3.org/1999/xhtml"
>
headid="
Head1"
runat="
server"
<
title>
网上银行<
/title>
/head>
body>
formid="
form1"
divstyle="
text-align:
center"
tablestyle="
z-index:
100;
left:
281px;
width:
594px;
position:
absolute;
top:
18px;
height:
457px"
tr>
tdalign="
center"
style="
background-position:
centercenter;
background-image:
url(pic/main.jpg);
100px;
background-repeat:
no-repeat;
225px"
valign="
middle"
asp:
LabelID="
Label1"
Height="
17px"
Style="
font-size:
12px;
z-index:
228px;
vertical-align:
middle;
font-family:
宋体;
143px;
text-align:
Text="
用户名:
"
Width="
65px"
/asp:
Label>
TextBoxID="
name"
12px"
103;
313px;
142px"
119px"
OnTextChanged="
name_TextChanged"
TextBox>
Label2"
16px"
102;
236px;
169px"
密码:
57px"
psw"
TextBox2_TextChanged"
104;
TextMode="
Password"
ButtonID="
submit"
20px"
101;
253px;
202px"
登陆"
40px"
OnClick="
submit_Click"
/>
Button2"
106;
319px;
201px"
重设"
Button2_Click"
/div>
/td>
/tr>
width:
100px"
/table>
/form>
/body>
/html>
//index.aspx.cs
usingSystem;
usingSystem.Data;
usingSystem.Configuration;
usingSystem.Web;
usingSystem.Web.Security;
usingSystem.Web.UI;
usingSystem.Web.UI.WebControls;
usingSystem.Web.UI.WebControls.WebParts;
usingSystem.Web.UI.HtmlControls;
usingSystem.Data.SqlClient;
publicpartialclassindex:
System.Web.UI.Page
{
protectedvoidPage_Load(objectsender,EventArgse)
{
}
protectedvoidButton2_Click(objectsender,EventArgse)
Response.Redirect("
index.aspx"
);
protectedvoidsubmit_Click(objectsender,EventArgse)
//连接数据库,查询数据库
stringconString="
server=school-913254b1;
+
Trusted_Connection=yes;
database=bank"
;
SqlConnectionconn=newSqlConnection(conString);
conn.Open();
SqlCommandthisCommand=conn.CreateCommand();
thisCommand.CommandText="
select*from[user]whereusername='
+name.Text.Trim().ToString()+"
'
andpassword='
+psw.Text.Trim().ToString()+"
//Response.Write(thisCommand.CommandText);
SqlDataReaderthisReader=thisCommand.ExecuteReader();
if(thisReader.Read())
Session["
username"
]=name.Text.Trim().ToString();
password"
]=psw.Text.Trim().ToString();
id"
]=thisReader["
].ToString();
zhanghu.aspx?
id='
+Session["
]+"
else
Response.Write("
script>
alert('
输入有误,请重新输入!
)<
/script>
thisReader.Close();
conn.Close();
protectedvoidTextBox2_TextChanged(objectsender,EventArgse)
protectedvoidname_TextChanged(objectsender,EventArgse)
}
//zhanghu.aspx
//账户管理页面
zhanghu.aspx.cs"
zhanghu"
scriptlanguage="
javascript"
type="
text/javascript"
//<
CDATA[
functionTABLE1_onclick(){
//]]>
form2"
div>
&
nbsp;
tableid="
TABLE1"
width="
1000"
onclick="
returnTABLE1_onclick()"
border-right:
thinsolid;
border-top:
border-left:
border-bottom:
thinsolid"
tdcolspan="
3"
background-image:
url(pic/faq_03.jpg);
82px"
tdstyle="
125px;
368px;
url(pic/faq_04.jpg);
192px;
368px"
297px;
161px"
您帐户的余额为:
count"
382px;
209px"
count_TextChanged"
ReadOnly="
True"
&
Button3"
109;
317px;
297px"
存款"
Button3_Click"
Button1"
401px;
取款"
Button1_Click"
501px;
注销"
150px;
url(pic/ccb_08.jpg);
height:
21px;
background-color:
cornflowerblue;
colspan="
Label4"
center;
font-size:
230px;
499px;
Copyright©
2007zhanglijiu.Allrightsreserved.Designed&
Powerbyzhanglijiu"
//zhanghu.aspx.cs
usingSystem.Collections;
publicpartialclasszhanghu:
stringbalance="
//intcheck=0;
stringconnect="
SqlConnectionconn=newSqlConnection(connect);
SqlCommandcommand=conn.CreateCommand();
stringsql=command.CommandText="
select*from[user]whereid='
SqlDataAdapterdataAdapter=newSqlDataAdapter(sql,conn);
DataSetdataSet=newDataSet();
dataAdapter.Fill(dataSet,"
user"
Stringbalance=dataSet.Tables["
].Rows[0]["
balance"
//check=Convert.ToInt32(balance);
count.Text=balance.ToString();
protectedvoidcount_TextChanged(objectsender,EventArgse)
protectedvoidButton3_Click(objectsender,EventArgse)
//进入存款页面
cunkuan.aspx?
protectedvoidButton1_Click(objectsender,EventArgse)
//进入取款页面
qukuan.aspx?
//注销
//cunkuan.aspx
//存款页面
cunkuan.aspx.cs"
cunkuan"
headrunat="
299px;