数据库课程设计快餐网售系统.doc

上传人:文库蛋蛋多 文档编号:2395621 上传时间:2023-02-17 格式:DOC 页数:22 大小:738KB
返回 下载 相关 举报
数据库课程设计快餐网售系统.doc_第1页
第1页 / 共22页
数据库课程设计快餐网售系统.doc_第2页
第2页 / 共22页
数据库课程设计快餐网售系统.doc_第3页
第3页 / 共22页
数据库课程设计快餐网售系统.doc_第4页
第4页 / 共22页
数据库课程设计快餐网售系统.doc_第5页
第5页 / 共22页
点击查看更多>>
资源描述

《数据库课程设计快餐网售系统.doc》由会员分享,可在线阅读,更多相关《数据库课程设计快餐网售系统.doc(22页珍藏版)》请在三一办公上搜索。

1、课程设计 快餐网售课程设计 一、 设计需求:本设计为快餐网售,可以在网上选购自己喜欢的快餐,通过这个系统可以随时订餐,送餐上门。快餐网购的功能要求: 用户登录、注销、用户注册 查询所需的快餐。 订购所需快餐 结算订购快餐的款项 选择方便的方式进行快餐的价钱的支付 到相应的网站进行支付 二、设计的目的:为在校学生提供方便的送货上门的快餐服务,以便学生拥有更健康的身体及更有效地学习。三、快餐网售的模块:通过登陆界面 登录.aspx 验证正确的用户名和密码后进入主界面 快餐主页.aspx。若没有用户名和密码,则先跳到注册界面 注册.aspx 进行注册(注册内容包括:客户名、密码、编号)。在主页面上包

2、含:1. 快餐买卖 快餐主页.aspx2. 快速下订单 输入快餐.aspx3. 支付 支付页面.aspx4. 请结算 结算.aspx以上模块共同构成整个系统。四、网站的内容:首先是硬盘的功能流程图:快餐网购系统运行用户登录用户注册系统主界面快餐买卖请下订单搜索结算查看个人资料到支付宝支付请下支付系统功能流程图五、数据库的设计:1.需求分析 通过对大学生日常生活进行的可行性分析和详细调查,确定开发快餐网购管理系统。开发小组的成员经过调查研究、信息流程分析和数据收集,明确了该系统的主要功能;用户登录、注销、用户注册、查询所需的快餐、订购所需快餐、结算订购快餐的款项、选择方便的方式进行快餐的价钱的支

3、付、到相应的网站进行支付,并提供简单的查询功能。2.概念结构设计 由于系统不太复杂,设计E-R图可以直接从系统的数据流下手。参照需求分析中对业务数据流程的描述,对每个试题及属性进行如下定义: 订单表(订单编号、客户编号、商品编号、订单时间)客户表(客户编号、姓名、密码、已购数量)商品表(商品编号、商品名称、数量、保质期、下架时间、价钱)系统的E-R图如图所示:客户商品订单下架时间保质期数量、价钱商品名称商品编号客户编号订单编号订单时间客户编号姓名密码已购数量商品编号图2 E-R图3.逻辑结构设计 根据概念结构设计的结果,设计出“快餐网售管理系统”数据库的逻辑关系模型。将图2的E-R图转换为关系

4、模型,关系的主码用下划线划出:订单表(订单编号、客户编号、商品编号、订单时间)客户(客户编号、姓名、密码、已购数量)商品表(商品编号、商品名称、数量、保质期、下架时间、价钱)4.物理设计结构设计 将逻辑结构设计的关系模型转换为物理数据库,及具体的RDBMS中支持的关系数据模型-表。在SQL Server2005数据库管理系统中创建订单表、客户、商品表、订单1和订单2。表的结构如表1-表5所示。1名称:订单表,如表-1所示 订单表包括订单编号、客户编号、商品编号和订单时间。表-1字段名称类 型主 键非 空订单编号自动生成YesYes客户编号文本NoYes 商品编号文本NoYes订单时间文本NoY

5、es2名称:商品表,如表1-2所示 商品表包括商品编号、商品名称、数量、保质期、下架时间和价钱。表-2字段名称类 型主 键非 空商品编号自动编号YesYes商品名称文本NoYes数量文本NoYes保质期文本NoYes下架时间文本NoYes价钱文本NoYes3名称:客户表,如表1-3所示 客户表包括:姓名、密码、客户编号、已购数量e。表-3字段名称类 型主 键非 空客户编号自动编号YesYes姓名文本NoYes密码文本NoYes已购数量文本NoYes5.数据库实施、数据库运行及维护 在SQL Server 2005 中创建表成功后,向表中添加数据,将各种表的记录添加到各个表中。六、系统设计 前台

6、设计: 1.创建项目首先启动Microsoft Visual Studio 2005,进入.NET的IDE界面,创建一个新的项目,选择菜单“文件”“新建”“网站”。在打开的“新建网站”对话框中,选择建立ASP.NET网站,设置网站文件所在文件系统的位置,并指定开发语言为Visual C#。网站建立成功后,在网站项目下可以看到Default.aspx页面,该页面为网站的第一个网页,登录页面生成。2.设计登录页面public partial class _Default : System.Web.UI.Page protected void Page_Load(object sender, Eve

7、ntArgs e) protected void LinkButton1_Click(object sender, EventArgs e) this.Response.Redirect(“注册”.aspx); protected void Button1_Click(object sender, EventArgs e) SqlConnection myConnection = new SqlConnection(Data Source=;Integrated Security=SSPI;Initial Catalog=用户信息); string mySQL = select * from

8、客户 where 姓名 = + TextBox1.Text + and 密码 = + TextBox2.Text + ; try myConnection.Open(); SqlCommand myComm = new SqlCommand(mySQL, myConnection); SqlDataReader dr = myComm.ExecuteReader(); if (dr.Read() this.Response.Redirect(快餐主页.aspx); else this.Response.Write(alert(登录失败); catch (Exception) this.Resp

9、onse.Write(alert(异常); finally myConnection.Close(); Application ww = this.TextBox1 .Text; protected void LinkButton2_Click(object sender, EventArgs e) this.Response.Redirect(快餐主页.aspx); 2.2 注册页面public partial class Default2 : System.Web.UI.Page protected void Page_Load(object sender, EventArgs e) pr

10、otected void Button1_Click(object sender, EventArgs e) SqlConnection myConnection = new SqlConnection(Data Source=;Integrated Security=SSPI;Initial Catalog=用户信息); string mySQL = insert into 客户(姓名,密码,客户编号) values( + this.TextBox1.Text + , + this.TextBox2.Text + , + this.TextBox3.Text + ); trymyConnec

11、tion.Open(); SqlCommand cmd = new SqlCommand(mySQL, myConnection); cmd.ExecuteNonQuery(); this.Response.Write(alert(注册成功|!); catch (Exception) this.Response.Write(alert(注册失败!); FinallymyConnection.Close(); protected void Button2_Click(object sender, EventArgs e) this.Response.Redirect(登录.aspx);prote

12、cted void TextBox1_TextChanged(object sender, EventArgs e) protected void Button3_Click(object sender, EventArgs e) SqlConnection myConnection = new SqlConnection(Data Source=;Integrated Security=SSPI;Initial Catalog=用户信息); string mySQL = execute 级联删除 + TextBox3.Text + ; myConnection.Open(); SqlComm

13、and myComm = new SqlCommand(mySQL, myConnection); SqlDataReader dr = myComm.ExecuteReader(); this.Response.Write(alert(删除成功); myConnection.Close(); 3.设计快餐网售的主页面public partial class Default7 : System.Web.UI.Page protected void Page_Load(object sender, EventArgs e) this.Label10.Text = Convert.ToString

14、(Applicationww); protected void Button1_Click(object sender, EventArgs e) string myConnStr = Data Source=;Integrated Security=SSPI;Initial Catalog=用户信息; SqlConnection myConn = new SqlConnection(myConnStr); string sql = select * from 商品表 where 商品编号 like % + this.TextBox1.Text + % and + 商品名称 like % +

15、this.TextBox2.Text + %; SqlCommand myComm = new SqlCommand(sql, myConn); myConn.Open(); SqlDataReader myReader = myComm.ExecuteReader(); DataTable dt = new DataTable(); dt.Columns.Add(new DataColumn(商品编号, typeof(string); dt.Columns.Add(new DataColumn(商品名称, typeof(string); dt.Columns.Add(new DataColu

16、mn(数量, typeof(string); dt.Columns.Add(new DataColumn(保质期, typeof(string); dt.Columns.Add(new DataColumn(下架时间, typeof(string); dt.Columns.Add(new DataColumn(价钱, typeof(string); while (myReader.Read() DataRow dr = dt.NewRow(); dr0 = myReader.GetValue(0).ToString(); dr1 = myReader.GetValue(0).ToString(

17、); dr2 = myReader.GetValue(0).ToString(); dr3 = myReader.GetValue(0).ToString(); dr4 = myReader.GetValue(0).ToString(); dr5 = myReader.GetValue(0).ToString(); dt.Rows.Add(dr); myConn.Close(); this.GridView1.DataSource = new DataView(dt); this.GridView1.DataBind(); protected void LinkButton1_Click(ob

18、ject sender, EventArgs e) this.Response.Redirect(订单输入.aspx); 4.设计下订单的页面public partial class Default6 : System.Web.UI.Page protected void Page_Load(object sender, EventArgs e) string myConnStr = Data Source=;Integrated Security=SSPI;Initial Catalog=用户信息; SqlConnection myConn = new SqlConnection(myCon

19、nStr); string sql=select max(订单编号)from 订单表; SqlCommand myComm = new SqlCommand(sql, myConn); myConn.Open(); /int maxNum = Convert.ToInt32(myComm.ExecuteScalar() + 1; /this.TextBox1.Text = maxNum.ToString(); sql = select 商品编号 from 商品表; myComm = new SqlCommand(sql, myConn); SqlDataReader myReader = my

20、Comm.ExecuteReader(); while (myReader.Read() this.DropDownList1.Items.Add(myReader.GetValue(0).ToString(); myReader.Close(); sql = select 客户编号 from 客户; myComm = new SqlCommand(sql, myConn); myReader = myComm.ExecuteReader(); while (myReader.Read() this.DropDownList2.Items.Add(myReader.GetValue(0).To

21、String(); myConn.Close(); protected void Button1_Click(object sender, EventArgs e) string myConnStr = Data Source=;Integrated Security=SSPI;Initial Catalog=用户信息; SqlConnection myConn = new SqlConnection(myConnStr); string sql = insert into 订单表(订单编号,商品编号,客户编号,订单时间)values( + this.TextBox1.Text + , + t

22、his.DropDownList1.Text + , + this.DropDownList2.Text + , + this.TextBox4.Text + ); SqlCommand myComm = new SqlCommand(sql, myConn); myConn.Open(); myComm.ExecuteNonQuery(); myConn.Close(); this .Response .Write (alert(订单成功!); Applicationww = this.DropDownList1.Text; Applicationaa = this.TextBox5.Tex

23、t; protected void LinkButton1_Click(object sender, EventArgs e) this.Response.Redirect(商品查询.aspx); protected void LinkButton2_Click(object sender, EventArgs e) this.Response.Redirect(支付页面.aspx); 5.设计支付的页面public partial class _Default : System.Web.UI.Page protected void Page_Load(object sender, Event

24、Args e) this.TextBox3.Text = Convert.ToString (Applicationww); this.TextBox2.Text = Convert.ToString(Applicationaa); protected void LinkButton1_Click(object sender, EventArgs e) this.Response.Redirect(结算.aspx); protected void Button1_Click1(object sender, EventArgs e) SqlConnection myConnection = ne

25、w SqlConnection(Data Source=;Integrated Security=SSPI;Initial Catalog=用户信息); string mySql=select 价钱 from 商品表 where 商品编号=+this .TextBox3 .Text+; try myConnection.Open(); /调用对象的Open()方法,打开数据库连接 SqlCommand mycomm = new SqlCommand (mySql, myConnection); string count = Convert.ToString(mycomm.ExecuteScal

26、ar(); /DataSet ds = new DataSet(); /myDataAdapter.Fill(ds, 价钱); this.Label9.Text = count; catch (Exception) this.Response .Write (存在异常); /处理异常 finally myConnection.Close(); this.Response.Write(关闭数据库连接成功); Applicationee =this.Label9.Text; 6设计结算的页面public partial class _Default : System.Web.UI.Page pro

27、tected void Page_Load(object sender, EventArgs e) TextBox1.Text = Convert.ToString(Applicationee); /int i=int.Parse (TextBox1 .Text )+int.Parse (TextBox2 .Text ); /Label4.Text = i.ToString(); Label4.Text = Convert.ToString(TextBox1.Text) + Convert.ToString(TextBox2.Text); protected void LinkButton1_

28、Click(object sender, EventArgs e) this.Response.Redirect( 2.后台设计namespace WindowsFormsApplication1 public partial class Form2 : Form SqlConnection myConnection = new SqlConnection(Data Source=;Integrated Security=SSPI;Initial Catalog=用户信息); public Form2() InitializeComponent(); private void label1_C

29、lick(object sender, EventArgs e) private void button1_Click(object sender, EventArgs e) string mySQL = select * from 订单表; try myConnection.Open(); SqlDataAdapter myDataAdapter = new SqlDataAdapter(mySQL, myConnection); DataSet ds = new DataSet(); myDataAdapter.Fill(ds, 商品); this.dataGridView1.DataSo

30、urce = ds; this.dataGridView1.DataMember = 商品; catch (Exception) MessageBox.Show(存在异常); finally myConnection.Close(); private void button2_Click(object sender, EventArgs e) string sql = insert 订单表 values( + textBox1.Text + , + textBox2.Text + , + textBox3.Text + , + textBox4.Text + ); try myConnecti

31、on.Open(); SqlCommand cmd = new SqlCommand(sql, myConnection); cmd.ExecuteNonQuery(); MessageBox.Show(添加成功!); catch (Exception) MessageBox.Show(存在异常); finally myConnection.Close(); private void button3_Click(object sender, EventArgs e) string sql = string.Format( Update 订单表 set 商品编号=1,客户编号=2,订单时间=3w

32、here 订单编号=4 , textBox1.Text, textBox2.Text, textBox3.Text, textBox4.Text, textBox1.Text); SqlCommand command = new SqlCommand(sql, myConnection); myConnection.Open(); command.ExecuteNonQuery(); / 执行命令 myConnection.Close(); MessageBox.Show(信息被修改); private void button4_Click(object sender, EventArgs e

33、) string sql = delete from 订单表 where 订单编号= + textBox1.Text + ; try myConnection.Open(); SqlCommand cmd = new SqlCommand(sql, myConnection); cmd.ExecuteNonQuery(); MessageBox.Show(信息删除成功); catch (Exception) MessageBox.Show(存在异常); finally myConnection.Close(); 核心代码:七、课程设计总结心得:通过这次课程设计使我懂得了理论与实际相结合是很重要

34、的,只有理论知识是远远不够的,只有把所学的理论知识与实践相结合起来,从理论中得出结论,才能真正为社会服务,从而提高自己的实际动手能力和独立思考的能力。在设计的过程中遇到问题,可以说得是困难重重,这毕竟第一次做的,难免会遇到过各种各样的问题,同时在设计的过程中发现了自己的不足之处,对以前所学过的知识理解得不够深刻,掌握得不够牢固。同时让我知道我们的工作是一个团队的工作,团队需要个人,个人也离不开团队,必须发扬团结协作的精神。某个人的离群都可能导致导致整项工作的失败。实习中只有一个人知道原理是远远不够的,必须让每个人都知道,否则一个人的错误,就有可能导致整个工作失败。团结协作是我们实习成功的一项非常重要的保证。而这次实习也正好锻炼我们这一点,这也是非常宝贵的。最后,在这次课程设计,学到了很多课内学不到的东西,比如独立思考解决问题,出现差错的随机应变,和与人合作共同提高,都受益非浅,今后的制作应该更轻松,自己也都能扛的起并高质量的完成项目。

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 建筑/施工/环境 > 项目建议


备案号:宁ICP备20000045号-2

经营许可证:宁B2-20210002

宁公网安备 64010402000987号