当前位置:
首页 > Python基础教程 >
-
C#实现在线点餐系统
这个是C#大作业,写作业很用心,写了很久,所以留存一下。不是现在的是之前的的期末作业,现在才想着整理一下
实现功能:
1、商家登录;客户的登录、注册。
2、商家界面实现了对菜单的增、删、改、查;还有订单的查看、查询、结账(删除订单)、查看已结账订单、关闭;退出系统。
3、用户界面实现了菜单的查看,查询,新建订单,选择餐桌,保存订单,增加菜品,退出。
C#语言实现在线点餐系统,具体功能如下图
登录界面
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
|
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Data.SqlClient; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; namespace MenuSystemWss { public partial class Form1 : Form { int dlsf=0; /* SqlConnection sqlcon; SqlCommand sqlcom; SqlDataReader sqlsdr;*/ BaseInfo baseinfo = new BaseInfo(); // BaseInfo.GkInfo gkinfo = new BaseInfo.GkInfo(); // public Form1() { InitializeComponent(); } public void dengluzt() { DataSet ds = null ; gkinfo.Gk_num = textBox1.Text.Trim(); ds = baseinfo.DengLu(gkinfo, "db_menu" ); gkinfo.Gk_zt = 1; gkinfo.Gk_apw = gkinfo.Gk_pw; gkinfo.Gk_name = ds.Tables[0].Rows[0][1].ToString().Trim(); baseinfo.Updatgk( this .gkinfo); } private void button1_Click( object sender, EventArgs e) { if (radioButton1.Checked) dlsf = 1; if (radioButton2.Checked) dlsf = 2; if (textBox1.Text.Trim() == "" ) { label3.Text = "账号不能为空" ; textBox1.Focus(); return ; } else if (textBox2.Text.Trim() == "" ) { label3.Text = "密码不能为空" ; textBox1.Focus(); return ; } else if (dlsf == 2) { try { DataSet ds = null ; gkinfo.Gk_num = textBox1.Text.Trim(); gkinfo.Gk_pw = textBox2.Text.Trim(); ds = baseinfo.DengLu(gkinfo, "db_menu" ); if (ds== null ||ds.Tables.Count == 0||(ds.Tables.Count == 1 && ds.Tables[0].Rows.Count == 0)) { MessageBox.Show( "用户名错误!" ); return ; } else if (ds.Tables[0].Rows[0][2].ToString().Trim() != textBox2.Text.Trim()) { MessageBox.Show( "密码错误" ); } else { MessageBox.Show( "登陆成功!" ); dengluzt(); gkfm fm = new gkfm(); fm.add (Convert.ToString(textBox1.Text)); fm.Show(); //this.Hide(); } } catch (Exception ee) { MessageBox.Show(ee.Message); } } else if (dlsf == 1) { if (textBox1.Text.Trim() == "1" && textBox2.Text.Trim() == "1" ) { MessageBox.Show( "登录成功" ); sjfm fm = new sjfm(); fm.Show(); // this.Hide(); } else { MessageBox.Show( "账号或密码错误!请重新输入!" ); return ; } } } private void label3_Click( object sender, EventArgs e) { zcfm fm = new zcfm(); fm.Show(); this .Hide(); } } } |
注册界面
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
|
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Data.SqlClient; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; namespace MenuSystemWss { public partial class zcfm : Form { BaseInfo baseinfo = new BaseInfo(); // BaseInfo.GkInfo gkinfo = new BaseInfo.GkInfo(); // /* SqlConnection sqlcon; SqlCommand sqlcom;*/ public zcfm() { InitializeComponent(); } private void label6_Click( object sender, EventArgs e) { Form1 fm = new Form1(); fm.Show(); this .Hide(); } private void button1_Click( object sender, EventArgs e) { if (textBox1.Text.Trim() == "" || textBox1.Text.Length != 11) { MessageBox.Show( "手机号错误,请规范填写" ); } else if (textBox2.Text.Trim() == "" ) { MessageBox.Show( "用户名错误,请规范填写4-8位" ); } else if (textBox3.Text.Trim() == "" || textBox3.Text.Length < 6 || textBox3.Text.Length > 8) { MessageBox.Show( "密码错误,请规范填写6-8位!" ); } else if (textBox4.Text.Trim() == "" ) { MessageBox.Show( "密码错误,请规范填写6-8位!" ); } else if (textBox3.Text.Trim() != textBox4.Text.Trim()) { MessageBox.Show( "两次输入密码必须一致!" ); } else { try { gkinfo.Gk_num = textBox1.Text.Trim(); gkinfo.Gk_name = textBox2.Text.Trim(); gkinfo.Gk_pw = textBox3.Text.Trim(); gkinfo.Gk_apw = textBox4.Text.Trim(); gkinfo.Gk_zt = 0; int id = baseinfo.AddGk(gkinfo); MessageBox.Show( "注册成功!" , "成功提示!" , MessageBoxButtons.OK, MessageBoxIcon.Information); } catch (Exception ee){ MessageBox.Show(ee.Message); } } } private void zcfm_Load( object sender, EventArgs e) { } } } |
商家界面:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; namespace MenuSystemWss { public partial class sjfm : Form { public sjfm() { InitializeComponent(); } private void button1_Click( object sender, EventArgs e) { MenuShop fm = new MenuShop(); fm.Show(); } private void button3_Click( object sender, EventArgs e) { Application.Exit(); } private void button2_Click( object sender, EventArgs e) { glfm fm = new glfm(); fm.Show(); } } } |
菜单管理
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
|
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; namespace MenuSystemWss { public partial class MenuShop : Form { BaseInfo baseinfo = new BaseInfo(); BaseInfo.MenuInfo stockinfo = new BaseInfo.MenuInfo(); int kj_bz = 0; //控件状态标志 public MenuShop() { InitializeComponent(); } private void clearText() { Textboxnum.Text = string .Empty; TextboxName.Text = string .Empty; Textboxgg.Text = string .Empty; Textboxlx.Text = string .Empty; Textboxdj.Text = string .Empty; } private void cancelEnabled() { groupBox1.Enabled = false ; tlBtnAdd.Enabled = true ; BtnEdit.Enabled = true ; BtnDelete.Enabled = true ; BtnSave.Enabled = false ; BtnCancel.Enabled = false ; } private void LoadEnabled() { groupBox1.Enabled = false ; tlBtnAdd.Enabled = true ; BtnEdit.Enabled = true ; BtnDelete.Enabled = true ; BtnSave.Enabled = false ; BtnCancel.Enabled = false ; } private void editEnabled() { groupBox1.Enabled = true ; tlBtnAdd.Enabled = false ; BtnEdit.Enabled = false ; BtnDelete.Enabled = false ; BtnSave.Enabled = true ; BtnCancel.Enabled = true ; } private void AddEnabled() { Textboxdj.Text = "" ; Textboxgg.Text = "" ; Textboxnum.Text = "" ; TextboxName.Text = "" ; Textboxlx.Text = "" ; groupBox1.Enabled = true ; tlBtnAdd.Enabled = false ; BtnEdit.Enabled = false ; BtnDelete.Enabled = false ; BtnSave.Enabled = true ; BtnCancel.Enabled = true ; } private void MenuShop_Load( object sender, EventArgs e) { this .LoadEnabled(); dataGridView1.DataSource = baseinfo.GetAllmenu( "db_menu" ).Tables[0].DefaultView; //展示菜品信息 this .SetdataGridView1HeadText(); } private void SetdataGridView1HeadText() { dataGridView1.Columns[0].HeaderText = "菜品编号" ; dataGridView1.Columns[1].HeaderText = "菜品名称" ; dataGridView1.Columns[2].HeaderText = "菜品规格" ; dataGridView1.Columns[3].HeaderText = "菜品类型" ; dataGridView1.Columns[4].HeaderText = "菜品价格" ; } private void dataGridView1_CellClick( object sender, DataGridViewCellEventArgs e) { Textboxnum.Text = this .dataGridView1[0, dataGridView1.CurrentCell.RowIndex].Value.ToString(); //显示菜品编号 TextboxName.Text = this .dataGridView1[1, dataGridView1.CurrentCell.RowIndex].Value.ToString(); //显示菜品全称 Textboxgg.Text = this .dataGridView1[2, dataGridView1.CurrentCell.RowIndex].Value.ToString(); //显示菜品规格 Textboxlx.Text = this .dataGridView1[3, dataGridView1.CurrentCell.RowIndex].Value.ToString(); //显示菜品类型 Textboxdj.Text = this .dataGridView1[4, dataGridView1.CurrentCell.RowIndex].Value.ToString(); //显示菜品单价 } public void labletime() { labelsj.Text = System.DateTime.Now.ToString(); } private void timer1_Tick( object sender, EventArgs e) { labletime(); } private void tlBtnExit_Click( object sender, EventArgs e) { this .Close(); //Application.Exit(); } private void BtnDelete_Click( object sender, EventArgs e) { if (Textboxnum.Text.Trim() == string .Empty) { MessageBox.Show( "删除--菜品数据--失败!" , "错误提示!" , MessageBoxButtons.OK, MessageBoxIcon.Error); return ; } stockinfo.Menu_num = Textboxnum.Text.Trim(); int id = baseinfo.Deletemenu(stockinfo); MessageBox.Show( "删除--库存商品数据--成功!" , "成功提示!" , MessageBoxButtons.OK, MessageBoxIcon.Information); dataGridView1.DataSource = baseinfo.GetAllmenu( "db_menu" ).Tables[0].DefaultView; this .SetdataGridView1HeadText(); this .clearText(); //清空文本框 } private void BtnSave_Click( object sender, EventArgs e) { if (kj_bz == 0) { try { //添加数据 stockinfo.Menu_num =Textboxnum.Text; stockinfo.Menu_name = TextboxName.Text; stockinfo.Menu_gg = Textboxgg.Text; stockinfo.Menu_lx= Textboxlx.Text; stockinfo.Menu_dj = float .Parse( Textboxdj.Text.Trim()); //执行添加操作 int id = baseinfo.Addmenu(stockinfo); MessageBox.Show( "新增--库存商品数据--成功!" , "成功提示!" , MessageBoxButtons.OK, MessageBoxIcon.Information); } catch (Exception ex) { MessageBox.Show(ex.Message, "错误提示" , MessageBoxButtons.OK, MessageBoxIcon.Error); } } else { //修改数据 stockinfo.Menu_num = Textboxnum.Text; stockinfo.Menu_name = TextboxName.Text; stockinfo.Menu_gg = Textboxgg.Text; stockinfo.Menu_lx = Textboxlx.Text; stockinfo.Menu_dj = float .Parse(Textboxdj.Text.Trim()); //执行修改操作 int id = baseinfo.Updatemenu(stockinfo); MessageBox.Show( "修改--库存商品数据--成功!" , "成功提示!" , MessageBoxButtons.OK, MessageBoxIcon.Information); } dataGridView1.DataSource = baseinfo.GetAllmenu( "db_menu" ).Tables[0].DefaultView; this .SetdataGridView1HeadText(); this .cancelEnabled(); //设置各个按钮的可用状态 } private void BtnFind_Click( object sender, EventArgs e) { if (tlCmbStockType.Text == string .Empty) { MessageBox.Show( "查询类别不能为空!" , "错误提示!" , MessageBoxButtons.OK, MessageBoxIcon.Error); tlCmbStockType.Focus(); return ; } else if (tlCmbStockType.Text.Trim() == "全部" ) { dataGridView1.DataSource = baseinfo.GetAllmenu( "db_menu" ).Tables[0].DefaultView; this .SetdataGridView1HeadText(); return ; } else { DataSet ds = null ; stockinfo.Menu_lx = tlCmbStockType.Text; ds = baseinfo.FindmenuBylx(stockinfo, "db_menu" ); dataGridView1.DataSource = ds.Tables[0].DefaultView; this .SetdataGridView1HeadText(); } } private void BtnCancel_Click( object sender, EventArgs e) { this .cancelEnabled(); } private void BtnEdit_Click( object sender, EventArgs e) { kj_bz = 1; this .editEnabled(); } private void tlBtnAdd_Click( object sender, EventArgs e) { this .AddEnabled(); kj_bz = 0; } } } |
栏目列表
最新更新
nodejs爬虫
Python正则表达式完全指南
爬取豆瓣Top250图书数据
shp 地图文件批量添加字段
爬虫小试牛刀(爬取学校通知公告)
【python基础】函数-初识函数
【python基础】函数-返回值
HTTP请求:requests模块基础使用必知必会
Python初学者友好丨详解参数传递类型
如何有效管理爬虫流量?
SQL SERVER中递归
2个场景实例讲解GaussDB(DWS)基表统计信息估
常用的 SQL Server 关键字及其含义
动手分析SQL Server中的事务中使用的锁
openGauss内核分析:SQL by pass & 经典执行
一招教你如何高效批量导入与更新数据
天天写SQL,这些神奇的特性你知道吗?
openGauss内核分析:执行计划生成
[IM002]Navicat ODBC驱动器管理器 未发现数据
初入Sql Server 之 存储过程的简单使用
这是目前我见过最好的跨域解决方案!
减少回流与重绘
减少回流与重绘
如何使用KrpanoToolJS在浏览器切图
performance.now() 与 Date.now() 对比
一款纯 JS 实现的轻量化图片编辑器
关于开发 VS Code 插件遇到的 workbench.scm.
前端设计模式——观察者模式
前端设计模式——中介者模式
创建型-原型模式