private void btnSetMeal_Click(object sender, EventArgs e) { using (dialogGetSetMeal d = new dialogGetSetMeal()) { if (d.ShowDialog() == System.Windows.Forms.DialogResult.OK) { dish set = d.getDish(); dgvOrder.Rows.Add(set.getId(), 1, set.getName(), set.getOtherName(), "", set.getPrice()); dgvOrder.Rows[dgvOrder.Rows.Count - 1].DefaultCellStyle.BackColor = Color.GreenYellow; using (SqlConnection sqlCon = new SqlConnection(connectionString)) { sqlCon.Open(); SqlCommand getSetDish = new SqlCommand("GetSetDish", sqlCon); getSetDish.CommandType = CommandType.StoredProcedure; getSetDish.Parameters.AddWithValue("@setId", set.getId()); using (SqlDataReader reader = getSetDish.ExecuteReader()) { while (reader.Read()) { dgvOrder.Rows.Add(reader["dishNo"].ToString(), reader["QTY"].ToString(), reader["foodName"].ToString(), reader["foodOtherName"].ToString(), "", reader["price"].ToString()); dgvOrder.Rows[dgvOrder.Rows.Count - 1].DefaultCellStyle.BackColor = Color.Gold; } } sqlCon.Close(); } lblTotal.Text = "£ " + calculateTotal(); } } }
private void btnGetDish_Click(object sender, EventArgs e) { using (dialogSelectSetMealDish d = new dialogSelectSetMealDish()) { if (d.ShowDialog() == System.Windows.Forms.DialogResult.OK) { food = d.getDish(); lblDishName.Text = food.getName(); lblDishOther.Text = food.getOtherName(); } } }