Example #1
0
        public string autenticar(string cpf, string senha)
        {
            cpf = UtilFormatar.retirarFormatacao(cpf);

            string validar = validarDadosLogin(cpf, senha);

            if (string.IsNullOrEmpty(validar))
            {
                clnCliente objCliente = new clnCliente
                {
                    Cpf  = cpf,
                    Hash = senha
                }.autenticarPorCPF();

                if (objCliente != null)
                {
                    HttpContext.Current.Session["clienteAutenticado"] = (clnCliente)objCliente;
                    return("1Autenticado com sucesso!");
                }
                else
                {
                    return("0Os dados informados são inválidos.");
                }
            }
            else
            {
                return("0" + validar);
            }
        }
Example #2
0
        private void exibirReservas()
        {
            List <clnReserva> objReservas = new clnReserva
            {
                Agendado = dtpListar.Value.Date
            }.obterPorDataAgendada();

            lstReservas.LimparOpcoes();
            foreach (clnReserva objReserva in objReservas)
            {
                clnCliente objCliente = new clnCliente
                {
                    Cod = objReserva.CodCliente
                }.obterPorCod();

                lstReservas.Adicionar(objReserva.Cod, "RESERVA " + objReserva.Cod + "\n"
                                      + objCliente.Nome.Split(' ')[0] + " - " + UtilFormatar.formatarHora(objReserva.Agendado),
                                      Properties.Resources.reserva, AppDesktop.VisualStyle.BoxColor, () =>
                {
                    abrirReserva(objReserva);
                    return(UIXItemsList.ListResult.NENHUM);
                });
            }
            lstReservas.exibirItens();
        }
Example #3
0
        private string gerarTokenCliente(clnCliente objCliente)
        {
            String tokenCliente = objCliente.Cpf + "-" + objCliente.Email + "-" + objCliente.obterHash();

            tokenCliente = vitorrdgs.Util.Hash.Hash.HASH.cyph(tokenCliente);

            return(tokenCliente);
        }
Example #4
0
        public string cadastrar(string nome, string email, string senha, string cpf, string celular,
                                string cartaoNumero, string cartaoValidade, string cartaoCVV)
        {
            if (!autenticado())
            {
                cartaoNumero = UtilFormatar.retirarFormatacao(cartaoNumero);
                cpf          = UtilFormatar.retirarFormatacao(cpf);

                string validar = validarDados(nome, email, senha, cpf, celular, cartaoNumero, cartaoValidade, cartaoCVV);

                if (string.IsNullOrEmpty(validar))
                {
                    clnCliente objClienteEmail = new clnCliente
                    {
                        Email = email
                    }.obterPorEmail();
                    if (objClienteEmail != null)
                    {
                        validar += "E-mail já cadastrado.";
                    }

                    clnCliente objClienteCPF = new clnCliente
                    {
                        Cpf = cpf
                    }.obterPorCPF();
                    if (objClienteCPF != null)
                    {
                        validar += "CPF já cadastrado.";
                    }

                    if (string.IsNullOrEmpty(validar))
                    {
                        clnCliente objCliente = new clnCliente
                        {
                            Nome           = nome,
                            Email          = email,
                            Hash           = senha,
                            Ativo          = true,
                            TelCelular     = UtilFormatar.retirarFormatacao(celular),
                            Cpf            = cpf,
                            Cadastro       = DateTime.Now,
                            CartaoCVV      = UtilFormatar.retirarFormatacao(cartaoCVV),
                            CartaoNumero   = UtilFormatar.retirarFormatacao(cartaoNumero),
                            CartaoValidade = UtilFormatar.retirarFormatacao(cartaoValidade)
                        };
                        objCliente.gravar();

                        HttpContext.Current.Session["clienteAutenticado"] = (clnCliente)objCliente;
                        return("1Cadastrado com sucesso!");
                    }
                }
                return("0" + validar);
            }
            else
            {
                return("0Você já está autenticado");
            }
        }
Example #5
0
        private String construirToken(clnCliente objCliente)
        {
            String tokenCliente = gerarTokenCliente(objCliente);

            DateTime tempoParaRecuperar = DateTime.Now;

            tempoParaRecuperar = tempoParaRecuperar.AddHours(3);

            String tokenDataHora = UtilFormatar.formatarData(tempoParaRecuperar) + "$" + UtilFormatar.formatarHora(tempoParaRecuperar);
            String token         = tokenCliente + "&" + tokenDataHora;

            return(UtilConvert.ToBase64(token));
        }
Example #6
0
        public string novaReserva(string cpf, string dataStr, string horaStr, string lugaresStr, string informacoes, string codCliente)
        {
            cpf = UtilFormatar.retirarFormatacao(cpf);

            clnCliente objCliente;

            if (clienteBLL.autenticado())
            {
                objCliente = clienteBLL.obterCliente();
            }
            else if (codCliente != null && UtilValidar.validarInt(codCliente))
            {
                objCliente = new clnCliente
                {
                    Cod = UtilConvert.ToInt(codCliente)
                }.obterPorCod();
            }
            else
            {
                return("0Cliente não informado");
            }

            string validar = validarDados(cpf, dataStr, horaStr, lugaresStr, informacoes, objCliente);

            if (string.IsNullOrEmpty(validar))
            {
                if (string.IsNullOrEmpty(informacoes))
                {
                    informacoes = "Sem informações adicionais.";
                }

                clnReserva objReserva = new clnReserva
                {
                    Informacoes = informacoes,
                    Pessoas     = UtilConvert.ToInt(lugaresStr),
                    CodCliente  = objCliente.Cod,
                    Agendado    = UtilConvert.ObterDataHora(dataStr, horaStr),
                    Agendamento = DateTime.Now.Date,
                    Situacao    = clnReserva.reservaSituacao.MARCADA
                };
                objReserva.gravar();

                atribuirMesas(objReserva);

                return("1Reserva realizada com sucesso");
            }
            else
            {
                return("0" + validar);
            }
        }
Example #7
0
 private void btnExcluir_Click(object sender, EventArgs e)
 {
     if (MessageBox.Show("Deseja excluir o cliente?", this.Text, MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
     {
         return;
     }
     else
     {
         clnCliente cliente = new clnCliente();
         cliente.Excluir((int)(dgdGrid.CurrentRow.Cells[0].Value));
         MessageBox.Show("Cliente excluído com sucesso!", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
         CarregaGrid();
     }
 }
Example #8
0
        private void btnCliente_Click(object sender, EventArgs e)
        {
            clnCliente    cliente = new clnCliente();
            SqlDataReader drDados = null;

            drDados = cliente.ListarCliente(txtCliente.Text);
            if (drDados.HasRows)
            {
                while (drDados.Read())
                {
                    txtCliente.Text = drDados["cli_nomerazao"].ToString();
                }
            }
            dtpData.Text = DateTime.Now.ToLongDateString();
        }
Example #9
0
            public bool call(DataGridView dgv, string pesquisa, bool ativo)
            {
                clnCliente objClientes = new clnCliente
                {
                    Nome  = pesquisa,
                    Cpf   = pesquisa,
                    Ativo = ativo
                };

                foreach (clnCliente objCliente in objClientes.obterPorNomeCPF())
                {
                    //"Código", "Nome", "CPF", "Celular", "Email"
                    dgv.Rows.Add(new object[] { objCliente.Cod, objCliente.Nome, UtilFormatar.formatarCPF(objCliente.Cpf), UtilFormatar.formatarCelular(objCliente.TelCelular), objCliente.Email });
                }
                return(false);
            }
Example #10
0
            public bool call(DataGridViewRow row)
            {
                clnCliente objCliente = new clnCliente
                {
                    Cod = UtilConvert.ToInt(row.Cells[0].Value)
                }.obterPorCod();

                if (objCliente != null)
                {
                    frmCliente frmAlterarCliente = new frmCliente
                    {
                        ObjCliente = objCliente
                    };
                    frmAlterarCliente.ShowDialog();
                    return(true);
                }
                return(false);
            }
Example #11
0
        private void enviarToken(clnCliente objCliente)
        {
            string token = construirToken(objCliente);

            StringBuilder conteudo = new StringBuilder();

            conteudo.Append("Olá ").Append(objCliente.Nome);
            conteudo.Append("<br/>");
            conteudo.Append("<br/>Ao que parece, você acabou esquecendo a sua senha.");
            conteudo.Append("<br/>");
            conteudo.Append("<br/><a href='").Append(App.Webiste).Append("recuperar.cshtml?token=" + token + "&email=" + objCliente.Email).Append("'>Clique aqui para redefinir sua senha</a>");
            conteudo.Append("<br/>Não se esqueça, o link é válido por apenas 3 horas.");
            conteudo.Append("<br/>");
            conteudo.Append("<br/>Atenciosamente,");
            conteudo.Append("<br/>Equipe ").Append("<a href='").Append(App.Webiste).Append("'>").Append(App.Name).Append("</a>").Append(".");
            conteudo.Append("<br/>");
            conteudo.Append("<br/>(Esta mensagem é automática)");

            App.EmailClient.SendEmail(App.Name, App.EmailClient.CredentialEmail, objCliente.Email, "Esqueceu sua senha?", conteudo, App.TemplateEmail);
        }
Example #12
0
        public string alterar(string nome, string senha, string celular,
                              string cartaoNumero, string cartaoValidade, string cartaoCVV)
        {
            if (autenticado())
            {
                clnCliente objCliente = obterCliente();

                cartaoNumero = UtilFormatar.retirarFormatacao(cartaoNumero);

                string validar = validarDados(nome, objCliente.Email, ((senha == "") ? null : senha), objCliente.Cpf, celular, cartaoNumero, cartaoValidade, cartaoCVV);

                if (string.IsNullOrEmpty(validar))
                {
                    objCliente                = obterCliente();
                    objCliente.Nome           = nome;
                    objCliente.TelCelular     = UtilFormatar.retirarFormatacao(celular);
                    objCliente.CartaoNumero   = UtilFormatar.retirarFormatacao(cartaoNumero);
                    objCliente.CartaoValidade = UtilFormatar.retirarFormatacao(cartaoValidade);
                    objCliente.CartaoCVV      = UtilFormatar.retirarFormatacao(cartaoCVV);
                    if (senha != "")
                    {
                        objCliente.Hash = senha;
                    }

                    objCliente.alterar();

                    return("1Seus dados foram atualizados com sucesso!");
                }
                else
                {
                    return("0" + validar);
                }
            }
            else
            {
                return("0Você não está autenticado");
            }
        }
Example #13
0
        public string enviarRecuperacao(string cpf, string email)
        {
            string valido = validarCPFEmail(cpf, email);

            if (string.IsNullOrEmpty(valido))
            {
                clnCliente objCliente = new clnCliente
                {
                    Email = email
                }.obterPorEmail();

                if (objCliente.Ativo && objCliente.Cpf.Equals(UtilFormatar.retirarFormatacao(cpf)))
                {
                    enviarToken(objCliente);
                }

                return("1Se seus dados são validos, enviamos um link de recuperação para você");
            }
            else
            {
                return("0" + valido);
            }
        }
Example #14
0
        public string recuperarSenha(string token, string email, string cpf, string senha)
        {
            string valido = validarRecuperacao(token, email, cpf, senha);

            if (string.IsNullOrEmpty(valido))
            {
                clnCliente objCliente = new clnCliente
                {
                    Email = email
                }.obterPorEmail();

                if (objCliente != null)
                {
                    if (objCliente.Cpf.Equals(UtilFormatar.retirarFormatacao(cpf)))
                    {
                        String tokenClienteValido = gerarTokenCliente(objCliente);
                        String tokenCliente       = UtilConvert.FromBase64(token).Split('&')[0];

                        if (tokenCliente.Equals(tokenClienteValido))
                        {
                            objCliente.Hash = senha;
                            objCliente.alterar();
                            return("1Senha alterada com sucesso!");
                        }
                        else
                        {
                            return("0O token informado é inválido.");
                        }
                    }
                }
                return("0O cliente informado é inválido");
            }
            else
            {
                return("0" + valido);
            }
        }
Example #15
0
 private void frmClienteCadastro_Load(object sender, EventArgs e)
 {
     if (Operacao == clnFuncoesGerais.Operacao.Alteracao)
     {
         clnCliente    cliente = new clnCliente();
         SqlDataReader drDados = null;
         drDados = cliente.ListarCliente(Codigo);
         if (drDados.HasRows)
         {
             while (drDados.Read())
             {
                 txtNome.Text       = drDados["cli_nomerazao"].ToString();
                 txtCpfCnpj.Text    = drDados["cli_cnpjcpf"].ToString();
                 txtLogradouro.Text = drDados["cli_logradouro"].ToString();
                 txtBairro.Text     = drDados["cli_bairro"].ToString();
                 txtCidade.Text     = drDados["cli_cidade"].ToString();
                 cboUf.Text         = drDados["cli_uf"].ToString();
                 txtCep.Text        = drDados["cli_cep"].ToString();
                 txtEmail.Text      = drDados["cli_email"].ToString();
                 txtTelefones.Text  = drDados["cli_fones"].ToString();
             }
         }
     }
 }
Example #16
0
        private void btnNovo_Click(object sender, EventArgs e)
        {
            if (txtNome.Text.Equals(string.Empty))
            {
                errError.SetError(txtNome, "Digite um nome");
                return;
            }
            else
            {
                errError.SetError(txtNome, "");
            }

            if (txtCpfCnpj.Text.Equals(string.Empty))
            {
                errError.SetError(txtCpfCnpj, "Digite um CPF/CNPJ");
                return;
            }
            else
            {
                errError.SetError(txtCpfCnpj, "");
            }
            if (txtLogradouro.Text.Equals(string.Empty))
            {
                errError.SetError(txtLogradouro, "Digite um logradouro");
                return;
            }
            else
            {
                errError.SetError(txtLogradouro, "");
            }
            if (txtBairro.Text.Equals(string.Empty))
            {
                errError.SetError(txtBairro, "Digite um bairro");
                return;
            }
            else
            {
                errError.SetError(txtBairro, "");
            }
            if (txtCidade.Text.Equals(string.Empty))
            {
                errError.SetError(txtCidade, "Digite uma cidade");
                return;
            }
            else
            {
                errError.SetError(txtCidade, "");
            }
            if (cboUf.Text.Equals(string.Empty))
            {
                errError.SetError(cboUf, "Selecione uma UF");
                return;
            }
            else
            {
                errError.SetError(cboUf, "");
            }
            if (txtCep.Text.Equals(string.Empty))
            {
                errError.SetError(txtCep, "Digite um CEP");
                return;
            }
            else
            {
                errError.SetError(txtCep, "");
            }
            if (txtEmail.Text.Equals(string.Empty))
            {
                errError.SetError(txtEmail, "Digite um email");
                return;
            }
            else
            {
                errError.SetError(txtEmail, "");
            }
            if (txtTelefones.Text.Equals(string.Empty))
            {
                errError.SetError(txtTelefones, "Digite um telefone");
                return;
            }
            else
            {
                errError.SetError(txtTelefones, "");
            }
            clnCliente cliente = new clnCliente();

            cliente.Cli_bairro     = txtBairro.Text;
            cliente.Cli_cep        = txtCep.Text;
            cliente.Cli_cidade     = txtCidade.Text;
            cliente.Cli_cnpjcpf    = txtCpfCnpj.Text;
            cliente.Cli_dtcadastro = DateTime.Now.ToString("yyyy-MM-dd"); // Pegando a data de Hoje
            cliente.Cli_email      = txtEmail.Text;
            cliente.Cli_fones      = txtTelefones.Text;
            cliente.Cli_logradouro = txtLogradouro.Text;
            cliente.Cli_nomerazao  = txtNome.Text;
            cliente.Cli_uf         = cboUf.Text;
            if (Operacao == clnFuncoesGerais.Operacao.Inclusao)
            {
                cliente.Gravar();
            }
            else if (Operacao == clnFuncoesGerais.Operacao.Alteracao)
            {
                cliente.Alterar(Codigo);
            }
            MessageBox.Show("Cliente cadastrado com sucesso!", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
            this.Close();
        }
Example #17
0
        private string validarDados(string cpf, string dataStr, string horaStr, string lugaresStr, string informacoes, clnCliente objCliente)
        {
            if (objCliente != null)
            {
                StringBuilder errosBuilder = new StringBuilder();

                if (UtilValidar.vazio(cpf))
                {
                    errosBuilder.Append("É necessário informar o CPF.");
                }
                else if (!UtilValidar.validarCPF(cpf))
                {
                    errosBuilder.Append("O CPF informado é inválido.");
                }
                else if (!cpf.Equals(objCliente.Cpf))
                {
                    errosBuilder.Append("O CPF foi informado incorretamente.");
                }

                if (UtilValidar.vazio(dataStr))
                {
                    errosBuilder.Append("É necessário informar a data.");
                }
                else if (!UtilValidar.validarData(dataStr))
                {
                    errosBuilder.Append("A data informada é inválida.");
                }
                else if (!UtilValidar.validarDataFutura(dataStr))
                {
                    errosBuilder.Append("A data informada é inválida.");
                }

                if (UtilValidar.vazio(horaStr))
                {
                    errosBuilder.Append("É necessário informar a hora.");
                }
                else if (!UtilValidar.validarHora(horaStr))
                {
                    errosBuilder.Append("A hora informada é inválida.");
                }

                if (UtilValidar.vazio(lugaresStr))
                {
                    errosBuilder.Append("É necessário informar os lugares.");
                }
                else if (!UtilValidar.validarValor(lugaresStr))
                {
                    errosBuilder.Append("É necessário informar um valor válido para os lugares.");
                }
                else
                {
                    int lugares = UtilConvert.ToInt(lugaresStr);
                    if (lugares < 2)
                    {
                        errosBuilder.Append("É necessário reservar no minimo 2 lugares.");
                    }
                    else if (lugares > 8)
                    {
                        errosBuilder.Append("Não é possível reservar mais que 8 lugares.");
                    }
                }

                if (informacoes.Length > 256)
                {
                    errosBuilder.Append("O limite de informações é de 256 caracteres.");
                }

                if (errosBuilder.Length == 0)
                {
                    int      lugares = UtilConvert.ToInt(lugaresStr);
                    DateTime data    = UtilConvert.ObterDataHora(dataStr, horaStr);

                    //TODAS AS INFORMAÇÕE ESTÃO OK, VALIDE SE NÃO TEM RESERVA E SE É POSSÍVEL
                    List <clnReserva> objReservas = new clnReserva
                    {
                        CodCliente = objCliente.Cod,
                        Agendado   = data,
                        Ativo      = true
                    }.obterPorClienteData();

                    if (objReservas.Count > 0)
                    {
                        errosBuilder.Append("Você já realizou uma reserva para esta data!");
                    }
                    else
                    {
                        int lugaresTotais = new clnMesa {
                        }.obterLugares();

                        int lugaresReservados = new clnReserva
                        {
                            Agendado = data
                        }.obterLugaresReservados();

                        if (lugaresReservados > (lugaresTotais / 2))
                        {
                            errosBuilder.Append("Não há lugares disponiveis para reserva via Internet nesta data.");
                        }
                        else
                        {
                            int lugaresDisponiveis = lugaresTotais - lugaresReservados;

                            if (lugares > lugaresDisponiveis)
                            {
                                errosBuilder.Append("Não existem lugares disponiveis para esta data");
                            }
                        }
                    }
                }

                return(errosBuilder.ToString());
            }
            else
            {
                return("Você não está autenticado.");
            }
        }
Example #18
0
        private void CarregaGrid()
        {
            clnCliente cliente = new clnCliente();

            dgdGrid.DataSource = cliente.Listar(txtDescricao.Text).Tables[0];
        }