Exemplo n.º 1
0
        public void consultarAdestrador(Adestrador adestrador)
        {
            try
            {
                SqlCommand cmd = new SqlCommand("select " +
                                                "(@nome_adestrador," +
                                                "@telefone_adestrador," +
                                                "@email_adestrador," +
                                                "@rua_adestrador," +
                                                "@numCasa_adestrador," +
                                                "@bairro_adestrador," +
                                                "@cidade_adestrador," +
                                                "@estado_adestrador," +
                                                "@senha_adestrador," +
                                                "@cpf_adestrador); select @@IDENTITY;", conn.conectarBD());

                cmd.Parameters.AddWithValue("@nome_adestrador", adestrador.Nome);

                cmd.ExecuteNonQuery();
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
            finally
            {
                conn.desconectarBD();
            }
            MessageBox.Show("Cadastro efetuado com sucesso!");
        }
Exemplo n.º 2
0
        public void upgradeAdestrador(Adestrador adestrador)
        {
            try
            {
                SqlCommand cmd = new SqlCommand("update Adestrador set " +
                                                "nome_adestrador = @nome_adestrador, " +
                                                "telefone_adestrador = @telefone_adestrador, " +
                                                "email_adestrador = @email_adestrador, " +
                                                "rua_adestrador = @rua_adestrador, " +
                                                "numCasa_adestrador = @numCasa_adestrador," +
                                                "bairro_adestrador = @bairro_adestrador," +
                                                "cidade_adestrador = @cidade_adestrador," +
                                                "estado_adestrador = @estado_adestrador where id_adestrador = " + adestrador.IdAdestrador + ";", conn.conectarBD());

                cmd.Parameters.Add("@nome_adestrador", SqlDbType.VarChar).Value     = adestrador.Nome;
                cmd.Parameters.Add("@telefone_adestrador", SqlDbType.VarChar).Value = adestrador.Telefone;
                cmd.Parameters.Add("@email_adestrador", SqlDbType.VarChar).Value    = adestrador.Email;
                cmd.Parameters.Add("@rua_adestrador", SqlDbType.VarChar).Value      = adestrador.Rua;
                cmd.Parameters.Add("@numCasa_adestrador", SqlDbType.Int).Value      = adestrador.NumCasa;
                cmd.Parameters.Add("@bairro_adestrador", SqlDbType.VarChar).Value   = adestrador.Bairro;
                cmd.Parameters.Add("@cidade_adestrador", SqlDbType.VarChar).Value   = adestrador.Cidade;
                cmd.Parameters.Add("@estado_adestrador", SqlDbType.VarChar).Value   = adestrador.Estado;

                cmd.ExecuteNonQuery();
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
            finally
            {
                MessageBox.Show("Alterado com Sucesso");
                conn.desconectarBD();
            }
        }
Exemplo n.º 3
0
        public Adestrador GetAdestradorTelaPerfil(int idUser, Adestrador adestrador)
        {
            SqlCommand    cmd = new SqlCommand("select * from Adestrador where id_adestrador = " + idUser, conn.conectarBD());
            SqlDataReader dr  = cmd.ExecuteReader();

            while (dr.Read())
            {
                adestrador.IdAdestrador = Convert.ToInt16(dr[0]);
                adestrador.Nome         = Convert.ToString(dr[1]);
                adestrador.Telefone     = Convert.ToString(dr[2]);
                adestrador.Email        = Convert.ToString(dr[3]);
                adestrador.Rua          = Convert.ToString(dr[4]);
                adestrador.NumCasa      = Convert.ToInt16(dr[5]);
                adestrador.Bairro       = Convert.ToString(dr[6]);
                adestrador.Cidade       = Convert.ToString(dr[7]);
                adestrador.Estado       = Convert.ToString(dr[8]);
            }
            conn.desconectarBD();
            return(adestrador);
        }
Exemplo n.º 4
0
        private void btnSalvarAdestrador_Click(object sender, EventArgs e)
        {
            if (txtNomeAdestrador.Text == "" || txtTelAdestrador.Text == "" || txtEmailAdestrador.Text == "" || txtRuaAdestrador.Text == "" || txtBairroAdestrador.Text == "" || txtCidadeAdestrador.Text == "" || cmbEstadoAdestrador.Text == "" || mtbCpfAdestrador.Text == "")
            {
                MessageBox.Show("Campos em branco, Por favor digite novamente");
                txtNomeAdestrador.Clear();
                txtTelAdestrador.Clear();
                txtEmailAdestrador.Clear();
                txtRuaAdestrador.Clear();
                txtBairroAdestrador.Clear();
                txtCidadeAdestrador.Clear();
                mtbCpfAdestrador.Clear();
                txtNomeAdestrador.Focus();
            }
            int numero;

            if (int.TryParse(txtTelAdestrador.Text, out numero))
            {
                Adestrador adestrador = new Adestrador();

                adestrador.Nome     = txtNomeAdestrador.Text;
                adestrador.Telefone = txtTelAdestrador.Text;
                adestrador.Email    = txtEmailAdestrador.Text;
                adestrador.Rua      = txtRuaAdestrador.Text;
                adestrador.NumCasa  = int.Parse(txtNumAdestrador.Text);
                adestrador.Bairro   = txtBairroAdestrador.Text;
                adestrador.Cidade   = txtCidadeAdestrador.Text;
                adestrador.Estado   = cmbEstadoAdestrador.Text;
                adestrador.Senha    = txtSenhaAdestrador.Text;
                adestrador.Cpf      = int.Parse(mtbCpfAdestrador.Text);

                controladorCadastro.InserirAdestrador(adestrador);
                this.Close();
            }
            else
            {
                MessageBox.Show("Telefone inválido");
                txtTelAdestrador.Clear();
                txtTelAdestrador.Focus();
            }
        }
Exemplo n.º 5
0
 public void AlterarAdestrador(Adestrador adestrador)
 {
     repositorioAdestrador.upgradeAdestrador(adestrador);
 }
Exemplo n.º 6
0
 public void InserirAdestrador(Adestrador adestrador)
 {
     repositorioAdestrador.salvarAdestrador(adestrador);
 }
Exemplo n.º 7
0
 public void obterRegistrosAdestrador(Adestrador adestrador, int idUser)
 {
     repositorioAdestrador.GetAdestradorTelaPerfil(idUser, adestrador);
 }
Exemplo n.º 8
0
 public void deleteAdestrador(Adestrador adestrador)
 {
 }