158 lines
4.8 KiB
C#
158 lines
4.8 KiB
C#
using System;
|
|
using System.Activities;
|
|
using System.Collections.Generic;
|
|
using System.Data;
|
|
using System.Linq;
|
|
using System.Web;
|
|
using System.Web.UI;
|
|
using System.Web.UI.WebControls;
|
|
using System.Web.UI.HtmlControls;
|
|
|
|
using Extensiones;
|
|
|
|
public partial class OI_RepNormatividad : ClsPaginas
|
|
{
|
|
|
|
|
|
#region "Propiedades"
|
|
private int IDSelected
|
|
{
|
|
get
|
|
{
|
|
return ViewState["IDSelected"].ToEntero();
|
|
}
|
|
|
|
set
|
|
{
|
|
ViewState["IDSelected"] = value;
|
|
}
|
|
}
|
|
private String ruta
|
|
{
|
|
get
|
|
{
|
|
return ViewState["ruta"].ToString();
|
|
}
|
|
|
|
set
|
|
{
|
|
ViewState["ruta"] = value;
|
|
}
|
|
}
|
|
|
|
public DataTable DtDatos { get; private set; }
|
|
#endregion
|
|
|
|
protected void Page_Load(object sender, EventArgs e)
|
|
{
|
|
if (!IsPostBack)
|
|
{
|
|
CargaDatos();
|
|
|
|
if (DtDatos.Rows.Count == 0)
|
|
{
|
|
ClsOIEventos ObjOIEventos = new ClsOIEventos();
|
|
|
|
if (ObjOIEventos.AddEventoNormatividad("PADRE", "PADRE DE TODOS", "", UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, "".ToEntero()))
|
|
{
|
|
if (ObjOIEventos.GetEventoNormatividad(UsuarioActual.CveEmpresa))
|
|
{
|
|
IDSelected = ObjOIEventos.DtResultados.Rows[0]["CveEvento"].ToString().ToEntero();
|
|
ObjOIEventos.AddEventoNormatividad("Título 1", "", "", UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, IDSelected);
|
|
}
|
|
}
|
|
ObjOIEventos.Dispose();
|
|
CargaDatos();
|
|
}
|
|
RegistraScript(String.Format("expandir();"));
|
|
|
|
//Control btnAdd = ArbolCuentas.FindControl(String.Format("285595"));
|
|
|
|
//List<Control> list = GetListControls(btnAdd);
|
|
|
|
// Control c = list[2];
|
|
// LinkButton lbAdd = (LinkButton)btnAdd.FindControl(c.ID);
|
|
// lbAdd.Visible = false;
|
|
|
|
}
|
|
}
|
|
public List<Control> GetListControls(Control ctrl)
|
|
{
|
|
List<Control> list = new List<Control>();
|
|
|
|
foreach (Control item in ctrl.Controls)
|
|
{
|
|
list.Add(item);
|
|
|
|
if (item.Controls.Count > 0)
|
|
list.AddRange(GetListControls(item));
|
|
}
|
|
|
|
return list;
|
|
}
|
|
private DataTable getNodospadreHijos(int nodo)
|
|
{
|
|
return DtDatos.FiltraParametros(String.Format("CveEvento = {0}", nodo));
|
|
}
|
|
protected void CargaDatos()
|
|
{
|
|
ClsOIEventos ObjOIEventos = new ClsOIEventos();
|
|
if (ObjOIEventos.GetEventoNormatividad(UsuarioActual.CveEmpresa))
|
|
{
|
|
DtDatos = ObjOIEventos.DtResultados.FiltraParametros("", "CveEvento");
|
|
DtDatos.Columns.Add("tdOcultar");
|
|
|
|
foreach(DataRow dr in DtDatos.Rows)
|
|
{
|
|
dr["tdOcultar"] = (dr["Archivo"].ToString().Length > 0 ? "" : "btnOculto");
|
|
}
|
|
DtDatos.AcceptChanges();
|
|
}
|
|
|
|
ArbolCuentas.DataSource = DtDatos;
|
|
ArbolCuentas.nivel = "CtaInicial";
|
|
ArbolCuentas.nodoid = "CveEvento";
|
|
ArbolCuentas.padre = "CveEventoPadre";
|
|
ArbolCuentas.titulo = "Asunto";
|
|
// ArbolCuentas.CssClassAdd = "tdOcultar";
|
|
updatos.Update();
|
|
|
|
ObjOIEventos.Dispose();
|
|
}
|
|
|
|
protected void aradd_Click(object sender, EventArgs e)
|
|
{
|
|
//RegistraScript("OcultarBoton('285584');");
|
|
ADServerControl.DragableItem obj = (ADServerControl.DragableItem)sender;
|
|
IDSelected = obj.Cve;
|
|
CargaDatos();
|
|
DataTable dt = getNodospadreHijos(IDSelected);
|
|
ruta = UsuarioActual.Empresa.Ruta + String.Format("OI\\\\{0}", dt.Rows[0]["Archivo"].ToString());
|
|
if (System.IO.File.Exists(ruta))
|
|
{
|
|
RegistraScript("$get('BtnDownload').click();");
|
|
//Alert("archivo.", ModExtensiones.TipoMensaje.MsgAdvertencia);
|
|
}
|
|
else
|
|
{
|
|
Alert("No se encontró archivo.", ModExtensiones.TipoMensaje.MsgAdvertencia);
|
|
}
|
|
}
|
|
|
|
protected void BtnDownload_Click(object sender, EventArgs e)
|
|
{
|
|
|
|
System.IO.FileInfo archivo = new System.IO.FileInfo(ruta);
|
|
|
|
HttpContext.Current.Response.Clear();
|
|
HttpContext.Current.Response.ClearContent();
|
|
HttpContext.Current.Response.ContentType = "application/octet-stream";
|
|
HttpContext.Current.Response.AppendHeader("Content-disposition", "attachment; filename=" + System.IO.Path.GetFileName(ruta));
|
|
HttpContext.Current.Response.AddHeader("Content-Length", archivo.Length.ToString());
|
|
HttpContext.Current.Response.TransmitFile(ruta);
|
|
HttpContext.Current.Response.Flush();
|
|
HttpContext.Current.Response.End();
|
|
|
|
archivo = new System.IO.FileInfo("");
|
|
}
|
|
} |