版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1、 .NET程序设计课程实验报告实验1 :题目学 院 软件学院 年 级 2005级 班 级 5班 学 号 姓 名 张力久 2007年 5 月 15 日实验:银行客户服务系统1. 实验目的 做一个三层结构的银行客户服务系统,实现客户的存款和取款的过程。其中三层要求如下:第一层:业务表现层,在用户界面上实现客户的存款取款过程。第二层:业务逻辑层,验证用户的输入是否合法,比如用正则表达式验证用户的存款和取款的输入必须是数字。第三层:数据访问层,当业务逻辑层完成数据的验证以后,使用数据访问层的类直接对数据库进行插入或者删除的操作。2. 实验内容 3. 设计代码见附录。4. 实验结果首页(index.as
2、px) 提示用户输入用户名和密码:图1若输入身份证号码错误,或者密码错误,弹出错误提示框,返回首页图2若用户名与密码正确则登陆到账户管理页面图3选择存款功能,进入存款页面图4若输入不是数字,或违法恶意输入,弹出提示框,返回用户管理页面图5 若输入正确,弹出交易成功提示框,返回用户管理页面,余额相应增加图6选择取款功能,进入取款界面图7若输入不是数字,或违法恶意输入,弹出提示框,返回用户管理页面图7若取款金额超出余额,弹出提示框,禁止取款,返回用户管理页面若输入正确,提示交易成功,跳转到用户管理页面,金额相应减少图8若选择注销功能,消除Session值,跳转到登陆页面图10数据库样例:图115.
3、 说明体会本人熟悉web开发,之前一直使用php在appache环境下做网站,数组库使用的是mysql,也在iis下做过asp,这次有机会使用ASP.NET,让我感触很多。首先,.net允许你使用多种不同编程语言的框架,你可以在你的网站中嵌入各种语言,然后,他还有出色的面向对象编程模型,强大的类库为用户带来了很多方便,还有,ASP.NET起初运行于IIS,现在也可以运行于Apache,这将给.net的安全性带来不少改进。由于接触时间不长,在使用方面不是很熟悉。通过这次实验我对.net有了进一步了解,以后会继续努力学习钻研!6. 附录源代码:/index.aspx/登陆页面 网上银行 /inde
4、x.aspx.cs/登陆页面using System;using System.Data;using System.Data;using System.Configuration;using System.Web;using System.Web.Security;using System.Web.UI;using System.Web.UI.WebControls;using System.Web.UI.WebControls.WebParts;using System.Web.UI.HtmlControls;using System.Data.SqlClient;public partia
5、l class index : System.Web.UI.Page protected void Page_Load(object sender, EventArgs e) protected void Button2_Click(object sender, EventArgs e) Response.Redirect(index.aspx); protected void submit_Click(object sender, EventArgs e) /连接数据库,查询数据库 string conString = server=school-b1; + Trusted_Connecti
6、on=yes; database=bank; SqlConnection conn = new SqlConnection(conString); conn.Open(); SqlCommand thisCommand = conn.CreateCommand(); thisCommand.CommandText = select * from user where username= + name.Text.Trim().ToString() + and password= + psw.Text.Trim().ToString() + ; / Response.Write(thisComma
7、nd.CommandText); SqlDataReader thisReader = thisCommand.ExecuteReader(); if (thisReader.Read() Sessionusername = name.Text.Trim().ToString(); Sessionpassword = psw.Text.Trim().ToString(); Sessionid = thisReaderid.ToString(); Response.Redirect(zhanghu.aspx?id= + Sessionid + ); else Response.Write(ale
8、rt(输入有误,请重新输入!); thisReader.Close(); conn.Close(); protected void TextBox2_TextChanged(object sender, EventArgs e) protected void name_TextChanged(object sender, EventArgs e) /zhanghu.aspx/账户管理页面 网上银行/ /zhanghu.aspx.cs/账户管理页面using System;using System.D
9、ata;using System.Configuration;using System.Collections;using System.Web;using System.Web.Security;using System.Web.UI;using System.Web.UI.WebControls;using System.Web.UI.WebControls.WebParts;using System.Web.UI.HtmlControls;using System.Data.SqlClient;public partial class zhanghu : System.Web.UI.Pa
10、ge string balance = ; /int check = 0; protected void Page_Load(object sender, EventArgs e)/连接数据库,查询数据库 string connect = server=school-b1; + Trusted_Connection=yes; database=bank; SqlConnection conn = new SqlConnection(connect); conn.Open(); SqlCommand command = conn.CreateCommand(); string sql = com
11、mand.CommandText = select * from user where id= + Sessionid + ; SqlDataAdapter dataAdapter = new SqlDataAdapter(sql, conn); DataSet dataSet = new DataSet(); dataAdapter.Fill(dataSet, user); String balance = dataSet.Tablesuser.Rows0balance.ToString(); / check = Convert.ToInt32(balance); count.Text =
12、balance.ToString(); protected void count_TextChanged(object sender, EventArgs e) protected void Button3_Click(object sender, EventArgs e) /进入存款页面 Response.Redirect(cunkuan.aspx?id= + Sessionid + ); protected void Button1_Click(object sender, EventArgs e)/进入取款页面 Response.Redirect(qukuan.aspx?id= + Se
13、ssionid + ); protected void Button2_Click(object sender, EventArgs e)/注销 Response.Redirect(index.aspx); / cunkuan.aspx/存款页面 网上银行/ /cunkuan.aspx.cs/存款页面using System;using System.Data;using System.Configuration;using System.Collections;using System.Web;using System.We
14、b.Security;using System.Web.UI;using System.Web.UI.WebControls;using System.Web.UI.WebControls.WebParts;using System.Web.UI.HtmlControls;using System.Data.SqlClient;using System.Text.RegularExpressions;public partial class cunkuan : System.Web.UI.Page string balance = ; private double amount = 0; st
15、ring connect = server=school-b1; + Trusted_Connection=yes; database=bank; protected void Page_Load(object sender, EventArgs e) /连接数据库,查询余额 SqlConnection conn = new SqlConnection(connect); conn.Open(); SqlCommand command = conn.CreateCommand(); string sql = command.CommandText = select * from user wh
16、ere id= + Sessionid + ; SqlDataAdapter dataAdapter = new SqlDataAdapter(sql, conn); DataSet dataSet = new DataSet(); dataAdapter.Fill(dataSet, user); String balance = dataSet.Tablesuser.Rows0balance.ToString(); amount = Convert.ToDouble(balance); count.Text = balance.ToString(); protected void TextB
17、ox1_TextChanged(object sender, EventArgs e) protected void Button1_Click(object sender, EventArgs e) protected void Button2_Click(object sender, EventArgs e) protected void Button1_Click1(object sender, EventArgs e) string input = SaveAmount.Text; SaveAmount.Text = ;/使用正则表达式验证输入是否合法 Regex theReg = n
18、ew Regex(d+(.d0,2)?$); if (theReg.IsMatch(input) /输入合法,连接数据库,修改数据 double money = Convert.ToDouble(input); amount += money; SqlConnection conn = new SqlConnection(connect); conn.Open(); SqlCommand command = conn.CreateCommand(); string sql = command.CommandText = update user set balance = + Convert.ToDouble(amount) + where id = + Sessionid + ; command.ExecuteNonQuery(); conn.Close(); Response.Write(alert(交易成功); SaveAmount.Focus(); else Response.Write(alert(输入有误,请重新输入!); protected void SaveAmount_TextChang
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 2026年中级安全工程师《建筑施工安全实务》练习题及答案
- 2026年RDPAC资格认证《急诊用药常识》题库(附含答案)
- 2026年福建省漳州市教师招聘笔试题库
- 任正非华为上市演讲稿
- 干部竞选演讲稿1000
- 热质交换原理与设备addition12.30
- 众志成城备战期末演讲稿
- 关于十二生肖电影演讲稿
- 液压伺服与比例控制系统课件
- T/ZSMM 6-2024免疫固定电泳实验室检测室内质量控制指南
- 2024年《道德与法治》五年级下册全册教案
- 糖尿病病例书写规范与SOAP病历应用
- 调取监控申请书
- 大数据导论-大数据如何改变世界知到智慧树章节测试课后答案2024年秋浙江大学
- 接入式涉路工程安全影响评价报告
- 学位英语4000词(开放大学)
- 人工智能训练师理论知识考核要素细目表一级
- 开源情报分析以县域经济为例
- 《医院空气净化管理》课件
- 顶棚涂料喷涂施工方案范本
- 职业技能鉴定考评员聘用协议书【模板】
评论
0/150
提交评论