C#实现在线点餐系统

这个是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)
 {

 }
 }
}

商家界面:

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();
 }
 }
}

菜单管理

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;
 }

 }
}

订单管理

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 glfm : Form
 {
 BaseInfo baseinfo = new BaseInfo();
 BaseInfo.Ddinfo dd = new BaseInfo.Ddinfo();
 public glfm()
 {
 InitializeComponent();
 }

 private void glfm_Load(object sender, EventArgs e)
 {
 textBoxddxq.Enabled = false;
 dataGridView1.DataSource = baseinfo.GetAlldd("db_dd").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 toolStripButton1_Click(object sender, EventArgs e)
 {
 if (ComboBoxzh.Text == string.Empty)
 {
 MessageBox.Show("查询类别不能为空!", "错误提示!", MessageBoxButtons.OK, MessageBoxIcon.Error);
 ComboBoxzh.Focus();
 return;
 }
 else
 if (ComboBoxzh.Text.Trim() == "全部")
 {
 dataGridView1.DataSource = baseinfo.GetAlldd("db_dd").Tables[0].DefaultView;
 return;
 }
 if (ComboBoxzh.Text.Trim() == "已结账订单")
 {
 dataGridView1.DataSource = baseinfo.GetAllsydd("db_sydd").Tables[0].DefaultView;
 //labelxfzj.Text = baseinfo.GetAllddsy("dd_sydd").ToString();
 return;
 }
 else
 {
 DataSet ds = null;
 dd.Dd_num = int.Parse(ComboBoxzh.Text);
 ds = baseinfo.FindddByzh(dd, "db_dd");
 dataGridView1.DataSource = ds.Tables[0].DefaultView;
 this.SetdataGridView1HeadText();
 if (ds == null || ds.Tables.Count == 0 || (ds.Tables.Count == 1 && ds.Tables[0].Rows.Count == 0))
 {
  textBoxddxq.Text = "";
 }
 else
 {
  textBoxddxq.Text = ds.Tables[0].Rows[0][2].ToString().Trim();
 }
 }
 }
 public void yjdd()
 {
 dataGridView1.DataSource = baseinfo.GetAlldd("db_sydd").Tables[0].DefaultView;
 SetdataGridView1HeadText();
 }

 private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e)
 {
 ComboBoxzh.Text = this.dataGridView1[0, dataGridView1.CurrentCell.RowIndex].Value.ToString();
 textBoxddxq.Text = this.dataGridView1[2, dataGridView1.CurrentCell.RowIndex].Value.ToString();
 labelxfzj.Text = "本次消费总价为:" + this.dataGridView1[3, dataGridView1.CurrentCell.RowIndex].Value.ToString();
 }

 private void ExitBtn_Click(object sender, EventArgs e)
 {
 this.Close();
 }

 private void toolStripButton2_Click(object sender, EventArgs e)
 {
 if (ComboBoxzh.Text.Trim() != "")
 {
 dd.Dd_num = int.Parse(ComboBoxzh.Text.Trim());
 dd.Zd_num = this.dataGridView1[1, dataGridView1.CurrentCell.RowIndex].Value.ToString();
 dd.Dd_name = this.dataGridView1[2, dataGridView1.CurrentCell.RowIndex].Value.ToString();
 dd.Dd_zj= float.Parse(this.dataGridView1[3, dataGridView1.CurrentCell.RowIndex].Value.ToString());
 dd.Dd_time = this.dataGridView1[4, dataGridView1.CurrentCell.RowIndex].Value.ToString();
 baseinfo.bcdd(dd);
 baseinfo.Deletedd(dd);
 MessageBox.Show("结账完成!");
 dataGridView1.DataSource = baseinfo.GetAlldd("db_dd").Tables[0].DefaultView;
 this.SetdataGridView1HeadText();
 }
 else
 {
 MessageBox.Show("请选择正确的桌号!");
 return ;
 }
 }
 }
}

用户界面

using MenuSystemWss;
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 gkfm : Form
 {
 BaseInfo baseinfo = new BaseInfo();
 BaseInfo.GkInfo gkinfo = new BaseInfo.GkInfo();
 BaseInfo.MenuInfo menu = new BaseInfo.MenuInfo();
 BaseInfo.Ddinfo ddinfo = new BaseInfo.Ddinfo();
 public double xfzj = 0;//消费总价
 public string yhsj = "";//用户手机号
 public int qxzt = 0;//点击取消时的状态
 public gkfm()
 {
 InitializeComponent();
 }

 private void gkfm_Load(object sender, EventArgs e)
 {
 dataGridView1.DataSource =baseinfo.GetAllmenu("db_menu").Tables[0].DefaultView;//展示菜品信息
 dataGridView1.ReadOnly = true;
 this.SetdataGridView1HeadText();
 load_Enable();
 }

 public void load_Enable()
 {
 cancelAll_Enable();
 DataSet ds = null;
 ddinfo.Zd_num = yhsj;
 ds = baseinfo.FindddByzcnum(ddinfo, "db_dd");
 if (ds == null || ds.Tables.Count == 0 || (ds.Tables.Count == 1 && ds.Tables[0].Rows.Count == 0))
 {
 comboBox1.Enabled = true;
 tlBtnAdd.Enabled = true;
 }
 else {
 jcBtn.Enabled = true;
 comboBox1.Text= ds.Tables[0].Rows[0][0].ToString().Trim();
 textBoxxq.Text = ds.Tables[0].Rows[0][2].ToString().Trim();
 textBoxzj.Text = ds.Tables[0].Rows[0][3].ToString().Trim();
 }
 if (textBoxzj.Text.Trim() != "")
 {
 xfzj = Convert.ToDouble(textBoxzj.Text.Trim());
 }
 else
 {
 xfzj = 0;
 }
 if (textBoxxq.Text != "") qxzt = 1;
 }

 public void cancelAll_Enable()//关闭所有的控件
 {
 tlBtnAdd.Enabled = false;
 BtnSave.Enabled = false;
 BtnCancel.Enabled = false;
 jcBtn.Enabled = false;
 comboBox1.Enabled = false;
 textBoxlx.Enabled = false;
 textBoxdj.Enabled = false;
 textBoxname.Enabled = false;
 button1.Enabled = false;
 textBoxzj.Enabled = false;
 textBoxxq.Enabled = false;
 }

 public void jc_Enable()
 {
 BtnCancel.Enabled = true;
 BtnSave.Enabled = true;
 button1.Enabled = true;
 }

 public void add_Enable()
 {
 tlBtnAdd.Enabled = false;
 BtnSave.Enabled = true;
 BtnCancel.Enabled = true;
 button1.Enabled = true;

 }

 public void cancel_Enable()
 {
 if (qxzt == 0)
 {
 cancelAll_Enable();
 tlBtnAdd.Enabled = true;
 comboBox1.Enabled = true;
 xfzj = 0;
 textBoxxq.Text = "";
 }
 else
 {
 BtnSave.Enabled = false;
 BtnCancel.Enabled = false;
 }
 }

 public void labletime()
 {
 labelTime.Text = System.DateTime.Now.ToString();
 }
 private void timer1_Tick(object sender, EventArgs e)
 {
 labletime();
 }
 private void SetdataGridView1HeadText()
 {
 dataGridView1.Columns[0].HeaderText = "菜品编号";
 dataGridView1.Columns[1].HeaderText = "菜品名称";
 dataGridView1.Columns[2].HeaderText = "菜品规格";
 dataGridView1.Columns[3].HeaderText = "菜品类型";
 dataGridView1.Columns[4].HeaderText = "菜品价格";
 }

 public void add(string strgk)
 {
 DataSet ds = null;
 yhsj = strgk;
 gkinfo.Gk_num = strgk;
 ds = baseinfo.DengLu1(gkinfo, "db_menu");
 label1.Text = ds.Tables[0].Rows[0][1].ToString().Trim() + "顾客您好 欢迎光临小帅饭店"; //**先生
 }

 private void BtnFind_Click(object sender, EventArgs e)
 {
 if (toolStripComboBox1.Text == string.Empty)
 {
 MessageBox.Show("查询类别不能为空!", "错误提示!", MessageBoxButtons.OK, MessageBoxIcon.Error);
 toolStripComboBox1.Focus();
 return;
 }
 else
 if (toolStripComboBox1.Text.Trim() == "全部")
 {
 dataGridView1.DataSource = baseinfo.GetAllmenu("db_menu").Tables[0].DefaultView;
 this.SetdataGridView1HeadText();
 return;
 }
 else
 {
 DataSet ds = null;
 menu.Menu_lx = toolStripComboBox1.Text;
 ds = baseinfo.FindmenuBylx(menu, "db_menu");
 dataGridView1.DataSource = ds.Tables[0].DefaultView;
 this.SetdataGridView1HeadText();
 }
 }

 private void toolStrip1_ItemClicked(object sender, ToolStripItemClickedEventArgs e)
 {

 }

 private void tlBtnAdd_Click(object sender, EventArgs e)
 {
 MessageBox.Show("请选择桌号!");
 add_Enable();
 }

 private void BtnCancel_Click(object sender, EventArgs e)
 {
 cancel_Enable();
 }

 private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e)
 {
 textBoxname.Text = this.dataGridView1[1, 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();//显示菜品价格
 }

 private void tlBtnExit_Click(object sender, EventArgs e)
 {
 Application.Exit();
 }

 private void button1_Click(object sender, EventArgs e)
 {
 textBoxxq.Text += textBoxname.Text.Trim() + "*1; ";
 //listView1 .Items.Add(textBoxname.Text.Trim()+"*1;");
 xfzj += Convert.ToDouble(textBoxdj.Text.Trim());
 textBoxzj.Text = xfzj.ToString();
 }

 private void BtnSave_Click(object sender, EventArgs e)
 {
 if (comboBox1.Text == "") { MessageBox.Show("桌号不能为空!请选择桌号!");return; }
 string strlist=textBoxxq.Text.Trim() ;
 /* for (int i = 0; i < listView1.Items.Count; i++)
 {
  ListViewItem item = listView1.Items[i];
  for (int j = 0; j < item.SubItems.Count; j++)
  {
  strlist += item.SubItems[j].Text;
  }
 }*/
 if (qxzt == 0)
 {
 try
 {
  ddinfo.Dd_num = Convert.ToInt32(comboBox1.SelectedItem);
  ddinfo.Zd_num = yhsj;
  ddinfo.Dd_name = strlist;
  ddinfo.Dd_zj = float.Parse(textBoxzj.Text);
  ddinfo.Dd_time = System.DateTime.Now.ToString().Trim();
  int id = baseinfo.Adddd(ddinfo);
  MessageBox.Show("新增订单成功!", "成功提示!", MessageBoxButtons.OK, MessageBoxIcon.Information);
 }
 catch (Exception ex)
 {
  MessageBox.Show(ex.Message, "错误提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
 }
 }
 else
 {
 ddinfo.Dd_num = Convert.ToInt32(comboBox1.SelectedItem);
 ddinfo.Zd_num = yhsj;
 ddinfo.Dd_name = strlist;
 ddinfo.Dd_zj = float.Parse(textBoxzj.Text);
 int id = baseinfo.Updatedd(ddinfo);
 MessageBox.Show("菜品添加成功!");

 }
 ////listView1.Clear();
 qxzt = 1;
 cancelAll_Enable();
 jcBtn.Enabled = true;
 }

 private void jcBtn_Click(object sender, EventArgs e)
 {
 jc_Enable();
 }

 private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
 {

 DataSet ds = null;
 ddinfo.Dd_num = int.Parse(comboBox1.Text.Trim());
 ds = baseinfo.FindddByzh(ddinfo, "db_dd");
 if (ds == null || ds.Tables.Count == 0 || (ds.Tables.Count == 1 && ds.Tables[0].Rows.Count == 0))
 {
 comboBox1.Enabled = false;
 }
 // else { MessageBox.Show("桌号选择错误!请重新选择");comboBox1.Text = ""; return; }
 }
 }
}

还有两个类文件,可在项目中查看。
部分代码参考我们学的课本上的源代码,代码只是大作水平,仅供参考学习。

更多学习资料请关注专题《管理系统开发》。

以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持我们。

(0)

相关推荐

  • C#实现简单学生信息管理系统

    本文实例为大家分享了C#实现简单学生信息管理系统的具体代码,供大家参考,具体内容如下 一.运行环境windows,使用vs编译软件 二.主要功能 登录.添加学生信息.修改学生信息.删除学生信息.查询学生信息 三.实现步骤 1.登陆界面功能实现 老规矩,先贴下主要代码: //构造方法 public Login() { InitializeComponent(); this.label3.Parent = this; this.label1.BackColor = Color.Transparent

  • C#超市收银系统设计

    本文实例为大家分享了C#超市收银系统设计的具体代码,供大家参考,具体内容如下 1.登录界面 代码如下: 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.

  • C#实现餐厅管理系统

    本文实例为大家分享了C#实现餐厅管理系统的具体代码,供大家参考,具体内容如下 部分代码: fm_change_password.cs 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;

  • C#图书管理系统 附源码下载

    用来练手还是不错的,分享大家看一下,还是一些新颖点的   !哈哈 就是自定义DataGridView,方便每个功能部分调用!简单!再次重申!!!后面源码会送上! 首先看一下登录,上图吧! 只有超级管理员跟管理员 接下来看一下主界面 更改DataGridView数据列 datagridView自定义类 using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.

  • C#实现餐饮管理系统

    本文实例为大家分享了C#实现餐饮管理系统的具体代码,供大家参考,具体内容如下 此系统采用C#语言的Winfrom和ADO.NET技术搭建的简单的CS系统. 部分代码: frmBook.cs using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text;

  • 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.Thread

  • c#实现KTV点歌系统

    下面通过图文并茂的方式给大家分享C#实现KTV点歌系统. public enum SongPlayState { //未播放,播放,重播,切歌 unplayed, played, again, cut } public class Song { public string SongName { get; set; }//歌曲名称 public string SongURL { get; set; }//歌曲路径 public SongPlayState playState = SongPlayS

  • C#实现影院售票系统

    本文实例为大家分享了C#实现影院售票系统的具体代码,供大家参考,具体内容如下 本人认为此项目的难点有4点 1.首先是将解析完的XML文件绑定到TreeView上 2.用代码动态生成座位的label,生成触发事件Label_Click,俩组放映时间的售出座位是不同的 3.用序列化与反序列化实现代码的多次利用 4.打印票务 创建与本项目相关的10个类 一.首先在放映计划类中创建LoadItems()方法来解析ShowList.xml文件 XmlDocument dic=new XmlDocument

  • C#实现汽车租赁系统项目

    本文实例为大家分享了C#实现汽车租赁系统的具体代码,供大家参考,具体内容如下 汽车和卡车的父类 using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; //父类变量和方法 namespace 汽车租赁系统 { public class Inheritance { public Inheritance() { } publi

  • C#实现餐饮管理系统完整版

    完整版的C#餐饮管理系统,供大家一起共同分享学习. 部分代码: Dataoperator.cs using System; using System.Data; using System.Configuration; using System.Linq; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.HtmlControls; using System.Web.UI.We

随机推荐