//Comentario de ejemplo protected void Page_Load(object sender, EventArgs e) { uow = new UnitOfWork(Session["IdUser"].ToString()); if (!IsPostBack) { string M = string.Empty; int idPOADetalle = Request.QueryString["pd"] != null?Utilerias.StrToInt(Request.QueryString["pd"].ToString()) : 0; int idObra = Request.QueryString["ob"] != null?Utilerias.StrToInt(Request.QueryString["ob"].ToString()) : 0; //Se recupera el id del objeto OBRA int ordenPlantilla = Utilerias.StrToInt(Request.QueryString["o"].ToString()); //Se recupera el orden de la plantilla que sera evaluada BindControlesObra(idObra, idPOADetalle); //Se bindean los datos del poadetalle, se pasa como argumento el ID, recuperado de la sesion Plantilla plantilla = uow.PlantillaBusinessLogic.Get(p => p.Orden == ordenPlantilla).FirstOrDefault(); idPOADetalle = Utilerias.StrToInt(_IDPOADetalle.Value); //DEPENDIENDO DE DONDE SE HAYA LLAMADO LA EVALUACION, SE COLOCA EL POADETALLEID POAPlantilla poaPlantilla = uow.POAPlantillaBusinessLogic.Get(pp => pp.PlantillaId == plantilla.Id && pp.POADetalleId == idPOADetalle).FirstOrDefault(); //Se recupera POAPlantilla if (poaPlantilla == null) //Si no existe ningun objeto con la plantilla creada, entonces se procede a clonar la plantilla { M = CopiarPlantilla(plantilla.Id); } else { M = CrearPreguntasInexistentes(poaPlantilla.Id); //Se obtienen todas aquellas preguntas que se pudieron haber creado en las plantillas despues de HABER creado la clonada de plantillas, } //Si hubo errores if (!M.Equals(string.Empty)) { lblMsgImportarPlantilla.Text = M; lblMsgImportarPlantilla.ForeColor = System.Drawing.Color.Red; divMsgImportarPlantilla.Style.Add("display", "block"); return; } //Se carga la informacion de la plantilla clonada BindArbol(treePOAPlantilla); //Se bindea el arbol de las plantillas que se seleccionaron, las que se van a usar if (treePOAPlantilla.Nodes.Count > 0) //Si existen plantillas cargadas, se bindea el grid de preguntas para la primera plantilla { BindGrid(Utilerias.StrToInt(treePOAPlantilla.Nodes[0].Value)); _IDPlantilla.Value = treePOAPlantilla.Nodes[0].Value; treePOAPlantilla.Nodes[0].Selected = true; } _SoloChecks.Value = "true"; //Hidden que indica cuando solo se van a guardar las respuetas de las preguntas (NO, SI, NO APLICA) } //Evento que se ejecuta en JAVASCRIPT para evitar que se 'RESCROLLEE' el arbol al seleccionar un NODO y no se pierda el nodo seleccionado ClientScript.RegisterStartupScript(this.GetType(), "script", "SetSelectedTreeNodeVisible('<%= TreeViewName.ClientID %>_SelectedNode')", true); }
/// <summary> /// metodo encargado de bindear el grid de preguntas que marcara el usuario como NO, SI, NO APLICA /// Creado por Rigberto TS /// 29/09/2014 /// </summary> /// </summary> /// <param name="idPlantilla">ID de la plantilla que haya seleccionado el usuario</param> private void BindGrid(int idPlantilla) { int IDPOADetalle = Utilerias.StrToInt(_IDPOADetalle.Value); POAPlantilla obj = uow.POAPlantillaBusinessLogic.Get(e => e.POADetalleId == IDPOADetalle && e.PlantillaId == idPlantilla).FirstOrDefault(); if (obj != null) { grid.PageIndex = Utilerias.StrToInt(_PageIndex.Value); grid.DataSource = obj.Detalles.OrderBy(e => e.PlantillaDetalle.Orden).ToList(); grid.DataBind(); } }
/// <summary> /// Metodo encargado de Importar la plantilla del catalogo de plantillas que haya elegido el usuario en el show modal /// Se crean objetos en POAPlantilla /// Creado por Rigoberto TS /// 29/09/2014 /// </summary> /// </summary> /// <param name="IDPlantilla">ID de la plantilla que eligio el usuario</param> /// <returns>Regresa una cadena. Vacia si no hay errores</returns> public string ImportarPlantilla(int IDPlantilla) { string M = string.Empty; int IDPoaDetalle = Utilerias.StrToInt(_IDPOADetalle.Value); //Se obtiene el OBJ de la PLANTILLA PADRE QUE SE ELIGIO Plantilla objPlantilla = uow.PlantillaBusinessLogic.GetByID(IDPlantilla); #region CREAR EN PRIMERA INSTANCIA POAPLANTILLA CON DATOS DE LA PLANTILLA PADRE QUE SE ELIGIO //Se crea el OBJ de POAPlantilla, con los datos del la plantilla PADRE que se obtuvo POAPlantilla obj = new POAPlantilla(); obj.PlantillaId = IDPlantilla; obj.POADetalleId = IDPoaDetalle; //SE ALMACENA EL POAPLANTILLA uow.POAPlantillaBusinessLogic.Insert(obj); uow.SaveChanges(); //Si hubo errores if (uow.Errors.Count > 0) { M = string.Empty; foreach (string cad in uow.Errors) { M += cad; } return(M); } //Se crea detalle de preguntas en POAPLANTILLADETALLE M = ImportarDetallePlantilla(objPlantilla.DetallePreguntas.ToList(), obj.Id); //Si hubo errores if (!M.Equals(string.Empty)) { return(M); } #endregion #region CREAR POAPLANTILLASDETALLE TANTAS COMO SUBPLANTILLAS EXISTAN //Se Crean tantos POAPlantilla como subplantillas tenga el OBJ de la PLANTILLA PADRE QUE SE ELIGIO if (objPlantilla.Detalles.Count > 0) { foreach (Plantilla p in objPlantilla.Detalles) { obj = null; //Se crea el OBJ de POAPlantilla, con los datos del la plantilla PADRE que se obtuvo obj = new POAPlantilla(); obj.PlantillaId = p.Id; obj.POADetalleId = IDPoaDetalle; //SE ALMACENA EL POAPLANTILLA uow.POAPlantillaBusinessLogic.Insert(obj); uow.SaveChanges(); //Si hubo errores if (uow.Errors.Count > 0) { M = string.Empty; foreach (string cad in uow.Errors) { M += cad; } return(M); } //Se crea detalle de preguntas en POAPLANTILLADETALLE M = ImportarDetallePlantilla(p.DetallePreguntas.ToList(), obj.Id); //Si hubo errores if (!M.Equals(string.Empty)) { return(M); } } } #endregion return(M); }