904 lines
No EOL
31 KiB
C#
904 lines
No EOL
31 KiB
C#
/*===========================================================================================================================
|
||
* Instituto Costarricense de Acueductos y Alcantarillados. - 2015
|
||
* Administración de la Seguridad
|
||
* Nombre de la Pantalla: frwUsuario.aspx
|
||
*
|
||
* Explicación de los contenidos del archivo
|
||
*===========================================================================================================================
|
||
* HISTORIAL
|
||
*
|
||
* PERSONA DIA – MES - AÑO DESCRIPCIÓN
|
||
* Esteban Gutierrez Rapso 20 – 04 - 2015 Se inicia con el diseño de la pagina
|
||
* …………………………………………………………
|
||
* …………………………………………………………
|
||
*===========================================================================================================================
|
||
* Derechos Reservados (C) 2015 AyA.
|
||
* ESTE CÓDIGO ES PROVEÍDO “TAL CUAL ES” SIN GARANTÍA ALGUNA
|
||
* DE NINGÚN TIPO, SEA IMPLICITA O EXPLICITA.
|
||
* NO SE PERMITE SU REPRODUCCIÓN PARCIAL O TOTAL, NI SU COMERCIALIZACIÓN
|
||
*===========================================================================================================================
|
||
*/
|
||
|
||
using System;
|
||
using System.Collections;
|
||
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 AyABL;
|
||
|
||
using AyABL.AUT.Autenticacion;
|
||
//using AyABL.APL;
|
||
using AyADAL;
|
||
using System.Configuration;
|
||
using AyABL.RCS;
|
||
|
||
using AyABL;
|
||
|
||
using AyABL.APL;
|
||
using AyABL.Usuario;
|
||
|
||
|
||
|
||
|
||
public partial class Forms_Mantenimiento_frwDependenciaSdaa : General
|
||
{
|
||
|
||
#region Inicializar Formulario (R0)
|
||
|
||
override protected void OnInit(EventArgs e) //M0
|
||
{
|
||
try
|
||
{
|
||
base.OnInit(e);
|
||
|
||
InicializarFormulario();
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
MensajeError("Error en R0M0", ex);
|
||
}
|
||
}
|
||
|
||
private void InicializarFormulario() //M1
|
||
{
|
||
try
|
||
{
|
||
Response.Cache.SetCacheability(HttpCacheability.NoCache);
|
||
|
||
construirGridView();
|
||
|
||
|
||
Javascript.CheckAllGridViewItems(Page);
|
||
|
||
cuwBusquedaList.Buscar += new _controlesusuario_Estandar_cuwBusquedaList.SearchEvent(Buscar);
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
MensajeError("Error en R0M1", ex);
|
||
}
|
||
}
|
||
|
||
#endregion
|
||
|
||
#region Variables (R1)
|
||
|
||
GridView grvListaDatosTemp, grvTemp;
|
||
|
||
dependenciasdaaBL objDependenciasdaaBL;
|
||
AutenticacionBL objAutenticacionBL;
|
||
UsuarioRolBL objUsuarioRolBL;
|
||
RolItemMenuComandoBL objRolItemMenuComandoBL;
|
||
|
||
|
||
dependenciaBL objDependenciaBL;
|
||
ArrayList arlCondicionesFiltroBusqueda = new ArrayList();
|
||
regionBL objRegionBL;
|
||
#endregion
|
||
|
||
#region Eventos Formulario (R2)
|
||
|
||
protected void Page_Load(object sender, EventArgs e) //M0
|
||
{
|
||
try
|
||
{
|
||
if ((!IsPostBack) && (Session.Count > 0))
|
||
{
|
||
llenarGridView(true);
|
||
mostrarFilaTabla(1);
|
||
llenarDDLregion();
|
||
llenarDDLdependencia();
|
||
ComandosxMenu();
|
||
}
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
MensajeError("Error en R2M0", ex);
|
||
}
|
||
}
|
||
|
||
#endregion
|
||
|
||
#region Eventos Controles Web (R3)
|
||
|
||
/// <summary>
|
||
/// Metodo que se utiliza para extraer información del registro de la base de datos y ser mostrado en el acordeon de Controles
|
||
/// </summary>
|
||
/// <param name="sender"></param>
|
||
/// <param name="e"></param>
|
||
|
||
protected void grvListaDatos_RowCommand(object sender, GridViewCommandEventArgs e) //M0
|
||
{
|
||
try
|
||
{
|
||
if (e.CommandName == "editar")
|
||
{
|
||
int i = Convert.ToInt32(e.CommandArgument);
|
||
GridViewRow selectedRow = grvListaDatos.Rows[i];
|
||
int intPk = Convert.ToInt32(selectedRow.Cells[2].Text);
|
||
ViewState["PkCantonal"] = intPk;
|
||
ViewState["MODO"] = "Modifica";
|
||
|
||
mostrarFilaTabla(2);
|
||
|
||
mostrarDatos(intPk);
|
||
|
||
}
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
MensajeError("Error en R3M0", ex);
|
||
}
|
||
}
|
||
|
||
|
||
|
||
|
||
/// <summary>
|
||
/// 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 grvListaDatos_PageIndexChanging(object sender, GridViewPageEventArgs e) //M3
|
||
{
|
||
try
|
||
{
|
||
grvListaDatos.PageIndex = e.NewPageIndex;
|
||
llenarGridView(true);
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
MensajeError("Error en R3M3", ex);
|
||
}
|
||
}
|
||
|
||
///<summary>
|
||
///Activar el botón de Refrescar
|
||
///</summary>
|
||
///<param name="sender"></param>
|
||
///<param name="e"></param>
|
||
|
||
protected void btnRefrescar_Click(object sender, System.Web.UI.ImageClickEventArgs e) //M4
|
||
{
|
||
try
|
||
{
|
||
llenarGridView(true);
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
MensajeError("Error en R3M4" + MensajesAplicacion.RefrescarFallido.ToString(), ex);
|
||
}
|
||
}
|
||
|
||
|
||
|
||
|
||
|
||
/// <summary>
|
||
/// Activa el evento del botón Buscar (binoculares)
|
||
/// </summary>
|
||
/// <param name="sender"></param>
|
||
/// <param name="e"></param>
|
||
protected void btnBuscar_Click(object sender, System.Web.UI.ImageClickEventArgs e) //M7
|
||
{
|
||
try
|
||
{
|
||
llenarGridView(true);
|
||
}
|
||
catch(Exception ex)
|
||
{
|
||
MensajeError("Error en R3M7" + MensajesAplicacion.UsuarioInexistente.ToString(), ex);
|
||
}
|
||
}
|
||
|
||
/// <summary>
|
||
/// Activa el evento del boton Nuevo
|
||
/// </summary>
|
||
/// <param name="sender"></param>
|
||
/// <param name="e"></param>
|
||
|
||
protected void btnNuevo_Click(object sender, EventArgs e) //M8
|
||
{
|
||
try
|
||
{
|
||
ViewState["MODO"] = "Nuevo";
|
||
mostrarFilaTabla(2);
|
||
//Limpia el grid de Active Directory
|
||
|
||
ddlRegion.Focus();
|
||
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
MensajeError("Error en R3M8" + MensajesAplicacion.GuardadoFallido.ToString(), ex);
|
||
}
|
||
}
|
||
|
||
/// <summary>
|
||
/// Metodo que activa el botón de Eliminar
|
||
/// </summary>
|
||
/// <param name="sender"></param>
|
||
/// <param name="e"></param>
|
||
|
||
protected void btnActivar_Click(object sender, EventArgs e) //M9
|
||
{
|
||
try
|
||
{
|
||
|
||
foreach (GridViewRow row in grvListaDatos.Rows)
|
||
{
|
||
HtmlInputCheckBox chkTemp = (HtmlInputCheckBox)row.Controls[0].Controls[1];
|
||
if (chkTemp != null)
|
||
{
|
||
// si el registro esta marcado
|
||
if (chkTemp.Checked)
|
||
{
|
||
int intPkEliminar = Convert.ToInt32(row.Cells[2].Text);
|
||
ActivarDesactivar(intPkEliminar);
|
||
MensajeInformativo(AyABL.BASESDEDATOS.ADS + "Interfaz: " + MensajesAplicacion.GuardadoExitoso.ToString());
|
||
}
|
||
}
|
||
}
|
||
llenarGridView(true);
|
||
|
||
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
MensajeError("Error en R3M9", ex);
|
||
}
|
||
|
||
|
||
}
|
||
|
||
/// <summary>
|
||
/// Activa el evento del ddlApp para cargar el listado de roles de la aplicación seleccionada
|
||
/// </summary>
|
||
/// <param name="sender"></param>
|
||
/// <param name="e"></param>
|
||
|
||
protected void ddlAplicacion_SelectedIndexChanged(object sender, EventArgs e) //M10
|
||
{
|
||
try
|
||
{
|
||
llenarDDLregion();
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
MensajeError("Error en R3M10", ex);
|
||
}
|
||
|
||
}
|
||
|
||
///<summary>
|
||
///Activa el metodo del boton Anterior, regresa a la primera fila de la tabla
|
||
///</summary>
|
||
///<param name="sender"></param>
|
||
///<param name="e"></param>
|
||
|
||
protected void btnAnterior_Click(object sender, EventArgs e) //M12
|
||
{
|
||
try
|
||
{
|
||
llenarGridView(true);
|
||
divDatosSuperiores.Visible = true;
|
||
divDatosMedios.Visible = false;
|
||
|
||
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
MensajeError("Error en R3M12", ex);
|
||
}
|
||
}
|
||
|
||
|
||
/// <summary>
|
||
/// Activa el evento del boton guardar.1
|
||
/// </summary>
|
||
/// <param name="sender"></param>
|
||
/// <param name="e"></param>
|
||
|
||
protected void btnGuardar_Click(object sender, EventArgs e) //M14
|
||
{
|
||
try
|
||
{
|
||
if (ddlRegion.SelectedValue != "-1" && ddlDependencia.SelectedValue != "-1" )
|
||
{
|
||
int pkRegistro = GuardarDatos();
|
||
llenarGridView(true);
|
||
mostrarFilaTabla(1);
|
||
llenarDDLregion();
|
||
llenarDDLdependencia();
|
||
MensajeInformativo(AyABL.BASESDEDATOS.ADS + "Interfaz: " + MensajesAplicacion.GuardadoExitoso.ToString());
|
||
}
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
MensajeError("Error en R3M14", ex);
|
||
}
|
||
}
|
||
|
||
|
||
#endregion
|
||
|
||
#region Metodos Personalizados (R4)
|
||
|
||
/// <summary>
|
||
/// Oculta las filas que lo requieran
|
||
/// </summary>
|
||
/// <param name="p_intFila"></param>
|
||
private void mostrarFilaTabla(int p_intFila) //M0
|
||
{
|
||
try
|
||
{
|
||
divDatosSuperiores.Visible = false;
|
||
divDatosMedios.Visible = false;
|
||
|
||
|
||
switch (p_intFila)
|
||
{
|
||
case 1:
|
||
llenarGridView(true);
|
||
divDatosSuperiores.Visible = true;
|
||
break;
|
||
case 2:
|
||
llenarGridView(true);
|
||
divDatosMedios.Visible = true;
|
||
break;
|
||
case 3:
|
||
llenarGridView(true);
|
||
|
||
break;
|
||
}
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
throw ex;
|
||
}
|
||
}
|
||
|
||
/// <summary>
|
||
/// Metodo que se utiliza para contruir el Grid al inicio de la pantalla
|
||
/// </summary>
|
||
private void construirGridView() //M1
|
||
{
|
||
try
|
||
{
|
||
grvListaDatosTemp = (GridView)tdLista.FindControl("grvListaDatos");
|
||
|
||
GridViewBoundField bdfPkProyecto = new GridViewBoundField("PKDEPENDENCIASIGDD", "PK", false, false, false);
|
||
GridViewBoundField bdfDescripcion = new GridViewBoundField("DESCRIPCIONREGION", "Region", true, false, true);
|
||
GridViewBoundField bdfNombreRegion = new GridViewBoundField("NOMBREDEPENDENCIA", "Dependencia", true, false, true);
|
||
GridViewBoundField bdfActivo = new GridViewBoundField("ASTATEDEPENDENCIASIGDD", "Activo", true, "Si", "No", true);
|
||
|
||
grvListaDatosTemp.Columns.Add(bdfPkProyecto);
|
||
grvListaDatosTemp.Columns.Add(bdfDescripcion);
|
||
grvListaDatosTemp.Columns.Add(bdfNombreRegion);
|
||
|
||
grvListaDatosTemp.Columns.Add(bdfActivo);
|
||
|
||
grvListaDatosTemp.Columns[0].ItemStyle.Width = 25;
|
||
grvListaDatosTemp.Columns[1].ItemStyle.Width = 25;
|
||
|
||
cuwBusquedaList.LlenarCHKLBusqueda(grvListaDatosTemp);
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
throw ex;
|
||
}
|
||
}
|
||
|
||
|
||
////<summary>
|
||
////Metodo que se utiliza para cargar la normativa de Control Internos con cada una de las normas, según el componente.
|
||
////</summary>
|
||
////<param name="p_intPadre"></param>
|
||
////<param name="p_tndNode"></param>
|
||
////<param name="p_blnDependencia"></param>
|
||
|
||
//private void CargarArbolOrganizacional(int p_intPadre, TreeNode p_tndNode, bool p_blnDependencia)
|
||
//{
|
||
// try
|
||
// {
|
||
// tvwArbolOrganizacional.Nodes.Clear();
|
||
// objdependenciasdaaBL.objdependenciasdaaEL = null;
|
||
// if (p_blnDependencia == true)
|
||
// {
|
||
// objdependenciasdaaBL.objdependenciasdaaEL.PK = p_intPadre;
|
||
// objdependenciasdaaBL.objdependenciasdaaEL.Padre = 0;
|
||
// }
|
||
// else
|
||
// {
|
||
// objdependenciasdaaBL.objdependenciasdaaEL.PK = 0;
|
||
// objdependenciasdaaBL.objdependenciasdaaEL.Padre = p_intPadre;
|
||
// }
|
||
|
||
// condicionesBusqueda();
|
||
|
||
// DataSet dsDependenciaDS = new DataSet();
|
||
// dsDependenciaDS = objdependenciasdaaBL.listarDependenciaSdaa(arlCondicionesFiltroBusqueda,false);
|
||
|
||
// TreeNode zDependencia;
|
||
|
||
// TreeNode zRaiz = new TreeNode();
|
||
// zRaiz.Text = "Árbol Organizacional";
|
||
// zRaiz.Value = "-1";
|
||
// zRaiz.ShowCheckBox = false;
|
||
|
||
// if (dsDependenciaDS.Tables[0].Rows.Count > 0)
|
||
// {
|
||
// foreach (DataRow row in dsDependenciaDS.Tables[0].Rows)
|
||
// {
|
||
// if (p_tndNode == null)
|
||
// {
|
||
// zDependencia = new TreeNode();
|
||
// zDependencia.Text = row["NOMBREDEPENDENCIA"].ToString();
|
||
// zDependencia.Value = row["PKDEPENDENCIASIGDD"].ToString();
|
||
// zRaiz.ChildNodes.Add(zDependencia);
|
||
|
||
// CargarArbolOrganizacional((int)row["PKDEPENDENCIASIGDD"], zDependencia, false);
|
||
// }
|
||
// else
|
||
// {
|
||
// zDependencia = new TreeNode();
|
||
// zDependencia.Text = row["NOMBREDEPENDENCIA"].ToString();
|
||
// zDependencia.Value = row["PKDEPENDENCIASIGDD"].ToString();
|
||
// p_tndNode.ChildNodes.Add(zDependencia);
|
||
|
||
// CargarArbolOrganizacional((int)row["PKDEPENDENCIASIGDD"], zDependencia, false);
|
||
// }
|
||
// }
|
||
// }
|
||
// if (zRaiz.ChildNodes.Count > 0)
|
||
// tvwArbolOrganizacional.Nodes.Add(zRaiz);
|
||
// tvwArbolOrganizacional.ExpandAll();
|
||
|
||
// }
|
||
// catch (Exception ex)
|
||
// {
|
||
// throw ex;
|
||
// }
|
||
//}
|
||
|
||
|
||
/// <summary>
|
||
/// Metodo que se encarga de agregar el filtro de busqueda seleccionado por el usuario
|
||
/// </summary>
|
||
/// <returns></returns>
|
||
private void condicionesBusqueda() //M2
|
||
{
|
||
AyABL.AyABL objBL = new AyABL.AyABL();
|
||
CondicionDAL condicion;
|
||
DateTime dteFechaInicio = new DateTime();
|
||
DateTime dteFechaFin = new DateTime();
|
||
ListItem li = new ListItem();
|
||
string p_parametros;
|
||
p_parametros = this.cuwBusquedaList.getValorBusqueda();
|
||
try
|
||
{
|
||
if (p_parametros != "")
|
||
{
|
||
//aqui se construye el listItem con los datos que vienen del control en formato {valor : texto , valor : texto}
|
||
char[] separadorTuplas = { ',' };
|
||
char[] separadorValores = { ':' };
|
||
string[] arrayTupla = p_parametros.Split(separadorTuplas);
|
||
|
||
for (int i = 0; i <= (arrayTupla.Length - 1); i++)
|
||
{
|
||
if (arrayTupla[i].ToString() != "")
|
||
{
|
||
string[] arrayValores = arrayTupla[i].ToString().Split(separadorValores);
|
||
li = new ListItem(arrayValores[1], arrayValores[0]);
|
||
|
||
if (li.Value.Contains("FECHA") && li.Text != string.Empty)
|
||
{
|
||
|
||
if (li.Value.Contains("INICIO"))
|
||
{
|
||
dteFechaInicio = Convert.ToDateTime(li.Text.ToString());
|
||
dteFechaFin = DateTime.Now;
|
||
}
|
||
if (li.Value.Contains("FIN"))
|
||
{
|
||
dteFechaFin = Convert.ToDateTime(li.Text.ToString());
|
||
|
||
if (dteFechaFin != null || dteFechaInicio != null)
|
||
if (dteFechaInicio < dteFechaFin || dteFechaFin == dteFechaInicio)
|
||
{
|
||
objBL = new AyABL.AyABL();
|
||
arlCondicionesFiltroBusqueda = objBL.buscarPorFechas(Tablas.BITACORA, dteFechaInicio, dteFechaFin, operadorLogico.AND, arlCondicionesFiltroBusqueda);
|
||
}
|
||
else
|
||
MensajeInformativo(AyABL.BASESDEDATOS.ADS + "Interfaz: " + "Verifique que la Fecha de Inicio sea menor que la Fecha Final" + "M2");
|
||
else
|
||
MensajeInformativo(AyABL.BASESDEDATOS.ADS + "Interfaz: " + "Verifique que los campos de las fechas no estén vacíos" + "M2");
|
||
}
|
||
else
|
||
{
|
||
objBL = new AyABL.AyABL();
|
||
arlCondicionesFiltroBusqueda = objBL.buscarPorFechas(Tablas.BITACORA, dteFechaInicio, dteFechaFin, operadorLogico.AND, arlCondicionesFiltroBusqueda);
|
||
}
|
||
}
|
||
else
|
||
{
|
||
if (li.Value.Contains("booleano") && li.Text != "2")
|
||
{
|
||
condicion = new CondicionDAL();
|
||
char[] separadorColumna = { '|' };
|
||
string[] strColumna = li.Value.Split(separadorColumna);
|
||
condicion.valorIzquierdo = strColumna[1].ToString();
|
||
condicion.operadorGeneral = operadorGeneral.EQUAL;
|
||
condicion.operadorLogico = operadorLogico.AND;
|
||
condicion.valorDerecho = li.Text.Trim();
|
||
arlCondicionesFiltroBusqueda.Add(condicion);
|
||
}
|
||
else
|
||
{
|
||
if (li.Text != string.Empty && !li.Value.Contains("booleano"))
|
||
{
|
||
condicion = new CondicionDAL();
|
||
condicion.valorIzquierdo = li.Value;
|
||
condicion.operadorGeneral = operadorGeneral.LIKEALL;
|
||
condicion.operadorLogico = operadorLogico.AND;
|
||
condicion.valorDerecho = "%" + li.Text.Trim() + "%";
|
||
arlCondicionesFiltroBusqueda.Add(condicion);
|
||
}
|
||
}
|
||
}
|
||
|
||
}
|
||
}
|
||
}
|
||
|
||
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
throw ex;
|
||
}
|
||
|
||
|
||
}
|
||
|
||
/// <summary>
|
||
/// Metodo que se utiliza con el buscador de la parte superior de la pantalla, y hace que se despliegue la información de acuerdo
|
||
/// a lo solicitado
|
||
/// </summary>|
|
||
private void Buscar() //M4
|
||
{
|
||
try
|
||
{
|
||
llenarGridView(true);
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
throw ex;
|
||
}
|
||
}
|
||
|
||
|
||
|
||
/// <summary>
|
||
/// Metodo que se utiliza para el despliegue de los botones
|
||
/// </summary>
|
||
private void ComandosxMenu() //M6
|
||
{
|
||
try
|
||
{
|
||
DataSet dsComandos = getComandos();
|
||
|
||
if (dsComandos != null)
|
||
{
|
||
foreach (DataRow drTemp in dsComandos.Tables[0].Rows)
|
||
{
|
||
switch (drTemp["NOMBRECOMANDO"].ToString().ToUpper())
|
||
{
|
||
case "NUEVO":
|
||
btnNuevo.Visible = true;
|
||
|
||
btnActivar.Visible = true;
|
||
break;
|
||
|
||
case "MODIFICA":
|
||
//Inicio de variable tipo VIEWSTATE
|
||
ViewState["PUEDEMODIFICAR"] = true;
|
||
btnGuardar.Visible = true;
|
||
break;
|
||
}
|
||
}
|
||
}
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
throw ex;
|
||
}
|
||
}
|
||
|
||
/// <summary>
|
||
/// Limpia los campos
|
||
/// </summary>
|
||
private void limpiarCampos()
|
||
{
|
||
|
||
ddlRegion.SelectedValue = "-1";
|
||
ddlDependencia.SelectedValue = "-1";
|
||
}
|
||
|
||
|
||
#endregion
|
||
|
||
#region Metodos Controles a Datos (R5)
|
||
|
||
/// <summary>
|
||
/// guarda y modifica registros en la tabla.
|
||
/// </summary>
|
||
/// <returns></returns>
|
||
private int GuardarDatos() //M0
|
||
{
|
||
int nValorRetornado = 0;
|
||
|
||
try
|
||
{
|
||
|
||
string strModo = ViewState["MODO"].ToString();
|
||
|
||
objDependenciasdaaBL = new dependenciasdaaBL();
|
||
// objDependenciasdaaBL.objdependenciasdaaEL.CODCANTONAL = Int32.Parse(ddlRegion.SelectedValue);
|
||
objDependenciasdaaBL.objdependenciasdaaEL.FKREGION = Int32.Parse(ddlRegion.SelectedValue);
|
||
objDependenciasdaaBL.objdependenciasdaaEL.FKDEPENDENCIAADS = Int32.Parse(ddlDependencia.SelectedValue);
|
||
objDependenciasdaaBL.objdependenciasdaaEL.Activo = true;
|
||
|
||
|
||
if (strModo == "Nuevo")
|
||
{
|
||
nValorRetornado = objDependenciasdaaBL.insertarDependenciaSdaa();
|
||
|
||
|
||
GuardarEventoBitacora(
|
||
Session["LOGIN"].ToString(),
|
||
AccionBitacora.INSERT.ToString(),
|
||
MensajesBitacora.IngresarRegistro + ": Se ha ingresado la dependencia " + ddlDependencia.SelectedItem.Text.Trim(),
|
||
"frwDependenciaSdaa.aspx",
|
||
Convert.ToInt32(ConfigurationManager.AppSettings["pkApp"])
|
||
);
|
||
|
||
}
|
||
else if (strModo == "Modifica" && bool.Parse(ViewState["PUEDEMODIFICAR"].ToString()) == true)
|
||
{
|
||
objDependenciasdaaBL.objdependenciasdaaEL.PK = Convert.ToInt32(ViewState["PkCantonal"]);
|
||
nValorRetornado = objDependenciasdaaBL.modificarDependenciaSdaa();
|
||
GuardarEventoBitacora(
|
||
Session["LOGIN"].ToString(),
|
||
AccionBitacora.INSERT.ToString(),
|
||
MensajesBitacora.IngresarRegistro + ": Se ha modificado la dependencia " + ddlDependencia.SelectedItem.Text.Trim(),
|
||
"frwDependenciaSdaa.aspx",
|
||
Convert.ToInt32(ConfigurationManager.AppSettings["pkApp"])
|
||
);
|
||
}
|
||
}
|
||
|
||
|
||
catch (Exception ex)
|
||
{
|
||
throw ex;
|
||
}
|
||
return nValorRetornado;
|
||
}
|
||
|
||
|
||
/// <summary>
|
||
/// Activa o desactiva el usuario
|
||
/// </summary>
|
||
/// <returns></returns>
|
||
|
||
private bool ActivarDesactivar(int p_intPkEliminar) //M2
|
||
{
|
||
bool blnValorRetornado = false;
|
||
bool blnActivo = false;
|
||
try
|
||
{
|
||
objDependenciasdaaBL = new dependenciasdaaBL();
|
||
objDependenciasdaaBL.objdependenciasdaaEL.PK = p_intPkEliminar;
|
||
DataSet dsDependenciaSdaaDS = objDependenciasdaaBL.listarDependenciaSdaa(null, false);
|
||
|
||
//Verifica que el usuario se encuentre en la BD
|
||
if (dsDependenciaSdaaDS.Tables[0].Rows.Count != 0)
|
||
{
|
||
//Si esta activado que lo desactive
|
||
if (Convert.ToBoolean(dsDependenciaSdaaDS.Tables[0].Rows[0][Concepto.ASTATE.ToString() + Tablas.dependenciasigdd.ToString()]))
|
||
blnActivo = false;
|
||
//Si esta desactivado que lo active
|
||
else
|
||
blnActivo = true;
|
||
|
||
objDependenciasdaaBL.objdependenciasdaaEL.Activo = blnActivo;
|
||
objDependenciasdaaBL.objdependenciasdaaEL.FKREGION = (int) dsDependenciaSdaaDS.Tables[0].Rows[0][t_seg_dependenciasdaa.FKREGION.ToString() + Tablas.dependenciasigdd.ToString()];
|
||
objDependenciasdaaBL.objdependenciasdaaEL.FKDEPENDENCIAADS = (int)(dsDependenciaSdaaDS.Tables[0].Rows[0][t_seg_dependenciasdaa.FKDEPENDENCIAADS.ToString() + Tablas.dependenciasigdd.ToString()]);
|
||
|
||
|
||
|
||
|
||
|
||
objDependenciasdaaBL.modificarDependenciaSdaa();
|
||
}
|
||
GuardarEventoBitacora(
|
||
Session["LOGIN"].ToString(),
|
||
AccionBitacora.INSERT.ToString(),
|
||
MensajesBitacora.ModificarRegistro + ": Se ha puesto el registro de la PK=" + p_intPkEliminar + " en " + blnActivo,
|
||
"frwDependenciaSdaa.aspx",
|
||
Convert.ToInt32(ConfigurationManager.AppSettings["pkApp"])
|
||
);
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
throw ex;
|
||
}
|
||
return blnValorRetornado;
|
||
}
|
||
|
||
|
||
|
||
|
||
#endregion
|
||
|
||
#region Metodos Datos a Controles (R6)
|
||
/// <summary>
|
||
/// Carga el grid principal
|
||
/// </summary>
|
||
/// <param name="p_Llenar"></param>
|
||
private void llenarGridView(bool p_Llenar) //M0
|
||
{
|
||
try
|
||
{
|
||
if (!IsPostBack || p_Llenar)
|
||
{
|
||
condicionesBusqueda();
|
||
|
||
DataSet ds = objDependenciasdaaBL.dsListaDependenciaSdaa(arlCondicionesFiltroBusqueda);
|
||
General.detalleGridView(ds, grvListaDatosTemp, lblTotalDatos);
|
||
}
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
throw ex;
|
||
}
|
||
}
|
||
|
||
/// <summary>
|
||
/// Muestra los datos del registro
|
||
/// </summary>
|
||
/// <param name="p_intPkConsultar"></param>
|
||
private void mostrarDatos(int p_intPkConsultar) //M1
|
||
{
|
||
try
|
||
{
|
||
|
||
|
||
objDependenciasdaaBL = new dependenciasdaaBL();
|
||
objDependenciasdaaBL.objdependenciasdaaEL.PK = p_intPkConsultar;
|
||
DataSet ds = objDependenciasdaaBL.dsListaDependenciaSdaa(null);
|
||
|
||
|
||
|
||
if (ds.Tables[0].Rows.Count > 0)
|
||
{
|
||
//Información de la cantonal
|
||
ddlRegion.SelectedValue = ds.Tables[0].Rows[0]["FKREGIONDEPENDENCIASIGDD"].ToString();
|
||
ddlDependencia.SelectedValue = ds.Tables[0].Rows[0]["FKDEPENDENCIAADSDEPENDENCIASIGDD"].ToString();
|
||
|
||
|
||
|
||
|
||
}
|
||
else
|
||
{
|
||
|
||
}
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
throw ex;
|
||
}
|
||
}
|
||
|
||
|
||
|
||
/// <summary>
|
||
/// Llena el dropdownlist de Cantonales según la aplicación
|
||
/// </summary>
|
||
private void llenarDDLregion() //M2
|
||
{
|
||
try
|
||
{
|
||
//Limpia el control
|
||
ddlRegion.Items.Clear();
|
||
//Instancia el bjeto
|
||
objRegionBL = new regionBL();
|
||
//Asigna datos al atributo
|
||
|
||
objRegionBL.objregionEL.PK = 0;
|
||
objRegionBL.objregionEL.Descripcion = "";
|
||
//Carga la información en un dataset
|
||
DataSet dsRegion = objRegionBL.dsListaRegiones(arlCondicionesFiltroBusqueda);
|
||
if (dsRegion.Tables[0].Rows.Count != 0)
|
||
{
|
||
ddlRegion.DataSource = dsRegion;
|
||
ddlRegion.DataTextField = dsRegion.Tables[0].Columns["DESCRIPCIONREGION"].ColumnName;
|
||
ddlRegion.DataValueField = dsRegion.Tables[0].Columns["PKREGION"].ColumnName;
|
||
ddlRegion.DataBind();
|
||
|
||
|
||
ddlRegion.Items.Insert(0, new ListItem("Seleccione", "-1"));
|
||
}
|
||
else
|
||
ddlRegion.Items.Insert(0, new ListItem("----- No existen regiones -----", "-1"));
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
throw ex;
|
||
}
|
||
}
|
||
|
||
/// <summary>
|
||
/// Llena el dropdownlist de Cantonales según la aplicación
|
||
/// </summary>
|
||
private void llenarDDLdependencia() //M3
|
||
{
|
||
try
|
||
{
|
||
//Limpia el control
|
||
ddlDependencia.Items.Clear();
|
||
//Instancia el bjeto
|
||
objDependenciaBL = new dependenciaBL();
|
||
|
||
//Carga la información en un dataset
|
||
DataSet dsDependencia = objDependenciaBL.dsListaDependencia(arlCondicionesFiltroBusqueda);
|
||
if (dsDependencia.Tables[0].Rows.Count != 0)
|
||
{
|
||
ddlDependencia.DataSource = dsDependencia;
|
||
ddlDependencia.DataTextField = dsDependencia.Tables[0].Columns["NOMBREDEPENDENCIA"].ColumnName;
|
||
ddlDependencia.DataValueField = dsDependencia.Tables[0].Columns["PKDEPENDENCIA"].ColumnName;
|
||
ddlDependencia.DataBind();
|
||
|
||
ddlDependencia.Items.Insert(0, new ListItem("Seleccione", "-1"));
|
||
}
|
||
else
|
||
ddlDependencia.Items.Insert(0, new ListItem("----- No existen dependencias -----", "-1"));
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
throw ex;
|
||
}
|
||
}
|
||
|
||
|
||
|
||
#endregion
|
||
|
||
} |