private void CarregaNotas()
        {
            LabelSel.Visible        = true;
            TextBoxTexto.Visible    = false;
            HyperLinkDoc.Visible    = false;
            HyperLinkCamara.Visible = false;

            if (DropDownListParlamentar.SelectedItem.Text.IndexOf("(DEPUTADO FEDERAL)") > 0)
            {
                HyperLinkCamara.Visible     = true;
                HyperLinkCamara.NavigateUrl = "http://www.camara.gov.br/cota-parlamentar/consulta-cota-parlamentar?ideDeputado=" + DropDownListParlamentar.SelectedValue;

                Pesquisa pesquisa = new Pesquisa();
                pesquisa.DocumentosFornecedor(GridViewResultado, lblCNPJ.InnerText, DropDownListParlamentar.SelectedValue);

                if (GridViewResultado.Rows.Count > 0)
                {
                    Session["SolicitaDocumentos"]           = GridViewResultado.DataSource;
                    Session["SolicitaDocumentosExpression"] = "Parlamentar";
                    Session["SolicitaDocumentosDirection"]  = "ASC";
                }
            }
            else
            {
                PesquisaSenadores pesquisaSenadores = new PesquisaSenadores();
                pesquisaSenadores.DocumentosFornecedor(GridViewResultado, lblCNPJ.InnerText, DropDownListParlamentar.SelectedValue);

                if (GridViewResultado.Rows.Count > 0)
                {
                    Session["SolicitaDocumentosSenadores"]           = GridViewResultado.DataSource;
                    Session["SolicitaDocumentosExpressionSenadores"] = "Parlamentar";
                    Session["SolicitaDocumentosDirectionSenadores"]  = "ASC";
                }
            }
        }
        private void Pesquisar()
        {
            if (mIdShare > 0)
            {
                ParametrosShare parametros = DbShare.Carregar(mIdShare);

                if (parametros == null)
                {
                    return;
                }

                DropDownListGrupo.SelectedValue       = parametros.Cargo;
                DropDownListAgrupamento.SelectedValue = parametros.Agrupamento;
                DropDownListPerido.SelectedValue      = Pesquisa.PERIODO_INFORMAR;
                DropDownListParlamentar.SelectedItems(parametros.Parlamentares);
                DropDownListDespesa.SelectedItems(parametros.Despesas);
                txtFornecedor.Text = parametros.Fornecedores.Split('|')[0];
                DropDownListPartido.SelectedItems(parametros.Partidos);
                DropDownListUF.SelectedItems(parametros.Ufs);
                DropDownListMesInicial.SelectedValue = parametros.MesInicial.ToString("00");
                DropDownListAnoInicial.SelectedValue = parametros.AnoInicial.ToString("00");
                DropDownListMesFinal.SelectedValue   = parametros.MesFinal.ToString("00");
                DropDownListAnoFinal.SelectedValue   = parametros.AnoFinal.ToString("00");
            }

            if (CheckBoxSepararMes.Checked == true && DropDownListPerido.SelectedValue == Pesquisa.PERIODO_INFORMAR)
            {
                DateTime dt1 = new DateTime(Convert.ToInt32(DropDownListAnoInicial.SelectedValue), Convert.ToInt32(DropDownListMesInicial.SelectedValue), 1);
                DateTime dt2 = new DateTime(Convert.ToInt32(DropDownListAnoFinal.SelectedValue), Convert.ToInt32(DropDownListMesFinal.SelectedValue), 1);

                if ((Convert.ToInt32(DropDownListMesFinal.SelectedValue) - Convert.ToInt32(DropDownListMesInicial.SelectedValue) + 1) + 12 * (Convert.ToInt32(DropDownListAnoFinal.SelectedValue) - Convert.ToInt32(DropDownListAnoInicial.SelectedValue)) > 24)
                {
                    Response.Write("<script>alert('Período informado é grande demais para separar os meses. Informo no máximo 24 meses.')</script>");
                    return;
                }
            }

            //HiddenFieldGrupo.Value = DropDownListGrupo.SelectedValue;
            //HiddenFieldAgrupamentoAtual.Value = DropDownListAgrupamento.SelectedValue;

            var lstParlamentar = String.Join(",", DropDownListParlamentar.Items.Cast <ListItem>().Where(i => i.Selected).Select(i => i.Value));
            var lstDespesa     = String.Join(",", DropDownListDespesa.Items.Cast <ListItem>().Where(i => i.Selected).Select(i => i.Value));
            var lstUF          = String.Join(",", DropDownListUF.Items.Cast <ListItem>().Where(i => i.Selected).Select(i => i.Value));
            var lstPartido     = String.Join(",", DropDownListPartido.Items.Cast <ListItem>().Where(i => i.Selected).Select(i => i.Value));

            switch (DropDownListGrupo.SelectedValue)
            {
            case GRUPO_DEPUTADO_FEDERAL:
                Pesquisa pesquisa = new Pesquisa();
                pesquisa.Carregar(GridViewResultado,
                                  HttpContext.Current.User.Identity.Name,
                                  "",
                                  DropDownListPerido.SelectedValue,
                                  DropDownListAgrupamento.SelectedValue,
                                  CheckBoxSepararMes.Checked,
                                  DropDownListAnoInicial.SelectedValue,
                                  DropDownListMesInicial.SelectedValue,
                                  DropDownListAnoFinal.SelectedValue,
                                  DropDownListMesFinal.SelectedValue,
                                  lstParlamentar,
                                  lstDespesa,
                                  txtFornecedor.Text,
                                  lstUF,
                                  lstPartido,
                                  ViewState["ChavePesquisa"].ToString());
                break;

            case GRUPO_SENADOR:
                PesquisaSenadores pesquisaSenadores = new PesquisaSenadores();
                pesquisaSenadores.Carregar(GridViewResultado,
                                           HttpContext.Current.User.Identity.Name,
                                           "",
                                           DropDownListPerido.SelectedValue,
                                           DropDownListAgrupamento.SelectedValue,
                                           CheckBoxSepararMes.Checked,
                                           DropDownListAnoInicial.SelectedValue,
                                           DropDownListMesInicial.SelectedValue,
                                           DropDownListAnoFinal.SelectedValue,
                                           DropDownListMesFinal.SelectedValue,
                                           lstParlamentar,
                                           lstDespesa,
                                           txtFornecedor.Text,
                                           lstUF,
                                           lstPartido,
                                           ViewState["ChavePesquisa"].ToString());
                break;
            }

            Session["pesquisa0"]       = GridViewResultado.DataSource;
            Session["SortDirection0"]  = "DESC";
            Session["SortExpression0"] = "Valor Total";

            if (GridViewResultado.Rows.Count == 1000)
            {
                LabelMaximo.InnerText = "O resultado está limitado a 1.000 registros para evitar sobrecarga.";
                LabelMaximo.Visible   = true;
            }
            else
            {
                LabelMaximo.InnerText = "";
                LabelMaximo.Visible   = false;
            }
        }
Exemplo n.º 3
0
        private void Pesquisar()
        {
            //Usado para selecionar o parlamentar ao solicitar documentos ao auditar o fornecedor
            if (!string.IsNullOrEmpty(HiddenFieldParlamentar.Value))
            {
                Session["ParlamentarQueEstaSendoAuditado"] = HiddenFieldParlamentar.Value.Split(',')[0];
            }

            switch (HiddenFieldGrupo.Value)
            {
            case GRUPO_DEPUTADO_FEDERAL:
                Pesquisa pesquisa = new Pesquisa();
                pesquisa.Carregar(GridViewResultado,
                                  HttpContext.Current.User.Identity.Name,
                                  HiddenFieldDocumento.Value,
                                  HiddenFieldPeriodo.Value,
                                  HiddenFieldAgrupamento.Value,
                                  Convert.ToBoolean(HiddenFieldSeparaMes.Value),
                                  HiddenFieldAnoIni.Value,
                                  HiddenFieldMesIni.Value,
                                  HiddenFieldAnoFim.Value,
                                  HiddenFieldMesFim.Value,
                                  HiddenFieldParlamentar.Value,
                                  HiddenFieldDespesa.Value,
                                  HiddenFieldFornecedor.Value,
                                  HiddenFieldUF.Value,
                                  HiddenFieldPartido.Value,
                                  ChavePesquisa.Value);

                break;

            case GRUPO_SENADOR:
                PesquisaSenadores pesquisaSenadores = new PesquisaSenadores();
                pesquisaSenadores.Carregar(GridViewResultado,
                                           HttpContext.Current.User.Identity.Name,
                                           HiddenFieldDocumento.Value,
                                           HiddenFieldPeriodo.Value,
                                           HiddenFieldAgrupamento.Value,
                                           Convert.ToBoolean(HiddenFieldSeparaMes.Value),
                                           HiddenFieldAnoIni.Value,
                                           HiddenFieldMesIni.Value,
                                           HiddenFieldAnoFim.Value,
                                           HiddenFieldMesFim.Value,
                                           HiddenFieldParlamentar.Value,
                                           HiddenFieldDespesa.Value,
                                           HiddenFieldFornecedor.Value,
                                           HiddenFieldUF.Value,
                                           HiddenFieldPartido.Value,
                                           ChavePesquisa.Value);

                break;
            }

            String id = HttpUtility.HtmlDecode(Request.QueryString["id"]);

            Session["pesquisa" + id] = GridViewResultado.DataSource;

            Session["SortDirection" + id]  = "DESC";
            Session["SortExpression" + id] = "Valor Total";

            LabelMaximo.Visible = (GridViewResultado.Rows.Count == 1000);
        }