diff --git a/OI/Documentos.aspx b/OI/Documentos.aspx index 818d0df70..5e37a8679 100644 --- a/OI/Documentos.aspx +++ b/OI/Documentos.aspx @@ -28,17 +28,22 @@ - + Style="margin-top: -10px; text-align: center; width: 100%" GridLines="None" OnRowDataBound="GvDatos_RowDataBound"> + - <%----%> - + + + + + + diff --git a/OI/Documentos.aspx.cs b/OI/Documentos.aspx.cs index 2f162df73..9f02947a3 100644 --- a/OI/Documentos.aspx.cs +++ b/OI/Documentos.aspx.cs @@ -6,6 +6,7 @@ using System.Web.UI; using System.Web.UI.WebControls; using Extensiones; using System.Data; +using System.IO; public partial class OI_Documentos : ClsPaginas { @@ -27,4 +28,32 @@ public partial class OI_Documentos : ClsPaginas } ObjOI.Dispose(); } + + protected void GvDatos_RowDataBound(object sender, GridViewRowEventArgs e) + { + if (e.Row.RowType == DataControlRowType.DataRow) + { + LinkButton lkButonAux = e.Row.FCLinkButton("LkbDescargarDoc"); + ScriptManager.GetCurrent(this).RegisterPostBackControl(lkButonAux); + } + } + + protected void LkbDescargarDoc_Click(object sender, EventArgs e) + { + GridViewRow GvRow = (GridViewRow)(((LinkButton)sender).NamingContainer); + + string ArchivoFisico = GvRow.DataKey("ArchivoFisico"); + string NombreArchivo = ArchivoFisico.Split('_')[1]; + + string Ruta = string.Format("{0}Empresas/{1}/DocumentosRepo/{2}", ModExtensiones.DirectorioBaseEmpresas, UsuarioActual.CveEmpresa, ArchivoFisico); + byte[] archivoBytes = File.ReadAllBytes(Ruta); + + HttpContext.Current.Response.Clear(); + HttpContext.Current.Response.ClearContent(); + HttpContext.Current.Response.ContentType = "application/octet-stream"; + HttpContext.Current.Response.AddHeader("Content-Disposition", String.Format("attachment;filename={0}", NombreArchivo)); + HttpContext.Current.Response.AddHeader("Content-Length", archivoBytes.Length.ToString()); + HttpContext.Current.Response.OutputStream.Write(archivoBytes, 0, archivoBytes.Length); + HttpContext.Current.Response.End(); + } } \ No newline at end of file