556 lines
No EOL
20 KiB
C#
556 lines
No EOL
20 KiB
C#
/*===========================================================================================================================
|
||
* Instituto Costarricense de Acueductos y Alcantarillados. - 2019
|
||
* Formularios para Proyectos de Inversión
|
||
* Nombre de la Pantalla: wfrInfoComplementaria.aspx
|
||
*
|
||
* Explicación de los contenidos del archivo
|
||
*===========================================================================================================================
|
||
* HISTORIAL
|
||
*
|
||
* PERSONA DIA – MES - AÑO DESCRIPCIÓN
|
||
* Esteban Gutierrez Rapso 18 – 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.Collections.Generic;
|
||
using System.Configuration;
|
||
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 AyADAL;
|
||
using AyABL.RCS;
|
||
using AyABL.ICP;
|
||
using AyABL.AGP;
|
||
|
||
public partial class webforms_FOR_wfrInfoComplementaria : 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);
|
||
|
||
Javascript.CheckAllGridViewItems(Page);
|
||
|
||
construirGrvObservaciones();
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
MensajeError("Error en R0M1", ex);
|
||
}
|
||
}
|
||
|
||
#endregion
|
||
|
||
#region Variables (R1)
|
||
|
||
GridView grvObservacionesTemp;
|
||
|
||
ProyectoBL objProyectoBL;
|
||
ObservacionBL objObservacionBL;
|
||
InformacionBL objInformacionBL;
|
||
|
||
#endregion
|
||
|
||
#region Eventos Formulario (R2)
|
||
|
||
protected void Page_Load(object sender, EventArgs e) //M0
|
||
{
|
||
try
|
||
{
|
||
if ((!IsPostBack) && (Session.Count > 0))
|
||
{
|
||
objProyectoBL = new ProyectoBL();
|
||
objProyectoBL.objProyectoEL.PK = Int32.Parse(Session["PKPROYECTO"].ToString());
|
||
DataSet dsProyecto = objProyectoBL.getProyectos();
|
||
if (dsProyecto.Tables[0].Rows.Count != 0)
|
||
{
|
||
txtProyecto.Text = dsProyecto.Tables[0].Rows[0]["NOMBREPROYECTO"].ToString();
|
||
txtNumeroBPIP.Text = dsProyecto.Tables[0].Rows[0]["NUMEROBPIPPROYECTO"].ToString();
|
||
txtEstadoProyecto.Text = string.IsNullOrEmpty(dsProyecto.Tables[0].Rows[0]["NOMBREESTADO"].ToString()) ? "Sin Asignar" : dsProyecto.Tables[0].Rows[0]["NOMBREESTADO"].ToString();
|
||
}
|
||
|
||
mostrarDatos();
|
||
}
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
MensajeError("Error en R2M0", ex);
|
||
}
|
||
}
|
||
|
||
#endregion
|
||
|
||
#region Eventos Controles Web (R3)
|
||
|
||
protected void btnAnterior_Click(object sender, EventArgs e) //M0
|
||
{
|
||
try
|
||
{
|
||
Response.Redirect("wfrProyectos.aspx");
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
MensajeError("Error en R3M0", ex);
|
||
}
|
||
}
|
||
|
||
protected void btnGuardarIC_Click(object sender, EventArgs e) //M1
|
||
{
|
||
try
|
||
{
|
||
if (GuardarDatos())
|
||
{
|
||
MensajeInformativo("El registro fue almacenado exitosamente");
|
||
}
|
||
else
|
||
{
|
||
MensajeError("El registro no fue almacenado, verifique", null);
|
||
}
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
MensajeError("Error en R3M1", ex);
|
||
}
|
||
}
|
||
|
||
protected void grvObservaciones_RowCommand(object sender, GridViewCommandEventArgs e) //M2
|
||
{
|
||
try
|
||
{
|
||
if (e.CommandName == "editar")
|
||
{
|
||
int i = Convert.ToInt32(e.CommandArgument);
|
||
GridViewRow selectedRow = grvObservaciones.Rows[i];
|
||
int intPkObservacion = Convert.ToInt32(selectedRow.Cells[2].Text);
|
||
ViewState["PkObservacion"] = intPkObservacion;
|
||
ViewState["Modo_Observacion"] = "Modifica";
|
||
|
||
mostrarFilasObservaciones(2);
|
||
mostrarObservaciones();
|
||
}
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
MensajeError("Error en R3M2", ex);
|
||
}
|
||
}
|
||
|
||
protected void grvObservaciones_PageIndexChanging(object sender, GridViewPageEventArgs e) //M3
|
||
{
|
||
try
|
||
{
|
||
grvObservaciones.PageIndex = e.NewPageIndex;
|
||
llenarGrvObservacion();
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
MensajeError("Error R3M3", ex);
|
||
}
|
||
}
|
||
|
||
protected void btnNuevoOB_Click(object sender, EventArgs e) //M4
|
||
{
|
||
try
|
||
{
|
||
ViewState["Modo_Observacion"] = "Nuevo";
|
||
mostrarFilasObservaciones(2);
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
MensajeError("Error en R3M4", ex);
|
||
}
|
||
}
|
||
|
||
protected void btnEliminarOB_Click(object sender, EventArgs e) //M5
|
||
{
|
||
try
|
||
{
|
||
// recorro el grid
|
||
foreach (GridViewRow row in grvObservacionesTemp.Rows)
|
||
{
|
||
|
||
HtmlInputCheckBox chkTemp = (HtmlInputCheckBox)row.Controls[0].Controls[1];
|
||
if (chkTemp != null)
|
||
{
|
||
// si el registro esta marcado
|
||
if (chkTemp.Checked)
|
||
{
|
||
//Iguala la variable al valor en la celda seleccionada
|
||
int intPkEliminar = Convert.ToInt32(row.Cells[2].Text);
|
||
eliminarDatosObservaciones(intPkEliminar);
|
||
}
|
||
}
|
||
}
|
||
llenarGrvObservacion();
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
MensajeError("Error en R3M5", ex);
|
||
}
|
||
}
|
||
|
||
protected void btnGuardarOB_Click(object sender, EventArgs e) //M6
|
||
{
|
||
try
|
||
{
|
||
if (guardarDatosObservaciones())
|
||
{
|
||
MensajeInformativo("El agregó la observacion exitosamente");
|
||
|
||
llenarGrvObservacion();
|
||
}
|
||
else
|
||
{
|
||
MensajeError("La observación no fue agregada, verifique", null);
|
||
}
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
MensajeError("Error en R3M6", ex);
|
||
}
|
||
}
|
||
|
||
protected void btnAnteriorOB_Click(object sender, EventArgs e) //M7
|
||
{
|
||
try
|
||
{
|
||
mostrarFilasObservaciones(1);
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
MensajeError("Error en R3M7", ex);
|
||
}
|
||
}
|
||
|
||
#endregion
|
||
|
||
#region Metodos Personalizados (R4)
|
||
|
||
private void construirGrvObservaciones() //M0
|
||
{
|
||
try
|
||
{
|
||
grvObservacionesTemp = (GridView)divLista.FindControl("grvObservaciones");
|
||
|
||
GridViewBoundField bdfPkObservacion = new GridViewBoundField("PKOBSERVACION", "PK", false, false, false);
|
||
GridViewBoundField bdfFechaIngreso = new GridViewBoundField("FECHAINGRESOOBSERVACION", "FECHA", false, true, true);
|
||
GridViewBoundField bdfDescripcion = new GridViewBoundField("DESCRIPCIONOBSERVACION", "OBSERVACION", false, true, true);
|
||
|
||
grvObservacionesTemp.Columns.Add(bdfPkObservacion);
|
||
grvObservacionesTemp.Columns.Add(bdfFechaIngreso);
|
||
grvObservacionesTemp.Columns.Add(bdfDescripcion);
|
||
|
||
grvObservacionesTemp.Columns[0].ItemStyle.Width = 25;
|
||
grvObservacionesTemp.Columns[1].ItemStyle.Width = 25;
|
||
grvObservacionesTemp.Columns[3].ItemStyle.Width = 100;
|
||
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
MensajeError("Error en R4M0", ex);
|
||
}
|
||
}
|
||
|
||
private void limpiarCampos() //M1
|
||
{
|
||
txtImportancia.Text = string.Empty;
|
||
txtProblema.Text = string.Empty;
|
||
txtMedidas.Text = string.Empty;
|
||
txtProyectosVinculados.Text = string.Empty;
|
||
txtEntidades.Text = string.Empty;
|
||
txtFecha.Value = string.Empty;
|
||
txtObservacion.Text = string.Empty;
|
||
}
|
||
|
||
private void mostrarFilasObservaciones(int p_intFila) //M2
|
||
{
|
||
try
|
||
{
|
||
divLista.Visible = false;
|
||
divFormulario.Visible = false;
|
||
|
||
switch (p_intFila)
|
||
{
|
||
case 1:
|
||
llenarGrvObservacion();
|
||
divLista.Visible = true;
|
||
break;
|
||
case 2:
|
||
limpiarCamposOB();
|
||
divFormulario.Visible = true;
|
||
break;
|
||
}
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
MensajeError("Error en R4M2", ex);
|
||
}
|
||
}
|
||
|
||
private void limpiarCamposOB() //M3
|
||
{
|
||
txtFecha.Value = string.Empty;
|
||
txtObservacion.Text = string.Empty;
|
||
}
|
||
|
||
#endregion
|
||
|
||
#region Metodos Controles a Datos (R5)
|
||
|
||
private bool GuardarDatos() //M0
|
||
{
|
||
bool blnEjecutado = false;
|
||
|
||
try
|
||
{
|
||
string strModo = ViewState["Modo"].ToString();
|
||
|
||
objInformacionBL = new InformacionBL();
|
||
objInformacionBL.objInformacionEL.Importancia = txtImportancia.Text;
|
||
objInformacionBL.objInformacionEL.Problema = txtProblema.Text;
|
||
objInformacionBL.objInformacionEL.Medida = txtMedidas.Text;
|
||
objInformacionBL.objInformacionEL.ProyectoVinculado = txtProyectosVinculados.Text;
|
||
objInformacionBL.objInformacionEL.OtrasEntidades = txtEntidades.Text;
|
||
objInformacionBL.objInformacionEL.Proyecto = Int32.Parse(Session["PKPROYECTO"].ToString());
|
||
|
||
if (strModo == "Nuevo")
|
||
{
|
||
int intInformacionProyecto = objInformacionBL.insertarInformacion();
|
||
|
||
blnEjecutado = true;
|
||
|
||
ViewState["FkInformacion"] = intInformacionProyecto;
|
||
GuardarEventoBitacora(
|
||
Session["LOGIN"].ToString(),
|
||
AccionBitacora.INSERT.ToString(),
|
||
MensajesBitacora.IngresarRegistro + ": Se ha ingresado el registro " + txtImportancia.Text + ", " + txtProblema.Text + ", " + txtMedidas.Text + ", "
|
||
+ txtProyectosVinculados.Text + ", " + txtEntidades.Text + ", " + txtProyecto.Text,
|
||
"wfrInfoComplementaria.aspx");
|
||
|
||
ViewState["Modo"] = "Modifica";
|
||
}
|
||
else if (strModo == "Modifica")
|
||
{
|
||
if (objInformacionBL.actualizarInformacion())
|
||
{
|
||
blnEjecutado = true;
|
||
|
||
GuardarEventoBitacora(
|
||
Session["LOGIN"].ToString(),
|
||
AccionBitacora.UPDATE.ToString(),
|
||
MensajesBitacora.ModificarRegistro + ": Se ha modificado el registro " + txtImportancia.Text + ", " + txtProblema.Text + ", " + txtMedidas.Text + ", "
|
||
+ txtProyectosVinculados.Text + ", " + txtEntidades.Text + ", " + txtProyecto.Text,
|
||
"wfrInfoComplementaria.aspx");
|
||
}
|
||
|
||
}
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
blnEjecutado = false;
|
||
throw ex;
|
||
General.ReportarError(ex, Session["LOGIN"].ToString());
|
||
}
|
||
return blnEjecutado;
|
||
}
|
||
|
||
private bool guardarDatosObservaciones() //M1
|
||
{
|
||
bool blnEjecutado = false;
|
||
|
||
try
|
||
{
|
||
string strModo = ViewState["Modo_Observacion"].ToString();
|
||
|
||
if (!txtObservacion.Text.Equals(""))
|
||
{
|
||
objObservacionBL = new ObservacionBL();
|
||
objObservacionBL.objObservacionEL.FechaIngreso = txtFecha.Value != "" ? Convert.ToDateTime(txtFecha.Value) : DateTime.Now;
|
||
objObservacionBL.objObservacionEL.Descripcion = txtObservacion.Text;
|
||
objObservacionBL.objObservacionEL.Informacion = Int32.Parse(ViewState["FkInformacion"].ToString());
|
||
|
||
if (strModo == "Nuevo")
|
||
{
|
||
if (objObservacionBL.insertarObservacion())
|
||
{
|
||
blnEjecutado = true;
|
||
|
||
GuardarEventoBitacora(
|
||
Session["LOGIN"].ToString(),
|
||
AccionBitacora.INSERT.ToString(),
|
||
MensajesBitacora.IngresarRegistro + ": Se ha ingresado el registro en Observación " + txtFecha.Value + ", " + txtObservacion.Text + ", "
|
||
+ ViewState["FkInformacion"].ToString(),
|
||
"wfrInfoComplementaria.aspx");
|
||
}
|
||
|
||
blnEjecutado = true;
|
||
}
|
||
else if (strModo == "Modifica")
|
||
{
|
||
objObservacionBL.objObservacionEL.PK = Int32.Parse(ViewState["PkObservacion"].ToString());
|
||
if (objObservacionBL.actualizarObservacion())
|
||
{
|
||
blnEjecutado = true;
|
||
|
||
GuardarEventoBitacora(
|
||
Session["LOGIN"].ToString(),
|
||
AccionBitacora.INSERT.ToString(),
|
||
MensajesBitacora.ModificarRegistro + ": Se ha modificado el registro en Observación " + txtFecha.Value + ", " + txtObservacion.Text + ", "
|
||
+ ViewState["FkInformacion"].ToString(),
|
||
"wfrInfoComplementaria.aspx");
|
||
}
|
||
|
||
blnEjecutado = true;
|
||
}
|
||
|
||
llenarGrvObservacion();
|
||
}
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
blnEjecutado = false;
|
||
throw ex;
|
||
General.ReportarError(ex, Session["LOGIN"].ToString());
|
||
}
|
||
|
||
return blnEjecutado;
|
||
}
|
||
|
||
private void eliminarDatosObservaciones(int p_intPkObservacion) //M2
|
||
{
|
||
try
|
||
{
|
||
objObservacionBL = new ObservacionBL();
|
||
|
||
objObservacionBL.objObservacionEL.PK = p_intPkObservacion;
|
||
objObservacionBL.objObservacionEL.ASTATE = false;
|
||
objObservacionBL.actualizaEstadoObservacion();
|
||
|
||
GuardarEventoBitacora(Session["LOGIN"].ToString(),
|
||
AccionBitacora.DELETE.ToString(),
|
||
MensajesBitacora.EliminarRegistro + ": Se ha borrado el registro con la PK: " + ": " + p_intPkObservacion,
|
||
"wfrInfoComplementaria.aspx");
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
MensajeError("Error en R5M2", ex);
|
||
General.ReportarError(ex, Session["LOGIN"].ToString());
|
||
}
|
||
}
|
||
|
||
#endregion
|
||
|
||
#region Metodos Datos a Controles (R6)
|
||
|
||
private void mostrarDatos() //M0
|
||
{
|
||
try
|
||
{
|
||
limpiarCampos();
|
||
|
||
//Carga campos informaci[on
|
||
objInformacionBL = new InformacionBL();
|
||
objInformacionBL.objInformacionEL.Proyecto = Int32.Parse(Session["PKPROYECTO"].ToString());
|
||
DataSet ds = objInformacionBL.getInformacion();
|
||
if (ds.Tables[0].Rows.Count != 0)
|
||
{
|
||
ViewState["Modo"] = "Modifica";
|
||
|
||
txtImportancia.Text = ds.Tables[0].Rows[0]["IMPORTANCIAINFORMACION"].ToString();
|
||
txtProblema.Text = ds.Tables[0].Rows[0]["PROBLEMAINFORMACION"].ToString();
|
||
txtMedidas.Text = ds.Tables[0].Rows[0]["MEDIDAINFORMACION"].ToString();
|
||
txtProyectosVinculados.Text = ds.Tables[0].Rows[0]["PROYECTOVINCULADOINFORMACION"].ToString();
|
||
txtEntidades.Text = ds.Tables[0].Rows[0]["OTRASENTIDADESINFORMACION"].ToString();
|
||
ViewState["FkInformacion"] = Int32.Parse(ds.Tables[0].Rows[0]["PKINFORMACION"].ToString());
|
||
|
||
llenarGrvObservacion();
|
||
}
|
||
else if (ds.Tables[0].Rows.Count == 0)
|
||
{
|
||
ViewState["Modo"] = "Nuevo";
|
||
}
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
MensajeError("Error en R6M0", ex);
|
||
General.ReportarError(ex, Session["LOGIN"].ToString());
|
||
}
|
||
}
|
||
|
||
private void llenarGrvObservacion() //M1
|
||
{
|
||
try
|
||
{
|
||
objObservacionBL = new ObservacionBL();
|
||
objObservacionBL.objObservacionEL.Informacion = Int32.Parse(ViewState["FkInformacion"].ToString());
|
||
|
||
DataSet dsObservaciones = objObservacionBL.getObservacion();
|
||
|
||
detalleGRVDatos(dsObservaciones, grvObservacionesTemp);
|
||
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
MensajeError("Error en R6M1", ex);
|
||
General.ReportarError(ex, Session["LOGIN"].ToString());
|
||
}
|
||
}
|
||
|
||
private void mostrarObservaciones() //M2
|
||
{
|
||
try
|
||
{
|
||
limpiarCamposOB();
|
||
|
||
//Carga campos informaci[on
|
||
objObservacionBL = new ObservacionBL();
|
||
objObservacionBL.objObservacionEL.PK = Int32.Parse(ViewState["PkObservacion"].ToString());
|
||
DataSet ds = objObservacionBL.getObservacion2();
|
||
if (ds.Tables[0].Rows.Count != 0)
|
||
{
|
||
txtFecha.Value = ds.Tables[0].Rows[0]["FECHAINGRESOOBSERVACION"].ToString().Substring(0,10);
|
||
txtObservacion.Text = ds.Tables[0].Rows[0]["DESCRIPCIONOBSERVACION"].ToString();
|
||
}
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
MensajeError("Error en R6M0", ex);
|
||
General.ReportarError(ex, Session["LOGIN"].ToString());
|
||
}
|
||
}
|
||
|
||
#endregion
|
||
|
||
} |