Example #1
0
        public static void definirEndereco(String cep, System.Windows.Forms.Control ctlLogradouro, System.Windows.Forms.Control ctlBairro, System.Windows.Forms.Control ctlCidade, System.Windows.Forms.Control cboUF, System.Windows.Forms.Control ctlNr, System.Windows.Forms.Control ctlComplemento)
        {
            if (UtilValidar.validarCEP(cep))
            {
                Cursor.Current = Cursors.WaitCursor;
                Endereco objEndereco = Endereco.obterEndereco(cep);
                if (objEndereco != null)
                {
                    Disable(ctlLogradouro);
                    Disable(ctlBairro);
                    Disable(ctlCidade);
                    Disable(cboUF);

                    ctlLogradouro.Text  = objEndereco.Logradouro;
                    ctlBairro.Text      = objEndereco.Bairro;
                    ctlCidade.Text      = objEndereco.Localidade;
                    cboUF.Text          = objEndereco.UF;
                    ctlComplemento.Text = objEndereco.Complemento;
                    ctlNr.Focus();
                }
                else
                {
                    Enable(ctlLogradouro);
                    Enable(ctlBairro);
                    Enable(ctlCidade);
                    Enable(cboUF);

                    ctlLogradouro.Focus();
                }
                Cursor.Current = Cursors.Default;
            }
        }
Example #2
0
        private string validarDadosLogin(string cpf, string senha)
        {
            if (!autenticado())
            {
                StringBuilder errosBuilder = new StringBuilder();

                if (UtilValidar.vazio(cpf))
                {
                    errosBuilder.Append("É necessário informar um CPF.");
                }
                else if (!UtilValidar.validarCPF(cpf))
                {
                    errosBuilder.Append("É necessário informar um CPF válido.");
                }

                if (UtilValidar.vazio(senha))
                {
                    errosBuilder.Append("É necessário informar a senha.");
                }

                return(errosBuilder.ToString());
            }
            else
            {
                return("Você já se encontra autenticado.");
            }
        }
        private string validarDados(string nome, string email, string mensagem)
        {
            StringBuilder errosBuilder = new StringBuilder();

            if (UtilValidar.vazio(nome))
            {
                errosBuilder.Append("É necessário informar o nome.");
            }
            else if (nome.Length < 10)
            {
                errosBuilder.Append("O nome informádo é invalido.");
            }

            if (UtilValidar.vazio(email))
            {
                errosBuilder.Append("É necessário informar o e-mail.");
            }
            else if (!UtilValidar.validarEmail(email))
            {
                errosBuilder.Append("O e-mail informado é inválido.");
            }

            if (UtilValidar.vazio(mensagem))
            {
                errosBuilder.Append("É necessário informar a mensagem.");
            }
            else if (mensagem.Length < 15)
            {
                errosBuilder.Append("A mensagem informada é inválida.");
            }

            return(errosBuilder.ToString());
        }
Example #4
0
        public string listarReservas(string codCliente)
        {
            if (codCliente != null && UtilValidar.validarInt(codCliente))
            {
                int cod = UtilConvert.ToInt(codCliente);

                List <clnReserva> objReservas = new clnReserva
                {
                    CodCliente = cod
                }.obterPorCliente();

                StringBuilder listarBuilder = new StringBuilder();

                foreach (clnReserva objReserva in objReservas)
                {
                    if (listarBuilder.Length > 0)
                    {
                        listarBuilder.AppendLine("$");
                    }
                    listarBuilder.Append(objReserva.Cod);
                    listarBuilder.Append("&").Append(new DateTimeOffset(objReserva.Agendado).ToUnixTimeMilliseconds());
                    listarBuilder.Append("&").Append(objReserva.Pessoas);
                    listarBuilder.Append("&").Append(objReserva.Informacoes);
                    listarBuilder.Append("&").Append(objReserva.prefixo(objReserva.Situacao));
                }

                return(listarBuilder.ToString());
            }
            else
            {
                return("0Cliente não informado");
            }
        }
Example #5
0
        public static void definirEndereco(String cep, Control ctlLogradouro, Control ctlBairro, Control ctlCidade, ComboBox cboUF, Control ctlNr, Control ctlComplemento)
        {
            if (UtilValidar.validarCEP(cep))
            {
                Cursor.Current = Cursors.WaitCursor;
                Endereco objEndereco = Endereco.obterEndereco(cep);
                if (objEndereco != null)
                {
                    UtilForm.Disable(ctlLogradouro);
                    UtilForm.Disable(ctlBairro);
                    UtilForm.Disable(ctlCidade);
                    UtilForm.Disable(cboUF);

                    ctlLogradouro.Text  = objEndereco.Logradouro;
                    ctlBairro.Text      = objEndereco.Bairro;
                    ctlCidade.Text      = objEndereco.Localidade;
                    cboUF.Text          = objEndereco.UF;
                    ctlComplemento.Text = objEndereco.Complemento;
                    ctlNr.Focus();
                }
                else
                {
                    UtilForm.Enable(ctlLogradouro);
                    UtilForm.Enable(ctlBairro);
                    UtilForm.Enable(ctlCidade);
                    UtilForm.Enable(cboUF);

                    UtilMensagem.mostrarOk("Endereço", "Não foi possível obter as informações a partir do CEP, preencha manualmente");
                    ctlLogradouro.Focus();
                }
                Cursor.Current = Cursors.Default;
            }
        }
Example #6
0
        private void btnAtualizar_Click(object sender, EventArgs e)
        {
            try
            {
                if (UtilValidar.CamposValidos(uiPanelCryptocurrency))
                {
                    if (newImage)
                    {
                        int archiveId = new Archive
                        {
                            Blob = UtilImage.ImageToByte(picCriptocurrency.Image),
                        }.Gravar();

                        bool updated = new Cryptocurency
                        {
                            ArchiveId             = archiveId,
                            Name                  = uiTxtCriptocurrency.Text,
                            Base                  = uiTxtCryptocurrencyBase.Text,
                            Description           = uiTxtDescription.Text,
                            CryptocurrencyBalance = UtilConvert.ToInt(uiTxtCryptocurrencyBalance.Text),
                            CryptocurrencyUnit    = uiTxtCryptocurrencyUnit.Text
                        }.AlterarPorId();

                        if (updated)
                        {
                            new Alert(String.Format("A criptomoeda {0} foi cadastrada.", uiTxtCriptocurrency.Text), uiCSB.Toastr.Type.Info);
                            newImage = false;
                        }
                        else
                        {
                            new Alert(String.Format("A criptomoeda {0} não foi cadastrada. Tente novamente mais tarde.", uiTxtCriptocurrency.Text), uiCSB.Toastr.Type.Warning);
                            newImage = true;
                        }
                    }
                    else
                    {
                        bool response = new Cryptocurency
                        {
                            ArchiveId             = UtilConvert.ToInt(lblArchiveId.Text),
                            Name                  = uiTxtCriptocurrency.Text,
                            Base                  = uiTxtCryptocurrencyBase.Text,
                            Description           = uiTxtDescription.Text,
                            CryptocurrencyBalance = UtilConvert.ToInt(uiTxtCryptocurrencyBalance.Text),
                            CryptocurrencyUnit    = uiTxtCryptocurrencyUnit.Text
                        }.AlterarPorId();

                        new Alert(String.Format("A criptomoeda {0} foi cadastrada.", uiTxtCriptocurrency.Text), uiCSB.Toastr.Type.Info);
                    }
                }
            }
            catch (Exception ex)
            {
                new Alert(ex.Message, uiCSB.Toastr.Type.Warning);
            }
            finally
            {
                ObterCriptomoedas();
            }
        }
Example #7
0
        private void uiTxtSearch_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.Enter || e.KeyCode == Keys.Tab)
            {
                if (uiTxtSearch.TextLength == 11)
                {
                    if (UtilValidar.validarCPF(uiTxtSearch.Text))
                    {
                        currentCustomerFisico = new CustomerFisico()
                        {
                            CPF = uiTxtSearch.Text
                        }.ObterPorCPF();

                        if (currentCustomerFisico != null)
                        {
                            UtilCreatePanel.CreateCustomerFPanel(currentCustomerFisico, uiFlowPanel, Customer_Click);
                            flowPanelCustomerF.Visible = false;
                        }
                        else
                        {
                            new Alert("Não possui cliente com o CPF inserido.", uiCSB.Toastr.Type.Warning);
                            uiTxtSearch.Text = string.Empty;
                        }
                    }
                    else
                    {
                        new Alert("O CPF inserido é inválido.", uiCSB.Toastr.Type.Warning);
                        uiTxtSearch.Text = string.Empty;
                    }
                }
                else if (uiTxtSearch.TextLength == 14)
                {
                    if (UtilValidar.validarCNPJ(uiTxtSearch.Text))
                    {
                        currentCustomerJuridico = new CustomerJuridico()
                        {
                            CNPJ = uiTxtSearch.Text
                        }.ObterPorCNPJ();

                        if (currentCustomerJuridico != null)
                        {
                        }
                        else
                        {
                            new Alert("Não possui cliente com o CNPJ inserido.", uiCSB.Toastr.Type.Warning);
                            uiTxtSearch.Text = string.Empty;
                        }
                    }
                    else
                    {
                        new Alert("O CNPJ inserido é inválido.", uiCSB.Toastr.Type.Warning);
                        uiTxtSearch.Text = string.Empty;
                    }
                }
            }
        }
Example #8
0
        private void uiTxtSearch_TextChanged(object sender, EventArgs e)
        {
            uiFlowPanel.Controls.Clear();
            currentCustomerJuridico = null;
            currentCustomerFisico   = null;

            if (uiTxtSearch.TextLength == 11)
            {
                if (UtilValidar.validarCPF(uiTxtSearch.Text))
                {
                    currentCustomerFisico = new CustomerFisico()
                    {
                        CPF = uiTxtSearch.Text
                    }.ObterPorCPF();

                    if (currentCustomerFisico != null)
                    {
                        UtilCreatePanel.CreateCustomerFPanel(currentCustomerFisico, uiFlowPanel, Customer_Click);
                        flowPanelCustomerF.Visible = false;
                    }
                    else
                    {
                        new Alert("Não possui cliente com o CPF inserido.", uiCSB.Toastr.Type.Warning);
                    }
                }
            }
            else if (uiTxtSearch.TextLength == 14)
            {
                if (UtilValidar.validarCNPJ(uiTxtSearch.Text))
                {
                    currentCustomerJuridico = new CustomerJuridico()
                    {
                        CNPJ = uiTxtSearch.Text
                    }.ObterPorCNPJ();

                    if (currentCustomerJuridico != null)
                    {
                        UtilCreatePanel.CreateCustomerJPanel(currentCustomerJuridico, uiFlowPanel, Customer_Click);
                        flowPanelCustomerJ.Visible = false;
                    }
                    else
                    {
                        new Alert("Não possui cliente com o CNPJ inserido.", uiCSB.Toastr.Type.Warning);
                        uiTxtSearch.Text = string.Empty;
                    }
                }
                else
                {
                    new Alert("O CNPJ inserido é inválido.", uiCSB.Toastr.Type.Warning);
                    uiTxtSearch.Text = string.Empty;
                    uiTxtSearch.Focus();
                }
            }
        }
Example #9
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 #10
0
        public static void definirCEP(UIXMaskedTextBox mtbCEP, Control ctlLogradouro, Control ctlBairro, Control ctlCidade, ComboBox cboUF, Control ctlNr, Control ctlComplemento)
        {
            UtilForm.Disable(ctlLogradouro);
            UtilForm.Disable(ctlBairro);
            UtilForm.Disable(ctlCidade);
            UtilForm.Disable(cboUF);

            addUFs(cboUF);
            mtbCEP.mtb.Validated += (object sender, EventArgs e) =>
            {
                if (UtilValidar.validarCEP(mtbCEP.Text))
                {
                    clnUtil.definirEndereco(mtbCEP.Text, ctlLogradouro, ctlBairro, ctlCidade, cboUF, ctlNr, ctlComplemento);
                }
            };
        }
Example #11
0
        public static void definirCEP(uiTextBox mtbCEP, System.Windows.Forms.Control ctlLogradouro, System.Windows.Forms.Control ctlBairro, System.Windows.Forms.Control ctlCidade, System.Windows.Forms.Control cboUF, System.Windows.Forms.Control ctlNr, System.Windows.Forms.Control ctlComplemento)
        {
            Disable(ctlLogradouro);
            Disable(ctlBairro);
            Disable(ctlCidade);
            Disable(cboUF);

            //addUFs(cboUF);
            mtbCEP.Validated += (object sender, EventArgs e) =>
            {
                if (UtilValidar.validarCEP(mtbCEP.Text))
                {
                    UtilCorreios.definirEndereco(mtbCEP.Text, ctlLogradouro, ctlBairro, ctlCidade, cboUF, ctlNr, ctlComplemento);
                }
            };
        }
Example #12
0
        private void btnCriar_Click(object sender, EventArgs e)
        {
            try
            {
                if (UtilValidar.CamposValidos(uiPanelCryptocurrency))
                {
                    if (newImage)
                    {
                        int archiveId = new Archive
                        {
                            Blob = UtilImage.ImageToByte(picCriptocurrency.Image),
                        }.Gravar();

                        int response = new Cryptocurency
                        {
                            ArchiveId             = archiveId,
                            Name                  = uiTxtCriptocurrency.Text,
                            Base                  = uiTxtCryptocurrencyBase.Text,
                            Description           = uiTxtDescription.Text,
                            CryptocurrencyBalance = UtilConvert.ToInt(uiTxtCryptocurrencyBalance.Text),
                            CryptocurrencyUnit    = uiTxtCryptocurrencyUnit.Text
                        }.Gravar();

                        new Alert(String.Format("A criptomoeda {0} foi cadastrada.", uiTxtCriptocurrency.Text), uiCSB.Toastr.Type.Info);
                        newImage = false;
                    }
                    else
                    {
                        int response = new Cryptocurency
                        {
                            ArchiveId             = 1,
                            Name                  = uiTxtCriptocurrency.Text,
                            Base                  = uiTxtCryptocurrencyBase.Text,
                            Description           = uiTxtDescription.Text,
                            CryptocurrencyBalance = UtilConvert.ToInt(uiTxtCryptocurrencyBalance.Text),
                            CryptocurrencyUnit    = uiTxtCryptocurrencyUnit.Text
                        }.Gravar();

                        new Alert(String.Format("A criptomoeda {0} foi cadastrada.", uiTxtCriptocurrency.Text), uiCSB.Toastr.Type.Info);
                    }
                }
            }
            catch (Exception ex)
            {
                new Alert(ex.Message, uiCSB.Toastr.Type.Warning);
            }
        }
Example #13
0
        private string validarRecuperacao(string token, string email, string cpf, string senha)
        {
            StringBuilder errosBuilder = new StringBuilder();

            if (UtilValidar.vazio(cpf))
            {
                errosBuilder.Append("É necessário informar um CPF.");
            }
            else if (!UtilValidar.validarCPF(cpf))
            {
                errosBuilder.Append("É necessário informar um CPF válido.");
            }

            if (UtilValidar.vazio(email))
            {
                errosBuilder.Append("É necessário informar o email.");
            }
            else if (!UtilValidar.validarEmail(email))
            {
                errosBuilder.Append("É necessário informar um email válido.");
            }

            if (UtilValidar.vazio(senha))
            {
                errosBuilder.Append("É necessário informar a nova senha.");
            }
            else if (senha.Length < 6)
            {
                errosBuilder.Append("A senha precisa ter no minimo 6 caracteres.");
            }

            if (UtilValidar.vazio(token))
            {
                errosBuilder.Append("É necessário informar o token.");
            }
            else if (!tokenValidade(token))
            {
                errosBuilder.Append("O token informado já expirou.");
            }

            return(errosBuilder.ToString());
        }
Example #14
0
        private string validarCPFEmail(string cpf, string email)
        {
            StringBuilder errosBuilder = new StringBuilder();

            if (UtilValidar.vazio(cpf))
            {
                errosBuilder.Append("É necessário informar um CPF.");
            }
            else if (!UtilValidar.validarCPF(cpf))
            {
                errosBuilder.Append("É necessário informar um CPF válido.");
            }

            if (UtilValidar.vazio(email))
            {
                errosBuilder.Append("É necessário informar o email.");
            }
            else if (!UtilValidar.validarEmail(email))
            {
                errosBuilder.Append("É necessário informar um email válido.");
            }

            return(errosBuilder.ToString());
        }
Example #15
0
 private void btnCriar_ClickAsync(object sender, EventArgs e)
 {
     try
     {
         if (UtilValidar.CamposValidos(uiPanelDados))
         {
             if (newImage)
             {
                 new Employee
                 {
                     ArchiveId = new Archive {
                         Blob = UtilImage.ImageToByte(picProfilePhoto.Image)
                     }.Gravar(),
                     Words         = UtilConvert.ToString(RandomWordsAsync(12)),
                     WordsLanguage = UtilConvert.ToString("en-US"),
                     FirstName     = UtilConvert.ToString(uiTxtPNome.Text),
                     LastName      = UtilConvert.ToString(uiTxtUNome.Text),
                     DateBirth     = UtilConvert.ToDateTime(uiTxtDataNasc.Text),
                     Gender        = UtilConvert.ToChar(uiTxtSexo.Text),
                     CPF           = uiTxtCPF.Text,
                     RG            = uiTxtRG.Text,
                     Email         = uiTxtEmail.Text,
                     StreetLine    = uiTxtLogradouro.Text,
                     //uiTxtNumero.Text,
                     //uiTxtBairro.Text,
                     Country      = uiTxtPais.Text,
                     City         = uiTxtCidade.Text,
                     Neighborhood = uiTxtBairro.Text,
                     Region       = uiTxtEstado.Text,
                     Number       = uiTxtNumero.Text,
                     PostCode     = uiTxtCep.Text,
                     MobileNumber = uiTxtTelCel.Text,
                     PhoneNumber  = uiTxtTelFixo.Text
                 }.Gravar();
             }
             else
             {
                 new Employee
                 {
                     ArchiveId     = UtilConvert.ToInt(lblArchiveId.Text),
                     Words         = UtilConvert.ToString(RandomWordsAsync(12)),
                     WordsLanguage = UtilConvert.ToString("en-US"),
                     FirstName     = UtilConvert.ToString(uiTxtPNome.Text),
                     LastName      = UtilConvert.ToString(uiTxtUNome.Text),
                     DateBirth     = UtilConvert.ToDateTime(uiTxtDataNasc.Text),
                     Gender        = UtilConvert.ToChar(uiTxtSexo.Text),
                     CPF           = uiTxtCPF.Text,
                     RG            = uiTxtRG.Text,
                     Email         = uiTxtEmail.Text,
                     StreetLine    = uiTxtLogradouro.Text,
                     //uiTxtNumero.Text,
                     //uiTxtBairro.Text,
                     Country      = uiTxtPais.Text,
                     City         = uiTxtCidade.Text,
                     Neighborhood = uiTxtBairro.Text,
                     Region       = uiTxtEstado.Text,
                     Number       = uiTxtNumero.Text,
                     PostCode     = uiTxtCep.Text,
                     MobileNumber = uiTxtTelCel.Text,
                     PhoneNumber  = uiTxtTelFixo.Text
                 }.Gravar();
             }
         }
     }
     catch (NullReferenceException)
     {
         new Alert("Preencha todos os campos antes de atualizar.", Type.Warning);
     }
     catch (Exception ex)
     {
         new Alert(ex.Message, Type.Warning);
     }
 }
Example #16
0
        private string validarDados(string nome, string email, string senha, string cpf,
                                    string celular, string cartaoNumero, string cartaoValidade, string cartaoCVV)
        {
            StringBuilder errosBuilder = new StringBuilder();

            if (UtilValidar.vazio(nome))
            {
                errosBuilder.Append("É necessário informar o nome.");
            }
            else if (nome.Length < 10)
            {
                errosBuilder.Append("O nome informado é inválido.");
            }

            if (UtilValidar.vazio(email))
            {
                errosBuilder.Append("É necessário informar o e-mail.");
            }
            else if (!UtilValidar.validarEmail(email))
            {
                errosBuilder.Append("O e-mail informado é inválido.");
            }

            if (senha != null)
            {
                if (UtilValidar.vazio(senha))
                {
                    errosBuilder.Append("É necessário informar a senha.");
                }
                else if (senha.Length < 6)
                {
                    errosBuilder.Append("A senha precisa ter no minimo 6 caracteres.");
                }
            }

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

            if (UtilValidar.vazio(celular))
            {
                errosBuilder.Append("É necessário informar o celular.");
            }
            else if (!UtilValidar.validarCelular(celular))
            {
                errosBuilder.Append("O celular informado é inválido.");
            }

            if (UtilValidar.vazio(cartaoNumero))
            {
                errosBuilder.Append("É necessário informar o número do cartão.");
            }
            else if (cartaoNumero.ToString().Length != 16)
            {
                errosBuilder.Append("O número do cartão informado é inválido.");
            }

            if (UtilValidar.vazio(cartaoValidade))
            {
                errosBuilder.Append("É necessário informar a validade do cartão.");
            }
            else if (cartaoValidade.ToString().Length != 5)
            {
                errosBuilder.Append("A validade do cartão informada é inválida.");
            }
            else if (!UtilValidar.validarCartaoValidade(cartaoValidade))
            {
                errosBuilder.Append("A validade do cartão informada é inválida.");
            }

            if (UtilValidar.vazio(cartaoCVV))
            {
                errosBuilder.Append("É necessário informar o CVV do cartão.");
            }
            else if (cartaoCVV.ToString().Length != 3)
            {
                errosBuilder.Append("O CVV do cartão informado é inválido.");
            }

            return(errosBuilder.ToString());
        }
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
            public bool validar(Control control)
            {
                if (!control.Visible || !control.Enabled)
                {
                    return(true);
                }
                String conteudo = clnUtil.obterConteudo(control);

                if (!_validacoes.Contains(Validacao.OBRIGATORIO) && UtilValidar.vazio(conteudo))
                {
                    return(true);
                }

                bool valido = true;

                _motivo  = "";
                conteudo = control.Text;
                foreach (Validacao tipo in _validacoes)
                {
                    bool   val = true;
                    String res = "";
                    switch (tipo)
                    {
                    case Validacao.OBRIGATORIO:
                        val = !UtilValidar.vazio(conteudo);
                        res = "precisa ser preenchido.";
                        break;

                    case Validacao.EMAIL:
                        val = UtilValidar.validarEmail(conteudo);
                        res = "deve conter um e-mail válido.";
                        break;

                    case Validacao.CPF:
                        val = UtilValidar.validarCPF(conteudo);
                        res = "deve conter um CPF válido.";
                        break;

                    case Validacao.CNPJ:
                        val = UtilValidar.validarCNPJ(conteudo);
                        res = "deve conter um CNPJ válido.";
                        break;

                    case Validacao.CEP:
                        val = UtilValidar.validarCEP(conteudo);
                        res = "deve conter um CEP válido.";
                        break;

                    case Validacao.INT:
                        val = UtilValidar.validarInt(conteudo);
                        res = "deve conter um número inteiro.";
                        break;

                    case Validacao.QUANTIDADE:
                        val = UtilConvert.ToInt(conteudo) > 0;
                        res = "deve conter um número maior que ZERO.";
                        break;

                    case Validacao.DATA:
                        val = UtilValidar.validarData(conteudo);
                        res = "deve conter uma data válida";
                        break;

                    case Validacao.DATA_NASC:
                        val = UtilValidar.validarDataNasc(conteudo);
                        res = "deve conter uma data da nascimento.";
                        break;

                    case Validacao.CELULAR:
                        val = UtilValidar.validarCelular(conteudo);
                        res = "deve conter um número de celular válido.";
                        break;

                    case Validacao.TELEFONE:
                        val = UtilValidar.validarTelefone(conteudo);
                        res = "deve conter um número de telefone válido.";
                        break;

                    case Validacao.DATA_FUTURA:
                        val = UtilValidar.validarDataFutura(conteudo);
                        res = "deve conter uma data futura.";
                        break;

                    case Validacao.HORA:
                        val = UtilValidar.validarHora(conteudo);
                        res = "deve conter uma hora válida.";
                        break;

                    case Validacao.VALOR:
                        val = UtilValidar.validarValor(conteudo);
                        res = "deve conter um valor válido.";
                        break;

                    case Validacao.DOUBLE:
                        val = UtilValidar.validarDouble(conteudo);
                        res = "deve conter um número decimal válido.";
                        break;
                    }
                    if (!val)
                    {
                        valido  = false;
                        _motivo = res;
                        break;
                    }
                }

                return(valido);
            }