protected void BtnSubir_Click(object sender, EventArgs e) { try { if (GuardarFirma()) { Doc = new BllDocumentos.Documentos(); Doc.DocuActa = int.Parse(Session["acta"].ToString()); Doc.DocuTiDo = int.Parse(CmbtipoDocumento.SelectedValue); Doc.DocuFeCa = System.DateTime.Now; Doc.DocuUsCa = Usuario.username; Doc.DocuUrLo = lblImage.Text; Doc.DocuSincro = "1"; Doc.DocuVeri = "1"; Doc.DocuFeVe = System.DateTime.Now.ToString(); Doc.DocuUsVe = Usuario.username; ; int r = Doc.Insert(); if (r > 0) { FillDocumentos(); Metodos.divMensaje(Constantes.Succes, Constantes.Guardado, PnlMsg, Constantes.Ok); lblImage.Text = "Seleccione Archivo"; Page.Response.Redirect(Page.Request.Url.ToString(), true); ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "script", "revisar();", true); } else { Metodos.divMensaje(Constantes.Succes, Constantes.ErrorAlGuardar, PnlMsg, Constantes.Ok); ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "script", "revisar();", true); } } else { Metodos.divMensaje(Constantes.Succes, "No se a podido subir el archivo", PnlMsg, Constantes.Ok); ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "script", "revisar();", true); } } catch (Exception ex) { ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "script", "revisar();", true); Log.EscribirError(ex); } }
protected void chkVer_CheckedChanged(object sender, EventArgs e) { try { //ScriptManager.RegisterStartupScript(this.Page, this.Page.GetType(),"err_msg","confirm('Esta seguro de confirmar este Documento)');",true); //llamada al evento jquery para mantener el tab CheckBox ch = (CheckBox)(sender); // Naming container me da la referencia de donde esta el control seleccionado GridViewRow row = (GridViewRow)ch.NamingContainer; if (ch.Checked) { Doc = BllDocumentos.GetCargo(int.Parse(gridDocume.Rows[row.RowIndex].Cells[0].Text)); Doc.DocuVeri = "1"; Doc.DocuUsVe = Usuario.username; Doc.Update(); FillDocumentos(); } //ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "script", "Confirm();", true); ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "script", "revisar();", true); } catch (Exception ex) { Log.EscribirError(ex); Metodos.divMensaje(Constantes.Danger, Constantes.errorGeneral, PnlMsg, Constantes.Fallo); } }
protected void btnDelete_Command(object sender, CommandEventArgs e) { try { if (e.CommandName == "delete") { BllDocumentos.Documentos Docu = new BllDocumentos.Documentos(); BllTipoDocumento.TipoDocumento TiDo = new BllTipoDocumento.TipoDocumento(); Docu = BllDocumentos.GetCargo(int.Parse(e.CommandArgument.ToString())); TiDo = BllTipoDocumento.GetCargo(Docu.DocuTiDo); if (TiDo.TiDoDele == true) { File.Delete(Server.MapPath(Docu.DocuUrLo)); if (BllDocumentos.Delete(Docu.DocuCodi.Value)) { FillDocumentos(); Metodos.divMensaje(Constantes.Succes, Constantes.Eliminado, PnlMsg, Constantes.Ok); } else { Metodos.divMensaje(Constantes.Danger, Constantes.ErrorEliminando, PnlMsg, Constantes.Fallo); } } } } catch (Exception ex) { Log.EscribirError(ex); } }
//Metodo para Mostrar el archivo private void RenderReport(ReportViewer Report, HttpResponse Response) { try { Warning[] warnings = null; string[] streamids; string mimeType = ""; string encoding; string extension = "pdf"; string filename = "Proceso" + Session["Proc"].ToString() + "Acta" + Session["acta"].ToString(); ObjectDataSource ObjectDataSource1 = new ObjectDataSource("Generals.Web.Datasets.DstProcesoSimpliTableAdapters.Sp_Proceso_SimpliTableAdapter", "GetData"); ObjectDataSource1.SelectParameters.Add("conse", Session["Proc"].ToString()); Microsoft.Reporting.WebForms.ReportDataSource rds = new Microsoft.Reporting.WebForms.ReportDataSource("DsPr", ObjectDataSource1); Report.LocalReport.DataSources.Add(rds); // Report.LocalReport.DataSources.Add(this.Page.FindControl("ObjectDataSource1")); byte[] bytes = ReportViewer1.LocalReport.Render("PDF", null, out mimeType, out encoding, out extension, out streamids, out warnings); //// esto es solo para mostrar l pdf en una pagina //Response.Clear(); //Response.ContentType = mimeType; //Response.AppendHeader("content-Disposition", "attachment;filename=" + filename + "." + extension); var saveAs = string.Format("{0}.pdf", Path.Combine(Server.MapPath(@"~\File\Documentos\"), filename)); if (idx == 0) { while (File.Exists(saveAs)) { idx += 1; saveAs = string.Format("{0}.{1}.pdf", Path.Combine(Server.MapPath(@"~\File\Documentos\"), filename), idx); } using (var stream = new FileStream(saveAs, FileMode.Create, FileAccess.Write)) { stream.Write(bytes, 0, bytes.Length); stream.Close(); } } //Response.WriteFile(Server.MapPath(@"~\File\Documentos\" + filename + "." + extension)); //Response.BinaryWrite(bytes); //Response.TransmitFile(Server.MapPath(@"~\File\Documentos\" + filename + "." + extension)); //Response.BinaryWrite(bytes); Doc = new BllDocumentos.Documentos(); Doc.DocuActa = int.Parse(Session["acta"].ToString()); Doc.DocuTiDo = 16; Doc.DocuFeCa = System.DateTime.Now; Doc.DocuUsCa = Usuario.username; Doc.DocuUrLo = "~/File/Documentos/" + filename + "." + extension; Doc.DocuSincro = "1"; Doc.DocuVeri = "1"; Doc.DocuFeVe = System.DateTime.Now.ToString(); Doc.DocuUsVe = Usuario.username; ; int r = Doc.Insert(); if (r > 0) { // Response.Flush(); //HttpContext.Current.Response.Buffer = true; //HttpContext.Current.Response.Clear(); //HttpContext.Current.Response.ContentType = mimeType; //HttpContext.Current.Response.AddHeader("content-Disposition", "attachment; filename=" + "Proceso" + Session["acta"].ToString() + "." + extension); //HttpContext.Current.Response.BinaryWrite(bytes); //HttpContext.Current.Response.Flush(); //Response.Redirect("GestionBandejas.aspx"); //HttpContext.Current.Response.Close(); //Response.Buffer = true; //Response.Clear(); //Response.ContentType = mimeType; //Response.AddHeader("content-Disposition", "attachment; filename=" + "Proceso" + Session["acta"].ToString() + "." + extension); //Response.BinaryWrite(bytes); //Response.Flush(); Response.Redirect("GestionBandejas.aspx"); //HttpContext.Current.Response.Close(); } } catch (Exception ex) { Response.Redirect("GestionBandejas.aspx", false); Log.EscribirError(ex); } }
//Metodo para Mostrar el archivo private void RenderReport(ReportViewer Report, HttpResponse Response) { try { Warning[] warnings = null; string[] streamids; string mimeType = ""; string encoding; string extension = "pdf"; string filename = "Liq" + Session["conse"].ToString() + "Ac"+Session["acta"].ToString(); //Dataset para Liquidacion ObjectDataSource ObjectDataSource1 = new ObjectDataSource("Generals.Web.Datasets.Ds_liquiTableAdapters.Sp_RevisarLiquidacionTableAdapter", "GetData"); ObjectDataSource1.SelectParameters.Add("conse", Session["Conse"].ToString()); Microsoft.Reporting.WebForms.ReportDataSource rds = new Microsoft.Reporting.WebForms.ReportDataSource("DsLiqui", ObjectDataSource1); //DataSet para Consumo ObjectDataSource ObjectDataSource2 = new ObjectDataSource("Generals.Web.Datasets.Ds_liquiTableAdapters.Sp_Consumos_RevisarLiquiTableAdapter", "GetData"); ObjectDataSource2.SelectParameters.Add("acta", Session["acta"].ToString()); Microsoft.Reporting.WebForms.ReportDataSource rds1 = new Microsoft.Reporting.WebForms.ReportDataSource("DsConsumos", ObjectDataSource2); Report.LocalReport.DataSources.Add(rds); Report.LocalReport.DataSources.Add(rds1); // Report.LocalReport.DataSources.Add(this.Page.FindControl("ObjectDataSource1")); byte[] bytes = ReportViewer1.LocalReport.Render("PDF", null, out mimeType, out encoding, out extension, out streamids, out warnings); //// esto es solo para mostrar l pdf en una pagina var saveAs = string.Format("{0}.pdf", Path.Combine(Server.MapPath(@"~\File\Documentos\"), filename)); if (idx == 0) { while (File.Exists(saveAs)) { idx += 1; saveAs = string.Format("{0}.{1}.pdf", Path.Combine(Server.MapPath(@"~\File\Documentos\"), filename), idx); } using (var stream = new FileStream(saveAs, FileMode.Create, FileAccess.Write)) { stream.Write(bytes, 0, bytes.Length); stream.Close(); } } Doc = new BllDocumentos.Documentos(); Doc.DocuActa = int.Parse(Session["acta"].ToString()); Doc.DocuTiDo = 13; Doc.DocuFeCa = System.DateTime.Now; Doc.DocuUsCa = Usuario.username; Doc.DocuUrLo = "~/File/Documentos/"+filename+"."+ extension; Doc.DocuSincro = "1"; Doc.DocuVeri = "1"; Doc.DocuFeVe = System.DateTime.Now.ToString(); Doc.DocuUsVe = Usuario.username; ; int r = Doc.Insert(); if (r > 0) { // Panel p = new Panel(); ; // Response.Clear(); // Response.Buffer = true; // Response.ContentType = "application/pdf"; // Response.AddHeader("content-disposition", "attachment;filename="+filename+"."+ extension); // Response.Charset = ""; // this.EnableViewState = false; // ScriptManager pr = new ScriptManager(); // System.IO.StringWriter sw = new System.IO.StringWriter(); // System.Web.UI.HtmlTextWriter htw = new System.Web.UI.HtmlTextWriter(sw); // p.Controls.Add(pr); // p.Controls.Add(Report); // p.RenderControl(htw); // Response.Write(sw.ToString()); // Response.End(); //// Response.Buffer = true; ////Response.Clear(); //// Response.ContentType = mimeType; //// Response.AddHeader("content-Disposition", "attachment; filename=" + filename + "." + extension); //// Response.BinaryWrite(bytes); //// Response.Flush(); //Response.Close(); Response.Redirect("GestionBandejas.aspx", false); } } catch (Exception ex) { Log.EscribirError(ex); } finally { Response.Redirect("~/GestionBandejas.aspx", false); } }