Beispiel #1
0
        /// <summary>
        /// Evento que se dispara cuando se da clic en el boton de editar, se preparan los controles para que el usuario ueda modificar los datos
        /// Credo por Rigoberto TS
        /// 10/10/2014
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void imgBtnEdit_Click(object sender, ImageClickEventArgs e)
        {
            txtObservacionesPregunta.Disabled = false;
            btnBuscarArchivo.Enabled          = true;

            GridViewRow row = (GridViewRow)((ImageButton)sender).NamingContainer;

            int id = Convert.ToInt32(grid.DataKeys[row.RowIndex].Values["Id"].ToString());

            _IDPregunta.Value = id.ToString();

            POAPlantillaDetalle obj = uow.POAPlantillaDetalleBusinessLogic.GetByID(id);

            txtPregunta.Value = obj.PlantillaDetalle.Pregunta;
            txtObservacionesPregunta.Value = obj.Observaciones;
            txtArchivoAdjunto.Value        = obj.NombreArchivo != null && obj.NombreArchivo != string.Empty ? obj.NombreArchivo : string.Empty;

            divEvaluacion.Style.Add("display", "block");
            divDatos.Style.Add("display", "none");
            divMsgError.Style.Add("display", "none");
            divMsgSuccess.Style.Add("display", "none");
            divCapturaPreguntas.Style.Add("display", "block");

            _SoloChecks.Value = "false"; //Se indica que tambien se almacenaran datos de la PREGUNTA, no solo las respuestas SI, NO, NO APLICA

            divBtnGuardarDatosPreguntas.Style.Add("display", "block");

            btnCancelar.Disabled = false;
        }
Beispiel #2
0
        /// <summary>
        /// Metodo encargado de crear la lista de preguntas que contiene la Plantilla que haya elegido el usuario en el show modal
        /// Se crean objetos en POAPLANTILLADETALLE
        /// Creado por Rigoberto TS
        /// 29/09/2014
        /// </summary>
        /// </summary>
        /// <param name="DetallePreguntas">Lista de Preguntas (objeto PlantillaDetalle)</param>
        /// <param name="IDPOAPlantilla">ID del objeto POAPlantilla que se creo con la plantilla que eligio el usuario</param>
        /// <returns>Regresa una cadena. vacia si no hay errores</returns>
        public string ImportarDetallePlantilla(List <PlantillaDetalle> DetallePreguntas, int IDPOAPlantilla)
        {
            string M = string.Empty;

            //Se crean OBJs de POAPlantillaDetalle, que es la que almacenara todas las preguntas de la plantilladetalle
            //Se recorre el detalle de preguntas que trae la plantilladetalle
            foreach (PlantillaDetalle pregunta in DetallePreguntas)
            {
                POAPlantillaDetalle objPOAPlantillaDetalle = new POAPlantillaDetalle();
                objPOAPlantillaDetalle.POAPlantillaId     = IDPOAPlantilla; //ID del obj POAPlantilla
                objPOAPlantillaDetalle.PlantillaDetalleId = pregunta.Id;    //Id del obj Plantilla detalle

                //Se agregan mas datos, los de bitacora....pendiente

                uow.POAPlantillaDetalleBusinessLogic.Insert(objPOAPlantillaDetalle);
                uow.SaveChanges();

                //Si hubo errores
                if (uow.Errors.Count > 0)
                {
                    M = string.Empty;
                    foreach (string cad in uow.Errors)
                    {
                        M += cad;
                    }

                    return(M);
                }
            }

            return(M);
        }
Beispiel #3
0
        public static List <string> GuardarDatosPlantilla(string idPregunta, string observacion, string nombreArchivo)
        {
            string        M = string.Empty;
            List <string> R = new List <string>();

            UnitOfWork uow = new UnitOfWork();

            POAPlantillaDetalle obj = uow.POAPlantillaDetalleBusinessLogic.GetByID(Utilerias.StrToInt(idPregunta));

            if (obj != null)
            {
                obj.Observaciones = observacion;

                string fullPath = Path.GetFullPath(nombreArchivo);

                FileInfo fileInfo = new FileInfo(nombreArchivo);

                List <string> R2 = null;// GuardarArchivo(fullPath, nombreArchivo, idPregunta);

                if (!R2[0].Equals(string.Empty))
                {
                    R.Add(R2[0]);
                    return(R);
                }

                obj.RutaArchivo = nombreArchivo;

                uow.POAPlantillaDetalleBusinessLogic.Update(obj);
                uow.SaveChanges();

                //Si hubo errores
                if (uow.Errors.Count > 0)
                {
                    M = string.Empty;
                    foreach (string cad in uow.Errors)
                    {
                        M += cad;
                    }

                    R.Add(M);
                    return(R);
                }
            }

            R.Add(M);
            return(R);
        }
Beispiel #4
0
        public static List <string> GetValoresPregunta(string idPregunta)
        {
            List <string> R = new List <string>();

            UnitOfWork uow = new UnitOfWork();

            POAPlantillaDetalle obj = uow.POAPlantillaDetalleBusinessLogic.GetByID(Utilerias.StrToInt(idPregunta));

            if (obj != null)
            {
                R.Add(obj.Observaciones != null && obj.Observaciones != string.Empty ? obj.Observaciones : string.Empty);
                R.Add(obj.NombreArchivo != null && obj.NombreArchivo != string.Empty?obj.NombreArchivo:string.Empty);
                R.Add(obj.PlantillaDetalle.Pregunta);
            }

            return(R);
        }
Beispiel #5
0
        /// <summary>
        /// Metodo encagado ya de modificar el objeto de POAPlantillaDetalle, colocando ya en la RESPUESTA, un valor segun sea lo que se haya marcado SI, NO, NO APLICA
        /// Creado por Rigoberto TS
        /// 05/10/2014
        /// </summary>
        /// <param name="idPregunta">ID de la Pregunta (POAPlantillaDetalle)</param>
        /// <param name="respuesta">RESPUESTA que marco el usuario (1=SI, 2=NO, 3=NO APLICA)</param>
        /// <returns></returns>
        public static string GuardarPlantillaChecks(string idPregunta, string respuesta, UnitOfWork _uow, int idUser)
        {
            string     M   = string.Empty;
            UnitOfWork uow = _uow;

            int id = Utilerias.StrToInt(idPregunta);
            POAPlantillaDetalle pregu = uow.POAPlantillaDetalleBusinessLogic.GetByID(id);

            if (pregu != null)
            {
                switch (respuesta) //Segun la respuesta, se asigna el valor
                {
                case "1":
                    pregu.Respuesta = enumRespuesta.Si;
                    break;

                case "2":
                    pregu.Respuesta = enumRespuesta.No;
                    break;

                case "3":
                    pregu.Respuesta = enumRespuesta.NoAplica;
                    break;
                }
                pregu.EditedById = idUser;
                uow.POAPlantillaDetalleBusinessLogic.Update(pregu);
                uow.SaveChanges();

                //Si hubo errores
                if (uow.Errors.Count > 0)
                {
                    M = string.Empty;
                    foreach (string cad in uow.Errors)
                    {
                        M += cad;
                    }


                    return(M);
                }
            }


            return(M);
        }
Beispiel #6
0
        /// <summary>
        /// Metodo encargado de obtner las nuevas preguntas de una plantilla que se hayan creado
        /// posterior o despues de haber clonado la plantilla
        /// Se obtienen y se agregan a POAPLANTILLADETALLE
        /// Creado por Rigoberto TS
        /// 20/10/2014
        /// </summary>
        /// <param name="POAPlantillaID"></param>
        /// <returns></returns>
        private string CrearPreguntasInexistentes(int POAPlantillaID)
        {
            int    ordenPlantilla = Utilerias.StrToInt(Request.QueryString["o"].ToString());
            string M = string.Empty;

            //Consulta que hace la diferencia de preguntas entre POAPLANTILLADETALLE y PLANTILLADETALLE
            var list = (from p in uow.PlantillaDetalleBusinessLogic.Get()
                        join pp in uow.PlantillaBusinessLogic.Get(e => e.Orden == ordenPlantilla).ToList()
                        on p.PlantillaId equals pp.Id
                        join po in uow.POAPlantillaDetalleBusinessLogic.Get()
                        on p.Id equals po.PlantillaDetalleId into temp
                        from pi in temp.DefaultIfEmpty()
                        select new { p.Id, pp.Orden, pregunta = (pi == null ? 0 : pi.PlantillaDetalleId) });


            foreach (var obj in list)
            {
                if (obj.pregunta == 0)
                {
                    POAPlantillaDetalle objPOAPlantillaDetalle = new POAPlantillaDetalle();
                    objPOAPlantillaDetalle.POAPlantillaId     = POAPlantillaID; //ID del obj POAPlantilla
                    objPOAPlantillaDetalle.PlantillaDetalleId = obj.Id;         //Id del obj Plantilla detalle


                    uow.POAPlantillaDetalleBusinessLogic.Insert(objPOAPlantillaDetalle);
                    uow.SaveChanges();

                    //Si hubo errores
                    if (uow.Errors.Count > 0)
                    {
                        M = string.Empty;
                        foreach (string cad in uow.Errors)
                        {
                            M += cad;
                        }

                        return(M);
                    }
                }
            }

            return(M);
        }
Beispiel #7
0
        /// <summary>
        /// Evento encargado de almacenar los datos de la pregunta que se este editando, ademas de las respuestas que haya marcado el usuario
        /// Creado por Rigoberto TS
        /// 10/10/2014
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnGuardarDatosPreguntas_ServerClick(object sender, EventArgs e)
        {
            string        M = string.Empty;
            List <string> R = new List <string>();

            if (!Convert.ToBoolean(_SoloChecks.Value))
            {
                //Siempre se van a actualizar datos de la pregunta (Observaciones y el archivo de soporte)
                int idPregunta = Utilerias.StrToInt(_IDPregunta.Value);
                _SoloChecks.Value = "true";
                string nomAnterior      = string.Empty;
                POAPlantillaDetalle obj = uow.POAPlantillaDetalleBusinessLogic.GetByID(idPregunta);

                nomAnterior = obj.NombreArchivo;

                //Se tiene que almacenar el archivo adjunto, si es que se cargo uno
                if (!btnBuscarArchivo.PostedFile.FileName.Equals(string.Empty))
                {
                    //Validar el tamaño del archivo
                    if (btnBuscarArchivo.FileBytes.Length > 10485296)
                    {
                        divMsgError.Style.Add("display", "block");
                        divMsgSuccess.Style.Add("display", "none");
                        lblMsgError.Text = "Se ha excedido en el tamaño del archivo, el máximo permitido es de 10 Mb";

                        return;
                    }


                    if (nomAnterior != null)
                    {
                        if (!nomAnterior.Equals(Path.GetFileName(btnBuscarArchivo.FileName)))  //Se elimina el archivo anterior
                        {
                            if (!nomAnterior.Equals(string.Empty))
                            {
                                M = EliminarArchivo(obj.Id, nomAnterior);
                            }
                        }
                    }


                    R = GuardarArchivo(btnBuscarArchivo.PostedFile, idPregunta); //Se guarda el archivo

                    //Si hubo errores
                    if (!R[0].Equals(string.Empty))
                    {
                        divMsgError.Style.Add("display", "block");
                        divMsgSuccess.Style.Add("display", "none");
                        lblMsgError.Text = R[0];
                        return;
                    }

                    //Se guarda el objeto con la informacion del archivo y sus datos correspondientes
                    obj.NombreArchivo = Path.GetFileName(btnBuscarArchivo.FileName);
                    obj.TipoArchivo   = btnBuscarArchivo.PostedFile.ContentType;
                }


                obj.Observaciones = txtObservacionesPregunta.Value;


                uow.POAPlantillaDetalleBusinessLogic.Update(obj);
                uow.SaveChanges();

                //Si hubo errores
                if (uow.Errors.Count > 0)
                {
                    M = string.Empty;
                    foreach (string cad in uow.Errors)
                    {
                        M += cad;
                    }
                    divMsgError.Style.Add("display", "block");
                    divMsgSuccess.Style.Add("display", "none");
                    lblMsgError.Text = M;
                    return;
                }
            }

            //Se tienen que almacenar los checks de cada una de las preguntas que se pudieran
            //haber marcado

            R = null;

            R = GuardarPlantillas(_CadValoresChecks.Value, uow, Utilerias.StrToInt(Session["IdUser"].ToString())); //Se guarda las respuestas que se hayan marcado en el grid SI, NO, NO APLICA

            //Si hubo errores
            if (R.Count > 1)
            {
                divMsgError.Style.Add("display", "block");
                divMsgSuccess.Style.Add("display", "none");
                lblMsgError.Text = R[1];

                return;
            }

            BindGrid(Utilerias.StrToInt(_IDPlantilla.Value)); //Se bindea nuevamente el grid de preguntas

            btnCancelar.Disabled              = true;
            btnBuscarArchivo.Enabled          = false;
            txtObservacionesPregunta.Disabled = true;

            divMsgError.Style.Add("display", "none");
            divMsgSuccess.Style.Add("display", "block");
            lblMsgSuccess.Text = R[0];
            divEvaluacion.Style.Add("display", "block");
            divDatos.Style.Add("display", "none");
            divCapturaPreguntas.Style.Add("display", "none");
        }
Beispiel #8
0
        /// <summary>
        /// Evento del grid al momento de llenarse, coloca las funciones de JAVASCRIPT sobre los radio buttons
        /// Ademas de marcar o desmarcar segun la RESPUESTA que traiga el objeto POAPLANTILLADETALLE
        /// Creado por Rigoberto TS
        /// 29/09/2014
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void grid_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            if (e.Row.RowType == DataControlRowType.Header)
            {
                //GridViewRow gvrow = new GridViewRow(0, 0, DataControlRowType.Header, DataControlRowState.Insert);
                //TableCell cell0 = new TableCell();
                //cell0.Text = string.Empty;
                //cell0.HorizontalAlign = HorizontalAlign.Center;
                //cell0.ColumnSpan = 2;

                //TableCell cell1 = new TableCell();
                //cell1.Text = "RESPUESTA";
                //cell1.ForeColor = System.Drawing.Color.Black;

                //cell1.HorizontalAlign = HorizontalAlign.Center;
                //cell1.ColumnSpan = 3;

                //gvrow.Cells.Add(cell0);
                //gvrow.Cells.Add(cell1);

                //grid.Controls[0].Controls.AddAt(0, gvrow);
            }

            if (e.Row.RowType == DataControlRowType.DataRow)
            {
                if (grid.DataKeys[e.Row.RowIndex].Values["Id"] != null)
                {
                    int id = Utilerias.StrToInt(grid.DataKeys[e.Row.RowIndex].Values["Id"].ToString());
                    POAPlantillaDetalle obj = uow.POAPlantillaDetalleBusinessLogic.GetByID(id);

                    //Se recuperan los controles de RADIOBUTTONS
                    HtmlInputRadioButton chkSI       = (HtmlInputRadioButton)e.Row.FindControl("chkSI");
                    HtmlInputRadioButton chkNO       = (HtmlInputRadioButton)e.Row.FindControl("chkNO");
                    HtmlInputRadioButton chkNOAplica = (HtmlInputRadioButton)e.Row.FindControl("chkNOAplica");
                    Label lblArchivo = (Label)e.Row.FindControl("lblArchivo");

                    //Se coloca la FUNCION de fnc_DesmarcarChecks en JAVASCRIPT
                    chkSI.Attributes["onchange"]       = "fnc_DesmarcarChecks(this," + e.Row.RowIndex + ",'" + grid.ID + "','" + chkNO.ID + "','" + chkNOAplica.ID + "')";
                    chkNO.Attributes["onchange"]       = "fnc_DesmarcarChecks(this," + e.Row.RowIndex + ",'" + grid.ID + "','" + chkSI.ID + "','" + chkNOAplica.ID + "')";
                    chkNOAplica.Attributes["onchange"] = "fnc_DesmarcarChecks(this," + e.Row.RowIndex + ",'" + grid.ID + "','" + chkSI.ID + "','" + chkNO.ID + "')";
                    e.Row.Cells[1].Attributes.Add("onclick", "fnc_ClickRow(" + e.Row.RowIndex + ")");
                    e.Row.Cells[0].Attributes.Add("onclick", "fnc_ClickRow(" + e.Row.RowIndex + ")");

                    if (obj.Respuesta != 0)
                    {
                        switch (obj.Respuesta) //Segun sea la respuesta que traiga el objeto, se marca el radiobutton correspondiente
                        {
                        case enumRespuesta.Si:
                            chkSI.Value   = "true";
                            chkSI.Checked = true;
                            break;

                        case enumRespuesta.No:
                            chkNO.Value   = "true";
                            chkNO.Checked = true;
                            break;

                        case enumRespuesta.NoAplica:
                            chkNOAplica.Value   = "true";
                            chkNOAplica.Checked = true;
                            break;
                        }
                    }

                    if (obj.NombreArchivo != null)
                    {
                        if (!obj.NombreArchivo.Equals(string.Empty))
                        {
                            lblArchivo.Text = obj.NombreArchivo;
                        }
                        else
                        {
                            lblArchivo.Text = "No existe archivo adjunto";
                        }
                    }
                    else
                    {
                        lblArchivo.Text = "No existe archivo adjunto";
                    }

                    //Se coloca la fucnion a corespondiente para visualizar el DOCUMENTO ADJUNTO A LA PREGUNTA
                    HtmlButton btnVer = (HtmlButton)e.Row.FindControl("btnVer");
                    string     ruta   = ResolveClientUrl("~/AbrirDocto.aspx");
                    btnVer.Attributes["onclick"] = "fnc_AbrirArchivo('" + ruta + "'," + id + ")";
                }
            }
        }