private void botonCerrarMesa_Click(object sender, EventArgs e) { //Recorro el DataGridView y cuento el total int cont = dataGridView2.Rows.Count; int total = 0; for (int contador = 0; contador < cont; contador++) { total = total + int.Parse(dataGridView2.Rows[contador].Cells["precio"].Value.ToString()); } //Muestro el panel con el resultado final panelMesaCerrada.Visible = true; panelMesaCerrada.BringToFront(); labelMesaTotal.Text = total.ToString(); labelMesaCerrada.Text = "Mesa " + p.Tag.ToString(); DataSet DDSS = new DataSet(); int mesaNumero = Int32.Parse(p.Tag.ToString()); Mesa m = new Mesa(); DDSS = m.PedidoVer(mesaNumero); dataGridView3.DataSource = DDSS.Tables[0]; //Vacío la mesa m.MesaVaciar(int.Parse(p.Tag.ToString())); botonMesaAgregar.Enabled = false; botonCerrarMesa.Enabled = false; botonAbrirMesa.Enabled = true; dataGridView2.DataSource = null; }