廢話不多說直接開始
我們點選菜單按鈕會連結到這個表單
全域變數
string MyConnection2 = "datasource=122.0.0.0;port=3366;username=root;password=;Allow Zero Datetime=True;";
private string dbHost = "localhost";
private string dbPort = "3306";
private string dbUser = "root";
private string dbPassword = "";
private string dbName = "db85cc";
MySqlConnection conn = null;
MySqlDataAdapter mySqlDataAdapter;
DataSet ds;
按鈕按照菜單內商品去做分類
麵包按鈕:
try
{
string Query = "select product.Product_name,product.Product_price from db85cc.product where product.prodict_id='bread'";
MySqlConnection MyConn2 = new MySqlConnection(MyConnection2);
MySqlCommand MyCommand2 = new MySqlCommand(Query, MyConn2);
MySqlDataAdapter MyAdapter = new MySqlDataAdapter();
MyAdapter.SelectCommand = MyCommand2;
DataTable dTable = new DataTable();
MyAdapter.Fill(dTable);
dgvmenu.DataSource = dTable;
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
切片蛋糕:
try
{
string Query = "select product.Product_name,product.Product_price from db85cc.product where product.prodict_id='cake'";
MySqlConnection MyConn2 = new MySqlConnection(MyConnection2);
MySqlCommand MyCommand2 = new MySqlCommand(Query, MyConn2);
MySqlDataAdapter MyAdapter = new MySqlDataAdapter();
MyAdapter.SelectCommand = MyCommand2;
DataTable dTable = new DataTable();
MyAdapter.Fill(dTable);
dgvmenu.DataSource = dTable;
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
大杯飲料:
try
{
string Query = "select product.Product_name,product.Product_price from db85cc.product where product.prodict_id='drinkL'";
MySqlConnection MyConn2 = new MySqlConnection(MyConnection2);
MySqlCommand MyCommand2 = new MySqlCommand(Query, MyConn2);
MySqlDataAdapter MyAdapter = new MySqlDataAdapter();
MyAdapter.SelectCommand = MyCommand2;
DataTable dTable = new DataTable();
MyAdapter.Fill(dTable);
dgvmenu.DataSource = dTable;
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
中杯飲料:
try
{
string Query = "select product.Product_name,product.Product_price from db85cc.product where product.prodict_id='drinkM'";
MySqlConnection MyConn2 = new MySqlConnection(MyConnection2);
MySqlCommand MyCommand2 = new MySqlCommand(Query, MyConn2);
MySqlDataAdapter MyAdapter = new MySqlDataAdapter();
MyAdapter.SelectCommand = MyCommand2;
DataTable dTable = new DataTable();
MyAdapter.Fill(dTable);
dgvmenu.DataSource = dTable;
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
小杯飲料:
try
{
string Query = "select product.Product_name,product.Product_price from db85cc.product where product.prodict_id='drinkS'";
MySqlConnection MyConn2 = new MySqlConnection(MyConnection2);
MySqlCommand MyCommand2 = new MySqlCommand(Query, MyConn2);
MySqlDataAdapter MyAdapter = new MySqlDataAdapter();
MyAdapter.SelectCommand = MyCommand2;
DataTable dTable = new DataTable();
MyAdapter.Fill(dTable);
dgvmenu.DataSource = dTable;
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
六吋蛋糕:
try
{
string Query = "select product.Product_name,product.Product_price from db85cc.product where product.prodict_id='cake6'";
MySqlConnection MyConn2 = new MySqlConnection(MyConnection2);
MySqlCommand MyCommand2 = new MySqlCommand(Query, MyConn2);
MySqlDataAdapter MyAdapter = new MySqlDataAdapter();
MyAdapter.SelectCommand = MyCommand2;
DataTable dTable = new DataTable();
MyAdapter.Fill(dTable);
dgvmenu.DataSource = dTable;
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
八吋蛋糕:
try
{
string Query = "select product.Product_name,product.Product_price from db85cc.product where product.prodict_id='cake8'";
MySqlConnection MyConn2 = new MySqlConnection(MyConnection2);
MySqlCommand MyCommand2 = new MySqlCommand(Query, MyConn2);
MySqlDataAdapter MyAdapter = new MySqlDataAdapter();
MyAdapter.SelectCommand = MyCommand2;
DataTable dTable = new DataTable();
MyAdapter.Fill(dTable);
dgvmenu.DataSource = dTable;
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
下篇見~~