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!"); }
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(); } }
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); }
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(); } }
public void AlterarAdestrador(Adestrador adestrador) { repositorioAdestrador.upgradeAdestrador(adestrador); }
public void InserirAdestrador(Adestrador adestrador) { repositorioAdestrador.salvarAdestrador(adestrador); }
public void obterRegistrosAdestrador(Adestrador adestrador, int idUser) { repositorioAdestrador.GetAdestradorTelaPerfil(idUser, adestrador); }
public void deleteAdestrador(Adestrador adestrador) { }