1094 lines
No EOL
39 KiB
C#
1094 lines
No EOL
39 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
|
||
* Rubén Vargas González 22 – 03 - 2017 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 AyADAL;
|
||
using System.Configuration;
|
||
using AyABL.RCS;
|
||
using AyABL;
|
||
using AyABL.Tran;
|
||
using AyABL.APL;
|
||
using AyABL.Tran;
|
||
using AyABL.Usuario;
|
||
|
||
|
||
public partial class Forms_Mantenimiento_frwCaudal : 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 grvListaDatosCaudalTemp, grvCantonalesADTemp;
|
||
|
||
proyectoBL objProyectoBL;
|
||
caudalBL objCaudalBL;
|
||
UsuarioBL objUsuarioBL;
|
||
|
||
ArrayList arlCondicionesFiltroBusqueda = new ArrayList();
|
||
|
||
#endregion
|
||
|
||
#region Eventos Formulario (R2)
|
||
|
||
protected void Page_Load(object sender, EventArgs e) //M0
|
||
{
|
||
try
|
||
{
|
||
if ((!IsPostBack) && (Session.Count > 0))
|
||
{
|
||
llenarGridView(true);
|
||
mostrarFilaTabla(1);
|
||
llenarTipoProyecto();
|
||
llenarDDLtipoInspeccion();
|
||
llenarDDLregion();
|
||
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 grvListaDatosCaudal_RowCommand(object sender, GridViewCommandEventArgs e) //M0
|
||
{
|
||
try
|
||
{
|
||
if (e.CommandName == "editar")
|
||
{
|
||
int i = Convert.ToInt32(e.CommandArgument);
|
||
GridViewRow selectedRow = grvListaDatosCaudal.Rows[i];
|
||
int intPKCaudal = Convert.ToInt32(selectedRow.Cells[2].Text);
|
||
ViewState["PKCaudal"] = intPKCaudal;
|
||
ViewState["MODO"] = "Modifica";
|
||
|
||
mostrarFilaTabla(2);
|
||
llenarTipoProyecto();
|
||
llenarDDLtipoInspeccion();
|
||
llenarDDLregion();
|
||
mostrarDatos(intPKCaudal);
|
||
llenarGridViewCaudalRegion(true);
|
||
ddlTipoInspeccion.Enabled = false;
|
||
ddlTipoProyecto.Enabled = false;
|
||
}
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
MensajeError("Error en R3M0", ex);
|
||
}
|
||
}
|
||
|
||
protected void grvListaCaudalRegion_PageIndexChanging(object sender, GridViewPageEventArgs e)
|
||
{
|
||
try
|
||
{
|
||
grvListaCaudalRegion.PageIndex = e.NewPageIndex;
|
||
llenarGridViewCaudalRegion(true);
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
MensajeError("Error en R3M3", 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 grvListaDatosCaudal_PageIndexChanging(object sender, GridViewPageEventArgs e) //M3
|
||
{
|
||
try
|
||
{
|
||
grvListaDatosCaudal.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);
|
||
limpiarCampos();
|
||
ddlTipoInspeccion.Enabled = true;
|
||
ddlTipoProyecto.Enabled = true;
|
||
ViewState["PKCaudal"] = null;
|
||
ViewState["PKCaudalRegion"] = null;
|
||
//Limpia el grid de Active Directory
|
||
|
||
//txtDescripcion.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 grvListaDatosCaudal.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 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 (txtDescripcion.Text != "" && txtDocSoporte.Text != "" && ddlTipoInspeccion.SelectedValue != "-1")
|
||
if (ddlTipoProyecto.SelectedValue != "-1" && txtDotación.Text != "" && txtFachacinamiento.Text != "" && txtIanc.Text != "" && ddlTipoInspeccion.SelectedValue != "-1")
|
||
{
|
||
int PKCaudal = GuardarDatos();
|
||
llenarGridView(true);
|
||
llenarGridViewCaudalRegion(true);
|
||
//mostrarFilaTabla(1);
|
||
|
||
MensajeInformativo(AyABL.BASESDEDATOS.ADS + "Interfaz: " + MensajesAplicacion.GuardadoExitoso.ToString());
|
||
}
|
||
else
|
||
{
|
||
//MensajeAlerta(AyABL.BASESDEDATOS.ADS + "Interfaz: " + MensajesAplicacion.GuardadoFallido.ToString());
|
||
}
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
MensajeError("Error en R3M14", ex);
|
||
}
|
||
}
|
||
|
||
protected void ddlTipoProyecto_SelectedIndexChanged(object sender, EventArgs e)//M12
|
||
{
|
||
try
|
||
{
|
||
|
||
llenarTipoProyecto();
|
||
div1.Visible = true;
|
||
|
||
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
MensajeError("Error en R3M12", ex);
|
||
}
|
||
}
|
||
|
||
//private void ddlTipoInspeccion_SelectedIndexChanged(object sender, EventArgs e)
|
||
//{
|
||
// div1.Visible = false;
|
||
// div2.Visible = false;
|
||
|
||
// if(ddlTipoInspeccion.SelectedValue !="1")
|
||
// {
|
||
// div1.Visible = false;
|
||
// div2.Visible = false;
|
||
|
||
// }
|
||
// else
|
||
// {
|
||
// div1.Visible = true;
|
||
// div2.Visible = true;
|
||
// }
|
||
|
||
// if(ddlTipoInspeccion.SelectedValue !="2")
|
||
// {
|
||
// div1.Visible = false;
|
||
// div2.Visible = false;
|
||
|
||
// }
|
||
// else
|
||
// {
|
||
// div1.Visible = false;
|
||
// div2.Visible = false;
|
||
// }
|
||
//}
|
||
|
||
protected void llenarDDLtipoInspeccion_SelectedIndexChanged(object sender, EventArgs e) //M5
|
||
{
|
||
//div1.Visible = false;
|
||
//div2.Visible = false;
|
||
|
||
if (ddlTipoInspeccion.SelectedValue != "1")
|
||
{
|
||
//div1.Visible = false;
|
||
txtIanc.Enabled = false;
|
||
|
||
|
||
}
|
||
else
|
||
{
|
||
//div1.Visible = true;
|
||
txtIanc.Enabled = true;
|
||
limpiarCampos();
|
||
}
|
||
|
||
if (ddlTipoInspeccion.SelectedValue != "2")
|
||
{
|
||
//div1.Visible = true;
|
||
txtIanc.Enabled = true;
|
||
|
||
limpiarCampos();
|
||
}
|
||
else
|
||
{
|
||
|
||
txtIanc.Text = "0";
|
||
//div1.Visible = false;
|
||
txtIanc.Enabled = true;
|
||
|
||
|
||
}
|
||
llenarGridViewCaudalRegion(true);
|
||
}
|
||
|
||
#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
|
||
{
|
||
grvListaDatosCaudalTemp = (GridView)tdLista.FindControl("grvListaDatosCaudal");
|
||
|
||
GridViewBoundField bdfPkCaudal = new GridViewBoundField("PKCAUDAL", "PK", false, false, false);
|
||
GridViewBoundField bdfDESCRIPCION = new GridViewBoundField("DESCRIPCIONPROYECTO", "Propósito del desarrollo", true, false, true);
|
||
GridViewBoundField bdfDESCRIPCIONTIPOINSPECCION = new GridViewBoundField("DESCRIPCIONTIPOINSPECCION", "Tipo disponibilidad", true, false, true);
|
||
|
||
GridViewBoundField bdfActivo = new GridViewBoundField("ASTATECAUDAL", "Activo", true, "Si", "No", true);
|
||
|
||
grvListaDatosCaudalTemp.Columns.Add(bdfPkCaudal);
|
||
grvListaDatosCaudalTemp.Columns.Add(bdfDESCRIPCION);
|
||
grvListaDatosCaudalTemp.Columns.Add(bdfDESCRIPCIONTIPOINSPECCION);
|
||
|
||
grvListaDatosCaudalTemp.Columns.Add(bdfActivo);
|
||
|
||
//grvListaDatosCaudalTemp.Columns[0].ItemStyle.Width = 25;
|
||
//grvListaDatosCaudalTemp.Columns[1].ItemStyle.Width = 25;
|
||
//grvListaDatosCaudalTemp.Columns[2].ItemStyle.Width = 25;
|
||
//grvListaDatosCaudalTemp.Columns[3].ItemStyle.Width = 300;
|
||
//grvListaDatosCaudalTemp.Columns[4].ItemStyle.Width = 300;
|
||
//grvListaDatosCaudalTemp.Columns[5].ItemStyle.Width = 425;
|
||
//grvListaDatosCantonalesTemp.Columns[4].ItemStyle.Width = 25;
|
||
|
||
|
||
cuwBusquedaList.LlenarCHKLBusqueda(grvListaDatosCaudalTemp);
|
||
}
|
||
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;
|
||
|
||
|
||
break;
|
||
|
||
case "MODIFICA":
|
||
//Inicio de variable tipo VIEWSTATE
|
||
ViewState["PUEDEMODIFICAR"] = true;
|
||
btnGuardar.Visible = true;
|
||
btnActivar.Visible = true;
|
||
break;
|
||
}
|
||
}
|
||
}
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
throw ex;
|
||
}
|
||
}
|
||
|
||
|
||
/// <summary>
|
||
/// Limpia los campos
|
||
/// </summary>
|
||
private void limpiarCampos()
|
||
{
|
||
txtDotación.Text = string.Empty;
|
||
txtFachacinamiento.Text = string.Empty;
|
||
txtIanc.Text = string.Empty;
|
||
grvListaCaudalRegion.DataSource = null;
|
||
grvListaCaudalRegion.DataBind();
|
||
|
||
}
|
||
|
||
#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();
|
||
|
||
objCaudalBL = new caudalBL();
|
||
|
||
|
||
|
||
objCaudalBL.objcaudalEL.FKPROYECTO = Int32.Parse(ddlTipoProyecto.SelectedValue);
|
||
objCaudalBL.objcaudalEL.FKTIPOINSPECCION = Int32.Parse(ddlTipoInspeccion.SelectedValue);
|
||
objCaudalBL.objcaudalEL.Activo = true;
|
||
objCaudalBL.objcaudalEL.Fecha = DateTime.Now;
|
||
objCaudalBL.objcaudalEL.USUARIO = Session["LOGIN"].ToString();
|
||
|
||
|
||
if (strModo == "Nuevo")
|
||
{
|
||
|
||
nValorRetornado = objCaudalBL.insertarCaudal();
|
||
if (nValorRetornado > 0)
|
||
{
|
||
caudalregionBL objCaudalRegionBL = new caudalregionBL();
|
||
objCaudalRegionBL.objcaudalregionEL.DOTACION = decimal.Parse(txtDotación.Text);
|
||
objCaudalRegionBL.objcaudalregionEL.FACTORHACINAMIENTO = decimal.Parse(txtFachacinamiento.Text);
|
||
objCaudalRegionBL.objcaudalregionEL.IANC = decimal.Parse(txtIanc.Text);
|
||
objCaudalRegionBL.objcaudalregionEL.FKREGION = int.Parse(ddlRegion.SelectedValue);
|
||
objCaudalRegionBL.objcaudalregionEL.Fecha = DateTime.Now;
|
||
objCaudalRegionBL.objcaudalregionEL.FKCAUDAL = nValorRetornado;
|
||
objCaudalRegionBL.objcaudalregionEL.FKUSUARIOINGRESA = int.Parse(Session["PKUSUARIO"].ToString());
|
||
objCaudalRegionBL.objcaudalregionEL.Activo = true;
|
||
int pkCaudalRegion = objCaudalRegionBL.insertarCaudalRegion();
|
||
}
|
||
|
||
|
||
limpiarCampos();
|
||
GuardarEventoBitacora(
|
||
Session["LOGIN"].ToString(),
|
||
AccionBitacora.INSERT.ToString(),
|
||
MensajesBitacora.IngresarRegistro + ": Se ha ingresado el caudal para el tipo de proyecto " + ddlTipoProyecto.SelectedItem.Text.Trim() + ", tipo disponibilidad " + ddlTipoInspeccion.SelectedItem.Text.ToString() + ", región " + ddlRegion.SelectedItem.Text.ToString(),
|
||
"frwCaudal.aspx",
|
||
Convert.ToInt32(ConfigurationManager.AppSettings["pkApp"])
|
||
);
|
||
|
||
}
|
||
else if (strModo == "Modifica" && bool.Parse(ViewState["PUEDEMODIFICAR"].ToString()) == true)
|
||
{
|
||
if (ViewState["PKCaudal"] != null)
|
||
{
|
||
objCaudalBL.objcaudalEL.PK = Convert.ToInt32(ViewState["PKCaudal"]);
|
||
nValorRetornado = objCaudalBL.modificarCaudal();
|
||
|
||
caudalregionBL objCaudalRegionBL = new caudalregionBL();
|
||
|
||
objCaudalRegionBL.objcaudalregionEL.ASTATE = true;
|
||
objCaudalRegionBL.objcaudalregionEL.DOTACION = decimal.Parse(txtDotación.Text);
|
||
objCaudalRegionBL.objcaudalregionEL.FACTORHACINAMIENTO = decimal.Parse(txtFachacinamiento.Text);
|
||
objCaudalRegionBL.objcaudalregionEL.IANC = decimal.Parse(txtIanc.Text);
|
||
objCaudalRegionBL.objcaudalregionEL.FKREGION = int.Parse(ddlRegion.SelectedValue);
|
||
objCaudalRegionBL.objcaudalregionEL.Fecha = DateTime.Now;
|
||
objCaudalRegionBL.objcaudalregionEL.FKCAUDAL = Convert.ToInt32(ViewState["PKCaudal"]);
|
||
objCaudalRegionBL.objcaudalregionEL.FKUSUARIOINGRESA = int.Parse(Session["PKUSUARIO"].ToString());
|
||
objCaudalRegionBL.objcaudalregionEL.Activo = true;
|
||
|
||
if (ViewState["PKCaudalRegion"] != null)
|
||
objCaudalRegionBL.objcaudalregionEL.PK = Convert.ToInt32(ViewState["PKCaudalRegion"]);
|
||
|
||
|
||
|
||
int pkCaudalRegion = 0;
|
||
if (ViewState["PKCaudalRegion"] != null )
|
||
pkCaudalRegion = objCaudalRegionBL.modificarCaudalRegion();
|
||
else
|
||
pkCaudalRegion = objCaudalRegionBL.insertarCaudalRegion();
|
||
|
||
limpiarCampos();
|
||
GuardarEventoBitacora(
|
||
Session["LOGIN"].ToString(),
|
||
AccionBitacora.UPDATE.ToString(),
|
||
MensajesBitacora.ModificarRegistro + ": Se ha modificado el caudal para el tipo de proyecto " + ddlTipoProyecto.SelectedItem.Text.Trim() + ", tipo disponibilidad " + ddlTipoInspeccion.SelectedItem.Text.ToString() + ", región " + ddlRegion.SelectedItem.Text.ToString(),
|
||
"frwCaudal.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
|
||
{
|
||
objCaudalBL = new caudalBL();
|
||
objCaudalBL.objcaudalEL.PK = p_intPkEliminar;
|
||
DataSet dsCaudalDS = objCaudalBL.listarCaudal(null, false, null);
|
||
|
||
//Verifica que el usuario se encuentre en la BD
|
||
if (dsCaudalDS.Tables[0].Rows.Count != 0)
|
||
{
|
||
//Si esta activado que lo desactive
|
||
if (Convert.ToBoolean(dsCaudalDS.Tables[0].Rows[0][Concepto.ASTATE.ToString() + Tablas.caudal.ToString()]))
|
||
blnActivo = false;
|
||
//Si esta desactivado que lo active
|
||
else
|
||
blnActivo = true;
|
||
|
||
|
||
objCaudalBL.objcaudalEL.Activo = blnActivo;
|
||
objCaudalBL.objcaudalEL.Fecha = Convert.ToDateTime(dsCaudalDS.Tables[0].Rows[0][t_adm_caudal.FECHA.ToString() + Tablas.caudal.ToString()]);
|
||
objCaudalBL.objcaudalEL.USUARIO = dsCaudalDS.Tables[0].Rows[0][t_adm_caudal.USUARIO.ToString() + Tablas.caudal.ToString()].ToString();
|
||
objCaudalBL.objcaudalEL.FKPROYECTO = (int)dsCaudalDS.Tables[0].Rows[0][t_adm_caudal.FKPROYECTO.ToString()];
|
||
objCaudalBL.objcaudalEL.FKTIPOINSPECCION = (int)dsCaudalDS.Tables[0].Rows[0][t_adm_caudal.FKTIPOINSPECCION.ToString()];
|
||
|
||
objCaudalBL.modificarCaudal();
|
||
|
||
}
|
||
GuardarEventoBitacora(
|
||
Session["LOGIN"].ToString(),
|
||
AccionBitacora.INSERT.ToString(),
|
||
MensajesBitacora.ModificarRegistro + ": Se ha puesto el registro de la PK=" + p_intPkEliminar + " en " + blnActivo,
|
||
"frwCaudal.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)
|
||
{
|
||
arlCondicionesFiltroBusqueda = new ArrayList();
|
||
objCaudalBL = new caudalBL();
|
||
condicionesBusqueda();
|
||
|
||
DataSet dsCaudal = objCaudalBL.dsListaCaudal(arlCondicionesFiltroBusqueda);
|
||
General.detalleGridView(dsCaudal, grvListaDatosCaudal, lblTotalDatos);
|
||
}
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
throw ex;
|
||
}
|
||
}
|
||
|
||
/// <summary>
|
||
/// Carga el grid principal
|
||
/// </summary>
|
||
/// <param name="p_Llenar"></param>
|
||
private void llenarGridViewCaudalRegion(bool p_Llenar) //M0
|
||
{
|
||
try
|
||
{
|
||
if (!IsPostBack || p_Llenar)
|
||
{
|
||
arlCondicionesFiltroBusqueda = new ArrayList();
|
||
caudalregionBL objCaudalRegionBL = new caudalregionBL();
|
||
objCaudalRegionBL.objcaudalregionEL.FKCAUDAL = int.Parse(ViewState["PKCaudal"].ToString());
|
||
//objCaudalRegionBL.objcaudalregionEL.FKREGION = int.Parse(ddlRegion.SelectedValue.ToString());
|
||
DataSet dsCaudalRegion = objCaudalRegionBL.dsListaCaudalRegionAsignados(null);
|
||
|
||
if (dsCaudalRegion.Tables[0].Rows.Count > 0)
|
||
{
|
||
grvListaCaudalRegion.DataSource = dsCaudalRegion;
|
||
grvListaCaudalRegion.DataBind();
|
||
General.detalleGridView(dsCaudalRegion, grvListaCaudalRegion, null);
|
||
// mostrarFilaTabla(1);
|
||
}
|
||
}
|
||
}
|
||
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
|
||
{
|
||
|
||
|
||
objCaudalBL = new caudalBL();
|
||
objCaudalBL.objcaudalEL.PK = p_intPkConsultar;
|
||
DataSet dsCaudal = objCaudalBL.dsListaCaudal(null);
|
||
|
||
|
||
if (dsCaudal.Tables[0].Rows.Count > 0)
|
||
{
|
||
//Información de la cantonal
|
||
|
||
//txtDotación.Text = dsCaudal.Tables[0].Rows[0]["DOTACIONCAUDAL"].ToString();
|
||
|
||
//txtFachacinamiento.Text = dsCaudal.Tables[0].Rows[0]["FACTORHACINAMIENTOCAUDAL"].ToString();
|
||
|
||
//txtIancgam.Text = dsCaudal.Tables[0].Rows[0]["IANCGAMCAUDAL"].ToString();
|
||
|
||
ddlTipoProyecto.SelectedValue = dsCaudal.Tables[0].Rows[0]["PKPROYECTO"].ToString();
|
||
ddlTipoInspeccion.SelectedValue = dsCaudal.Tables[0].Rows[0]["PKTIPOINSPECCION"].ToString();
|
||
|
||
caudalregionBL objCaudalRegionBL = new caudalregionBL();
|
||
objCaudalRegionBL.objcaudalregionEL.FKCAUDAL = p_intPkConsultar;
|
||
objCaudalRegionBL.objcaudalregionEL.FKREGION = int.Parse(ddlRegion.SelectedValue);
|
||
objCaudalRegionBL.objcaudalregionEL.ASTATE = true;
|
||
|
||
|
||
DataSet dsCaudalRegion = objCaudalRegionBL.listarCaudalRegion(null, true);
|
||
if (dsCaudalRegion.Tables[0].Rows.Count > 0)
|
||
{
|
||
ViewState["PKCaudalRegion"] = dsCaudalRegion.Tables[0].Rows[0]["PKCAUDALREGION"].ToString();
|
||
txtDotación.Text = dsCaudalRegion.Tables[0].Rows[0]["DOTACIONCAUDALREGION"].ToString();
|
||
txtFachacinamiento.Text = dsCaudalRegion.Tables[0].Rows[0]["FACTORHACINAMIENTOCAUDALREGION"].ToString();
|
||
txtIanc.Text = dsCaudalRegion.Tables[0].Rows[0]["IANCCAUDALREGION"].ToString();
|
||
}
|
||
}
|
||
else
|
||
{
|
||
|
||
}
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
throw ex;
|
||
}
|
||
}
|
||
|
||
/// <summary>
|
||
/// Llena el dropdownlist de grado academico según la aplicación
|
||
/// </summary>
|
||
private void llenarTipoProyecto() //M1
|
||
{
|
||
try
|
||
{
|
||
//Limpia el control
|
||
ddlTipoProyecto.Items.Clear();
|
||
//Instancia el bjeto
|
||
proyectoBL objProyectoBL;
|
||
objProyectoBL = new proyectoBL();
|
||
//Asigna datos al atributo
|
||
|
||
|
||
//Carga la información en un dataset
|
||
|
||
|
||
DataSet dsProyectos = objProyectoBL.dsListaProyectos(null);
|
||
|
||
if (dsProyectos.Tables[0].Rows.Count != 0)
|
||
{
|
||
ddlTipoProyecto.DataSource = dsProyectos;
|
||
ddlTipoProyecto.DataTextField = dsProyectos.Tables[0].Columns["DESCRIPCIONPROYECTO"].ColumnName;
|
||
ddlTipoProyecto.DataValueField = dsProyectos.Tables[0].Columns["PKPROYECTO"].ColumnName;
|
||
ddlTipoProyecto.DataBind();
|
||
|
||
|
||
ddlTipoProyecto.Items.Insert(0, new ListItem("Seleccione", "-1"));
|
||
}
|
||
else
|
||
ddlTipoProyecto.Items.Insert(0, new ListItem("----- No existen opciones -----", "-1"));
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
throw ex;
|
||
}
|
||
}
|
||
|
||
/// <summary>
|
||
/// Llena el dropdownlist de grado academico según la aplicación
|
||
/// </summary>
|
||
private void llenarDDLtipoInspeccion() //M6
|
||
{
|
||
try
|
||
{
|
||
//Limpia el control
|
||
ddlTipoInspeccion.Items.Clear();
|
||
//Instancia el bjeto
|
||
objUsuarioBL = new UsuarioBL();
|
||
//Asigna datos al atributo
|
||
|
||
|
||
//Carga la información en un dataset
|
||
DataSet dsTipoInspeccion = objUsuarioBL.dsListaTipoDisponibilidad(null);
|
||
if (dsTipoInspeccion.Tables[0].Rows.Count != 0)
|
||
{
|
||
ddlTipoInspeccion.DataSource = dsTipoInspeccion;
|
||
ddlTipoInspeccion.DataTextField = dsTipoInspeccion.Tables[0].Columns["DESCRIPCIONTIPOINSPECCION"].ColumnName;
|
||
ddlTipoInspeccion.DataValueField = dsTipoInspeccion.Tables[0].Columns["PKTIPOINSPECCION"].ColumnName;
|
||
ddlTipoInspeccion.DataBind();
|
||
|
||
|
||
ddlTipoInspeccion.Items.Insert(0, new ListItem("Seleccione", "-1"));
|
||
}
|
||
else
|
||
ddlTipoInspeccion.Items.Insert(0, new ListItem("----- No existen opciones -----", "-1"));
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
throw ex;
|
||
}
|
||
}
|
||
private void llenarDDLregion() //M2
|
||
{
|
||
try
|
||
{
|
||
//Limpia el control
|
||
ddlRegion.Items.Clear();
|
||
//Instancia el bjeto
|
||
regionBL 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(null);
|
||
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();
|
||
|
||
|
||
}
|
||
else
|
||
ddlRegion.Items.Insert(0, new ListItem("----- Vacio -----", "-1"));
|
||
|
||
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
throw ex;
|
||
}
|
||
}
|
||
|
||
|
||
|
||
#endregion
|
||
|
||
|
||
|
||
|
||
protected void ddlRegion_SelectedIndexChanged(object sender, EventArgs e)
|
||
{
|
||
try
|
||
{
|
||
caudalregionBL objCaudalRegionBL = new caudalregionBL();
|
||
objCaudalRegionBL.objcaudalregionEL.FKCAUDAL = int.Parse(ViewState["PKCaudal"].ToString());
|
||
objCaudalRegionBL.objcaudalregionEL.FKREGION = int.Parse(ddlRegion.SelectedValue);
|
||
objCaudalRegionBL.objcaudalregionEL.ASTATE = true;
|
||
|
||
limpiarCampos();
|
||
DataSet dsCaudalRegion = objCaudalRegionBL.listarCaudalRegion(null, true);
|
||
if (dsCaudalRegion.Tables[0].Rows.Count > 0)
|
||
{
|
||
ViewState["PKCaudalRegion"] = dsCaudalRegion.Tables[0].Rows[0]["PKCAUDALREGION"].ToString();
|
||
txtDotación.Text = dsCaudalRegion.Tables[0].Rows[0]["DOTACIONCAUDALREGION"].ToString();
|
||
txtFachacinamiento.Text = dsCaudalRegion.Tables[0].Rows[0]["FACTORHACINAMIENTOCAUDALREGION"].ToString();
|
||
txtIanc.Text = dsCaudalRegion.Tables[0].Rows[0]["IANCCAUDALREGION"].ToString();
|
||
}
|
||
else
|
||
{
|
||
ViewState["PKCaudalRegion"] = null;
|
||
}
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
MensajeError("Se dio un problema al cargar los datos de la región seleccionada" , ex);
|
||
}
|
||
llenarGridViewCaudalRegion(true);
|
||
}
|
||
} |