Exemplo n.º 1
0
        private void dataGridViewDoencas_MouseDoubleClick(object sender, MouseEventArgs e)
        {
            int i = dataGridViewDoencas.CurrentCell.RowIndex;

            foreach (var al in auxiliar)
            {
                if (al.nome == dataGridViewDoencas.Rows[i].Cells[0].Value.ToString())
                {
                    alergia = al;
                }
            }
            if (alergia != null)
            {
                txtNome.Text     = alergia.nome;
                txtSintomas.Text = alergia.sintomas;
                txtId.Text       = (alergia.IdAlergia).ToString();
            }
        }
Exemplo n.º 2
0
        private List <Alergia> getAlergias()
        {
            conn.Open();
            com.Connection = conn;

            SqlCommand cmd = new SqlCommand("select * from Alergia order by Nome", conn);

            SqlDataReader reader = cmd.ExecuteReader();

            while (reader.Read())
            {
                alergia = new Alergia
                {
                    nome      = (string)reader["nome"],
                    sintomas  = (string)reader["sintomas"],
                    IdAlergia = (int)reader["IdAlergia"],
                };
                listaAlergias.Add(alergia);
            }
            conn.Close();

            return(listaAlergias);
        }