public void Index()
        {
            var repositorio = new RepositorioDeClientes();

            var cliente1 = new Cliente
                {
                    Nome = "nonono"
                };

            repositorio["nonono"] = cliente1;

            var cliente2 = repositorio["nonono"];

            Assert.AreSame(cliente1, cliente2);

            try
            {
                var clienteTiago = repositorio["Nonono"];

                Assert.Fail("Não deve encontrar o cliente");
            }
            catch (Exception e)
            {
            }
        }
        public frmCadastroDeCliente(Cliente prod, ClienteEnum cliEnum)
        {
            if (prod != null)
            {
                CLI = prod;
            }
            ENUM = cliEnum;

            InitializeComponent();
        }
예제 #3
0
        public void Criar()
        {
            Cliente cliente = new Cliente("*****@*****.**");

            cliente.Rg = new RG { Numero = "123412332312", UF = "PR" };

            cliente.DataNascimento = DateTime.Now;

            Assert.AreEqual(CategoriaCliente.Desconhecida,
                cliente.Categoria);

            cliente.Categoria = CategoriaCliente.Premium;

            Assert.AreEqual(10, cliente.ObterPercentualDesconto());

            cliente.Categoria = CategoriaCliente.Standard;

            Assert.AreEqual(1, cliente.ObterPercentualDesconto());
        }
예제 #4
0
        public bool DeleteCliente(Cliente cliente)
        {
            try
            {
                LimparParametros();
                AdicionaParametro("@id", cliente.IdCliente);
                if (ExecutaComando(CommandType.StoredProcedure, "[dbo].[_aspDeleteCliente]") != null)
                {
                    return true;
                }
                else
                {
                    return false;
                }
            }
            catch (Exception Erro)
            {

                throw new Exception(Erro.Message);
            }
        }
예제 #5
0
        public bool InsertCliente(Cliente Cliente)
        {
            try
            {
                LimparParametros();
                AdicionaParametro("@Nome", Cliente.Nome);
                AdicionaParametro("@cpf", Cliente.CPF);
                AdicionaParametro("@Telefone", Cliente.Celular);
                if (ExecutaComando(CommandType.StoredProcedure, "_aspInsertCliente") != null)
                {
                    return true;
                }
                else
                {
                    return false;
                }
            }
            catch (Exception Erro)
            {

                throw new Exception(Erro.Message);
            }
        }
예제 #6
0
        public bool UpdateCliente(Cliente cliente)
        {
            try
            {
                LimparParametros();
                AdicionaParametro("@Id", cliente.IdCliente);
                AdicionaParametro("@nOME", cliente.Nome);
                AdicionaParametro("@Celular", cliente.Celular);
                AdicionaParametro("@CPF", cliente.CPF);
                if (ExecutaComando(CommandType.StoredProcedure, "_aspAlterarCliente") != null)
                {
                    return true;
                }
                else
                {
                    return false;
                }
            }
            catch (Exception Erro)
            {

                throw new Exception(Erro.Message);
            }
        }
예제 #7
0
        public Cliente SelectForId(int Id)
        {
            try
            {
                LimparParametros();
                AdicionaParametro("@Id", Id);
                DataRow Linha = ExecutaConsulta(CommandType.StoredProcedure, "_aspSelectClientePorId").Rows[0];
                if (Linha != null)
                {
                    Cliente cliente = new Cliente
                    {
                        Nome = Linha["Nome"].ToString(),
                        IdCliente = Convert.ToInt32(Linha["ID"]),
                        CPF = Linha["CPF"].ToString(),
                        Celular = Linha["Celular"].ToString()

                    };
                    return cliente;
                }
                else
                {
                    return null;
                }
            }
            catch (Exception Erro)
            {

                throw new Exception(Erro.Message);
            }
        }