private void btnFinalizar_Click(object sender, EventArgs e) { if (MessageBox.Show("Confirmar pedido", "Confirmação de Lanche", MessageBoxButtons.OKCancel, MessageBoxIcon.Information) == DialogResult.OK) { string refri = "não"; string batata = "não"; if (cbxRefri.Checked == true) { refri = "sim"; } if (cbxBatata.Checked == true) { batata = "sim"; } string ingredientes = ""; SqlConnection con = Conexao.OC(); for (int i = 0; i < dgvLanche.RowCount; i++) { ingredientes = dgvLanche.Rows[i].Cells[0].Value.ToString() + "-" + ingredientes; } foreach (DataGridViewRow dr in dgvLanche.Rows) { SqlCommand cmdtira = new SqlCommand("TiraIngrediente", con); cmdtira.CommandType = CommandType.StoredProcedure; cmdtira.Parameters.AddWithValue("@nome", SqlDbType.NChar).Value = dr.Cells[0].Value; string tira = "update ingredientes set quantidade = quantidade-2 where nome = 'pao'"; SqlCommand cmdpao = new SqlCommand(tira, con); cmdtira.ExecuteNonQuery(); cmdpao.ExecuteNonQuery(); } SqlCommand cmd = con.CreateCommand(); cmd.CommandText = "Pedir_Cria_Lanche"; cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@nome", ingredientes); cmd.Parameters.AddWithValue("@preço", txtValor.Text); cmd.Parameters.AddWithValue("@batata", batata); cmd.Parameters.AddWithValue("@refri", refri); cmd.ExecuteNonQuery(); Conexao.FC(); this.Close(); FrmObrigado obri = new FrmObrigado(); obri.Show(); } /*List <object> ingredientes = new List<object>(); * for (Int32 i = 0; i < dgvLanche.Rows.Count; i++) * { * ingredientes.Add(Convert.ToString(dgvLanche.Rows[i].Cells[0].Value.ToString())); * } * try * { * SqlConnection con = Conexao.OC(); * SqlCommand cmd = con.CreateCommand(); * cmd.CommandText = "Pedir_Lanche_Pronto"; * cmd.CommandType = CommandType.StoredProcedure; * cmd.Parameters.AddWithValue("@nome", SqlDbType.Text).Value = ingredientes; * cmd.Parameters.AddWithValue("@preço", txtValor.Text); * cmd.Parameters.AddWithValue("@batata", batata); * cmd.Parameters.AddWithValue("@refri", refri); * cmd.ExecuteNonQuery(); * MessageBox.Show("Pedido realizado com sucesso!", "PEDIDO", MessageBoxButtons.OK); * * } * catch (Exception) * { * * MessageBox.Show("DEU RUIM DNV AFFFF!", "PEDIDO", MessageBoxButtons.OK); * }*/ /*int linhas = 0; * List<Ingrediente> ingrediente = new List<Ingrediente>(); * while (linhas < dgvLanche.Rows.Count) * { * ingrediente.Add(new Ingrediente() { dgvLanche.Rows[linhas].Cells[0].Value.ToString() }); * linhas++; * } * try * { * SqlConnection con = Conexao.OC(); * SqlCommand cmd = con.CreateCommand(); * cmd.CommandText = "Pedir_Lanche_Pronto"; * cmd.CommandType = CommandType.StoredProcedure; * cmd.Parameters.AddWithValue("@nome", ingrediente); * cmd.Parameters.AddWithValue("@preço", txtValor.Text); * cmd.Parameters.AddWithValue("@batata", batata); * cmd.Parameters.AddWithValue("@refri", refri); * cmd.ExecuteNonQuery(); * MessageBox.Show("Pedido realizado com sucesso!", "PEDIDO", MessageBoxButtons.OK); * } * catch (Exception) * { * MessageBox.Show("Deu ruim dnv", "PEDIDO", MessageBoxButtons.OK); * * }*/ }