您好,欢迎访问三七文档
《.NET程序设计》课程实验报告实验1:题目学院软件学院年级2005级班级5班学号3005218111姓名张力久2007年5月15日1实验:银行客户服务系统1.实验目的做一个三层结构的银行客户服务系统,实现客户的存款和取款的过程。其中三层要求如下:第一层:业务表现层,在用户界面上实现客户的存款取款过程。第二层:业务逻辑层,验证用户的输入是否合法,比如用正则表达式验证用户的存款和取款的输入必须是数字。第三层:数据访问层,当业务逻辑层完成数据的验证以后,使用数据访问层的类直接对数据库进行插入或者删除的操作。2.实验内容3.设计代码见附录。4.实验结果首页(index.aspx)提示用户输入用户名和密码:图12若输入身份证号码错误,或者密码错误,弹出错误提示框,返回首页图2若用户名与密码正确则登陆到账户管理页面图33选择存款功能,进入存款页面图4若输入不是数字,或违法恶意输入,弹出提示框,返回用户管理页面图5若输入正确,弹出‘交易成功’提示框,返回用户管理页面,余额相应增加图64选择取款功能,进入取款界面图7若输入不是数字,或违法恶意输入,弹出提示框,返回用户管理页面图7若取款金额超出余额,弹出提示框,禁止取款,返回用户管理页面5若输入正确,提示交易成功,跳转到用户管理页面,金额相应减少图8若选择注销功能,消除Session值,跳转到登陆页面图10数据库样例:图1165.说明体会本人熟悉web开发,之前一直使用php在appache环境下做网站,数组库使用的是mysql,也在iis下做过asp,这次有机会使用ASP.NET,让我感触很多。首先,.net允许你使用多种不同编程语言的框架,你可以在你的网站中嵌入各种语言,然后,他还有出色的面向对象编程模型,强大的类库为用户带来了很多方便,还有,ASP.NET起初运行于IIS,现在也可以运行于Apache,这将给.net的安全性带来不少改进。由于接触时间不长,在使用方面不是很熟悉。通过这次实验我对.net有了进一步了解,以后会继续努力学习钻研!6.附录源代码://index.aspx//登陆页面%@PageLanguage=C#AutoEventWireup=trueCodeFile=index.aspx.csInherits=index%!DOCTYPEhtmlPUBLIC-//W3C//DTDXHTML1.0Transitional//EN==Head1runat=servertitle网上银行/title/headbodyformid=form1runat=serverdivstyle=text-align:centertablestyle=z-index:100;left:281px;width:594px;position:absolute;top:18px;height:457pxtrtdalign=centerstyle=background-position:centercenter;7background-image:url(pic/main.jpg);width:100px;background-repeat:no-repeat;height:225pxvalign=middledivstyle=text-align:centerasp:LabelID=Label1runat=serverHeight=17pxStyle=font-size:12px;z-index:100;left:228px;vertical-align:middle;font-family:宋体;position:absolute;top:143px;text-align:centerText=用户名:Width=65px/asp:Labelasp:TextBoxID=namerunat=serverHeight=12pxStyle=z-index:103;left:313px;position:absolute;top:142pxWidth=119pxOnTextChanged=name_TextChanged/asp:TextBoxasp:LabelID=Label2runat=serverHeight=16pxStyle=font-size:12px;z-index:102;left:236px;position:absolute;top:169pxText=密码:Width=57px/asp:Labelasp:TextBoxID=pswrunat=serverHeight=12pxOnTextChanged=TextBox2_TextChangedStyle=z-index:104;left:313px;position:absolute;top:169pxTextMode=PasswordWidth=119px/asp:TextBoxasp:ButtonID=submitrunat=serverHeight=20pxStyle=z-index:101;left:253px;position:absolute;top:202pxText=登陆Width=40pxOnClick=submit_Click/asp:ButtonID=Button2runat=serverHeight=20pxStyle=z-index:106;left:319px;position:absolute;top:201pxText=重设Width=40pxOnClick=Button2_Click//div/td/trtrtdalign=centerstyle=width:100pxvalign=middle/td/tr/table/div/form8/body/html//index.aspx.cs//登陆页面usingSystem;usingSystem.Data;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();Session[password]=psw.Text.Trim().ToString();9Session[id]=thisReader[id].ToString();Response.Redirect(zhanghu.aspx?id='+Session[id]+');}else{Response.Write(scriptalert('输入有误,请重新输入!')/script);}thisReader.Close();conn.Close();}protectedvoidTextBox2_TextChanged(objectsender,EventArgse){}protectedvoidname_TextChanged(objectsender,EventArgse){}}//zhanghu.aspx//账户管理页面%@PageLanguage=C#AutoEventWireup=trueCodeFile=zhanghu.aspx.csInherits=zhanghu%!DOCTYPEhtmlPUBLIC-//W3C//DTDXHTML1.0Transitional//EN==Head1runat=servertitle网上银行/titlescriptlanguage=javascripttype=text/javascript//!CDATA[functionTABLE1_onclick(){}10//]]/script/headbodyformid=form2runat=serverdiv tableid=TABLE1width=1000onclick=returnTABLE1_onclick()style=border-right:thinsolid;border-top:thinsolid;border-left:thinsolid;border-bottom:thinsolidtrtdcolspan=3style=background-image:url(pic/faq_03.jpg);background-repeat:no-repeat;height:82px/td/trtrtdstyle=width:125px;height:368px;background-image:url(pic/faq_04.jpg);background-repeat:no-repeat;/tdtdstyle=width:192px;height:368px asp:LabelID=Label1runat=serverStyle=font-size:12px;z-index:100;left:297px;position:absolute;top:161pxText=您帐户的余额为:/asp:Label asp:TextBoxID=countrunat=serverHeight=12pxStyle=z-index:102;left:382px;position:absolute;top:209pxWidth=119pxOnTextCh
本文标题:实验报告模板
链接地址:https://www.777doc.com/doc-4095063 .html