198 lines
7.4 KiB
C#
198 lines
7.4 KiB
C#
using BASEBL; // Para usar a enumsBL
|
|
using System;
|
|
using System.IO;
|
|
using System.Web;
|
|
using System.Text;
|
|
using System.Data;
|
|
using System.Linq;
|
|
using System.Web.UI;
|
|
using System.Xml.Linq;
|
|
using System.Diagnostics;
|
|
using System.Collections;
|
|
using AjaxControlToolkit;
|
|
using System.Configuration;
|
|
using System.Web.UI.WebControls;
|
|
using System.Web.UI.HtmlControls;
|
|
using System.Web.UI.WebControls.WebParts;
|
|
|
|
|
|
public partial class _controlesusuario_cuwGridDocumento : System.Web.UI.UserControl
|
|
{
|
|
#region Variables
|
|
Documento dtDocumento = new Documento();
|
|
public static ArrayList ImageList;
|
|
General dtGeneral = new General();
|
|
#endregion
|
|
|
|
#region Eventos Formulario
|
|
|
|
protected void Page_Load(object sender, EventArgs e)
|
|
{
|
|
try
|
|
{
|
|
Session["GUARDADOCUMENTO"] = String.Empty; //variable es usada en algunas pantallas para carga de documento, ésto para que cargen bien
|
|
//el tab que contengan combos ya que la carga de combos es por cascada
|
|
lblMensage.Text = String.Empty;
|
|
lblTotalDocumento.Text = String.Empty; //informa el total de documentos contenido en el grid ejemplo: Viendo Datos del 1 al 10
|
|
txtDescripcionDocumento.Text = String.Empty;
|
|
txtNombreDeseadoAchivo.Text = String.Empty;
|
|
txtURL.Text = String.Empty;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw ex;
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region Eventos Controles Web
|
|
|
|
/// Metodo que se utiliza para la paginación del Grid en caso de que el usuario desee ver mas registros
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void grvDocumento_PageIndexChanging(object sender, GridViewPageEventArgs e)
|
|
{
|
|
try
|
|
{
|
|
grvDocumento.DataBind();
|
|
grvDocumento.PageIndex = e.NewPageIndex;
|
|
dtDocumento.LlenarGridView_Documento(lblTotalDocumento, grvDocumento, Session["LLAVE"].ToString(), GlobalBL.InstanciaGlobalBL().strValorLlave);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
//cuwMensajeAviso.showError(Resources.MensajesAplicacion.ErrorWebServiceVision2020, ex);
|
|
}
|
|
}
|
|
|
|
/// Metodo que extrae de la base de datos el documento y lo coloca en un directorio temporal y mostrar el archivo en el wrowser
|
|
/// </summary>
|
|
protected void hypArchivo_Click(object sender, EventArgs e)
|
|
{
|
|
Documento dtDocumento = new Documento();
|
|
try
|
|
{
|
|
GridViewRow grdrow = (GridViewRow)((LinkButton)sender).NamingContainer;
|
|
Label txtIdCarpeta = (Label)grdrow.FindControl("txtIDCarpeta");
|
|
Label txtIdObjeto = (Label)grdrow.FindControl("txtIDObjeto");
|
|
|
|
//Process.Start(dtDocumento.strURLArchivo(txtIdCarpeta.Text, txtIdObjeto.Text));
|
|
Response.Redirect(dtDocumento.strURLArchivo(txtIdCarpeta.Text, txtIdObjeto.Text), true);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
//cuwMensajeAviso.showError(Resources.MensajesError.AYAEM000, ex);
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// actualiza el grid al finalizar el popup
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void btnFinalizar_Click(object sender, ImageClickEventArgs e)
|
|
{
|
|
grvDocumento.DataBind();
|
|
dtDocumento.LlenarGridView_Documento(lblTotalDocumento, grvDocumento, Session["LLAVE"].ToString(), GlobalBL.InstanciaGlobalBL().strValorLlave);
|
|
}
|
|
#endregion
|
|
|
|
#region Métodos Personalizados
|
|
|
|
/// <summary>
|
|
/// carga el grid de documentos
|
|
/// </summary>
|
|
/// <param name="blControl"></param>
|
|
public void cargaDatos(Boolean blControl)
|
|
{
|
|
try
|
|
{
|
|
grvDocumento.DataBind();
|
|
grvDocumento.DataSource = null;
|
|
|
|
btnNuevoDocumento.Visible = blControl; //activa o desactiva el boton nuevo documento en base al rol del usuario
|
|
pnlDocumento.Visible = blControl;
|
|
|
|
this.grvDocumento.Columns[4].Visible = Convert.ToBoolean(ConfigurationManager.AppSettings["MuestraValorOculto"].ToString());
|
|
this.grvDocumento.Columns[3].Visible = Convert.ToBoolean(ConfigurationManager.AppSettings["MuestraValorOculto"].ToString());
|
|
|
|
if (dtDocumento.LlenarGridView_Documento(lblTotalDocumento, grvDocumento, Session["LLAVE"].ToString(), GlobalBL.InstanciaGlobalBL().strValorLlave))
|
|
{
|
|
GlobalBL.InstanciaGlobalBL().sErrorErrorWebServiceVision2020 = "";
|
|
btnNuevoDocumento.Visible = true;
|
|
pnlDocumento.Visible = false;
|
|
}
|
|
else
|
|
{
|
|
GlobalBL.InstanciaGlobalBL().sCantidadRegistros = "Documentos(0)";
|
|
GlobalBL.InstanciaGlobalBL().sErrorErrorWebServiceVision2020 = "Error";
|
|
btnNuevoDocumento.Visible = false;
|
|
pnlDocumento.Visible = false;
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
GlobalBL.InstanciaGlobalBL().sCantidadRegistros = "Documentos(0)";
|
|
GlobalBL.InstanciaGlobalBL().sErrorErrorWebServiceVision2020 = "Error";
|
|
btnNuevoDocumento.Visible = false;
|
|
pnlDocumento.Visible = false;
|
|
throw ex;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Verifica si existe conexion con vision2020, para que cargue los datos y muestre en el tab la cantidad de registros obtenidos
|
|
/// </summary>
|
|
/// <param name="strValorLlave">los valores de la llave</param>
|
|
/// <param name="strLlave">estructura de la llave</param>
|
|
/// <returns></returns>
|
|
public bool LlenarGridView_Documento(String strValorLlave, string strLlave)
|
|
{
|
|
DataSet ListaArchivosDS = new DataSet();
|
|
grvDocumento.DataBind();
|
|
|
|
try
|
|
{
|
|
if(dtDocumento.LlenarGridView_Documento(lblTotalDocumento, grvDocumento, strLlave, strValorLlave))
|
|
{
|
|
GlobalBL.InstanciaGlobalBL().sErrorErrorWebServiceVision2020 = "";
|
|
return true;
|
|
}
|
|
else
|
|
{
|
|
GlobalBL.InstanciaGlobalBL().sCantidadRegistros = "Documentos(0)";
|
|
lblTotalDocumento.Text = "0 Registros encontrados";
|
|
GlobalBL.InstanciaGlobalBL().sErrorErrorWebServiceVision2020 = "Error";
|
|
return false;
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
return false; // no se logró conectar al web Service
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// guarda los documentos en el server
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
public void Guardar_Documento(object sender, AjaxControlToolkit.AsyncFileUploadEventArgs e)
|
|
{
|
|
try
|
|
{
|
|
dtDocumento.GuardarDatos_Documento(Session["ETIQUETACARPETA"].ToString(), txtNombreDeseadoAchivo, txtDescripcionDocumento, txtURL, afuArchivo, GlobalBL.LLAVE, GlobalBL.InstanciaGlobalBL().strValorLlave);
|
|
Session["GUARDADOCUMENTO"] = "GUARDADOCUMENTO";
|
|
|
|
|
|
GlobalBL.InstanciaGlobalBL().sCantidadRegistros = "Documentos" + "(" +( Convert.ToInt32(Session["CANTIDAD"].ToString()) + 1 )+ ")";
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
//cuwMensajeAviso.showError(Resources.MensajesError.AYAEM001, ex);
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
}
|