Exemplo n.º 1
0
        /// <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;
            }
        }
Exemplo n.º 2
0
 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();
     }
 }
Exemplo n.º 3
0
 protected List<Documento> bindGrid()
 {
     comando = (String)Session["pesquisa"];
     List<Documento> lista = new List<Documento>();
     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;
 }
Exemplo n.º 4
0
 protected List<Pessoa> bindGrid()
 {
     List<Pessoa> lista = new List<Pessoa>();
     Adaptador adpt = new Adaptador();
     lista = adpt.PorColuna(coluna);
     return lista;
 }
Exemplo n.º 5
0
        /// <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;
            }
        }
Exemplo n.º 6
0
 protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)
 {
     GridView1.PageIndex = e.NewPageIndex;
     Adaptador adpt = new Adaptador();
     GridView1.DataSource = adpt.Todos();
     GridView1.DataBind();
 }
Exemplo n.º 7
0
 protected List<Documento> bindGrid()
 {
     List<Documento> lista = new List<Documento>();
     Adaptador adpt = new Adaptador();
     lista = adpt.PorColuna(coluna);
     return lista;
 }
Exemplo n.º 8
0
        protected List <Documento> bindGrid()
        {
            comando = (String)Session["pesquisa"];
            List <Documento> lista = new List <Documento>();
            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);
        }
Exemplo n.º 9
0
        protected List <Documento> bindGrid()
        {
            List <Documento> lista = new List <Documento>();
            Adaptador        adpt  = new Adaptador();

            lista = adpt.PorColuna(coluna);
            return(lista);
        }
Exemplo n.º 10
0
        protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)
        {
            GridView1.PageIndex = e.NewPageIndex;
            Adaptador adpt = new Adaptador();

            GridView1.DataSource = adpt.Todos();
            GridView1.DataBind();
        }
Exemplo n.º 11
0
 protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)
 {
     comando = (String)Session["pesquisa"];
     GridView1.PageIndex = e.NewPageIndex;
     Adaptador adpt = new Adaptador();
     GridView1.DataSource = adpt.PesquisarCampos(comando);
     GridView1.DataBind();
 }
Exemplo n.º 12
0
        protected List <Pessoa> bindGrid()
        {
            List <Pessoa> lista = new List <Pessoa>();
            Adaptador     adpt  = new Adaptador();

            lista = adpt.PorColuna(coluna);
            return(lista);
        }
Exemplo n.º 13
0
        protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)
        {
            comando             = (String)Session["pesquisa"];
            GridView1.PageIndex = e.NewPageIndex;
            Adaptador adpt = new Adaptador();

            GridView1.DataSource = adpt.PesquisarCampos(comando);
            GridView1.DataBind();
        }
Exemplo n.º 14
0
        /// <summary>
        /// Método usado para ordenar ou mudar a página do gridView.
        /// </summary>
        /// <param name="opcao">opcao indica se quer ordenar ou mudar a página do gridView.</param>
        /// <returns>uma lista de Documentos já ordenada ou com outro indice.</returns>
        protected List<Documento> bindGrid(string opcao)
        {
            List<Documento> lista = new List<Documento>();
            Adaptador adpt = new Adaptador();
            if (opcao == "sort")
            {
                if ((String)Session["orderBy"] == null)
                {
                    orderBy = "desc";
                    Session.Add("orderBy", orderBy);
                }
                else
                {
                    if ((String)Session["coluna"] != "id")
                    {
                        if ((String)Session["orderBy"] == "asc")
                        {
                            orderBy = "desc";
                            Session["orderBy"] = orderBy;
                        }
                        else
                        {
                            orderBy = "asc";
                            Session["orderBy"] = orderBy;
                        }
                    }
                    else
                    {
                        orderBy = "desc";
                        Session["orderBy"] = orderBy;
                    }

                }

                if (coluna == null)
                {
                    coluna = "id";
                }
                lista = adpt.PorColuna(null, coluna, orderBy);
            }
            else if (opcao == "indexchange")
            {
                if ((String)Session["coluna"] == null)
                {
                    lista = adpt.PorColuna(null, "id", "desc");
                }
                else
                {
                    coluna = (String)Session["coluna"];
                    orderBy = (String)Session["orderBy"];
                    lista = adpt.PorColuna(null, coluna, orderBy);
                }
            }
            return lista;
        }
Exemplo n.º 15
0
        /// <summary>
        /// Método usado para ordenar ou mudar a página do gridView.
        /// </summary>
        /// <param name="opcao">opcao indica se quer ordenar ou mudar a página do gridView.</param>
        /// <returns>uma lista de Documentos já ordenada ou com outro indice.</returns>
        protected List <Documento> bindGrid(string opcao)
        {
            List <Documento> lista = new List <Documento>();
            Adaptador        adpt  = new Adaptador();

            if (opcao == "sort")
            {
                if ((String)Session["orderBy"] == null)
                {
                    orderBy = "desc";
                    Session.Add("orderBy", orderBy);
                }
                else
                {
                    if ((String)Session["coluna"] != "id")
                    {
                        if ((String)Session["orderBy"] == "asc")
                        {
                            orderBy            = "desc";
                            Session["orderBy"] = orderBy;
                        }
                        else
                        {
                            orderBy            = "asc";
                            Session["orderBy"] = orderBy;
                        }
                    }
                    else
                    {
                        orderBy            = "desc";
                        Session["orderBy"] = orderBy;
                    }
                }

                if (coluna == null)
                {
                    coluna = "id";
                }
                lista = adpt.PorColuna(null, coluna, orderBy);
            }
            else if (opcao == "indexchange")
            {
                if ((String)Session["coluna"] == null)
                {
                    lista = adpt.PorColuna(null, "id", "desc");
                }
                else
                {
                    coluna  = (String)Session["coluna"];
                    orderBy = (String)Session["orderBy"];
                    lista   = adpt.PorColuna(null, coluna, orderBy);
                }
            }
            return(lista);
        }
Exemplo n.º 16
0
 /// <summary>
 /// Método usado para verificar se já existe a matrícula passada.
 /// </summary>
 /// <param name="source">The source of the event.</param>
 /// <param name="args">The <see cref="System.Web.UI.WebControls.ServerValidateEventArgs"/> instance containing the event data.</param>
 protected void CustomValidatorMatricula_ServerValidate(object source, ServerValidateEventArgs args)
 {
     Adaptador adpt = new Adaptador();
     if (!adpt.existeMatricula(args.Value))
     {
         args.IsValid = false;
     }
     else
     {
         args.IsValid = true;
     }
 }
Exemplo n.º 17
0
        protected void ImageButtonDelete_Click(object sender, ImageClickEventArgs e)
        {
            string nameFile = retornaAbaAtiva();
            string id       = "";

            try
            {
                id = obterIdCadastrado();
            }
            catch (Exception ex)
            {
                LabelErro.Text         = ex.Message;
                ImageAttention.Visible = true;
            }
            string nome = montarFormatoGD(id, nameFile);

            diretorio = pathDir;


            if (Directory.Exists(diretorio))
            {
                File.Delete(diretorio + nome);

                TableArquivo.Visible      = false;
                ImageButtonVer.Visible    = false;
                ImageButtonDelete.Visible = false;
            }
            else
            {
                LabelErro.Text         = "Diretório " + diretorio + "  não encontrado";
                ImageAttention.Visible = true;
            }

            File.Delete(pathDir + Session["fileName"].ToString());

            if (Session["cadastro"].ToString().Equals((string)"nao"))
            {
                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 um arquivo do id " + id;
                Adaptador adpt = new Adaptador();
                adpt.InserirLog(log);
            }

            TableArquivo.Visible      = false;
            ImageButtonVer.Visible    = false;
            ImageButtonDelete.Visible = false;
            Session.Add("postou_" + nameFile, "nao");
            LabelArquivo.Text = "";
        }
Exemplo n.º 18
0
        /// <summary>
        /// Método usado para verificar se já existe a matrícula passada.
        /// </summary>
        /// <param name="source">The source of the event.</param>
        /// <param name="args">The <see cref="System.Web.UI.WebControls.ServerValidateEventArgs"/> instance containing the event data.</param>
        protected void CustomValidatorMatricula_ServerValidate(object source, ServerValidateEventArgs args)
        {
            Adaptador adpt = new Adaptador();

            if (!adpt.existeMatricula(args.Value))
            {
                args.IsValid = false;
            }
            else
            {
                args.IsValid = true;
            }
        }
Exemplo n.º 19
0
 /// <summary>
 /// Método usado para verificar se já existe o Login passado.
 /// </summary>
 /// <param name="source">The source of the event.</param>
 /// <param name="args">The <see cref="System.Web.UI.WebControls.ServerValidateEventArgs"/> instance containing the event data.</param>
 protected void CustomValidatorLogin_ServerValidate(object source, ServerValidateEventArgs args)
 {
     //fazer acesso ao adaptador pra verificar se ja existe um login desse.
     Adaptador adpt = new Adaptador();
     if (adpt.existeLogin(args.Value))
     {
         args.IsValid = false;
     }
     else
     {
         args.IsValid = true;
     }
 }
Exemplo n.º 20
0
 protected void Page_Load(object sender, EventArgs e)
 {
     Adaptador adpt = new Adaptador();
     List<Arquivo> lista = new List<Arquivo>();
     for (int i = 0; i < 3; i++)
     {
         Arquivo arq = new Arquivo();
         arq.nome_Arquivo = "identidade" + i + ".pdf";
         lista.Add(arq);
     }
     lista = adpt.RetornaArquivos(lista);
     GridView1.DataSource = lista;
     GridView1.DataBind();
 }
Exemplo n.º 21
0
        /// <summary>
        /// Método usado para verificar se já existe o Login passado.
        /// </summary>
        /// <param name="source">The source of the event.</param>
        /// <param name="args">The <see cref="System.Web.UI.WebControls.ServerValidateEventArgs"/> instance containing the event data.</param>
        protected void CustomValidatorLogin_ServerValidate(object source, ServerValidateEventArgs args)
        {
            //fazer acesso ao adaptador pra verificar se ja existe um login desse.
            Adaptador adpt = new Adaptador();

            if (adpt.existeLogin(args.Value))
            {
                args.IsValid = false;
            }
            else
            {
                args.IsValid = true;
            }
        }
Exemplo n.º 22
0
        protected void Page_Load(object sender, EventArgs e)
        {
            Adaptador      adpt  = new Adaptador();
            List <Arquivo> lista = new List <Arquivo>();

            for (int i = 0; i < 3; i++)
            {
                Arquivo arq = new Arquivo();
                arq.nome_Arquivo = "identidade" + i + ".pdf";
                lista.Add(arq);
            }
            lista = adpt.RetornaArquivos(lista);
            GridView1.DataSource = lista;
            GridView1.DataBind();
        }
Exemplo n.º 23
0
        /// <summary>
        /// Método usado para logar no sistema, e caso autenticado, transfere para a pagina inicial.
        /// </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)
        {
            Adaptador adpt  = new Adaptador();
            int       login = 0;

            try
            {
                login = adpt.EfetuaLogin(TextBoxUsuario.Text, TextBoxSenha.Text);
            }
            catch (Exception ex)
            {
                LabelErro.Text         = ex.Message;
                ImageAttention.Visible = true;
            }
            if (login == 1)
            {
                Session.Add("usuario", TextBoxUsuario.Text);
                Session.Add("senha", TextBoxSenha.Text);
                Session.Add("tipo_usuario", "RHADM");
                //Response.Write("<script>alert('Login de " + TextBoxUsuario.Text.ToUpper() + " efetuado com sucesso')</script>");
                Session.Add("login", 1);
                Server.Transfer("Home.aspx");
            }
            else if (login == 2)
            {
                Session.Add("usuario", TextBoxUsuario.Text);
                Session.Add("senha", TextBoxSenha.Text);
                Session.Add("tipo_usuario", "RHLIM");
                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("home.aspx");
            }
            else if (login == 3)
            {
                LabelErro.Text         = "Usuário não tem permissão para esta aplicação";
                ImageAttention.Visible = true;
            }
            else if (login == 4)
            {
                LabelErro.Text         = "Usuário inexistente";
                ImageAttention.Visible = true;
            }
            else
            {
                LabelErro.Text         = "Erro não identificado";
                ImageAttention.Visible = true;
            }
        }
Exemplo n.º 24
0
 /// <summary>
 /// Método usado para logar no sistema, e caso autenticado, transfere para a pagina inicial.
 /// </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)
 {
     Adaptador adpt = new Adaptador();
     int login = 0;
     try
     {
         login = adpt.EfetuaLogin(TextBoxUsuario.Text, TextBoxSenha.Text);
     }
     catch (Exception ex)
     {
         LabelErro.Text = ex.Message;
         ImageAttention.Visible = true;
     }
     if (login == 1)
     {
         Session.Add("usuario", TextBoxUsuario.Text);
         Session.Add("senha", TextBoxSenha.Text);
         Session.Add("tipo_usuario", "RHADM");
         //Response.Write("<script>alert('Login de " + TextBoxUsuario.Text.ToUpper() + " efetuado com sucesso')</script>");
         Session.Add("login", 1);
         Server.Transfer("Home.aspx");
     }
     else if (login == 2)
     {
         Session.Add("usuario", TextBoxUsuario.Text);
         Session.Add("senha", TextBoxSenha.Text);
         Session.Add("tipo_usuario", "RHLIM");
         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("home.aspx");
     }
     else if (login == 3)
     {
         LabelErro.Text = "Usuário não tem permissão para esta aplicação";
         ImageAttention.Visible = true;
     }
     else if (login == 4)
     {
         LabelErro.Text = "Usuário inexistente";
         ImageAttention.Visible = true;
     }
     else
     {
         LabelErro.Text = "Erro não identificado";
         ImageAttention.Visible = true;
     }
 }
Exemplo n.º 25
0
        /// <summary>
        /// Método usado para fazer pesquisa dentro da lista de LOGs.
        /// </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 ButtonEnviarPesquisa_Click(object sender, EventArgs e)
        {
            comando = (String)Session["pesquisaLOG"];
            campos  = (String)Session["campos"];
            Adaptador adpt = new Adaptador();

            if (IsPostBack)
            {
                if (campos == TextBoxPesquisa.Text)
                {
                    GridView1.DataSource = adpt.PesquisarCamposLOG(comando);
                    GridView1.DataBind();
                }
                else
                {
                    if (campos == null)
                    {
                        campos = TextBoxPesquisa.Text;
                    }
                    else
                    {
                        campos += " " + TextBoxPesquisa.Text;
                    }
                    Session["campos"] = campos;
                    string parametros = montarComando(campos);
                    //string parametros = TextBoxPesquisa.Text;
                    if (TextBoxPesquisa.Text == null)
                    {
                        ScriptManager.RegisterStartupScript(Page, GetType(), Guid.NewGuid().ToString(), "window.alert('Parâmetro Inválido.');", true);
                    }
                    else
                    {
                        comando              = "textsearch in log " + montaParametros(parametros);
                        listaLog             = adpt.PesquisarCamposLOG(comando);
                        GridView1.DataSource = listaLog;
                        GridView1.DataBind();
                        Session["pesquisaLOG"] = comando;
                        Session["listaLog"]    = listaLog;
                    }
                }
            }
        }
Exemplo n.º 26
0
        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();
            }
        }
Exemplo n.º 27
0
 /// <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"];
 }
Exemplo n.º 28
0
        /// <summary>
        /// Método usado para processar a pesquisa dentro da lista de Colaboradores.
        /// </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 ButtonEnviarPesquisa_Click(object sender, EventArgs e)
        {
            comando = (String)Session["pesquisa"];
            campos  = (String)Session["campos"];
            Adaptador adpt = new Adaptador();

            if (IsPostBack)
            {
                if (campos == TextBoxPesquisa.Text)
                {
                    GridView1.DataSource = adpt.PesquisarCampos(comando);
                    GridView1.DataBind();
                }
                else
                {
                    Session["campos"] = TextBoxPesquisa.Text;
                    string parametros = montarComando(TextBoxPesquisa.Text);
                    if (parametros == null)
                    {
                        ScriptManager.RegisterStartupScript(Page, GetType(), Guid.NewGuid().ToString(), "window.alert('Parâmetro Inválido.');", true);
                    }
                    else
                    {
                        comando += " E " + parametros;
                        GridView1.DataSource = adpt.PesquisarCampos(comando);
                        GridView1.DataBind();
                    }
                }
            }

            //List<Documento> lista = new List<Documento>();
            //lista = adpt.PesquisarCampos(comando);

            //GridView1.DataSource = lista;
            //GridView1.DataBind();
        }
Exemplo n.º 29
0
        protected void ImageButtonEnviar_Click(object sender, ImageClickEventArgs e)
        {
            Documento documento = new Documento();
            List<Arquivo> list_arquivo = new List<Arquivo>();

            documento.matricula_Colaborador = TextBoxMatricula.Text;
            documento.nome_Colaborador = TextNome_Colaborador.Text;
            documento.cpf_Colaborador = TextBoxCPF.Text;
            documento.foto = ImageFoto.ImageUrl;
            /*
             * Salvando arquivos postados no banco
             * ( ver como faz pra colocar um identificador do tipo pra qnd fazer um update saber buscar esse tipo)
             */
            if (Session["postou_docsPessoais"].ToString().Equals((string)"sim"))
            {
                Arquivo arq_temp = new Arquivo();
                arq_temp = retornaArquivos("docsPessoais");
                if (arq_temp != null)
                {
                    list_arquivo.Add(arq_temp);
                }
            }
            if (Session["postou_titulacoes"].ToString().Equals((string)"sim"))
            {
                Arquivo arq_temp = new Arquivo();
                arq_temp = retornaArquivos("titulacoes");
                if (arq_temp != null)
                {
                    list_arquivo.Add(arq_temp);
                }
            }
            if (Session["postou_portarias"].ToString().Equals((string)"sim"))
            {
                Arquivo arq_temp = new Arquivo();
                arq_temp = retornaArquivos("portarias");
                if (arq_temp != null)
                {
                    list_arquivo.Add(arq_temp);
                }
            }
            if (Session["postou_cis"].ToString().Equals((string)"sim"))
            {
                Arquivo arq_temp = new Arquivo();
                arq_temp = retornaArquivos("cis");
                if (arq_temp != null)
                {
                    list_arquivo.Add(arq_temp);
                }
            }
            if (Session["postou_avisoFerias"].ToString().Equals((string)"sim"))
            {
                Arquivo arq_temp = new Arquivo();
                arq_temp = retornaArquivos("avisoFerias");
                if (arq_temp != null)
                {
                    list_arquivo.Add(arq_temp);
                }
            }
            if (Session["postou_requerimentos"].ToString().Equals((string)"sim"))
            {
                Arquivo arq_temp = new Arquivo();
                arq_temp = retornaArquivos("requerimentos");
                if (arq_temp != null)
                {
                    list_arquivo.Add(arq_temp);
                }
            }
            if (Session["postou_outros"].ToString().Equals((string)"sim"))
            {
                Arquivo arq_temp = new Arquivo();
                arq_temp = retornaArquivos("outros");
                if (arq_temp != null)
                {
                    list_arquivo.Add(arq_temp);
                }
            }
            //Adicionando a lista dos arquivos aos documentos pra depois adicionar no banco

            //list_arquivo = (List<Arquivo>)Session["arquivos"];
            if (list_arquivo == null)
            {
                list_arquivo = new List<Arquivo>();
            }
            documento.arquivos = list_arquivo;

            Adaptador adpt = new Adaptador();
            try
            {
                adpt.AtualizarDocumento(documento, id);
                Log log = new Log();
                log.data_log = DateTime.Now;
                log.tipo_acao_log = "Editar";
                log.usuario_log = (String)Session["usuario"];
                log.mensagem_acao_log = "O usuário " + log.usuario_log + " atualizou o colaborador de matrícula " + documento.matricula_Colaborador;
                adpt.InserirLog(log);
            }
            catch (Exception ex)
            {
                LabelErro.Text = ex.Message;
                ImageAttention.Visible = true;
            }

            /*foreach (Arquivo arq in list_arquivo)
            {
                versiona_indexa(arq.nome_Arquivo);
            }*/

            mensagem = "Registro modificado com sucesso";
            Session.Add("mensagem", mensagem);
            Server.Transfer("listar.aspx");
        }
Exemplo n.º 30
0
        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;
            }
        }
Exemplo n.º 31
0
        protected void ImageButtonDelete_Click(object sender, ImageClickEventArgs e)
        {
            string nameFile = retornaAbaAtiva();
            string id = "";
            try
            {
                id = obterIdCadastrado();
            }
            catch (Exception ex)
            {
                LabelErro.Text = ex.Message;
                ImageAttention.Visible = true;
            }
            string nome = montarFormatoGD(id, nameFile);
            diretorio = pathDir;

            if (Directory.Exists(diretorio))
            {
                File.Delete(diretorio + nome);

                TableArquivo.Visible = false;
                ImageButtonVer.Visible = false;
                ImageButtonDelete.Visible = false;
            }
            else
            {
                LabelErro.Text = "Diretório " + diretorio + "  não encontrado";
                ImageAttention.Visible = true;
            }

            File.Delete(pathDir + Session["fileName"].ToString());

            if (Session["cadastro"].ToString().Equals((string)"nao"))
            {
                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 um arquivo do id " + id;
                Adaptador adpt = new Adaptador();
                adpt.InserirLog(log);
            }

            TableArquivo.Visible = false;
            ImageButtonVer.Visible = false;
            ImageButtonDelete.Visible = false;
            Session.Add("postou_" + nameFile, "nao");
            LabelArquivo.Text = "";
        }
Exemplo n.º 32
0
        protected void ImageButtonCadastrar_Click(object sender, ImageClickEventArgs e)
        {
            string ext = "";
            string id = "";
            string arquivo = "";
            int tamanho = 0;
            string nomeArquivoLBW = "";

            if (FileUploadArquivo.PostedFile.ContentLength == 0)
            {
                LabelErro.Text = "É necessário selecionar um arquivo";
            }
            else
            {
                try
                {
                    id = obterIdCadastrado();
                }
                catch (Exception ex)
                {
                    LabelErro.Text = ex.Message;
                }
                arquivo = FileUploadArquivo.PostedFile.FileName;
                nomeArquivo = System.IO.Path.GetFileName(arquivo);
                tamanho = nomeArquivo.Length;
                nomeArquivoLBW = montarFormatoGD(id, nomeArquivo);
                Pessoa pessoa = new Pessoa();
                pessoa.arq_Arquivo = nomeArquivoLBW;

                pessoa.nome_Colaborador = TextBoxNome_Colaborador.Text;
                pessoa.naturalidade = TextBoxNaturalidade.Text;
                pessoa.data_Nascimento = Convert.ToDateTime(TextBoxData_Nascimento.Text);
                if (RadioButtonListSexo.SelectedIndex == 0)
                {
                    pessoa.sexo = 'm';
                }
                else
                {
                    pessoa.sexo = 'm';
                }
                pessoa.nome_Pai = TextBoxNome_Pai.Text;
                pessoa.nome_Mae = TextBoxNome_Mae.Text;
                pessoa.cargo = TextBoxCargo.Text;

                Endereco endereco = new Endereco();
                endereco.endereco = TextBoxEndereco.Text;
                endereco.numero = TextBoxNumero.Text;
                endereco.complemento = TextBoxComplemento.Text;
                endereco.bairro = TextBoxBairro.Text;
                endereco.cep = TextBoxCEP.Text;
                endereco.cidade = TextBoxCidade.Text;
                endereco.estado = TextBoxEstado.Text;
                pessoa.endereco = endereco;
                Telefone telefone = new Telefone();
                telefone.numero_TelefoneFixo = TextBoxTelefoneResidencial.Text;
                telefone.numero_TelefoneCelular = TextBoxTelefoneCelular.Text;
                pessoa.telefone = telefone;

                Adaptador adpt = new Adaptador();
                try
                {
                    adpt.InserirPessoa(pessoa);
                }
                catch (Exception ex)
                {
                    LabelErro.Text = ex.Message;
                }

                Versao versao = new Versao();

                //FileUploadArquivo.PostedFile.SaveAs(Settings.Default.CaminhoDoRepositorioPessoa + nomeArquivoLBW);
                FileUploadArquivo.PostedFile.SaveAs(@"c:/temp/" + nomeArquivoLBW);

                versao.CaminhoDoArquivo = Settings.Default.CaminhoDoRepositorioPessoa;
                versao.Extensao = ext;
                versao.NomeDoArquivo = nomeArquivoLBW;

                versao.Id = Convert.ToInt32(obterIdCadastrado());

                Indexador indexador = new Indexador();
                indexador.Indexe(versao);

                mensagem = "Colaborador inserido com sucesso";
                Session.Add("mensagem", mensagem);
                Server.Transfer("listar.aspx");
            }
        }
Exemplo n.º 33
0
        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();
            }
        }
Exemplo n.º 34
0
        /// <summary>
        /// Método usado para cadastrar o colaborador e seus respectivos documentos.
        /// </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 ImageButton1_Click(object sender, ImageClickEventArgs e)
        {
            Documento documento = new Documento();
            List<Arquivo> list_arquivo = new List<Arquivo>();
            documento.matricula_Colaborador = matricula;
            documento.nome_Colaborador = TextNome_Colaborador.Text;
            documento.foto = ImageFoto.ImageUrl;
            documento.cpf_Colaborador = TextBoxCPF.Text;

            if ((TextBoxMatricula.Text.Equals("")) || (TextBoxCPF.Text.Equals("")) || (TextNome_Colaborador.Text.Equals("")))
            {
                LabelErro.Text = "Preencha todos os campos!";
                ImageAttention.Visible = true;
            }
            else
            {
                /*
                * Salvando arquivos postados no banco
                */
                if (Session["postou_docsPessoais"].ToString().Equals((string)"sim"))
                {
                    Arquivo arq_temp = new Arquivo();
                    arq_temp.nome_Arquivo = montarFormatoGD(matricula, "docsPessoais.pdf");
                    arq_temp.tipo_Arquivo = "docsPessoais";
                    list_arquivo.Add(arq_temp);
                }
                if (Session["postou_titulacoes"].ToString().Equals((string)"sim"))
                {
                    Arquivo arq_temp = new Arquivo();
                    arq_temp.nome_Arquivo = montarFormatoGD(matricula, "titulacoes.pdf");
                    arq_temp.tipo_Arquivo = "titulacoes";
                    list_arquivo.Add(arq_temp);
                }
                if (Session["postou_portarias"].ToString().Equals((string)"sim"))
                {
                    Arquivo arq_temp = new Arquivo();
                    arq_temp.nome_Arquivo = montarFormatoGD(matricula, "portarias.pdf");
                    arq_temp.tipo_Arquivo = "portarias";
                    list_arquivo.Add(arq_temp);
                }
                if (Session["postou_portariasComProcesso"].ToString().Equals((string)"sim"))
                {
                    Arquivo arq_temp = new Arquivo();
                    arq_temp.nome_Arquivo = montarFormatoGD(matricula, "portariasComProcesso.pdf");
                    arq_temp.tipo_Arquivo = "portariasComProcesso";
                    list_arquivo.Add(arq_temp);
                }
                if (Session["postou_cis"].ToString().Equals((string)"sim"))
                {
                    Arquivo arq_temp = new Arquivo();
                    arq_temp.nome_Arquivo = montarFormatoGD(matricula, "cis.pdf");
                    arq_temp.tipo_Arquivo = "cis";
                    list_arquivo.Add(arq_temp);
                }
                if (Session["postou_avisoFerias"].ToString().Equals((string)"sim"))
                {
                    Arquivo arq_temp = new Arquivo();
                    arq_temp.nome_Arquivo = montarFormatoGD(matricula, "avisoFerias.pdf");
                    arq_temp.tipo_Arquivo = "avisoFerias";
                    list_arquivo.Add(arq_temp);
                }
                if (Session["postou_requerimentos"].ToString().Equals((string)"sim"))
                {
                    Arquivo arq_temp = new Arquivo();
                    arq_temp.nome_Arquivo = montarFormatoGD(matricula, "requerimentos.pdf");
                    arq_temp.tipo_Arquivo = "requerimentos";
                    list_arquivo.Add(arq_temp);
                }
                if (Session["postou_outros"].ToString().Equals((string)"sim"))
                {
                    Arquivo arq_temp = new Arquivo();
                    arq_temp.nome_Arquivo = montarFormatoGD(matricula, "outros.pdf");
                    arq_temp.tipo_Arquivo = "outros";
                    list_arquivo.Add(arq_temp);
                }

                // Verifica se existe documento pra adicionar ao banco
                if (list_arquivo.Count == 0)
                {
                    LabelErro.Text = "Nenhum documento adicionado";
                    ImageAttention.Visible = true;
                }
                else
                {
                    //Adicionando a lista dos arquivos aos documentos pra depois adicionar no banco
                    documento.arquivos = list_arquivo;

                    Adaptador adpt = new Adaptador();
                    try
                    {
                        adpt.InserirDocumento(documento);
                        //Após inserir o documento é inserido na base de LOG a mensagem de log do que foi feito.
                        Log log = new Log();
                        log.data_log = DateTime.Now;
                        log.tipo_acao_log = "Inserir";
                        log.usuario_log = (String)Session["usuario"];
                        log.mensagem_acao_log = "Matrícula " + documento.matricula_Colaborador + " (" + documento.nome_Colaborador + ")";
                        adpt.InserirLog(log);
                    }
                    catch (Exception ex)
                    {
                        LabelErro.Text = ex.Message;
                        ImageAttention.Visible = true;
                    }

                    //foreach (Arquivo arq in list_arquivo)
                    //{
                    //    versiona_indexa(arq.nome_Arquivo);
                    //}

                    mensagem = "Colaborador inserido com sucesso";
                    Session.Add("mensagem", mensagem);
                    Server.Transfer("listar.aspx");
                }
            }
        }
Exemplo n.º 35
0
        protected void ImageButton1_Click(object sender, ImageClickEventArgs e)
        {
            string id = "";

            try
            {
                id = obterIdCadastrado();
            }
            catch (Exception ex)
            {
                LabelErro.Text = ex.Message;
            }

            Documento documento = new Documento();
            List<Arquivo> list_arquivo = new List<Arquivo>();

            documento.matricula_Colaborador = TextBoxMatricula.Text;
            documento.nome_Colaborador = TextNome_Colaborador.Text;
            /*
             * Salvando arquivos postados no banco
             * ( ver como faz pra colocar um identificador do tipo pra qnd fazer um update saber buscar esse tipo)
             */
            if (Session["postou_docsPessoais"].ToString().Equals((string)"sim"))
            {
                Arquivo arq_temp = new Arquivo();
                arq_temp = inserirArquivosNaLista(id, "docsPessoais");
                if (arq_temp != null)
                {
                    list_arquivo.Add(arq_temp);
                }
            }
            if (Session["postou_titulacoes"].ToString().Equals((string)"sim"))
            {
                Arquivo arq_temp = new Arquivo();
                arq_temp = inserirArquivosNaLista(id, "titulacoes");
                if (arq_temp != null)
                {
                    list_arquivo.Add(arq_temp);
                }
            }
            if (Session["postou_portarias"].ToString().Equals((string)"sim"))
            {
                Arquivo arq_temp = new Arquivo();
                arq_temp = inserirArquivosNaLista(id, "portarias");
                if (arq_temp != null)
                {
                    list_arquivo.Add(arq_temp);
                }
            }
            if (Session["postou_cis"].ToString().Equals((string)"sim"))
            {
                Arquivo arq_temp = new Arquivo();
                arq_temp = inserirArquivosNaLista(id, "cis");
                if (arq_temp != null)
                {
                    list_arquivo.Add(arq_temp);
                }
            }
            if (Session["postou_avisoFerias"].ToString().Equals((string)"sim"))
            {
                Arquivo arq_temp = new Arquivo();
                arq_temp = inserirArquivosNaLista(id, "avisoFerias");
                if (arq_temp != null)
                {
                    list_arquivo.Add(arq_temp);
                }
            }
            if (Session["postou_requerimentos"].ToString().Equals((string)"sim"))
            {
                Arquivo arq_temp = new Arquivo();
                arq_temp = inserirArquivosNaLista(id, "requerimentos");
                if (arq_temp != null)
                {
                    list_arquivo.Add(arq_temp);
                }
            }
            if (Session["postou_outros"].ToString().Equals((string)"sim"))
            {
                Arquivo arq_temp = new Arquivo();
                arq_temp = inserirArquivosNaLista(id, "outros");
                if (arq_temp != null)
                {
                    list_arquivo.Add(arq_temp);
                }
            }
            //Adicionando a lista dos arquivos aos documentos pra depois adicionar no banco
            documento.arquivos = list_arquivo;

            Adaptador adpt = new Adaptador();
            try
            {
                adpt.AtualizarDocumento(documento);
            }
            catch (Exception ex)
            {
                LabelErro.Text = ex.Message;
            }

            /*foreach (Arquivo arq in list_arquivo)
            {
                versiona_indexa(arq.nome_Arquivo);
            }*/

            mensagem = "Registro modificado com sucesso";
            Session.Add("mensagem", mensagem);
            Server.Transfer("listar.aspx");
        }
Exemplo n.º 36
0
        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.";
            }
        }
Exemplo n.º 37
0
        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.";
            }
        }
Exemplo n.º 38
0
        /// <summary>
        /// Método usado para processar a pesquisa dentro da lista de Colaboradores.
        /// </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 ButtonEnviarPesquisa_Click(object sender, EventArgs e)
        {
            comando = (String)Session["pesquisa"];
            campos = (String)Session["campos"];
            Adaptador adpt = new Adaptador();
            if (IsPostBack)
            {
                if (campos == TextBoxPesquisa.Text)
                {
                    GridView1.DataSource = adpt.PesquisarCampos(comando);
                    GridView1.DataBind();
                }
                else
                {
                    Session["campos"] = TextBoxPesquisa.Text;
                    string parametros = montarComando(TextBoxPesquisa.Text);
                    if (parametros == null)
                    {
                        ScriptManager.RegisterStartupScript(Page, GetType(), Guid.NewGuid().ToString(), "window.alert('Parâmetro Inválido.');", true);
                    }
                    else
                    {
                        comando += " E " + parametros;
                        GridView1.DataSource = adpt.PesquisarCampos(comando);
                        GridView1.DataBind();
                    }

                }
            }

            //List<Documento> lista = new List<Documento>();
            //lista = adpt.PesquisarCampos(comando);

            //GridView1.DataSource = lista;
            //GridView1.DataBind();
        }
Exemplo n.º 39
0
        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;
            }
        }
Exemplo n.º 40
0
        protected void ImageButtonEnviar_Click(object sender, ImageClickEventArgs e)
        {
            Documento      documento    = new Documento();
            List <Arquivo> list_arquivo = new List <Arquivo>();

            documento.matricula_Colaborador = TextBoxMatricula.Text;
            documento.nome_Colaborador      = TextNome_Colaborador.Text;
            documento.cpf_Colaborador       = TextBoxCPF.Text;
            documento.foto = ImageFoto.ImageUrl;

            /*
             * Salvando arquivos postados no banco
             * ( ver como faz pra colocar um identificador do tipo pra qnd fazer um update saber buscar esse tipo)
             */
            if (Session["postou_docsPessoais"].ToString().Equals((string)"sim"))
            {
                Arquivo arq_temp = new Arquivo();
                arq_temp = retornaArquivos("docsPessoais");
                if (arq_temp != null)
                {
                    list_arquivo.Add(arq_temp);
                }
            }
            if (Session["postou_titulacoes"].ToString().Equals((string)"sim"))
            {
                Arquivo arq_temp = new Arquivo();
                arq_temp = retornaArquivos("titulacoes");
                if (arq_temp != null)
                {
                    list_arquivo.Add(arq_temp);
                }
            }
            if (Session["postou_portarias"].ToString().Equals((string)"sim"))
            {
                Arquivo arq_temp = new Arquivo();
                arq_temp = retornaArquivos("portarias");
                if (arq_temp != null)
                {
                    list_arquivo.Add(arq_temp);
                }
            }
            if (Session["postou_cis"].ToString().Equals((string)"sim"))
            {
                Arquivo arq_temp = new Arquivo();
                arq_temp = retornaArquivos("cis");
                if (arq_temp != null)
                {
                    list_arquivo.Add(arq_temp);
                }
            }
            if (Session["postou_avisoFerias"].ToString().Equals((string)"sim"))
            {
                Arquivo arq_temp = new Arquivo();
                arq_temp = retornaArquivos("avisoFerias");
                if (arq_temp != null)
                {
                    list_arquivo.Add(arq_temp);
                }
            }
            if (Session["postou_requerimentos"].ToString().Equals((string)"sim"))
            {
                Arquivo arq_temp = new Arquivo();
                arq_temp = retornaArquivos("requerimentos");
                if (arq_temp != null)
                {
                    list_arquivo.Add(arq_temp);
                }
            }
            if (Session["postou_outros"].ToString().Equals((string)"sim"))
            {
                Arquivo arq_temp = new Arquivo();
                arq_temp = retornaArquivos("outros");
                if (arq_temp != null)
                {
                    list_arquivo.Add(arq_temp);
                }
            }
            //Adicionando a lista dos arquivos aos documentos pra depois adicionar no banco

            //list_arquivo = (List<Arquivo>)Session["arquivos"];
            if (list_arquivo == null)
            {
                list_arquivo = new List <Arquivo>();
            }
            documento.arquivos = list_arquivo;

            Adaptador adpt = new Adaptador();

            try
            {
                adpt.AtualizarDocumento(documento, id);
                Log log = new Log();
                log.data_log          = DateTime.Now;
                log.tipo_acao_log     = "Editar";
                log.usuario_log       = (String)Session["usuario"];
                log.mensagem_acao_log = "O usuário " + log.usuario_log + " atualizou o colaborador de matrícula " + documento.matricula_Colaborador;
                adpt.InserirLog(log);
            }
            catch (Exception ex)
            {
                LabelErro.Text         = ex.Message;
                ImageAttention.Visible = true;
            }

            /*foreach (Arquivo arq in list_arquivo)
             * {
             *  versiona_indexa(arq.nome_Arquivo);
             * }*/

            mensagem = "Registro modificado com sucesso";
            Session.Add("mensagem", mensagem);
            Server.Transfer("listar.aspx");
        }
Exemplo n.º 41
0
        protected void ImageButtonCadastrar_Click(object sender, ImageClickEventArgs e)
        {
            string ext = "";
            string id = "";
            string arquivo = "";
            int tamanho = 0;
            string nomeArquivoLBW = "";

            try
            {
                id = obterIdCadastrado();
            }
            catch (Exception ex)
            {
                LabelErro.Text = ex.Message;
            }
            /* Ver como pegar os arquivos pra salvar no banco
            arquivo = FileUploadArquivo.PostedFile.FileName;
            nomeArquivo = System.IO.Path.GetFileName(arquivo);
            tamanho = nomeArquivo.Length;
            nomeArquivoLBW = montarFormatoGD(id, nomeArquivo);
             * */

            //criar classe Documento
            Pessoa pessoa = new Pessoa();
            pessoa.arq_Arquivo = nomeArquivoLBW;

            pessoa.nome_Colaborador = TextBoxNome_Colaborador.Text;

            Adaptador adpt = new Adaptador();
            try
            {
                adpt.InserirPessoa(pessoa);
            }
            catch (Exception ex)
            {
                LabelErro.Text = ex.Message;
            }

            Versao versao = new Versao();

            //FileUploadArquivo.PostedFile.SaveAs(@"c:/temp/" + nomeArquivoLBW);

            versao.CaminhoDoArquivo = Settings.Default.CaminhoDoRepositorioPessoa;
            versao.Extensao = ext;
            versao.NomeDoArquivo = nomeArquivoLBW;

            versao.Id = Convert.ToInt32(obterIdCadastrado());

            Indexador indexador = new Indexador();
            indexador.Indexe(versao);

            mensagem = "Colaborador inserido com sucesso";
            Session.Add("mensagem", mensagem);
            Server.Transfer("listar.aspx");
        }
Exemplo n.º 42
0
        protected void ImageButtonCadastrar_Click(object sender, ImageClickEventArgs e)
        {
            string ext            = "";
            string id             = "";
            string arquivo        = "";
            int    tamanho        = 0;
            string nomeArquivoLBW = "";



            try
            {
                id = obterIdCadastrado();
            }
            catch (Exception ex)
            {
                LabelErro.Text = ex.Message;
            }

            /* Ver como pegar os arquivos pra salvar no banco
             * arquivo = FileUploadArquivo.PostedFile.FileName;
             * nomeArquivo = System.IO.Path.GetFileName(arquivo);
             * tamanho = nomeArquivo.Length;
             * nomeArquivoLBW = montarFormatoGD(id, nomeArquivo);
             * */

            //criar classe Documento
            Pessoa pessoa = new Pessoa();

            pessoa.arq_Arquivo = nomeArquivoLBW;

            pessoa.nome_Colaborador = TextBoxNome_Colaborador.Text;



            Adaptador adpt = new Adaptador();

            try
            {
                adpt.InserirPessoa(pessoa);
            }
            catch (Exception ex)
            {
                LabelErro.Text = ex.Message;
            }

            Versao versao = new Versao();

            //FileUploadArquivo.PostedFile.SaveAs(@"c:/temp/" + nomeArquivoLBW);

            versao.CaminhoDoArquivo = Settings.Default.CaminhoDoRepositorioPessoa;
            versao.Extensao         = ext;
            versao.NomeDoArquivo    = nomeArquivoLBW;

            versao.Id = Convert.ToInt32(obterIdCadastrado());

            Indexador indexador = new Indexador();

            indexador.Indexe(versao);

            mensagem = "Colaborador inserido com sucesso";
            Session.Add("mensagem", mensagem);
            Server.Transfer("listar.aspx");
        }
Exemplo n.º 43
0
        protected void ImageButtonCadastrar_Click(object sender, ImageClickEventArgs e)
        {
            string ext            = "";
            string id             = "";
            string arquivo        = "";
            int    tamanho        = 0;
            string nomeArquivoLBW = "";

            if (FileUploadArquivo.PostedFile.ContentLength == 0)
            {
                LabelErro.Text = "É necessário selecionar um arquivo";
            }
            else
            {
                try
                {
                    id = obterIdCadastrado();
                }
                catch (Exception ex)
                {
                    LabelErro.Text = ex.Message;
                }
                arquivo        = FileUploadArquivo.PostedFile.FileName;
                nomeArquivo    = System.IO.Path.GetFileName(arquivo);
                tamanho        = nomeArquivo.Length;
                nomeArquivoLBW = montarFormatoGD(id, nomeArquivo);
                Pessoa pessoa = new Pessoa();
                pessoa.arq_Arquivo = nomeArquivoLBW;

                pessoa.nome_Colaborador = TextBoxNome_Colaborador.Text;
                pessoa.naturalidade     = TextBoxNaturalidade.Text;
                pessoa.data_Nascimento  = Convert.ToDateTime(TextBoxData_Nascimento.Text);
                if (RadioButtonListSexo.SelectedIndex == 0)
                {
                    pessoa.sexo = 'm';
                }
                else
                {
                    pessoa.sexo = 'm';
                }
                pessoa.nome_Pai = TextBoxNome_Pai.Text;
                pessoa.nome_Mae = TextBoxNome_Mae.Text;
                pessoa.cargo    = TextBoxCargo.Text;

                Endereco endereco = new Endereco();
                endereco.endereco    = TextBoxEndereco.Text;
                endereco.numero      = TextBoxNumero.Text;
                endereco.complemento = TextBoxComplemento.Text;
                endereco.bairro      = TextBoxBairro.Text;
                endereco.cep         = TextBoxCEP.Text;
                endereco.cidade      = TextBoxCidade.Text;
                endereco.estado      = TextBoxEstado.Text;
                pessoa.endereco      = endereco;
                Telefone telefone = new Telefone();
                telefone.numero_TelefoneFixo    = TextBoxTelefoneResidencial.Text;
                telefone.numero_TelefoneCelular = TextBoxTelefoneCelular.Text;
                pessoa.telefone = telefone;


                Adaptador adpt = new Adaptador();
                try
                {
                    adpt.InserirPessoa(pessoa);
                }
                catch (Exception ex)
                {
                    LabelErro.Text = ex.Message;
                }

                Versao versao = new Versao();

                //FileUploadArquivo.PostedFile.SaveAs(Settings.Default.CaminhoDoRepositorioPessoa + nomeArquivoLBW);
                FileUploadArquivo.PostedFile.SaveAs(@"c:/temp/" + nomeArquivoLBW);

                versao.CaminhoDoArquivo = Settings.Default.CaminhoDoRepositorioPessoa;
                versao.Extensao         = ext;
                versao.NomeDoArquivo    = nomeArquivoLBW;

                versao.Id = Convert.ToInt32(obterIdCadastrado());

                Indexador indexador = new Indexador();
                indexador.Indexe(versao);

                mensagem = "Colaborador inserido com sucesso";
                Session.Add("mensagem", mensagem);
                Server.Transfer("listar.aspx");
            }
        }
Exemplo n.º 44
0
        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();
            }
        }
Exemplo n.º 45
0
        protected void ImageButton1_Click(object sender, ImageClickEventArgs e)
        {
            string id = "";

            try
            {
                id = obterIdCadastrado();
            }
            catch (Exception ex)
            {
                LabelErro.Text = ex.Message;
            }

            Documento      documento    = new Documento();
            List <Arquivo> list_arquivo = new List <Arquivo>();

            documento.matricula_Colaborador = TextBoxMatricula.Text;
            documento.nome_Colaborador      = TextNome_Colaborador.Text;

            /*
             * Salvando arquivos postados no banco
             * ( ver como faz pra colocar um identificador do tipo pra qnd fazer um update saber buscar esse tipo)
             */
            if (Session["postou_docsPessoais"].ToString().Equals((string)"sim"))
            {
                Arquivo arq_temp = new Arquivo();
                arq_temp = inserirArquivosNaLista(id, "docsPessoais");
                if (arq_temp != null)
                {
                    list_arquivo.Add(arq_temp);
                }
            }
            if (Session["postou_titulacoes"].ToString().Equals((string)"sim"))
            {
                Arquivo arq_temp = new Arquivo();
                arq_temp = inserirArquivosNaLista(id, "titulacoes");
                if (arq_temp != null)
                {
                    list_arquivo.Add(arq_temp);
                }
            }
            if (Session["postou_portarias"].ToString().Equals((string)"sim"))
            {
                Arquivo arq_temp = new Arquivo();
                arq_temp = inserirArquivosNaLista(id, "portarias");
                if (arq_temp != null)
                {
                    list_arquivo.Add(arq_temp);
                }
            }
            if (Session["postou_cis"].ToString().Equals((string)"sim"))
            {
                Arquivo arq_temp = new Arquivo();
                arq_temp = inserirArquivosNaLista(id, "cis");
                if (arq_temp != null)
                {
                    list_arquivo.Add(arq_temp);
                }
            }
            if (Session["postou_avisoFerias"].ToString().Equals((string)"sim"))
            {
                Arquivo arq_temp = new Arquivo();
                arq_temp = inserirArquivosNaLista(id, "avisoFerias");
                if (arq_temp != null)
                {
                    list_arquivo.Add(arq_temp);
                }
            }
            if (Session["postou_requerimentos"].ToString().Equals((string)"sim"))
            {
                Arquivo arq_temp = new Arquivo();
                arq_temp = inserirArquivosNaLista(id, "requerimentos");
                if (arq_temp != null)
                {
                    list_arquivo.Add(arq_temp);
                }
            }
            if (Session["postou_outros"].ToString().Equals((string)"sim"))
            {
                Arquivo arq_temp = new Arquivo();
                arq_temp = inserirArquivosNaLista(id, "outros");
                if (arq_temp != null)
                {
                    list_arquivo.Add(arq_temp);
                }
            }
            //Adicionando a lista dos arquivos aos documentos pra depois adicionar no banco
            documento.arquivos = list_arquivo;

            Adaptador adpt = new Adaptador();

            try
            {
                adpt.InserirDocumento(documento);
            }
            catch (Exception ex)
            {
                LabelErro.Text = ex.Message;
            }

            /*foreach (Arquivo arq in list_arquivo)
             * {
             *  versiona_indexa(arq.nome_Arquivo);
             * }*/

            mensagem = "Colaborador inserido com sucesso";
            Session.Add("mensagem", mensagem);
            Server.Transfer("listar.aspx");
        }
Exemplo n.º 46
0
        protected void ImageButton1_Click(object sender, ImageClickEventArgs e)
        {
            string id = "";

            try
            {
                id = obterIdCadastrado();
            }
            catch (Exception ex)
            {
                LabelErro.Text         = ex.Message;
                ImageAttention.Visible = true;
            }

            Documento      documento    = new Documento();
            List <Arquivo> list_arquivo = new List <Arquivo>();

            documento.matricula_Colaborador = TextBoxMatricula.Text;
            documento.nome_Colaborador      = TextNome_Colaborador.Text;
            documento.foto            = ImageFoto.ImageUrl;
            documento.cpf_Colaborador = TextBoxCPF.Text;

            if ((TextBoxMatricula.Text.Equals("")) || (TextBoxCPF.Text.Equals("")) || (TextNome_Colaborador.Text.Equals("")))
            {
                LabelErro.Text         = "Preencha todos os campos!";
                ImageAttention.Visible = true;
            }
            else
            {
                /*
                 * Salvando arquivos postados no banco
                 */
                if (Session["postou_docsPessoais"].ToString().Equals((string)"sim"))
                {
                    Arquivo arq_temp = new Arquivo();
                    arq_temp.nome_Arquivo = montarFormatoGD(id, "docsPessoais.pdf");
                    arq_temp.tipo_Arquivo = "docsPessoais";
                    list_arquivo.Add(arq_temp);
                }
                if (Session["postou_titulacoes"].ToString().Equals((string)"sim"))
                {
                    Arquivo arq_temp = new Arquivo();
                    arq_temp.nome_Arquivo = montarFormatoGD(id, "titulacoes.pdf");
                    arq_temp.tipo_Arquivo = "titulacoes";
                    list_arquivo.Add(arq_temp);
                }
                if (Session["postou_portarias"].ToString().Equals((string)"sim"))
                {
                    Arquivo arq_temp = new Arquivo();
                    arq_temp.nome_Arquivo = montarFormatoGD(id, "portarias.pdf");
                    arq_temp.tipo_Arquivo = "portarias";
                    list_arquivo.Add(arq_temp);
                }
                if (Session["postou_cis"].ToString().Equals((string)"sim"))
                {
                    Arquivo arq_temp = new Arquivo();
                    arq_temp.nome_Arquivo = montarFormatoGD(id, "cis.pdf");
                    arq_temp.tipo_Arquivo = "cis";
                    list_arquivo.Add(arq_temp);
                }
                if (Session["postou_avisoFerias"].ToString().Equals((string)"sim"))
                {
                    Arquivo arq_temp = new Arquivo();
                    arq_temp.nome_Arquivo = montarFormatoGD(id, "avisoFerias.pdf");
                    arq_temp.tipo_Arquivo = "avisoFerias";
                    list_arquivo.Add(arq_temp);
                }
                if (Session["postou_requerimentos"].ToString().Equals((string)"sim"))
                {
                    Arquivo arq_temp = new Arquivo();
                    arq_temp.nome_Arquivo = montarFormatoGD(id, "requerimentos.pdf");
                    arq_temp.tipo_Arquivo = "requerimentos";
                    list_arquivo.Add(arq_temp);
                }
                if (Session["postou_outros"].ToString().Equals((string)"sim"))
                {
                    Arquivo arq_temp = new Arquivo();
                    arq_temp.nome_Arquivo = montarFormatoGD(id, "outros.pdf");
                    arq_temp.tipo_Arquivo = "outros";
                    list_arquivo.Add(arq_temp);
                }

                // Verifica se existe documento pra adicionar ao banco
                if (list_arquivo.Count == 0)
                {
                    LabelErro.Text         = "Nenhum documento adicionado";
                    ImageAttention.Visible = true;
                }
                else
                {
                    //Adicionando a lista dos arquivos aos documentos pra depois adicionar no banco
                    documento.arquivos = list_arquivo;

                    Adaptador adpt = new Adaptador();
                    try
                    {
                        adpt.InserirDocumento(documento);
                        Log log = new Log();
                        log.data_log          = DateTime.Now;
                        log.tipo_acao_log     = "Inserir";
                        log.usuario_log       = (String)Session["usuario"];
                        log.mensagem_acao_log = "O usuário " + log.usuario_log + " inseriu o colaborador de matrícula " + documento.matricula_Colaborador;
                        adpt.InserirLog(log);
                    }
                    catch (Exception ex)
                    {
                        LabelErro.Text         = ex.Message;
                        ImageAttention.Visible = true;
                    }

                    /*foreach (Arquivo arq in list_arquivo)
                     * {
                     *  versiona_indexa(arq.nome_Arquivo);
                     * }*/

                    mensagem = "Colaborador inserido com sucesso";
                    Session.Add("mensagem", mensagem);
                    Server.Transfer("listar.aspx");
                }
            }
        }