public IRLib.Codigo.Brainiac.Retorno CadastroValido() { if (!ValidacaoAtiva()) { return new IRLib.Codigo.Brainiac.Retorno() { TipoRetorno = IRLib.Codigo.Brainiac.Enumeradores.EnumTipoRetorno.Ok } } ; if (this.CPF.Valor.Length == 0) { return new IRLib.Codigo.Brainiac.Retorno() { TipoRetorno = IRLib.Codigo.Brainiac.Enumeradores.EnumTipoRetorno.ImplicarErro, Mensagem = "CPF Inválido." } } ; if (this.StatusConsulta == enumStatusCPF.Confirmado) { return new IRLib.Codigo.Brainiac.Retorno() { TipoRetorno = IRLib.Codigo.Brainiac.Enumeradores.EnumTipoRetorno.Ok } } ; IRLib.Codigo.Brainiac.Retorno retornoBrainiac = CadastroValido(this.CPF.Valor, this.Nome.Valor, this.StatusConsulta); switch (retornoBrainiac.TipoRetorno) { case IRLib.Codigo.Brainiac.Enumeradores.EnumTipoRetorno.Ok: // Confirmado, salva no banco. this.StatusConsulta = enumStatusCPF.Confirmado; SalvarConsultaCPF(this.Control.ID.ToString()); break; case IRLib.Codigo.Brainiac.Enumeradores.EnumTipoRetorno.ImplicarErro: // cadastro inválido! this.StatusConsulta = enumStatusCPF.Invalido; SalvarConsultaCPF(this.Control.ID.ToString()); break; case IRLib.Codigo.Brainiac.Enumeradores.EnumTipoRetorno.Parcial: break; default: throw new Exception("Falha ao consultar o CPF!"); } return(retornoBrainiac); }
public IRLib.Codigo.Brainiac.Retorno CadastroEntregaValido() { if (!ValidacaoAtiva()) { return new IRLib.Codigo.Brainiac.Retorno() { TipoRetorno = IRLib.Codigo.Brainiac.Enumeradores.EnumTipoRetorno.Ok } } ; if (this.Pais.Valor != "Brasil") { return new IRLib.Codigo.Brainiac.Retorno() { TipoRetorno = IRLib.Codigo.Brainiac.Enumeradores.EnumTipoRetorno.Ok } } ; // Método só estará disponível para utilização se o objeto estiver populado. if (this.Control.ID.Equals(0)) { throw new ArgumentException("Cliente não encontrado para validação!"); } ////Compara os nomes e atribui status; string retNomeConsultadoEntrega = string.Empty; IRLib.Codigo.Brainiac.Retorno retornoBrainiac = null; //Entrou com Nome de entrega Igual ao do Cliente -- Passa direto sem precisar validar novamente com a SCSP if (this.CPFEntrega.Valor == this.CPF.Valor && Utilitario.CompararSemAcentos(this.Nome.Valor, this.NomeEntrega.Valor) == 0 && this.StatusConsulta == enumStatusCPF.Confirmado) { retornoBrainiac = new IRLib.Codigo.Brainiac.Gerenciador().IniciarNomes(this.Nome.Valor, this.NomeEntrega.Valor); switch (retornoBrainiac.TipoRetorno) { case IRLib.Codigo.Brainiac.Enumeradores.EnumTipoRetorno.Ok: this.CPFConsultadoEntrega.Valor = this.CPFEntrega.Valor; this.NomeConsultadoEntrega.Valor = this.NomeEntrega.Valor; base.StatusConsultaEntrega.Valor = (int)enumStatusCPF.Confirmado; SalvarConsultaCPFEntrega(); break; case IRLib.Codigo.Brainiac.Enumeradores.EnumTipoRetorno.ImplicarErro: base.StatusConsultaEntrega.Valor = (int)enumStatusCPF.Invalido; this.CPFConsultadoEntrega.Valor = this.CPFEntrega.Valor; this.NomeConsultadoEntrega.Valor = this.NomeEntrega.Valor; SalvarConsultaCPFEntrega(); break; } return(retornoBrainiac); } // 1.0 Verifica se os valores de entrega anteriores sao diferentes dos que estao agora, se estiver, 1.1 ou 1.2 else if (this.CPFEntrega.Valor != this.CPFConsultadoEntrega.Valor || (Utilitario.CompararSemAcentos(this.NomeEntrega.Valor.Trim(), this.NomeConsultadoEntrega.Valor.Trim()) != 0) || this.StatusConsultaEntrega != enumStatusCPF.Confirmado) { retornoBrainiac = this.CadastroValido(this.CPFEntrega.Valor, this.NomeEntrega.Valor, this.CPFConsultadoEntrega.Valor, this.NomeConsultadoEntrega.Valor, this.StatusConsultaEntrega == enumStatusCPF.NaoConsultado ? enumStatusCPF.NaoConsultado : enumStatusCPF.Invalido, ref retNomeConsultadoEntrega); switch (retornoBrainiac.TipoRetorno) { //1.1 Verifica o Cadastro forcando o Status Invalido case IRLib.Codigo.Brainiac.Enumeradores.EnumTipoRetorno.Ok: // Confirmado, salva no banco. sem precisar ir até a SCSP - Ja havia sido consultado. this.CPFConsultadoEntrega.Valor = this.CPFEntrega.Valor; this.NomeConsultadoEntrega.Valor = retNomeConsultadoEntrega; base.StatusConsultaEntrega.Valor = (int)enumStatusCPF.Confirmado; SalvarConsultaCPFEntrega(); break; //1.2 Atribui o Status Invalido para mostrar no Retorno case IRLib.Codigo.Brainiac.Enumeradores.EnumTipoRetorno.ImplicarErro: base.StatusConsultaEntrega.Valor = (int)enumStatusCPF.Invalido; if (!string.IsNullOrEmpty(retNomeConsultadoEntrega)) { this.CPFConsultadoEntrega.Valor = this.CPFEntrega.Valor; this.NomeConsultadoEntrega.Valor = retNomeConsultadoEntrega; } SalvarConsultaCPFEntrega(); break; case IRLib.Codigo.Brainiac.Enumeradores.EnumTipoRetorno.Parcial: break; default: throw new Exception("Falha ao consultar o CPF!"); } return(retornoBrainiac); } //Utiliziou o mesmo Cliente da compra anterior nesta.. else if (this.StatusConsultaEntrega == enumStatusCPF.Confirmado) { return new IRLib.Codigo.Brainiac.Retorno() { TipoRetorno = IRLib.Codigo.Brainiac.Enumeradores.EnumTipoRetorno.Ok } } ; //Fez a pesquisa no SCPC no só que colocou nome errado, como esta digitado corretamente, só atribui o status de Confirmado else { this.StatusConsultaEntrega = enumStatusCPF.Confirmado; this.SalvarConsultaCPFEntrega(); return(new IRLib.Codigo.Brainiac.Retorno() { TipoRetorno = IRLib.Codigo.Brainiac.Enumeradores.EnumTipoRetorno.Ok }); } }
public IRLib.Codigo.Brainiac.Retorno CadastroValido() { if (!ValidacaoAtiva()) { return new IRLib.Codigo.Brainiac.Retorno() { TipoRetorno = IRLib.Codigo.Brainiac.Enumeradores.EnumTipoRetorno.Ok } } ; if (this.Pais.Valor != "Brasil") { return new IRLib.Codigo.Brainiac.Retorno() { TipoRetorno = IRLib.Codigo.Brainiac.Enumeradores.EnumTipoRetorno.Ok } } ; if (this.CPF.Valor.Length == 0) { return new IRLib.Codigo.Brainiac.Retorno() { TipoRetorno = IRLib.Codigo.Brainiac.Enumeradores.EnumTipoRetorno.ImplicarErro, Mensagem = "CPF Inválido." } } ; if (this.StatusConsulta == enumStatusCPF.Confirmado) { return new IRLib.Codigo.Brainiac.Retorno() { TipoRetorno = IRLib.Codigo.Brainiac.Enumeradores.EnumTipoRetorno.Ok } } ; string retNomeConsultado = string.Empty; int[] clienteID = BuscarClienteCPF(this.CPF.Valor); IRLib.Codigo.Brainiac.Retorno retornoBrainiac = CadastroValido(this.CPF.Valor, this.Nome.Valor, this.CPFConsultado.Valor, this.NomeConsultado.Valor, this.StatusConsulta, ref retNomeConsultado); switch (retornoBrainiac.TipoRetorno) { case IRLib.Codigo.Brainiac.Enumeradores.EnumTipoRetorno.Ok: // Confirmado, salva no banco. this.CPFConsultado.Valor = this.CPF.Valor; this.NomeConsultado.Valor = retNomeConsultado; this.StatusConsulta = enumStatusCPF.Confirmado; SalvarConsultaCPF(clienteID[1].ToString()); break; case IRLib.Codigo.Brainiac.Enumeradores.EnumTipoRetorno.ImplicarErro: // cadastro inválido! this.CPFConsultado.Valor = this.CPF.Valor; this.NomeConsultado.Valor = retNomeConsultado; this.StatusConsulta = enumStatusCPF.Invalido; SalvarConsultaCPF(clienteID[1].ToString()); break; case IRLib.Codigo.Brainiac.Enumeradores.EnumTipoRetorno.Parcial: break; default: throw new Exception("Falha ao consultar o CPF!"); } return(retornoBrainiac); }