protected void Page_Load(object sender, EventArgs e) { try { if (!Page.IsPostBack) { DocumentoDAL dDAL = new DocumentoDAL(); Documento d = dDAL.CarregarDadosPorIdDocumento(Convert.ToInt32(Request.QueryString["idDoc"])); // PREENCHE OS TIPOS DE DOCUMENTOS // TipoDocumentoDAL tdDAL = new TipoDocumentoDAL(); ddlTipoDocumento.DataSource = tdDAL.Listar(); ddlTipoDocumento.DataBind(); ddlTipoDocumento.SelectedValue = d.TipoDocumento.IdTipoDocumento.ToString(); // FIM // txtDescricao.Text = d.Descricao; txtNomePortador.Text = d.NomePortador; txtRg.Text = d.RG; txtNumeroInss.Text = d.NumeroINSS; txtCpfCnpj.Text = d.CPFCNPJ; txtVigencia.Text = d.Vigencia.ToString(); DateTime dtNula = new DateTime(0001, 1, 1); if (d.VencimentoVigencia != dtNula) { txtVencimentoVigencia.Text = d.VencimentoVigencia.ToShortDateString(); } if (d.DataEmissao != dtNula) { txtDataEmissao.Text = d.DataEmissao.ToShortDateString(); } if (d.DataAssinatura != dtNula) { txtDataAssinatura.Text = d.DataAssinatura.ToShortDateString(); } if (d.DataPagamentoRecebimento != dtNula) { txtDataPagamentoRecebimento.Text = d.DataPagamentoRecebimento.ToShortDateString(); } txtNumeroParcelas.Text = d.NumeroParcelas; txtValorPrevistoParcela.Text = d.ValorPrevistoParcela; if (d.Descarte != dtNula) { txtDescarte.Text = d.Descarte.ToShortDateString(); } } } catch (Exception) { throw; } }
protected void Page_Load(object sender, EventArgs e) { try { DocumentoDAL dDAL = new DocumentoDAL(); MovimentacaoDAL mDAL = new MovimentacaoDAL(); lblDescricao.Text = dDAL.CarregarDadosPorIdDocumento(Convert.ToInt32(Request.QueryString["idDoc"])).Descricao; rptHistoricoDocumento.DataSource = mDAL.ListarPorIdDocumento(Convert.ToInt32(Request.QueryString["idDoc"])); rptHistoricoDocumento.DataBind(); } catch (Exception) { throw; } }
protected void Page_Load(object sender, EventArgs e) { try { DocumentoDAL dDAL = new DocumentoDAL(); switch (Request.QueryString["act"]) { case "exc": Documento d = dDAL.CarregarDadosPorIdDocumento(Convert.ToInt32(Request.QueryString["idDoc"])); dDAL.Excluir(d); Response.Write("<script language='JavaScript'>alert('O Documento foi excluído com sucesso');location='ListarDocumentos.aspx';</script>"); break; case "rcv": dDAL.Receber(Convert.ToInt32(Request.QueryString["idDoc"])); Response.Write("<script language='JavaScript'>alert('O Documento foi recebido com sucesso');location='ListarDocumentos.aspx';</script>"); break; default: break; } if (!Page.IsPostBack) { // PREENCHE OS TIPOS DE DOCUMENTOS // TipoDocumentoDAL tdDAL = new TipoDocumentoDAL(); ddlTipoDocumento.DataSource = tdDAL.Listar(); ddlTipoDocumento.DataBind(); if (Request.QueryString["idTpd"] == null) { ddlTipoDocumento.Items.Insert(0, (new ListItem("Selecione o tipo de documento", ""))); } else { ddlTipoDocumento.SelectedValue = Request.QueryString["idTpd"]; } // FIM // } } catch (Exception) { throw; } }
protected void Page_Load(object sender, EventArgs e) { try { if (!Page.IsPostBack) { DocumentoDAL dDAL = new DocumentoDAL(); Documento d = dDAL.CarregarDadosPorIdDocumento(Convert.ToInt32(Request.QueryString["idDoc"])); litDescricao.Text = d.Descricao; litTipo.Text = d.TipoDocumento.DSTipoDocumento; litPortador.Text = d.NomePortador; // PREENCHE OS PROCESSOS // ProcessoDAL pDAL = new ProcessoDAL(); ddlProcessoDestino.DataSource = pDAL.Listar(); ddlProcessoDestino.DataBind(); ddlProcessoDestino.Items.Insert(0, (new ListItem("", ""))); // FIM // } } catch (Exception) { throw; } }
protected void Alterar(object sender, EventArgs e) { try { DocumentoDAL dDAL = new DocumentoDAL(); Documento d = dDAL.CarregarDadosPorIdDocumento(Convert.ToInt32(Request.QueryString["idDoc"])); TipoDocumentoDAL tdDAL = new TipoDocumentoDAL(); d.TipoDocumento = tdDAL.CarregarDadosPorIdTipoDocumento(Convert.ToInt32(ddlTipoDocumento.SelectedValue)); d.Descricao = txtDescricao.Text; d.NomePortador = txtNomePortador.Text; d.RG = txtRg.Text; d.NumeroINSS = txtNumeroInss.Text; d.CPFCNPJ = txtCpfCnpj.Text; if (txtVigencia.Text == "") { d.Vigencia = 0; } else { d.Vigencia = Convert.ToInt32(txtVigencia.Text); } if (txtVencimentoVigencia.Text == "") { d.VencimentoVigencia = new DateTime(1900, 1, 1); } else { d.VencimentoVigencia = Convert.ToDateTime(txtVencimentoVigencia.Text); } if (txtDataEmissao.Text == "") { d.DataEmissao = new DateTime(1900, 1, 1); } else { d.DataEmissao = Convert.ToDateTime(txtDataEmissao.Text); } if (txtDataAssinatura.Text == "") { d.DataAssinatura = new DateTime(1900, 1, 1); } else { d.DataAssinatura = Convert.ToDateTime(txtDataAssinatura.Text); } if (txtDataPagamentoRecebimento.Text == "") { d.DataPagamentoRecebimento = new DateTime(1900, 1, 1); } else { d.DataPagamentoRecebimento = Convert.ToDateTime(txtDataPagamentoRecebimento.Text); } d.NumeroParcelas = txtNumeroParcelas.Text; d.ValorPrevistoParcela = txtValorPrevistoParcela.Text; if (txtDescarte.Text == "") { d.Descarte = new DateTime(1900, 1, 1); } else { d.Descarte = Convert.ToDateTime(txtDescarte.Text); } dDAL.Alterar(d); Response.Write("<script language='JavaScript'>alert('Documento alterado com sucesso');window.parent.location='ListarDocumentos.aspx';</script>"); } catch (Exception) { throw; } }
protected void Arquivar(object sender, EventArgs e) { try { DocumentoDAL dDAL = new DocumentoDAL(); ArquivamentoInterno ai = new ArquivamentoInterno(); // CADASTRA O ARQUIVAMENTO INTERNO // bool boolArquivoInvalido = false; if (txtArquivoDocumento.HasFile) { switch (txtArquivoDocumento.FileName.Substring(txtArquivoDocumento.FileName.Length - 4)) { case ".pdf": ai.Documento = dDAL.CarregarDadosPorIdDocumento(Convert.ToInt32(Request.QueryString["idDoc"])); ai.Arquivo = Convert.ToInt32(txtArquivo.Text); ai.Gaveta = Convert.ToInt32(txtGaveta.Text); ai.Pasta = Convert.ToInt32(txtPasta.Text); ai.ArquivoDocumento = "-"; ArquivamentoInternoDAL aiDAL = new ArquivamentoInternoDAL(); aiDAL.Cadastrar(ai); ArquivamentoInterno aiUltimo = new ArquivamentoInterno(); aiUltimo = aiDAL.CarregarDadosUltimoCadastrado(); String strNome; strNome = aiUltimo.IdArquivamentoInterno + txtArquivoDocumento.FileName.Substring(txtArquivoDocumento.FileName.Length - 4); aiUltimo.ArquivoDocumento = strNome; txtArquivoDocumento.SaveAs(Server.MapPath(@"../../../sgd/img/arquivamentosInternos/") + strNome); aiDAL.Alterar(aiUltimo); break; default: boolArquivoInvalido = true; break; } } else { ai.Documento = dDAL.CarregarDadosPorIdDocumento(Convert.ToInt32(Request.QueryString["idDoc"])); ai.Arquivo = Convert.ToInt32(txtArquivo.Text); ai.Gaveta = Convert.ToInt32(txtGaveta.Text); ai.Pasta = Convert.ToInt32(txtPasta.Text); ai.ArquivoDocumento = "-"; ArquivamentoInternoDAL aiDAL = new ArquivamentoInternoDAL(); aiDAL.Cadastrar(ai); } // FIM // // ALTERA O STATUS DO DOCUMENTO // Documento d = dDAL.CarregarDadosPorIdDocumento(Convert.ToInt32(Request.QueryString["idDoc"])); d.Arquivado = "1"; //Response.Write(d.VencimentoVigencia == new DateTime(0001, 1, 1)); //Response.End(); dDAL.Alterar(d); // FIM // // EXCLUI TODOS OS ARQUIVAMENTOS EXTERNOS DO DOCUMENTO // ArquivamentoExternoDAL aeDAL = new ArquivamentoExternoDAL(); aeDAL.ExcluirPorIdDocumento(d.IdDocumento); // FIM // Response.Write("<script language='JavaScript'>alert('Arquivamento Interno do Documento realizado com sucesso');window.parent.location='ListarDocumentos.aspx';</script>"); } catch (Exception) { throw; } }
protected void Arquivar(object sender, EventArgs e) { try { DocumentoDAL dDAL = new DocumentoDAL(); // CADASTRA O ARQUIVAMENTO EXTERNO // bool boolArquivoInvalido = false; if (txtArquivoDocumento.HasFile) { switch (txtArquivoDocumento.FileName.Substring(txtArquivoDocumento.FileName.Length - 4)) { case ".pdf": ArquivamentoExterno ae = new ArquivamentoExterno(); ae.Documento = dDAL.CarregarDadosPorIdDocumento(Convert.ToInt32(Request.QueryString["idDoc"])); ae.Estante = Convert.ToInt32(txtEstante.Text); ae.Prateleira = Convert.ToInt32(txtPrateleira.Text); ae.Caixa = Convert.ToInt32(txtCaixa.Text); ae.ArquivoDocumento = "-"; ArquivamentoExternoDAL aeDAL = new ArquivamentoExternoDAL(); aeDAL.Cadastrar(ae); ArquivamentoExterno aeUltimo = new ArquivamentoExterno(); aeUltimo = aeDAL.CarregarDadosUltimoCadastrado(); String strNome; strNome = aeUltimo.IdArquivamentoExterno + txtArquivoDocumento.FileName.Substring(txtArquivoDocumento.FileName.Length - 4); aeUltimo.ArquivoDocumento = strNome; txtArquivoDocumento.SaveAs(Server.MapPath(@"../../../sgd/img/arquivamentosExternos/") + strNome); aeDAL.Alterar(aeUltimo); break; default: boolArquivoInvalido = true; break; } } // FIM // // ALTERA O STATUS DO DOCUMENTO // Documento d = dDAL.CarregarDadosPorIdDocumento(Convert.ToInt32(Request.QueryString["idDoc"])); d.Arquivado = "2"; dDAL.Alterar(d); // FIM // // EXCLUI TODOS OS ARQUIVAMENTOS INTERNOS DO DOCUMENTO // ArquivamentoInternoDAL aiDAL = new ArquivamentoInternoDAL(); aiDAL.ExcluirPorIdDocumento(d.IdDocumento); // FIM // } catch (Exception) { throw; } }
protected void Movimentar(object sender, EventArgs e) { try { DocumentoDAL dDAL = new DocumentoDAL(); Documento d = dDAL.CarregarDadosPorIdDocumento(Convert.ToInt32(Request.QueryString["idDoc"])); UsuarioDAL uDAL = new UsuarioDAL(); Usuario u = uDAL.ObterDadosPorId(Convert.ToInt32(Session["sesIdUsuario"])); ProcessoDAL pDAL = new ProcessoDAL(); Processo p = pDAL.ObterDadosPorId(Convert.ToInt32(ddlProcessoDestino.SelectedValue)); DateTime dtPrazo = DateTime.Now.AddDays(p.NRPrazoMaximo); Movimentacao m = new Movimentacao(); m.Documento = d; m.ProcessoOrigem = Convert.ToInt32(Session["sesIdProcesso"]); m.ProcessoDestino = Convert.ToInt32(ddlProcessoDestino.SelectedValue); m.DataHoraMovimentacao = DateTime.Now.ToShortDateString() + " " + DateTime.Now.ToLongTimeString(); m.MovimentadoPor = u.DSNome; m.Recebido = "Não"; m.DataHoraRecebimento = ""; m.Prazo = dtPrazo; m.Despacho = txtDespacho.Text.Replace("\n", "<br />"); m.EntreguePara = txtEntreguePara.Text.Replace("'", ""); m.AlertaPrazo = "Não"; dDAL.Movimentar(m, d.IdDocumento); // ENVIA O E-MAIL // string strNomeRemetente = "LFC - GesDoc"; string strEmailRemetente = "*****@*****.**"; string strSenha = "01!GesDoc!"; string strSMTP = "smtp.lfc.org.br"; string strEmailDestinatario = "*****@*****.**"; string strAssunto = "Documento movimentado para este processo"; string strConteudo = "Teste de envio de emails usando System.Net.Mail em C#"; //Cria objeto com dados do e-mail. MailMessage objEmail = new MailMessage(); objEmail.From = new System.Net.Mail.MailAddress(strNomeRemetente + "<" + strEmailRemetente + ">"); objEmail.To.Add(strEmailDestinatario); objEmail.Priority = System.Net.Mail.MailPriority.Normal; objEmail.IsBodyHtml = true; objEmail.Subject = strAssunto; objEmail.Body = strConteudo; //Para evitar problemas de caracteres "estranhos", configuramos o charset para "ISO-8859-1" objEmail.SubjectEncoding = System.Text.Encoding.GetEncoding("ISO-8859-1"); objEmail.BodyEncoding = System.Text.Encoding.GetEncoding("ISO-8859-1"); //Cria objeto com os dados do SMTP System.Net.Mail.SmtpClient objSmtp = new System.Net.Mail.SmtpClient(); //Alocamos o endereço do host para enviar os e-mails objSmtp.Credentials = new System.Net.NetworkCredential(strEmailRemetente, strSenha); objSmtp.Host = strSMTP; objSmtp.Port = 587; //Enviamos o e-mail através do método .send() try { objSmtp.Send(objEmail); } catch (Exception ex) { Response.Write("Ocorreram problemas no envio do e-mail. Erro = " + ex.Message); } finally { objEmail.Dispose(); } // FIM // Response.Write("<script language='JavaScript'>alert('O Documento foi movimentado com sucesso');parent.location='ListarDocumentos.aspx';</script>"); } catch (Exception) { throw; } }