protected void Page_Load(object sender, EventArgs e) { TextBoxSenhaAtual.Focus(); GoldenAccess goldenAccess; User usuario = new User("", ""); ; string nome = (String)Session["usuario"]; string senha = (String)Session["senha"]; try { goldenAccess = new GoldenAccess("http://localhost:3271/GoldenAccess.soap"); usuario = goldenAccess.Authenticate(nome, senha); } catch (Exception ex) { LabelErro.Text = ex.Message; } if (usuario.IsAuthenticated) { LabelUsuario.Text = usuario.Login; } else { Server.Transfer("Login.aspx"); Session.Abandon(); } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { 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; ImageAttention.Visible = true; } if (usuario.IsAuthenticated && !usuario.Disabled) { } else { erro = "Usuário não autenticado"; Session.Add("erro", erro); Server.Transfer("Login.aspx"); Session.Abandon(); } comando = (String)Session["pesquisa"]; Adaptador adpt = new Adaptador(); GridView1.DataSource = adpt.PesquisarCampos(comando); GridView1.DataBind(); } }
protected void Page_Load(object sender, EventArgs e) { ImageButton lkListar = (ImageButton)Master.FindControl("ImageButtonListar"); lkListar.Visible = false; ImageButton lkAjuda = (ImageButton)Master.FindControl("ImageButtonAjuda"); lkAjuda.Visible = false; string usuarioConectado = (String)Session["usuario"]; string senhaConectado = (String)Session["senha"]; GoldenAccess servicoDeAutenticacao = new GoldenAccess("http://localhost:3271/GoldenAccess.soap"); LightInfocon.GoldenAccess.General.User usuarioGoldenAccess = new LightInfocon.GoldenAccess.General.User(usuarioConectado, senhaConectado); try { usuarioGoldenAccess = servicoDeAutenticacao.Authenticate(usuarioConectado, senhaConectado); } catch (Exception ex) { LabelErro.Text = ex.Message; } if (usuarioGoldenAccess.IsAuthenticated) { TextBoxSenhaAtual.Focus(); } else { Server.Transfer("login.aspx"); erro = "Usuário não autenticado"; Session.Add("erro", erro); Session.Abandon(); } }
/// <summary> /// Método usado para cadastrar o usuário no banco. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="System.Web.UI.ImageClickEventArgs"/> instance containing the event data.</param> protected void ImageButtonEnviar_Click(object sender, ImageClickEventArgs e) { Usuario usuario = new Usuario(); usuario.matricula = TextBoxMatricula.Text; usuario.login = TextBoxLogin.Text; usuario.password = TextSenha.Text; usuario.permissoes = retornaListaPermissoes(); Adaptador adpt = new Adaptador(); //inserir o usuario no GoldenAcess adpt.addUsuario(usuario); /***************** Faz criptografia da senha após cadastrar *********************/ GoldenAccess goldenAccess = new GoldenAccess("http://localhost:3271/GoldenAccess.soap"); try { User usuarioAccess = goldenAccess.Authenticate(TextBoxLogin.Text, TextSenha.Text); GoldenAccessService servicoGoldenAccess = new GoldenAccessService(usuarioAccess); //servicoGoldenAccess.ChangePassword(usuario.login, Convert.ToBase64String(usuario.password)); // ChangePassword(TextBoxLogin.Text, TextSenha.Text); } catch (Exception ex) { LabelErro.Text = ex.Message; } }
protected void ImageButtonConfirmar_Click(object sender, ImageClickEventArgs e) { GoldenAccess goldenAccess = new GoldenAccess("http://localhost:3271/GoldenAccess.soap"); try { User usuario = goldenAccess.Authenticate(LabelUsuario.Text, TextBoxSenhaAtual.Text); if (usuario.IsAuthenticated && cont <= 3) { GoldenAccessService servicoGoldenAccess = new GoldenAccessService(usuario); if (TextBoxNovaSenha.Text == TextBoxConfirmacaoSenha.Text) { cont++; servicoGoldenAccess.ChangePassword(LabelUsuario.Text, TextBoxNovaSenha.Text); LabelErro.Text = "Senha alterada com sucesso"; } else { LabelErro.Text = "Senha e confirmação precissam ser iguais"; } } else { LabelErro.Text = "Tentativas de mudança de senha excedidas"; } } catch (Exception ex) { LabelErro.Text = ex.Message; } }
protected void Page_Load(object sender, EventArgs e) { string usuarioConectado = (String)Session["usuario"]; string 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) { TextBoxBuscaPorPalavra.Focus(); } else { erro = "Usuário não autenticado"; Session.Add("erro", erro); Server.Transfer("Login.aspx"); Session.Abandon(); } }
/// <summary> /// Metodo usado para autencicar o usuário. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param> protected void Page_Load(object sender, EventArgs e) { TextBoxSenhaAtual.Focus(); GoldenAccess goldenAccess; User usuario = new User("", "");; string nome = (String)Session["usuario"]; string senha = (String)Session["senha"]; try { goldenAccess = new GoldenAccess("http://localhost:3271/GoldenAccess.soap"); usuario = goldenAccess.Authenticate(nome, senha); } catch (Exception ex) { LabelErro.Text = ex.Message; } if (usuario.IsAuthenticated) { LabelUsuario.Text = usuario.Login; } else { Server.Transfer("Login.aspx"); Session.Abandon(); } }
/// <summary> /// Método usado para confirmar a alteração da senha verificando a senha antiga e cadastrando a nova. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="System.Web.UI.ImageClickEventArgs"/> instance containing the event data.</param> protected void ImageButtonConfirmar_Click(object sender, ImageClickEventArgs e) { GoldenAccess goldenAccess = new GoldenAccess("http://localhost:3271/GoldenAccess.soap"); try { User usuario = goldenAccess.Authenticate(LabelUsuario.Text, TextBoxSenhaAtual.Text); if (usuario.IsAuthenticated && cont <= 3) { GoldenAccessService servicoGoldenAccess = new GoldenAccessService(usuario); if (TextBoxNovaSenha.Text == TextBoxConfirmacaoSenha.Text) { cont++; servicoGoldenAccess.ChangePassword(LabelUsuario.Text, TextBoxNovaSenha.Text); LabelErro.Text = "Senha alterada com sucesso"; } else { LabelErro.Text = "Senha e confirmação precissam ser iguais"; } } else { LabelErro.Text = "Tentativas de mudança de senha excedidas"; } } catch (Exception ex) { LabelErro.Text = ex.Message; } }
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(); } } }
/* * Definição das funcionalidades que serão realizadas na carga da página. */ protected void Page_Load(object sender, EventArgs e) { // Mostrando e ocultando botões do menu dinamicamente. ImageButton lkPrincipal = (ImageButton)Master.FindControl("ImageButtonPrincipal"); lkPrincipal.Visible = false; ImageButton lkCadastrar = (ImageButton)Master.FindControl("ImageButtonCadastrar"); lkCadastrar.Visible = true; ImageButton lkListar = (ImageButton)Master.FindControl("ImageButtonListar"); lkListar.Visible = true; ImageButton lkAlterarSenha = (ImageButton)Master.FindControl("ImageButtonAlterarSenha"); lkAlterarSenha.Visible = true; ImageButton lkAjuda = (ImageButton)Master.FindControl("ImageButtonAjuda"); lkAjuda.Visible = true; ImageButton lkSair = (ImageButton)Master.FindControl("ImageButtonSair"); lkSair.Visible = true; TextBoxBuscaPorPalavra.Focus();//Dexiando o foco no campo de busca por palavra //Verificando se o usuário que está manipulando a página é o mesmo que acessou o sistema. string usuarioConectado = (String)Session["usuario"]; string senhaConectado = (String)Session["senha"]; GoldenAccess servicoDeAutenticacao = new GoldenAccess("http://localhost:3271/GoldenAccess.soap"); LightInfocon.GoldenAccess.General.User usuarioGoldenAccess = new LightInfocon.GoldenAccess.General.User(usuarioConectado, senhaConectado); try { usuarioGoldenAccess = servicoDeAutenticacao.Authenticate(usuarioConectado, senhaConectado); } catch (Exception ex) { LabelErro.Text = ex.Message; } if (usuarioGoldenAccess.IsAuthenticated) { TextBoxBuscaPorPalavra.Focus(); } else { //Caso não seja o mesmo usuário ele será redirecionado para o login e toda sessão será limpa. erro = "Usuário não autenticado"; Session.Add("erro", erro); Session.Abandon(); Server.Transfer("login.aspx"); } }
protected void Page_Load(object sender, EventArgs e) { TextBoxComandoPesquisa.Focus(); if (!IsPostBack) { ImageButton lkCadastrar = (ImageButton)Master.FindControl("ImageButtonCadastrar"); lkCadastrar.Visible = true; 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(); } campos = (String)Session["campo"]; //Pegando o parâmetro de consulta da página principal. TextBoxComandoPesquisa.Text = campos; //Listando os registros retornados pela pesquisa específica. comando = (String)Session["lista"]; Adaptador adpt = new Adaptador(); List <Prontuario> prontuario = new List <Prontuario>(); GridView1.DataSource = adpt.PesquisarCampos(comando); GridView1.DataBind(); } else { LabelErro.Text = "Não foram retornados resultados para essa consulta."; } }
protected void Page_Load(object sender, EventArgs e) { ImageButton lkAjuda = (ImageButton)Master.FindControl("ImageButtonAjuda"); lkAjuda.Visible = false; string usuarioConectado = (String)Session["usuario"]; string senhaConectado = (String)Session["senha"]; GoldenAccess servicoDeAutenticacao = new GoldenAccess("http://localhost:3271/GoldenAccess.soap"); LightInfocon.GoldenAccess.General.User usuarioGoldenAccess = new LightInfocon.GoldenAccess.General.User(usuarioConectado, senhaConectado); try { usuarioGoldenAccess = servicoDeAutenticacao.Authenticate(usuarioConectado, senhaConectado); } catch (Exception ex) { LabelErro.Text = ex.Message; } if (usuarioGoldenAccess.IsAuthenticated) { TextBoxNumeroProcesso.Focus(); } else { Server.Transfer("Login.aspx"); erro = "Usuário não autenticado"; Session.Add("erro", erro); Session.Abandon(); } if ((String)Session["id"] != null) { id = (String)Session["id"]; } else { Server.Transfer("Default.aspx"); erro = "Identificador do campo não encontrado"; Session.Add("erro", erro); } if (!Page.IsPostBack) { MontaTela(id); } }
protected void Page_Load(object sender, EventArgs e) { ImageButton lkPrincipal = (ImageButton)Master.FindControl("ImageButtonPrincipal"); lkPrincipal.Visible = true; ImageButton lkCadastrar = (ImageButton)Master.FindControl("ImageButtonCadastrar"); lkCadastrar.Visible = false; ImageButton lkListar = (ImageButton)Master.FindControl("ImageButtonListar"); lkListar.Visible = true; ImageButton lkAlterarSenha = (ImageButton)Master.FindControl("ImageButtonAlterarSenha"); lkAlterarSenha.Visible = true; ImageButton lkAjuda = (ImageButton)Master.FindControl("ImageButtonAjuda"); lkAjuda.Visible = false; ImageButton lkSair = (ImageButton)Master.FindControl("ImageButtonSair"); lkSair.Visible = true; string usuarioConectado = (String)Session["usuario"]; string senhaConectado = (String)Session["senha"]; GoldenAccess servicoDeAutenticacao = new GoldenAccess("http://localhost:3271/GoldenAccess.soap"); LightInfocon.GoldenAccess.General.User usuarioGoldenAccess = new LightInfocon.GoldenAccess.General.User(usuarioConectado, senhaConectado); try { usuarioGoldenAccess = servicoDeAutenticacao.Authenticate(usuarioConectado, senhaConectado); } catch (Exception ex) { LabelErro.Text = ex.Message; } if (usuarioGoldenAccess.IsAuthenticated) { TextBoxNumero_Registro.Focus(); } else { //Caso não seja o mesmo usuário, este será redirecionado para o login e a sessão será limpa. erro = "Usuário não autenticado"; Session.Add("erro", erro); Session.Abandon(); Server.Transfer("login.aspx"); } }
protected void Page_Load(object sender, EventArgs e) { string usuarioConectado = (String)Session["usuario"]; string senhaConectado = (String)Session["senha"]; GoldenAccess servicoDeAutenticacao = new GoldenAccess("http://localhost:3271/GoldenAccess.soap"); LightInfocon.GoldenAccess.General.User usuarioGoldenAccess = new LightInfocon.GoldenAccess.General.User(usuarioConectado, senhaConectado); try { usuarioGoldenAccess = servicoDeAutenticacao.Authenticate(usuarioConectado, senhaConectado); } catch (Exception ex) { LabelErro.Text = ex.Message; } if (usuarioGoldenAccess.IsAuthenticated) { TextBoxNumero_Registro.Focus(); } else { erro = "Usuário não autenticado"; Session.Add("erro", erro); Session.Abandon(); Server.Transfer("login.aspx"); } if ((String)Session["id"] != null) { id = (String)Session["id"]; } else { Server.Transfer("default.aspx"); erro = "Identificador do campo não encontrado"; Session.Add("erro", erro); } //Caso esteja sendo aberta pela primeira vez, a página buscará os valores dos campos. if (!Page.IsPostBack) { MontaTela(id); } }
protected void Page_Load(object sender, EventArgs e) { 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"]; AdaptadorDespesa adpt = new AdaptadorDespesa(); List <Despesa> despesas = new List <Despesa>(); 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) { //GridView1.DataSource = despesas; //GridView1.DataBind(); } else { erro = "Usuário não autenticado"; Session.Add("erro", erro); Server.Transfer("Login.aspx"); Session.Abandon(); } } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { //ImageButton lkCadastrar = (ImageButton)Master.FindControl("ImageButtonCadastrar"); //lkCadastrar.Visible = true; //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(); GridView1.DataSource = adpt.Todos(); GridView1.DataBind(); } }
public bool AlterarSenha(string nome, string novaSenha) { GoldenAccess servicoDeAutenticacao = new GoldenAccess("http://localhost:3271/GoldenAccess.soap"); LightInfocon.GoldenAccess.General.User usuarioGoldenAccess = new LightInfocon.GoldenAccess.General.User(nome, novaSenha); try { usuarioGoldenAccess = servicoDeAutenticacao.Authenticate(nome, novaSenha); } catch (Exception e) { string erro = e.Message; } if (usuarioGoldenAccess.IsAuthenticated && usuarioGoldenAccess.IsAdm) { return true; } else { return false; } }
/// <summary> /// Método usado para alterar a senha do usuário que esta logado. /// </summary> /// <param name="nome">O username.</param> /// <param name="novaSenha">A nova senha.</param> /// <returns>um booleano informando se foi auterada.</returns> public bool AlterarSenha(string nome, string novaSenha) { GoldenAccess servicoDeAutenticacao = new GoldenAccess("http://localhost:3271/GoldenAccess.soap"); LightInfocon.GoldenAccess.General.User usuarioGoldenAccess = new LightInfocon.GoldenAccess.General.User(nome, novaSenha); try { usuarioGoldenAccess = servicoDeAutenticacao.Authenticate(nome, novaSenha); } catch (Exception e) { string erro = e.Message; } if (usuarioGoldenAccess.IsAuthenticated && usuarioGoldenAccess.IsAdm) { return(true); } else { return(false); } }
/// <summary> /// Método que verifica se o usuário está autenticado e preenche o grid com a listagem de LOG. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param> protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { 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) { } if (usuario.IsAuthenticated && !usuario.Disabled) { } else { erro = "Usuário não autenticado"; Session.Add("erro", erro); Server.Transfer("Login.aspx"); Session.Abandon(); } Session.Add("coluna", "id"); Session.Add("orderBy", "desc"); Session.Add("campos", null); comando = "textsearch in log "; Session.Add("pesquisaLOG", comando); Adaptador adpt = new Adaptador(); listaLog = adpt.TodosLogs(); Session.Add("listaLog", listaLog); //GridView1.DataSource = bindGrid("sort"); GridView1.DataSource = listaLog; GridView1.DataBind(); } listaLog = (List <Log>)Session["listaLog"]; }
protected void Page_Load(object sender, EventArgs e) { ImageButton lkListar = (ImageButton)Master.FindControl("ImageButtonListar"); lkListar.Visible = false; ImageButton lkCadastrar = (ImageButton)Master.FindControl("ImageButtonCadastrar"); lkCadastrar.Visible = false; ImageButton lkAlterarSenha = (ImageButton)Master.FindControl("ImageButtonAlterarSenha"); lkAlterarSenha.Visible = false; ImageButton lkAjuda = (ImageButton)Master.FindControl("ImageButtonAjuda"); lkAjuda.Visible = false; TextBoxSenhaAtual.Focus(); GoldenAccess goldenAccess; User usuario = new User("", "");; string nome = (String)Session["usuario"]; string senha = (String)Session["senha"]; try { goldenAccess = new GoldenAccess("http://localhost:3271/GoldenAccess.soap"); usuario = goldenAccess.Authenticate(nome, senha); } catch (Exception ex) { LabelErro.Text = ex.Message; } if (usuario.IsAuthenticated) { LabelUsuario.Text = usuario.Login; } else { Server.Transfer("Login.aspx"); Session.Abandon(); } }
protected void Page_Load(object sender, EventArgs e) { //// Create a merge document and set it's properties //MergeDocument document = MergeDocument.Merge( MapPath( "../PDFs/DocumentA.pdf" ), MapPath( "../PDFs/DocumentB.pdf" )); //// Append additional PDF //document.Append( MapPath( "../PDFs/DocumentC.pdf" ) ); //// Append 3 pages from an aditional PDF //document.Append( MapPath( "../PDFs/DocumentD.pdf" ), 1, 3 ); //// Outputs the merged document to the current web page //document.DrawToWeb( "MergePDFs.pdf" ); string usuarioConectado = (String)Session["usuario"]; string senhaConectado = (String)Session["senha"]; GoldenAccess servicoDeAutenticacao = new GoldenAccess("http://localhost:3271/GoldenAccess.soap"); LightInfocon.GoldenAccess.General.User usuarioGoldenAccess = new LightInfocon.GoldenAccess.General.User(usuarioConectado, senhaConectado); try { usuarioGoldenAccess = servicoDeAutenticacao.Authenticate(usuarioConectado, senhaConectado); } catch (Exception ex) { string erro = ex.Message; } if (usuarioGoldenAccess.IsAuthenticated) { FileUpload1.Focus(); } else { //Caso não seja o mesmo usuário, este será redirecionado para o login e a sessão será limpa. erro = "Usuário não autenticado"; Session.Add("erro", erro); Session.Abandon(); Server.Transfer("login.aspx"); } }
/* * Método que verifica as permissões de acesso de um usuário a aplicação. */ public int EfetuaLogin(string nome, string senha) { GoldenAccess goldenAccess = new GoldenAccess("http://localhost:3271/GoldenAccess.soap"); LightInfocon.GoldenAccess.General.User usuario = new LightInfocon.GoldenAccess.General.User(nome, senha); //Validação de usuário e senha try { usuario = goldenAccess.Authenticate(nome, senha); //Autenticação de usuário e senha. } catch (Exception ex) { if (!usuario.IsAuthenticated) { string erro = ex.Message; return(4); } } if (usuario.IsAuthenticated) { if (usuario.HasGroup("PTRIOADM")) { return(1);//Será retornado 1 caso o usuário seja administrado do sistema. } else if (usuario.HasGroup("PTRIOLIM")) { return(2);// Será retornado 2 caso o usuário tenha permissões limitadas a aplicação (Apenas consulta). } else { return(3);// Será retornado 3 caso não seja um usuário do sistema. } } else { return(5);// Será retornado 5 caso o erro gerado não tenha sido identificado. } }
/// <summary> /// Método que retorna o tipo de usuário no login. /// </summary> /// <param name="nome">O username.</param> /// <param name="senha">A senha.</param> /// <returns></returns> public int EfetuaLogin(string nome, string senha) { GoldenAccess goldenAccess = new GoldenAccess("http://localhost:3271/GoldenAccess.soap"); LightInfocon.GoldenAccess.General.User usuario = new LightInfocon.GoldenAccess.General.User(nome, senha); try { usuario = goldenAccess.Authenticate(nome, senha); } catch (Exception ex) { if (!usuario.IsAuthenticated) { string erro = ex.Message; return(4); } } if (usuario.IsAuthenticated) { if (usuario.HasGroup("RHADM")) { return(1); } else if (usuario.HasGroup("RHLIM")) { return(2); } else { return(3); } } else { return(5); } }
/// <summary> /// Método usado para verificar se o usuário esta autenticado. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param> protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { 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) { erro = ex.Message; } if (usuario.IsAuthenticated && !usuario.Disabled) { if (usuario.HasGroup("RHADM")) { LinkButtonLog.Visible = true; } else if (usuario.HasGroup("RHLIM")) { LinkButtonLog.Visible = false; } } else { erro = "Usuário não autenticado"; Session.Add("erro", erro); Server.Transfer("Login.aspx"); Session.Abandon(); } } }
public int EfetuaLogin(string nome, string senha) { GoldenAccess goldenAccess = new GoldenAccess("http://localhost:3271/GoldenAccess.soap"); LightInfocon.GoldenAccess.General.User usuario = new LightInfocon.GoldenAccess.General.User(nome, senha); try { usuario = goldenAccess.Authenticate(nome, senha); } catch (Exception ex) { if (!usuario.IsAuthenticated) { string erro = ex.Message; return 4; } } if (usuario.IsAuthenticated) { if (usuario.HasGroup("RHADM")) { return 1; } else if (usuario.HasGroup("RHADM")) { return 2; } else { return 3; } } else { return 5; } }
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("PTRIOADM")) { 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(); Prontuario prontuario = new Prontuario(); Medico medico = new Medico(); prontuario = adpt.obterProntuarioPorId(id.ToString()); medico = prontuario.medico; nome = prontuario.arq_Arquivo; //diretorio = Server.MapPath(Settings.Default.CaminhoDoRepositorioProntuario); diretorio = Server.MapPath("~\\arquivos\\"); Medico medicosSolicitantes = new Medico(); medicosSolicitantes = medicoParticipante(prontuario.numero_Registro, usuarioConectado); if(medicosSolicitantes.matricula_Medico1 == medico.matricula_Medico1 || medicosSolicitantes.matricula_Medico2 == medico.matricula_Medico2 || medicosSolicitantes.matricula_Medico3 == medico.matricula_Medico3 || medicosSolicitantes.matricula_Medico4 == medico.matricula_Medico4 || usuario.Login == "admpront") { 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"; } } else { LabelErro.Text = "Você não tem permissão para " + e.CommandName + " esse prontuário"; } } catch (Exception ex) { LabelErro.Text = ex.Message; } } if (e.CommandName == "Alterar") { index = Convert.ToInt32(e.CommandArgument) - (GridView1.PageSize * GridView1.PageIndex); int id = Convert.ToInt32(GridView1.DataKeys[index].Value); Prontuario prontuario = new Prontuario(); Adaptador adpt = new Adaptador(); prontuario = adpt.obterProntuarioPorId(id.ToString()); Medico medico = new Medico(); Medico medicosSolicitantes = new Medico(); medicosSolicitantes = medicoParticipante(prontuario.numero_Registro, usuarioConectado); if (medicosSolicitantes.matricula_Medico1 == medico.matricula_Medico1 || medicosSolicitantes.matricula_Medico2 == medico.matricula_Medico2 || medicosSolicitantes.matricula_Medico3 == medico.matricula_Medico3 || medicosSolicitantes.matricula_Medico4 == medico.matricula_Medico4 || usuario.Login == "admpront") { Session.Add("id", id.ToString()); Server.Transfer("alterarpaciente.aspx"); } else { LabelErro.Text = "Você não possui permissão para " + e.CommandName + " esse prontuário"; } } if (e.CommandName == "Excluir") { index = Convert.ToInt32(e.CommandArgument) - (GridView1.PageSize * GridView1.PageIndex); ; int id = Convert.ToInt32(GridView1.DataKeys[index].Value); Medico medico = new Medico(); Adaptador adpt = new Adaptador(); Prontuario prontuario = new Prontuario(); prontuario = adpt.obterProntuarioPorId(id.ToString()); Medico medicosSolicitantes = new Medico(); medicosSolicitantes = medicoParticipante(prontuario.numero_Registro, usuarioConectado); if (medicosSolicitantes.matricula_Medico1 == medico.matricula_Medico1 || medicosSolicitantes.matricula_Medico2 == medico.matricula_Medico2 || medicosSolicitantes.matricula_Medico3 == medico.matricula_Medico3 || medicosSolicitantes.matricula_Medico4 == medico.matricula_Medico4 || usuario.Login == "admpront") { string nomeArquivoAntigo = prontuario.arq_Arquivo; if (nomeArquivoAntigo != null) { string diretorioRemover = Settings.Default.CaminhoDoRepositorioProntuario + nomeArquivoAntigo; FileInfo arquivoAntigo = new FileInfo(diretorioRemover); arquivoAntigo.Delete(); } adpt.RemoverProntuario(id); GridView1.DataSource = adpt.Todos(); GridView1.DataBind(); } else { LabelErro.Text = "Você não possui permissão para " + e.CommandName + " esse prontuário"; } } } else if (usuario.HasGroup("PTRIOLIM")) { if (e.CommandName == "Abrir") { LabelErro.Text = "Você não tem permissão para " + e.CommandName + " esse prontuário."; //string nome = ""; //try //{ // index = Convert.ToInt32(e.CommandArgument); // int id = Convert.ToInt32(GridView1.DataKeys[index].Value); // Adaptador adpt = new Adaptador(); // Prontuario processo = new Prontuario(); // processo = adpt.obterProntuarioPorId(id.ToString()); // nome = processo.arq_Arquivo; // diretorio = Server.MapPath(Settings.Default.CaminhoDoRepositorioProntuario); // 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."; } }
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; ImageAttention.Visible = true; } if (usuario.IsAuthenticated && !usuario.Disabled) { if (usuario.HasGroup("RHADM")) { 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(); Documento processo = new Documento(); processo = adpt.obterDocumentoPorId(id.ToString()); //nome = processo.arq_Arquivo; diretorio = Server.MapPath(Settings.Default.CaminhoDoRepositorioDocumento); 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"; ImageAttention.Visible = true; } } catch (Exception ex) { LabelErro.Text = ex.Message; ImageAttention.Visible = true; } } if (e.CommandName == "Alterar") { index = Convert.ToInt32(e.CommandArgument) - (GridView1.PageSize * GridView1.PageIndex); int id = Convert.ToInt32(GridView1.DataKeys[index].Value); Session.Add("id", id.ToString()); Server.Transfer("alterarColaborador.aspx"); } if (e.CommandName == "Excluir") { index = Convert.ToInt32(e.CommandArgument) - (GridView1.PageSize * GridView1.PageIndex); ; int id = Convert.ToInt32(GridView1.DataKeys[index].Value); Adaptador adpt = new Adaptador(); Documento documento = new Documento(); documento = adpt.obterDocumentoPorId(id.ToString()); //testar se ta pegando os arquivos certos if (documento.arquivos != null) { //loop que pega os nomes dos arquivos e deleta foreach (var arq in documento.arquivos) { string nomeArquivoAntigo = arq.nome_Arquivo; if (nomeArquivoAntigo != null) { string diretorioRemover = HttpContext.Current.Server.MapPath("~/arquivos/") + nomeArquivoAntigo; FileInfo arquivoAntigo = new FileInfo(diretorioRemover); arquivoAntigo.Delete(); } } } adpt.RemoverDocumento(id); Log log = new Log(); log.data_log = DateTime.Now; log.tipo_acao_log = "Excluir"; log.usuario_log = (String)Session["usuario"]; log.mensagem_acao_log = "O usuário " + log.usuario_log + " deletou o colaborador de matrícula " + documento.matricula_Colaborador; adpt.InserirLog(log); GridView1.DataSource = adpt.Todos(); GridView1.DataBind(); } } else if (usuario.HasGroup("RHLIM")) { if (e.CommandName == "Abrir") { string nome = ""; try { index = Convert.ToInt32(e.CommandArgument); int id = Convert.ToInt32(GridView1.DataKeys[index].Value); Adaptador adpt = new Adaptador(); Documento processo = new Documento(); processo = adpt.obterDocumentoPorId(id.ToString()); //ver como faço pra colocar o nome do arquivo dos documentos(titulacoes , CIs...) //nome = processo.arq_Arquivo; diretorio = Server.MapPath(Settings.Default.CaminhoDoRepositorioDocumento); 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"; ImageAttention.Visible = true; } } catch (Exception ex) { LabelErro.Text = ex.Message; ImageAttention.Visible = true; } } if (e.CommandName == "Alterar") { LabelErro.Text = "Você não tem permissão para " + e.CommandName + " esse registro."; ImageAttention.Visible = true; } if (e.CommandName == "Excluir") { LabelErro.Text = "Você não tem permissão para " + e.CommandName + " esse registro."; ImageAttention.Visible = true; } } else { LabelErro.Text = "Você não tem permissão para " + e.CommandName + " esse registro."; ImageAttention.Visible = true; } } else { LabelErro.Text = "Você não é usuário do sistema."; ImageAttention.Visible = true; } }
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."; } }
protected void Page_Load(object sender, EventArgs e) { TextBoxComandoPesquisa.Focus(); if (!IsPostBack) { ImageButton lkCadastrar = (ImageButton)Master.FindControl("ImageButtonCadastrar"); lkCadastrar.Visible = true; 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(); } campos = (String)Session["campo"]; //Pegando o parâmetro de consulta da página principal. TextBoxComandoPesquisa.Text = campos; //Listando os registros retornados pela pesquisa específica. comando = (String)Session["lista"]; Adaptador adpt = new Adaptador(); List<Prontuario> prontuario = new List<Prontuario>(); GridView1.DataSource = adpt.PesquisarCampos(comando); GridView1.DataBind(); } else { LabelErro.Text = "Não foram retornados resultados para essa consulta."; } }
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 == "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(); // adpt.RemoveProcesso(id); //} if (e.CommandName == "Abrir") { string nome = ""; string diretorio; try { index = Convert.ToInt32(e.CommandArgument) - (GridView1.PageSize * GridView1.PageIndex); int id = Convert.ToInt32(GridView1.DataKeys[index].Value); AdaptadorProtocolo adpt = new AdaptadorProtocolo(); Protocolo protocolo = new Protocolo(); protocolo = adpt.obterProtocoloPorId(id.ToString()); nome = protocolo.arq_Arquivo; //diretorio = Server.MapPath("~\\arquivos\\protocolos\\"); diretorio = Server.MapPath(Settings.Default.CaminhoDoRepositorioProtocolo); 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; } } } 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 Page_Load(object sender, EventArgs e) { //int codigo = (Int32)Session["login"]; ImageButton lkPrincipal = (ImageButton)Master.FindControl("ImageButtonPrincipal"); lkPrincipal.Visible = false; ImageButton lkCadastrar = (ImageButton)Master.FindControl("ImageButtonCadastrar"); lkCadastrar.Visible = false; ImageButton lkListar = (ImageButton)Master.FindControl("ImageButtonListar"); lkListar.Visible = true; ImageButton lkAlterarSenha = (ImageButton)Master.FindControl("ImageButtonAlterarSenha"); lkAlterarSenha.Visible = true; ImageButton lkAjuda = (ImageButton)Master.FindControl("ImageButtonAjuda"); lkAjuda.Visible = false; ImageButton lkSair = (ImageButton)Master.FindControl("ImageButtonSair"); lkSair.Visible = true; string usuarioConectado = (String)Session["usuario"]; string 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) { TextBoxNumeroProcesso.Focus(); } else { erro = "Usuário não autenticado"; Session.Add("erro", erro); Server.Transfer("Login.aspx"); Session.Abandon(); } //if (RadioButtonListTipos.Items.FindByText("Jurisprudência").Selected) //{ // PanelJurisprudencia.Visible = true; //} //else if (RadioButtonListTipos.Items.FindByText("Protocolo").Selected) //{ // PanelProtocolo.Visible = true; //} //else if (RadioButtonListTipos.Items.FindByText("Processo de Despesa").Selected) //{ // PanelProcessoDespesa.Visible = true; //} //else //{ // PanelProcessoDespesa.Visible = false; // PanelProtocolo.Visible = false; // PanelJurisprudencia.Visible = false; //} }
protected void Page_Load(object sender, EventArgs e) { ImageButton lkListar = (ImageButton)Master.FindControl("ImageButtonListar"); lkListar.Visible = false; ImageButton lkCadastrar = (ImageButton)Master.FindControl("ImageButtonCadastrar"); lkCadastrar.Visible = false; ImageButton lkAlterarSenha = (ImageButton)Master.FindControl("ImageButtonAlterarSenha"); lkAlterarSenha.Visible = false; ImageButton lkAjuda = (ImageButton)Master.FindControl("ImageButtonAjuda"); lkAjuda.Visible = false; TextBoxSenhaAtual.Focus(); GoldenAccess goldenAccess; User usuario = new User("", ""); ; string nome = (String)Session["usuario"]; string senha = (String)Session["senha"]; try { goldenAccess = new GoldenAccess("http://localhost:3271/GoldenAccess.soap"); usuario = goldenAccess.Authenticate(nome, senha); } catch (Exception ex) { LabelErro.Text = ex.Message; } if (usuario.IsAuthenticated) { LabelUsuario.Text = usuario.Login; } else { Server.Transfer("Login.aspx"); Session.Abandon(); } }
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 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("RHADM")) { 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(); Pessoa processo = new Pessoa(); processo = adpt.obterPessoaPorId(id.ToString()); nome = processo.arq_Arquivo; diretorio = Server.MapPath(Settings.Default.CaminhoDoRepositorioPessoa); 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) - (GridView1.PageSize * GridView1.PageIndex); int id = Convert.ToInt32(GridView1.DataKeys[index].Value); Session.Add("id", id.ToString()); Server.Transfer("alterarColaborador.aspx"); } if (e.CommandName == "Excluir") { index = Convert.ToInt32(e.CommandArgument) - (GridView1.PageSize * GridView1.PageIndex);; int id = Convert.ToInt32(GridView1.DataKeys[index].Value); Adaptador adpt = new Adaptador(); Pessoa processo = new Pessoa(); processo = adpt.obterPessoaPorId(id.ToString()); string nomeArquivoAntigo = processo.arq_Arquivo; if (nomeArquivoAntigo != null) { string diretorioRemover = Settings.Default.CaminhoDoRepositorioPessoa + nomeArquivoAntigo; FileInfo arquivoAntigo = new FileInfo(diretorioRemover); arquivoAntigo.Delete(); } adpt.RemoverPessoa(id); } } else if (usuario.HasGroup("RHLIM")) { if (e.CommandName == "Abrir") { string nome = ""; try { index = Convert.ToInt32(e.CommandArgument); int id = Convert.ToInt32(GridView1.DataKeys[index].Value); Adaptador adpt = new Adaptador(); Pessoa processo = new Pessoa(); processo = adpt.obterPessoaPorId(id.ToString()); nome = processo.arq_Arquivo; diretorio = Server.MapPath(Settings.Default.CaminhoDoRepositorioPessoa); 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."; } }
protected void Page_Load(object sender, EventArgs e) { 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"]; AdaptadorDespesa adpt = new AdaptadorDespesa(); List<Despesa> despesas = new List<Despesa>(); 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) { //GridView1.DataSource = despesas; //GridView1.DataBind(); } else { erro = "Usuário não autenticado"; Session.Add("erro", erro); Server.Transfer("Login.aspx"); Session.Abandon(); } } }
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; ImageAttention.Visible = true; } if (usuario.IsAuthenticated && !usuario.Disabled) { if (usuario.HasGroup("RHADM")) { 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(); Documento processo = new Documento(); processo = adpt.obterDocumentoPorId(id.ToString()); //nome = processo.arq_Arquivo; diretorio = Server.MapPath(Settings.Default.CaminhoDoRepositorioDocumento); 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"; ImageAttention.Visible = true; } } catch (Exception ex) { LabelErro.Text = ex.Message; ImageAttention.Visible = true; } } if (e.CommandName == "Alterar") { index = Convert.ToInt32(e.CommandArgument) - (GridView1.PageSize * GridView1.PageIndex); int id = Convert.ToInt32(GridView1.DataKeys[index].Value); Session.Add("id", id.ToString()); Server.Transfer("alterarColaborador.aspx"); } if (e.CommandName == "Excluir") { index = Convert.ToInt32(e.CommandArgument) - (GridView1.PageSize * GridView1.PageIndex);; int id = Convert.ToInt32(GridView1.DataKeys[index].Value); Adaptador adpt = new Adaptador(); Documento documento = new Documento(); documento = adpt.obterDocumentoPorId(id.ToString()); //testar se ta pegando os arquivos certos if (documento.arquivos != null) { //loop que pega os nomes dos arquivos e deleta foreach (var arq in documento.arquivos) { string nomeArquivoAntigo = arq.nome_Arquivo; if (nomeArquivoAntigo != null) { string diretorioRemover = HttpContext.Current.Server.MapPath("~/arquivos/") + nomeArquivoAntigo; FileInfo arquivoAntigo = new FileInfo(diretorioRemover); arquivoAntigo.Delete(); } } } adpt.RemoverDocumento(id); Log log = new Log(); log.data_log = DateTime.Now; log.tipo_acao_log = "Excluir"; log.usuario_log = (String)Session["usuario"]; log.mensagem_acao_log = "O usuário " + log.usuario_log + " deletou o colaborador de matrícula " + documento.matricula_Colaborador; adpt.InserirLog(log); GridView1.DataSource = adpt.Todos(); GridView1.DataBind(); } } else if (usuario.HasGroup("RHLIM")) { if (e.CommandName == "Abrir") { string nome = ""; try { index = Convert.ToInt32(e.CommandArgument); int id = Convert.ToInt32(GridView1.DataKeys[index].Value); Adaptador adpt = new Adaptador(); Documento processo = new Documento(); processo = adpt.obterDocumentoPorId(id.ToString()); //ver como faço pra colocar o nome do arquivo dos documentos(titulacoes , CIs...) //nome = processo.arq_Arquivo; diretorio = Server.MapPath(Settings.Default.CaminhoDoRepositorioDocumento); 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"; ImageAttention.Visible = true; } } catch (Exception ex) { LabelErro.Text = ex.Message; ImageAttention.Visible = true; } } if (e.CommandName == "Alterar") { LabelErro.Text = "Você não tem permissão para " + e.CommandName + " esse registro."; ImageAttention.Visible = true; } if (e.CommandName == "Excluir") { LabelErro.Text = "Você não tem permissão para " + e.CommandName + " esse registro."; ImageAttention.Visible = true; } } else { LabelErro.Text = "Você não tem permissão para " + e.CommandName + " esse registro."; ImageAttention.Visible = true; } } else { LabelErro.Text = "Você não é usuário do sistema."; ImageAttention.Visible = true; } }
protected void Page_Load(object sender, EventArgs e) { 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; 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(); } AdaptadorProtocolo adpt = new AdaptadorProtocolo(); GridView1.DataSource = adpt.Todos(); GridView1.DataBind(); } }
protected void Page_Load(object sender, EventArgs e) { ImageButton lkCadastrar = (ImageButton)Master.FindControl("ImageButtonCadastrar"); lkCadastrar.Visible = false; ImageButton lkPrincipal = (ImageButton)Master.FindControl("ImageButtonPrincipal"); lkPrincipal.Visible = true; ImageButton lkListar = (ImageButton)Master.FindControl("ImageButtonListar"); lkListar.Visible = false; ImageButton lkAjuda = (ImageButton)Master.FindControl("ImageButtonAjuda"); lkAjuda.Visible = false; string usuarioConectado = (String)Session["usuario"]; string senhaConectado = (String)Session["senha"]; GoldenAccess servicoDeAutenticacao = new GoldenAccess("http://localhost:3271/GoldenAccess.soap"); LightInfocon.GoldenAccess.General.User usuarioGoldenAccess = new LightInfocon.GoldenAccess.General.User(usuarioConectado, senhaConectado); try { usuarioGoldenAccess = servicoDeAutenticacao.Authenticate(usuarioConectado, senhaConectado); } catch (Exception ex) { LabelErro.Text = ex.Message; } if (usuarioGoldenAccess.IsAuthenticated) { TextBoxNumeroProcesso.Focus(); } else { erro = "Usuário não autenticado"; Session.Add("erro", erro); Server.Transfer("Login.aspx"); Session.Abandon(); } if (TextBoxQtdPessoas.Text == "") { TextBoxQtdPessoas.Text = "0"; } LabelPessoa1.Visible = false; LabelPessoa2.Visible = false; LabelPessoa3.Visible = false; LabelPessoa4.Visible = false; TextBoxPessoa1.Visible = false; TextBoxPessoa2.Visible = false; TextBoxPessoa3.Visible = false; TextBoxPessoa4.Visible = false; }
/* * Método que verifica as permissões de acesso de um usuário a aplicação. */ public int EfetuaLogin(string nome, string senha) { GoldenAccess goldenAccess = new GoldenAccess("http://localhost:3271/GoldenAccess.soap"); LightInfocon.GoldenAccess.General.User usuario = new LightInfocon.GoldenAccess.General.User(nome, senha); //Validação de usuário e senha try { usuario = goldenAccess.Authenticate(nome, senha); //Autenticação de usuário e senha. } catch(Exception ex) { if (!usuario.IsAuthenticated) { string erro = ex.Message; return 4; } } if (usuario.IsAuthenticated) { if (usuario.HasGroup("PTRIOADM")) { return 1;//Será retornado 1 caso o usuário seja administrado do sistema. } else if (usuario.HasGroup("PTRIOLIM")) { return 2;// Será retornado 2 caso o usuário tenha permissões limitadas a aplicação (Apenas consulta). } else { return 3;// Será retornado 3 caso não seja um usuário do sistema. } } else { return 5;// Será retornado 5 caso o erro gerado não tenha sido identificado. } }
/* * Método que trata o click em uma linha do grid. */ 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("PTRIOADM")) { //Caso seja clicado no botão abrir. if (e.CommandName == "Abrir") { string nome = ""; try { index = Convert.ToInt32(e.CommandArgument) - (GridView1.PageSize * GridView1.PageIndex); //pegando a linha clicada. int id = Convert.ToInt32(GridView1.DataKeys[index].Value); //pegando o id da linha Adaptador adpt = new Adaptador(); Prontuario prontuario = new Prontuario(); Medico medico = new Medico(); prontuario = adpt.obterProntuarioPorId(id.ToString()); medico = prontuario.medico; nome = prontuario.arq_Arquivo; //diretorio = Server.MapPath(Settings.Default.CaminhoDoRepositorioProntuario); diretorio = Server.MapPath("~\\arquivos\\");//pegando o diretório onde o arquivo encontra-se Medico medicosSolicitantes = new Medico(); medicosSolicitantes = medicoParticipante(prontuario.numero_Registro, usuarioConectado); if (medicosSolicitantes.matricula_Medico1 == medico.matricula_Medico1 || medicosSolicitantes.matricula_Medico2 == medico.matricula_Medico2 || medicosSolicitantes.matricula_Medico3 == medico.matricula_Medico3 || medicosSolicitantes.matricula_Medico4 == medico.matricula_Medico4 || usuario.Login == "admpront") { //Abertura do arquivo anexado. 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"; } } else { LabelErro.Text = "Você não tem permissão para consultar esse prontuário"; } } catch (Exception ex) { LabelErro.Text = ex.Message; } } //Caso seja clicado no botão alterar if (e.CommandName == "Alterar") { index = Convert.ToInt32(e.CommandArgument) - (GridView1.PageSize * GridView1.PageIndex); int id = Convert.ToInt32(GridView1.DataKeys[index].Value); Adaptador adpt = new Adaptador(); Prontuario prontuario = new Prontuario(); Medico medico = new Medico(); prontuario = adpt.obterProntuarioPorId(id.ToString()); medico = prontuario.medico; Medico medicosSolicitantes = new Medico(); medicosSolicitantes = medicoParticipante(prontuario.numero_Registro, usuarioConectado); if (medicosSolicitantes.matricula_Medico1 == medico.matricula_Medico1 || medicosSolicitantes.matricula_Medico2 == medico.matricula_Medico2 || medicosSolicitantes.matricula_Medico3 == medico.matricula_Medico3 || medicosSolicitantes.matricula_Medico4 == medico.matricula_Medico4 || usuario.Login == "admpront") { Session.Add("id", id.ToString()); Server.Transfer("alterarpaciente.aspx");//redirecionamento para a página de alteração de dados. } else { LabelErro.Text = "Você não tem permissão para consultar esse prontuário"; } } //Caso seja clicado no botão excluir. if (e.CommandName == "Excluir") { index = Convert.ToInt32(e.CommandArgument) - (GridView1.PageSize * GridView1.PageIndex);; int id = Convert.ToInt32(GridView1.DataKeys[index].Value); Adaptador adpt = new Adaptador(); Prontuario prontuario = new Prontuario(); Medico medico = new Medico(); prontuario = adpt.obterProntuarioPorId(id.ToString()); Medico medicosSolicitantes = new Medico(); medicosSolicitantes = medicoParticipante(prontuario.numero_Registro, usuarioConectado); if (medicosSolicitantes.matricula_Medico1 == medico.matricula_Medico1 || medicosSolicitantes.matricula_Medico2 == medico.matricula_Medico2 || medicosSolicitantes.matricula_Medico3 == medico.matricula_Medico3 || medicosSolicitantes.matricula_Medico4 == medico.matricula_Medico4 || usuario.Login == "admpront") { string nomeArquivoAntigo = prontuario.arq_Arquivo; if (nomeArquivoAntigo != null) { string diretorioRemover = Settings.Default.CaminhoDoRepositorioProntuario + nomeArquivoAntigo; FileInfo arquivoAntigo = new FileInfo(diretorioRemover); arquivoAntigo.Delete();//exclusão do arquivo } //recarga da página após a exclusão do registro. adpt.RemoverProntuario(id); GridView1.DataSource = adpt.Todos(); GridView1.DataBind(); } else { LabelErro.Text = "Você não tem permissão para consultar esse prontuário"; } } } //Caso o usuário não tenha permissão de modificar os dados. else if (usuario.HasGroup("PTRIOLIM")) { if (e.CommandName == "Abrir") { LabelErro.Text = "Você não tem permissão para " + e.CommandName + " esse prontuário."; //string nome = ""; //try //{ // index = Convert.ToInt32(e.CommandArgument); // int id = Convert.ToInt32(GridView1.DataKeys[index].Value); // Adaptador adpt = new Adaptador(); // Prontuario processo = new Prontuario(); // processo = adpt.obterProntuarioPorId(id.ToString()); // nome = processo.arq_Arquivo; // diretorio = Server.MapPath("~\\arquivos\\"); // 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."; } }
protected void Page_Load(object sender, EventArgs e) { 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; string usuarioConectado = (String)Session["usuario"]; string 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) { TextBoxBuscaQualquerPalavra.Focus(); } else { erro = "Usuário não autenticado"; Session.Add("erro", erro); Server.Transfer("Login.aspx"); Session.Abandon(); } }