Exemplo n.º 1
0
        public string CadastroNovoContaFiado(DadosCliente Cliente)
        {
            using (var connection = GetConnection())
            {
                connection.Open();
                string rpta = "";
                try
                {
                    command.Connection  = connection;
                    command.CommandText = "CadastroCliente";
                    command.CommandType = CommandType.StoredProcedure;
                    SqlParameter parId = new SqlParameter();
                    parId.ParameterName = "@id_cliente";
                    parId.Value         = Cliente.IdCliente;
                    parId.SqlDbType     = SqlDbType.Int;
                    parId.Direction     = ParameterDirection.Output;
                    command.Parameters.Add(parId);
                    command.Parameters.AddWithValue("@nome", Cliente.Nome);
                    command.Parameters.AddWithValue("@sobre_nome", Cliente.SobreNome);
                    command.Parameters.AddWithValue("@cpf", Cliente.CPF);
                    command.Parameters.AddWithValue("@fone", Cliente.Fone);
                    command.Parameters.AddWithValue("@email", Cliente.Email);
                    command.Parameters.AddWithValue("@cep", Cliente.CEP);
                    command.Parameters.AddWithValue("@endereco", Cliente.Endereco);
                    command.Parameters.AddWithValue("@bairro", Cliente.Bairro);
                    command.Parameters.AddWithValue("@cidade", Cliente.Cidade);
                    command.Parameters.AddWithValue("@uf", Cliente.UF);
                    command.Parameters.AddWithValue("@observacao", Cliente.Observacao);
                    //
                    command.Parameters.AddWithValue("@id_pedido", Cliente.IdPedido);
                    command.Parameters.AddWithValue("@saldo_devedor", Cliente.SaldoDevedor);

                    rpta = command.ExecuteNonQuery() == 2 ? "OK" : "Erro ao cadastrar cliente";
                }
                catch (Exception ex)
                {
                    rpta = ex.Message;
                }
                return(rpta);
            }
        }
Exemplo n.º 2
0
 //cadastro apenas do CPF para nota fiscal
 public string CadastroCpf(DadosCliente CPF)
 {
     using (var connection = GetConnection())
     {
         connection.Open();
         string rpta = "";
         try
         {
             command.Connection  = connection;
             command.CommandText = "insert into tb_cliente (nome, sobre_nome, cpf, fone, email, cep, endereco, bairro, cidade, uf, observacao) values ('', '', @cpf, '', '', '', '', '', '', '', '')";
             command.CommandType = CommandType.Text;
             command.Parameters.AddWithValue("@cpf", CPF.CPF);
             rpta = command.ExecuteNonQuery() == 1 ? "OK" : "Erro ao cadastrar CPF";
         }
         catch (Exception ex)
         {
             rpta = ex.Message;
         }
         return(rpta);
     }
 }
Exemplo n.º 3
0
        public bool ValidarCadastro(DadosCliente Valida)
        {
            using (var connection = GetConnection())
            {
                connection.Open();
                try
                {
                    command.Connection  = connection;
                    command.CommandText = "SELECT * FROM tb_cliente where cpf=@cpf";
                    command.CommandType = CommandType.Text;
                    command.Parameters.AddWithValue("@cpf", Valida.CPF);
                    var result = command.ExecuteScalar();

                    if (result != null)
                    {
                        return(true);
                    }
                }
                catch (Exception ex)
                {
                }
                return(false);
            }
        }