这个是C#大作业,写作业很用心,写了很久,所以留存一下。不是现在的是之前的的期末作业,现在才想着整理一下
实现功能:
1、商家登录;客户的登录、注册。
2、商家界面实现了对菜单的增、删、改、查;还有订单的查看、查询、结账(删除订单)、查看已结账订单、关闭;退出系统。
3、用户界面实现了菜单的查看,查询,新建订单,选择餐桌,保存订单,增加菜品,退出。
C#语言实现在线点餐系统,具体功能如下图
登录界面
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(); } } }
注册界面
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) { } } }