979 lines
No EOL
36 KiB
C#
979 lines
No EOL
36 KiB
C#
/*===========================================================================================================================
|
||
* Instituto Costarricense de Acueductos y Alcantarillados. - 2015
|
||
* Formularios para Proyectos de Inversión
|
||
* Nombre de la Pantalla: frwInformacionGeneral.aspx
|
||
*
|
||
* Explicación de los contenidos del archivo
|
||
*===========================================================================================================================
|
||
* HISTORIAL
|
||
*
|
||
* PERSONA DIA – MES - AÑO DESCRIPCIÓN
|
||
* Pamela Quesada Calderon CGC 23 – 02 - 2017 Se inicia con el diseño de la pagina
|
||
* …………………………………………………………
|
||
* …………………………………………………………
|
||
*===========================================================================================================================
|
||
* Derechos Reservados (C) 2016 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.IGP;
|
||
using AyABL.AGP;
|
||
using AyABL.PLE;
|
||
using AyABL.ADM;
|
||
using AyABL.CIP;
|
||
using AyABL.FNP;
|
||
|
||
public partial class webforms_CIP_wfrCierre : 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);
|
||
|
||
construirgrvLeccion();
|
||
construirgrvComentario();
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
MensajeError("Error en R0M1", ex);
|
||
}
|
||
}
|
||
|
||
#endregion
|
||
|
||
#region Variables (R1)
|
||
|
||
GridView grvComentarioTemp, grvLeccionTemp;
|
||
|
||
ProyectoBL objProyectoBL;
|
||
InformacionGeneralBL objInformacionGeneralBL;
|
||
LeccionBL objLeccionBL;
|
||
ComentarioBL objComentarioBL;
|
||
CierreBL objCierreBL;
|
||
ObjetivoEspecificoBL objObjetivoEspecificoBL;
|
||
FinanciamientoBL objFinanciamientoBL;
|
||
|
||
#endregion
|
||
|
||
#region Eventos Formulario (R2)
|
||
|
||
protected void Page_Load(object sender, EventArgs e) //M0
|
||
{
|
||
try
|
||
{
|
||
if ((!IsPostBack) && (Session.Count > 0))
|
||
{
|
||
llenarDDLProyecto();
|
||
ComandosxMenu();
|
||
ViewState["MODOLECCION"] = "Nuevo";
|
||
|
||
if (Session["PKPROYECTO"] != null)
|
||
{
|
||
ddlProyecto.SelectedValue = Session["PKPROYECTO"].ToString();
|
||
|
||
ddlProyecto_SelectedIndexChanged(null, null);
|
||
}
|
||
else
|
||
{
|
||
ddlProyecto.SelectedValue = "-1";
|
||
}
|
||
|
||
mostrarDatos();
|
||
}
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
MensajeError("Error en R2M0", ex);
|
||
}
|
||
}
|
||
|
||
#endregion
|
||
|
||
#region Eventos Controles Web (R3)
|
||
|
||
/// <summary>
|
||
/// Activa el evento del boton Nuevo
|
||
/// </summary>
|
||
/// <param name="sender"></param>
|
||
/// <param name="e"></param>
|
||
|
||
protected void btnEliminar_Click(object sender, EventArgs e) //M0
|
||
{
|
||
try
|
||
{
|
||
if (grvLeccion.Rows.Count > 0 && grvComentario.Rows.Count > 0)
|
||
{
|
||
MensajeError("No se puede eliminar la información pues hay lecciones y Comentarioes relacionadas.", null);
|
||
}
|
||
else
|
||
{
|
||
objCierreBL = new CierreBL();
|
||
objCierreBL.objCierreEL.PK = Convert.ToInt32(ViewState["PKCIERRE"].ToString());
|
||
|
||
//Actualiza estado a eliminado en la tabla
|
||
objCierreBL.actualizaEstadoCierre();
|
||
|
||
limpiarCampos();
|
||
mostrarDatos();
|
||
}
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
MensajeError("Error en R3M0", ex);
|
||
}
|
||
}
|
||
|
||
/// <summary>
|
||
/// Activa el evento del boton guardar.1
|
||
/// </summary>
|
||
/// <param name="sender"></param>
|
||
/// <param name="e"></param>
|
||
|
||
protected void btnGuardarCierre_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 ddlProyecto_SelectedIndexChanged(object sender, EventArgs e) //M2
|
||
{
|
||
try
|
||
{
|
||
limpiarCampos();
|
||
|
||
Session["PKPROYECTO"] = ddlProyecto.SelectedValue;
|
||
|
||
mostrarDatos();
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
MensajeError("Error en R3M2", ex);
|
||
}
|
||
}
|
||
|
||
protected void btnGuardarLeccion_Click(object sender, EventArgs e) //M3
|
||
{
|
||
try
|
||
{
|
||
if (GuardarDatosLeccion())
|
||
{
|
||
MensajeInformativo("El registro fue almacenado exitosamente");
|
||
txtEvento.Text = string.Empty;
|
||
txtDescripcion.Text = string.Empty;
|
||
llenarGrvLeccion();
|
||
}
|
||
else
|
||
{
|
||
MensajeError("El registro no fue almacenado, verifique", null);
|
||
}
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
MensajeError("Error en R3M3", ex);
|
||
}
|
||
}
|
||
|
||
protected void btnGuardarComentario_Click(object sender, EventArgs e) //M4
|
||
{
|
||
try
|
||
{
|
||
if (GuardarDatosComentario())
|
||
{
|
||
MensajeInformativo("El registro fue almacenado exitosamente");
|
||
txtFecha.Value = string.Empty;
|
||
txtComentario.Text = string.Empty;
|
||
llenarGrvComentario();
|
||
}
|
||
else
|
||
{
|
||
MensajeError("El registro no fue almacenado, verifique", null);
|
||
}
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
MensajeError("Error en R3M4", ex);
|
||
}
|
||
}
|
||
|
||
protected void btnEliminarLA_Click(object sender, EventArgs e) //M5
|
||
{
|
||
try
|
||
{
|
||
// recorro el grid
|
||
foreach (GridViewRow row in grvLeccion.Rows)
|
||
{
|
||
HtmlInputCheckBox chkTemp = (HtmlInputCheckBox)row.Controls[0].Controls[1];
|
||
if (chkTemp != null)
|
||
{
|
||
// si el registro esta marcado
|
||
if (chkTemp.Checked)
|
||
{
|
||
int intPkIndice = Convert.ToInt32(row.Cells[1].Text);
|
||
eliminarLeccion(intPkIndice);
|
||
}
|
||
}
|
||
}
|
||
|
||
llenarGrvLeccion();
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
MensajeError("Error en R3M5", ex);
|
||
}
|
||
}
|
||
|
||
protected void btnEliminarComen_Click(object sender, EventArgs e) //M6
|
||
{
|
||
try
|
||
{
|
||
// recorro el grid
|
||
foreach (GridViewRow row in grvComentario.Rows)
|
||
{
|
||
HtmlInputCheckBox chkTemp = (HtmlInputCheckBox)row.Controls[0].Controls[1];
|
||
if (chkTemp != null)
|
||
{
|
||
// si el registro esta marcado
|
||
if (chkTemp.Checked)
|
||
{
|
||
int intPkIndice = Convert.ToInt32(row.Cells[1].Text);
|
||
eliminarComentario(intPkIndice);
|
||
}
|
||
}
|
||
}
|
||
|
||
llenarGrvComentario();
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
MensajeError("Error en R3M6", ex);
|
||
}
|
||
}
|
||
|
||
protected void btnNoCumplir_Click(object sender, EventArgs e) //M7
|
||
{
|
||
try
|
||
{
|
||
// recorro el grid
|
||
foreach (GridViewRow row in grvObjCumplidos.Rows)
|
||
{
|
||
HtmlInputCheckBox chkTemp = (HtmlInputCheckBox)row.Controls[0].Controls[1];
|
||
if (chkTemp != null)
|
||
{
|
||
// si el registro esta marcado
|
||
if (chkTemp.Checked)
|
||
{
|
||
int intPkIndice = Convert.ToInt32(row.Cells[1].Text);
|
||
int numero = Convert.ToInt32(row.Cells[2].Text);
|
||
string descripcion = row.Cells[3].Text;
|
||
cambiaEstadoObjetivo(intPkIndice, false, numero, descripcion);
|
||
}
|
||
}
|
||
}
|
||
|
||
llenarGrvObjetivos();
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
MensajeError("Error en R3M7", ex);
|
||
}
|
||
}
|
||
|
||
protected void btnCumplir_Click(object sender, EventArgs e) //M8
|
||
{
|
||
try
|
||
{
|
||
// recorro el grid
|
||
foreach (GridViewRow row in grvObjNoCumplidos.Rows)
|
||
{
|
||
HtmlInputCheckBox chkTemp = (HtmlInputCheckBox)row.Controls[0].Controls[1];
|
||
if (chkTemp != null)
|
||
{
|
||
// si el registro esta marcado
|
||
if (chkTemp.Checked)
|
||
{
|
||
int intPkIndice = Convert.ToInt32(row.Cells[1].Text);
|
||
int numero = Convert.ToInt32(row.Cells[2].Text);
|
||
string descripcion = row.Cells[3].Text;
|
||
cambiaEstadoObjetivo(intPkIndice, true, numero, descripcion);
|
||
}
|
||
}
|
||
}
|
||
|
||
llenarGrvObjetivos();
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
MensajeError("Error en R3M7", ex);
|
||
}
|
||
}
|
||
|
||
#endregion
|
||
|
||
#region Metodos Personalizados (R4)
|
||
|
||
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 "NUEVO":
|
||
btnGuardarCierre.Visible = true;
|
||
btnGuardarOb.Visible = true;
|
||
btnGuardarLA.Visible = true;
|
||
break;
|
||
case "ELIMINAR":
|
||
btnEliminarCierre.Visible = true;
|
||
btnEliminarComen.Visible = true;
|
||
btnEliminarLA.Visible = true;
|
||
break;
|
||
case "MODIFICA":
|
||
//Inicio de variable tipo VIEWSTATE
|
||
ViewState["PUEDEMODIFICAR"] = true;
|
||
btnCumplir.Visible = true;
|
||
btnNoCumplir.Visible = true;
|
||
break;
|
||
}
|
||
}
|
||
}
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
MensajeError("Error en R4M0", ex);
|
||
}
|
||
}
|
||
|
||
|
||
private void construirgrvComentario() //M1
|
||
{
|
||
try
|
||
{
|
||
grvComentarioTemp = (GridView)divLecciones.FindControl("grvComentario");
|
||
|
||
GridViewBoundField bdfPkLeccion = new GridViewBoundField("PKComentario", "PK", false, false, false);
|
||
GridViewBoundField bdfEvento = new GridViewBoundField("FECHAINGRESOComentario", "FECHA", true, false, true);
|
||
GridViewBoundField bdfDescripcion = new GridViewBoundField("Comentario", "COMENTARIO", true, false, true);
|
||
|
||
grvComentarioTemp.Columns.Add(bdfPkLeccion);
|
||
grvComentarioTemp.Columns.Add(bdfEvento);
|
||
grvComentarioTemp.Columns.Add(bdfDescripcion);
|
||
|
||
grvComentarioTemp.Columns[0].ItemStyle.Width = 25;
|
||
grvComentarioTemp.Columns[2].ItemStyle.Width = 50;
|
||
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
MensajeError("Error en R4M1", ex);
|
||
}
|
||
}
|
||
|
||
public static void detalleGRVDatos(DataSet p_dsDatos, GridView p_grvGridView) //M2
|
||
{
|
||
try
|
||
{
|
||
p_grvGridView.ShowHeader = true;
|
||
p_grvGridView.DataSource = p_dsDatos;
|
||
p_grvGridView.DataBind();
|
||
}
|
||
catch (Exception)
|
||
{
|
||
}
|
||
}
|
||
|
||
private void construirgrvLeccion() //M3
|
||
{
|
||
try
|
||
{
|
||
grvLeccionTemp = (GridView)divLecciones.FindControl("grvLeccion");
|
||
|
||
GridViewBoundField bdfPkLeccion = new GridViewBoundField("PKLECCION", "PK", false, false, false);
|
||
GridViewBoundField bdfEvento = new GridViewBoundField("EVENTOLECCION", "EVENTO", true, false, true);
|
||
GridViewBoundField bdfDescripcion = new GridViewBoundField("DESCRIPCIONLECCION", "DESCRIPCION", true, false, true);
|
||
|
||
grvLeccionTemp.Columns.Add(bdfPkLeccion);
|
||
grvLeccionTemp.Columns.Add(bdfEvento);
|
||
grvLeccionTemp.Columns.Add(bdfDescripcion);
|
||
|
||
grvLeccionTemp.Columns[0].ItemStyle.Width = 25;
|
||
grvLeccionTemp.Columns[1].ItemStyle.Width = 25;
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
MensajeError("Error en R4M3", ex);
|
||
}
|
||
}
|
||
|
||
private void limpiarCampos() //M4
|
||
{
|
||
try
|
||
{
|
||
txtDescripcion.Text = string.Empty;
|
||
txtEvento.Text = string.Empty;
|
||
txtFecha.Value = string.Empty;
|
||
txtFechaCapitalizacion.Value = string.Empty;
|
||
txtFechaEntrega.Value = string.Empty;
|
||
txtFechaFinalizacion.Value = string.Empty;
|
||
txtFechaInicio.Value = string.Empty;
|
||
txtFinanciamiento.Text = string.Empty;
|
||
txtInversion.Text = string.Empty;
|
||
txtMontoCapitalizacion.Value = string.Empty;
|
||
txtComentario.Text = string.Empty;
|
||
txtPreInversion.Text = string.Empty;
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
MensajeError("Error en R4M4", ex);
|
||
}
|
||
}
|
||
|
||
#endregion
|
||
|
||
#region Metodos Controles a Datos (R5)
|
||
|
||
/// <summary>
|
||
/// guarda y modifica registros en la tabla.
|
||
/// </summary>
|
||
/// <returns></returns>
|
||
private bool GuardarDatos() //M0
|
||
{
|
||
bool blnEjecutado = false;
|
||
|
||
try
|
||
{
|
||
string strModo = string.Empty;
|
||
|
||
if (ddlProyecto.SelectedIndex > 0)
|
||
{
|
||
strModo = ViewState["MODO"].ToString();
|
||
|
||
objCierreBL = new CierreBL();
|
||
objCierreBL.objCierreEL.DocumentoFinanciamiento = txtFinanciamiento.Text;
|
||
objCierreBL.objCierreEL.DocumentoInversion = txtInversion.Text;
|
||
objCierreBL.objCierreEL.DocumentoPreInversion = txtPreInversion.Text;
|
||
objCierreBL.objCierreEL.MontoCapitalizacion = txtMontoCapitalizacion.Value == "" ? 0 : Decimal.Parse(txtMontoCapitalizacion.Value);
|
||
objCierreBL.objCierreEL.FechaCapitalizacion = txtFechaCapitalizacion.Value != "" ? Convert.ToDateTime(txtFechaCapitalizacion.Value) : DateTime.Now;
|
||
objCierreBL.objCierreEL.Proyecto = Int32.Parse(ddlProyecto.SelectedValue);
|
||
|
||
if (strModo == "Nuevo")
|
||
{
|
||
int cierre = objCierreBL.insertarCierre();
|
||
{
|
||
blnEjecutado = true;
|
||
ViewState["PKCIERRE"] = cierre;
|
||
|
||
GuardarEventoBitacora(
|
||
Session["LOGIN"].ToString(),
|
||
AccionBitacora.INSERT.ToString(),
|
||
MensajesBitacora.IngresarRegistro + ": Se ha ingresado el registro: " + " : DocumentoFinanciamiento" + txtFinanciamiento.Text + " : DocumentoInversion" + txtInversion.Text + " : DocumentoPreInversion" + txtPreInversion.Text +
|
||
" MontoCapitalizacion: " + txtMontoCapitalizacion.Value + " FechaCapitalizacion: " + txtFechaCapitalizacion.Value + " FechaEntrega: " +
|
||
txtFechaEntrega.Value + " FechaFinalizacion: " + txtFechaFinalizacion.Value + " FechaInicio: " + txtFechaInicio.Value,
|
||
"wfrCierre.aspx");
|
||
}
|
||
}
|
||
else if (strModo == "Modifica" && bool.Parse(ViewState["PUEDEMODIFICAR"].ToString()) == true)
|
||
{
|
||
objCierreBL.objCierreEL.PK = Int32.Parse(ViewState["PKCIERRE"].ToString());
|
||
|
||
if (objCierreBL.actualizarCierre())
|
||
{
|
||
blnEjecutado = true;
|
||
|
||
GuardarEventoBitacora(
|
||
Session["LOGIN"].ToString(),
|
||
AccionBitacora.UPDATE.ToString(),
|
||
MensajesBitacora.ModificarRegistro + ": Se ha modificado el registro: " + " : DocumentoFinanciamiento" + txtFinanciamiento.Text + " : DocumentoInversion" + txtInversion.Text + " : DocumentoPreInversion" + txtPreInversion.Text +
|
||
" MontoCapitalizacion: " + Decimal.Parse(txtMontoCapitalizacion.Value).ToString("###,###,###.#0") + " FechaCapitalizacion: " + txtFechaCapitalizacion.Value + " FechaEntrega: " +
|
||
txtFechaEntrega.Value + " FechaFinalizacion: " + txtFechaFinalizacion.Value + " FechaInicio: " + txtFechaInicio.Value,
|
||
"wfrCierre.aspx");
|
||
}
|
||
}
|
||
}
|
||
else
|
||
MensajeAdvertencia("Debe seleccionar un proyecto antes de guardar la información");
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
blnEjecutado = false;
|
||
throw ex;
|
||
}
|
||
return blnEjecutado;
|
||
}
|
||
|
||
/// <summary>
|
||
/// guarda y modifica registros en la tabla.
|
||
/// </summary>
|
||
/// <returns></returns>
|
||
private bool GuardarDatosLeccion() //M1
|
||
{
|
||
bool blnEjecutado = false;
|
||
|
||
try
|
||
{
|
||
string strModo = string.Empty;
|
||
|
||
if (ddlProyecto.SelectedIndex > 0 && ViewState["PKCIERRE"].ToString() != "-1")
|
||
{
|
||
strModo = ViewState["MODOLECCION"].ToString();
|
||
|
||
objLeccionBL = new LeccionBL();
|
||
objLeccionBL.objLeccionEL.Evento = txtEvento.Text;
|
||
objLeccionBL.objLeccionEL.Descripcion = txtDescripcion.Text;
|
||
objLeccionBL.objLeccionEL.Cierre = Int32.Parse(ViewState["PKCIERRE"].ToString());
|
||
|
||
if (strModo == "Nuevo")
|
||
{
|
||
int leccion = objLeccionBL.insertarLeccion();
|
||
{
|
||
blnEjecutado = true;
|
||
|
||
GuardarEventoBitacora(
|
||
Session["LOGIN"].ToString(),
|
||
AccionBitacora.INSERT.ToString(),
|
||
MensajesBitacora.IngresarRegistro + ": Se ha ingresado el registro en Leccion: " + " : Evento" + txtEvento.Text + " : Descripcion" + txtDescripcion.Text,
|
||
"wfrCierre.aspx");
|
||
}
|
||
}
|
||
else if (strModo == "Modifica" && bool.Parse(ViewState["PUEDEMODIFICAR"].ToString()) == true)
|
||
{
|
||
objLeccionBL.objLeccionEL.PK = Convert.ToInt32(ViewState["PKLECION"].ToString());
|
||
if (objLeccionBL.actualizarLeccion())
|
||
{
|
||
blnEjecutado = true;
|
||
|
||
GuardarEventoBitacora(
|
||
Session["LOGIN"].ToString(),
|
||
AccionBitacora.UPDATE.ToString(),
|
||
MensajesBitacora.ModificarRegistro +
|
||
MensajesBitacora.IngresarRegistro + ": Se ha modificado el registro en Leccion: " + " : Evento" + txtEvento.Text + " : Descripcion" + txtDescripcion.Text,
|
||
"wfrCierre.aspx");
|
||
}
|
||
}
|
||
}
|
||
else
|
||
MensajeAdvertencia("Debe seleccionar un proyecto antes de guardar la información");
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
blnEjecutado = false;
|
||
throw ex;
|
||
}
|
||
return blnEjecutado;
|
||
}
|
||
|
||
private void eliminarComentario(int p_intPKIndice) //M2
|
||
{
|
||
try
|
||
{
|
||
objComentarioBL = new ComentarioBL();
|
||
|
||
objComentarioBL.objComentarioEL.PK = p_intPKIndice;
|
||
objComentarioBL.actualizaEstadoComentario();
|
||
|
||
GuardarEventoBitacora(
|
||
Session["LOGIN"].ToString(),
|
||
AccionBitacora.DELETE.ToString(),
|
||
MensajesBitacora.EliminarRegistro + ": Se ha eliminado el registro: " + p_intPKIndice + " de Comentario.",
|
||
"wfrCierre.aspx");
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
MensajeError("Error en R5M2", ex);
|
||
}
|
||
|
||
}
|
||
|
||
/// <summary>
|
||
/// guarda y modifica registros en la tabla.
|
||
/// </summary>
|
||
/// <returns></returns>
|
||
private bool GuardarDatosComentario() //M3
|
||
{
|
||
bool blnEjecutado = false;
|
||
|
||
try
|
||
{
|
||
if (ddlProyecto.SelectedIndex > 0)
|
||
{
|
||
if (!txtComentario.Text.Equals(""))
|
||
{
|
||
objComentarioBL = new ComentarioBL();
|
||
objComentarioBL.objComentarioEL.Comentario = txtComentario.Text;
|
||
objComentarioBL.objComentarioEL.Fecha = txtFecha.Value != "" ? Convert.ToDateTime(txtFecha.Value) : DateTime.Now;
|
||
objComentarioBL.objComentarioEL.Cierre = Int32.Parse(ViewState["PKCIERRE"].ToString());
|
||
|
||
int observ = objComentarioBL.insertarComentario();
|
||
{
|
||
blnEjecutado = true;
|
||
|
||
GuardarEventoBitacora(
|
||
Session["LOGIN"].ToString(),
|
||
AccionBitacora.INSERT.ToString(),
|
||
MensajesBitacora.IngresarRegistro + ": Se ha ingresado el registro en Observación: " + " : Observación" + txtComentario.Text + " : Fecha" + objComentarioBL.objComentarioEL.Fecha,
|
||
"wfrCierre.aspx");
|
||
}
|
||
}
|
||
else
|
||
MensajeAdvertencia("Debe escribir una observación antes de guardar.");
|
||
}
|
||
else
|
||
MensajeAdvertencia("Debe seleccionar un proyecto antes de guardar la observación");
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
blnEjecutado = false;
|
||
throw ex;
|
||
}
|
||
return blnEjecutado;
|
||
}
|
||
|
||
private void eliminarLeccion(int p_intPKIndice) //M4
|
||
{
|
||
try
|
||
{
|
||
objLeccionBL = new LeccionBL();
|
||
|
||
objLeccionBL.objLeccionEL.PK = p_intPKIndice;
|
||
objLeccionBL.actualizaEstadoLeccion();
|
||
|
||
GuardarEventoBitacora(
|
||
Session["LOGIN"].ToString(),
|
||
AccionBitacora.DELETE.ToString(),
|
||
MensajesBitacora.EliminarRegistro + ": Se ha eliminado el registro: " + p_intPKIndice + " de Leccion.",
|
||
"wfrCierre.aspx");
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
MensajeError("Error en R5M4", ex);
|
||
}
|
||
}
|
||
|
||
private void cambiaEstadoObjetivo(int p_intPkIndice, bool p_cumplido, int p_numero,
|
||
string p_descripcion) //M5
|
||
{
|
||
try
|
||
{
|
||
objObjetivoEspecificoBL = new ObjetivoEspecificoBL();
|
||
|
||
objObjetivoEspecificoBL.objObjetivoEspecificoEL.PK = p_intPkIndice;
|
||
objObjetivoEspecificoBL.objObjetivoEspecificoEL.Cumplido = p_cumplido;
|
||
objObjetivoEspecificoBL.objObjetivoEspecificoEL.Numero = p_numero;
|
||
objObjetivoEspecificoBL.objObjetivoEspecificoEL.Descripcion = p_descripcion;
|
||
objObjetivoEspecificoBL.objObjetivoEspecificoEL.Proyecto = Convert.ToInt32(ddlProyecto.SelectedValue);
|
||
objObjetivoEspecificoBL.actualizarObjetivo();
|
||
|
||
GuardarEventoBitacora(
|
||
Session["LOGIN"].ToString(),
|
||
AccionBitacora.UPDATE.ToString(),
|
||
MensajesBitacora.IngresarRegistro + ": Se ha modificado el registro de Objetivo Específico, PK : " + p_intPkIndice + ", Cumplido: " + p_cumplido,
|
||
"wfrCierre.aspx");
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
MensajeError("Error en R5M5", ex);
|
||
}
|
||
}
|
||
|
||
#endregion
|
||
|
||
#region Metodos Datos a Controles (R6)
|
||
|
||
private void llenarDDLProyecto() //M0
|
||
{
|
||
try
|
||
{
|
||
//Instancia el objeto
|
||
objProyectoBL = new ProyectoBL();
|
||
|
||
objProyectoBL.objProyectoEL.PK = 0;
|
||
objProyectoBL.objProyectoEL.ASTATE = true;
|
||
objProyectoBL.objProyectoEL.CodigoAcceso = Session["CODIGOACCESO"].ToString();
|
||
|
||
//Carga la información en un dataset
|
||
DataSet dsProyecto = objProyectoBL.getProyectos();
|
||
|
||
ddlListaProyectos(dsProyecto, ddlProyecto);
|
||
ddlProyecto.Attributes["style"] = "width: 90%; max-width: 90%";
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
MensajeError("Error en R6M0", ex);
|
||
}
|
||
}
|
||
|
||
private void llenarGrvLeccion() //M1
|
||
{
|
||
try
|
||
{
|
||
objLeccionBL = new LeccionBL();
|
||
objLeccionBL.objLeccionEL.Cierre = Int32.Parse(ViewState["PKCIERRE"].ToString());
|
||
|
||
DataSet dsLeccion = objLeccionBL.getLeccion();
|
||
|
||
detalleGRVDatos(dsLeccion, grvLeccion);
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
MensajeError("Error en R6M1", ex);
|
||
}
|
||
}
|
||
|
||
private void llenarGrvComentario() //M2
|
||
{
|
||
try
|
||
{
|
||
objComentarioBL = new ComentarioBL();
|
||
objComentarioBL.objComentarioEL.Cierre = Int32.Parse(ViewState["PKCIERRE"].ToString());
|
||
|
||
DataSet dsComentario = objComentarioBL.getComentario();
|
||
|
||
detalleGRVDatos(dsComentario, grvComentario);
|
||
|
||
for (int i = 0; i <= grvComentario.Rows.Count - 1; ++i)
|
||
{
|
||
grvComentario.Rows[i].Cells[2].Text = Convert.ToDateTime(grvComentario.Rows[i].Cells[2].Text).ToString("dd/MM/yyyy");
|
||
}
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
MensajeError("Error en R6M2", ex);
|
||
}
|
||
}
|
||
|
||
private void llenarOtrosDatos() //M3
|
||
{
|
||
try
|
||
{
|
||
objCierreBL = new CierreBL();
|
||
objCierreBL.objCierreEL.Proyecto = Convert.ToInt32(ddlProyecto.SelectedValue);
|
||
|
||
DataSet dsCierre = objCierreBL.getOtrosDatos();
|
||
|
||
if (dsCierre.Tables[0].Rows.Count != 0)
|
||
{
|
||
if (dsCierre.Tables[0].Rows[0]["ENCARGADOINFORMACIONGENERAL"].ToString() != "")
|
||
txtEncargadoProyecto.Text = dsCierre.Tables[0].Rows[0]["ENCARGADOINFORMACIONGENERAL"].ToString();
|
||
if (dsCierre.Tables[0].Rows[0]["FECHAINICIO"].ToString() != "")
|
||
txtFechaInicio.Value = Convert.ToDateTime(dsCierre.Tables[0].Rows[0]["FECHAINICIO"].ToString()).Date.ToString("dd/MM/yyyy");
|
||
if (dsCierre.Tables[0].Rows[0]["MONTOFINANCIAMIENTO"].ToString() != "")
|
||
txtCostoTotal.Value = Decimal.Parse(dsCierre.Tables[0].Rows[0]["MONTOFINANCIAMIENTO"].ToString()).ToString("###,###,###,###.#0");
|
||
if (dsCierre.Tables[0].Rows[0]["FECHAFIN"].ToString() != "")
|
||
{
|
||
txtFechaFinalizacion.Value = Convert.ToDateTime(dsCierre.Tables[0].Rows[0]["FECHAFIN"].ToString()).Date.ToString("dd/MM/yyyy");
|
||
txtFechaEntrega.Value = Convert.ToDateTime(dsCierre.Tables[0].Rows[0]["FECHAFIN"].ToString()).Date.ToString("dd/MM/yyyy");
|
||
|
||
}
|
||
|
||
}
|
||
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
MensajeError("Error en R6M3", ex);
|
||
}
|
||
}
|
||
|
||
private void llenarTxtCostoTotalProyecto() //M4
|
||
{
|
||
try
|
||
{
|
||
objFinanciamientoBL = new FinanciamientoBL();
|
||
objFinanciamientoBL.objFinanciamientoEL.Proyecto = Int32.Parse(ddlProyecto.SelectedValue);
|
||
|
||
DataSet dsFinanciamiento = objFinanciamientoBL.getDetalle();
|
||
|
||
if (dsFinanciamiento.Tables[0].Rows.Count != 0)
|
||
{
|
||
decimal total = 0;
|
||
for (int r = 0; r < dsFinanciamiento.Tables[0].Rows.Count; r++)
|
||
{
|
||
total += Decimal.Parse(dsFinanciamiento.Tables[0].Rows[r]["MONTOFINANCIAMIENTO"].ToString());
|
||
}
|
||
txtCostoTotal.Value = Decimal.Parse(total.ToString()).ToString("###,###,###,###.#0");
|
||
}
|
||
else
|
||
txtCostoTotal.Value = null;
|
||
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
MensajeError("Error en R6M4", ex);
|
||
}
|
||
}
|
||
|
||
private DataSet llenarGrvObjetivosProyecto(bool cumplido) //M5
|
||
{
|
||
DataSet dsObjetivos = new DataSet();
|
||
try
|
||
{
|
||
objObjetivoEspecificoBL = new ObjetivoEspecificoBL();
|
||
objObjetivoEspecificoBL.objObjetivoEspecificoEL.Proyecto = Int32.Parse(ddlProyecto.SelectedValue);
|
||
|
||
dsObjetivos = objObjetivoEspecificoBL.getObjetivoEspecifico();
|
||
|
||
if (dsObjetivos.Tables[0].Rows.Count != 0)
|
||
{
|
||
for (int r = 0; r < dsObjetivos.Tables[0].Rows.Count; r++)
|
||
{
|
||
if (Convert.ToBoolean(dsObjetivos.Tables[0].Rows[r]["CUMPLIDOOBJETIVOESPECIFICO"].ToString()) != cumplido)
|
||
dsObjetivos.Tables[0].Rows[r].Delete();
|
||
}
|
||
}
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
MensajeError("Error en R6M5", ex);
|
||
}
|
||
|
||
return dsObjetivos;
|
||
}
|
||
|
||
private void mostrarDatos() //M6
|
||
{
|
||
try
|
||
{
|
||
|
||
ViewState["MODO"] = "Nuevo";
|
||
objCierreBL = new CierreBL();
|
||
objCierreBL.objCierreEL.Proyecto = Convert.ToInt32(ddlProyecto.SelectedValue);
|
||
|
||
DataSet dsCierre = objCierreBL.getCierre();
|
||
|
||
llenarOtrosDatos();
|
||
|
||
if (dsCierre.Tables[0].Rows.Count != 0)
|
||
{
|
||
ViewState["MODO"] = "Modifica";
|
||
ViewState["PKCIERRE"] = Convert.ToInt32(dsCierre.Tables[0].Rows[0]["PKCIERRE"].ToString());
|
||
txtPreInversion.Text = dsCierre.Tables[0].Rows[0]["DOCUMENTOPREINVERSIONCIERRE"].ToString();
|
||
txtFinanciamiento.Text = dsCierre.Tables[0].Rows[0]["DOCUMENTOFINANCIAMIENTOCIERRE"].ToString();
|
||
txtInversion.Text = dsCierre.Tables[0].Rows[0]["DOCUMENTOINVERSIONCIERRE"].ToString();
|
||
txtFechaCapitalizacion.Value = Convert.ToDateTime(dsCierre.Tables[0].Rows[0]["FECHACAPITALIZACIONCIERRE"].ToString()).Date.ToString("dd/MM/yyyy");
|
||
txtMontoCapitalizacion.Value = Decimal.Parse(dsCierre.Tables[0].Rows[0]["MONTOCAPITALIZACIONCIERRE"].ToString()).ToString("###,###,###,###.#0");
|
||
}
|
||
else
|
||
{
|
||
ViewState["PKCIERRE"] = -1;
|
||
}
|
||
|
||
llenarGrvLeccion();
|
||
llenarGrvComentario();
|
||
llenarGrvObjetivos();
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
MensajeError("Error en R6M6", ex);
|
||
}
|
||
}
|
||
|
||
private void llenarGrvObjetivos() //M7
|
||
{
|
||
try
|
||
{
|
||
detalleGRVDatos(llenarGrvObjetivosProyecto(false), grvObjNoCumplidos);
|
||
if (grvObjNoCumplidos.HeaderRow != null)
|
||
{
|
||
//Invisibiliza la fila de t[itulo
|
||
grvObjNoCumplidos.HeaderRow.Cells[1].Visible = false;
|
||
grvObjNoCumplidos.HeaderRow.Cells[2].Text = " # ";
|
||
grvObjNoCumplidos.HeaderRow.Cells[3].Text = "OBJETIVO";
|
||
grvObjNoCumplidos.HeaderRow.Cells[4].Visible = false;
|
||
grvObjNoCumplidos.HeaderRow.Cells[5].Visible = false;
|
||
grvObjNoCumplidos.HeaderRow.Cells[6].Visible = false;
|
||
|
||
//Invisibiliza las columnas que no se ocupan
|
||
for (int i = 0; i <= grvObjNoCumplidos.Rows.Count - 1; ++i)
|
||
{
|
||
grvObjNoCumplidos.Rows[i].Cells[1].Visible = false;
|
||
grvObjNoCumplidos.Rows[i].Cells[4].Visible = false;
|
||
grvObjNoCumplidos.Rows[i].Cells[5].Visible = false;
|
||
grvObjNoCumplidos.Rows[i].Cells[6].Visible = false;
|
||
}
|
||
}
|
||
|
||
detalleGRVDatos(llenarGrvObjetivosProyecto(true), grvObjCumplidos);
|
||
if (grvObjCumplidos.HeaderRow != null)
|
||
{
|
||
//Invisibiliza la fila de t[itulo
|
||
grvObjCumplidos.HeaderRow.Cells[1].Visible = false;
|
||
grvObjCumplidos.HeaderRow.Cells[2].Text = " # ";
|
||
grvObjCumplidos.HeaderRow.Cells[3].Text = "OBJETIVO";
|
||
grvObjCumplidos.HeaderRow.Cells[4].Visible = false;
|
||
grvObjCumplidos.HeaderRow.Cells[5].Visible = false;
|
||
grvObjCumplidos.HeaderRow.Cells[6].Visible = false;
|
||
|
||
//Invisibiliza las columnas que no se ocupan
|
||
for (int i = 0; i <= grvObjCumplidos.Rows.Count - 1; ++i)
|
||
{
|
||
grvObjCumplidos.Rows[i].Cells[1].Visible = false;
|
||
grvObjCumplidos.Rows[i].Cells[4].Visible = false;
|
||
grvObjCumplidos.Rows[i].Cells[5].Visible = false;
|
||
grvObjCumplidos.Rows[i].Cells[6].Visible = false;
|
||
}
|
||
}
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
MensajeError("Error en R6M7", ex);
|
||
}
|
||
}
|
||
#endregion
|
||
|
||
|
||
} |