/*=========================================================================================================================== * Instituto Costarricense de Acueductos y Alcantarillados. - 2019 * Formularios para Proyectos de Inversión * Nombre de la Pantalla: frwAspectosGenerales.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.Data; using System.Web; using System.Web.UI.WebControls; using System.Web.UI.HtmlControls; using AyABL.RCS; using AyABL.ADM; using AyABL.AGP; using AyABL.IGP; using System.Web.Services; using System.Web.Script.Serialization; using AyAEL.ADM; using System.Collections.Generic; using System.Activities; using System.Web.UI; public partial class webforms_FOR_wfrAspectosGenerales : 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); construirgrvObjetivos(); construirgrvListaResultados(); construirgrvUbicaciones(); } catch (Exception ex) { MensajeError("Error en R0M1", ex); } } #endregion #region Variables (R1) ProyectoBL objProyectoBL; DependenciaBL objDependenciaBL; CatalogoBL objCatalogoBL; UbicacionBL objUbicacionBL; RegionBL objRegionBL; ObjetivoEspecificoBL objObjetivoEspecificoBL; ResultadoBL objResultadoBL; InformacionGeneralBL objInformacionGeneralBL; ComplejidadBL objComplejidadBL; GridView grvObjetivosTemp, grvListaResultadosTemp, grvUbicacionesTemp; #endregion #region Eventos Formulario (R2) protected void Page_Load(object sender, EventArgs e) //M0 { try { if ((!IsPostBack) && (Session.Count > 0)) { llenarDDLRegionAyA(); llenarDDLPrioridad(); llenarDDLCategoria(); llenarDDLDependencia(); llenarDDLRegion(); llenarDDLAreaTematica(); llenarDDLInfluencia(); llenarDDLSector(); llenarDDLComplejidad(); llenarDDLUbicacion(ddlProvincia, -1); objProyectoBL = new ProyectoBL(); objProyectoBL.objProyectoEL.PK = Int32.Parse(Session["PKPROYECTO"].ToString()); DataSet dsProyecto = objProyectoBL.getProyectos(); if (dsProyecto.Tables[0].Rows.Count == 0) { ViewState["Modo"] = "Nuevo"; ViewState["Modo_InfoGeneral"] = "Nuevo"; limpiarCampos(); } else { ViewState["Modo"] = "Modifica"; ViewState["Modo_InfoGeneral"] = "Modifica"; mostrarDatos(); } } ScriptManager.RegisterStartupScript(Page, typeof(Page), "Check", "validarEstado()", true); } catch (Exception ex) { MensajeError("Error en R2M0", ex); } } #endregion #region Eventos Controles Web (R3) protected void btnGuardar_Click(object sender, EventArgs e) //M0 { try { if (GuardarDatos()) { MensajeInformativo("El registro fue almacenado exitosamente"); } else { MensajeError("El registro no fue almacenado, verifique", null); } } catch (Exception ex) { MensajeError("Error en R3M0", ex); } } protected void grvListaObjetivos_RowCommand(object sender, GridViewCommandEventArgs e) //M1 { try { if (e.CommandName == "editar") { int i = Convert.ToInt32(e.CommandArgument); GridViewRow selectedRow = grvObjetivos.Rows[i]; int intPkObjetivo = Convert.ToInt32(selectedRow.Cells[2].Text); ViewState["PkObjetivo"] = intPkObjetivo; ViewState["MODO_Objetivo"] = "Modifica"; mostrarFilasObjetivos(2); mostrarObjetivos(); } } catch (Exception ex) { MensajeError("Error en R3M1", ex); } } protected void grvListaObjetivos_PageIndexChanging(object sender, GridViewPageEventArgs e) //M2 { try { grvObjetivos.PageIndex = e.NewPageIndex; llenarGridObjetivos(); } catch (Exception ex) { MensajeError("Error R3M2", ex); } } protected void btnAnterior_Click(object sender, EventArgs e) //M3 { try { Response.Redirect("wfrProyectos.aspx"); } catch (Exception ex) { MensajeError("Error en R3M3", ex); } } protected void btnNuevoOE_Click(object sender, EventArgs e) //M4 { try { ViewState["MODO_Objetivo"] = "Nuevo"; mostrarFilasObjetivos(2); limpiarObjetivos(); } catch (Exception ex) { MensajeError("Error en R3M4", ex); } } protected void btnEliminarOE_Click(object sender, EventArgs e) //M5 { try { // recorro el grid foreach (GridViewRow row in grvObjetivos.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); EliminarObjetivo(intPkEliminar); } } } llenarGridObjetivos(); } catch (Exception ex) { MensajeError("Error en R3M5", ex); } } protected void btnGuardarOE_Click(object sender, EventArgs e) //M6 { try { if (GuardaObjetivos()) { MensajeInformativo("El registro fue almacenado exitosamente"); } else { MensajeError("El registro no fue almacenado, verifique", null); } } catch (Exception ex) { MensajeError("Error en R3M6", ex); } } protected void btnAnteriorOE_Click(object sender, EventArgs e) //M7 { try { mostrarFilasObjetivos(1); } catch (Exception ex) { MensajeError("Error en R3M7", ex); } } protected void grvListaResultados_RowCommand(object sender, GridViewCommandEventArgs e) //M8 { try { if (e.CommandName == "editar") { int i = Convert.ToInt32(e.CommandArgument); GridViewRow selectedRow = grvListaResultados.Rows[i]; int intPkResultado = Convert.ToInt32(selectedRow.Cells[2].Text); ViewState["PkResultado"] = intPkResultado; ViewState["MODO_Resultado"] = "Modifica"; mostrarFilasResultados(2); mostrarResultados(); } } catch (Exception ex) { MensajeError("Error en R3M8", ex); } } protected void grvListaResultados_PageIndexChanging(object sender, GridViewPageEventArgs e) //M9 { try { grvListaResultados.PageIndex = e.NewPageIndex; llenarGridResultados(); } catch (Exception ex) { MensajeError("Error R3M9", ex); } } protected void btnNuevoRS_Click(object sender, EventArgs e) //M10 { try { ViewState["MODO_Resultado"] = "Nuevo"; mostrarFilasResultados(2); limpiarResultados(); } catch (Exception ex) { MensajeError("Error en R3M10", ex); } } protected void btnEliminarRS_Click(object sender, EventArgs e) //M11 { try { // recorro el grid foreach (GridViewRow row in grvListaResultados.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); EliminarResultado(intPkEliminar); } } } llenarGridResultados(); } catch (Exception ex) { MensajeError("Error en R3M11", ex); } } protected void btnGuardarRS_Click(object sender, EventArgs e) //M12 { try { if (GuardaResultados()) { MensajeInformativo("El registro fue almacenado exitosamente"); } else { MensajeError("El registro no fue almacenado, verifique", null); } } catch (Exception ex) { MensajeError("Error en R3M12", ex); } } protected void btnAnteriorRS_Click(object sender, EventArgs e) //M13 { try { mostrarFilasResultados(1); } catch (Exception ex) { MensajeError("Error en R3M13", ex); } } protected void btnAdministrarUbicaciones_Click(object sender, EventArgs e) { Session["NOMBREPROYECTO"] = txtProyecto.Text; string url = "../AGP/wfrAdministrarUbicaciones.aspx"; string s = "window.open('" + url + "', 'FROPI', 'location=0,toolbar=no,height=500,left=100,top=100,rigth=100,resizable=yes');"; //ScriptManager.RegisterStartupScript(Page, typeof(Page), "Check", s , true); mostrarSeccion(divAdminUbicaciones.ID); } #endregion #region Metodos Personalizados (R4) private void mostrarFilasObjetivos(int p_intFila) //M0 { try { divListaObjetivos.Visible = false; divFormularioObjetivos.Visible = false; switch (p_intFila) { case 1: llenarGridObjetivos(); divListaObjetivos.Visible = true; break; case 2: llenarGridObjetivos(); divFormularioObjetivos.Visible = true; break; } } catch (Exception ex) { MensajeError("Error en R4M5", ex); } } private void mostrarFilasResultados(int p_intFila) //M1 { try { divListaResultados.Visible = false; divFormularioResultados.Visible = false; switch (p_intFila) { case 1: llenarGridResultados(); divListaResultados.Visible = true; break; case 2: llenarGridResultados(); divFormularioResultados.Visible = true; break; } } catch (Exception ex) { MensajeError("Error en R4M1", ex); } } private void construirgrvObjetivos() //M2 { try { grvObjetivosTemp = (GridView)divListaObjetivos.FindControl("grvObjetivos"); GridViewBoundField bdfPkObjetivo = new GridViewBoundField("PKOBJETIVOESPECIFICO", "PK", false, false, false); GridViewBoundField bdfNumero = new GridViewBoundField("NUMEROOBJETIVOESPECIFICO", "#", false, false, true); GridViewBoundField bdfDescripcion = new GridViewBoundField("DESCRIPCIONOBJETIVOESPECIFICO", "OBJETIVO", false, false, true); GridViewBoundField bdfCumplido = new GridViewBoundField("CUMPLIDOOBJETIVOESPECIFICO", "CUMPLIDO", false, "Si", "No", true); grvObjetivosTemp.Columns.Add(bdfPkObjetivo); grvObjetivosTemp.Columns.Add(bdfNumero); grvObjetivosTemp.Columns.Add(bdfDescripcion); grvObjetivosTemp.Columns.Add(bdfCumplido); grvObjetivosTemp.Columns[0].ItemStyle.Width = 25; grvObjetivosTemp.Columns[1].ItemStyle.Width = 25; grvObjetivosTemp.Columns[3].ItemStyle.Width = 25; grvObjetivosTemp.Columns[4].ItemStyle.Width = 250; grvObjetivosTemp.Columns[5].ItemStyle.Width = 50; } catch (Exception ex) { MensajeError("Error en R4M2", ex); } } private void construirgrvListaResultados() //M3 { try { grvListaResultadosTemp = (GridView)divListaResultados.FindControl("grvListaResultados"); GridViewBoundField bdfPkResultado = new GridViewBoundField("PKRESULTADO", "PK", false, false, false); GridViewBoundField bdfNumero = new GridViewBoundField("NUMERORESULTADO", "#", false, false, true); GridViewBoundField bdfDescripcion = new GridViewBoundField("DESCRIPCIONRESULTADO", "RESULTADO", false, false, true); grvListaResultadosTemp.Columns.Add(bdfPkResultado); grvListaResultadosTemp.Columns.Add(bdfNumero); grvListaResultadosTemp.Columns.Add(bdfDescripcion); grvListaResultadosTemp.Columns[0].ItemStyle.Width = 25; grvListaResultadosTemp.Columns[1].ItemStyle.Width = 25; grvListaResultadosTemp.Columns[3].ItemStyle.Width = 25; grvListaResultadosTemp.Columns[4].ItemStyle.Width = 250; } catch (Exception ex) { MensajeError("Error en R4M8", ex); } } private void construirgrvUbicaciones() //M2 { try { grvUbicacionesTemp = (GridView)divListaObjetivos.FindControl("grvUbicaciones"); GridViewBoundField bdFkUbicacion = new GridViewBoundField("FKPROYECTO", "FK", false, false, false); GridViewBoundField bdProvincia = new GridViewBoundField("PROVINCIA", "PROVINCIA", false, false, true); GridViewBoundField bdCanton = new GridViewBoundField("CANTON", "CANTÓN", false, false, true); GridViewBoundField bdDistrito = new GridViewBoundField("DISTRITO", "DISTRITO", false, false, true); GridViewBoundField bdBarrios = new GridViewBoundField("LISTABARRIOS", "COMUNIDADES", false, false, true); grvUbicacionesTemp.Columns.Add(bdFkUbicacion); grvUbicacionesTemp.Columns.Add(bdProvincia); grvUbicacionesTemp.Columns.Add(bdCanton); grvUbicacionesTemp.Columns.Add(bdDistrito); grvUbicacionesTemp.Columns.Add(bdBarrios); } catch (Exception ex) { MensajeError("Error en R4M2", ex); } } private void limpiarCampos() //M4 { txtProyecto.Text = string.Empty; txtNumeroBPIP.Text = string.Empty; //ddlCanton.Text = string.Empty; //ddlDistrito.Text = string.Empty; txtNumeroAccion.Text = string.Empty; txtMetaAccion.Text = string.Empty; txtMetaInstitucional.Text = string.Empty; txtDescripcion.Text = string.Empty; txtBeneficioDir.Text = string.Empty; txtBeneficioIndir.Text = string.Empty; txtObjetivo.Text = string.Empty; grvObjetivos.DataBind(); grvListaResultados.DataBind(); } private void limpiarObjetivos() //M5 { txtNumeracionOE.Text = string.Empty; txtObjetivoEspecifico.Text = string.Empty; chkCumplido.Checked = false; } private void limpiarResultados() //M6 { txtNumeracionRS.Text = string.Empty; txtResultado.Text = string.Empty; } #endregion #region Metodos Controles a Datos (R5) private bool GuardarDatos() //M0 { bool blnEjecutado = false; try { string strModo = ViewState["Modo"].ToString(); string strModo_InfoGeneral = ViewState["Modo_InfoGeneral"].ToString(); objProyectoBL = new ProyectoBL(); objProyectoBL.objProyectoEL.Nombre = txtProyecto.Text.Trim(); objProyectoBL.objProyectoEL.Dependencia = Int32.Parse(ddlDependencia.SelectedValue); objProyectoBL.objProyectoEL.Sector = Int32.Parse(ddlSector.SelectedValue); objProyectoBL.objProyectoEL.AreaTematica = Int32.Parse(ddlAreaTematica.SelectedValue); objProyectoBL.objProyectoEL.AreaInfluencia = Int32.Parse(ddlInfluencia.SelectedValue); objProyectoBL.objProyectoEL.Region = Int32.Parse(ddlRegion.SelectedValue); //objProyectoBL.objProyectoEL.Provincia = Int32.Parse(ddlProvincia.SelectedValue); //objProyectoBL.objProyectoEL.Canton = ddlCanton.Text.Trim(); //objProyectoBL.objProyectoEL.Distrito = ddlDistrito.Text.Trim(); objProyectoBL.objProyectoEL.NumeroAccionEstrategica = txtNumeroAccion.Text.Trim(); objProyectoBL.objProyectoEL.MetaAccionEstrategica = txtMetaAccion.Text.Trim(); objProyectoBL.objProyectoEL.MetaInstitucional = txtMetaInstitucional.Text.Trim(); objProyectoBL.objProyectoEL.Prioridad = Int32.Parse(ddlPrioridad.SelectedValue); objProyectoBL.objProyectoEL.Complejidad = Int32.Parse(ddlComplejidad.SelectedValue); objProyectoBL.objProyectoEL.Descripcion = txtDescripcion.Text.Trim(); objProyectoBL.objProyectoEL.ObjetivoGeneral = txtObjetivo.Text.Trim(); objProyectoBL.objProyectoEL.BeneficiarioDirecto = txtBeneficioDir.Text.Trim(); objProyectoBL.objProyectoEL.BeneficiarioIndirecto = txtBeneficioIndir.Text.Trim(); objProyectoBL.objProyectoEL.CodigoAcceso = Session["CODIGOACCESO"].ToString(); objProyectoBL.objProyectoEL.Categoria = Int32.Parse(ddlCategoria.SelectedValue); objProyectoBL.objProyectoEL.Patrocinador = txtPatrocinador.Text; objProyectoBL.objProyectoEL.Lider = txtLider.Text; objProyectoBL.objProyectoEL.TotalEstimado = string.IsNullOrWhiteSpace(txtTotalEstimado.Text) ? 0M : Convert.ToDecimal(txtTotalEstimado.Text); //Información General objInformacionGeneralBL = new InformacionGeneralBL(); objInformacionGeneralBL.objInformacionGeneralEL.Encargado = txtEncargado.Text; objInformacionGeneralBL.objInformacionGeneralEL.Region = Int32.Parse(ddlRegionAyA.SelectedValue); if (strModo == "Nuevo") { //*****************Validar que todos los ddl este llenos if (objProyectoBL.verificaProyecto()) { objProyectoBL.objProyectoEL.NumeroBPIP = "Sin Asignar"; Session["PKPROYECTO"] = objProyectoBL.insertarProyecto(); if (Int32.Parse(Session["PKPROYECTO"].ToString()) != 0) { GuardarEventoBitacora( Session["LOGIN"].ToString(), AccionBitacora.INSERT.ToString(), MensajesBitacora.IngresarRegistro + ": Proyecto: " + txtProyecto.Text + ", Dependencia: " + ddlDependencia.SelectedItem.Text + ", Sector: " + ddlSector.SelectedItem.Text + ", " + "Area Tematica: " + ddlAreaTematica.SelectedItem.Text + ", Area Influencia: " + //ddlInfluencia.SelectedItem.Text + ", Región: " + ddlRegion.SelectedItem.Text + ", Provincia: " + ddlProvincia.SelectedItem.Text + ", " + // "Cantón: " + ddlCanton.SelectedItem.Text + ", Distrito: " + ddlDistrito.SelectedItem.Text + ", " + "Numero Acción Estratégica: " + txtNumeroAccion.Text + ", Meta Acción Estratégica: " + txtMetaAccion.Text + ", Meta Institucional: " + txtMetaInstitucional.Text + ", Prioridad: " + ddlPrioridad.SelectedItem.Text + ", Descripción: " + txtDescripcion.Text + ", Objetivo General: " + txtObjetivo.Text + ", Beneficiarios Directos: " + txtBeneficioDir.Text + ", Benerficiario Indirecto: " + txtBeneficioIndir.Text + ", Categoría del Proyecto: " + ddlCategoria.SelectedItem.Text + ", Código Acceso: " + Session["CODIGOACCESO"].ToString(), "wfrAspectosGenerales.aspx"); ViewState["Modo"] = "Modifica"; blnEjecutado = true; } else MensajeAdvertencia("No se incluyó el proyecto, verifique que en los listados se haya seleccionado un item"); } else MensajeAdvertencia("No se incluyó el proyecto debido a que ya se ha incluido otro con el mismo nombre"); } else if (strModo == "Modifica") { objProyectoBL.objProyectoEL.PK = Int32.Parse(Session["PKPROYECTO"].ToString()); objProyectoBL.objProyectoEL.NumeroBPIP = txtNumeroBPIP.Text; if (objProyectoBL.actualizarProyecto()) { GuardarEventoBitacora( Session["LOGIN"].ToString(), AccionBitacora.UPDATE.ToString(), MensajesBitacora.ModificarRegistro + ": Proyecto: " + txtProyecto.Text + ", Dependencia: " + ddlDependencia.SelectedItem.Text + ", Sector: " + ddlSector.SelectedItem.Text + ", Area Tematica: " + ddlAreaTematica.SelectedItem.Text + ", Area Influencia: " + ddlInfluencia.SelectedItem.Text + ", Región: " + ddlRegion.SelectedItem.Text + "," + ", Numero Acción Estratégica: " + txtNumeroAccion.Text + ", Meta Acción Estratégica: " + txtMetaAccion.Text + ", Meta Institucional: " + txtMetaInstitucional.Text + ", Prioridad: " + ddlPrioridad.SelectedItem.Text + ", Descripción: " + txtDescripcion.Text + ", Objetivo General: " + txtObjetivo.Text + ", Beneficiarios Directos: " + txtBeneficioDir.Text + ", Benerficiario Indirecto: " + txtBeneficioIndir.Text + ", Categoría del Proyecto: " + ddlCategoria.SelectedItem.Text, "wfrAspectosGenerales.aspx"); } } if (strModo_InfoGeneral == "Nuevo") { objInformacionGeneralBL.objInformacionGeneralEL.Proyecto = Int32.Parse(Session["PKPROYECTO"].ToString()); if (objInformacionGeneralBL.insertarInformacionGeneral() != 0) { GuardarEventoBitacora( Session["LOGIN"].ToString(), AccionBitacora.INSERT.ToString(), MensajesBitacora.IngresarRegistro + ": " + " Encargado: " + txtEncargado.Text + ", Región AyA: " + ddlRegionAyA.SelectedItem.Text + ", Provincia: " + ", Proyecto: " + txtProyecto.Text, "wfrAspectosGenerales.aspx"); ViewState["Modo_InfoGeneral"] = "Modifica"; blnEjecutado = true; } } else if (strModo_InfoGeneral == "Modifica") { objInformacionGeneralBL.objInformacionGeneralEL.Proyecto = Int32.Parse(Session["PKPROYECTO"].ToString()); if (objInformacionGeneralBL.actualizarInformacionGeneral()) { blnEjecutado = true; GuardarEventoBitacora( Session["LOGIN"].ToString(), AccionBitacora.UPDATE.ToString(), MensajesBitacora.ModificarRegistro + ": " + " Encargado: " + txtEncargado.Text + ", Región AyA: " + ddlRegionAyA.SelectedItem.Text + ", Provincia: " + ", Proyecto: " + txtProyecto.Text, "wfrAspectosGenerales.aspx"); blnEjecutado = true; } } } catch (Exception ex) { blnEjecutado = false; throw ex; General.ReportarError(ex, Session["LOGIN"].ToString()); } return blnEjecutado; } private void EliminarDatos() //M1 { try { objProyectoBL = new ProyectoBL(); objProyectoBL.objProyectoEL.PK = Int32.Parse(Session["PKPROYECTO"].ToString()); if (objProyectoBL.actualizaEstadoProyecto()) { GuardarEventoBitacora( Session["LOGIN"].ToString(), AccionBitacora.UPDATE.ToString(), MensajesBitacora.EliminarRegistro + ": Proyecto: " + txtProyecto.Text + ", Dependencia: " + ddlDependencia.SelectedItem.Text + ", Sector: " + ddlSector.SelectedItem.Text + ", Area Tematica: " + //ddlAreaTematica.SelectedItem.Text + ", Area Influencia: " + ddlInfluencia.SelectedItem.Text + ", Región: " + ddlRegion.SelectedItem.Text + ", Provincia: " + ddlProvincia.SelectedItem.Text + ", Cantón: " + ddlCanton.SelectedItem.Text + ", Distrito: " + ddlDistrito.SelectedItem.Text + ", Numero Acción Estratégica: " + txtNumeroAccion.Text + ", Meta Acción Estratégica: " + txtMetaAccion.Text + ", Meta Institucional: " + txtMetaInstitucional.Text + ", Prioridad: " + ddlPrioridad.SelectedItem.Text + ", Descripción: " + txtDescripcion.Text + ", Objetivo General: " + txtObjetivo.Text + ", Beneficiarios Directos: " + txtBeneficioDir.Text + ", Benerficiario Indirecto: " + txtBeneficioIndir.Text + ", Categoría del Proyecto: " + ddlCategoria.SelectedItem.Text, "wfrAspectosGenerales.aspx"); MensajeInformativo("El Proyecto se eliminó correctamente"); } } catch (Exception ex) { MensajeError("Error en R5M1", ex); General.ReportarError(ex, Session["LOGIN"].ToString()); } } private bool GuardaObjetivos() //M2 { bool blnEjecutado = false; string strModo = ViewState["MODO_Objetivo"].ToString(); try { if (txtObjetivoEspecifico.Text != string.Empty && txtNumeracionOE.Text != string.Empty) { objObjetivoEspecificoBL = new ObjetivoEspecificoBL(); objObjetivoEspecificoBL.objObjetivoEspecificoEL.Numero = Int32.Parse(txtNumeracionOE.Text); objObjetivoEspecificoBL.objObjetivoEspecificoEL.Descripcion = txtObjetivoEspecifico.Text; objObjetivoEspecificoBL.objObjetivoEspecificoEL.Cumplido = chkCumplido.Checked; objObjetivoEspecificoBL.objObjetivoEspecificoEL.Proyecto = Int32.Parse(Session["PKPROYECTO"].ToString()); if (strModo == "Nuevo") { if (objObjetivoEspecificoBL.insertarObjetivo()) { GuardarEventoBitacora( Session["LOGIN"].ToString(), AccionBitacora.INSERT.ToString(), MensajesBitacora.IngresarRegistro + ": " + txtNumeracionOE.Text + "." + txtObjetivoEspecifico.Text + " del Proyecto " + txtProyecto.Text, "wfrAspectosGenerales.aspx"); } llenarGridObjetivos(); } else if (strModo == "Modifica") { objObjetivoEspecificoBL.objObjetivoEspecificoEL.PK = Int32.Parse(ViewState["PkObjetivo"].ToString()); if (objObjetivoEspecificoBL.actualizarObjetivo()) { GuardarEventoBitacora( Session["LOGIN"].ToString(), AccionBitacora.UPDATE.ToString(), MensajesBitacora.ModificarRegistro + ": " + txtNumeracionOE.Text + "." + txtObjetivoEspecifico.Text + " del Proyecto " + txtProyecto.Text, "wfrAspectosGenerales.aspx"); } llenarGridObjetivos(); } blnEjecutado = true; } } catch (Exception ex) { MensajeError("Error en R5M2", ex); General.ReportarError(ex, Session["LOGIN"].ToString()); } return blnEjecutado; } private void EliminarObjetivo(int p_intPkObjetivo) //M3 { try { objObjetivoEspecificoBL = new ObjetivoEspecificoBL(); objObjetivoEspecificoBL.objObjetivoEspecificoEL.PK = p_intPkObjetivo; objObjetivoEspecificoBL.actualizaEstadoObjetivo(); MensajeInformativo("Se eliminó el Objetivo Especifico satisfatoriamente"); } catch (Exception ex) { MensajeError("Error en R5M3", ex); General.ReportarError(ex, Session["LOGIN"].ToString()); } } private bool GuardaResultados() //M4 { bool blnEjecutado = false; string strModo = ViewState["MODO_Resultado"].ToString(); try { objResultadoBL = new ResultadoBL(); objResultadoBL.objResultadoEL.Numero = Int32.Parse(txtNumeracionRS.Text); objResultadoBL.objResultadoEL.Descripcion = txtResultado.Text; objResultadoBL.objResultadoEL.Proyecto = Int32.Parse(Session["PKPROYECTO"].ToString()); if (strModo == "Nuevo") { if (objResultadoBL.insertarResultado()) { GuardarEventoBitacora( Session["LOGIN"].ToString(), AccionBitacora.INSERT.ToString(), MensajesBitacora.IngresarRegistro + ": " + txtNumeracionRS.Text + "." + txtResultado.Text + " del Proyecto " + txtProyecto.Text, "wfrAspectosGenerales.aspx"); } llenarGridResultados(); } else if (strModo == "Modifica") { objResultadoBL.objResultadoEL.PK = Int32.Parse(ViewState["PkResultado"].ToString()); if (objResultadoBL.actualizarResultado()) { GuardarEventoBitacora( Session["LOGIN"].ToString(), AccionBitacora.UPDATE.ToString(), MensajesBitacora.ModificarRegistro + ": " + txtNumeracionRS.Text + "." + txtResultado.Text + " del Proyecto " + txtProyecto.Text, "wfrAspectosGenerales.aspx"); } llenarGridResultados(); } blnEjecutado = true; } catch (Exception ex) { MensajeError("Error en R5M4", ex); General.ReportarError(ex, Session["LOGIN"].ToString()); } return blnEjecutado; } private void EliminarResultado(int p_intPkResultado) //M5 { try { objResultadoBL = new ResultadoBL(); objResultadoBL.objResultadoEL.PK = p_intPkResultado; objResultadoBL.actualizaEstadoResultado(); } catch (Exception ex) { MensajeError("Error en R5M5", ex); General.ReportarError(ex, Session["LOGIN"].ToString()); } } #endregion #region Metodos Datos a Controles (R6) private void mostrarDatos() //M0 { try { limpiarCampos(); 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(); txtNumeroAccion.Text = dsProyecto.Tables[0].Rows[0]["NUMEROACCIONESTRATEGICAPROYECTO"].ToString(); txtMetaAccion.Text = dsProyecto.Tables[0].Rows[0]["METAACCIONESTRATEGICAPROYECTO"].ToString(); txtMetaInstitucional.Text = dsProyecto.Tables[0].Rows[0]["METAINSTITUCIONALPROYECTO"].ToString(); ddlPrioridad.SelectedValue = dsProyecto.Tables[0].Rows[0]["FKPRIORIDAD"].ToString(); txtDescripcion.Text = dsProyecto.Tables[0].Rows[0]["DESCRIPCIONPROYECTO"].ToString(); ddlAreaTematica.SelectedValue = dsProyecto.Tables[0].Rows[0]["FKAREATEMATICA"].ToString(); ddlInfluencia.SelectedValue = dsProyecto.Tables[0].Rows[0]["FKAREAINFLUENCIA"].ToString(); txtObjetivo.Text = dsProyecto.Tables[0].Rows[0]["OBJETIVOGENERALPROYECTO"].ToString(); txtBeneficioDir.Text = dsProyecto.Tables[0].Rows[0]["BENEFICIARIODIRECTOPROYECTO"].ToString(); txtBeneficioIndir.Text = dsProyecto.Tables[0].Rows[0]["BENEFICIARIOINDIRECTOPROYECTO"].ToString(); ddlDependencia.SelectedValue = dsProyecto.Tables[0].Rows[0]["FKDEPENDENCIA"].ToString(); ddlCategoria.SelectedValue = dsProyecto.Tables[0].Rows[0]["FKCATEGORIA"].ToString(); ddlSector.SelectedValue = dsProyecto.Tables[0].Rows[0]["FKSECTOR"].ToString(); txtPatrocinador.Text = dsProyecto.Tables[0].Rows[0]["PATROCINADORPROYECTO"].ToString(); txtTotalEstimado.Text = dsProyecto.Tables[0].Rows[0]["COSTOESTIMADOPROYECTO"].ToString(); txtLider.Text = dsProyecto.Tables[0].Rows[0]["LIDERPROYECTO"].ToString(); ddlComplejidad.SelectedValue = dsProyecto.Tables[0].Rows[0]["FKCOMPLEJIDAD"].ToString(); if (!string.IsNullOrWhiteSpace(txtNumeroBPIP.Text)) txtProyecto.ReadOnly = true; ddlRegion.SelectedValue = dsProyecto.Tables[0].Rows[0]["FKREGION"].ToString(); //MOSTRAR OBJETIVOS Y RESULTADOS llenarGridObjetivos(); llenarGridResultados(); //MOSTRAR UBICACIONES llenarGridUbicaciones(); //INFORMACION GENERAL txtEstadoProyecto.Text = string.IsNullOrEmpty(dsProyecto.Tables[0].Rows[0]["NOMBREESTADO"].ToString()) ? "Sin Asignar" : dsProyecto.Tables[0].Rows[0]["NOMBREESTADO"].ToString(); objInformacionGeneralBL = new InformacionGeneralBL(); objInformacionGeneralBL.objInformacionGeneralEL.Proyecto = Int32.Parse(Session["PKPROYECTO"].ToString()); DataSet dsInformacion = objInformacionGeneralBL.getInformacionGeneral(); if (dsInformacion.Tables[0].Rows.Count != 0) { ViewState["PkInformacionGeneral"] = dsInformacion.Tables[0].Rows[0]["PKINFORMACIONGENERAL"].ToString(); ; txtEncargado.Text = dsInformacion.Tables[0].Rows[0]["ENCARGADOINFORMACIONGENERAL"].ToString(); ddlRegionAyA.SelectedValue = dsInformacion.Tables[0].Rows[0]["PKREGION"].ToString(); ViewState["Modo_InfoGeneral"] = "Modifica"; } else if (dsInformacion.Tables[0].Rows.Count == 0) { ViewState["Modo_InfoGeneral"] = "Nuevo"; } } } catch (Exception ex) { MensajeError("Error en R6M0", ex); General.ReportarError(ex, Session["LOGIN"].ToString()); } } private void llenarGridObjetivos() //M1 { try { objObjetivoEspecificoBL = new ObjetivoEspecificoBL(); objObjetivoEspecificoBL.objObjetivoEspecificoEL.PK = 0; objObjetivoEspecificoBL.objObjetivoEspecificoEL.Proyecto = Int32.Parse(Session["PKPROYECTO"].ToString()); DataSet dsObjetivos = objObjetivoEspecificoBL.getObjetivoEspecifico(); detalleGRVDatos(dsObjetivos, grvObjetivosTemp); } catch (Exception ex) { MensajeError("Error en R6M1", ex); } } private void llenarGridResultados() //M2 { try { objResultadoBL = new ResultadoBL(); objResultadoBL.objResultadoEL.PK = 0; objResultadoBL.objResultadoEL.Proyecto = Int32.Parse(Session["PKPROYECTO"].ToString()); DataSet dsResultados = objResultadoBL.getResultados(); detalleGRVDatos(dsResultados, grvListaResultadosTemp); } catch (Exception ex) { MensajeError("Error en R6M2", ex); } } private void llenarDDLPrioridad() //M3 { try { //Limpia el control ddlPrioridad.Items.Clear(); //Instancia el objeto objCatalogoBL = new CatalogoBL(); objCatalogoBL.objCatalogoEL.PK = 0; objCatalogoBL.objCatalogoEL.Padre = 7; objCatalogoBL.objCatalogoEL.ASTATE = true; //Carga la información en un dataset DataSet dsPrioridad = objCatalogoBL.getCatalogo(); if (dsPrioridad.Tables[0].Rows.Count != 0) { ddlPrioridad.DataSource = dsPrioridad; ddlPrioridad.DataTextField = dsPrioridad.Tables[0].Columns["NOMBRECATALOGO"].ColumnName; ddlPrioridad.DataValueField = dsPrioridad.Tables[0].Columns["PKCATALOGO"].ColumnName; ddlPrioridad.DataBind(); ddlPrioridad.Items.Insert(0, new ListItem("Seleccione una Prioridad", "-1")); } } catch (Exception ex) { MensajeError("Error en R6M2", ex); } } private void llenarDDLDependencia() //M4 { try { //Limpia el control ddlDependencia.Items.Clear(); //Instancia el objeto objDependenciaBL = new DependenciaBL(); objDependenciaBL.objDependenciaEL.PK = 0; objDependenciaBL.objDependenciaEL.Padre = 0; objDependenciaBL.objDependenciaEL.ASTATE = true; //Carga la información en un dataset DataSet dsDependencia = objDependenciaBL.getDependencia(null); if (dsDependencia.Tables[0].Rows.Count != 0) { ddlDependencia.DataSource = dsDependencia; ddlDependencia.DataTextField = dsDependencia.Tables[0].Columns["NOMBREDEPENDENCIA"].ColumnName; ddlDependencia.DataValueField = dsDependencia.Tables[0].Columns["PKDEPENDENCIA"].ColumnName; ddlDependencia.DataBind(); ddlDependencia.Items.Insert(0, new ListItem("Seleccione una Dependencia", "-1")); } } catch (Exception ex) { MensajeError("Error en R6M4", ex); } } private void llenarDDLCategoria() //M5 { try { //Limpia el control ddlCategoria.Items.Clear(); objCatalogoBL = new CatalogoBL(); objCatalogoBL.objCatalogoEL.PK = 0; objCatalogoBL.objCatalogoEL.Padre = 11; objCatalogoBL.objCatalogoEL.ASTATE = true; DataSet dsCategoria = objCatalogoBL.getCatalogo(); if (dsCategoria.Tables[0].Rows.Count != 0) { ddlCategoria.DataSource = dsCategoria; ddlCategoria.DataTextField = dsCategoria.Tables[0].Columns["NOMBRECATALOGO"].ColumnName; ddlCategoria.DataValueField = dsCategoria.Tables[0].Columns["PKCATALOGO"].ColumnName; ddlCategoria.DataBind(); ddlCategoria.Items.Insert(0, new ListItem("Seleccione un Categoria", "-1")); } } catch (Exception ex) { MensajeError("Error en R6M5", ex); } } private void llenarDDLRegion() //M7 { try { //Limpia el control ddlRegion.Items.Clear(); //Instancia el objeto objRegionBL = new RegionBL(); objRegionBL.objRegionEL.PK = 0; objRegionBL.objRegionEL.Padre = 2; objRegionBL.objRegionEL.ASTATE = true; DataSet dsRegion = objRegionBL.getRegion(); if (dsRegion.Tables[0].Rows.Count != 0) { ddlRegion.DataSource = dsRegion; ddlRegion.DataTextField = dsRegion.Tables[0].Columns["NOMBREREGION"].ColumnName; ddlRegion.DataValueField = dsRegion.Tables[0].Columns["PKREGION"].ColumnName; ddlRegion.DataBind(); ddlRegion.Items.Insert(0, new ListItem("Seleccione una Región", "-1")); } } catch (Exception ex) { MensajeError("Error en R6M7", ex); } } private void llenarDDLAreaTematica() //M8 { try { //Limpia el control ddlAreaTematica.Items.Clear(); //Instancia el objeto objCatalogoBL = new CatalogoBL(); objCatalogoBL.objCatalogoEL.PK = 0; objCatalogoBL.objCatalogoEL.Padre = 4; objCatalogoBL.objCatalogoEL.ASTATE = true; DataSet dsAreaTematica = objCatalogoBL.getCatalogo(); if (dsAreaTematica.Tables[0].Rows.Count != 0) { ddlAreaTematica.DataSource = dsAreaTematica; ddlAreaTematica.DataTextField = dsAreaTematica.Tables[0].Columns["NOMBRECATALOGO"].ColumnName; ddlAreaTematica.DataValueField = dsAreaTematica.Tables[0].Columns["PKCATALOGO"].ColumnName; ddlAreaTematica.DataBind(); ddlAreaTematica.Items.Insert(0, new ListItem("Seleccione un AreaTematica", "-1")); } } catch (Exception ex) { MensajeError("Error en R6M8", ex); } } private void llenarDDLSector() //M9 { try { //Limpia el control ddlSector.Items.Clear(); objCatalogoBL = new CatalogoBL(); objCatalogoBL.objCatalogoEL.PK = 0; objCatalogoBL.objCatalogoEL.Padre = 1; objCatalogoBL.objCatalogoEL.ASTATE = true; DataSet dsSector = objCatalogoBL.getCatalogo(); if (dsSector.Tables[0].Rows.Count != 0) { ddlSector.DataSource = dsSector; ddlSector.DataTextField = dsSector.Tables[0].Columns["NOMBRECATALOGO"].ColumnName; ddlSector.DataValueField = dsSector.Tables[0].Columns["PKCATALOGO"].ColumnName; ddlSector.DataBind(); ddlSector.Items.Insert(0, new ListItem("Seleccione un Sector", "-1")); } } catch (Exception ex) { MensajeError("Error en R6M9", ex); } } private void llenarDDLInfluencia() //M10 { try { //Limpia el control ddlInfluencia.Items.Clear(); objCatalogoBL = new CatalogoBL(); objCatalogoBL.objCatalogoEL.PK = 0; objCatalogoBL.objCatalogoEL.Padre = 43; objCatalogoBL.objCatalogoEL.ASTATE = true; DataSet dsInfluencia = objCatalogoBL.getCatalogo(); if (dsInfluencia.Tables[0].Rows.Count != 0) { ddlInfluencia.DataSource = dsInfluencia; ddlInfluencia.DataTextField = dsInfluencia.Tables[0].Columns["NOMBRECATALOGO"].ColumnName; ddlInfluencia.DataValueField = dsInfluencia.Tables[0].Columns["PKCATALOGO"].ColumnName; ddlInfluencia.DataBind(); //ddlInfluencia.Items.Insert(0, new ListItem("Seleccione la Influencia del Proyecto", "-1")); } } catch (Exception ex) { MensajeError("Error en R6M10", ex); } } private void mostrarObjetivos() //M11 { try { limpiarObjetivos(); objObjetivoEspecificoBL = new ObjetivoEspecificoBL(); objObjetivoEspecificoBL.objObjetivoEspecificoEL.PK = Int32.Parse(ViewState["PkObjetivo"].ToString()); DataSet dsObjetivo = objObjetivoEspecificoBL.getObjetivoEspecifico(); txtNumeracionOE.Text = dsObjetivo.Tables[0].Rows[0]["NUMEROOBJETIVOESPECIFICO"].ToString(); txtObjetivoEspecifico.Text = dsObjetivo.Tables[0].Rows[0]["DESCRIPCIONOBJETIVOESPECIFICO"].ToString(); chkCumplido.Checked = bool.Parse(dsObjetivo.Tables[0].Rows[0]["CUMPLIDOOBJETIVOESPECIFICO"].ToString()); } catch (Exception ex) { MensajeError("Error en R6M11", ex); General.ReportarError(ex, Session["LOGIN"].ToString()); } } private void mostrarResultados() //M12 { try { limpiarResultados(); objResultadoBL = new ResultadoBL(); objResultadoBL.objResultadoEL.PK = Int32.Parse(ViewState["PkResultado"].ToString()); DataSet dsResultado = objResultadoBL.getResultados(); txtNumeracionRS.Text = dsResultado.Tables[0].Rows[0]["NUMERORESULTADO"].ToString(); txtResultado.Text = dsResultado.Tables[0].Rows[0]["DESCRIPCIONRESULTADO"].ToString(); } catch (Exception ex) { MensajeError("Error en R6M12", ex); General.ReportarError(ex, Session["LOGIN"].ToString()); } } private void llenarDDLRegionAyA() //M13 { try { //Limpia el control ddlRegion.Items.Clear(); //Instancia el objeto objRegionBL = new RegionBL(); objRegionBL.objRegionEL.PK = 0; objRegionBL.objRegionEL.Padre = 1; objRegionBL.objRegionEL.ASTATE = true; DataSet dsRegionAyA = objRegionBL.getRegion(); if (dsRegionAyA.Tables[0].Rows.Count != 0) { ddlRegionAyA.DataSource = dsRegionAyA; ddlRegionAyA.DataTextField = dsRegionAyA.Tables[0].Columns["NOMBREREGION"].ColumnName; ddlRegionAyA.DataValueField = dsRegionAyA.Tables[0].Columns["PKREGION"].ColumnName; ddlRegionAyA.DataBind(); } ddlRegionAyA.Items.Insert(0, new ListItem("Seleccione una Región AyA", "-1")); } catch (Exception ex) { MensajeError("Error en R6M13", ex); } } private void llenarGridUbicaciones() //M15 { try { objUbicacionBL = new UbicacionBL(); DataSet dsUbicaciones = objUbicacionBL.getUbicacion(Int32.Parse(Session["PKPROYECTO"].ToString())); detalleGRVDatos(dsUbicaciones, grvUbicacionesTemp); } catch (Exception ex) { MensajeError("Error en R6M15", ex); } } private void llenarDDLComplejidad() //M16 { try { //Instancia el objeto objComplejidadBL = new ComplejidadBL(); objComplejidadBL.objComplejidadEL.Padre = 0; objComplejidadBL.objComplejidadEL.PK = 0; objComplejidadBL.objComplejidadEL.ASTATE = true; DataSet dsComplejidades = objComplejidadBL.getComplejidad(null); ddlComplejidad.DataSource = dsComplejidades; ddlComplejidad.DataTextField = dsComplejidades.Tables[0].Columns["NOMBRECOMPLEJIDAD"].ColumnName; ddlComplejidad.DataValueField = dsComplejidades.Tables[0].Columns["PKCOMPLEJIDAD"].ColumnName; ddlComplejidad.DataBind(); ddlComplejidad.Items.Insert(0, new ListItem("Seleccione una opción", "-1")); } catch (Exception ex) { MensajeError("Error en R6M16", ex); General.ReportarError(ex, Session["LOGIN"].ToString()); } } private void mostrarSeccion(string pSeccion) { try { divGridUbicaciones.Visible = false; divAdminUbicaciones.Visible = false; switch (pSeccion) { case "divGridUbicaciones": llenarGridUbicaciones(); divGridUbicaciones.Visible = true; break; case "divAdminUbicaciones": divAdminUbicaciones.Visible = true; llenarGridAdminUbicaciones(); break; } } catch (Exception ex) { MensajeError("Error en R4M1", ex); } } #endregion #region Administrar Ubicaciones protected void btnAgregarUbicacion_Click(object sender, EventArgs e) //M14 { try { var FKDISTRITO = ddlDistrito.SelectedValue; var FKBARRIO = txtBarrio.Text; string[] VBARRIOS; objUbicacionBL = new UbicacionBL(); objUbicacionBL.objUbicacionEL.FK = Int32.Parse(Session["PKPROYECTO"].ToString()); objUbicacionBL.objUbicacionEL.FKUBICACIONDISTRITO = string.IsNullOrWhiteSpace(FKDISTRITO) ? 0 : Convert.ToInt32(FKDISTRITO); if (!FKBARRIO.Contains(",")) { objUbicacionBL.objUbicacionEL.FKUBICACIONBARRIO = string.IsNullOrWhiteSpace(FKBARRIO) ? 0 : Convert.ToInt32(FKBARRIO); if (objUbicacionBL.InsertarUbicacionProyecto()) { GuardarEventoBitacora( Session["LOGIN"].ToString(), AccionBitacora.INSERT.ToString(), MensajesBitacora.IngresarRegistro + ": Proyecto: " + Session["PKPROYECTO"].ToString() + "." + "Descripcion: " + txtProyecto.Text + "Distrito: " + FKDISTRITO + "Barrio: " + FKBARRIO, "wfrAspectosGenerales.aspx"); MensajeInformativo("Ubicación agregada correctamente"); llenarGridAdminUbicaciones(); } else { MensajeAdvertencia("No se pudo agregar la ubicación indicada, por favor verifique que no exista un registro con el mismo valor"); } return; } VBARRIOS = FKBARRIO.Split(','); var vError = false; foreach (var VBARRIO in VBARRIOS) { objUbicacionBL.objUbicacionEL.FKUBICACIONBARRIO = Convert.ToInt32(VBARRIO); if (objUbicacionBL.InsertarUbicacionProyecto()) { GuardarEventoBitacora( Session["LOGIN"].ToString(), AccionBitacora.INSERT.ToString(), MensajesBitacora.IngresarRegistro + ": Proyecto: " + Session["PKPROYECTO"].ToString() + "." + "Descripcion: " + txtProyecto.Text + "Distrito: " + FKDISTRITO + "Barrio: " + FKBARRIO, "wfrAspectosGenerales.aspx"); } else vError = true; } if (vError) MensajeAdvertencia("No se pudo agregar la ubicación indicada, por favor verifique que no exista un registro con el mismo valor"); else { MensajeInformativo("Ubicación agregada correctamente"); llenarGridAdminUbicaciones(); } } catch (Exception ex) { MensajeError("Error en R3M14", ex); } } protected void btnRegresar_Click(object sender, EventArgs e) //M14 { try { mostrarSeccion(divGridUbicaciones.ID); } catch (Exception ex) { MensajeError("Error en R3M14", ex); } } protected void grvAdministrarUbicaciones_RowCommand(object sender, GridViewCommandEventArgs e) { try { int i = Convert.ToInt32(e.CommandArgument); int FKUBICACIONBARRIO; int FKUBICACIONDISTRITO; GridViewRow selectedRow = grvAdministrarUbicaciones.Rows[i]; FKUBICACIONDISTRITO = Convert.ToInt32(selectedRow.Cells[4].Text); FKUBICACIONBARRIO = string.IsNullOrWhiteSpace(selectedRow.Cells[6].Text) || selectedRow.Cells[6].Text == " " ? 0 : Convert.ToInt32(selectedRow.Cells[5].Text); objUbicacionBL = new UbicacionBL(); objUbicacionBL.objUbicacionEL.FK = Int32.Parse(Session["PKPROYECTO"].ToString()); objUbicacionBL.objUbicacionEL.FKUBICACIONBARRIO = FKUBICACIONBARRIO; objUbicacionBL.objUbicacionEL.FKUBICACIONDISTRITO = FKUBICACIONDISTRITO; switch (e.CommandName) { case "remover": if (objUbicacionBL.borradoLogicoUbicacionProyecto()) { //MensajeInformativo("Ubicación eliminada correctamente"); llenarGridAdminUbicaciones(); } else MensajeAdvertencia("Error al tratar de eliminar la ubicación"); break; } } catch (Exception ex) { } } protected void ddlCanton_SelectedIndexChanged(object sender, EventArgs e) { llenarDDLUbicacion(ddlDistrito, Convert.ToInt32(ddlCanton.SelectedValue)); } protected void ddlProvincia_SelectedIndexChanged(object sender, EventArgs e) { llenarDDLUbicacion(ddlCanton, Convert.ToInt32(ddlProvincia.SelectedValue)); } /// /// Metodo encargado de obtener las ubicaciones asociadas /// /// Corresponde al identificador de la ubicacion /// private DataSet obtenerUbicaciones(int? PKUBICACION) //M14 { try { //Instancia el objeto objUbicacionBL = new UbicacionBL(); objUbicacionBL.objUbicacionEL.PK = 0; objUbicacionBL.objUbicacionEL.Padre = PKUBICACION; objUbicacionBL.objUbicacionEL.ASTATE = true; return objUbicacionBL.getUbicacion(); } catch (Exception ex) { MensajeError("Error en R6M14", ex); } return null; } private void llenarDDLUbicacion(DropDownList pDropDownList, int? PKUBICACION) //M6 { try { pDropDownList.Items.Clear(); if (!PKUBICACION.HasValue || PKUBICACION == 0) { pDropDownList.Items.Insert(0, new ListItem("Sin ubicaciones asociadas", "0")); return; } var vUbicaciones = obtenerUbicaciones(PKUBICACION); if (vUbicaciones.Tables[0].Rows.Count != 0) { pDropDownList.DataSource = vUbicaciones; pDropDownList.DataTextField = vUbicaciones.Tables[0].Columns["NOMBREUBICACION"].ColumnName; pDropDownList.DataValueField = vUbicaciones.Tables[0].Columns["PKUBICACION"].ColumnName; pDropDownList.DataBind(); pDropDownList.Items.Insert(0, new ListItem("Seleccione una ubicación", "0")); } else { pDropDownList.Items.Insert(0, new ListItem("Sin ubicaciones asociadas", "0")); } pDropDownList.SelectedValue = "0"; } catch (Exception ex) { MensajeError("Error en R6M6", ex); } } private void llenarGridAdminUbicaciones() { try { objUbicacionBL = new UbicacionBL(); DataSet dsUbicaciones = objUbicacionBL.getUbicacionProyecto(Int32.Parse(Session["PKPROYECTO"].ToString())); detalleGRVDatos(dsUbicaciones, grvAdministrarUbicaciones); updPanel.Update(); } catch (Exception ex) { MensajeError("Error en R6M15", ex); } } #region WebMethods [WebMethod] public static string llenarDDLUbicaciones(int PKUBICACION) { List lstBarrios = new List(); JavaScriptSerializer _Json = new JavaScriptSerializer(); try { //Instancia el objeto AyABL.ADM.UbicacionBL objUbicacionBL = new AyABL.ADM.UbicacionBL(); objUbicacionBL.objUbicacionEL.PK = 0; objUbicacionBL.objUbicacionEL.Padre = PKUBICACION; objUbicacionBL.objUbicacionEL.ASTATE = true; DataSet dsProvincia = objUbicacionBL.getUbicacion(); foreach (DataRow drProvincia in dsProvincia.Tables[0].Rows) { var infoProvincia = new UbicacionEL { PK = int.Parse(drProvincia["PKUBICACION"].ToString()), Nombre = drProvincia["NOMBREUBICACION"].ToString() }; lstBarrios.Add(infoProvincia); } } catch (Exception ex) { return null; //MensajeError("Error en R6M", ex); } return _Json.Serialize(lstBarrios); } [WebMethod] public static string agregarUbicacion(string FKDISTRITO, string FKBARRIO, int FKPROYECTO) { var msg = string.Empty; try { AyABL.ADM.UbicacionBL objUbicacionBL = new UbicacionBL(); objUbicacionBL.objUbicacionEL.FK = FKPROYECTO; objUbicacionBL.objUbicacionEL.FKUBICACIONBARRIO = string.IsNullOrWhiteSpace(FKBARRIO) ? 0 : Convert.ToInt32(FKBARRIO); objUbicacionBL.objUbicacionEL.FKUBICACIONDISTRITO = string.IsNullOrWhiteSpace(FKDISTRITO) ? 0 : Convert.ToInt32(FKDISTRITO); if (objUbicacionBL.InsertarUbicacionProyecto()) msg = "OK"; } catch (Exception ex) { msg = ex.ToString(); } return msg; } #endregion #endregion }