예제 #1
0
        public void atualizarGrid()
        {
            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.idDentista = reader.GetInt32(0);
                    dentista.Nome       = reader.GetString(1);
                    dentista.Cro        = reader.GetString(2);
                    dentista.Sexo       = reader.GetValue(3) == null ? "" : reader.GetValue(3).ToString();
                    dentista.Linkedin   = reader.GetValue(4).ToString() == "true" ? 1 : 0;
                    dentista.Instagram  = reader.GetValue(5).ToString() == "true" ? 1 : 0;
                    dentista.Facebook   = reader.GetValue(6).ToString() == "true" ? 1 : 0;
                    dentista.Twitter    = reader.GetValue(7).ToString() == "true" ? 1 : 0;

                    listDentista.Add(dentista);
                }
                reader.Close();
            }
            else
            {
                Console.WriteLine("Não retornou dados. ");
            }

            dgvDados.DataSource = null;
            dgvDados.DataSource = listDentista;
        }
예제 #2
0
        public void lerDados()
        {
            objDentista            = new Dentista();
            objDentista.idDentista = int.Parse(txtID.Text.Trim());
            objDentista.Nome       = txtNome.Text;
            objDentista.Cro        = txtCRO.Text;

            objDentista.Instagram = chbInstagram.Checked ? 1 : 0;
            objDentista.Twitter   = chbTwitter.Checked ? 1 : 0;
            objDentista.Facebook  = chbFacebook.Checked ? 1 : 0;
            objDentista.Linkedin  = chbLinkedin.Checked ? 1 : 0;

            if (rbFeminino.Checked)

            {
                objDentista.Sexo = "F";
            }
            else
            {
                objDentista.Sexo = "M";
            }
        }
예제 #3
0
        private void btnExcluir_Click(object sender, EventArgs e)
        {
            con.conectar();
            DialogResult op = MessageBox.Show("Tem certeza que deseja excluir?", "Excluir?", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning);

            if (op == DialogResult.Yes)
            {
                Dentista dentista = new Dentista();
                dentista.idDentista = int.Parse(txtID.Text.ToString());
                String sql = "DELETE FROM tb_dentista WHERE id_dentista =" + dentista.idDentista;

                if (con.executar(sql) == 1)
                {
                    MessageBox.Show("Excluindo");
                }
                else
                {
                    MessageBox.Show("Não foi excluido");
                }
                atualizarGrid();
            }
        }