基于ASP课程设计实验报告书.doc_第1页
基于ASP课程设计实验报告书.doc_第2页
基于ASP课程设计实验报告书.doc_第3页
基于ASP课程设计实验报告书.doc_第4页
基于ASP课程设计实验报告书.doc_第5页
已阅读5页,还剩14页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

基于ASP.NET的电子通信录系统的设计与实现一【实验目的】 通过制作一个电子通信录系统来掌握使用ADO.NET访问与操纵数据库的方法。二【实验内容】l 电子通信录包括三部分信息:1. 用户登录注册信息2. 通信组信息3. 联系人信息数据结构描述:数据库名Correspondence用户名数据表结构(TableUser)通信组数据表结构 (TableGroup)联系人数据表结构 (TableUser)l 电子通信录的基本功能:添加,删除,编辑,显示通信组信息和联系人信息。此外还可以根据一定条件查找联系人和修改密码。三【系统框架】1.工程文档结构 2.数据库的设计 3.系统框架的效果图:四【模块设计】 如首页所示:三大模块:登录,注册,电子通讯录首页。(1)注册:l 功能:如果用户没有账号可以在注册界面建立自己的账号和密码。(2)登录:l 功能:用户利用已经注册的账号登录到电子通讯录首页(3) 电子通讯录首页:(共分为6个小模块)l 功能:登录到主页以后可以根据首页的六个标签来选择所要进行的操作。1)创建于维护通讯组:通信组是根据联系人之间的关系建立不同性质的Group,以上页面主要访问数据库中的TableGroup数据表。页面主要功能分别为:组的创建和维护。比如,可以建立亲友通信组、工作通信组、同学通信组以及其他类型通信组等。2)显示通讯组:显示已经创建的组信息。3)创建与维护联系人:根据联系人与通信组的关系,对联系人进行分类添加和维护,以上页面涉及到对TableUser数据表的操作,同时需要考虑与TableGroup数据表之间的关系。4)现实联系人:显示已经创建的联系人信息。5)修改密码:用户可以在登录后随意修改密码,便于个人使用。6)查找联系人:如果用户为节省时间而查找某个记录,可以找查找中输入要求简要的信息,获取所需要的信息。五【编码实现】(1) 登录界面.aspx相关代码的实现:无标题页#form1 width: 764px; top: 57px; margin-bottom: 18px; .style4 width: 232px;style5height: 40px; .style6 width: 210px; height: 40px; .style8 width: 210px;.style9 height: 71px; .style10 width: 105px; .style11 height: 40px; width: 105px; /注册相响应函数 protected void Button2_Click(object sender, EventArgs e) Response.Redirect(注册界面.aspx); /登录的响应函数 protected void Button1_Click(object sender, EventArgs e) if (TextBox1.Text = ) | (TextBox2.Text = ) Label1.Text = 您可能没有按照要求填写信息登录失败!; else string coon = SqlDataSource1.ConnectionString; SqlConnection con = new SqlConnection(coon); string strsql = select * from TableUser where UserID= + TextBox1.Text + and Password= + TextBox2.Text + ; SqlDataReader sdr = ExecReader(strsql); if (sdr.Read() SessionUserID = TextBox1.Text; SessionPassword = TextBox2.Text; Response.Redirect(电子通信录主页.aspx); else Label1.Text = 无法登陆,用户名或密码错误; public SqlDataReader ExecReader(string sqlcmd, params SqlParameter paraList) string coon = SqlDataSource1.ConnectionString; SqlConnection con = new SqlConnection(coon); SqlCommand cmd = new SqlCommand(); cmd.Connection = con; cmd.CommandText = sqlcmd; if (paraList != null) cmd.CommandType = CommandType.Text; foreach (SqlParameter para in paraList) cmd.Parameters.Add(para); con.Open(); SqlDataReader sdr = cmd.ExecuteReader(CommandBehavior.CloseConnection); return sdr; public void ExecNonQuery(string sqlcmd, params SqlParameter paraList) string coon = SqlDataSource1.ConnectionString; using (SqlConnection con = new SqlConnection(coon) SqlCommand cmd = new SqlCommand(); cmd.Connection = con; cmd.CommandText = sqlcmd; if (paraList != null) cmd.CommandType = CommandType.Text; foreach (SqlParameter para in paraList) cmd.Parameters.Add(para); con.Open(); cmd.ExecuteNonQuery();   用户名: 密码:   asp:SqlDataSource ID=SqlDataSource1 runat=server ConnectionString= SelectCommand=SELECT * FROM TableUser(2) 注册界面.aspx相关代码实现:欢迎进行用户注册 .style1 font-size: xx-large; font-weight: bold; font-family: 黑体; #form1 margin-left: 46px; margin-top: 55px;.style2 height: 39px; .style3 height: 47px; /立即注册 protected void Button1_Click(object sender, EventArgs e) try string createtime = DateTime.Now.ToString(f); SqlDataSource1.InsertCommand = insert into TableUser (UserID,Password,CreatTime) values ( + TextBox1.Text + , + TextBox2.Text + , + createtime + ); SqlDataSource1.Insert(); Response.Write(注册成功); Response.Redirect(登录界面.aspx); catch (SqlException ex) Response.Write(用户已存在!); protected void Button2_Click(object sender, EventArgs e) Response.Redirect(注册界面.aspx);      欢迎您注册电子通信录  用户名:      密码:     确认: 注册成功后自动跳转到登陆面! asp:SqlDataSource ID=SqlDataSource1 runat=server ConnectionString= OldValuesParameterFormatString=original_0 SelectCommand=SELECT * FROM TableUser (3) 电子通信录主页.aspx相关代码的实现: 无标题页 style=border-style: none; font-size: x-large; font-style: oblique; font-family: 方正姚体; z-index: auto;  电子通信录首页   ; 创建与维护通讯组         显示通讯组 创建与维护联系人        显示联系人        修改密码            查找联系人 asp:SqlDataSource ID=SqlDataSource1 runat=server ConnectionString= SelectCommand=SELECT UserID, Password, CreatTime FROM TableUser WHERE (UserID = UserID) l 通信组的创建.aspx相关代码实现: /确定响应 protected void Button1_Click(object sender, EventArgs e) if (TextBox1.Text = ) Label2.Text = 添加组失败!请检查是否按要求输入信息!; else try SqlDataSource1.InsertCommand = insert into TableGroup (GID,UserID,GName,GDescription) values ( + TextBox1.Text + , + SessionUserID + , + TextBox2.Text + , + TextBox3.Text + ); SqlDataSource1.Insert(); Label2.Text = 添加组信息成功!; catch (SqlException ex) Label2.Text = 请检查您是否建立了相同的GID通信组,创建失败!; /删除响应 protected void Button2_Click(object sender, EventArgs e) if (TextBox1.Text = ) Label2.Text = 删除失败!; else string coon = SqlDataSource1.ConnectionString; SqlConnection con = new SqlConnection(coon); string str1 = delete from TableGroup where GID= + TextBox1.Text + ; SqlCommand comd1 = new SqlCommand(str1, con); try comd1.Connection.Open(); comd1.ExecuteNonQuery(); catch (SqlException ex) Console.WriteLine(error); Response.Write(请检查用户是否存在!); Label2.Text = 删除成功!; /返回响应 protected void Button3_Click(object sender, EventArgs e) Response.Redirect(电子通信录主页.aspx); protected void Button5_Click(object sender, EventArgs e) Response.Redirect(通信组的显示.aspx); /编辑响应 protected void Button4_Click(object sender, EventArgs e) string coon = SqlDataSource1.ConnectionString; SqlConnection con = new SqlConnection(coon); string str1 = update TableGroup set GName= + TextBox2.Text + , GDescription= + TextBox3.Text + where GID= + TextBox1.Text + ; SqlCommand comd1 = new SqlCommand(str1, con); try comd1.Connection.Open(); int affRow = comd1.ExecuteNonQuery(); if (affRow != 0) Label2.Text = 编辑成功!; else Label2.Text = 编辑失败!; catch (SqlException ex) Console.WriteLine(请检查是否按照要求输入?); 通信组GID: 必填字段 通信组名GName:   通信组描述 GDescription:   asp:SqlDataSource ID=SqlDataSource1 runat=server ConnectionString= SelectCommand=SELECT * FROM TableGroup l 通信组的显示.aspx相关代码实现 无标题页 #form1 width: 682px; margin-left: 0px; margin-top: 0px; height: 461px; margin-right: 240px; protected void Button1_Click(object sender, EventArgs e)Response.Redirect(通信组的创建.aspx); asp:SqlDataSource ID=SqlDataSource1 runat=server ConnectionString= SelectCommand=SELECT GID, GName, GDescription FROM TableGroup WHERE (UserID = UserID) l 联系人信息的添加或删除.aspx相关代码实现 无标题页 #form1 margin-left: 190px; margin-right: 101px; margin-top: 0px; .style1width: 119px; .style2 width: 177px; /确定响应 protected void Button1_Click(object sender, EventArgs e) if (TextBox1.Text = ) | (TextBox2.Text = ) | (TextBox3.Text = ) Label3.Text = 添加失败!; else try Sqldatasource1.InsertCommand = insert into CTableUser (UID,GID,Name,Gender,Address,PostCode,Telephone,Mobile,E-mail) values ( + TextBox1.Text + , + TextBox2.Text + , + TextBox3.Text + , + TextBox4.Text + , + TextBox5.Text + , + TextBox6.Text + , +

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论