private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e) { if (e.RowIndex == -1) { return; } try { int id = int.Parse(dataGridView1[0, e.RowIndex].Value.ToString()); Order1 = db.orderDetail.Find(id); msMenu = db.MsMenu.Find(id); textBox1.Text = msMenu.Name; if (textBox1.Text.Equals("Risotto")) { pictureBox1.ImageLocation = "C:/Users/master/source/repos/Restautrant/Restautrant/image/risotto.jpeg"; } else if (textBox1.Text.Equals("Lasagna")) { pictureBox1.ImageLocation = "C:/Users/master/source/repos/Restautrant/Restautrant/image/lasagna.jpg"; } else if (textBox1.Text.Equals("Mac and Chesse")) { pictureBox1.ImageLocation = "C:/Users/master/source/repos/Restautrant/Restautrant/image/mac and cheese.jpg"; } else if (textBox1.Text.Equals("Pepperoni Pizza")) { pictureBox1.ImageLocation = "C:/Users/master/source/repos/Restautrant/Restautrant/image/pepperoni pizza.jpg"; } else if (textBox1.Text.Equals("Matcha Latte")) { pictureBox1.ImageLocation = "C:/Users/master/source/repos/Restautrant/Restautrant/image/matcha latte.jpg"; } else if (textBox1.Text.Equals("Cheese Burger")) { pictureBox1.ImageLocation = "C:/Users/master/source/repos/Restautrant/Restautrant/image/cheese burger.jpeg"; } else if (textBox1.Text.Equals("French Fries")) { pictureBox1.ImageLocation = "C:/Users/master/source/repos/Restautrant/Restautrant/image/french fries.jpg"; } else if (textBox1.Text.Equals("Iced Coffee")) { pictureBox1.ImageLocation = "C:/Users/master/source/repos/Restautrant/Restautrant/image/iced coffee.jpg"; } else { pictureBox1.ImageLocation = "C:/Users/master/source/repos/Restautrant/Restautrant/image/nopict.png"; } } catch { } }
private void dataGridView2_CellContentClick(object sender, DataGridViewCellEventArgs e) { if (e.RowIndex == -1) { return; } int menuId = int.Parse(dataGridView2[0, e.RowIndex].Value.ToString()); Order2 = db.orderDetail.Find(menuId); }
private void button2_Click(object sender, EventArgs e) { if (Order2 == null) { MessageBox.Show("pilih item yang akan dihapus"); return; } OrderDetails.Remove(Order2); ClearTotal(); Order2 = null; LoadData(); }
private void button1_Click(object sender, EventArgs e) { if (textBox1.Text == null || textBox2.Text == null) { MessageBox.Show("Menu atau Qty wajib diisi"); return; } if (Order1 == null) { MessageBox.Show("Select data first"); return; } OrderDetails.Add(Order1); setTotal(); Order1 = null; LoadData(); }