private void CargarProyectoNegocio(int _convocatoria) { try { var proyectoDeEvaluacion = (from p in consultas.Db.pr_ProyectosEvaluados(Convert.ToInt32(ViewState["idacta"]), _convocatoria) select p).ToList(); if (proyectoDeEvaluacion.Count != 0) { GrvPlanesNegocio.DataSource = proyectoDeEvaluacion; GrvPlanesNegocio.DataBind(); } } catch (Exception ex) { GrvPlanesNegocio.DataSource = null; GrvPlanesNegocio.DataBind(); } }
/// <summary> /// Evento de RowCommand /// </summary> protected void GrvPlanesNegocio_RowCommand(object sender, GridViewCommandEventArgs e) { try { switch (e.CommandName) { case "proyecto": if (usuario.CodGrupo == Constantes.CONST_GerenteInterventor) { Response.Redirect("~/Fonade/evaluacion/AccesoDenegado.aspx"); } else { HttpContext.Current.Session["CodProyecto"] = e.CommandArgument.ToString(); HttpContext.Current.Session["CodConvocatoria"] = DdlCodConvocatoria.SelectedValue; Response.Redirect("EvaluacionFrameSet.aspx"); } break; case "evaluador": HttpContext.Current.Session["codcontacto"] = e.CommandArgument; Redirect(null, "VerPerfilContacto.aspx", "_blank", "menubar=0,scrollbars=1,width=710,height=400,top=100"); break; case "eliminar": var idacta = Convert.ToInt32(HttpContext.Current.Session["idacta"] ?? 0); var codproyecto = Convert.ToInt32(e.CommandArgument); var actaEvaluacion = consultas.Db.EvaluacionActas.FirstOrDefault(p => p.Id_Acta == idacta); if (actaEvaluacion == null) { throw new ApplicationException("No se pudo obtener el acta final de validación"); } if (actaEvaluacion.publicado.Value) { throw new ApplicationException("No se puede eliminar el proyecto porque el acta se encuentra publicada."); } var proyectoEvaluacion = consultas.Db.EvaluacionActaProyectos.FirstOrDefault(p => p.CodActa == idacta && p.CodProyecto == codproyecto); if (proyectoEvaluacion == null) { throw new ApplicationException("No se pudo obtener la información del proyecto del acta final de validación"); } consultas.Db.EvaluacionActaProyectos.DeleteOnSubmit(proyectoEvaluacion); consultas.Db.SubmitChanges(); GrvPlanesNegocio.DataBind(); ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "Mensaje", "alert(' El proyecto fue eliminado satisfactoriamente. ');", true); break; default: break; } } catch (ApplicationException ex) { ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "Mensaje", "alert('Sucedio un error, intentelo de nuevo. detalle : " + ex.Message + " ');", true); } catch (Exception ex) { ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "Mensaje", "alert('Sucedio un error. detalle : " + ex.Message + " ');", true); } }