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();
         }
     }
 }
Ejemplo n.º 3
0
 private void btnSelect_Click(object sender, EventArgs e)
 {
     if (dgvDish.SelectedRows.Count > 0)
     {
         DataGridViewRow row = dgvDish.SelectedRows[0];
         d = new dish((int)row.Cells[0].Value, (string)row.Cells[1].Value, (string)row.Cells[2].Value, "");
         this.DialogResult = DialogResult.OK;
     }
     else
     {
         MessageBox.Show("Please select one dish from grid on right", "Error", MessageBoxButtons.OK,
                         MessageBoxIcon.Error);
     }
 }