Exemplo n.º 1
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.º 2
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.º 3
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.º 4
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.º 5
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");
                }
            }
        }
Exemplo n.º 6
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.º 7
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.º 8
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 = "";
        }