protected List <Processo> bindGrid() { List <Processo> lista = new List <Processo>(); Adaptador adpt = new Adaptador(); if ((String)Session["orderBy"] == null) { orderBy = "asc"; Session.Add("orderBy", orderBy); } else { if ((String)Session["orderBy"] == "asc") { orderBy = "desc"; Session["orderBy"] = orderBy; } else { orderBy = "asc"; Session["orderBy"] = orderBy; } } lista = adpt.porColuna(null, coluna, orderBy); return(lista); }
protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e) { GridView1.PageIndex = e.NewPageIndex; Adaptador adpt = new Adaptador(); GridView1.DataSource = adpt.Todos(); GridView1.DataBind(); }
protected List<Processo> bindGrid() { comando = (String)Session["lista"]; List<Processo> lista = new List<Processo>(); Adaptador adpt = new Adaptador(); if ((String)Session["orderBy"] == null) { orderBy = "asc"; Session.Add("orderBy", orderBy); } else { if ((String)Session["orderBy"] == "asc") { orderBy = "desc"; Session["orderBy"] = orderBy; } else { orderBy = "asc"; Session["orderBy"] = orderBy; } } lista = adpt.porColuna(comando, coluna, orderBy); return lista; }
protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e) { GridView1.PageIndex = e.NewPageIndex; comando = (String)Session["lista"]; Adaptador adpt = new Adaptador(); GridView1.DataSource = adpt.PesquisarCampos(comando); GridView1.DataBind(); }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { pesquisa = (String)Session["ComandoPesquisa"]; campos = (String)Session["Campos"]; string[] parametros = campos.Split(' '); for (int i = 0; i < parametros.Length; i++) { if (i < parametros.Length) { TextBoxComandoPesquisa.Text += parametros[i] + " "; } } } TextBoxComandoPesquisa.Focus(); if (!IsPostBack) { ImageButton lkListar = (ImageButton)Master.FindControl("ImageButtonListar"); lkListar.Visible = false; ImageButton lkCadastrar = (ImageButton)Master.FindControl("ImageButtonCadastrar"); lkCadastrar.Visible = false; ImageButton lkAjuda = (ImageButton)Master.FindControl("ImageButtonAjuda"); lkAjuda.Visible = false; comando = (String)Session["lista"]; Adaptador adpt = new Adaptador(); List <Processo> processos = new List <Processo>(); GridView1.DataSource = adpt.PesquisarCampos(comando); GridView1.DataBind(); usuarioConectado = (String)Session["usuario"]; senhaConectado = (String)Session["senha"]; GoldenAccess servicoDeAutenticacao = new GoldenAccess("http://localhost:3271/GoldenAccess.soap"); User usuarioGoldenAccess = new User(usuarioConectado, senhaConectado); try { usuarioGoldenAccess = servicoDeAutenticacao.Authenticate(usuarioConectado, senhaConectado); } catch (Exception ex) { LabelErro.Text = ex.Message; } if (usuarioGoldenAccess.IsAuthenticated && !usuarioGoldenAccess.Disabled) { } else { erro = "Usuário não autenticado"; Session.Add("erro", erro); Server.Transfer("Login.aspx"); Session.Abandon(); } } }
protected void ImageButtonEnviar_Click(object sender, ImageClickEventArgs e) { Adaptador adpt = new Adaptador(); int login = 0; try { login = adpt.EfetuaLogin(TextBoxUsuario.Text, TextBoxSenha.Text); } catch (Exception ex) { LabelErro.Text = ex.Message; } if (login == 1) { Session.Add("usuario", TextBoxUsuario.Text); Session.Add("senha", TextBoxSenha.Text); //Response.Write("<script>alert('Login de " + TextBoxUsuario.Text.ToUpper() + " efetuado com sucesso')</script>"); Session.Add("login", 1); Server.Transfer("Default.aspx"); } else if (login == 2) { Session.Add("usuario", TextBoxUsuario.Text); Session.Add("senha", TextBoxSenha.Text); Response.Write("<script>alert('Login de " + TextBoxUsuario.Text.ToUpper() + " efetuado com sucesso')</script>"); //Transferir para a página de acesso a usuário com permissão restrita. Server.Transfer("Default.aspx"); } else if (login == 3) { LabelErro.Text = "Usuário não tem permissão para esta aplicação"; } else if (login == 4) { LabelErro.Text = "Usuário inexistente"; } else { LabelErro.Text = "Erro não identificado"; } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { ImageButton lkCadastrar = (ImageButton)Master.FindControl("ImageButtonCadastrar"); lkCadastrar.Visible = false; ImageButton lkListar = (ImageButton)Master.FindControl("ImageButtonListar"); lkListar.Visible = false; ImageButton lkAjuda = (ImageButton)Master.FindControl("ImageButtonAjuda"); lkAjuda.Visible = false; usuarioConectado = (String)Session["usuario"]; senhaConectado = (String)Session["senha"]; GoldenAccess goldenAccess = new GoldenAccess("http://localhost:3271/GoldenAccess.soap"); User usuario = new User(usuarioConectado, senhaConectado); try { usuario = goldenAccess.Authenticate(usuarioConectado, senhaConectado); } catch (Exception ex) { LabelErro.Text = ex.Message; } if (usuario.IsAuthenticated && !usuario.Disabled) { } else { erro = "Usuário não autenticado"; Session.Add("erro", erro); Server.Transfer("login.aspx"); Session.Abandon(); } Adaptador adpt = new Adaptador(); List <Processo> lista = new List <Processo>(); lista = adpt.Todos(); GridView1.DataSource = lista; GridView1.DataBind(); } }
protected void ButtonPesquisaComando_Click(object sender, EventArgs e) { comando = (String)Session["lista"]; campos = (String)Session["Campos"]; if (IsPostBack) { Adaptador adpt2 = new Adaptador(); if (campos == TextBoxComandoPesquisa.Text) { GridView1.DataSource = adpt2.PesquisarCampos(comando); GridView1.DataBind(); } else { Session["Campos"] = TextBoxComandoPesquisa.Text; string parametros = montarComando(TextBoxComandoPesquisa.Text); comando = "textsearch in tcejurisprudencia " + parametros; GridView1.DataSource = adpt2.PesquisarCampos(comando); GridView1.DataBind(); } } Adaptador adpt = new Adaptador(); List <Processo> lista = new List <Processo>(); lista = adpt.PesquisarCampos(comando); if (lista.Count == 0) { LabelErro.Text = "Não foram encontrados resultados para essa pesquisa"; } else { GridView1.DataSource = lista; GridView1.DataBind(); } }
protected void ImageButtonPesquisar_Click(object sender, ImageClickEventArgs e) { if (TextBoxNumeroProcesso.Text == "" && TextBoxAnoProcesso.Text == "" && TextBoxOrigem.Text == "" && TextBoxAssunto.Text == "" && TextBoxDescricao.Text == "" && TextBoxInteressado.Text == "" && TextBoxQualquerCampo.Text == "") { LabelErro.Text = "Não existem campos para pesquisa"; } else { comando = "textsearch in tcejurisprudencia "; if (TextBoxQualquerCampo.Text != "") { comando += montarComando(TextBoxQualquerCampo.Text); if (TextBoxNumeroProcesso.Text != "") { campos += TextBoxNumeroProcesso.Text + " "; comando += " E " + TextBoxNumeroProcesso.Text + "[numero_Processo] "; } if (TextBoxAnoProcesso.Text != "") { campos += TextBoxAnoProcesso.Text + " "; comando += " E " + TextBoxAnoProcesso.Text + "[ano_Processo] "; i++; } if (TextBoxOrigem.Text != "") { campos += TextBoxOrigem.Text + " "; comando += " E " + montarComandoPROX(TextBoxOrigem.Text) + "[origem] "; i++; } if (TextBoxAssunto.Text != "") { campos += TextBoxAssunto.Text + " "; comando += " E " + montarComandoPROX(TextBoxAssunto.Text) + " [assunto] "; i++; } if (TextBoxDescricao.Text != "") { campos += TextBoxDescricao.Text + " "; comando += " E " + montarComandoPROX(TextBoxDescricao.Text) + " [descricao] "; i++; } if (TextBoxInteressado.Text != "") { campos += TextBoxInteressado.Text + " "; comando += " E " + montarComandoPROX(TextBoxInteressado.Text) + "[nome]"; i++; } campos += TextBoxQualquerCampo.Text; } else { if (TextBoxNumeroProcesso.Text != "") { campos += TextBoxNumeroProcesso.Text + " "; comando += TextBoxNumeroProcesso.Text + "[numero_Processo] "; i++; } if (TextBoxAnoProcesso.Text != "") { campos += TextBoxAnoProcesso.Text + " "; if (i >= 1) { comando += " E " + TextBoxAnoProcesso.Text + "[ano_Processo] "; i++; } else if(i == 0) { comando += TextBoxAnoProcesso.Text + "[ano_Processo] "; i++; } } if (TextBoxOrigem.Text != "") { campos += TextBoxOrigem.Text + " "; if (i >= 1) { comando += " E " + montarComandoPROX(TextBoxOrigem.Text) + "[origem] "; i++; } else if (i == 0) { comando += montarComandoPROX(TextBoxOrigem.Text) + "[origem] "; i++; } } if (TextBoxAssunto.Text != "") { campos += TextBoxAssunto.Text + " "; if (i >= 1) { comando += " E " + montarComandoPROX(TextBoxAssunto.Text) + "[assunto] "; i++; } else if (i == 0) { comando += montarComandoPROX(TextBoxAssunto.Text) + "[assunto] "; i++; } } if (TextBoxDescricao.Text != "") { campos += TextBoxDescricao.Text + " "; if (i >= 1) { comando += " E " + montarComandoPROX(TextBoxDescricao.Text) + "[descricao] "; i++; } else if (i == 0) { comando += montarComandoPROX(TextBoxDescricao.Text) + "[descricao] "; i++; } } if (TextBoxInteressado.Text != "") { campos += TextBoxInteressado.Text + " "; if (i >= 1) { comando += " E " + montarComandoPROX(TextBoxInteressado.Text) + "[nome]"; i++; } else if(i == 0) { comando += montarComandoPROX(TextBoxInteressado.Text) + "[nome]"; i++; } } } Session.Add("ComandoPesquisa", comando); Session.Add("Campos", campos); } Adaptador adpt = new Adaptador(); List<Processo> lista = adpt.PesquisaPorCampo(comando); if (lista.Count == 0) { LabelErro.Text = "Não foram encontrados resultados para essa pesquisa"; } else { Session.Add("lista", comando); Session.Add("modulo", 0); Session.Add("pagina", pagina); try { Server.Transfer("pesquisar.aspx"); } catch (Exception ex) { LabelErro.Text = ex.Message; } } }
protected void ImageButtonEnviar_Click(object sender, ImageClickEventArgs e) { if (FileUpload.PostedFile.ContentLength == 0) { Response.Write("<script>alert('Favor selecionar arquivo')</script>"); } else { arquivo = FileUpload.PostedFile.FileName; nomeArquivo = System.IO.Path.GetFileName(arquivo); int pos = 0; pos = nomeArquivo.LastIndexOf('.'); extensao = nomeArquivo.Substring(pos).ToLower(); tamanho = nomeArquivo.Length; nomeArquivoLBW = id + "_" + "0001" + "_" + "arq_Arquivo" + extensao; Processo processo = new Processo(); processo.id = Convert.ToInt16(id); processo.arq_Arquivo = nomeArquivoLBW; processo.numero_Processo = TextBoxNumeroProcesso.Text; processo.ano_Processo = TextBoxAnoProcesso.Text; processo.origem = TextBoxOrigem.Text; processo.assunto = TextBoxAssunto.Text; processo.descricao = TextBoxDescricao.Text; processo.pessoa1 = TextBoxPessoa1.Text; processo.pessoa2 = TextBoxPessoa2.Text; processo.pessoa3 = TextBoxPessoa3.Text; processo.pessoa4 = TextBoxPessoa4.Text; Adaptador adt = new Adaptador(); try { Processo proc = new Processo(); proc = adt.obterProcessoPorId(id); nomeArquivoAntigo = proc.arq_Arquivo; if (nomeArquivoAntigo != null) { string diretorioRemover = Settings.Default.CaminhoDoRepositorioJurisprudencia + nomeArquivoAntigo; FileInfo arquivoAntigo = new FileInfo(diretorioRemover); arquivoAntigo.Delete(); } adt.AtualizaProcesso(processo); } catch (Exception ex) { LabelErro.Text = ex.Message; } Versao versao = new Versao(); FileUpload.PostedFile.SaveAs(Settings.Default.CaminhoDoRepositorioJurisprudencia + nomeArquivoLBW); versao.CaminhoDoArquivo = Settings.Default.CaminhoDoRepositorioJurisprudencia; versao.Extensao = extensao; versao.NomeDoArquivo = nomeArquivoLBW; versao.Id = processo.id; Indexador indexador = new Indexador(); indexador.Indexe(versao); mensagem = "Registro modificado com sucesso"; Session.Add("mensagem", mensagem); Server.Transfer("Listar.aspx"); } }
protected void ImageButtonPesquisar_Click(object sender, ImageClickEventArgs e) { if (TextBoxBuscaComExpressao.Text != "" || TextBoxBuscaQualquerPalavra.Text != "") { int modulo = (Int32)Session["modulo"]; if (modulo == 0) { if (TextBoxBuscaComExpressao.Text != "" && TextBoxBuscaQualquerPalavra.Text != "") { LabelErro.Text = "Apenas um campo deve estar preenchido"; } if (TextBoxBuscaQualquerPalavra.Text != "") { novoComando = montarComandoPorPalavra(TextBoxBuscaQualquerPalavra.Text); if (novoComando == "") { LabelErro.Text = "Não foram encontrados resultados para essa pesquisa"; } else { comando = "textsearch in tcejurisprudencia " + novoComando; } } if (TextBoxBuscaComExpressao.Text != "") { novoComando = montarComandoPorExpressao(TextBoxBuscaComExpressao.Text); if (novoComando == "") { LabelErro.Text = "Não foram encontrados resultados para essa pesquisa"; } else { comando = "textsearch in tcejurisprudencia " + novoComando; //comando = "textsearch in tcejurisprudencia " + "\"" + TextBoxBuscaComExpressao.Text + "\""; } } Adaptador adpt = new Adaptador(); List <Processo> lista = adpt.PesquisaPorCampo(comando); if (lista.Count == 0) { LabelErro.Text = "Não foram encontrados resultados para essa pesquisa"; } else { Session.Add("lista", comando); Session.Add("pagina", pagina); try { Server.Transfer("pesquisar.aspx"); } catch (Exception ex) { LabelErro.Text = ex.Message; } } } else if (modulo == 1) { if (TextBoxBuscaComExpressao.Text != "" && TextBoxBuscaQualquerPalavra.Text != "") { LabelErro.Text = "Apenas um campo deve estar preenchido"; } if (TextBoxBuscaQualquerPalavra.Text != "") { novoComando = montarComandoPorPalavra(TextBoxBuscaQualquerPalavra.Text); if (novoComando == "") { LabelErro.Text = "Não foram encontrados resultados para essa pesquisa"; } else { comando = "textsearch in folder245_indices5 " + novoComando; } } if (TextBoxBuscaComExpressao.Text != "") { novoComando = montarComandoPorExpressao(TextBoxBuscaQualquerPalavra.Text); if (novoComando == "") { LabelErro.Text = "Não foram encontrados resultados para essa pesquisa"; } else { comando = "textsearch in folder245_indices5 " + novoComando; } } AdaptadorDespesa adpt = new AdaptadorDespesa(); List <Despesa> lista = adpt.PesquisaPorCampo(comando); if (lista.Count == 0) { LabelErro.Text = "Não foram encontrados resultados para essa pesquisa"; } else { Session.Add("lista", comando); Session.Add("pagina", pagina); try { Server.Transfer("pesquisarprocessosdespesa.aspx"); } catch (Exception ex) { LabelErro.Text = ex.Message; } } } else if (modulo == 2) { if (TextBoxBuscaComExpressao.Text != "" && TextBoxBuscaQualquerPalavra.Text != "") { LabelErro.Text = "Apenas um campo deve estar preenchido"; } if (TextBoxBuscaQualquerPalavra.Text != "") { novoComando = montarComandoPorPalavra(TextBoxBuscaQualquerPalavra.Text); if (novoComando == "") { LabelErro.Text = "Não foram encontrados resultados para essa pesquisa"; } else { comando = "textsearch in folder245_indices6 " + novoComando; } } if (TextBoxBuscaComExpressao.Text != "") { novoComando = montarComandoPorExpressao(TextBoxBuscaComExpressao.Text); if (novoComando == "") { LabelErro.Text = "Não foram encontrados resultados para essa pesquisa"; } else { comando = "textsearch in folder245_indices6 \"" + novoComando; } } AdaptadorProtocolo adpt = new AdaptadorProtocolo(); List <Protocolo> lista = adpt.PesquisaPorCampo(comando); if (lista.Count == 0) { LabelErro.Text = "Não foram encontrados resultados para essa pesquisa"; } else { Session.Add("lista", comando); Session.Add("pagina", pagina); try { Server.Transfer("pesquisarprotocolos.aspx"); } catch (Exception ex) { LabelErro.Text = ex.Message; } } } else { LabelErro.Text = "Erro não identificado"; } } else { LabelErro.Text = "Um dos campos deve estar preenchido"; } }
protected void ImageButtonEnviar_Click(object sender, ImageClickEventArgs e) { string ext = ""; string id = ""; string arquivo = ""; string nomeArquivo = ""; int tamanho = 0; string nomeArquivoLBW = ""; if (FileUpload.PostedFile.ContentLength == 0) { LabelErro.Text = "É necessário selecionar um arquivo"; } else { try { id = obterIdCadastrado(); } catch (Exception ex) { LabelErro.Text = ex.Message; } arquivo = FileUpload.PostedFile.FileName; nomeArquivo = System.IO.Path.GetFileName(arquivo); int pos = 0; pos = nomeArquivo.LastIndexOf('.'); ext = nomeArquivo.Substring(pos).ToLower(); tamanho = nomeArquivo.Length; nomeArquivoLBW = montarFormatoGD(id, ext); Processo processo = new Processo(); processo.arq_Arquivo = nomeArquivoLBW; processo.numero_Processo = TextBoxNumeroProcesso.Text; processo.ano_Processo = TextBoxAnoProcesso.Text; processo.origem = TextBoxOrigem.Text; processo.assunto = TextBoxAssunto.Text; processo.descricao = TextBoxDescricao.Text; processo.pessoa1 = TextBoxPessoa1.Text; processo.pessoa2 = TextBoxPessoa2.Text; processo.pessoa3 = TextBoxPessoa3.Text; processo.pessoa4 = TextBoxPessoa4.Text; processo.qtdPessoas = Convert.ToInt16(TextBoxQtdPessoas.Text); Adaptador adpt = new Adaptador(); try { adpt.InsereProcesso(processo); } catch (Exception ex) { LabelErro.Text = ex.Message; } Versao versao = new Versao(); FileUpload.PostedFile.SaveAs(Settings.Default.CaminhoDoRepositorioJurisprudencia + nomeArquivoLBW); versao.CaminhoDoArquivo = Settings.Default.CaminhoDoRepositorioJurisprudencia; versao.Extensao = ext; versao.NomeDoArquivo = nomeArquivoLBW; versao.Id = Convert.ToInt32(obterIdCadastrado()); Indexador indexador = new Indexador(); indexador.Indexe(versao); mensagem = "Registro inserido com sucesso"; Session.Add("mensagem", mensagem); Server.Transfer("Listar.aspx"); } }
protected void ImageButtonPesquisar_Click(object sender, ImageClickEventArgs e) { if (TextBoxBuscaComExpressao.Text != "" || TextBoxBuscaQualquerPalavra.Text != "") { int modulo = (Int32)Session["modulo"]; if (modulo == 0) { if (TextBoxBuscaComExpressao.Text != "" && TextBoxBuscaQualquerPalavra.Text != "") { LabelErro.Text = "Apenas um campo deve estar preenchido"; } if (TextBoxBuscaQualquerPalavra.Text != "") { novoComando = montarComandoPorPalavra(TextBoxBuscaQualquerPalavra.Text); if (novoComando == "") { LabelErro.Text = "Não foram encontrados resultados para essa pesquisa"; } else { comando = "textsearch in tcejurisprudencia " + novoComando; } } if (TextBoxBuscaComExpressao.Text != "") { novoComando = montarComandoPorExpressao(TextBoxBuscaComExpressao.Text); if (novoComando == "") { LabelErro.Text = "Não foram encontrados resultados para essa pesquisa"; } else { comando = "textsearch in tcejurisprudencia " + novoComando; //comando = "textsearch in tcejurisprudencia " + "\"" + TextBoxBuscaComExpressao.Text + "\""; } } Adaptador adpt = new Adaptador(); List<Processo> lista = adpt.PesquisaPorCampo(comando); if (lista.Count == 0) { LabelErro.Text = "Não foram encontrados resultados para essa pesquisa"; } else { Session.Add("lista", comando); Session.Add("pagina", pagina); try { Server.Transfer("pesquisar.aspx"); } catch (Exception ex) { LabelErro.Text = ex.Message; } } } else if (modulo == 1) { if (TextBoxBuscaComExpressao.Text != "" && TextBoxBuscaQualquerPalavra.Text != "") { LabelErro.Text = "Apenas um campo deve estar preenchido"; } if (TextBoxBuscaQualquerPalavra.Text != "") { novoComando = montarComandoPorPalavra(TextBoxBuscaQualquerPalavra.Text); if (novoComando == "") { LabelErro.Text = "Não foram encontrados resultados para essa pesquisa"; } else { comando = "textsearch in folder245_indices5 " + novoComando; } } if (TextBoxBuscaComExpressao.Text != "") { novoComando = montarComandoPorExpressao(TextBoxBuscaQualquerPalavra.Text); if (novoComando == "") { LabelErro.Text = "Não foram encontrados resultados para essa pesquisa"; } else { comando = "textsearch in folder245_indices5 " + novoComando; } } AdaptadorDespesa adpt = new AdaptadorDespesa(); List<Despesa> lista = adpt.PesquisaPorCampo(comando); if (lista.Count == 0) { LabelErro.Text = "Não foram encontrados resultados para essa pesquisa"; } else { Session.Add("lista", comando); Session.Add("pagina", pagina); try { Server.Transfer("pesquisarprocessosdespesa.aspx"); } catch (Exception ex) { LabelErro.Text = ex.Message; } } } else if (modulo == 2) { if (TextBoxBuscaComExpressao.Text != "" && TextBoxBuscaQualquerPalavra.Text != "") { LabelErro.Text = "Apenas um campo deve estar preenchido"; } if (TextBoxBuscaQualquerPalavra.Text != "") { novoComando = montarComandoPorPalavra(TextBoxBuscaQualquerPalavra.Text); if (novoComando == "") { LabelErro.Text = "Não foram encontrados resultados para essa pesquisa"; } else { comando = "textsearch in folder245_indices6 " + novoComando; } } if (TextBoxBuscaComExpressao.Text != "") { novoComando = montarComandoPorExpressao(TextBoxBuscaComExpressao.Text); if (novoComando == "") { LabelErro.Text = "Não foram encontrados resultados para essa pesquisa"; } else { comando = "textsearch in folder245_indices6 \"" + novoComando; } } AdaptadorProtocolo adpt = new AdaptadorProtocolo(); List<Protocolo> lista = adpt.PesquisaPorCampo(comando); if (lista.Count == 0) { LabelErro.Text = "Não foram encontrados resultados para essa pesquisa"; } else { Session.Add("lista", comando); Session.Add("pagina", pagina); try { Server.Transfer("pesquisarprotocolos.aspx"); } catch (Exception ex) { LabelErro.Text = ex.Message; } } } else { LabelErro.Text = "Erro não identificado"; } } else { LabelErro.Text = "Um dos campos deve estar preenchido"; } }
protected void ButtonPesquisaComando_Click(object sender, EventArgs e) { comando = (String)Session["lista"]; campos = (String)Session["Campos"]; if (IsPostBack) { Adaptador adpt2 = new Adaptador(); if(campos == TextBoxComandoPesquisa.Text) { GridView1.DataSource = adpt2.PesquisarCampos(comando); GridView1.DataBind(); } else { Session["Campos"] = TextBoxComandoPesquisa.Text; string parametros = montarComando(TextBoxComandoPesquisa.Text); comando = "textsearch in tcejurisprudencia " + parametros; GridView1.DataSource = adpt2.PesquisarCampos(comando); GridView1.DataBind(); } } Adaptador adpt = new Adaptador(); List<Processo> lista = new List<Processo>(); lista = adpt.PesquisarCampos(comando); if(lista.Count == 0) { LabelErro.Text = "Não foram encontrados resultados para essa pesquisa"; } else { GridView1.DataSource = lista; GridView1.DataBind(); } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { pesquisa = (String)Session["ComandoPesquisa"]; campos = (String)Session["Campos"]; string[] parametros = campos.Split(' '); for (int i = 0; i < parametros.Length; i++) { if (i < parametros.Length) { TextBoxComandoPesquisa.Text += parametros[i] + " "; } } } TextBoxComandoPesquisa.Focus(); if (!IsPostBack) { ImageButton lkListar = (ImageButton)Master.FindControl("ImageButtonListar"); lkListar.Visible = false; ImageButton lkCadastrar = (ImageButton)Master.FindControl("ImageButtonCadastrar"); lkCadastrar.Visible = false; ImageButton lkAjuda = (ImageButton)Master.FindControl("ImageButtonAjuda"); lkAjuda.Visible = false; comando = (String)Session["lista"]; Adaptador adpt = new Adaptador(); List<Processo> processos = new List<Processo>(); GridView1.DataSource = adpt.PesquisarCampos(comando); GridView1.DataBind(); usuarioConectado = (String)Session["usuario"]; senhaConectado = (String)Session["senha"]; GoldenAccess servicoDeAutenticacao = new GoldenAccess("http://localhost:3271/GoldenAccess.soap"); User usuarioGoldenAccess = new User(usuarioConectado, senhaConectado); try { usuarioGoldenAccess = servicoDeAutenticacao.Authenticate(usuarioConectado, senhaConectado); } catch (Exception ex) { LabelErro.Text = ex.Message; } if (usuarioGoldenAccess.IsAuthenticated && !usuarioGoldenAccess.Disabled) { } else { erro = "Usuário não autenticado"; Session.Add("erro", erro); Server.Transfer("Login.aspx"); Session.Abandon(); } } }
protected void GridView1_RowCommand1(object sender, GridViewCommandEventArgs e) { int index; usuarioConectado = (String)Session["usuario"]; senhaConectado = (String)Session["senha"]; GoldenAccess goldenAccess = new GoldenAccess("http://localhost:3271/GoldenAccess.soap"); User usuario = new User(usuarioConectado, senhaConectado); try { usuario = goldenAccess.Authenticate(usuarioConectado, senhaConectado); } catch (Exception ex) { LabelErro.Text = ex.Message; } if (usuario.IsAuthenticated && !usuario.Disabled) { if (usuario.HasGroup("TCESEADM")) { if (e.CommandName == "Alterar") { index = Convert.ToInt32(e.CommandArgument); string id = (String)GridView1.DataKeys[index].Value.ToString(); Session.Add("id", id); Server.Transfer("Alterar.aspx"); } if (e.CommandName == "Excluir") { index = Convert.ToInt32(e.CommandArgument); int id = Convert.ToInt32(GridView1.DataKeys[index].Value); Adaptador adpt = new Adaptador(); Processo processo = new Processo(); processo = adpt.obterProcessoPorId(id.ToString()); string nomeArquivoAntigo = processo.arq_Arquivo; if (nomeArquivoAntigo != null) { string diretorioRemover = Settings.Default.CaminhoDoRepositorioJurisprudencia + nomeArquivoAntigo; FileInfo arquivoAntigo = new FileInfo(diretorioRemover); arquivoAntigo.Delete(); } adpt.RemoveProcesso(id); } if (e.CommandName == "Abrir") { string nome = ""; try { index = Convert.ToInt32(e.CommandArgument) - (GridView1.PageSize * GridView1.PageIndex); int id = Convert.ToInt32(GridView1.DataKeys[index].Value); Adaptador adpt = new Adaptador(); Processo processo = new Processo(); processo = adpt.obterProcessoPorId(id.ToString()); nome = processo.arq_Arquivo; diretorio = Server.MapPath(Settings.Default.CaminhoDoRepositorioJurisprudencia); if (Directory.Exists(diretorio)) { Response.Clear(); Response.ClearHeaders(); Response.AddHeader("Content-Type", "application/pdf"); Response.AddHeader("Content-Disposition", "attachment; filename=" + nome); FileStream file = new FileStream(diretorio + nome, System.IO.FileMode.Open, FileAccess.Read); byte[] bytes = new byte[Convert.ToInt32(file.Length)]; file.Read(bytes, 0, bytes.Length); file.Close(); Response.OutputStream.Write(bytes, 0, bytes.GetUpperBound(0)); Response.Flush(); Response.Close(); } else { LabelErro.Text = "Diretório " + diretorio + " não encontrado"; } } catch (Exception ex) { LabelErro.Text = ex.Message; } } if (e.CommandName == "AbrirDecisao") { index = Convert.ToInt32(e.CommandArgument); int id = Convert.ToInt32(GridView1.DataKeys[index].Value); Adaptador adpt = new Adaptador(); Processo processo = new Processo(); processo = adpt.obterProcessoPorId(id.ToString()); diretorio = Server.MapPath(Settings.Default.CaminhoDoRepositorioDecisao); //string subDiretorio = processo.decisao.Substring(processo.decisao.IndexOf("\\DECISAO$") + 9); nome = processo.decisao.Substring(processo.decisao.LastIndexOf('\\') + 1); //subDiretorio = subDiretorio.Replace(nome, ""); if (processo.decisao == null || processo.decisao == "") { //Response.Write("<script>alert('Ainda não existe decisão para esse processo')</script>"); LabelErro.Text = "Não existe decisão para este processo"; } else { if (Directory.Exists(diretorio)) { Response.Clear(); Response.ClearHeaders(); Response.AddHeader("Content-Type", "application/pdf"); Response.AddHeader("Content-Disposition", "attachment; filename=" + nome); FileStream file = new FileStream(diretorio /*+ subDiretorio*/ + nome, System.IO.FileMode.Open, FileAccess.Read); byte[] bytes = new byte[Convert.ToInt32(file.Length)]; file.Read(bytes, 0, bytes.Length); file.Close(); Response.OutputStream.Write(bytes, 0, bytes.GetUpperBound(0)); Response.Flush(); Response.Close(); } } GridView1.Rows[index].Cells[1].Enabled = true; } } else { LabelErro.Text = "Você não tem permissão para " + e.CommandName + " esse registro."; } } else { LabelErro.Text = "Você não é usuário do sistema."; } }
protected void ImageButtonPesquisar_Click(object sender, ImageClickEventArgs e) { if (TextBoxNumeroProcesso.Text == "" && TextBoxAnoProcesso.Text == "" && TextBoxOrigem.Text == "" && TextBoxAssunto.Text == "" && TextBoxDescricao.Text == "" && TextBoxInteressado.Text == "" && TextBoxQualquerCampo.Text == "") { LabelErro.Text = "Não existem campos para pesquisa"; } else { comando = "textsearch in tcejurisprudencia "; if (TextBoxQualquerCampo.Text != "") { comando += montarComando(TextBoxQualquerCampo.Text); if (TextBoxNumeroProcesso.Text != "") { campos += TextBoxNumeroProcesso.Text + " "; comando += " E " + TextBoxNumeroProcesso.Text + "[numero_Processo] "; } if (TextBoxAnoProcesso.Text != "") { campos += TextBoxAnoProcesso.Text + " "; comando += " E " + TextBoxAnoProcesso.Text + "[ano_Processo] "; i++; } if (TextBoxOrigem.Text != "") { campos += TextBoxOrigem.Text + " "; comando += " E " + montarComandoPROX(TextBoxOrigem.Text) + "[origem] "; i++; } if (TextBoxAssunto.Text != "") { campos += TextBoxAssunto.Text + " "; comando += " E " + montarComandoPROX(TextBoxAssunto.Text) + " [assunto] "; i++; } if (TextBoxDescricao.Text != "") { campos += TextBoxDescricao.Text + " "; comando += " E " + montarComandoPROX(TextBoxDescricao.Text) + " [descricao] "; i++; } if (TextBoxInteressado.Text != "") { campos += TextBoxInteressado.Text + " "; comando += " E " + montarComandoPROX(TextBoxInteressado.Text) + "[nome]"; i++; } campos += TextBoxQualquerCampo.Text; } else { if (TextBoxNumeroProcesso.Text != "") { campos += TextBoxNumeroProcesso.Text + " "; comando += TextBoxNumeroProcesso.Text + "[numero_Processo] "; i++; } if (TextBoxAnoProcesso.Text != "") { campos += TextBoxAnoProcesso.Text + " "; if (i >= 1) { comando += " E " + TextBoxAnoProcesso.Text + "[ano_Processo] "; i++; } else if (i == 0) { comando += TextBoxAnoProcesso.Text + "[ano_Processo] "; i++; } } if (TextBoxOrigem.Text != "") { campos += TextBoxOrigem.Text + " "; if (i >= 1) { comando += " E " + montarComandoPROX(TextBoxOrigem.Text) + "[origem] "; i++; } else if (i == 0) { comando += montarComandoPROX(TextBoxOrigem.Text) + "[origem] "; i++; } } if (TextBoxAssunto.Text != "") { campos += TextBoxAssunto.Text + " "; if (i >= 1) { comando += " E " + montarComandoPROX(TextBoxAssunto.Text) + "[assunto] "; i++; } else if (i == 0) { comando += montarComandoPROX(TextBoxAssunto.Text) + "[assunto] "; i++; } } if (TextBoxDescricao.Text != "") { campos += TextBoxDescricao.Text + " "; if (i >= 1) { comando += " E " + montarComandoPROX(TextBoxDescricao.Text) + "[descricao] "; i++; } else if (i == 0) { comando += montarComandoPROX(TextBoxDescricao.Text) + "[descricao] "; i++; } } if (TextBoxInteressado.Text != "") { campos += TextBoxInteressado.Text + " "; if (i >= 1) { comando += " E " + montarComandoPROX(TextBoxInteressado.Text) + "[nome]"; i++; } else if (i == 0) { comando += montarComandoPROX(TextBoxInteressado.Text) + "[nome]"; i++; } } } Session.Add("ComandoPesquisa", comando); Session.Add("Campos", campos); } Adaptador adpt = new Adaptador(); List <Processo> lista = adpt.PesquisaPorCampo(comando); if (lista.Count == 0) { LabelErro.Text = "Não foram encontrados resultados para essa pesquisa"; } else { Session.Add("lista", comando); Session.Add("modulo", 0); Session.Add("pagina", pagina); try { Server.Transfer("pesquisar.aspx"); } catch (Exception ex) { LabelErro.Text = ex.Message; } } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { ImageButton lkCadastrar = (ImageButton)Master.FindControl("ImageButtonCadastrar"); lkCadastrar.Visible = false; ImageButton lkListar = (ImageButton)Master.FindControl("ImageButtonListar"); lkListar.Visible = false; ImageButton lkAjuda = (ImageButton)Master.FindControl("ImageButtonAjuda"); lkAjuda.Visible = false; usuarioConectado = (String)Session["usuario"]; senhaConectado = (String)Session["senha"]; GoldenAccess goldenAccess = new GoldenAccess("http://localhost:3271/GoldenAccess.soap"); User usuario = new User(usuarioConectado, senhaConectado); try { usuario = goldenAccess.Authenticate(usuarioConectado, senhaConectado); } catch (Exception ex) { LabelErro.Text = ex.Message; } if (usuario.IsAuthenticated && !usuario.Disabled) { } else { erro = "Usuário não autenticado"; Session.Add("erro", erro); Server.Transfer("login.aspx"); Session.Abandon(); } Adaptador adpt = new Adaptador(); List<Processo> lista = new List<Processo>(); lista = adpt.Todos(); GridView1.DataSource = lista; GridView1.DataBind(); } }
protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e) { int index; usuarioConectado = (String)Session["usuario"]; senhaConectado = (String)Session["senha"]; GoldenAccess goldenAccess = new GoldenAccess("http://localhost:3271/GoldenAccess.soap"); User usuario = new User(usuarioConectado, senhaConectado); try { usuario = goldenAccess.Authenticate(usuarioConectado, senhaConectado); } catch (Exception ex) { LabelErro.Text = ex.Message; } if (usuario.IsAuthenticated && !usuario.Disabled) { if (usuario.HasGroup("TCESEADM")) { if (e.CommandName == "Abrir") { string nome = ""; try { index = Convert.ToInt32(e.CommandArgument) - (GridView1.PageSize * GridView1.PageIndex); int id = Convert.ToInt32(GridView1.DataKeys[index].Value); Adaptador adpt = new Adaptador(); Processo processo = new Processo(); processo = adpt.obterProcessoPorId(id.ToString()); nome = processo.arq_Arquivo; //diretorio = Server.MapPath("~\\arquivos\\jurisprudencia\\"); diretorio = Server.MapPath(Settings.Default.CaminhoDoRepositorioJurisprudencia); //diretorio = "\\\\tce-s008\\GED_Arquivos\\jurisprudencia\\"; if (Directory.Exists(diretorio)) { Response.Clear(); Response.ClearHeaders(); Response.AddHeader("Content-Type", "application/pdf"); Response.AddHeader("Content-Disposition", "attachment; filename=" + nome); FileStream file = new FileStream(diretorio + nome, System.IO.FileMode.Open, FileAccess.Read); byte[] bytes = new byte[Convert.ToInt32(file.Length)]; file.Read(bytes, 0, bytes.Length); file.Close(); Response.OutputStream.Write(bytes, 0, bytes.GetUpperBound(0)); Response.Flush(); Response.Close(); } else { LabelErro.Text = "Diretório " + diretorio + " não encontrado"; } } catch (Exception ex) { LabelErro.Text = ex.Message; } } if (e.CommandName == "Alterar") { index = Convert.ToInt32(e.CommandArgument); string id = (String)GridView1.DataKeys[index].Value.ToString(); Session.Add("id", id); Server.Transfer("Alterar.aspx"); } if (e.CommandName == "Excluir") { index = Convert.ToInt32(e.CommandArgument); int id = Convert.ToInt32(GridView1.DataKeys[index].Value); Adaptador adpt = new Adaptador(); Processo processo = new Processo(); processo = adpt.obterProcessoPorId(id.ToString()); string nomeArquivoAntigo = processo.arq_Arquivo; if (nomeArquivoAntigo != null) { string diretorioRemover = Settings.Default.CaminhoDoRepositorioJurisprudencia + nomeArquivoAntigo; FileInfo arquivoAntigo = new FileInfo(diretorioRemover); arquivoAntigo.Delete(); } adpt.RemoveProcesso(id); } if (e.CommandName == "AbrirDecisao") { index = Convert.ToInt32(e.CommandArgument); int id = Convert.ToInt32(GridView1.DataKeys[index].Value); Adaptador adpt = new Adaptador(); Processo processo = new Processo(); processo = adpt.obterProcessoPorId(id.ToString()); diretorio = Server.MapPath(Settings.Default.CaminhoDoRepositorioDecisao); string subDiretorio = processo.decisao.Substring(processo.decisao.IndexOf("\\DECISAO$") + 9); nome = processo.decisao.Substring(processo.decisao.LastIndexOf('\\') + 1); subDiretorio = subDiretorio.Replace(nome, ""); if (processo.decisao == null) { //Response.Write("<script>alert('Ainda não existe decisão para esse processo')</script>"); LabelErro.Text = "Não existe decisão para este processo"; } else { //if (Directory.Exists(diretorio)) //{ Response.Clear(); Response.ClearHeaders(); Response.AddHeader("Content-Type", "application/pdf"); Response.AddHeader("Content-Disposition", "attachment; filename=" + nome); FileStream file = new FileStream(diretorio + subDiretorio + nome, System.IO.FileMode.Open, FileAccess.Read); byte[] bytes = new byte[Convert.ToInt32(file.Length)]; file.Read(bytes, 0, bytes.Length); file.Close(); Response.OutputStream.Write(bytes, 0, bytes.GetUpperBound(0)); Response.Flush(); Response.Close(); //} } GridView1.Rows[index].Cells[1].Enabled = true; } } else if (usuario.HasGroup("TCESELIM")) { if (e.CommandName == "Abrir") { string nome = ""; try { index = Convert.ToInt32(e.CommandArgument); int id = Convert.ToInt32(GridView1.DataKeys[index].Value); Adaptador adpt = new Adaptador(); Processo processo = new Processo(); processo = adpt.obterProcessoPorId(id.ToString()); nome = processo.arq_Arquivo; diretorio = Server.MapPath(Settings.Default.CaminhoDoRepositorioJurisprudencia); if (Directory.Exists(diretorio)) { Response.Clear(); Response.ClearHeaders(); Response.AddHeader("Content-Type", "application/pdf"); Response.AddHeader("Content-Disposition", "attachment; filename=" + nome); FileStream file = new FileStream(diretorio + nome, System.IO.FileMode.Open, FileAccess.Read); byte[] bytes = new byte[Convert.ToInt32(file.Length)]; file.Read(bytes, 0, bytes.Length); file.Close(); Response.OutputStream.Write(bytes, 0, bytes.GetUpperBound(0)); Response.Flush(); Response.Close(); } else { LabelErro.Text = "Diretório " + diretorio + " não encontrado"; } } catch (Exception ex) { LabelErro.Text = ex.Message; } } if (e.CommandName == "Alterar") { LabelErro.Text = "Você não tem permissão para " + e.CommandName + " esse registro."; } if (e.CommandName == "Excluir") { LabelErro.Text = "Você não tem permissão para " + e.CommandName + " esse registro."; } } else { LabelErro.Text = "Você não tem permissão para " + e.CommandName + " esse registro."; } } else { LabelErro.Text = "Você não é usuário do sistema."; } }