//private void button1_Click(object sender, EventArgs e) //{ // Product menuin = new Product() // { // ProductName = textBox1.Text, // ProductType = textBox2.Text, // price = Convert.ToDecimal(textBox3.Text) // }; // ProductUtility.MenuAdd(menuin); // MessageBox.Show("新增成功"); // dataGridView1.DataSource = ProductUtility.GetAllMenu(); // dataGridView1.Refresh(); //} /// <summary> /// 新增產品 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void addProduct_btn_Click(object sender, EventArgs e) { if (textBox1.Text == "" || textBox2.Text == "" || textBox3.Text == "") { MessageBox.Show("尚未輸入新增的項目"); } else { Product menuin = new Product() { ProductName = textBox1.Text, ProductType = textBox2.Text, price = Convert.ToDecimal(textBox3.Text) }; ProductUtility.MenuAdd(menuin); MessageBox.Show("新增成功"); dataGridView1.DataSource = ProductUtility.GetAllMenu(); dataGridView1.Refresh(); } }
/// <summary> /// 修改產品 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void editProduct_btn_Click(object sender, EventArgs e) { if (textBox1.Text == "" || textBox2.Text == "" || textBox3.Text == "") { MessageBox.Show("尚未選擇修改的品項或內容不可為空白"); } else { Product prod = new Product() { ProductID = Convert.ToInt32(Hidden_ProductID_lab.Text), ProductName = textBox1.Text, ProductType = textBox2.Text, price = Convert.ToDecimal(textBox3.Text) }; ProductUtility.MenuUpdate(prod); dataGridView1.DataSource = ProductUtility.GetAllMenu(); dataGridView1.Refresh(); MessageBox.Show("修改成功"); } }
/// <summary> /// 重載 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void button13_Click(object sender, EventArgs e) { dataGridView1.DataSource = ProductUtility.GetAllMenu(); dataGridView1.Refresh(); }