C # implementation of online ordering system

Time:2021-6-12

This is the C # big homework. I’ve been working hard for a long time, so I’ll keep it. It’s not now. It’s the final assignment before. I just want to sort it out now

Implementation function:

1. Business login; Customer login and registration.
2. The business interface can add, delete, modify and check the menu; There are also order viewing, querying, closing (order deletion), viewing closed orders and closing; Exit the system.
3. The user interface realizes the menu view, query, new order, select table, save order, add dishes, exit.

C # language realizes the online ordering system, and the specific functions are shown in the figure below

Login interface

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 = account cannot be empty;
 textBox1.Focus();
 return;
 }
 else
 if (textBox2.Text.Trim() == "")
 {
 Label3. Text = password cannot be empty;
 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))
 {
 Message box. Show ("user name error!");
 return;
 }
 else
 if (ds.Tables[0].Rows[0][2].ToString().Trim() != textBox2.Text.Trim())
 {message box. Show ("password error");}
 else
 {
 Message box. Show ("login succeeded!");
 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")
 {
 Message box. Show ("login successful");
 sjfm fm = new sjfm();
 fm.Show();
 // this.Hide();
 }
 Else {message box. Show ("wrong account or password! Please re-enter! "); return; }
 }

 }
 private void label3_Click(object sender, EventArgs e)
 {
 zcfm fm = new zcfm();
 fm.Show();
 this.Hide();
 }
 }
}

Registration interface

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)
 {
 Message box. Show ("mobile phone number error, please fill in the specification");
 }
 else
 if (textBox2.Text.Trim() == "")
 {
 Message box. Show ("user name error, please fill in 4-8 digits in the specification");
 }
 else
 if (textBox3.Text.Trim() == "" || textBox3.Text.Length < 6 || textBox3.Text.Length > 8)
 {
 Message box. Show ("wrong password, please fill in 6-8 digits!");
 }
 else
 if (textBox4.Text.Trim() == "")
 {
 Message box. Show ("wrong password, please fill in 6-8 digits!");
 }
 else
 if (textBox3.Text.Trim() != textBox4.Text.Trim())
 {
 Message box. Show ("two input passwords must be consistent!");
 }
 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);
  Message box. Show ("registration successful!"“ "Success prompt!", MessageBoxButtons.OK, MessageBoxIcon.Information);
 }
 catch (Exception ee){ MessageBox.Show(ee.Message); }
 }
 }

 private void zcfm_Load(object sender, EventArgs e)
 {

 }
 }
}

Business interface:


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

Menu management

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;// Control status flag
 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;// Display dish information
 this.SetdataGridView1HeadText();
 }
 private void SetdataGridView1HeadText()
 {
 Datagridview1. Columns [0]. Headertext = dish number;
 Datagridview1. Columns [1]. Headertext = dish name;
 Datagridview1. Columns [2]. Headertext = dish specification;
 Datagridview1. Columns [3]. Headertext = dish type;
 Datagridview1. Columns [4]. Headertext = price of dishes;
 }
 private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e)
 {
 Textboxnum.Text = this.dataGridView1[0, dataGridView1.CurrentCell.RowIndex].Value.ToString();// Display dish number
 TextboxName.Text = this.dataGridView1[1, dataGridView1.CurrentCell.RowIndex].Value.ToString();// Displays the full name of the dish
 Textboxgg.Text = this.dataGridView1[2, dataGridView1.CurrentCell.RowIndex].Value.ToString();// Display dish specifications
 Textboxlx.Text = this.dataGridView1[3, dataGridView1.CurrentCell.RowIndex].Value.ToString();// Display dish type
 Textboxdj.Text = this.dataGridView1[4, dataGridView1.CurrentCell.RowIndex].Value.ToString();// Display the unit price of dishes
 }

 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)
 {
 Message box. Show ("delete -- dish data -- failed!"“ Error prompt! ", MessageBoxButtons.OK, MessageBoxIcon.Error);
 return;
 }

 stockinfo.Menu_num = Textboxnum.Text.Trim();
 int id = baseinfo.Deletemenu(stockinfo);
 Message box. Show ("delete - stock goods data - success!"“ "Success prompt!", MessageBoxButtons.OK, MessageBoxIcon.Information);
 dataGridView1.DataSource = baseinfo.GetAllmenu("db_menu").Tables[0].DefaultView;
 this.SetdataGridView1HeadText();
 this.clearText();// Clear text box
 }

 private void BtnSave_Click(object sender, EventArgs e)
 {
 if (kj_bz == 0)
 {
 try
 {
  //Add data
  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());
  //Perform the add operation
  int id = baseinfo.Addmenu(stockinfo);
  Message box. Show ("add - inventory item data - success!"“ "Success prompt!", MessageBoxButtons.OK, MessageBoxIcon.Information);
 }
 catch (Exception ex)
 {
  Message box. Show (ex. message, "error prompt", message boxbuttons. OK, message boxicon. Error);
 }
 }
 else
 {
 //Modify data
 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());
 //Perform modification
 int id = baseinfo.Updatemenu(stockinfo);
 Message box. Show ("modify -- inventory data -- success!"“ "Success prompt!", MessageBoxButtons.OK, MessageBoxIcon.Information);
 }
 dataGridView1.DataSource = baseinfo.GetAllmenu("db_menu").Tables[0].DefaultView;
 this.SetdataGridView1HeadText();
 this.cancelEnabled();// Set the available state of each button
 }

 private void BtnFind_Click(object sender, EventArgs e)
 {
 if (tlCmbStockType.Text == string.Empty)
 {
 Message box. Show ("query category cannot be empty!"“ Error prompt! ", MessageBoxButtons.OK, MessageBoxIcon.Error);
 tlCmbStockType.Focus();
 return;
 }
 else
 If (tlcmbstocktype. Text. Trim() = = all)
 {
 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;
 }

 
 }
}

Order management

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;// Display order information
 this.SetdataGridView1HeadText();
 }
 private void SetdataGridView1HeadText()
 {
 Datagridview1. Columns [0]. Headertext = table number;
 Datagridview1. Columns [1]. Headertext = customer's mobile number;
 Datagridview1. Columns [2]. Headertext = order details;
 Datagridview1. Columns [3]. Headertext = total order price;
 Datagridview1. Columns [4]. Headertext = order time;
 }

 private void toolStripButton1_Click(object sender, EventArgs e)
 {
 if (ComboBoxzh.Text == string.Empty)
 {
 Message box. Show ("query category cannot be empty!"“ Error prompt! ", MessageBoxButtons.OK, MessageBoxIcon.Error);
 ComboBoxzh.Focus();
 return;
 }
 else
 If (comboboxzh. Text. Trim() = = all)
 {
 dataGridView1.DataSource = baseinfo.GetAlldd("db_dd").Tables[0].DefaultView;
 return;
 }
 If (comboboxzh. Text. Trim() = = closed order)
 {
 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 = "the total price of this consumption is" + 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);
 Message box. Show ("checkout complete!");
 dataGridView1.DataSource = baseinfo.GetAlldd("db_dd").Tables[0].DefaultView;
 this.SetdataGridView1HeadText();
 }
 else
 {
 Message box. Show ("please select the correct table number!");
 return ;
 }
 }
 }
}

user interface

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;// Total consumption price
 public string yhsj = "";// User mobile number
 public int qxzt = 0;// Status when clicking cancel
 public gkfm()
 {
 InitializeComponent();
 }

 private void gkfm_Load(object sender, EventArgs e)
 {
 dataGridView1.DataSource =baseinfo.GetAllmenu("db_ menu").Tables[0].DefaultView;// Display dish information
 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() // close all controls
 {
 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 = dish number;
 Datagridview1. Columns [1]. Headertext = dish name;
 Datagridview1. Columns [2]. Headertext = dish specification;
 Datagridview1. Columns [3]. Headertext = dish type;
 Datagridview1. Columns [4]. Headertext = price of dishes;
 }

 
 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() + "Hello customer, welcome to Xiaoshuai Hotel"//** sir
 }

 private void BtnFind_Click(object sender, EventArgs e)
 {
 if (toolStripComboBox1.Text == string.Empty)
 {
 Message box. Show ("query category cannot be empty!"“ Error prompt! ", MessageBoxButtons.OK, MessageBoxIcon.Error);
 toolStripComboBox1.Focus();
 return;
 }
 else
 If (toolstripcombox1. Text. Trim() = = all)
 {
 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)
 {
 Message box. Show ("please select table number!");
 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();// Displays the full name of the dish
 textBoxlx.Text = this.dataGridView1[3, dataGridView1.CurrentCell.RowIndex].Value.ToString();// Display dish type
 textBoxdj.Text = this.dataGridView1[4, dataGridView1.CurrentCell.RowIndex].Value.ToString();// Display the price of dishes
 }

 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 = = = =) {message box. Show ("table number cannot be empty! Please select table number! "); 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);
  Message box. Show ("new order successfully!"“ "Success prompt!", MessageBoxButtons.OK, MessageBoxIcon.Information);
 }
 catch (Exception ex)
 {
  Message box. Show (ex. message, "error prompt", message boxbuttons. OK, message boxicon. 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);
 Message box. Show ("dishes added successfully!");

 }
 ////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 {message box. Show ("wrong table number! Please reselect '); comboBox1.Text = "";  return; }
 }
 }
}

There are also two class files that can be viewed in the project.
Part of the code reference we learn the source code on the textbook, the code is just a big level, only for reference.

For more learning materials, please pay attention to the topic management system development.

The above is the whole content of this article, I hope to help you learn, and I hope you can support developer more.