




免费预览已结束,剩余16页可下载查看
下载本文档
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
C#语言编程设计课程实验报告实验:银行客户服务系统1. 实验目的 做一个三层结构的银行客户服务系统,实现客户的存款和取款的过程。其中三层要求如下:第一层:业务表现层,在用户界面上实现客户的存款取款过程。第二层:业务逻辑层,验证用户的输入是否合法,比如用正则表达式验证用户的存款和取款的输入必须是数字。第三层:数据访问层,当业务逻辑层完成数据的验证以后,使用数据访问层的类直接对数据库进行插入或者删除的操作。2. 设计代码见附录。3. 实验结果首页(index.aspx) 提示用户输入用户名和密码:图1若输入身份证号码错误,或者密码错误,弹出错误提示框,返回首页图2若用户名与密码正确则登陆到账户管理页面图3选择存款功能,进入存款页面图4若输入不是数字,或违法恶意输入,弹出提示框,返回用户管理页面图5 若输入正确,弹出交易成功提示框,返回用户管理页面,余额相应增加图6选择取款功能,进入取款界面图7若输入不是数字,或违法恶意输入,弹出提示框,返回用户管理页面图7若取款金额超出余额,弹出提示框,禁止取款,返回用户管理页面若输入正确,提示交易成功,跳转到用户管理页面,金额相应减少图8若选择注销功能,消除Session值,跳转到登陆页面图10数据库样例:图114. 说明体会本人熟悉web开发,之前一直使用php在appache环境下做网站,数组库使用的是mysql,也在iis下做过asp,这次有机会使用ASP.NET,让我感触很多。首先,.net允许你使用多种不同编程语言的框架,你可以在你的网站中嵌入各种语言,然后,他还有出色的面向对象编程模型,强大的类库为用户带来了很多方便,还有,ASP.NET起初运行于IIS,现在也可以运行于Apache,这将给.net的安全性带来不少改进。由于接触时间不长,在使用方面不是很熟悉。通过这次实验我对.net有了进一步了解,以后会继续努力学习钻研!5. 附录源代码:/index.aspx/登陆页面 网上银行 /index.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 partial 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-913254b1; + Trusted_Connection=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(thisCommand.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(alert(输入有误,请重新输入!); 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.Data;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.Page string balance = ; /int check = 0; protected void Page_Load(object sender, EventArgs e)/连接数据库,查询数据库 string connect = server=school-913254b1; + Trusted_Connection=yes; database=bank; SqlConnection conn = new SqlConnection(connect); conn.Open(); SqlCommand command = conn.CreateCommand(); string sql = command.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 = 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= + Sessionid + ); 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.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;using System.Text.RegularExpressions;public partial class cunkuan : System.Web.UI.Page string balance = ; private double amount = 0; string connect = server=school-913254b1; + 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 where 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 TextBox1_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 = new 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 + ; comman
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 房地产租赁合同实务及法律风险防范
- 影视制作后期项目合作协议
- 企业合同审查与风险管理指南
- 在线课程销售合作协议与推广收益分配计划说明
- 2025四川眉山市医疗卫生辅助岗招募100人考试参考题库及答案解析
- 2025年甘肃省兰州市西北民族大学专任教师招聘补充考试模拟试题及答案解析
- 2025云南昭通市职业教育中心招聘城镇公益性岗位工作人员10人考试参考题库及答案解析
- 专业装修建材供应链管理合同
- 安全传输合同配置服务合同
- 农业生产力提升技术研发合作协议
- 沙坪公园完整
- 未成年人保护法宣传教育
- 【精】人民音乐出版社人音版五年级上册音乐《清晨》课件PPT
- 河南省道路救援收费标准
- 色盲检测图(第五版)-驾校考试-体检必备-自制最全最准确课件
- 特殊教育的基础理论-特殊教育学的理论基础
- 毕业生转正定级审批表
- 动画运动规律-动物-课件
- 【短视频直播带货营销策略分析9700字(论文)】
- solidworks高级培训钣金件经典课件
- 2023年高考数学复习专题课件★★空间向量与空间角、距离问题 课件(共34张PPT)
评论
0/150
提交评论