405 lines
13 KiB
C#
405 lines
13 KiB
C#
|
|
/*===========================================================================================================================
|
|||
|
|
* Instituto Costarricense de Acueductos y Alcantarillados. - 2019
|
|||
|
|
* Formularios para Proyectos de Inversión
|
|||
|
|
* Nombre de la Pantalla: wfrProyectos.aspx
|
|||
|
|
*
|
|||
|
|
* Explicación de los contenidos del archivo
|
|||
|
|
*===========================================================================================================================
|
|||
|
|
* HISTORIAL
|
|||
|
|
*
|
|||
|
|
* PERSONA DIA – MES - AÑO DESCRIPCIÓN
|
|||
|
|
* Esteban Gutierrez Rapso 11 – 02 - 2019 Se inicia con el diseño de la pagina
|
|||
|
|
* …………………………………………………………
|
|||
|
|
* …………………………………………………………
|
|||
|
|
*===========================================================================================================================
|
|||
|
|
* Derechos Reservados (C) 2019 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.Data;
|
|||
|
|
using System.Web;
|
|||
|
|
using System.Web.UI;
|
|||
|
|
using System.Web.UI.WebControls;
|
|||
|
|
using System.Web.UI.HtmlControls;
|
|||
|
|
|
|||
|
|
using AyADAL;
|
|||
|
|
using AyABL.RCS;
|
|||
|
|
|
|||
|
|
using AyABL.ADM;
|
|||
|
|
using AyABL.AGP;
|
|||
|
|
|
|||
|
|
public partial class webforms_FOR_wfrProyectos : 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);
|
|||
|
|
|
|||
|
|
Buscar += new SearchEvent(this.Busqueda);
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
catch (Exception ex)
|
|||
|
|
{
|
|||
|
|
MensajeError("Error en R0M1", ex);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
#endregion
|
|||
|
|
|
|||
|
|
#region Variables (R1)
|
|||
|
|
|
|||
|
|
GridView grvListaDatosTemp;
|
|||
|
|
ArrayList arlCondicionesFiltroBusqueda = new ArrayList();
|
|||
|
|
|
|||
|
|
//Variables para realizar la busqueda
|
|||
|
|
public delegate void SearchEvent();
|
|||
|
|
public event SearchEvent Buscar;
|
|||
|
|
|
|||
|
|
ProyectoBL objProyectoBL;
|
|||
|
|
|
|||
|
|
#endregion
|
|||
|
|
|
|||
|
|
#region Eventos Formulario (R2)
|
|||
|
|
|
|||
|
|
protected void Page_Load(object sender, EventArgs e) //M0
|
|||
|
|
{
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
if (!IsPostBack)
|
|||
|
|
{
|
|||
|
|
ComandosxMenu();
|
|||
|
|
|
|||
|
|
Session["PKPROYECTO"] = null;
|
|||
|
|
Session["BPIP"] = null;
|
|||
|
|
Session["PROYECTO"] = null;
|
|||
|
|
Session["MODO"] = null;
|
|||
|
|
|
|||
|
|
llenarGridView();
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
catch (Exception ex)
|
|||
|
|
{
|
|||
|
|
MensajeError("Error en R2M0", ex);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
#endregion
|
|||
|
|
|
|||
|
|
#region Eventos Controles Web (R3)
|
|||
|
|
|
|||
|
|
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];
|
|||
|
|
|
|||
|
|
Session["PKPROYECTO"] = Convert.ToInt32(selectedRow.Cells[2].Text);
|
|||
|
|
Session["BPIP"] = selectedRow.Cells[3].Text;
|
|||
|
|
Session["PROYECTO"] = selectedRow.Cells[4].Text;
|
|||
|
|
|
|||
|
|
Session["MODO"] = "Modifica";
|
|||
|
|
|
|||
|
|
Response.Redirect("wfrAspectosGenerales.aspx");
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
catch (Exception ex)
|
|||
|
|
{
|
|||
|
|
MensajeError("Error en R3M0", ex);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
protected void grvListaDatos_PageIndexChanging(object sender, GridViewPageEventArgs e) //M1
|
|||
|
|
{
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
grvListaDatos.PageIndex = e.NewPageIndex;
|
|||
|
|
llenarGridView();
|
|||
|
|
}
|
|||
|
|
catch (Exception ex)
|
|||
|
|
{
|
|||
|
|
MensajeError("Error R3M1", ex);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
protected void btnBusqueda_Click(object sender, ImageClickEventArgs e) //M2
|
|||
|
|
{
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
Buscar();
|
|||
|
|
}
|
|||
|
|
catch (Exception ex)
|
|||
|
|
{
|
|||
|
|
throw ex;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
protected void btnRefrescar_Click(object sender, System.Web.UI.ImageClickEventArgs e) //M3
|
|||
|
|
{
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
llenarGridView();
|
|||
|
|
}
|
|||
|
|
catch (Exception ex)
|
|||
|
|
{
|
|||
|
|
MensajeError("Error R3M3", ex);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
protected void btnNuevo_Click(object sender, EventArgs e) //M4
|
|||
|
|
{
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
Session["MODO"] = "Nuevo";
|
|||
|
|
Session["PKPROYECTO"] = -1;
|
|||
|
|
Response.Redirect("wfrAspectosGenerales.aspx");
|
|||
|
|
}
|
|||
|
|
catch (Exception ex)
|
|||
|
|
{
|
|||
|
|
MensajeError("Error en R3M4", ex);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
protected void btnEliminar_Click(object sender, EventArgs e) //M5
|
|||
|
|
{
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
//********** Instanciar objeto ******
|
|||
|
|
|
|||
|
|
// recorro el grid
|
|||
|
|
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)
|
|||
|
|
{
|
|||
|
|
objProyectoBL = new ProyectoBL();
|
|||
|
|
objProyectoBL.objProyectoEL.PK = Convert.ToInt32(row.Cells[2].Text);
|
|||
|
|
if (objProyectoBL.actualizaEstadoProyecto())
|
|||
|
|
{
|
|||
|
|
GuardarEventoBitacora(
|
|||
|
|
Session["LOGIN"].ToString(),
|
|||
|
|
AccionBitacora.UPDATE.ToString(),
|
|||
|
|
MensajesBitacora.EliminarRegistro + ": Número de Banco: " + row.Cells[3].Text + ", Proyecto: " + row.Cells[4].Text,
|
|||
|
|
"wfrProyectos.aspx");
|
|||
|
|
MensajeInformativo("El Proyecto se eliminó correctamente");
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
llenarGridView();
|
|||
|
|
}
|
|||
|
|
catch (Exception ex)
|
|||
|
|
{
|
|||
|
|
MensajeError("Error en R3M5", ex);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
#endregion
|
|||
|
|
|
|||
|
|
#region Metodos Personalizados (R4)
|
|||
|
|
|
|||
|
|
private void construirGridView() //M0
|
|||
|
|
{
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
//Se Instancia la variable con el control
|
|||
|
|
grvListaDatosTemp = (GridView)divDatosSuperiores.FindControl("grvListaDatos");
|
|||
|
|
|
|||
|
|
//Se crean las columnas del grid
|
|||
|
|
GridViewBoundField bdfPkProyecto = new GridViewBoundField("PKPROYECTO", "PK", false, false, false);
|
|||
|
|
GridViewBoundField bdfBPIP = new GridViewBoundField("NUMEROBPIPPROYECTO", "BPIP", true, false, true);
|
|||
|
|
GridViewBoundField bdfNombre = new GridViewBoundField("NOMBREPROYECTO", "PROYECTO", true, false, true);
|
|||
|
|
GridViewBoundField bdfDependencia = new GridViewBoundField("NOMBREDEPENDENCIA", "UNIDAD RESP.", true, false, true);
|
|||
|
|
GridViewBoundField bdfProvincia = new GridViewBoundField("NOMBREUBICACION", "PROVINCIA", true, false, true);
|
|||
|
|
|
|||
|
|
//Asigna las columnas a los campos a la hora de hacer la consulta
|
|||
|
|
grvListaDatosTemp.Columns.Add(bdfPkProyecto);
|
|||
|
|
grvListaDatosTemp.Columns.Add(bdfBPIP);
|
|||
|
|
grvListaDatosTemp.Columns.Add(bdfNombre);
|
|||
|
|
grvListaDatosTemp.Columns.Add(bdfDependencia);
|
|||
|
|
grvListaDatosTemp.Columns.Add(bdfProvincia);
|
|||
|
|
|
|||
|
|
|
|||
|
|
//Le damos estilo a las filas (opcional)
|
|||
|
|
grvListaDatosTemp.Columns[0].ItemStyle.Width = 25;
|
|||
|
|
grvListaDatosTemp.Columns[1].ItemStyle.Width = 25;
|
|||
|
|
grvListaDatosTemp.Columns[2].ItemStyle.Width = 25;
|
|||
|
|
grvListaDatosTemp.Columns[3].ItemStyle.Width = 75;
|
|||
|
|
grvListaDatosTemp.Columns[4].ItemStyle.Width = 500;
|
|||
|
|
grvListaDatosTemp.Columns[5].ItemStyle.Width = 250;
|
|||
|
|
grvListaDatosTemp.Columns[6].ItemStyle.Width = 100;
|
|||
|
|
|
|||
|
|
//http://localhost:60777/webforms/FOR/Listado.aspx
|
|||
|
|
|
|||
|
|
//Carga el buscador con las columnas del grid
|
|||
|
|
LlenarDDLBusqueda(grvListaDatosTemp);
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
catch (Exception ex)
|
|||
|
|
{
|
|||
|
|
MensajeError("Error en R4M0", ex);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void Busqueda() //M1
|
|||
|
|
{
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
llenarGridView();
|
|||
|
|
}
|
|||
|
|
catch (Exception ex)
|
|||
|
|
{
|
|||
|
|
MensajeError("Error en R4M1", ex);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public void LlenarDDLBusqueda(GridView gridView) //M2
|
|||
|
|
{
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
foreach (DataControlField dgcDGTempColumn in gridView.Columns)
|
|||
|
|
{
|
|||
|
|
if (dgcDGTempColumn.GetType().ToString() == "GridViewBoundField")
|
|||
|
|
{
|
|||
|
|
GridViewBoundField ndbTempDGBoundField = (GridViewBoundField)dgcDGTempColumn;
|
|||
|
|
|
|||
|
|
if (ndbTempDGBoundField.Visible && ndbTempDGBoundField.IsSearch)
|
|||
|
|
{
|
|||
|
|
ListItem litTempItem = new ListItem(ndbTempDGBoundField.HeaderText, ndbTempDGBoundField.DataField);
|
|||
|
|
ddlFiltrosBusqueda.Items.Add(litTempItem);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
catch (Exception ex)
|
|||
|
|
{
|
|||
|
|
MensajeError("Error en R4M2", ex);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private ArrayList condicionesBusqueda() //M3
|
|||
|
|
{
|
|||
|
|
ArrayList arlCondicionesFiltroBusqueda = null;
|
|||
|
|
CondicionDAL condicion;
|
|||
|
|
ListItem li = new ListItem(this.txtValorBusqueda.Text.Trim(), this.ddlFiltrosBusqueda.SelectedItem.Value);
|
|||
|
|
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
|
|||
|
|
if (li.Text != string.Empty)
|
|||
|
|
{
|
|||
|
|
arlCondicionesFiltroBusqueda = new ArrayList();
|
|||
|
|
|
|||
|
|
condicion = new CondicionDAL();
|
|||
|
|
condicion.valorIzquierdo = li.Value + " COLLATE SQL_LATIN1_GENERAL_CP1_CI_AI ";
|
|||
|
|
condicion.operadorGeneral = operadorGeneral.LIKEALL;
|
|||
|
|
condicion.operadorLogico = operadorLogico.AND;
|
|||
|
|
condicion.valorDerecho = "%" + li.Text + "%";
|
|||
|
|
|
|||
|
|
arlCondicionesFiltroBusqueda.Add(condicion);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
catch (Exception ex)
|
|||
|
|
{
|
|||
|
|
MensajeError("Error en R4M3", ex);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
return arlCondicionesFiltroBusqueda;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
#endregion
|
|||
|
|
|
|||
|
|
#region Metodos Controles a Datos (R5)
|
|||
|
|
|
|||
|
|
private void ComandosxMenu() //M0
|
|||
|
|
{
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
DataSet dsComandos = getComandos();
|
|||
|
|
|
|||
|
|
if (dsComandos != null)
|
|||
|
|
{
|
|||
|
|
foreach (DataRow drTemp in dsComandos.Tables[0].Rows)
|
|||
|
|
{
|
|||
|
|
switch (drTemp["NOMBRECOMANDO"].ToString().ToUpper())
|
|||
|
|
{
|
|||
|
|
case "ELIMINAR":
|
|||
|
|
btnEliminar.Visible = true;
|
|||
|
|
break;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
catch (Exception ex)
|
|||
|
|
{
|
|||
|
|
MensajeError("Error en R4M0", ex);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
#endregion
|
|||
|
|
|
|||
|
|
#region Metodos Datos a Controles (R6)
|
|||
|
|
|
|||
|
|
private void llenarGridView() //M0
|
|||
|
|
{
|
|||
|
|
ArrayList arlCondicionesFiltroBusqueda = condicionesBusqueda();
|
|||
|
|
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
if (!IsPostBack)
|
|||
|
|
{
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
objProyectoBL = new ProyectoBL();
|
|||
|
|
|
|||
|
|
objProyectoBL.objProyectoEL.CodigoAcceso = Session["CODIGOACCESO"].ToString();
|
|||
|
|
DataSet dsListaDatos = objProyectoBL.getListadoProyectos(arlCondicionesFiltroBusqueda);
|
|||
|
|
General.detalleGridView(dsListaDatos, grvListaDatosTemp, lblTotalDatos);
|
|||
|
|
}
|
|||
|
|
catch (Exception ex)
|
|||
|
|
{
|
|||
|
|
MensajeError("Error en R6M0", ex);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
#endregion
|
|||
|
|
|
|||
|
|
}
|