protected void gridDocumentosFiscalia_RowCommand(object sender, GridViewCommandEventArgs e) { asignacionResumen(ref objresumen); LogicaNegocio LN = new LogicaNegocio(); if (e.CommandName == "Descargar") { DataTable dt = new DataTable("dt"); Dictionary <string, string> datos = new Dictionary <string, string>(); string[] arg = new string[2]; arg = e.CommandArgument.ToString().Split(';'); string DescPlantilla = arg[1]; string idPlantilla = arg[0]; string TotalRepresentantes = string.Empty; string TotalAvales = string.Empty; dt = LN.ListarPlantillaById(Convert.ToInt32(idPlantilla)); if (dt.Rows.Count > 0) { ocultarDiv(); DataSet ds = new DataSet(); ds = LN.CargarDatosHtml(Convert.ToInt32(objresumen.idOperacion.ToString())); string ListarGarantiasAnexo1 = util.Mensaje(LN.ListarGarantiasAnexo1(objresumen.idEmpresa)); byte[] archivo = null; TotalRepresentantes = LN.ListarRepresentantes(objresumen.idEmpresa); TotalAvales = LN.ListarAvales(objresumen.idEmpresa); string codigoHtml = util.ReemplazarValores(dt.Rows[0]["ContenidoHtml"].ToString(), ds, ListarGarantiasAnexo1, TotalRepresentantes, TotalAvales); string NombrePlantilla = dt.Rows[0]["NombrePlantilla"].ToString(); if (!string.IsNullOrEmpty(codigoHtml)) { string contenido = HttpUtility.HtmlDecode(codigoHtml); Page.Session["Titulo"] = NombrePlantilla; Page.Session["tipoDoc"] = dt.Rows[0]["TipoDocumento"].ToString(); if (dt.Rows[0]["TipoDocumento"].ToString().ToLower() == "docx") { //bajarWord(codigoHtml, NombrePlantilla); archivo = util.bajarWord(codigoHtml, NombrePlantilla); Page.Session["binaryData"] = archivo; Page.Session["Titulo"] = NombrePlantilla.Trim(); ScriptManager.RegisterStartupScript(Page, Page.GetType(), "popup", "window.open('BajarDocumento.aspx','_blank')", true); } else { System.Text.StringBuilder sb = new System.Text.StringBuilder(); sb.Append("<table width='1000px'><tr><td align='center'><table width='900px'><tr><td>" + contenido + "</td></tr></table></td></tr></table>"); Page.Session["tipoDoc"] = "pdf"; archivo = util.PdfFiscalia(sb); } if (archivo != null) { Page.Session["binaryData"] = archivo; Page.Session["Titulo"] = NombrePlantilla.Trim(); ScriptManager.RegisterStartupScript(Page, Page.GetType(), "popup", "window.open('BajarDocumento.aspx','_blank')", true); } } else { dvWarning.Style.Add("display", "block"); lbWarning.Text = "revise la informacion necesaria: * Direccion Principal de la empresa"; } } } }
protected void gridDocumentosCurse_RowCommand(object sender, GridViewCommandEventArgs e) { asignacionResumen(ref objresumen); if (e.CommandName == "Eliminar") { string nombre = new Documentos { }.ObtenerNombreArchivo(e.CommandArgument.ToString(), ViewState["Certificado"].ToString(), objresumen); if (new Documentos { }.EliminarArchivo(nombre, ViewState["Certificado"].ToString(), objresumen)) { //DataTable tabla = Ln.ConsultarOperacion(int.Parse(objresumen.idOperacion.ToString())); addDocumentos(); } } if (e.CommandName == "Descargar") { LogicaNegocio Ln = new LogicaNegocio(); DataTable dt = new DataTable("dt"); Dictionary <string, string> datos = new Dictionary <string, string>(); datos["IdEmpresa"] = objresumen.idEmpresa.ToString(); datos["IdOperacion"] = objresumen.idOperacion.ToString(); //string indicador = util.BuscarValorIndicador(DateTime.Now.ToString()); DataTable dtValorMoneda = new DataTable("dtValorMoneda"); dtValorMoneda = Ln.GestionValorMoneda(DateTime.Now, 0, null, null, null, 1); datos["ValorUF"] = dtValorMoneda.Rows[0]["MontoUF"].ToString(); datos["ValorUS"] = dtValorMoneda.Rows[0]["MontoUSD"].ToString(); string[] arg = new string[2]; arg = e.CommandArgument.ToString().Split(';'); string DescPlantilla = arg[1]; string idPlantilla = arg[0]; if (DescPlantilla == "Solicitud de Emision") { byte[] archivo = new Reportes { }.GenerarReporte("Solicitud_de_Emision", datos, "admin", objresumen); if (archivo != null) { Page.Session["tipoDoc"] = "pdf"; Page.Session["binaryData"] = archivo; Page.Session["Titulo"] = "Solicitud_de_Emision"; ScriptManager.RegisterStartupScript(Page, Page.GetType(), "popup", "window.open('BajarDocumento.aspx','_blank')", true); } } else if (DescPlantilla == "Instruccion Curse") { byte[] archivo = new Reportes { }.GenerarReporte("Instruccion_de_Curse", datos, "admin", objresumen); if (archivo != null) { Page.Session["tipoDoc"] = "pdf"; Page.Session["binaryData"] = archivo; Page.Session["Titulo"] = "Instruccion_de_Curse"; ScriptManager.RegisterStartupScript(Page, Page.GetType(), "popup", "window.open('BajarDocumento.aspx','_blank')", true); } } else { dt = Ln.ListarPlantillaById(Convert.ToInt32(idPlantilla)); if (dt.Rows.Count > 0) { ocultarDiv(); DataSet dtLista = new DataSet(); dtLista = Ln.CargarDatosHtml(Convert.ToInt32(objresumen.idOperacion.ToString())); string codigoHtml = util.ReemplazarValores(dt.Rows[0]["ContenidoHtml"].ToString(), dtLista, "", "", ""); string NombrePlantilla = dt.Rows[0]["NombrePlantilla"].ToString(); if (!string.IsNullOrEmpty(codigoHtml)) { //generar(NombrePlantilla, codigoHtml); string contenido = HttpUtility.HtmlDecode(codigoHtml); System.Text.StringBuilder sb = new System.Text.StringBuilder(); sb.Append("<table width='1000px'><tr><td align='center'><table width='900px'><tr><td>" + contenido + "</td></tr></table></td></tr></table>"); byte[] archivo = util.ConvertirAPDF_Control(sb); Page.Session["Titulo"] = NombrePlantilla; if (archivo != null) { Page.Session["tipoDoc"] = dt.Rows[0]["TipoDocumento"].ToString(); Page.Session["binaryData"] = archivo; Page.Session["Titulo"] = NombrePlantilla.Trim(); ScriptManager.RegisterStartupScript(Page, Page.GetType(), "popup", "window.open('BajarDocumento.aspx','_blank')", true); } } } else { MensajeAlerta("Error al buscar el documento"); } } } if (e.CommandName == "Adjuntar") { DivArchivo.Visible = true; documentos.Visible = false; botones.Visible = false; tipo = e.CommandArgument.ToString(); AdjuntarDoc(); } }