66 lines
2.3 KiB
C#
66 lines
2.3 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Web;
|
|
using System.Web.UI;
|
|
using System.Web.UI.WebControls;
|
|
using Extensiones;
|
|
using System.Data;
|
|
using System.IO;
|
|
|
|
public partial class OI_Documentos : ClsPaginas
|
|
{
|
|
protected void Page_Load(object sender, EventArgs e)
|
|
{
|
|
if (!IsPostBack)
|
|
{
|
|
CargaDatos();
|
|
}
|
|
}
|
|
|
|
private void CargaDatos()
|
|
{
|
|
ClsOIEventos ObjOI = new ClsOIEventos();
|
|
if (ObjOI.ListadoDocumentos(UsuarioActual.CveEmpresa))
|
|
{
|
|
GvDatos.DataSource = ObjOI.DtResultados;
|
|
GvDatos.DataBind();
|
|
}
|
|
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 CveDocumento = GvRow.DataKey("CveDocumento");
|
|
//string NombreArchivo = ArchivoFisico.Split('_')[1];
|
|
|
|
string Ruta = string.Format("{0}Empresas/{1}/DocumentosRepo/{2}/{3}", ModExtensiones.DirectorioBaseEmpresas, UsuarioActual.CveEmpresa, CveDocumento, ArchivoFisico);
|
|
if (File.Exists(Ruta))
|
|
{
|
|
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}", ArchivoFisico));
|
|
HttpContext.Current.Response.AddHeader("Content-Length", archivoBytes.Length.ToString());
|
|
HttpContext.Current.Response.OutputStream.Write(archivoBytes, 0, archivoBytes.Length);
|
|
HttpContext.Current.Response.End();
|
|
}else
|
|
{
|
|
Alert("No se ha cargado Documento",ModExtensiones.TipoMensaje.MsgAdvertencia);
|
|
}
|
|
}
|
|
} |