private List <AnaliseLaboratorial> getMetodosContracetivos() { try { conn.Open(); com.Connection = conn; SqlCommand cmd = new SqlCommand("select * from analisesLaboratoriais order by NomeAnalise", conn); SqlDataReader reader = cmd.ExecuteReader(); while (reader.Read()) { analise = new AnaliseLaboratorial { nomeAnalise = (string)reader["NomeAnalise"], observacao = ((reader["Observacoes"] == DBNull.Value) ? "" : (string)reader["Observacoes"]), IdAnaliseLaboratorial = (int)reader["IdAnalisesLaboratoriais"], }; listaAnalisesLaboratorial.Add(analise); } conn.Close(); } catch (Exception) { if (conn.State == ConnectionState.Open) { conn.Close(); } MessageBox.Show("Por erro interno é impossível visualizar os dados!", "Atenção!", MessageBoxButtons.OK, MessageBoxIcon.Error); } return(listaAnalisesLaboratorial); }
private void dataGridViewAnalises_MouseDoubleClick(object sender, MouseEventArgs e) { int i = dataGridViewAnalises.CurrentCell.RowIndex; analise = null; foreach (var a in auxiliar) { if (a.nomeAnalise == dataGridViewAnalises.Rows[i].Cells[0].Value.ToString()) { analise = a; } } if (analise != null) { txtNome.Text = analise.nomeAnalise; txtObs.Text = analise.observacao; } }