private void Respuestas_Grid_CellValueChanged(object sender, DataGridViewCellEventArgs e)
        {
            switch (Respuestas_Grid.Columns[e.ColumnIndex].Name)
            {
            case "Opcion_CBC":

                Respuesta_Alumno_Examen respuesta = (Respuesta_Alumno_Examen)Respuestas_Grid.Rows[e.RowIndex].DataBoundItem;
                if (respuesta != null)
                {
                    PreguntaExamenInfo pregunta = _preguntas.GetItem(respuesta.OidPreguntaExamen);
                    if (pregunta != null)
                    {
                        respuesta.Correcta = false;

                        foreach (RespuestaExamenInfo resp in pregunta.RespuestaExamenes)
                        {
                            if (resp.Opcion == respuesta.Opcion)
                            {
                                if (resp.Correcta)
                                {
                                    respuesta.Correcta = true;
                                }
                                break;
                            }
                        }
                    }
                }

                Datos_Respuestas.ResetBindings(false);

                break;
            }
        }
コード例 #2
0
        protected void SetUnlinkedGridValues(string gridName)
        {
            switch (gridName)
            {
            case "Respuestas_Grid":
                PreguntaExamenList preguntas = ExamenInfo.Get(_examen.OidExamen).PreguntaExamenes;
                foreach (DataGridViewRow row in Respuestas_Grid.Rows)
                {
                    if (row.IsNewRow)
                    {
                        continue;
                    }
                    Respuesta_Alumno_Examen info = (Respuesta_Alumno_Examen)row.DataBoundItem;
                    if (info != null)
                    {
                        PreguntaExamenInfo pregunta = preguntas.GetItem(info.OidPreguntaExamen);
                        if (pregunta != null)
                        {
                            row.Cells["Orden"].Value    = pregunta.Orden;
                            row.Cells["Pregunta"].Value = pregunta.Texto;
                            row.Cells["Correcta"].Value = false;

                            foreach (RespuestaExamenInfo resp in pregunta.RespuestaExamenes)
                            {
                                if (resp.Opcion == info.Opcion)
                                {
                                    if (resp.Correcta)
                                    {
                                        row.Cells["Correcta"].Value = true;
                                        info.Correcta = true;
                                    }
                                    else
                                    {
                                        info.Correcta = false;
                                    }
                                    break;
                                }
                            }
                        }
                    }
                }

                break;
            }
        }