TFS_ANTIGUO/SIGPC/ProyectoSIGPC/App_Code/General.cs
kledezma 7fdadc4709 KLB
git-tfs-id: [http://192.168.1.10:8080/tfs/AyA]$/SINORT;C519
2021-01-22 15:05:35 +00:00

230 lines
No EOL
7.1 KiB
C#

using System;
using System.Collections.Generic;
using System.Data;
using System.Web.UI.WebControls;
using System.Runtime;
using AyABL.APL;
using AyABL.BIT;
using AyAEM.ExceptionManagement.Exceptions;
using System.Diagnostics;
/// <summary>
/// Descripción breve de General
/// </summary>
public partial class General : System.Web.UI.Page
{
#region Variables
ItemMenuBL objItemMenuBL;
RolItemMenuComandoBL objRolItemMenuComandoBL;
#endregion
#region Metodos
/// <summary>
/// Muestra la cantidad de datos que tiene el gridview asi como cuales son los datos que estoy visualizando en este. Ej: 11 al 20 de 20 datos
/// </summary>
/// <param name="p_dsDatos"></param>
/// <param name="p_grvGridView"></param>
/// <param name="p_Label"></param>
public static void detalleGridView(DataSet p_dsDatos, GridView p_grvGridView, object p_objLabel)
{
try
{
p_grvGridView.ShowHeader = true;
p_grvGridView.DataSource = p_dsDatos;
p_grvGridView.DataBind();
string mensaje = "0 Registros encontrados";
if (p_dsDatos != null)
{
if (p_dsDatos.Tables[0].Rows.Count > 0)
{
mensaje = "Viendo datos del " + ((p_grvGridView.PageIndex * p_grvGridView.PageSize) + 1) + " al " + (p_grvGridView.Rows.Count + (p_grvGridView.PageIndex * p_grvGridView.PageSize)) + " de " + p_dsDatos.Tables[0].Rows.Count;
}
}
if (p_objLabel != null)
{
Label label = (Label)p_objLabel;
label.Text = mensaje;
}
}
catch (Exception ex)
{
throw ex;
}
}
/// <summary>
/// Carga el rol de acceso de la pagina
/// </summary>
/// <returns></returns>
public DataSet getComandos()
{
DataSet dsComandosMenu = new DataSet();
string strURL = string.Empty;
objItemMenuBL = new ItemMenuBL();
ViewState["PUEDEMODIFICAR"] = false;
if (Session["PKROL"] != null)
{
strURL = Request.Url.AbsoluteUri.Replace("http://" + Request.Url.Authority + Request.ApplicationPath.ToString(), "~/").ToString().Replace("//", "/");
objItemMenuBL.objItemMenuEL.URL = strURL.Substring(0, strURL.Length - 54);// +".aspx";
dsComandosMenu = objItemMenuBL.obtenerItemMenuRol(Convert.ToInt32(Session["PKROL"]));
if (dsComandosMenu.Tables[0].Rows.Count != 0)
{
ViewState["PkItemMenu"] = dsComandosMenu.Tables[0].Rows[0]["PKITEMMENU"];
}
}
return dsComandosMenu;
}
BitacoraBL objBitacora = null;
/// <summary>
/// Registrar el evento en bitacora
/// </summary>
/// <param name="intComando"></param>
/// <param name="intOpcionMenu"></param>
/// <param name="strDetalle"></param>
public void GuardarEventoBitacora(string p_strLogin, string p_strAccion, string p_strRegistro, string p_strNombrePagina, int p_intPkApp)
{
objBitacora = new BitacoraBL();
objBitacora.objBitacoraEL.Login = p_strLogin;
objBitacora.objBitacoraEL.Fecha = DateTime.Now;
objBitacora.objBitacoraEL.Accion = p_strAccion;
objBitacora.objBitacoraEL.Registro = p_strRegistro;
objBitacora.objBitacoraEL.Pagina = p_strNombrePagina;
objBitacora.objBitacoraEL.Aplicacion = p_intPkApp;
objBitacora.objBitacoraEL.DireccionIP = Request.UserHostAddress.ToString();
objBitacora.insertarBitacora();
}
/// <summary>
/// muestra un mensaje de error en la ventana y en caso de que se presente un error
/// guardar el mismo en el archivo de ErrorLog.txt
/// </summary>
/// <param name="p_strMensaje"></param>
/// <param name="ex"></param>
public void MensajeError(string p_strMensaje, Exception ex)
{
try
{
if (ex != null)
{
AyAException.Publish(ex, p_strMensaje);
System.Web.UI.ScriptManager.RegisterStartupScript(
this,
typeof(General),
ClientID,
"toastr.error('" + p_strMensaje + ". No se realizó la transacción. Error: " + ex.Message.ToString() + "<br /><br /><button type=button class=btn clear>OK</button>', 'Error : ',toastr.options ={timeOut: 0, extendedTimeOut: 0,closeButton: true})",
true);
}
else
{
System.Web.UI.ScriptManager.RegisterStartupScript(
this,
typeof(General),
ClientID,
"toastr.error('" + p_strMensaje + ". No se realizó la transacción. <br /><br /><button type=button class=btn clear>OK</button>', 'Error : ',toastr.options ={timeOut: 0, extendedTimeOut: 0,closeButton: true})",
true);
}
}
catch (Exception exm)
{
throw exm;
}
}
/// <summary>
/// muestra un mensaje de informacion en la ventana
/// </summary>
/// <param name="p_strMensaje"></param>
public void MensajeInformativo(string p_strMensaje)
{
try
{
System.Web.UI.ScriptManager.RegisterStartupScript(
this,
typeof(General),
ClientID,
"toastr.success('" + p_strMensaje + "', 'Información',toastr.options ={closeButton: true})",
true);
}
catch (Exception ex)
{
throw ex;
}
}
/// <summary>
/// muestra un mensaje de informacion en la ventana y en caso de que se desee mostrar un mensaje del sistema
/// guardar el mismo en el archivo de ErrorLog.txt
/// </summary>
/// <param name="p_strMensaje"></param>
public void MensajeAlerta(string p_strMensaje)
{
try
{
System.Web.UI.ScriptManager.RegisterStartupScript(
this,
typeof(General),
ClientID,
"toastr.warning('" + p_strMensaje + "', 'Información',toastr.options ={closeButton: true})",
true);
}
catch (Exception ex)
{
throw ex;
}
}
/// <summary>
/// muestra un mensaje de error en la ventana y en caso de que se presente un error
/// guardar el mismo en el archivo de ErrorLog.txt
/// </summary>
/// <param name="p_strMensaje"></param>
/// <param name="ex"></param>
public void EjecutarScript(string p_strScript)
{
try
{
System.Web.UI.ScriptManager.RegisterStartupScript(
this,
typeof(General),
ClientID,
p_strScript ,
true);
}
catch (Exception exm)
{
throw exm;
}
}
#endregion
}