internal void cargarComida(EditarComida editarComida, int id) { try { conectar(); string sql = "select * from comida where id_comida = " + id; command = new SQLiteCommand(sql, connection); SQLiteDataReader lector = command.ExecuteReader(); while (lector.Read()) { editarComida.textBoxNombre.Text = lector.GetString(1); editarComida.checkBoxSinTACC.Checked = bool.Parse(lector.GetString(2)); editarComida.checkBoxVegetariano.Checked = bool.Parse(lector.GetString(3)); editarComida.textBoxPrecio.Text = lector.GetFloat(4).ToString(); } command.Connection.Close();; } catch (Exception e) { throw new Exception("Error: " + e); } finally { desconectar(); } }
private void button2_Click(object sender, EventArgs e) { if (seleccionado != null) { int id = int.Parse(seleccionado.Cells[0].Value.ToString()); EditarComida editarComida = new EditarComida(id, this); editarComida.Show(); seleccionado = null; RecargarTabla(); } }