Exemple #1
0
        public void Excluir(int id)
        {
            DbConnection conexao = DAOUtils.GetConexao();
            DbCommand    comando = DAOUtils.GetComando(conexao);

            comando.CommandType = CommandType.Text;
            comando.CommandText = "DELETE FROM CONTATOS WHERE ID = @id";
            //comando.Parameters.Add(new SqlParameter("@id", id));
            comando.Parameters.Add(DAOUtils.GetParameter("@id", id));
            comando.ExecuteNonQuery();
        }
Exemple #2
0
        public void Inserir(Contato contato)
        {
            DbConnection conexao = DAOUtils.GetConexao();
            DbCommand    comando = DAOUtils.GetComando(conexao);

            comando.CommandType = CommandType.Text;
            comando.CommandText = "INSERT INTO CONTATOS (NOME, EMAIL, TELEFONE) VALUES (@NOME, @EMAIL, @TELEFONE)"; // INFO SERAO INSERIDAS NA CLASSE CONTATO SEGUNDO O PARAMENTRO CONTATO.

            comando.Parameters.Add(DAOUtils.GetParameter("@nome", contato.Nome));
            comando.Parameters.Add(DAOUtils.GetParameter("@email", contato.Email));
            comando.Parameters.Add(DAOUtils.GetParameter("@telefone", contato.Telefone));
            comando.ExecuteNonQuery();
        }
Exemple #3
0
        public void Inserir(Contato contato)
        {
            DbConnection conexao = DAOUtils.GetConexao();
            DbCommand    comando = DAOUtils.GetComando(conexao);

            comando.CommandType = CommandType.Text;
            comando.CommandText = "INSERT INTO CONTATOS (NOME, EMAIL, TELEFONE) VALUES (@nome, @email, @telefone)";
            //comando.Parameters.Add(new SqlParameter("@nome", contato.Nome));
            //comando.Parameters.Add(new SqlParameter("@email", contato.Email));
            //comando.Parameters.Add(new SqlParameter("@telefone", contato.Telefone));
            //comando.Parameters.Add(new MySqlParameter("@nome", contato.Nome));
            //comando.Parameters.Add(new MySqlParameter("@email", contato.Email));
            //comando.Parameters.Add(new MySqlParameter("@telefone", contato.Telefone));
            comando.Parameters.Add(DAOUtils.GetParameter("@nome", contato.Nome));
            comando.Parameters.Add(DAOUtils.GetParameter("@email", contato.Email));
            comando.Parameters.Add(DAOUtils.GetParameter("@telefone", contato.Telefone));
            comando.ExecuteNonQuery();
        }
Exemple #4
0
 public void Atualizar(Contato contato)
 {
     try
     {
         DbConnection conexao = DAOUtils.GetConexao();
         DbCommand    comando = DAOUtils.GetComando(conexao);
         comando.CommandType = CommandType.Text;
         comando.CommandText = "UPDATE CONTATOS SET NOME = @nome, EMAIL = @email, TELEFONE = @telefone WHERE ID = @id";
         comando.Parameters.Add(DAOUtils.GetParameter("@nome", contato.Nome));
         comando.Parameters.Add(DAOUtils.GetParameter("@email", contato.Email));
         comando.Parameters.Add(DAOUtils.GetParameter("@telefone", contato.Telefone));
         comando.Parameters.Add(DAOUtils.GetParameter("@id", contato.Id));
         comando.ExecuteNonQuery(); // QUANDO A QUERY NAO RETORNA NADA
     }
     catch (Exception e)
     {
         MessageBox.Show("Falha ao salvar dados" + e.Message);
     }
 }
Exemple #5
0
        public void Atualizar(Contato contato)
        {
            DbConnection conexao = DAOUtils.GetConexao();
            DbCommand    comando = DAOUtils.GetComando(conexao);

            comando.CommandType = CommandType.Text;
            comando.CommandText = "UPDATE CONTATOS SET NOME = @nome, EMAIL = @email, TELEFONE = @telefone WHERE ID = @id";
            //comando.Parameters.Add(new SqlParameter("@nome", contato.Nome));
            //comando.Parameters.Add(new SqlParameter("@email", contato.Email));
            //comando.Parameters.Add(new SqlParameter("@telefone", contato.Telefone));
            //comando.Parameters.Add(new SqlParameter("@id", contato.Id));
            //comando.Parameters.Add(new MySqlParameter("@nome", contato.Nome));
            //comando.Parameters.Add(new MySqlParameter("@email", contato.Email));
            //comando.Parameters.Add(new MySqlParameter("@telefone", contato.Telefone));
            //comando.Parameters.Add(new MySqlParameter("@id", contato.Id));
            comando.Parameters.Add(DAOUtils.GetParameter("@nome", contato.Nome));
            comando.Parameters.Add(DAOUtils.GetParameter("@email", contato.Email));
            comando.Parameters.Add(DAOUtils.GetParameter("@telefone", contato.Telefone));
            comando.Parameters.Add(DAOUtils.GetParameter("@id", contato.Id));
            comando.ExecuteNonQuery();
        }