1、目录1.设计目的12.系统描述13.系统分析与设计24.各功能模块主要界面35.程序主要代码56.设计过程中遇到的主要问题197.总结191.设计目的巩固数据库的基本概念,结合实际的操作和设计,使学生掌握数据库系统的基本概念、原理和技术,将理论与实际相结合,应用现有的数据建模工具和数据库管理系统软件,规范、科学地完成一个小型数据库的设计与实现。巩固C#程序设计基础知识:主要包括语言基础、窗体界面设计、文本文件操作、数据库访问、数据绑定等。注意要养成良好的编码习惯:包括缩进、遵循命名规范等。结合软件工程知识了解一个实用系统的面向对象设计方法:功能描述系统设计模块设计类设计(本例中仅窗体类)。培养
2、学生调查研究、查阅技术文献、资料、手册以及编写技术文献的能力,把理论与实践相结合,提高其实际动手能力和创新能力。学会从用户的角度考虑界面构成,合理划分模块功能,使系统结构清晰、易于设计和维护。2.系统描述快餐店的多功能点餐系统要求实现对客户所点菜的菜单的查询,对客户结账,以及对会员进行打折,积分等进行计算机管理。该系统主要包括以下内容:(1)会员管理 设置创建会员,查看会员信息,更新会员信息,以及对会员的消费进行积分打折。(2)点餐处理 显示客户所点的菜,如果是普通客户的话,点餐后直接进行结账,没有任何优惠;如果是会员的话,点餐、结账后将对会员进行打折、积分处理。(3)管理员功能 通过管理员登
3、录系统后,进行会员管理,点餐处理。3.系统分析与设计菜单数据表结构列名数据类型长度允许空菜单号(主键)char(标识列)10否菜名Char20否价格int4是会员数据表结构列名数据类型长度允许空会员号(主键)char(标识列)10否积分int4否办理时间datetime8是 点餐信息查询数据表结构列名数据类型长度允许空菜单号(主键)char10否份额int4否点菜时间datetime8否窗体类数据结构包括12个窗体:管理员身份验证窗体,管理员查询窗体,系统主模块窗体,查询窗体,点餐窗体,结账窗体,会员登录与身份修改窗体。4.各功能模块主要界面5.程序主要代码管理员登录代码:using Syst
4、em;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Linq;using System.Text;using System.Windows.Forms;using System.Data.SqlClient;namespace WindowsFormsApplication1 public partial class Form1 : Form public Form1() InitializeComponent();
5、 private void button1_Click(object sender, EventArgs e) String strCon = connectionString.GetConnection1(); SqlConnection con = new SqlConnection(strCon); con.Open(); SqlCommand cmd4 = new SqlCommand(); cmd4.Connection = con; cmd4.CommandText = select * from 管理员表 where 管理员号= + textBox1.Text + and 密码=
6、 + textBox2.Text + ; cmd4.CommandType = CommandType.Text; SqlDataAdapter da4 = new SqlDataAdapter(cmd4); da4.MissingMappingAction = MissingMappingAction.Passthrough; DataTable dt4 = new DataTable(); da4.Fill(dt4); if (dt4.Rows.Count != 0) Form6 myform6 = new Form6(); myform6.Show(); private void but
7、ton2_Click(object sender, EventArgs e) this.Close(); private void Form1_Load(object sender, EventArgs e) 管理员操作代码:using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Linq;using System.Text;using System.Windows.Forms;using Syste
8、m.Data.SqlClient;namespace WindowsFormsApplication1 public partial class Form6 : Form public Form1 f; public Form6() InitializeComponent(); private void button1_Click(object sender, EventArgs e) Form11 myform11 = new Form11(this); myform11.Show(); this.Close(); private void button2_Click(object send
9、er, EventArgs e) Form12 myform12 = new Form12(); myform12.Show(); this.Close(); 管理员查看消费信息:using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Linq;using System.Text;using System.Windows.Forms;using System.Data.SqlClient;namesp
10、ace WindowsFormsApplication1 public partial class Form12 : Form public Form12() InitializeComponent(); private void button1_Click(object sender, EventArgs e) if (this.label1.Text.CompareTo(请输入年/月/日:) = 0) String strCon = connectionString.GetConnection2(); SqlConnection con = new SqlConnection(strCon
11、); con.Open(); SqlCommand cmd4 = new SqlCommand(); cmd4.Connection = con; DateTime t1 = Convert.ToDateTime(textBox1.Text); cmd4.CommandText = select * from 点餐信息查询,菜单 where 点餐信息查询.菜单号=菜单.菜单号 and datepart(dd,点菜时间)= + t1.Day .ToString() +and datepart(mm,点菜时间)= + t1.Month.ToString() + and datepart(yy,点菜
12、时间)= + t1.Year.ToString() + ; cmd4.CommandType = CommandType.Text; SqlDataAdapter da4 = new SqlDataAdapter(cmd4); da4.MissingMappingAction = MissingMappingAction.Passthrough; DataTable dt4 = new DataTable(); da4.Fill(dt4); this.dataGridView1.DataSource = dt4; else if (this.label1.Text.CompareTo(请输入年
13、/月份:) = 0) DateTime t1 = Convert.ToDateTime(textBox1.Text); String strCon = connectionString.GetConnection2(); SqlConnection con = new SqlConnection(strCon); con.Open(); SqlCommand cmd4 = new SqlCommand(); cmd4.Connection = con; cmd4.CommandText = select * from 点餐信息查询,菜单 where 点餐信息查询.菜单号=菜单.菜单号 and
14、datepart(mm,点菜时间)= + t1.Month.ToString() + and datepart(yy,点菜时间)= + t1.Year.ToString() + ; cmd4.CommandType = CommandType.Text; SqlDataAdapter da4 = new SqlDataAdapter(cmd4); da4.MissingMappingAction = MissingMappingAction.Passthrough; DataTable dt4 = new DataTable(); da4.Fill(dt4); this.dataGridVie
15、w1.DataSource = dt4; else if (this.label1.Text.CompareTo(请输入会员号:) = 0) String strCon = connectionString.GetConnection2(); SqlConnection con = new SqlConnection(strCon); con.Open(); SqlCommand cmd4 = new SqlCommand(); cmd4.Connection = con; cmd4.CommandText = select 会员号,菜名,点菜时间,价格 from 点餐信息查询,菜单 wher
16、e 点餐信息查询.菜单号=菜单.菜单号 and 会员号= +this.textBox1.Text+ ; cmd4.CommandType = CommandType.Text; SqlDataAdapter da4 = new SqlDataAdapter(cmd4); da4.MissingMappingAction = MissingMappingAction.Passthrough; DataTable dt4 = new DataTable(); da4.Fill(dt4); this.dataGridView1.DataSource = dt4; private void butto
17、n2_Click(object sender, EventArgs e) this.Close(); private void Form12_Load(object sender, EventArgs e) this.label1.Visible = false; this.textBox1.Visible = false; private void 按日查询ToolStripMenuItem_Click(object sender, EventArgs e) this.label1.Visible = true; this.label1.Text = 请输入年/月/日:; this.text
18、Box1.Visible = true ; private void 按月查询ToolStripMenuItem_Click(object sender, EventArgs e) this.label1.Visible = true; this.label1.Text = 请输入年/月份:; this.textBox1.Visible = true; private void 查看会员消费ToolStripMenuItem_Click(object sender, EventArgs e) this.label1.Visible = true; this.label1.Text = 请输入会
19、员号:; this.textBox1.Visible = true; private void 按年查询ToolStripMenuItem_Click(object sender, EventArgs e) this.label1.Visible = true; this.label1.Text = 请输入年份:; this.textBox1.Visible = true; 会员结账代码:using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System
20、.Drawing;using System.Linq;using System.Text;using System.Windows.Forms;using System.Data.SqlClient;namespace WindowsFormsApplication1 public partial class Form2 : Form public int zj = 0; public int number = 0; public string ccc = new string20; public Form5 f5; public string b; public Form2 ff; publ
21、ic Form9 f9; public Form2(Form5 f5) InitializeComponent(); this.f5 = f5; public Form2() InitializeComponent(); public Form2(Form9 f9) InitializeComponent(); this.f9 = f9; private void button1_Click(object sender, EventArgs e) dc my = new dc(); string name = ; name = this.textBox1.Text; if (my.checkn
22、umber(name) = 1) b = this.textBox1.Text; Form7 myform7 = new Form7(this); myform7.Show(); if (my.checknumber(name) = 0) Form3 myform3 = new Form3(); myform3.Show(); this.Close(); private void Form2_Load(object sender, EventArgs e) b = this.textBox1.Text; private void button2_Click_1(object sender, E
23、ventArgs e) dc hy = new dc(); int i = 0; while (this.f5.f1.fenei != null & i = this.f5.f1.fene.Length) hy.hydiancai(this.f5.f1.caidanhaoi, Convert.ToInt32(this.f5.f1.fenei), this.textBox1.Text); i+; int f = (int)(f5.f1.zj * 0.8); hy.gengxinhuiyuan(b, f); MessageBox.Show(打八折后,您消费金额总计为: + f + 元!n + 欢迎
24、下次光临!); this.Close(); private void textBox1_TextChanged(object sender, EventArgs e) 菜单代码:using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Linq;using System.Text;using System.Windows.Forms;using System.Data.SqlClient;namespa
25、ce WindowsFormsApplication1 public partial class Form9 : Form public string cdh; public int zj = 0; public int number = 0; public string ccc = new string20; public string caidanhao = new string20; public string fene = new string20; public Form9() InitializeComponent(); private void button2_Click(obj
26、ect sender, EventArgs e) / private void button1_Click(object sender, EventArgs e) int i = 0; dc cc = new dc(); int a; if (this.textBox1.Text != ) ccci = this.label2.Text + + this.label18.Text + + this.textBox1.Text; caidanhaoi = this.label2.Text; fenei = this.textBox1.Text; i+; number+; zj = zj + 5
27、* int.Parse(this.textBox1.Text.ToString(); a = int.Parse(this.textBox1.Text); /cc.pudiancai(this.label2.Text, a); if (this.textBox2.Text != ) ccci = this.label3.Text + + this.label19.Text + + this.textBox2.Text; caidanhaoi = this.label3.Text; fenei = this.textBox2.Text; i+; number+; zj = zj + 10 * i
28、nt.Parse(this.textBox2.Text.ToString(); a = int.Parse(this.textBox2.Text); /cc.diancai(this.label3.Text, a); if (this.textBox3.Text != ) ccci = this.label4.Text + + this.label20.Text + + this.textBox3.Text; caidanhaoi = this.label4.Text; fenei = this.textBox3.Text; i+; number+; zj = zj + 7 * int.Par
29、se(this.textBox3.Text.ToString(); a = int.Parse(this.textBox3.Text); / cc.diancai(this.label4.Text, a); if (this.textBox4.Text != ) ccci = this.label5.Text + + this.label21.Text + + this.textBox4.Text; caidanhaoi = this.label5.Text; fenei = this.textBox4.Text; i+; number+; zj = zj + 10 * int.Parse(t
30、his.textBox4.Text.ToString(); a = int.Parse(this.textBox4.Text); / cc.diancai(this.label5.Text, a); if (this.textBox5.Text != ) ccci = this.label6.Text + + this.label22.Text + + this.textBox5.Text; caidanhaoi = this.label6.Text; fenei = this.textBox5.Text; i+; number+; zj = zj + 10 * int.Parse(this.
31、textBox5.Text.ToString(); a = int.Parse(this.textBox5.Text); /cc.diancai(this.label6.Text, a); if (this.textBox6.Text != ) ccci = this.label7.Text + + this.label23.Text + + this.textBox6.Text; caidanhaoi = this.label7.Text; fenei = this.textBox6.Text; i+; number+; zj = zj + 15 * int.Parse(this.textB
32、ox6.Text.ToString(); a = int.Parse(this.textBox6.Text); /cc.diancai(this.label7.Text, a); if (this.textBox7.Text != ) ccci = this.label8.Text + + this.label24.Text + + this.textBox7.Text; caidanhaoi = this.label8.Text; fenei = this.textBox7.Text; i+; number+; zj = zj + 7 * int.Parse(this.textBox7.Te
33、xt.ToString(); a = int.Parse(this.textBox7.Text); / cc.diancai(this.label8.Text, a); if (this.textBox8.Text != ) ccci = this.label9.Text + + this.label25.Text + + this.textBox8.Text; caidanhaoi = this.label9.Text; fenei = this.textBox8.Text; i+; number+; zj = zj + 20 * int.Parse(this.textBox8.Text.ToString