1366 lines
No EOL
54 KiB
C#
1366 lines
No EOL
54 KiB
C#
/*===========================================================================================================================
|
||
* Instituto Costarricense de Acueductos y Alcantarillados. - 2015
|
||
* Formularios para Proyectos de Inversión
|
||
* Nombre de la Pantalla: wfrFinancimiento.aspx
|
||
*
|
||
* Explicación de los contenidos del archivo
|
||
*===========================================================================================================================
|
||
* HISTORIAL
|
||
*
|
||
* PERSONA DIA – MES - AÑO DESCRIPCIÓN
|
||
* Esteban Gutierrez Rapso 23 – 11 - 2016 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.AGP;
|
||
using AyABL.ADM;
|
||
using AyABL.FNP;
|
||
public partial class webforms_FNP_wfrFinanciamiento : 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);
|
||
|
||
construirgrvRecursos();
|
||
construirgrvEndeudamiento();
|
||
construirgrvDetalle();
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
MensajeError("Error en R0M1", ex);
|
||
}
|
||
}
|
||
|
||
#endregion
|
||
|
||
#region Variables (R1)
|
||
|
||
GridView grvRecursosTemp, grvEndeudamientoTemp, grvDetalleTemp;
|
||
|
||
|
||
FuenteFinanciamientoBL objFuenteFinanciamientoBL;
|
||
RecursoBL objRecursoBL;
|
||
FinanciamientoBL objFinanciamientoBL;
|
||
EndeudamientoBL objEndeudamientoBL;
|
||
ProyectoBL objProyectoBL;
|
||
|
||
#endregion
|
||
|
||
#region Eventos Formulario (R2)
|
||
|
||
protected void Page_Load(object sender, EventArgs e) //M0
|
||
{
|
||
try
|
||
{
|
||
if ((!IsPostBack) && (Session.Count > 0))
|
||
{
|
||
|
||
ComandosxMenu();
|
||
llenarDDLProyecto();
|
||
llenarDDLTipoRecurso();
|
||
llenarDDLRecurso();
|
||
llenarDDLAnio();
|
||
|
||
if (Session["PKPROYECTO"] != null)
|
||
{
|
||
ddlProyecto.SelectedValue = Session["PKPROYECTO"].ToString();
|
||
|
||
ddlProyecto_SelectedIndexChanged(null, null);
|
||
}
|
||
|
||
llenarGRVRecursos();
|
||
llenarGRVEndeudamiento();
|
||
llenarGRVDetalle();
|
||
|
||
llenarDDLTipoFuente();
|
||
llenarDDLFuenteFinanciamiento();
|
||
llenarDDLDesembolsoI();
|
||
llenarDDLDesembolsoF();
|
||
|
||
mostrarFilaTabla(1);
|
||
mostrarDetalleFinanciamiento(1);
|
||
}
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
MensajeError("Error en R2M0", ex);
|
||
}
|
||
}
|
||
|
||
#endregion
|
||
|
||
#region Eventos Controles Web (R3)
|
||
|
||
protected void btnGuardarInversion_Click(object sender, EventArgs e) //M0
|
||
{
|
||
try
|
||
{
|
||
if (GuardarInversion())
|
||
{
|
||
MensajeInformativo("El registro fue almacenado");
|
||
}
|
||
else
|
||
{
|
||
MensajeError("El registro no fue almacenado, verifique", null);
|
||
}
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
MensajeError("Error en R3M0", ex);
|
||
General.ReportarError(ex, Session["LOGIN"].ToString());
|
||
}
|
||
}
|
||
|
||
protected void btnEliminarInversion_Click(object sender, EventArgs e) //M1
|
||
{
|
||
try
|
||
{
|
||
if (ViewState["PkFinanciamiento"] != null)
|
||
{
|
||
int intPkIndice = Int32.Parse(ViewState["PkFinanciamiento"].ToString());
|
||
eliminarInversion(intPkIndice);
|
||
|
||
llenarGRVDetalle();
|
||
limpiarInversion();
|
||
}
|
||
else
|
||
MensajeAdvertencia("Debe seleccionar un registro");
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
MensajeError("Error en R3M1", ex);
|
||
General.ReportarError(ex, Session["LOGIN"].ToString());
|
||
}
|
||
}
|
||
|
||
protected void ddlTipoRecurso_SelectedIndexChanged(object sender, EventArgs e) //M2
|
||
{
|
||
llenarDDLRecurso();
|
||
}
|
||
|
||
protected void ddlAnio_SelectedIndexChanged(object sender, EventArgs e) //M3
|
||
{
|
||
|
||
}
|
||
|
||
protected void btnNuevoEndeudamiento_Click(object sender, EventArgs e) //M5
|
||
{
|
||
try
|
||
{
|
||
ddlFuenteFinanciamiento.Focus();
|
||
mostrarFilaTabla(2);
|
||
limpiarEndeudamiento();
|
||
|
||
btnGuardar.Visible = true;
|
||
btnModificar.Visible = false;
|
||
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
MensajeError("Error en R3M5", ex);
|
||
}
|
||
}
|
||
|
||
protected void btnAnterior_Click(object sender, EventArgs e) //M6
|
||
{
|
||
try
|
||
{
|
||
llenarGRVEndeudamiento();
|
||
mostrarFilaTabla(1);
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
MensajeError("Error en R3M6", ex);
|
||
}
|
||
}
|
||
|
||
protected void ddlProyecto_SelectedIndexChanged(object sender, EventArgs e) //M7
|
||
{
|
||
try
|
||
{
|
||
mostrarDatos();
|
||
|
||
Session["PKPROYECTO"] = ddlProyecto.SelectedValue;
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
MensajeError("Error en R3M7", ex);
|
||
}
|
||
}
|
||
|
||
protected void btnBuscar_Click(object sender, EventArgs e) //M8
|
||
{
|
||
try
|
||
{
|
||
mostrarDatos();
|
||
llenarGRVDetalle();
|
||
mostrarDetalleFinanciamiento(1);
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
MensajeError("Error en R3M8", ex);
|
||
}
|
||
}
|
||
|
||
protected void ddlTipoFuente_SelectedIndexChanged(object sender, EventArgs e) //M9
|
||
{
|
||
try
|
||
{
|
||
llenarDDLFuenteFinanciamiento();
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
MensajeError("Error en R3M9", ex);
|
||
}
|
||
}
|
||
|
||
protected void grvEndeudamiento_RowCommand(object sender, GridViewCommandEventArgs e) //M10
|
||
{
|
||
try
|
||
{
|
||
if (e.CommandName == "editar")
|
||
{
|
||
//Extrae la fila seleccionada del GridView
|
||
int i = Convert.ToInt32(e.CommandArgument);
|
||
GridViewRow selectedRow = grvEndeudamiento.Rows[i];
|
||
|
||
int intPKIndice = Convert.ToInt32(selectedRow.Cells[2].Text);
|
||
|
||
mostrarFilaTabla(2);
|
||
|
||
if (bool.Parse(ViewState["PUEDEMODIFICAR"].ToString()) == true)
|
||
{
|
||
btnModificar.Visible = true;
|
||
btnGuardar.Visible = false;
|
||
}
|
||
|
||
ViewState["PkEndeudamiento"] = intPKIndice;
|
||
|
||
mostrarDatos(intPKIndice);
|
||
}
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
MensajeError("Error en R3M10", ex);
|
||
}
|
||
}
|
||
|
||
protected void btnEliminarEndeudamiento_Click(object sender, EventArgs e) //M11
|
||
{
|
||
try
|
||
{
|
||
// recorro el grid
|
||
foreach (GridViewRow row in grvEndeudamiento.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[2].Text);
|
||
eliminarEndeudamiento(intPkIndice);
|
||
}
|
||
}
|
||
}
|
||
|
||
llenarGRVEndeudamiento();
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
MensajeError("Error en R3M11", ex);
|
||
}
|
||
}
|
||
|
||
protected void grvDetalle_RowCommand(object sender, GridViewCommandEventArgs e) //M12
|
||
{
|
||
try
|
||
{
|
||
if (e.CommandName == "editar")
|
||
{
|
||
int i = Convert.ToInt32(e.CommandArgument);
|
||
GridViewRow selectedRow = grvDetalle.Rows[i];
|
||
ViewState["PkFinanciamiento"] = Convert.ToInt32(selectedRow.Cells[1].Text);
|
||
|
||
mostrarDetalle();
|
||
|
||
}
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
MensajeError("Error en R3M12", ex);
|
||
}
|
||
}
|
||
|
||
protected void btnDetalle_Click(object sender, EventArgs e) //M13
|
||
{
|
||
try
|
||
{
|
||
mostrarDetalleFinanciamiento(2);
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
MensajeError("Error en R3M13", ex);
|
||
}
|
||
}
|
||
|
||
protected void btnGuardar_Click(object sender, EventArgs e) //M14
|
||
{
|
||
try
|
||
{
|
||
if (GuardarEndeudamiento())
|
||
{
|
||
MensajeInformativo("El registro fue almacenado");
|
||
|
||
mostrarFilaTabla(1);
|
||
}
|
||
else
|
||
{
|
||
MensajeError("El registro no fue almacenado, verifique", null);
|
||
}
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
MensajeError("Error en R3M14", ex);
|
||
General.ReportarError(ex, Session["LOGIN"].ToString());
|
||
}
|
||
}
|
||
|
||
protected void btnModificar_Click(object sender, EventArgs e) //M15
|
||
{
|
||
try
|
||
{
|
||
if (modificarEndeudameinto())
|
||
{
|
||
MensajeInformativo("El registro fue modificado");
|
||
|
||
mostrarFilaTabla(1);
|
||
}
|
||
else
|
||
{
|
||
MensajeError("El registro no fue modificado, verifique", null);
|
||
}
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
MensajeError("Error en R3M14", ex);
|
||
General.ReportarError(ex, Session["LOGIN"].ToString());
|
||
}
|
||
}
|
||
|
||
#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":
|
||
btnNuevoEndeudamiento.Visible = true;
|
||
break;
|
||
case "MODIFICA":
|
||
ViewState["PUEDEMODIFICAR"] = true;
|
||
btnGuardarInversion.Visible = true;
|
||
break;
|
||
case "ELIMINAR":
|
||
btnEliminarInversion.Visible = true;
|
||
btnEliminarEndeudamiento.Visible = true;
|
||
break;
|
||
}
|
||
}
|
||
}
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
MensajeError("Error en R4M0", ex);
|
||
}
|
||
}
|
||
|
||
private void iniciarTablaObjetivos() //M1
|
||
{
|
||
DataTable dt = new DataTable(); //tabla local
|
||
|
||
//Se crean los campos en el datatable
|
||
DataColumn dcPK = dt.Columns.Add("PKOBJETIVOESPECIFICO", typeof(Int32));
|
||
DataColumn dcNumero = dt.Columns.Add("NUMEROOBJETIVOESPECIFICO", typeof(string));
|
||
DataColumn dcDesc = dt.Columns.Add("DESCRIPCIONOBJETIVOESPECIFICO", typeof(string));
|
||
|
||
ViewState["OBJETIVOS"] = dt;
|
||
}
|
||
|
||
public static void ddlListaDatos(DataSet p_dsDatos, DropDownList p_ddlListado, string p_strSeleccion) //M2
|
||
{
|
||
try
|
||
{
|
||
p_ddlListado.DataSource = p_dsDatos;
|
||
p_ddlListado.DataTextField = p_dsDatos.Tables[0].Columns[2].ColumnName;
|
||
p_ddlListado.DataValueField = p_dsDatos.Tables[0].Columns[0].ColumnName;
|
||
p_ddlListado.DataBind();
|
||
|
||
p_ddlListado.Items.Insert(0, new ListItem(p_strSeleccion, "-1"));
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
throw ex;
|
||
}
|
||
}
|
||
|
||
private void construirgrvRecursos() //M3
|
||
{
|
||
try
|
||
{
|
||
grvRecursosTemp = (GridView)divDatosInferiores.FindControl("grvRecursos");
|
||
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
MensajeError("Error en R4M3", ex);
|
||
}
|
||
}
|
||
|
||
private void construirgrvEndeudamiento() //M4
|
||
{
|
||
try
|
||
{
|
||
grvEndeudamientoTemp = (GridView)divDatosInferiores.FindControl("grvEndeudamiento");
|
||
|
||
GridViewBoundField bdfPkEndeudamiento = new GridViewBoundField("PKENDEUDAMIENTO", "PK", false, false, false);
|
||
GridViewBoundField bdfFuenteFinanciamiento = new GridViewBoundField("NOMBREFUENTEFINANCIAMIENTO", "FUENTE", false, false, true);
|
||
GridViewBoundField bdfMonto = new GridViewBoundField("MONTOENDEUDAMIENTO", "MONTO", false, false, true);
|
||
GridViewBoundField bdfPeriodoGracia = new GridViewBoundField("PERIODOGRACIAENDEUDAMIENTO", "PERIODO GRACIA", false, false, true);
|
||
GridViewBoundField bdfPlazo = new GridViewBoundField("PLAZOENDEUDAMIENTO", "PLAZO", false, false, true);
|
||
GridViewBoundField bdfDesembolsoInicio = new GridViewBoundField("DESEMBOLSOINICIOENDEUDAMIENTO", "DESEMBOLSO INICIAL", false, false, true);
|
||
GridViewBoundField bdfDesembolsoFin = new GridViewBoundField("DESEMBOLSOFINENDEUDAMIENTO", "DESEMBOLSO FINAL", false, false, true);
|
||
GridViewBoundField bdfTipoCambio = new GridViewBoundField("TIPOCAMBIOCONTRATOENDEUDAMIENTO", "TIPO CAMBIO", false, false, true);
|
||
GridViewBoundField bdfFechaContrato = new GridViewBoundField("FECHACONTRATOENDEUDAMIENTO", "FECHA DE CONTRATO", false, true, true);
|
||
GridViewBoundField bdfSituacionActual = new GridViewBoundField("SITUACIONACTUALENDEUDAMIENTO", "SITUACION ACTUAL", false, false, true);
|
||
GridViewBoundField bdfTasa = new GridViewBoundField("TASAENDEUDAMIENTO", "TASA INTERES", false, false, true);
|
||
|
||
grvEndeudamientoTemp.Columns.Add(bdfPkEndeudamiento);
|
||
grvEndeudamientoTemp.Columns.Add(bdfFuenteFinanciamiento);
|
||
grvEndeudamientoTemp.Columns.Add(bdfMonto);
|
||
grvEndeudamientoTemp.Columns.Add(bdfPeriodoGracia);
|
||
grvEndeudamientoTemp.Columns.Add(bdfPlazo);
|
||
grvEndeudamientoTemp.Columns.Add(bdfDesembolsoInicio);
|
||
grvEndeudamientoTemp.Columns.Add(bdfDesembolsoFin);
|
||
grvEndeudamientoTemp.Columns.Add(bdfTipoCambio);
|
||
grvEndeudamientoTemp.Columns.Add(bdfFechaContrato);
|
||
grvEndeudamientoTemp.Columns.Add(bdfSituacionActual);
|
||
grvEndeudamientoTemp.Columns.Add(bdfTasa);
|
||
|
||
bdfMonto.DataFormatString = "{0:N2}";
|
||
bdfTipoCambio.DataFormatString = "{0:N2}";
|
||
|
||
grvEndeudamientoTemp.Columns[0].ItemStyle.Width = 15;
|
||
grvEndeudamientoTemp.Columns[1].ItemStyle.Width = 25;
|
||
grvEndeudamientoTemp.Columns[3].ItemStyle.Width = 300;
|
||
grvEndeudamientoTemp.Columns[4].ItemStyle.Width = 110;
|
||
grvEndeudamientoTemp.Columns[5].ItemStyle.Width = 50;
|
||
grvEndeudamientoTemp.Columns[6].ItemStyle.Width = 50;
|
||
grvEndeudamientoTemp.Columns[7].ItemStyle.Width = 50;
|
||
grvEndeudamientoTemp.Columns[8].ItemStyle.Width = 50;
|
||
grvEndeudamientoTemp.Columns[9].ItemStyle.Width = 50;
|
||
grvEndeudamientoTemp.Columns[10].ItemStyle.Width = 50;
|
||
grvEndeudamientoTemp.Columns[11].ItemStyle.Width = 50;
|
||
grvEndeudamientoTemp.Columns[12].ItemStyle.Width = 50;
|
||
|
||
grvEndeudamientoTemp.Columns[4].ItemStyle.HorizontalAlign = HorizontalAlign.Right;
|
||
grvEndeudamientoTemp.Columns[5].ItemStyle.HorizontalAlign = HorizontalAlign.Center;
|
||
grvEndeudamientoTemp.Columns[6].ItemStyle.HorizontalAlign = HorizontalAlign.Center;
|
||
grvEndeudamientoTemp.Columns[7].ItemStyle.HorizontalAlign = HorizontalAlign.Center;
|
||
grvEndeudamientoTemp.Columns[8].ItemStyle.HorizontalAlign = HorizontalAlign.Center;
|
||
grvEndeudamientoTemp.Columns[9].ItemStyle.HorizontalAlign = HorizontalAlign.Center;
|
||
grvEndeudamientoTemp.Columns[10].ItemStyle.HorizontalAlign = HorizontalAlign.Center;
|
||
grvEndeudamientoTemp.Columns[11].ItemStyle.HorizontalAlign = HorizontalAlign.Center;
|
||
grvEndeudamientoTemp.Columns[12].ItemStyle.HorizontalAlign = HorizontalAlign.Center;
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
MensajeError("Error en R4M4", ex);
|
||
}
|
||
}
|
||
|
||
public static void detalleGRVDatos(DataSet p_dsDatos, GridView p_grvGridView) //M5
|
||
{
|
||
try
|
||
{
|
||
p_grvGridView.ShowHeader = true;
|
||
p_grvGridView.DataSource = p_dsDatos;
|
||
p_grvGridView.DataBind();
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
throw ex;
|
||
}
|
||
}
|
||
|
||
private void mostrarFilaTabla(int p_intFila) //M6
|
||
{
|
||
try
|
||
{
|
||
divListado.Visible = false;
|
||
divDatos.Visible = false;
|
||
|
||
switch (p_intFila)
|
||
{
|
||
case 1:
|
||
llenarGRVEndeudamiento();
|
||
divListado.Visible = true;
|
||
ViewState["MODO"] = "Nuevo";
|
||
break;
|
||
case 2:
|
||
divDatos.Visible = true;
|
||
ViewState["MODO"] = "Modifica";
|
||
break;
|
||
}
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
MensajeError("Error en R4M6", ex);
|
||
}
|
||
}
|
||
|
||
private bool financiamientoDuplicado() //M7
|
||
{
|
||
bool blnDuplicado = true;
|
||
|
||
try
|
||
{
|
||
objFinanciamientoBL.objFinanciamientoEL.Proyecto = Int32.Parse(ddlProyecto.SelectedValue);
|
||
DataSet dsFinancimiento = objFinanciamientoBL.getFinanciamiento();
|
||
|
||
if (dsFinancimiento.Tables.Count == 0)
|
||
blnDuplicado = false;
|
||
}
|
||
catch(Exception ex)
|
||
{
|
||
MensajeError("Error en R4M7", ex);
|
||
}
|
||
|
||
return blnDuplicado;
|
||
}
|
||
|
||
private bool EndeudamientoDuplicado() //M8
|
||
{
|
||
bool blnDuplicado = true;
|
||
|
||
try
|
||
{
|
||
objEndeudamientoBL.objEndeudamientoEL.PK = 0;
|
||
objEndeudamientoBL.objEndeudamientoEL.Proyecto = Int32.Parse(ddlProyecto.SelectedValue);
|
||
DataSet dsEndeudamiento = objEndeudamientoBL.getEndeudamiento();
|
||
|
||
if (dsEndeudamiento.Tables[0].Rows.Count == 0)
|
||
blnDuplicado = false;
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
MensajeError("Error en R4M8", ex);
|
||
}
|
||
|
||
return blnDuplicado;
|
||
}
|
||
|
||
private void construirgrvDetalle() //M9
|
||
{
|
||
try
|
||
{
|
||
grvDetalleTemp = (GridView)divDatosInferiores.FindControl("grvDetalle");
|
||
|
||
GridViewBoundField bdfPkFinanciamiento = new GridViewBoundField("PKFINANCIAMIENTO", "PK", false, false, false);
|
||
GridViewBoundField bdfTipoFinanciamiento = new GridViewBoundField("TIPOFINANCIAMIENTO", "TIPO FINANCIAMIENTO", true, false, true);
|
||
GridViewBoundField bdfTipoRecurso = new GridViewBoundField("TIPORECURSOFINANCIAMIENTO", "TIPO RECURSO", true, false, true);
|
||
GridViewBoundField bdfPkRecurso = new GridViewBoundField("PKRECURSO", "PK", true, true, false);
|
||
GridViewBoundField bdfRecurso = new GridViewBoundField("NOMBRERECURSO", "RECURSO", true, true, true);
|
||
GridViewBoundField bdfAnio = new GridViewBoundField("ANIOFINANCIAMIENTO", "AÑO", true, false, true);
|
||
GridViewBoundField bdfMonto = new GridViewBoundField("MONTOFINANCIAMIENTO", "MONTO", true, false, true);
|
||
GridViewBoundField bdfFkProyecto = new GridViewBoundField("FKPROYECTO", "PROYECTO", true, false, false);
|
||
|
||
grvDetalleTemp.Columns.Add(bdfPkFinanciamiento);
|
||
grvDetalleTemp.Columns.Add(bdfTipoFinanciamiento);
|
||
grvDetalleTemp.Columns.Add(bdfTipoRecurso);
|
||
grvDetalleTemp.Columns.Add(bdfPkRecurso);
|
||
grvDetalleTemp.Columns.Add(bdfRecurso);
|
||
grvDetalleTemp.Columns.Add(bdfAnio);
|
||
grvDetalleTemp.Columns.Add(bdfMonto);
|
||
grvDetalleTemp.Columns.Add(bdfFkProyecto);
|
||
|
||
grvDetalleTemp.Columns[0].ItemStyle.Width = 25;
|
||
grvDetalleTemp.Columns[1].ItemStyle.Width = 25;
|
||
grvDetalleTemp.Columns[7].ItemStyle.HorizontalAlign = HorizontalAlign.Right;
|
||
|
||
bdfMonto.DataFormatString = "{0:N2}";
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
MensajeError("Error en R4M9", ex);
|
||
}
|
||
}
|
||
|
||
private void mostrarDetalleFinanciamiento(int p_intFila) //M10
|
||
{
|
||
try
|
||
{
|
||
divTabulado.Visible = false;
|
||
divDetalle.Visible = false;
|
||
|
||
switch (p_intFila)
|
||
{
|
||
case 1:
|
||
divTabulado.Visible = true;
|
||
ViewState["MODO"] = "Nuevo";
|
||
break;
|
||
case 2:
|
||
divDetalle.Visible = true;
|
||
ViewState["MODO"] = "Modifica";
|
||
break;
|
||
}
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
MensajeError("Error en R4M10", ex);
|
||
}
|
||
}
|
||
|
||
private void limpiarInversion() //M11
|
||
{
|
||
llenarDDLTipoFuente();
|
||
llenarDDLTipoRecurso();
|
||
llenarDDLRecurso();
|
||
llenarDDLAnio();
|
||
txtMonto.Text = string.Empty;
|
||
}
|
||
|
||
private void limpiarEndeudamiento() //M12
|
||
{
|
||
llenarDDLTipoFuente();
|
||
llenarDDLFuenteFinanciamiento();
|
||
txtMontoDeuda.Text = string.Empty;
|
||
txtTasa.Text = string.Empty;
|
||
txtPeriodoGracia.Text = string.Empty;
|
||
txtPlazo.Text = string.Empty;
|
||
llenarDDLDesembolsoI();
|
||
llenarDDLDesembolsoF();
|
||
txtTipoCambio.Text = string.Empty;
|
||
txtFechaContrato.Text = string.Empty;
|
||
txtSituacionContrato.Text = string.Empty;
|
||
}
|
||
|
||
#endregion
|
||
|
||
#region Metodos Controles a Datos (R5)
|
||
|
||
/// <summary>
|
||
/// guarda y modifica registros en la tabla.
|
||
/// </summary>
|
||
/// <returns></returns>
|
||
private bool GuardarInversion() //M0
|
||
{
|
||
bool blnEjecutado = false;
|
||
|
||
try
|
||
{
|
||
string strModo = ViewState["MODO"].ToString();
|
||
|
||
//Valida que los campos están llenos
|
||
if (ddlAnio.SelectedItem.Text != string.Empty && txtMonto.Text != string.Empty && ddlTipoFinanciamiento.SelectedItem.Text != string.Empty && ddlTipoRecurso.SelectedItem.Text != string.Empty)
|
||
{
|
||
objFinanciamientoBL = new FinanciamientoBL();
|
||
objFinanciamientoBL.objFinanciamientoEL.Anio = Int32.Parse(ddlAnio.SelectedItem.Text);
|
||
objFinanciamientoBL.objFinanciamientoEL.Monto = decimal.Parse(txtMonto.Text);
|
||
//Guarda el tipo de financiamiento
|
||
if (ddlTipoFinanciamiento.SelectedValue == "1")
|
||
objFinanciamientoBL.objFinanciamientoEL.TipoFinanciamiento = "PI"; //PreInversión
|
||
else
|
||
objFinanciamientoBL.objFinanciamientoEL.TipoFinanciamiento = "EI"; //Ejecución e Inversión
|
||
//Guarda el tipo de recurso
|
||
if (ddlTipoRecurso.SelectedValue == "1")
|
||
objFinanciamientoBL.objFinanciamientoEL.TipoRecurso = "RI"; //Recurso Interno
|
||
else
|
||
objFinanciamientoBL.objFinanciamientoEL.TipoRecurso = "RE"; //Recurso Externo
|
||
|
||
objFinanciamientoBL.objFinanciamientoEL.Recurso = Int32.Parse(ddlRecurso.SelectedValue);
|
||
objFinanciamientoBL.objFinanciamientoEL.Proyecto = Int32.Parse(ddlProyecto.SelectedValue);
|
||
|
||
if (strModo == "Nuevo")
|
||
{
|
||
|
||
int intFinancimiento = objFinanciamientoBL.insertarFinanciamiento();
|
||
|
||
GuardarEventoBitacora(Session["LOGIN"].ToString(),
|
||
AccionBitacora.INSERT.ToString(),
|
||
MensajesBitacora.IngresarRegistro + ": Año: " + ddlAnio.SelectedItem.Text + ", Monto: " + txtMonto.Text + ", Tipo Recurso: " + ddlTipoRecurso.SelectedItem.Text +
|
||
", Recurso: " + ddlRecurso.SelectedItem.Text + ", Proyecto: " + ddlProyecto.SelectedItem.Text,
|
||
"frwFinanciamiento.aspx");
|
||
|
||
MensajeInformativo("El registro fue almacenado");
|
||
}
|
||
else if (strModo == "Modifica" && bool.Parse(ViewState["PUEDEMODIFICAR"].ToString()) == true)
|
||
{
|
||
|
||
objFinanciamientoBL.objFinanciamientoEL.PK = Int32.Parse(ViewState["PkFinanciamiento"].ToString());
|
||
|
||
if (objFinanciamientoBL.actualizarFinanciamiento())
|
||
{
|
||
GuardarEventoBitacora(Session["LOGIN"].ToString(),
|
||
AccionBitacora.UPDATE.ToString(),
|
||
MensajesBitacora.ModificarRegistro + ": Se actualiza el registro: " + "Año: " + ddlAnio.SelectedItem.Text + ", Monto: " + txtMonto.Text + ", Tipo Recurso: " + ddlTipoRecurso.SelectedItem.Text +
|
||
", Recurso: " + ddlRecurso.SelectedItem.Text + ", Proyecto: " + ddlProyecto.SelectedItem.Text,
|
||
"frwFinancimiento.aspx");
|
||
|
||
llenarGRVDetalle();
|
||
|
||
MensajeInformativo("El registro fue actualizado");
|
||
}
|
||
}
|
||
|
||
llenarGRVRecursos();
|
||
|
||
blnEjecutado = true;
|
||
}
|
||
else
|
||
{
|
||
MensajeAdvertencia("Debe suminitrar toda la información");
|
||
}
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
blnEjecutado = false;
|
||
throw ex;
|
||
General.ReportarError(ex, Session["LOGIN"].ToString());
|
||
}
|
||
return blnEjecutado;
|
||
}
|
||
|
||
private void eliminarInversion(int p_intPKFinanciamiento) //M1
|
||
{
|
||
try
|
||
{
|
||
objFinanciamientoBL = new FinanciamientoBL();
|
||
|
||
objFinanciamientoBL.objFinanciamientoEL.PK = p_intPKFinanciamiento;
|
||
objFinanciamientoBL.objFinanciamientoEL.ASTATE = false;
|
||
|
||
objFinanciamientoBL.actualizaEstadoFinanciamiento();
|
||
|
||
GuardarEventoBitacora(Session["LOGIN"].ToString(),
|
||
AccionBitacora.INSERT.ToString(),
|
||
MensajesBitacora.IngresarRegistro + ": Se ha borrado el registro con la PK: " + ": " + p_intPKFinanciamiento + " del Proyecto: " + ddlProyecto.SelectedItem.Text,
|
||
"frwFinancimiento.aspx");
|
||
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
MensajeError("Error en R5M1", ex);
|
||
General.ReportarError(ex, Session["LOGIN"].ToString());
|
||
}
|
||
|
||
}
|
||
|
||
private bool GuardarEndeudamiento() //M2
|
||
{
|
||
bool blnEjecutado = false;
|
||
|
||
try
|
||
{
|
||
if (txtMontoDeuda.Text != string.Empty && txtPeriodoGracia.Text != string.Empty && txtPlazo.Text != string.Empty && ddlDesembolInicio.SelectedItem.Text != "Desembolso Inicial" &&
|
||
ddlDesembolFinal.SelectedItem.Text != "Desembolso Final" && txtTipoCambio.Text != string.Empty && txtFechaContrato.Text != string.Empty && txtSituacionContrato.Text != string.Empty &&
|
||
txtTasa.Text != string.Empty && ddlFuenteFinanciamiento.SelectedItem.Text != "Fuente de Financiamiento" && ddlTipoFuente.SelectedItem.Text != "Tipo de Fuente")
|
||
{
|
||
objEndeudamientoBL = new EndeudamientoBL();
|
||
objEndeudamientoBL.objEndeudamientoEL.Monto = Decimal.Parse(txtMontoDeuda.Text);
|
||
objEndeudamientoBL.objEndeudamientoEL.PeriodoGracia = txtPeriodoGracia.Text;
|
||
objEndeudamientoBL.objEndeudamientoEL.Plazo = txtPlazo.Text;
|
||
objEndeudamientoBL.objEndeudamientoEL.DesembolsoInicio = Int32.Parse(ddlDesembolInicio.SelectedItem.Text);
|
||
objEndeudamientoBL.objEndeudamientoEL.DesembolsoFin = Int32.Parse(ddlDesembolFinal.SelectedItem.Text);
|
||
objEndeudamientoBL.objEndeudamientoEL.TipoCambio = Decimal.Parse(txtTipoCambio.Text);
|
||
objEndeudamientoBL.objEndeudamientoEL.FechaContrato = DateTime.Parse(txtFechaContrato.Text);
|
||
objEndeudamientoBL.objEndeudamientoEL.SituacinActual = txtSituacionContrato.Text;
|
||
objEndeudamientoBL.objEndeudamientoEL.Tasa = txtTasa.Text;
|
||
objEndeudamientoBL.objEndeudamientoEL.FuenteFinanciamiento = Int32.Parse(ddlFuenteFinanciamiento.SelectedValue);
|
||
objEndeudamientoBL.objEndeudamientoEL.Proyecto = Int32.Parse(ddlProyecto.SelectedValue);
|
||
|
||
if (objEndeudamientoBL.insertarEndeudamiento())
|
||
{
|
||
blnEjecutado = true;
|
||
|
||
GuardarEventoBitacora(Session["LOGIN"].ToString(),
|
||
AccionBitacora.INSERT.ToString(),
|
||
MensajesBitacora.IngresarRegistro + ": Se ha ingresado el registro: " + "Monto: " + Decimal.Parse(txtMontoDeuda.Text).ToString("###,###,###.#0") + ", " +
|
||
"Periodo Gracia: " + txtPeriodoGracia.Text + ", Plazo: " + txtPlazo.Text + ", Desembolzo Inicial: " +
|
||
ddlDesembolInicio.SelectedItem.Text + ", Desembolso Final: " + ddlDesembolFinal.SelectedItem.Text +
|
||
", Tipo Cambio: " + Decimal.Parse(txtTipoCambio.Text).ToString("###,###,###.#0") + ", Fecha Contrato: " +
|
||
txtFechaContrato.Text + ", Situación Actual: " + txtSituacionContrato.Text + ", Tasa: " +
|
||
txtTasa.Text + ", Fuente de Financiamiento: " + ddlFuenteFinanciamiento.SelectedItem.Text +
|
||
", Proyecto: " + ddlProyecto.SelectedItem.Text, "frwFinancimiento.aspx");
|
||
}
|
||
|
||
llenarGRVEndeudamiento();
|
||
}
|
||
else
|
||
{
|
||
MensajeAdvertencia("Debe suminitrar toda la información");
|
||
}
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
MensajeError("Error en R5M2", ex);
|
||
General.ReportarError(ex, Session["LOGIN"].ToString());
|
||
}
|
||
|
||
return blnEjecutado;
|
||
}
|
||
|
||
private bool modificarEndeudameinto() //M3
|
||
{
|
||
bool blnEjecutado = false;
|
||
|
||
try
|
||
{
|
||
objEndeudamientoBL = new EndeudamientoBL();
|
||
objEndeudamientoBL.objEndeudamientoEL.Monto = Decimal.Parse(txtMontoDeuda.Text);
|
||
objEndeudamientoBL.objEndeudamientoEL.PeriodoGracia = txtPeriodoGracia.Text;
|
||
objEndeudamientoBL.objEndeudamientoEL.Plazo = txtPlazo.Text;
|
||
objEndeudamientoBL.objEndeudamientoEL.DesembolsoInicio = Int32.Parse(ddlDesembolInicio.SelectedItem.Text);
|
||
objEndeudamientoBL.objEndeudamientoEL.DesembolsoFin = Int32.Parse(ddlDesembolFinal.SelectedItem.Text);
|
||
objEndeudamientoBL.objEndeudamientoEL.TipoCambio = Decimal.Parse(txtTipoCambio.Text);
|
||
objEndeudamientoBL.objEndeudamientoEL.FechaContrato = DateTime.Parse(txtFechaContrato.Text);
|
||
objEndeudamientoBL.objEndeudamientoEL.SituacinActual = txtSituacionContrato.Text;
|
||
objEndeudamientoBL.objEndeudamientoEL.Tasa = txtTasa.Text;
|
||
objEndeudamientoBL.objEndeudamientoEL.FuenteFinanciamiento = Int32.Parse(ddlFuenteFinanciamiento.SelectedValue);
|
||
objEndeudamientoBL.objEndeudamientoEL.Proyecto = Int32.Parse(ddlProyecto.SelectedValue);
|
||
|
||
objEndeudamientoBL.objEndeudamientoEL.PK = Int32.Parse(ViewState["PkEndeudamiento"].ToString());
|
||
|
||
if (objEndeudamientoBL.actualizarEndeudamiento())
|
||
{
|
||
blnEjecutado = true;
|
||
|
||
GuardarEventoBitacora(Session["LOGIN"].ToString(),
|
||
AccionBitacora.UPDATE.ToString(),
|
||
MensajesBitacora.ModificarRegistro + ": " + "Monto: " + Decimal.Parse(txtMontoDeuda.Text).ToString("###,###,###.#0") + ", Periodo Gracia: " +
|
||
txtPeriodoGracia.Text + ", Plazo: " + txtPlazo.Text + ", Desembolzo Inicial: " +
|
||
ddlDesembolInicio.SelectedItem.Text + ", Desembolso Final: " + ddlDesembolFinal.SelectedItem.Text +
|
||
", Tipo Cambio: " + Decimal.Parse(txtTipoCambio.Text).ToString("###,###,###.#0") + ", Fecha Contrato: " +
|
||
txtFechaContrato.Text + ", Situación Actual: " + txtSituacionContrato.Text +", Tasa: " +
|
||
txtTasa.Text + ", Fuente de Financiamiento: " + ddlFuenteFinanciamiento.SelectedItem.Text +
|
||
", Proyecto: " + ddlProyecto.SelectedItem.Text, "frwFinancimiento.aspx");
|
||
|
||
llenarGRVEndeudamiento();
|
||
}
|
||
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
MensajeError("Error en R5M3", ex);
|
||
General.ReportarError(ex, Session["LOGIN"].ToString());
|
||
}
|
||
|
||
return blnEjecutado;
|
||
}
|
||
|
||
private void eliminarEndeudamiento(int p_intPKEndeudamiento) //M4
|
||
{
|
||
try
|
||
{
|
||
objEndeudamientoBL = new EndeudamientoBL();
|
||
|
||
objEndeudamientoBL.objEndeudamientoEL.PK = p_intPKEndeudamiento;
|
||
objEndeudamientoBL.objEndeudamientoEL.ASTATE = false;
|
||
objEndeudamientoBL.actualizaEstadoEndeudamiento();
|
||
|
||
GuardarEventoBitacora(Session["LOGIN"].ToString(),
|
||
AccionBitacora.DELETE.ToString(),
|
||
MensajesBitacora.IngresarRegistro + ": Se ha borrado el registro con la PK: " + ": " + p_intPKEndeudamiento +
|
||
" del Proyecto: " + ddlProyecto.SelectedItem.Text, "frwFinancimiento.aspx");
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
MensajeError("Error en R5M4", ex);
|
||
General.ReportarError(ex, Session["LOGIN"].ToString());
|
||
}
|
||
|
||
}
|
||
#endregion
|
||
|
||
#region Metodos Datos a Controles (R6)
|
||
|
||
/// <summary>
|
||
/// Muestra los datos del registro
|
||
/// </summary>
|
||
/// <param name="p_intPkConsultar"></param>
|
||
private void mostrarDatos() //M0
|
||
{
|
||
try
|
||
{
|
||
llenarGRVRecursos();
|
||
llenarGRVEndeudamiento();
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
MensajeError("Error en R6M0", ex);
|
||
}
|
||
}
|
||
|
||
private void llenarDDLProyecto() //M1
|
||
{
|
||
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 R6M1", ex);
|
||
}
|
||
}
|
||
|
||
private void llenarDDLTipoRecurso() //M2
|
||
{
|
||
try
|
||
{
|
||
objRecursoBL = new RecursoBL();
|
||
|
||
string strTipoRecurso = "Tipo Recurso";
|
||
|
||
objRecursoBL.objRecursoEL.PK = 0;
|
||
objRecursoBL.objRecursoEL.Padre = -1;
|
||
objRecursoBL.objRecursoEL.ASTATE = true;
|
||
|
||
//Carga la información en un dataset
|
||
DataSet dsTipoRecurso = objRecursoBL.getRecurso();
|
||
|
||
ddlListaDatos(dsTipoRecurso, ddlTipoRecurso, strTipoRecurso);
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
MensajeError("Error en R6M2", ex);
|
||
}
|
||
}
|
||
|
||
private void llenarDDLRecurso() //M3
|
||
{
|
||
try
|
||
{
|
||
objRecursoBL = new RecursoBL();
|
||
|
||
string strRecurso = "Recurso";
|
||
|
||
objRecursoBL.objRecursoEL.PK = 0;
|
||
objRecursoBL.objRecursoEL.Padre = Int32.Parse(ddlTipoRecurso.SelectedValue);;
|
||
objRecursoBL.objRecursoEL.ASTATE = true;
|
||
|
||
//Carga la información en un dataset
|
||
DataSet dsRecurso = objRecursoBL.getRecurso();
|
||
|
||
ddlListaDatos(dsRecurso, ddlRecurso, strRecurso);
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
MensajeError("Error en R6M3", ex);
|
||
}
|
||
}
|
||
|
||
private void llenarDDLAnio() //M4
|
||
{
|
||
try
|
||
{
|
||
|
||
ddlAnio.Items.Clear();
|
||
|
||
ListItem lstAnios = new ListItem("Año");
|
||
ddlAnio.Items.Add(lstAnios);
|
||
|
||
|
||
for (int i = DateTime.Now.Year - 7; i <= DateTime.Now.Year + 7; i++)
|
||
{
|
||
lstAnios = new ListItem(i.ToString());
|
||
ddlAnio.Items.Add(lstAnios);
|
||
}
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
MensajeError("Error en R6M4", ex);
|
||
}
|
||
}
|
||
|
||
private void llenarGRVRecursos() //M5
|
||
{
|
||
string strTipoFinanciamiento = string.Empty;
|
||
string strTipoRecurso = string.Empty;
|
||
|
||
try
|
||
{
|
||
if (ddlTipoFinanciamiento.SelectedValue == "1")
|
||
strTipoFinanciamiento = "PI";
|
||
else if (ddlTipoFinanciamiento.SelectedValue == "2")
|
||
strTipoFinanciamiento = "EI";
|
||
|
||
if (ddlTipoRecurso.SelectedValue == "1")
|
||
strTipoRecurso = "RI";
|
||
else if (ddlTipoRecurso.SelectedValue == "2")
|
||
strTipoRecurso = "RE";
|
||
|
||
objFinanciamientoBL = new FinanciamientoBL();
|
||
objFinanciamientoBL.objFinanciamientoEL.Proyecto = Int32.Parse(ddlProyecto.SelectedValue);
|
||
objFinanciamientoBL.objFinanciamientoEL.TipoFinanciamiento = strTipoFinanciamiento;
|
||
objFinanciamientoBL.objFinanciamientoEL.TipoRecurso = strTipoRecurso;
|
||
|
||
DataSet dsRecursos = objFinanciamientoBL.getFinanciamiento();
|
||
ViewState["dsRecursos"] = dsRecursos;
|
||
|
||
if (dsRecursos.Tables.Count == 0)
|
||
dsRecursos.Tables.Add();
|
||
|
||
detalleGRVDatos(dsRecursos, grvRecursos);
|
||
|
||
if (grvRecursos.HeaderRow != null)
|
||
{
|
||
//Invisiviliza el titulo de la columna de la PK
|
||
grvRecursos.HeaderRow.Cells[0].Visible = false;
|
||
|
||
//Invisibiliza la columna de PK
|
||
for (int i = 0; i <= grvRecursos.Rows.Count - 1; ++i)
|
||
{
|
||
grvRecursos.Rows[i].Cells[0].Visible = false;
|
||
}
|
||
|
||
//Dar formato a las cifras por año
|
||
for (int i = 0; i <= grvRecursos.Rows.Count - 1; ++i)
|
||
{
|
||
for (int j = 2; j <= grvRecursos.Rows[i].Cells.Count - 1; ++j)
|
||
{
|
||
if (grvRecursos.Rows[i].Cells[j].Text != "0.00")
|
||
grvRecursos.Rows[i].Cells[j].Text = Decimal.Parse(grvRecursos.Rows[i].Cells[j].Text).ToString("###,###,###,###.#0");
|
||
grvRecursos.Rows[i].Cells[j].HorizontalAlign = HorizontalAlign.Right;
|
||
}
|
||
}
|
||
}
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
MensajeError("Error en R6M5", ex);
|
||
}
|
||
}
|
||
|
||
private void llenarGRVEndeudamiento() //M6
|
||
{
|
||
try
|
||
{
|
||
objEndeudamientoBL = new EndeudamientoBL();
|
||
objEndeudamientoBL.objEndeudamientoEL.PK = 0;
|
||
objEndeudamientoBL.objEndeudamientoEL.Proyecto = Int32.Parse(ddlProyecto.SelectedValue);
|
||
|
||
DataSet dsEndeudamiento = objEndeudamientoBL.getEndeudamiento();
|
||
detalleGRVDatos(dsEndeudamiento, grvEndeudamientoTemp);
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
MensajeError("Error en R6M6", ex);
|
||
}
|
||
}
|
||
|
||
private void llenarDDLTipoFuente() //M7
|
||
{
|
||
try
|
||
{
|
||
objFuenteFinanciamientoBL = new FuenteFinanciamientoBL();
|
||
|
||
string strFuente = "Tipo Fuente";
|
||
|
||
objFuenteFinanciamientoBL.objFuenteFinanciamientoEL.Padre = -1;
|
||
objFuenteFinanciamientoBL.objFuenteFinanciamientoEL.PK = 0;
|
||
objFuenteFinanciamientoBL.objFuenteFinanciamientoEL.ASTATE = true;
|
||
|
||
//Carga la información en un dataset
|
||
DataSet dsFuente = objFuenteFinanciamientoBL.getFuenteFinanciamiento();
|
||
|
||
ddlListaDatos(dsFuente, ddlTipoFuente, strFuente);
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
MensajeError("Error en R6M7", ex);
|
||
}
|
||
}
|
||
|
||
private void llenarDDLFuenteFinanciamiento() //M8
|
||
{
|
||
try
|
||
{
|
||
objFuenteFinanciamientoBL = new FuenteFinanciamientoBL();
|
||
|
||
string strFuente = "Fuente Financiamiento";
|
||
|
||
objFuenteFinanciamientoBL.objFuenteFinanciamientoEL.Padre = Int32.Parse(ddlTipoFuente.SelectedValue);
|
||
objFuenteFinanciamientoBL.objFuenteFinanciamientoEL.PK = 0;
|
||
objFuenteFinanciamientoBL.objFuenteFinanciamientoEL.ASTATE = true;
|
||
|
||
//Carga la información en un dataset
|
||
DataSet dsFuente = objFuenteFinanciamientoBL.getFuenteFinanciamiento();
|
||
|
||
ddlListaDatos(dsFuente, ddlFuenteFinanciamiento, strFuente);
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
MensajeError("Error en R6M8", ex);
|
||
}
|
||
}
|
||
|
||
private void llenarDDLDesembolsoI() //M9
|
||
{
|
||
try
|
||
{
|
||
|
||
ddlDesembolInicio.Items.Clear();
|
||
|
||
ListItem lstAnios = new ListItem("Desembolso Inicial");
|
||
ddlDesembolInicio.Items.Add(lstAnios);
|
||
|
||
|
||
for (int i = DateTime.Now.Year - 7; i <= DateTime.Now.Year + 7; i++)
|
||
{
|
||
lstAnios = new ListItem(i.ToString());
|
||
ddlDesembolInicio.Items.Add(lstAnios);
|
||
}
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
MensajeError("Error en R6M9", ex);
|
||
}
|
||
}
|
||
|
||
private void llenarDDLDesembolsoF() //M10
|
||
{
|
||
try
|
||
{
|
||
|
||
ddlDesembolFinal.Items.Clear();
|
||
|
||
ListItem lstAnios = new ListItem("Desembolso Final");
|
||
ddlDesembolFinal.Items.Add(lstAnios);
|
||
|
||
|
||
for (int i = DateTime.Now.Year - 7; i <= DateTime.Now.Year + 7; i++)
|
||
{
|
||
lstAnios = new ListItem(i.ToString());
|
||
ddlDesembolFinal.Items.Add(lstAnios);
|
||
}
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
MensajeError("Error en R6M10", ex);
|
||
}
|
||
}
|
||
|
||
private void mostrarDatos(int p_intPkConsultar) //M11
|
||
{
|
||
try
|
||
{
|
||
objEndeudamientoBL = new EndeudamientoBL();
|
||
objEndeudamientoBL.objEndeudamientoEL.PK = p_intPkConsultar;
|
||
objEndeudamientoBL.objEndeudamientoEL.Proyecto = 0;
|
||
DataSet dsEndeudamiento = objEndeudamientoBL.getEndeudamiento();
|
||
|
||
|
||
if (dsEndeudamiento.Tables[0].Rows.Count != 0)
|
||
{
|
||
ddlTipoFuente.SelectedValue = dsEndeudamiento.Tables[0].Rows[0]["PADREFUENTEFINANCIAMIENTO"].ToString();
|
||
llenarDDLFuenteFinanciamiento();
|
||
ddlFuenteFinanciamiento.SelectedValue = dsEndeudamiento.Tables[0].Rows[0]["FKFUENTEFINANCIAMIENTO"].ToString();
|
||
txtMontoDeuda.Text = Decimal.Parse(dsEndeudamiento.Tables[0].Rows[0]["MONTOENDEUDAMIENTO"].ToString()).ToString("###,###,###,###.#0");
|
||
txtTasa.Text = dsEndeudamiento.Tables[0].Rows[0]["TASAENDEUDAMIENTO"].ToString();
|
||
txtPeriodoGracia.Text = dsEndeudamiento.Tables[0].Rows[0]["PERIODOGRACIAENDEUDAMIENTO"].ToString();
|
||
txtPlazo.Text = dsEndeudamiento.Tables[0].Rows[0]["PLAZOENDEUDAMIENTO"].ToString();
|
||
ddlDesembolInicio.SelectedItem.Text = dsEndeudamiento.Tables[0].Rows[0]["DESEMBOLSOINICIOENDEUDAMIENTO"].ToString();
|
||
ddlDesembolFinal.SelectedItem.Text = dsEndeudamiento.Tables[0].Rows[0]["DESEMBOLSOFINENDEUDAMIENTO"].ToString();
|
||
txtTipoCambio.Text = dsEndeudamiento.Tables[0].Rows[0]["TIPOCAMBIOCONTRATOENDEUDAMIENTO"].ToString();
|
||
txtFechaContrato.Text = DateTime.Parse(dsEndeudamiento.Tables[0].Rows[0]["FECHACONTRATOENDEUDAMIENTO"].ToString()).ToString("dd/MM/yyyy");
|
||
txtSituacionContrato.Text = dsEndeudamiento.Tables[0].Rows[0]["SITUACIONACTUALENDEUDAMIENTO"].ToString();
|
||
|
||
}
|
||
else
|
||
{
|
||
MensajeInformativo("No se encontró el registro solicitado");
|
||
}
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
MensajeError("Error en R6M11", ex);
|
||
}
|
||
}
|
||
|
||
private void mostrarDetalle() //M12
|
||
{
|
||
try
|
||
{
|
||
objFinanciamientoBL = new FinanciamientoBL();
|
||
objFinanciamientoBL.objFinanciamientoEL.PK = Int32.Parse(ViewState["PkFinanciamiento"].ToString());
|
||
DataSet dsFinanciamiento = objFinanciamientoBL.getDetalle();
|
||
if (dsFinanciamiento.Tables[0].Rows.Count > 0)
|
||
{
|
||
ddlTipoFinanciamiento.SelectedValue = dsFinanciamiento.Tables[0].Rows[0]["PKTIPOFINANCIAMIENTO"].ToString();
|
||
ddlTipoRecurso.SelectedValue = dsFinanciamiento.Tables[0].Rows[0]["PKTIPORECURSOFINANCIAMIENTO"].ToString();
|
||
llenarDDLRecurso();
|
||
ddlRecurso.SelectedValue = dsFinanciamiento.Tables[0].Rows[0]["PKRECURSO"].ToString();
|
||
ddlAnio.SelectedItem.Text = dsFinanciamiento.Tables[0].Rows[0]["ANIOFINANCIAMIENTO"].ToString();
|
||
txtMonto.Text = dsFinanciamiento.Tables[0].Rows[0]["MONTOFINANCIAMIENTO"].ToString();
|
||
}
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
MensajeError("Error en R6M12", ex);
|
||
}
|
||
}
|
||
|
||
private void llenarGRVDetalle() //M13
|
||
{
|
||
try
|
||
{
|
||
objFinanciamientoBL = new FinanciamientoBL();
|
||
objFinanciamientoBL.objFinanciamientoEL.PK = 0;
|
||
objFinanciamientoBL.objFinanciamientoEL.Proyecto = Int32.Parse(ddlProyecto.SelectedValue);
|
||
DataSet dsDetalle = objFinanciamientoBL.getDetalle();
|
||
|
||
detalleGRVDatos(dsDetalle, grvDetalle);
|
||
|
||
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
MensajeError("Error en R6M13", ex);
|
||
}
|
||
}
|
||
|
||
protected void grvRecursos_Sorting(object sender, GridViewSortEventArgs e) //M14
|
||
{
|
||
//Retrieve the table from the session object.
|
||
DataSet dsRecursos = ViewState["dsRecursos"] as DataSet;
|
||
DataTable dt = dsRecursos.Tables[0];
|
||
|
||
if (dt != null)
|
||
{
|
||
//Sort the data.
|
||
dt.DefaultView.Sort = e.SortExpression + " " + GetSortDirection(e.SortExpression);
|
||
grvRecursos.DataSource = dt;
|
||
grvRecursos.DataBind();
|
||
//Invisiviliza el titulo de la columna de la PK
|
||
if (grvRecursos.HeaderRow != null)
|
||
{
|
||
//Invisiviliza el titulo de la columna de la PK
|
||
grvRecursos.HeaderRow.Cells[0].Visible = false;
|
||
|
||
//Invisibiliza la columna de PK
|
||
for (int i = 0; i <= grvRecursos.Rows.Count - 1; ++i)
|
||
{
|
||
grvRecursos.Rows[i].Cells[0].Visible = false;
|
||
}
|
||
|
||
//Dar formato a las cifras por año
|
||
for (int i = 0; i <= grvRecursos.Rows.Count - 1; ++i)
|
||
{
|
||
for (int j = 3; j <= grvRecursos.Rows[i].Cells.Count - 1; ++j)
|
||
{
|
||
if (grvRecursos.Rows[i].Cells[j].Text != "0.00")
|
||
grvRecursos.Rows[i].Cells[j].Text = Decimal.Parse(grvRecursos.Rows[i].Cells[j].Text).ToString("###,###,###,###.#0");
|
||
grvRecursos.Rows[i].Cells[j].HorizontalAlign = HorizontalAlign.Right;
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
private string GetSortDirection(string column) //M15
|
||
{
|
||
// By default, set the sort direction to ascending.
|
||
string sortDirection = "ASC";
|
||
|
||
// Retrieve the last column that was sorted.
|
||
string sortExpression = column;//ViewState["SortExpression"] as string;
|
||
|
||
if (sortExpression != null)
|
||
{
|
||
// Check if the same column is being sorted.
|
||
// Otherwise, the default value can be returned.
|
||
if (sortExpression == column)
|
||
{
|
||
string lastDirection = ViewState["SortDirection"] as string;
|
||
if ((lastDirection != null) && (lastDirection == "ASC"))
|
||
{
|
||
sortDirection = "DESC";
|
||
}
|
||
}
|
||
}
|
||
|
||
// Save new values in ViewState.
|
||
ViewState["SortDirection"] = sortDirection;
|
||
ViewState["SortExpression"] = column;
|
||
|
||
return sortDirection;
|
||
}
|
||
|
||
#endregion
|
||
|
||
} |