数据库课程设计快餐网售系统.doc_第1页
数据库课程设计快餐网售系统.doc_第2页
数据库课程设计快餐网售系统.doc_第3页
数据库课程设计快餐网售系统.doc_第4页
数据库课程设计快餐网售系统.doc_第5页
已阅读5页,还剩17页未读 继续免费阅读

下载本文档

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

文档简介

课程设计班 级: 2009级姓 名: 孙超学 号:2009010423系 别:经济管理系 日 期:2011/12/19快餐网售课程设计 一、 设计需求:本设计为快餐网售,可以在网上选购自己喜欢的快餐,通过这个系统可以随时订餐,送餐上门。快餐网购的功能要求: 用户登录、注销、用户注册 查询所需的快餐。 订购所需快餐 结算订购快餐的款项 选择方便的方式进行快餐的价钱的支付 到相应的网站进行支付 二、设计的目的:为在校学生提供方便的送货上门的快餐服务,以便学生拥有更健康的身体及更有效地学习。三、快餐网售的模块:通过登陆界面 登录.aspx 验证正确的用户名和密码后进入主界面 快餐主页.aspx。若没有用户名和密码,则先跳到注册界面 注册.aspx 进行注册(注册内容包括:客户名、密码、编号)。在主页面上包含:1. 快餐买卖 快餐主页.aspx2. 快速下订单 输入快餐.aspx3. 支付 支付页面.aspx4. 请结算 结算.aspx以上模块共同构成整个系统。四、网站的内容:首先是硬盘的功能流程图:快餐网购系统运行用户登录用户注册系统主界面快餐买卖请下订单搜索结算查看个人资料到支付宝支付请下支付系统功能流程图五、数据库的设计:1.需求分析 通过对大学生日常生活进行的可行性分析和详细调查,确定开发快餐网购管理系统。开发小组的成员经过调查研究、信息流程分析和数据收集,明确了该系统的主要功能;用户登录、注销、用户注册、查询所需的快餐、订购所需快餐、结算订购快餐的款项、选择方便的方式进行快餐的价钱的支付、到相应的网站进行支付,并提供简单的查询功能。2.概念结构设计 由于系统不太复杂,设计E-R图可以直接从系统的数据流下手。参照需求分析中对业务数据流程的描述,对每个试题及属性进行如下定义: 订单表(订单编号、客户编号、商品编号、订单时间)客户表(客户编号、姓名、密码、已购数量)商品表(商品编号、商品名称、数量、保质期、下架时间、价钱)系统的E-R图如图所示:客户商品订单下架时间保质期数量、价钱商品名称商品编号客户编号订单编号订单时间客户编号姓名密码已购数量商品编号图2 E-R图3.逻辑结构设计 根据概念结构设计的结果,设计出“快餐网售管理系统”数据库的逻辑关系模型。将图2的E-R图转换为关系模型,关系的主码用下划线划出:订单表(订单编号、客户编号、商品编号、订单时间)客户(客户编号、姓名、密码、已购数量)商品表(商品编号、商品名称、数量、保质期、下架时间、价钱)4.物理设计结构设计 将逻辑结构设计的关系模型转换为物理数据库,及具体的RDBMS中支持的关系数据模型-表。在SQL Server2005数据库管理系统中创建订单表、客户、商品表、订单1和订单2。表的结构如表1-表5所示。1名称:订单表,如表-1所示 订单表包括订单编号、客户编号、商品编号和订单时间。表-1字段名称类 型主 键非 空订单编号自动生成YesYes客户编号文本NoYes 商品编号文本NoYes订单时间文本NoYes2名称:商品表,如表1-2所示 商品表包括商品编号、商品名称、数量、保质期、下架时间和价钱。表-2字段名称类 型主 键非 空商品编号自动编号YesYes商品名称文本NoYes数量文本NoYes保质期文本NoYes下架时间文本NoYes价钱文本NoYes3名称:客户表,如表1-3所示 客户表包括:姓名、密码、客户编号、已购数量e。表-3字段名称类 型主 键非 空客户编号自动编号YesYes姓名文本NoYes密码文本NoYes已购数量文本NoYes5.数据库实施、数据库运行及维护 在SQL Server 2005 中创建表成功后,向表中添加数据,将各种表的记录添加到各个表中。六、系统设计 前台设计: 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, EventArgs 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 客户 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.Response.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) protected 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 + ); trymyConnection.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);protected 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(); SqlCommand 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(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 % + 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 DataColumn(数量, 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(); 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(object 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(myConnStr); 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 = myComm.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).ToString(); 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 + , + this.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.Text; 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, EventArgs 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 = new 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.ExecuteScalar(); /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 protected 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_Click(object sender, EventArgs e) this.Response.Redirect(/login/index.htm?goto=); 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_Click(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.DataSource = 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 myConnection.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. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论