예제 #1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (HttpContext.Current.User.Identity.IsAuthenticated == false)
            {
                Response.Redirect("~/Account/Login.aspx");
            }

            if (!IsPostBack)
            {
                String cnpj = Request.QueryString["codigo"];

                if (cnpj == null || cnpj == "")
                {
                    Response.Redirect("~/PesquisaInicio.aspx");
                }

                Classes.Fornecedor fornecedor = new Classes.Fornecedor();

                fornecedor.CarregaDados(cnpj);

                fornecedor.MarcaVisitado(System.Web.HttpContext.Current.User.Identity.Name);

                LabelCNPJ.Text        = fornecedor.Cnpj;
                LabelRazaoSocial.Text = fornecedor.RazaoSocial;

                ButtonDenunciar.OnClientClick = "Denunciar();return false;";

                ButtonListarDeputados.OnClientClick  = "window.parent.addTabDocumentos('" + fornecedor.Cnpj + "','" + fornecedor.RazaoSocial + "', 0);return false;";
                ButtonListarDocumentos.OnClientClick = "window.parent.addTabDocumentos('" + fornecedor.Cnpj + "','" + fornecedor.RazaoSocial + "', 1);return false;";
                ButtonListarDoacoes.Visible          = fornecedor.Doador;
                ButtonListarDoacoes.OnClientClick    = "Doacoes();return false;";

                StringBuilder url = new StringBuilder();
                url.Append("http://www.google.com.br/search?q=");
                url.Append("\"" + fornecedor.RazaoSocial + "\"");

                ButtonPesquisa.OnClientClick = "window.open('" + url.ToString() + "');return false;";

                Denuncia denuncia = new Denuncia();
                denuncia.DenunciasFornecedorResumida(GridViewDenuncias, fornecedor.Cnpj);

                if (GridViewDenuncias.Rows.Count > 0)
                {
                    PanelExisteDenuncia.Visible = true;

                    if (GridViewDenuncias.Rows.Count == 1)
                    {
                        dvDenuncias.InnerText = "Este fornecedor possui 1 denúncia. Evite enviar denúncias repetidas caso existam outras recentes.";
                    }
                    else
                    {
                        dvDenuncias.InnerText = "Este fornecedor possui " + GridViewDenuncias.Rows.Count.ToString() + " denúncias. Evite enviar denúncias repetidas caso existam outras recentes.";
                    }
                }
            }

            GridViewDenuncias.PreRender += GridViewDenuncias_PreRender;
        }
예제 #2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (HttpContext.Current.User.Identity.IsAuthenticated == false)
                Response.Redirect("~/Account/Login.aspx");

            if (!IsPostBack)
            {
                String cnpj = Request.QueryString["codigo"];

                if (cnpj == null || cnpj == "")
                    Response.Redirect("~/PesquisaInicio.aspx");
                
                Classes.Fornecedor fornecedor = new Classes.Fornecedor();

                fornecedor.CarregaDados(cnpj);

                fornecedor.MarcaVisitado(System.Web.HttpContext.Current.User.Identity.Name);

                LabelCNPJ.Text = fornecedor.Cnpj;
                LabelRazaoSocial.Text = fornecedor.RazaoSocial;

                ButtonDenunciar.OnClientClick = "Denunciar();return false;";

                ButtonListarDeputados.OnClientClick = "window.parent.addTabDocumentos('" + fornecedor.Cnpj + "','" + fornecedor.RazaoSocial + "', 0);return false;";
                ButtonListarDocumentos.OnClientClick = "window.parent.addTabDocumentos('" + fornecedor.Cnpj + "','" + fornecedor.RazaoSocial + "', 1);return false;";
                ButtonListarDoacoes.Visible = fornecedor.Doador;
                ButtonListarDoacoes.OnClientClick = "Doacoes();return false;";

                StringBuilder url = new StringBuilder();
                url.Append("http://www.google.com.br/search?q=");
                url.Append("\"" + fornecedor.RazaoSocial + "\"");

                ButtonPesquisa.OnClientClick = "window.open('" + url.ToString() + "');return false;";

                Denuncia denuncia = new Denuncia();
                denuncia.DenunciasFornecedorResumida(GridViewDenuncias, fornecedor.Cnpj);

                if (GridViewDenuncias.Rows.Count > 0)
                {
                    PanelExisteDenuncia.Visible = true;

                    if (GridViewDenuncias.Rows.Count == 1)
                        dvDenuncias.InnerText = "Este fornecedor possui 1 denúncia. Evite enviar denúncias repetidas caso existam outras recentes.";
                    else
                        dvDenuncias.InnerText = "Este fornecedor possui " + GridViewDenuncias.Rows.Count.ToString() + " denúncias. Evite enviar denúncias repetidas caso existam outras recentes.";
                }
                
            }

            GridViewDenuncias.PreRender += GridViewDenuncias_PreRender;
        }
        protected void GridViewFornecedores_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            if (e.CommandName == "Select")
            {
                Int32 index = Convert.ToInt32(e.CommandArgument);

                Fornecedor fornecedor = new Fornecedor();

                if (fornecedor.ExcluiSolicitacaoFoto(GridViewFornecedores.Rows[index].Cells[3].Text))
                {
                    fornecedor.CarregaCidadesPendenciasFornecedor(GridViewFornecedores);
                }
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!System.Web.HttpContext.Current.User.Identity.IsAuthenticated || !System.Web.HttpContext.Current.User.IsInRole("REVISOR"))
                Response.Redirect("~/Default.aspx");

            if (!IsPostBack)
            {
                GridViewFornecedores.EmptyDataText = "Nenhuma pendência foi incluída";

                Fornecedor fornecedor = new Fornecedor();
                fornecedor.CarregaCidadesPendenciasFornecedor(GridViewFornecedores);
            }

        }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                GridViewCidades.EmptyDataText = "Nenhuma pendência foi incluída";

                Fornecedor fornecedor = new Fornecedor();
                fornecedor.CarregaCidadesPendencias(GridViewCidades);
            }

            if (!System.Web.HttpContext.Current.User.Identity.IsAuthenticated || !System.Web.HttpContext.Current.User.IsInRole("NOTICIA"))
            {
                ButtonGerenciar.Visible = false;
            }

            GridViewCidades.PreRender += GridViewCidades_PreRender;
        }
예제 #6
0
        public Fornecedor MontarObjFornecedor(string cnpj, string responseFromServer)
        {
            Fornecedor fornecedor = new Fornecedor();

            if (responseFromServer.IndexOf("NOME EMPRESARIAL") > 0)
            {
                string textoHTML = Regex.Replace(responseFromServer, @"<[^>]*>", string.Empty);
                textoHTML = textoHTML.Substring(textoHTML.IndexOf("NÚMERO DE INSCRIÇÃO"));
                textoHTML = textoHTML.Substring(0, textoHTML.IndexOf("Aprovado pela Instrução Normativa")).Replace("NÚMERO DE INSCRIÇÃO", "").Trim();
                textoHTML = Regex.Replace(textoHTML, "&nbsp;", string.Empty).Trim();
                fornecedor.Cnpj = cnpj; //textoHTML.Substring(0, textoHTML.IndexOf("\r\n"));

                textoHTML = textoHTML.Replace(fornecedor.Cnpj, "");
                fornecedor.Matriz = (textoHTML.Substring(0, textoHTML.IndexOf("COMPROVANTE")).Trim().Equals("MATRIZ")) ? 1 : 0;

                textoHTML = textoHTML.Substring(textoHTML.IndexOf("DATA DE ABERTURA")).Replace("DATA DE ABERTURA", "").Trim();
                fornecedor.DataAbertura = textoHTML.Substring(0, textoHTML.IndexOf("\r\n")).Trim();

                textoHTML = textoHTML.Substring(textoHTML.IndexOf("NOME EMPRESARIAL")).Replace("NOME EMPRESARIAL", "").Trim();
                fornecedor.RazaoSocial = textoHTML.Substring(0, textoHTML.IndexOf("\r\n")).Trim();

                textoHTML = textoHTML.Substring(textoHTML.IndexOf("(NOME DE FANTASIA)")).Replace("(NOME DE FANTASIA)", "").Trim();
                fornecedor.NomeFantasia = textoHTML.Substring(0, textoHTML.IndexOf("\r\n")).Trim();
                if (fornecedor.NomeFantasia.Substring(0, 1) == "*")
                    fornecedor.NomeFantasia = fornecedor.RazaoSocial;

                textoHTML = textoHTML.Substring(textoHTML.IndexOf("CÓDIGO E DESCRIÇÃO DA ATIVIDADE ECONÔMICA PRINCIPAL")).Replace("CÓDIGO E DESCRIÇÃO DA ATIVIDADE ECONÔMICA PRINCIPAL", "").Trim();
                fornecedor.AtividadePrincipal = textoHTML.Substring(0, textoHTML.IndexOf("\r\n")).Trim();
                if (fornecedor.AtividadePrincipal.Substring(0, 1) == "*")
                    fornecedor.AtividadePrincipal = "";

                textoHTML = textoHTML.Substring(textoHTML.IndexOf("CÓDIGO E DESCRIÇÃO DAS ATIVIDADES ECONÔMICAS SECUNDÁRIAS")).Replace("CÓDIGO E DESCRIÇÃO DAS ATIVIDADES ECONÔMICAS SECUNDÁRIAS", "").Trim();
                fornecedor.AtividadeSecundaria01 = textoHTML.Substring(0, textoHTML.IndexOf("CÓDIGO E DESCRIÇÃO DA NATUREZA JURÍDICA")).Trim();
                if (fornecedor.AtividadeSecundaria01.Equals("Não informada"))
                    fornecedor.AtividadeSecundaria01 = "";
                else
                {
                    fornecedor.AtividadeSecundaria01 = fornecedor.AtividadeSecundaria01.Replace("  ", "").Replace("\t", "").Replace("\r\n\r\n\r\n\r\n", "");
                    var atividadeSecundaria = fornecedor.AtividadeSecundaria01.Split(new string[] { "\r\n" }, StringSplitOptions.None);
                    try
                    {
                        fornecedor.AtividadeSecundaria01 = atividadeSecundaria[0];
                        fornecedor.AtividadeSecundaria02 = atividadeSecundaria[1];
                        fornecedor.AtividadeSecundaria03 = atividadeSecundaria[2];
                        fornecedor.AtividadeSecundaria04 = atividadeSecundaria[3];
                        fornecedor.AtividadeSecundaria05 = atividadeSecundaria[4];
                        fornecedor.AtividadeSecundaria06 = atividadeSecundaria[5];
                        fornecedor.AtividadeSecundaria07 = atividadeSecundaria[6];
                        fornecedor.AtividadeSecundaria08 = atividadeSecundaria[7];
                        fornecedor.AtividadeSecundaria09 = atividadeSecundaria[8];
                        fornecedor.AtividadeSecundaria10 = atividadeSecundaria[9];
                        fornecedor.AtividadeSecundaria11 = atividadeSecundaria[10];
                        fornecedor.AtividadeSecundaria12 = atividadeSecundaria[11];
                        fornecedor.AtividadeSecundaria13 = atividadeSecundaria[12];
                        fornecedor.AtividadeSecundaria14 = atividadeSecundaria[13];
                        fornecedor.AtividadeSecundaria15 = atividadeSecundaria[14];
                        fornecedor.AtividadeSecundaria16 = atividadeSecundaria[15];
                        fornecedor.AtividadeSecundaria17 = atividadeSecundaria[16];
                        fornecedor.AtividadeSecundaria18 = atividadeSecundaria[17];
                        fornecedor.AtividadeSecundaria19 = atividadeSecundaria[18];
                        fornecedor.AtividadeSecundaria20 = atividadeSecundaria[19];
                    }
                    catch (IndexOutOfRangeException)
                    { }
                }

                textoHTML = textoHTML.Substring(textoHTML.IndexOf("CÓDIGO E DESCRIÇÃO DA NATUREZA JURÍDICA")).Replace("CÓDIGO E DESCRIÇÃO DA NATUREZA JURÍDICA", "").Trim();
                fornecedor.NaturezaJuridica = textoHTML.Substring(0, textoHTML.IndexOf("PORTE DA EMPRESA")).Replace("PORTE DA EMPRESA", "").Trim();
                if (fornecedor.NaturezaJuridica.Equals("LOGRADOURO"))
                    fornecedor.NaturezaJuridica = "";

                textoHTML = textoHTML.Substring(textoHTML.IndexOf("LOGRADOURO")).Replace("LOGRADOURO", "").Trim();
                fornecedor.Logradouro = textoHTML.Substring(0, textoHTML.IndexOf("\r\n")).Trim();
                if (fornecedor.Logradouro.Equals("NÚMERO"))
                    fornecedor.Logradouro = "";

                textoHTML = textoHTML.Substring(textoHTML.IndexOf("NÚMERO")).Replace("NÚMERO", "").Trim();
                fornecedor.Numero = textoHTML.Substring(0, textoHTML.IndexOf("\r\n")).Trim();
                if (fornecedor.Numero.Equals("COMPLEMENTO"))
                    fornecedor.Numero = "";

                textoHTML = textoHTML.Substring(textoHTML.IndexOf("COMPLEMENTO")).Replace("COMPLEMENTO", "").Trim();
                fornecedor.Complemento = textoHTML.Substring(0, textoHTML.IndexOf("\r\n")).Trim();
                if (fornecedor.Complemento.Equals("CEP"))
                    fornecedor.Complemento = "";

                textoHTML = textoHTML.Substring(textoHTML.IndexOf("CEP")).Replace("CEP", "").Trim();
                fornecedor.Cep = textoHTML.Substring(0, textoHTML.IndexOf("\r\n")).Trim().Replace(".", "");
                if (fornecedor.Cep.Equals("DISTRITO"))
                    fornecedor.Cep = "";

                textoHTML = textoHTML.Substring(textoHTML.IndexOf("DISTRITO")).Replace("DISTRITO", "").Trim();
                fornecedor.Bairro = textoHTML.Substring(0, textoHTML.IndexOf("\r\n")).Trim();
                if (fornecedor.Bairro.Equals("MUNICÍPIO"))
                    fornecedor.Bairro = "";

                textoHTML = textoHTML.Substring(textoHTML.IndexOf("MUNICÍPIO")).Replace("MUNICÍPIO", "").Trim();
                fornecedor.Cidade = textoHTML.Substring(0, textoHTML.IndexOf("\r\n")).Trim();
                if (fornecedor.Cidade.Equals("UF"))
                    fornecedor.Cidade = "";

                textoHTML = textoHTML.Substring(textoHTML.IndexOf("UF")).Replace("UF", "").Trim();
                fornecedor.Uf = textoHTML.Substring(0, textoHTML.IndexOf("\r\n")).Trim();
                if (fornecedor.Uf.Equals("ENDEREÇO ELETRÔNICO"))
                    fornecedor.Uf = "";

                textoHTML = textoHTML.Substring(textoHTML.IndexOf("ENDEREÇO ELETRÔNICO")).Replace("ENDEREÇO ELETRÔNICO", "").Trim();
                fornecedor.Email = textoHTML.Substring(0, textoHTML.IndexOf("\r\n")).Trim();
                if (fornecedor.Email.Equals("TELEFONE"))
                    fornecedor.Email = "";

                textoHTML = textoHTML.Substring(textoHTML.IndexOf("TELEFONE")).Replace("TELEFONE", "").Trim();
                fornecedor.Telefone = textoHTML.Substring(0, textoHTML.IndexOf("\r\n")).Trim();
                if (fornecedor.Telefone.Equals("ENTE FEDERATIVO RESPONSÁVEL(EFR)"))
                    fornecedor.Telefone = "";

                textoHTML = textoHTML.Substring(textoHTML.IndexOf("ENTE FEDERATIVO RESPONSÁVEL (EFR)")).Replace("ENTE FEDERATIVO RESPONSÁVEL (EFR)", "").Trim();
                fornecedor.EnteFederativoResponsavel = textoHTML.Substring(0, textoHTML.IndexOf("\r\n")).Trim();
                if (fornecedor.EnteFederativoResponsavel.Substring(0, 1) == "*")
                    fornecedor.EnteFederativoResponsavel = "";

                textoHTML = ReplaceFirst(textoHTML.Substring(textoHTML.IndexOf("SITUAÇÃO CADASTRAL")), "SITUAÇÃO CADASTRAL", "").Trim();
                fornecedor.Situacao = textoHTML.Substring(0, textoHTML.IndexOf("\r\n")).Trim();
                if (fornecedor.Situacao.Equals("DATA DA SITUAÇÃO CADASTRAL"))
                    fornecedor.Situacao = "";

                textoHTML = textoHTML.Substring(textoHTML.IndexOf("DATA DA SITUAÇÃO CADASTRAL")).Replace("DATA DA SITUAÇÃO CADASTRAL", "").Trim();
                fornecedor.DataSituacao = textoHTML.Substring(0, textoHTML.IndexOf("\r\n")).Trim();
                if (fornecedor.DataSituacao.Equals("MOTIVO DE SITUAÇÃO CADASTRAL"))
                    fornecedor.DataSituacao = "";

                textoHTML = textoHTML.Substring(textoHTML.IndexOf("MOTIVO DE SITUAÇÃO CADASTRAL")).Replace("MOTIVO DE SITUAÇÃO CADASTRAL", "").Trim();
                fornecedor.MotivoSituacao = textoHTML.Substring(0, textoHTML.IndexOf("\r\n")).Trim();
                if (fornecedor.MotivoSituacao.Equals("SITUAÇÃO ESPECIAL"))
                    fornecedor.MotivoSituacao = "";

                textoHTML = ReplaceFirst(textoHTML.Substring(textoHTML.IndexOf("SITUAÇÃO ESPECIAL")), "SITUAÇÃO ESPECIAL", "").Trim();
                fornecedor.SituacaoEspecial = textoHTML.Substring(0, textoHTML.IndexOf("\r\n")).Trim();
                if (fornecedor.SituacaoEspecial.Substring(0, 1) == "*")
                    fornecedor.SituacaoEspecial = "";

                textoHTML = textoHTML.Substring(textoHTML.IndexOf("DATA DA SITUAÇÃO ESPECIAL")).Replace("DATA DA SITUAÇÃO ESPECIAL", "").Trim();
                fornecedor.DataSituacaoEspecial = textoHTML;
                if (fornecedor.DataSituacaoEspecial.Substring(0, 1) == "*")
                    fornecedor.DataSituacaoEspecial = "";

                return fornecedor;

            }
            else if (responseFromServer.IndexOf("Verifique se o mesmo foi digitado corretamente") > 0)
            {
                throw new System.Exception("CNPJ não localizado junto a receita federal.");
            }
            else if (responseFromServer.IndexOf("Digite os caracteres acima:") > 0)
            {
                throw new System.Exception("Capcha incorreto.");
            }
            return null;
        }
예제 #7
0
        public void MontarObjFornecedorQuadroSocietario(Fornecedor fornecedor, string responseFromServer)
        {
            fornecedor.lstFornecedorQuadroSocietario = new List<FornecedorQuadroSocietario>();
            if (responseFromServer.IndexOf("CAPITAL SOCIAL:") > 0)
            {
                string textoHTML = Regex.Replace(responseFromServer, @"<[^>]*>", string.Empty);

                textoHTML = textoHTML.Substring(textoHTML.IndexOf("CAPITAL SOCIAL:")).Replace("CAPITAL SOCIAL:", "").Trim();
                fornecedor.CapitalSocial = textoHTML.Substring(0, textoHTML.IndexOf("\r\n")).Trim();
                if (!fornecedor.CapitalSocial.Contains("R$"))
                {
                    fornecedor.CapitalSocial = "";
                }

                while (textoHTML.Contains("Nome/Nome Empresarial:"))
                {
                    var fornecedorQuadroSocietario = new FornecedorQuadroSocietario();

                    textoHTML = ReplaceFirst(textoHTML.Substring(textoHTML.IndexOf("Nome/Nome Empresarial:")), "Nome/Nome Empresarial:", "").Trim();
                    fornecedorQuadroSocietario.Nome = textoHTML.Substring(0, textoHTML.IndexOf("\r\n")).Trim();

                    textoHTML = ReplaceFirst(textoHTML.Substring(textoHTML.IndexOf("Qualificação:")), "Qualificação:", "").Trim();
                    fornecedorQuadroSocietario.Qualificacao = textoHTML.Substring(0, textoHTML.IndexOf("\r\n")).Trim();

                    //Valor Opcional. ex: 07436265000186
                    if (textoHTML.IndexOf("Qualif. Rep. Legal:") > 0 &&
                        (textoHTML.IndexOf("Nome/Nome Empresarial:") < 0 || textoHTML.IndexOf("Qualif. Rep. Legal:") < textoHTML.IndexOf("Nome/Nome Empresarial:")))
                    {
                        textoHTML = ReplaceFirst(textoHTML.Substring(textoHTML.IndexOf("Qualif. Rep. Legal:")), "Qualif. Rep. Legal:", "").Trim();
                        fornecedorQuadroSocietario.QualificacaoRepresentanteLegal = textoHTML.Substring(0, textoHTML.IndexOf("\r\n")).Trim();
                    }

                    //Valor Opcional. ex: 07436265000186
                    if (textoHTML.IndexOf("Nome do Repres. Legal:") > 0 &&
                        (textoHTML.IndexOf("Nome/Nome Empresarial:") < 0 || textoHTML.IndexOf("Nome do Repres. Legal:") < textoHTML.IndexOf("Nome/Nome Empresarial:")))
                    {
                        textoHTML = ReplaceFirst(textoHTML.Substring(textoHTML.IndexOf("Nome do Repres. Legal:")), "Nome do Repres. Legal:", "").Trim();
                        fornecedorQuadroSocietario.NomeRepresentanteLegal = textoHTML.Substring(0, textoHTML.IndexOf("\r\n")).Trim();

                    }

                    fornecedor.lstFornecedorQuadroSocietario.Add(fornecedorQuadroSocietario);
                }
            }
        }
예제 #8
0
 protected void ButtonFotoExcluir_Click(object sender, EventArgs e)
 {
     Fornecedor fornecedor = new Fornecedor();
     if (fornecedor.ExcluiSolicitacaoFoto(LabelCNPJ.Text))
     {
         ButtonFotoIncluir.Visible = true;
         ButtonFotoExcluir.Visible = false;
         DenunciaValidator.ErrorMessage = "Pendência excluída com sucesso.";
         DenunciaValidator.IsValid = false;
     }
 }
        protected void Page_Load(object sender, EventArgs e)
        {
            GridViewDenuncias.PreRender += GridViewDenuncias_PreRender;

            if (!IsPostBack && Request.QueryString["codigo"] != null)
            {
                if (HttpContext.Current.User.Identity.IsAuthenticated == false)
                    Response.Redirect("~/Account/Login.aspx");

                String forcarConsulta;

                lblCNPJ.InnerText = Request.QueryString["codigo"];
                forcarConsulta = Request.QueryString["forcarConsulta"];

                if (lblCNPJ.InnerText == "")
                {
                    Response.Redirect("~/PesquisaInicio.aspx");
                }
                else
                {
                    Fornecedor fornecedor = new Fornecedor();
                    if (fornecedor.EstaAtualizado(lblCNPJ.InnerText) && fornecedor.CarregaDados(lblCNPJ.InnerText))
                    {
                        fornecedor.MarcaVisitado(System.Web.HttpContext.Current.User.Identity.Name);

                        lblAtividadePrincipal.InnerText = fornecedor.AtividadePrincipal;
                        lblBairro.InnerText = fornecedor.Bairro;
                        lblCep.InnerText = fornecedor.Cep;
                        lblCidade.InnerText = fornecedor.Cidade;
                        lblCNPJ.InnerText = fornecedor.Cnpj;
                        lblComplemento.InnerText = fornecedor.Complemento;
                        lblDataAbertura.InnerText = fornecedor.DataAbertura;
                        lblDataSituacaoCadastral.InnerText = fornecedor.DataSituacao;
                        lblDataSituacaoEspecial.InnerText = fornecedor.DataSituacaoEspecial;
                        lblLogradouro.InnerText = fornecedor.Logradouro;
                        lblMotivoSituacaoCadastral.InnerText = fornecedor.MotivoSituacao;
                        lblCodigoDescricaoNaturezaJuridica.InnerText = fornecedor.NaturezaJuridica;
                        lblNomeFantasia.InnerText = fornecedor.NomeFantasia;
                        lblNumero.InnerText = fornecedor.Numero;
                        lblRazaoSocial.InnerText = fornecedor.RazaoSocial;
                        lblSituacaoCadastral.InnerText = fornecedor.Situacao;
                        lblSituacaoEspecial.InnerText = fornecedor.SituacaoEspecial;
                        lblUf.InnerText = fornecedor.Uf;
                        lblEmail.InnerText = fornecedor.Email;
                        lblTelefone.InnerText = fornecedor.Telefone;
                        lblEnteFederativoResponsavel.InnerText = fornecedor.EnteFederativoResponsavel;

                        lblAtividadeSecundaria.InnerHtml = fornecedor.AtividadeSecundaria01;

                        if (fornecedor.AtividadeSecundaria02 != "" && fornecedor.AtividadeSecundaria02 != null)
                            lblAtividadeSecundaria.InnerHtml += "<br />" + fornecedor.AtividadeSecundaria02;

                        if (fornecedor.AtividadeSecundaria03 != "" && fornecedor.AtividadeSecundaria03 != null)
                            lblAtividadeSecundaria.InnerHtml += "<br />" + fornecedor.AtividadeSecundaria03;

                        if (fornecedor.AtividadeSecundaria04 != "" && fornecedor.AtividadeSecundaria04 != null)
                            lblAtividadeSecundaria.InnerHtml += "<br />" + fornecedor.AtividadeSecundaria04;

                        if (fornecedor.AtividadeSecundaria05 != "" && fornecedor.AtividadeSecundaria05 != null)
                            lblAtividadeSecundaria.InnerHtml += "<br />" + fornecedor.AtividadeSecundaria05;

                        if (fornecedor.AtividadeSecundaria06 != "" && fornecedor.AtividadeSecundaria06 != null)
                            lblAtividadeSecundaria.InnerHtml += "<br />" + fornecedor.AtividadeSecundaria06;

                        if (fornecedor.AtividadeSecundaria07 != "" && fornecedor.AtividadeSecundaria07 != null)
                            lblAtividadeSecundaria.InnerHtml += "<br />" + fornecedor.AtividadeSecundaria07;

                        if (fornecedor.AtividadeSecundaria08 != "" && fornecedor.AtividadeSecundaria08 != null)
                            lblAtividadeSecundaria.InnerHtml += "<br />" + fornecedor.AtividadeSecundaria08;

                        if (fornecedor.AtividadeSecundaria09 != "" && fornecedor.AtividadeSecundaria09 != null)
                            lblAtividadeSecundaria.InnerHtml += "<br />" + fornecedor.AtividadeSecundaria09;

                        if (fornecedor.AtividadeSecundaria10 != "" && fornecedor.AtividadeSecundaria10 != null)
                            lblAtividadeSecundaria.InnerHtml += "<br />" + fornecedor.AtividadeSecundaria10;

                        if (fornecedor.AtividadeSecundaria11 != "" && fornecedor.AtividadeSecundaria11 != null)
                            lblAtividadeSecundaria.InnerHtml += "<br />" + fornecedor.AtividadeSecundaria11;

                        if (fornecedor.AtividadeSecundaria12 != "" && fornecedor.AtividadeSecundaria12 != null)
                            lblAtividadeSecundaria.InnerHtml += "<br />" + fornecedor.AtividadeSecundaria12;

                        if (fornecedor.AtividadeSecundaria13 != "" && fornecedor.AtividadeSecundaria13 != null)
                            lblAtividadeSecundaria.InnerHtml += "<br />" + fornecedor.AtividadeSecundaria13;

                        if (fornecedor.AtividadeSecundaria14 != "" && fornecedor.AtividadeSecundaria14 != null)
                            lblAtividadeSecundaria.InnerHtml += "<br />" + fornecedor.AtividadeSecundaria14;

                        if (fornecedor.AtividadeSecundaria15 != "" && fornecedor.AtividadeSecundaria15 != null)
                            lblAtividadeSecundaria.InnerHtml += "<br />" + fornecedor.AtividadeSecundaria15;

                        if (fornecedor.AtividadeSecundaria16 != "" && fornecedor.AtividadeSecundaria16 != null)
                            lblAtividadeSecundaria.InnerHtml += "<br />" + fornecedor.AtividadeSecundaria16;

                        if (fornecedor.AtividadeSecundaria17 != "" && fornecedor.AtividadeSecundaria17 != null)
                            lblAtividadeSecundaria.InnerHtml += "<br />" + fornecedor.AtividadeSecundaria17;

                        if (fornecedor.AtividadeSecundaria18 != "" && fornecedor.AtividadeSecundaria18 != null)
                            lblAtividadeSecundaria.InnerHtml += "<br />" + fornecedor.AtividadeSecundaria18;

                        if (fornecedor.AtividadeSecundaria19 != "" && fornecedor.AtividadeSecundaria19 != null)
                            lblAtividadeSecundaria.InnerHtml += "<br />" + fornecedor.AtividadeSecundaria19;

                        if (fornecedor.AtividadeSecundaria20 != "" && fornecedor.AtividadeSecundaria20 != null)
                            lblAtividadeSecundaria.InnerHtml += "<br />" + fornecedor.AtividadeSecundaria20;

                        lblCapitalSocial.InnerText = fornecedor.CapitalSocial;

                        fsConsultaReceita.Style.Add("display", "none");

                        ButtonListarDoacoes.Visible = fornecedor.Doador;

                        if (fornecedor.DataInclusao != DateTime.MinValue)
                        {
                            //TODO: Consultar data da Ultima NF e comparar com a data de pesquisa (DataInclusao).
                            dvInfoDataConsultaCNPJ.Visible = true;
                            dvInfoDataConsultaCNPJ.InnerHtml = string.Format("As informações abaixo foram consultadas em {0:dd/MM/yyyy HH:mm}. Clique <a href='#' onclick='ReconsultarDadosReceita(); return false;'>aqui</a> para atualizar os dados a partir da Receita Federal.", fornecedor.DataInclusao);
                        }

                        if (fornecedor.CarregaDadosQuadroSocietario(lblCNPJ.InnerText))
                        {
                            rptQuadroSocietario.DataSource = fornecedor.lstFornecedorQuadroSocietario;
                            rptQuadroSocietario.DataBind();
                        }
                        else
                        {
                            rptQuadroSocietario.Visible = false;
                            ltrSemQuadroSocios.Text = "<td colspan=\"4\" class=\"text-center\">A natureza jurídica não permite o preenchimento do QSA</td>";
                        }
                    }
                    else
                    {
                        fsDadosReceita.Style.Add("display", "none");
                        fsQuadroSocietario.Style.Add("display", "none");
                        dvBotoesAcao.Style.Add("display", "none");

                        captcha_img.Src = GetCaptcha();
                    }


                    Denuncia denuncia = new Denuncia();
                    denuncia.DenunciasFornecedorResumida(GridViewDenuncias, fornecedor.Cnpj);

                    if (GridViewDenuncias.Rows.Count > 0)
                    {
                        fsMinhasDenuncias.Visible = true;

                        if (GridViewDenuncias.Rows.Count == 1)
                            LabelExisteDenuncia.InnerText = "Este fornecedor possui 1 denúncia. Evite enviar denúncias repetidas caso existam outras recentes.";
                        else
                            LabelExisteDenuncia.InnerText = "Este fornecedor possui " + GridViewDenuncias.Rows.Count.ToString() + " denúncias. Evite enviar denúncias repetidas caso existam outras recentes.";
                    }
                    else
                    {
                        fsMinhasDenuncias.Visible = false;
                    }
                }

                ButtonAtualizar.Visible = System.Web.HttpContext.Current.User.Identity.IsAuthenticated;
            }
        }
예제 #10
0
        public Fornecedor MontarObjFornecedor(string cnpj, string responseFromServer)
        {
            Fornecedor fornecedor = new Fornecedor();

            if (responseFromServer.IndexOf("NOME EMPRESARIAL") > 0)
            {
                string textoHTML = Regex.Replace(responseFromServer, @"<[^>]*>", string.Empty);
                textoHTML       = textoHTML.Substring(textoHTML.IndexOf("NÚMERO DE INSCRIÇÃO"));
                textoHTML       = textoHTML.Substring(0, textoHTML.IndexOf("Aprovado pela Instrução Normativa")).Replace("NÚMERO DE INSCRIÇÃO", "").Trim();
                textoHTML       = Regex.Replace(textoHTML, "&nbsp;", string.Empty).Trim();
                fornecedor.Cnpj = cnpj; //textoHTML.Substring(0, textoHTML.IndexOf("\r\n"));

                textoHTML         = textoHTML.Replace(fornecedor.Cnpj, "");
                fornecedor.Matriz = (textoHTML.Substring(0, textoHTML.IndexOf("COMPROVANTE")).Trim().Equals("MATRIZ")) ? 1 : 0;

                textoHTML = textoHTML.Substring(textoHTML.IndexOf("DATA DE ABERTURA")).Replace("DATA DE ABERTURA", "").Trim();
                fornecedor.DataAbertura = textoHTML.Substring(0, textoHTML.IndexOf("\r\n")).Trim();

                textoHTML = textoHTML.Substring(textoHTML.IndexOf("NOME EMPRESARIAL")).Replace("NOME EMPRESARIAL", "").Trim();
                fornecedor.RazaoSocial = textoHTML.Substring(0, textoHTML.IndexOf("\r\n")).Trim();

                textoHTML = textoHTML.Substring(textoHTML.IndexOf("(NOME DE FANTASIA)")).Replace("(NOME DE FANTASIA)", "").Trim();
                fornecedor.NomeFantasia = textoHTML.Substring(0, textoHTML.IndexOf("\r\n")).Trim();
                if (fornecedor.NomeFantasia.Substring(0, 1) == "*")
                {
                    fornecedor.NomeFantasia = fornecedor.RazaoSocial;
                }

                textoHTML = textoHTML.Substring(textoHTML.IndexOf("CÓDIGO E DESCRIÇÃO DA ATIVIDADE ECONÔMICA PRINCIPAL")).Replace("CÓDIGO E DESCRIÇÃO DA ATIVIDADE ECONÔMICA PRINCIPAL", "").Trim();
                fornecedor.AtividadePrincipal = textoHTML.Substring(0, textoHTML.IndexOf("\r\n")).Trim();
                if (fornecedor.AtividadePrincipal.Substring(0, 1) == "*")
                {
                    fornecedor.AtividadePrincipal = "";
                }

                textoHTML = textoHTML.Substring(textoHTML.IndexOf("CÓDIGO E DESCRIÇÃO DAS ATIVIDADES ECONÔMICAS SECUNDÁRIAS")).Replace("CÓDIGO E DESCRIÇÃO DAS ATIVIDADES ECONÔMICAS SECUNDÁRIAS", "").Trim();
                fornecedor.AtividadeSecundaria01 = textoHTML.Substring(0, textoHTML.IndexOf("CÓDIGO E DESCRIÇÃO DA NATUREZA JURÍDICA")).Trim();
                if (fornecedor.AtividadeSecundaria01.Equals("Não informada"))
                {
                    fornecedor.AtividadeSecundaria01 = "";
                }
                else
                {
                    fornecedor.AtividadeSecundaria01 = fornecedor.AtividadeSecundaria01.Replace("  ", "").Replace("\t", "").Replace("\r\n\r\n\r\n\r\n", "");
                    var atividadeSecundaria = fornecedor.AtividadeSecundaria01.Split(new string[] { "\r\n" }, StringSplitOptions.None);
                    try
                    {
                        fornecedor.AtividadeSecundaria01 = atividadeSecundaria[0];
                        fornecedor.AtividadeSecundaria02 = atividadeSecundaria[1];
                        fornecedor.AtividadeSecundaria03 = atividadeSecundaria[2];
                        fornecedor.AtividadeSecundaria04 = atividadeSecundaria[3];
                        fornecedor.AtividadeSecundaria05 = atividadeSecundaria[4];
                        fornecedor.AtividadeSecundaria06 = atividadeSecundaria[5];
                        fornecedor.AtividadeSecundaria07 = atividadeSecundaria[6];
                        fornecedor.AtividadeSecundaria08 = atividadeSecundaria[7];
                        fornecedor.AtividadeSecundaria09 = atividadeSecundaria[8];
                        fornecedor.AtividadeSecundaria10 = atividadeSecundaria[9];
                        fornecedor.AtividadeSecundaria11 = atividadeSecundaria[10];
                        fornecedor.AtividadeSecundaria12 = atividadeSecundaria[11];
                        fornecedor.AtividadeSecundaria13 = atividadeSecundaria[12];
                        fornecedor.AtividadeSecundaria14 = atividadeSecundaria[13];
                        fornecedor.AtividadeSecundaria15 = atividadeSecundaria[14];
                        fornecedor.AtividadeSecundaria16 = atividadeSecundaria[15];
                        fornecedor.AtividadeSecundaria17 = atividadeSecundaria[16];
                        fornecedor.AtividadeSecundaria18 = atividadeSecundaria[17];
                        fornecedor.AtividadeSecundaria19 = atividadeSecundaria[18];
                        fornecedor.AtividadeSecundaria20 = atividadeSecundaria[19];
                    }
                    catch (IndexOutOfRangeException)
                    { }
                }

                textoHTML = textoHTML.Substring(textoHTML.IndexOf("CÓDIGO E DESCRIÇÃO DA NATUREZA JURÍDICA")).Replace("CÓDIGO E DESCRIÇÃO DA NATUREZA JURÍDICA", "").Trim();
                fornecedor.NaturezaJuridica = textoHTML.Substring(0, textoHTML.IndexOf("PORTE DA EMPRESA")).Replace("PORTE DA EMPRESA", "").Trim();
                if (fornecedor.NaturezaJuridica.Equals("LOGRADOURO"))
                {
                    fornecedor.NaturezaJuridica = "";
                }

                textoHTML             = textoHTML.Substring(textoHTML.IndexOf("LOGRADOURO")).Replace("LOGRADOURO", "").Trim();
                fornecedor.Logradouro = textoHTML.Substring(0, textoHTML.IndexOf("\r\n")).Trim();
                if (fornecedor.Logradouro.Equals("NÚMERO"))
                {
                    fornecedor.Logradouro = "";
                }

                textoHTML         = textoHTML.Substring(textoHTML.IndexOf("NÚMERO")).Replace("NÚMERO", "").Trim();
                fornecedor.Numero = textoHTML.Substring(0, textoHTML.IndexOf("\r\n")).Trim();
                if (fornecedor.Numero.Equals("COMPLEMENTO"))
                {
                    fornecedor.Numero = "";
                }

                textoHTML = textoHTML.Substring(textoHTML.IndexOf("COMPLEMENTO")).Replace("COMPLEMENTO", "").Trim();
                fornecedor.Complemento = textoHTML.Substring(0, textoHTML.IndexOf("\r\n")).Trim();
                if (fornecedor.Complemento.Equals("CEP"))
                {
                    fornecedor.Complemento = "";
                }

                textoHTML      = textoHTML.Substring(textoHTML.IndexOf("CEP")).Replace("CEP", "").Trim();
                fornecedor.Cep = textoHTML.Substring(0, textoHTML.IndexOf("\r\n")).Trim().Replace(".", "");
                if (fornecedor.Cep.Equals("DISTRITO"))
                {
                    fornecedor.Cep = "";
                }

                textoHTML         = textoHTML.Substring(textoHTML.IndexOf("DISTRITO")).Replace("DISTRITO", "").Trim();
                fornecedor.Bairro = textoHTML.Substring(0, textoHTML.IndexOf("\r\n")).Trim();
                if (fornecedor.Bairro.Equals("MUNICÍPIO"))
                {
                    fornecedor.Bairro = "";
                }

                textoHTML         = textoHTML.Substring(textoHTML.IndexOf("MUNICÍPIO")).Replace("MUNICÍPIO", "").Trim();
                fornecedor.Cidade = textoHTML.Substring(0, textoHTML.IndexOf("\r\n")).Trim();
                if (fornecedor.Cidade.Equals("UF"))
                {
                    fornecedor.Cidade = "";
                }

                textoHTML     = textoHTML.Substring(textoHTML.IndexOf("UF")).Replace("UF", "").Trim();
                fornecedor.Uf = textoHTML.Substring(0, textoHTML.IndexOf("\r\n")).Trim();
                if (fornecedor.Uf.Equals("ENDEREÇO ELETRÔNICO"))
                {
                    fornecedor.Uf = "";
                }

                textoHTML        = textoHTML.Substring(textoHTML.IndexOf("ENDEREÇO ELETRÔNICO")).Replace("ENDEREÇO ELETRÔNICO", "").Trim();
                fornecedor.Email = textoHTML.Substring(0, textoHTML.IndexOf("\r\n")).Trim();
                if (fornecedor.Email.Equals("TELEFONE"))
                {
                    fornecedor.Email = "";
                }

                textoHTML           = textoHTML.Substring(textoHTML.IndexOf("TELEFONE")).Replace("TELEFONE", "").Trim();
                fornecedor.Telefone = textoHTML.Substring(0, textoHTML.IndexOf("\r\n")).Trim();
                if (fornecedor.Telefone.Equals("ENTE FEDERATIVO RESPONSÁVEL(EFR)"))
                {
                    fornecedor.Telefone = "";
                }

                textoHTML = textoHTML.Substring(textoHTML.IndexOf("ENTE FEDERATIVO RESPONSÁVEL (EFR)")).Replace("ENTE FEDERATIVO RESPONSÁVEL (EFR)", "").Trim();
                fornecedor.EnteFederativoResponsavel = textoHTML.Substring(0, textoHTML.IndexOf("\r\n")).Trim();
                if (fornecedor.EnteFederativoResponsavel.Substring(0, 1) == "*")
                {
                    fornecedor.EnteFederativoResponsavel = "";
                }

                textoHTML           = ReplaceFirst(textoHTML.Substring(textoHTML.IndexOf("SITUAÇÃO CADASTRAL")), "SITUAÇÃO CADASTRAL", "").Trim();
                fornecedor.Situacao = textoHTML.Substring(0, textoHTML.IndexOf("\r\n")).Trim();
                if (fornecedor.Situacao.Equals("DATA DA SITUAÇÃO CADASTRAL"))
                {
                    fornecedor.Situacao = "";
                }

                textoHTML = textoHTML.Substring(textoHTML.IndexOf("DATA DA SITUAÇÃO CADASTRAL")).Replace("DATA DA SITUAÇÃO CADASTRAL", "").Trim();
                fornecedor.DataSituacao = textoHTML.Substring(0, textoHTML.IndexOf("\r\n")).Trim();
                if (fornecedor.DataSituacao.Equals("MOTIVO DE SITUAÇÃO CADASTRAL"))
                {
                    fornecedor.DataSituacao = "";
                }

                textoHTML = textoHTML.Substring(textoHTML.IndexOf("MOTIVO DE SITUAÇÃO CADASTRAL")).Replace("MOTIVO DE SITUAÇÃO CADASTRAL", "").Trim();
                fornecedor.MotivoSituacao = textoHTML.Substring(0, textoHTML.IndexOf("\r\n")).Trim();
                if (fornecedor.MotivoSituacao.Equals("SITUAÇÃO ESPECIAL"))
                {
                    fornecedor.MotivoSituacao = "";
                }

                textoHTML = ReplaceFirst(textoHTML.Substring(textoHTML.IndexOf("SITUAÇÃO ESPECIAL")), "SITUAÇÃO ESPECIAL", "").Trim();
                fornecedor.SituacaoEspecial = textoHTML.Substring(0, textoHTML.IndexOf("\r\n")).Trim();
                if (fornecedor.SituacaoEspecial.Substring(0, 1) == "*")
                {
                    fornecedor.SituacaoEspecial = "";
                }

                textoHTML = textoHTML.Substring(textoHTML.IndexOf("DATA DA SITUAÇÃO ESPECIAL")).Replace("DATA DA SITUAÇÃO ESPECIAL", "").Trim();
                fornecedor.DataSituacaoEspecial = textoHTML;
                if (fornecedor.DataSituacaoEspecial.Substring(0, 1) == "*")
                {
                    fornecedor.DataSituacaoEspecial = "";
                }

                return(fornecedor);
            }
            else if (responseFromServer.IndexOf("Verifique se o mesmo foi digitado corretamente") > 0)
            {
                throw new System.Exception("CNPJ não localizado junto a receita federal.");
            }
            else if (responseFromServer.IndexOf("Digite os caracteres acima:") > 0)
            {
                throw new System.Exception("Capcha incorreto.");
            }
            return(null);
        }