private void LoadCbDent() { List <Dentista> listDentista = new List <Dentista>(); con.conectar(); SqlDataReader reader; reader = con.exeConsulta("select * from tb_dentista"); if (reader.HasRows) { while (reader.Read()) { Dentista d = new Dentista(); d.id = reader.GetInt32(0); d.nome = reader.GetString(1); listDentista.Add(d); } reader.Close(); } else { Console.WriteLine("Não retornou dados"); } cbDentista.DataSource = null; cbDentista.DataSource = listDentista; cbDentista.DisplayMember = "nome"; cbDentista.ValueMember = "id"; }
public void lerDados() { objDentista = new Dentista(); objDentista.id = int.Parse(txtId.Text.Trim()); objDentista.nome = txtNome.Text; objDentista.Cro = txtCRO.Text; objDentista.Instagram = chbInstagram.Checked ? 1 : 0; objDentista.Facebook = chbFacebook.Checked ? 1 : 0; objDentista.Twitter = chbTwitter.Checked ? 1 : 0; objDentista.LinkedIn = chbLinkedIn.Checked ? 1 : 0; objDentista.Sexo = rbFeminino.Checked ? "F" : "M"; }
public void atualizarGrid() { limparDados(); List <Dentista> listDentista = new List <Dentista>(); con.conectar(); SqlDataReader reader; reader = con.exeConsulta("select * from tb_dentista"); if (reader.HasRows) { while (reader.Read()) { Dentista dentista = new Dentista(); dentista.id = reader.GetInt32(0); dentista.nome = reader.GetString(1); dentista.Cro = reader.GetString(2); dentista.Sexo = reader.GetString(3); dentista.Instagram = reader.GetBoolean(4) ? 1 : 0; dentista.Facebook = reader.GetBoolean(5) ? 1 : 0; dentista.Twitter = reader.GetBoolean(6) ? 1 : 0; dentista.LinkedIn = reader.GetBoolean(7) ? 1 : 0; listDentista.Add(dentista); } reader.Close(); } else { Console.WriteLine("Não retornou dados"); } dgvDados.DataSource = null; dgvDados.DataSource = listDentista; }