Exemple #1
0
        public void SetSourceData(Examen item, ModuloInfo modulo, SubmoduloList submodulos,
                                  TemaList temas, PreguntaList preguntas, List <long> preguntas_mismo_dia, bool propuesto)
        {
            lista_preguntas = new List <long>();
            //_memo_preguntas = item.MemoPreguntas;
            _entity = item;
            //if (propuesto) _entity.MemoPreguntas = string.Empty;
            _modulo              = modulo;
            _preguntas           = preguntas;
            _submodulos          = submodulos;
            _temas               = temas;
            _preguntas_mismo_dia = preguntas_mismo_dia;
            this.Text            = Resources.Labels.SELECT_PREGUNTAS;

            foreach (Pregunta_Examen pregunta in _entity.Pregunta_Examens)
            {
                lista_preguntas.Add(pregunta.OidPregunta);
            }

            //while (_memo_preguntas != string.Empty)
            //{
            //    long pregunta;
            //    int index = _memo_preguntas.IndexOf(";");
            //    pregunta = Convert.ToInt64(_memo_preguntas.Substring(0, index));
            //    _memo_preguntas = _memo_preguntas.Substring(index + 1);
            //    Pregunta p = _preguntas.GetItem(pregunta);
            //    lista_preguntas.Add(pregunta);
            //}
            RefreshMainData();
            RefreshSecondaryData();
        }
Exemple #2
0
        public override void RefreshSecondaryData()
        {
            ModuloList modulos = ModuloList.GetList(false);

            Library.Instruction.HComboBoxSourceList _combo_modulos = new Library.Instruction.HComboBoxSourceList(modulos);
            Datos_Modulos.DataSource = _combo_modulos;
            PgMng.Grow(string.Empty, "_combo_modulos");

            InstructorList instructores = InstructorList.GetList(false);

            Library.Instruction.HComboBoxSourceList _combo_instructores = new Library.Instruction.HComboBoxSourceList(instructores);
            Datos_Instructores.DataSource = _combo_instructores;
            PgMng.Grow(string.Empty, "_combo_instructores");

            PromocionList promociones = PromocionList.GetList(false);

            Library.Instruction.HComboBoxSourceList _combo_promociones = new Library.Instruction.HComboBoxSourceList(promociones);
            ComboBoxSource combo = new ComboBoxSource(-1, "No especificado");

            _combo_promociones.Add(combo);
            Datos_Promociones.DataSource = _combo_promociones;
            PgMng.Grow(string.Empty, "_combo_promociones");

            _lista_preguntas = PreguntaList.GetPreguntasModulo(Entity.OidModulo);
            PgMng.Grow(string.Empty, "Preguntas del Módulo");
            //_submodulos = SubmoduloList.GetList(false);
            //_temas = TemaList.GetList(false);
        }
Exemple #3
0
        /// <summary>
        /// Asigna el objeto principal al origen de datos
        /// <returns>void</returns>
        /// </summary>
        protected override void RefreshMainData()
        {
            _preguntas_modulo = PreguntaList.GetPreguntasModulo(_modulo.Oid, _entity.MemoPreguntas);
            //_modulo.Preguntas = _preguntas_modulo;
            PgMng.Grow(string.Empty, "_preguntas");

            _respuestas_modulo = RespuestaList.GetModuloList(_modulo.Oid);
            PgMng.Grow(string.Empty, "_respuestas");

            RellenaPreguntas();

            promociones = PromocionList.GetList(false);
            foreach (PromocionInfo info in promociones)
            {
                _promociones_todas.Add(info.Numero + " - " + info.Nombre, info);
            }

            RellenaPromociones();
            PgMng.Grow(string.Empty, "RellenaPreguntas");

            Datos.DataSource  = _entity;
            Duracion_MTB.Text = _entity.Duracion.TimeOfDay.ToString();
            PgMng.FillUp(string.Empty, "RefreshMain de ExamenEditForm");
            //PgMng.ShowCronos();
        }
Exemple #4
0
        /// <summary>
        /// Cambia el nombre de las imágenes de las preguntas
        /// Sustitye el Oid viejo por el nuevo Oid formateado
        /// </summary>
        /// <param name="preguntas"></param>
        public static void RenombrarImagenesPreguntas(PreguntaList preguntas)
        {
            string root = Images.GetRootPath();

            foreach (PreguntaInfo item in preguntas)
            {
                string nombre = item.Oid.ToString("00000") + ".jpg";
                if (item.OidOld != 0 && !File.Exists(root + ".\\Recursos\\Fotos\\JPEG\\" + nombre))
                {
                    string ruta = ".\\Recursos\\Fotos\\JPEG\\" + item.OidOld.ToString() + ".jpg";
                    if (File.Exists(root + ruta))
                    {
                        Bitmap imagen = new Bitmap(root + ruta);
                        Images.Save(root + ruta, AppController.FOTOS_PREGUNTAS_PATH, nombre, imagen.Width, imagen.Height);
                        //Images.DeleteImage(root + ruta);
                        //if (imagen.RawFormat.Guid.Equals(System.Drawing.Imaging.ImageFormat.Jpeg.Guid))
                        //    nombre += ".jpg";
                        //if (imagen.RawFormat.Guid.Equals(System.Drawing.Imaging.ImageFormat.Bmp.Guid))
                        //    nombre += ".bmp";
                        imagen.Dispose();
                        if (item.Imagen != nombre)
                        {
                            item.FormatImagen(nombre);
                        }
                    }
                    //else
                    //    item.FormatImagen(string.Empty);
                }
            }
        }
        public override void RefreshSecondaryData()
        {
            PgMng.Grow();

            Preguntas_TB.Text = _entity.PreguntaExamenes.Count.ToString();
            PgMng.Grow();

            Desarrollo_CB.Checked = _entity.Desarrollo;
            PgMng.Grow();

            if (EntityInfo != null && EntityInfo.OidModulo != 0)
            {
                _modulo = ModuloInfo.Get(EntityInfo.OidModulo, false);
                PgMng.Grow(string.Empty, "_modulo");

                _preguntas_modulo = PreguntaList.GetPreguntasModulo(_modulo.Oid);
                PgMng.Grow(string.Empty, "_preguntas");

                _temas = TemaList.GetModuloList(_modulo.Oid, false);
                PgMng.Grow(string.Empty, "_temas");

                _submodulos = SubmoduloList.GetModuloList(_modulo.Oid, false);
                PgMng.Grow(string.Empty, "_submodulos");

                RellenaPreguntas();
            }
            PgMng.Grow();

            base.RefreshSecondaryData();
            PgMng.Grow();
        }
        protected override void ResumenPreguntasAction()
        {
            if (_entity.MemoPreguntas == string.Empty)
            {
                return;
            }

            ExamenReportMng reportMng = new ExamenReportMng(AppContext.ActiveSchema);

            string lista = _entity.MemoPreguntas.Replace(';', ',');

            lista = lista.Substring(0, lista.Length - 1);
            bool        defecto = moleQule.Library.Instruction.ModulePrincipal.GetImpresionEmpresaDefaultBoolSetting();
            CompanyInfo empresa = null;

            if (defecto)
            {
                empresa = CompanyInfo.Get(moleQule.Library.Instruction.ModulePrincipal.GetImpresionEmpresaDefaultOidSetting(), false);
            }
            while (empresa == null)
            {
                moleQule.Face.Common.CompanySelectForm form = new Common.CompanySelectForm(this);
                DialogResult result = form.ShowDialog();

                try
                {
                    if (result == DialogResult.OK)
                    {
                        empresa = form.Selected as CompanyInfo;
                    }
                }
                catch
                { empresa = null; }
            }

            ISchemaInfo schema = AppContext.ActiveSchema;

            try
            {
                schema = empresa as ISchemaInfo;
                if (schema == null)
                {
                    schema = AppContext.ActiveSchema;
                }
            }
            catch
            {
            }

            ReportViewer.SetReport(reportMng.GetDetailResumenExamenReport(EntityInfo,
                                                                          PreguntaList.GetListaExamen(lista),
                                                                          null,
                                                                          empresa));
            ReportViewer.ShowDialog();
        }
Exemple #7
0
        public void SetSourceData(Examen item, ModuloInfo modulo, PreguntaList preguntas)
        {
            _entity = item;

            _modulo = modulo;

            _preguntas = preguntas;

            RefreshMainData();
            RefreshSecondaryData();
        }
 public ExamenDesarrolloReportForm(bool IsModal, ExamenInfo item,
                                   PreguntaList preguntas, Pregunta_Examens preguntas_examen)
     : base(IsModal)
 {
     InitializeComponent();
     _entity           = item;
     _preguntas        = preguntas;
     _preguntas_examen = preguntas_examen;
     SetFormData();
     this.Text = Resources.Labels.PRINT_TITLE;
 }
 public PreguntasViewForm(long oid, PreguntaList preguntas, bool ismodal)
     : base(ismodal)
 {
     InitializeComponent();
     ListaInfo      = preguntas;
     _pregunta_info = PreguntaInfo.Get(oid, true);
     if (ListaInfo != null)
     {
         SetFormData();
         this.Text = Resources.Labels.PREGUNTA_EDIT_TITLE;
     }
     _mf_type = ManagerFormType.MFView;
 }
        protected override void ResumenAction()
        {
            ResumenActionForm form = new ResumenActionForm();
            string            memo = string.Empty;

            if (_entity.MemoPreguntas != string.Empty)
            {
                memo = _entity.MemoPreguntas.Substring(0, _entity.MemoPreguntas.Length - 1);
            }
            PreguntaList preguntas = PreguntaList.GetPreguntasByList(memo);

            form.SetSourceData(EntityInfo, _modulo, preguntas);
            form.ShowDialog();
        }
Exemple #11
0
 public PreguntasEmitidasViewForm(long oid, PreguntaExamens preguntas, PreguntaList lista, bool ismodal)
     : base(ismodal)
 {
     InitializeComponent();
     Lista            = preguntas;
     _lista_preguntas = lista;
     _pregunta        = Lista.GetItem(oid);
     if (Lista != null)
     {
         SetFormData();
         this.Text = Resources.Labels.PREGUNTA_EDIT_TITLE;
     }
     _mf_type = ManagerFormType.MFView;
 }
Exemple #12
0
        private void Temas_Grid_UserDeletingRow(object sender, DataGridViewRowCancelEventArgs e)
        {
            Tema current = ((Tema)e.Row.DataBoundItem);

            if (current != null)
            {
                PreguntaList preguntas = PreguntaList.GetPreguntasTema(current.OidModulo, current.Oid);

                if (preguntas.Count > 0)
                {
                    PgMng.ShowErrorException(Resources.Messages.TEMA_CON_PREGUNTAS);
                    e.Cancel = true;
                }
            }
        }
        public PreguntaMngForm(bool isModal, Form parent, PreguntaList list)
            : base(isModal, parent, list)
        {
            InitializeComponent();
            SetView(molView.Normal);

            // Parche para poder abrir el formulario en modo diseño y no perder la configuracion de columnas
            DatosLocal_BS    = Datos;
            Tabla.DataSource = DatosLocal_BS;
            Datos.DataSource = PreguntaList.NewList().GetSortedList();

            TablaBase = Tabla;

            base.SortProperty = Codigo.DataPropertyName;
        }
        protected override void RellenaPreguntas()
        {
            PreguntaList _preguntas_examen = null;

            string memo = string.Empty;

            foreach (Pregunta_ExamenInfo item in _entity.Preguntas)
            {
                if (memo != string.Empty)
                {
                    memo += ",";
                }
                memo += item.OidPregunta.ToString();
            }

            if (memo != string.Empty)
            {
                _preguntas_examen = PreguntaList.GetPreguntasByList(memo);

                string inactivas = string.Empty;

                foreach (PreguntaInfo item in _preguntas_examen)
                {
                    if (!item.Activa)
                    {
                        inactivas += item.Serial.ToString() + ", ";
                    }
                }

                if (inactivas != string.Empty)
                {
                    inactivas = inactivas.Substring(0, inactivas.Length - 2);
                    MessageBox.Show(string.Format(Resources.Messages.PREGUNTAS_INACTIVAS, inactivas),
                                    moleQule.Library.Application.AppController.APP_TITLE,
                                    MessageBoxButtons.OK,
                                    MessageBoxIcon.Exclamation);
                }
            }

            Datos_Preguntas.DataSource = _preguntas_examen;

            Preguntas_TB.Text = Datos_Preguntas.Count.ToString();
        }
 public override void OpenViewForm()
 {
     try
     {
         PreguntaList plist = PreguntaList.GetList(ActiveList);
         AddForm(new PreguntasViewForm(ActiveOID, plist, true));
     }
     catch (Csla.DataPortalException ex)
     {
         MessageBox.Show(ex.BusinessException.ToString(),
                         moleQule.Face.Resources.Labels.ERROR_TITLE,
                         MessageBoxButtons.OK,
                         MessageBoxIcon.Exclamation);
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.ToString(),
                         moleQule.Face.Resources.Labels.ERROR_TITLE,
                         MessageBoxButtons.OK,
                         MessageBoxIcon.Exclamation);
     }
 }
Exemple #16
0
        public static void FormatFechaDisponibilidad()
        {
            PreguntaExamenList preguntasexamen = PreguntaExamenList.GetList(false);
            PreguntaList       preguntas       = PreguntaList.GetList(false);
            ExamenList         examenes        = ExamenList.GetList(false);

            foreach (PreguntaInfo item in preguntas)
            {
                DateTime fecha_disponibilidad = DateTime.MaxValue;

                foreach (PreguntaExamenInfo pexamen in preguntasexamen)
                {
                    //la pregunta se encuentra en un examen emitido
                    if (item.Oid == pexamen.OidPregunta)
                    {
                        ExamenInfo examen = examenes.GetItem(pexamen.OidExamen);

                        DateTime fecha = examen.FechaExamen.AddMonths(6);

                        if (fecha_disponibilidad.Equals(DateTime.MaxValue) ||
                            (!fecha_disponibilidad.Equals(DateTime.MaxValue) &&
                             fecha.Date > fecha_disponibilidad.Date))
                        {
                            fecha_disponibilidad = fecha;
                        }
                    }
                }

                if (fecha_disponibilidad.Date.Equals(DateTime.MaxValue.Date))
                {
                    fecha_disponibilidad = item.FechaAlta;
                }

                if (!item.FechaDisponibilidad.Date.Equals(fecha_disponibilidad.Date))
                {
                    Pregunta.FormatDisponibilidad(item.Oid, fecha_disponibilidad);
                }
            }
        }
        protected override void CellContentClick(int column, int row)
        {
            switch (Preguntas_Grid.Columns[column].Name)
            {
            case "Ver_BT":
            {
                string memo = _entity.MemoPreguntas;

                if (memo != string.Empty)
                {
                    memo = memo.Substring(0, memo.Length - 1);
                }
                memo = memo.Replace(';', ',');

                PreguntaList preguntas = PreguntaList.GetPreguntasByList(memo);

                PreguntaInfo      info = (PreguntaInfo)Preguntas_Grid.Rows[row].DataBoundItem;
                PreguntasViewForm form = new PreguntasViewForm(info.Oid, preguntas, true);
                form.ShowDialog();
            }
            break;
            }
        }
        public void SetSourceData(ExamenInfo item, ModuloInfo modulo, PreguntaList preguntas)
        {
            _modulo               = modulo;
            _submodulos           = SubmoduloList.GetModuloList(_modulo.Oid, false);
            _temas                = TemaList.GetModuloList(_modulo.Oid, false);
            _preguntas_modulo     = preguntas;
            _preguntas_exameninfo = item.Preguntas;
            _examen               = item;

            this.Text = Resources.Labels.RESUMEN_EXAMEN_TITLE;
            lista     = new List <RegistroResumen>();
            //string memo_preguntas = ";" + item;
            long contador = 0;

            foreach (SubmoduloInfo obj in _submodulos)
            {
                foreach (TemaInfo tema in _temas)
                {
                    if (tema.OidSubmodulo == obj.Oid)
                    {
                        foreach (Pregunta_ExamenInfo p in _preguntas_exameninfo)
                        {
                            PreguntaInfo info = _preguntas_modulo.GetItem(p.OidPregunta);
                            if (info.OidTema == tema.Oid)
                            {
                                lista = RegistroResumen.ContabilizaPregunta(lista, obj.Oid, obj.Codigo + " " + obj.Texto, tema.Codigo);
                                contador++;
                            }
                        }
                    }
                }
            }
            lista.Add(new RegistroResumen("TODOS", "TODOS", contador));

            RefreshMainData();
        }
Exemple #19
0
        protected override void RellenaPreguntas()
        {
            //Preguntas lista_aux = Preguntas.NewList();
            PreguntaList _preguntas_examen = null;

            //if (EntityInfo.MemoPreguntas.Length > 0)
            //{
            //    string lista = EntityInfo.MemoPreguntas.Replace(';', ',').Substring(0, EntityInfo.MemoPreguntas.Length - 1);
            //    lista_aux = Preguntas.GetPreguntasByList(lista);
            //}

            //string[] oid_preguntas = EntityInfo.MemoPreguntas.Split(';');

            //foreach (string item in oid_preguntas)
            //{
            //    try
            //    {
            //        long oid = Convert.ToInt32(item);
            //        //en _preguntas_examen se guardan las preguntas ordenadas según el campo MemoPreguntas
            //        _preguntas_examen.AddItem(lista_aux.GetItem(oid));
            //    }
            //    catch
            //    {
            //        continue;
            //    }
            //}

            string memo = string.Empty;

            foreach (Pregunta_Examen item in _entity.Pregunta_Examens)
            {
                if (memo != string.Empty)
                {
                    memo += ",";
                }
                memo += item.OidPregunta.ToString();
            }

            if (memo != string.Empty)
            {
                _preguntas_examen = PreguntaList.GetPreguntasByList(memo);

                string inactivas = string.Empty;

                foreach (PreguntaInfo item in _preguntas_examen)
                {
                    if (!item.Activa)
                    {
                        inactivas += item.Serial.ToString() + ", ";
                    }
                }

                if (inactivas != string.Empty)
                {
                    inactivas = inactivas.Substring(0, inactivas.Length - 2);
                    MessageBox.Show(string.Format(Resources.Messages.PREGUNTAS_INACTIVAS, inactivas),
                                    moleQule.Library.Application.AppController.APP_TITLE,
                                    MessageBoxButtons.OK,
                                    MessageBoxIcon.Exclamation);
                }
            }

            Datos_Preguntas.DataSource = _preguntas_examen;

            Preguntas_TB.Text = Datos_Preguntas.Count.ToString();

            TimeSpan duracion = TimeSpan.Zero;
            TimeSpan tiempo_pregunta;

            if (_entity.Desarrollo)
            {
                tiempo_pregunta = moleQule.Library.Instruction.ModulePrincipal.GetTiempoPreguntasTipoDesarrolloSetting().TimeOfDay;
            }
            else
            {
                tiempo_pregunta = moleQule.Library.Instruction.ModulePrincipal.GetTiempoPreguntasTipoTestSetting().TimeOfDay;
            }

            duracion          = TimeSpan.FromSeconds(tiempo_pregunta.TotalSeconds * Datos_Preguntas.Count);
            _entity.Duracion  = Convert.ToDateTime(duracion.ToString());
            Duracion_MTB.Text = _entity.Duracion.Hour.ToString("00") + ":" + _entity.Duracion.Minute.ToString("00");
        }
        private void ExportaDOC(CompanyInfo empresa)
        {
            object      oMissing  = System.Reflection.Missing.Value;
            object      oEndOfDoc = "\\endofdoc"; /* \endofdoc is a predefined bookmark */
            ExamenPrint examen    = null;

            try
            {
                WordExporter.InitWordExporter();

                examen = Entity.GetPrintObject(empresa, string.Empty);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message,
                                moleQule.Face.Resources.Labels.ERROR_TITLE,
                                MessageBoxButtons.OK,
                                MessageBoxIcon.Error);
                return;
            }

            PgMng.Reset(_entity.PreguntaExamenes.Count + 7, 1, Resources.Messages.LOADING_DATA, this);

            try
            {
                Word.Document oDoc = WordExporter.NewDocument();
                PgMng.Grow();

                foreach (Word.Section wordSection in oDoc.Sections)
                {
                    wordSection.Footers[Word.WdHeaderFooterIndex.wdHeaderFooterPrimary]
                    .Range.Text = empresa.Name;
                    wordSection.Footers[Word.WdHeaderFooterIndex.wdHeaderFooterPrimary]
                    .Range.Borders.DistanceFromTop = 10;
                    wordSection.Footers[
                        Word.WdHeaderFooterIndex.wdHeaderFooterPrimary].PageNumbers.ShowFirstPageNumber = true;
                    wordSection.Range.ParagraphFormat.SpaceAfter  = 0;
                    wordSection.Range.ParagraphFormat.SpaceBefore = 0;
                }
                PgMng.Grow();

                //Márgenes (1cm aprox.)
                oDoc.PageSetup.TopMargin    = 15;
                oDoc.PageSetup.BottomMargin = 0;
                oDoc.PageSetup.LeftMargin   = 30;
                oDoc.PageSetup.RightMargin  = 30;

                //Tabla de encabezado
                Word.Table oTable;
                Word.Range wrdRng = oDoc.Bookmarks.get_Item(ref oEndOfDoc).Range;
                oTable = oDoc.Tables.Add(wrdRng, 5, 4, ref oMissing, ref oMissing);

                oTable.Range.ParagraphFormat.SpaceAfter  = 6;
                oTable.Range.ParagraphFormat.SpaceBefore = 6;

                oTable.Columns[1].Cells.Merge();
                oTable.Borders.Enable           = 1;
                oTable.Borders.InsideLineWidth  = Word.WdLineWidth.wdLineWidth150pt;
                oTable.Borders.OutsideLineWidth = Word.WdLineWidth.wdLineWidth150pt;

                oTable.Columns[2].Cells[1].Merge(oTable.Columns[2].Cells[2]);

                oTable.Columns[1].Width = 108.44F;
                oTable.Columns[3].Width = 81.33F;
                oTable.Columns[4].Width = 81.33F;
                oTable.Columns[2].Width = 271.1F;

                oTable.Rows.Alignment = Word.WdRowAlignment.wdAlignRowCenter;
                PgMng.Grow();

                string logo = CompanyInfo.GetLogoPath(empresa.Oid);
                if (!File.Exists(logo))
                {
                    MessageBox.Show("No se ha encontrado la imagen: " + logo);
                }
                else
                {
                    oTable.Cell(1, 1).Range.InlineShapes.AddPicture(logo, ref oMissing, ref oMissing, ref oMissing);
                }
                oTable.Cell(1, 1).VerticalAlignment = Word.WdCellVerticalAlignment.wdCellAlignVerticalCenter;
                PgMng.Grow();

                oTable.Cell(1, 2).Range.Text                 = "HOJA DE PREGUNTAS";
                oTable.Cell(1, 2).Range.Font.Bold            = 1;
                oTable.Cell(1, 2).Range.Font.Size            = 16;
                oTable.Cell(1, 2).VerticalAlignment          = Word.WdCellVerticalAlignment.wdCellAlignVerticalCenter;
                oTable.Cell(1, 2).Range.Paragraphs.Alignment = Word.WdParagraphAlignment.wdAlignParagraphCenter;
                oTable.Columns[2].Cells[1].Range.Font.Name   = "Arial";

                oTable.Columns[2].Cells[2].Range.Text                 = examen.Modulo;
                oTable.Columns[2].Cells[2].Range.Font.Bold            = 1;
                oTable.Columns[2].Cells[2].Range.Font.Size            = 11;
                oTable.Columns[2].Cells[2].VerticalAlignment          = Word.WdCellVerticalAlignment.wdCellAlignVerticalCenter;
                oTable.Columns[2].Cells[2].Range.Paragraphs.Alignment = Word.WdParagraphAlignment.wdAlignParagraphCenter;
                oTable.Columns[2].Cells[2].Range.Font.Name            = "Arial";

                oTable.Columns[2].Cells[3].Range.Text                 = "CURSO : " + examen.Promocion;
                oTable.Columns[2].Cells[3].Range.Font.Bold            = 1;
                oTable.Columns[2].Cells[3].Range.Font.Size            = 11;
                oTable.Columns[2].Cells[3].VerticalAlignment          = Word.WdCellVerticalAlignment.wdCellAlignVerticalCenter;
                oTable.Columns[2].Cells[3].Range.Paragraphs.Alignment = Word.WdParagraphAlignment.wdAlignParagraphCenter;
                oTable.Columns[2].Cells[3].Range.Font.Name            = "Arial";

                oTable.Columns[2].Cells[4].Range.Text =
                    "Deberá utilizar la plantilla que se le entregará para responder a las preguntas del examen.";
                oTable.Columns[2].Cells[4].Range.Font.Size            = 11;
                oTable.Columns[2].Cells[4].VerticalAlignment          = Word.WdCellVerticalAlignment.wdCellAlignVerticalCenter;
                oTable.Columns[2].Cells[4].Range.Paragraphs.Alignment = Word.WdParagraphAlignment.wdAlignParagraphCenter;
                oTable.Columns[2].Cells[4].Range.Font.Name            = "Arial";

                oTable.Columns[3].Cells[1].Range.Text                 = "Nº EXAMEN";
                oTable.Columns[3].Cells[1].Range.Font.Bold            = 1;
                oTable.Columns[3].Cells[1].Range.Font.Size            = 11;
                oTable.Columns[3].Cells[1].VerticalAlignment          = Word.WdCellVerticalAlignment.wdCellAlignVerticalCenter;
                oTable.Columns[3].Cells[1].Range.Paragraphs.Alignment = Word.WdParagraphAlignment.wdAlignParagraphCenter;
                oTable.Columns[3].Cells[1].Range.Font.Name            = "Arial";

                oTable.Columns[3].Cells[2].Range.Text                 = "FECHA";
                oTable.Columns[3].Cells[2].Range.Font.Bold            = 1;
                oTable.Columns[3].Cells[2].Range.Font.Size            = 11;
                oTable.Columns[3].Cells[2].VerticalAlignment          = Word.WdCellVerticalAlignment.wdCellAlignVerticalCenter;
                oTable.Columns[3].Cells[2].Range.Paragraphs.Alignment = Word.WdParagraphAlignment.wdAlignParagraphCenter;
                oTable.Columns[3].Cells[2].Range.Font.Name            = "Arial";

                oTable.Columns[3].Cells[3].Range.Text                 = "TIPO EXAMEN";
                oTable.Columns[3].Cells[3].Range.Font.Bold            = 1;
                oTable.Columns[3].Cells[3].Range.Font.Size            = 11;
                oTable.Columns[3].Cells[3].VerticalAlignment          = Word.WdCellVerticalAlignment.wdCellAlignVerticalCenter;
                oTable.Columns[3].Cells[3].Range.Paragraphs.Alignment = Word.WdParagraphAlignment.wdAlignParagraphCenter;
                oTable.Columns[3].Cells[3].Range.Font.Name            = "Arial";

                oTable.Columns[3].Cells[4].Range.Text                 = "Nº PREGUNTAS";
                oTable.Columns[3].Cells[4].Range.Font.Bold            = 1;
                oTable.Columns[3].Cells[4].Range.Font.Size            = 11;
                oTable.Columns[3].Cells[4].VerticalAlignment          = Word.WdCellVerticalAlignment.wdCellAlignVerticalCenter;
                oTable.Columns[3].Cells[4].Range.Paragraphs.Alignment = Word.WdParagraphAlignment.wdAlignParagraphCenter;
                oTable.Columns[3].Cells[4].Range.Font.Name            = "Arial";

                oTable.Columns[3].Cells[5].Range.Text                 = "TIEMPO";
                oTable.Columns[3].Cells[5].Range.Font.Bold            = 1;
                oTable.Columns[3].Cells[5].Range.Font.Size            = 11;
                oTable.Columns[3].Cells[5].VerticalAlignment          = Word.WdCellVerticalAlignment.wdCellAlignVerticalCenter;
                oTable.Columns[3].Cells[5].Range.Paragraphs.Alignment = Word.WdParagraphAlignment.wdAlignParagraphCenter;
                oTable.Columns[3].Cells[5].Range.Font.Name            = "Arial";

                oTable.Columns[4].Cells[1].Range.Text                 = examen.Numero.ToString().Trim();
                oTable.Columns[4].Cells[1].Range.Font.Size            = 11;
                oTable.Columns[4].Cells[1].VerticalAlignment          = Word.WdCellVerticalAlignment.wdCellAlignVerticalCenter;
                oTable.Columns[4].Cells[1].Range.Paragraphs.Alignment = Word.WdParagraphAlignment.wdAlignParagraphCenter;
                oTable.Columns[4].Cells[1].Range.Font.Name            = "Arial";

                oTable.Columns[4].Cells[2].Range.Text                 = examen.FechaExamen.ToShortDateString().Trim();
                oTable.Columns[4].Cells[2].Range.Font.Size            = 11;
                oTable.Columns[4].Cells[2].VerticalAlignment          = Word.WdCellVerticalAlignment.wdCellAlignVerticalCenter;
                oTable.Columns[4].Cells[2].Range.Paragraphs.Alignment = Word.WdParagraphAlignment.wdAlignParagraphCenter;
                oTable.Columns[4].Cells[2].Range.Font.Name            = "Arial";

                oTable.Columns[4].Cells[3].Range.Text                 = examen.Tipo.Trim();
                oTable.Columns[4].Cells[3].Range.Font.Size            = 11;
                oTable.Columns[4].Cells[3].VerticalAlignment          = Word.WdCellVerticalAlignment.wdCellAlignVerticalCenter;
                oTable.Columns[4].Cells[3].Range.Paragraphs.Alignment = Word.WdParagraphAlignment.wdAlignParagraphCenter;
                oTable.Columns[4].Cells[3].Range.Font.Name            = "Arial";

                oTable.Columns[4].Cells[4].Range.Text                 = examen.NPreguntas.ToString().Trim();
                oTable.Columns[4].Cells[4].Range.Font.Size            = 11;
                oTable.Columns[4].Cells[4].VerticalAlignment          = Word.WdCellVerticalAlignment.wdCellAlignVerticalCenter;
                oTable.Columns[4].Cells[4].Range.Paragraphs.Alignment = Word.WdParagraphAlignment.wdAlignParagraphCenter;
                oTable.Columns[4].Cells[4].Range.Font.Name            = "Arial";

                oTable.Columns[4].Cells[5].Range.Font.Name            = "Arial";
                oTable.Columns[4].Cells[5].Range.Font.Size            = 11;
                oTable.Columns[4].Cells[5].VerticalAlignment          = Word.WdCellVerticalAlignment.wdCellAlignVerticalCenter;
                oTable.Columns[4].Cells[5].Range.Paragraphs.Alignment = Word.WdParagraphAlignment.wdAlignParagraphCenter;
                oTable.Columns[4].Cells[5].Range.Text = examen.Duracion.ToShortTimeString().Trim();
                PgMng.Grow();

                ////Add some text after the table.
                Word.Paragraph oParaAux;
                object         oRng = oDoc.Bookmarks.get_Item(ref oEndOfDoc).Range;
                oParaAux            = oDoc.Content.Paragraphs.Add(ref oRng);
                oParaAux.Range.Text = string.Empty;
                oParaAux.Range.InsertParagraph();

                //Nombre y apellidos
                Word.Paragraph oPara1;
                oPara1                 = oDoc.Content.Paragraphs.Add(ref oMissing);
                oPara1.Range.Text      = "NOMBRE Y APELLIDOS:";
                oPara1.Range.Font.Size = 12;
                oPara1.Range.Font.Name = "Arial";
                oPara1.Range.InsertParagraphAfter();
                oPara1.Range.InsertParagraphBefore();

                //DNI/NIE, FIRMA
                Word.Paragraph oPara2;
                oPara2                 = oDoc.Content.Paragraphs.Add(ref oMissing);
                oPara2.Range.Text      = "DNI/NIE:                                                           FIRMA:";
                oPara2.Range.Font.Size = 12;
                oPara2.Range.Font.Name = "Arial";
                oPara2.Range.InsertParagraphAfter();
                oPara2.Range.InsertParagraphBefore();
                PgMng.Grow();

                PreguntaList lista_preguntas = null;

                //Origen de las preguntas en función de si el examen está emitido o no
                if (_entity.Emitido)
                {
                    lista_preguntas = PreguntaList.GetList(_entity.PreguntaExamenes);
                }
                else
                {
                    lista_preguntas = _preguntas;
                }

                if (lista_preguntas != null)
                {
                    int          i = 1;
                    PreguntaInfo item;

                    foreach (PreguntaExamenInfo pex in _entity.PreguntaExamenes)
                    {
                        item = lista_preguntas.GetItem(pex.OidPregunta);

                        //Para cada pregunta se inserta una tabla
                        wrdRng = oDoc.Bookmarks.get_Item(ref oEndOfDoc).Range;
                        Word.Range newRng        = oDoc.Bookmarks.get_Item(ref oEndOfDoc).Range;
                        int        paginas_antes = (int)(oTable.Range.get_Information(
                                                             Word.WdInformation.wdNumberOfPagesInDocument));
                        oTable = oDoc.Tables.Add(wrdRng, 5, 3, ref oMissing, ref oMissing);

                        oTable.Rows.HeightRule = Word.WdRowHeightRule.wdRowHeightAuto;

                        oTable.Columns[1].Width                      = 30;
                        oTable.Cell(1, 1).Range.Text                 = i.ToString();
                        oTable.Cell(1, 1).Range.Font.Size            = 10;
                        oTable.Cell(1, 1).Range.Paragraphs.Alignment = Word.WdParagraphAlignment.wdAlignParagraphCenter;
                        oTable.Cell(1, 1).Range.Font.Bold            = 1;
                        oTable.Cell(1, 1).Range.Font.Name            = "Arial";

                        oTable.Cell(1, 2).Merge(oTable.Columns[3].Cells[1]);
                        oTable.Cell(1, 2).BottomPadding              = 8;
                        oTable.Cell(1, 2).Width                      = 510;
                        oTable.Cell(1, 2).Range.Text                 = item.Texto;
                        oTable.Cell(1, 2).Range.Font.Size            = 10;
                        oTable.Cell(1, 2).Range.Paragraphs.Alignment = Word.WdParagraphAlignment.wdAlignParagraphJustify;
                        oTable.Cell(1, 2).Range.Font.Bold            = 1;
                        oTable.Cell(1, 2).Range.Font.Name            = "Arial";

                        oTable.Cell(2, 2).Merge(oTable.Cell(2, 3));
                        oTable.Cell(2, 1).Merge(oTable.Cell(2, 2));
                        oTable.Cell(2, 1).Width = 540;

                        oTable.Cell(3, 2).Width                      = 20;
                        oTable.Cell(3, 2).Range.Text                 = "A";
                        oTable.Cell(3, 2).Range.Font.Size            = 10;
                        oTable.Cell(3, 2).Range.Paragraphs.Alignment =
                            Word.WdParagraphAlignment.wdAlignParagraphCenter;
                        oTable.Cell(3, 2).Range.Font.Name = "Arial";

                        oTable.Cell(4, 2).Width                      = 20;
                        oTable.Cell(4, 2).Range.Text                 = "B";
                        oTable.Cell(4, 2).Range.Font.Size            = 10;
                        oTable.Cell(4, 2).Range.Paragraphs.Alignment =
                            Word.WdParagraphAlignment.wdAlignParagraphCenter;
                        oTable.Cell(4, 2).Range.Font.Name = "Arial";

                        oTable.Cell(5, 2).Width                      = 20;
                        oTable.Cell(5, 2).Range.Text                 = "C";
                        oTable.Cell(5, 2).Range.Font.Size            = 10;
                        oTable.Cell(5, 2).Range.Paragraphs.Alignment =
                            Word.WdParagraphAlignment.wdAlignParagraphCenter;
                        oTable.Cell(5, 2).Range.Font.Name = "Arial";

                        foreach (RespuestaInfo obj in item.Respuestas)
                        {
                            switch (obj.Opcion)
                            {
                            case "A":
                            {
                                oTable.Cell(3, 3).Width                      = 490;
                                oTable.Cell(3, 3).Range.Text                 = obj.Texto;
                                oTable.Cell(3, 3).Range.Font.Size            = 10;
                                oTable.Cell(3, 3).Range.Paragraphs.Alignment =
                                    Word.WdParagraphAlignment.wdAlignParagraphJustify;
                                oTable.Cell(3, 3).Range.Font.Name = "Arial";
                                break;
                            }

                            case "B":
                            {
                                oTable.Cell(4, 3).Width                      = 490;
                                oTable.Cell(4, 3).Range.Text                 = obj.Texto;
                                oTable.Cell(4, 3).Range.Font.Size            = 10;
                                oTable.Cell(4, 3).Range.Paragraphs.Alignment =
                                    Word.WdParagraphAlignment.wdAlignParagraphJustify;
                                oTable.Cell(4, 3).Range.Font.Name = "Arial";
                                break;
                            }

                            case "C":
                            {
                                oTable.Cell(5, 3).Width                      = 490;
                                oTable.Cell(5, 3).Range.Text                 = obj.Texto;
                                oTable.Cell(5, 3).Range.Font.Size            = 10;
                                oTable.Cell(5, 3).Range.Paragraphs.Alignment =
                                    Word.WdParagraphAlignment.wdAlignParagraphJustify;
                                oTable.Cell(5, 3).Range.Font.Name = "Arial";
                                break;
                            }
                            }
                        }

                        if (item.Imagen != string.Empty)
                        {
                            string path = _entity.Emitido ?
                                          Library.Application.AppController.FOTOS_PREGUNTAS_EXAMEN_PATH + _entity.Oid.ToString("00000") + "\\" + item.Imagen :
                                          item.ImagenWithPath;

                            if (File.Exists(path))
                            {
                                oTable.Cell(2, 1).Range.InlineShapes.AddPictureBullet(path, ref oMissing);
                                oTable.Cell(2, 1).VerticalAlignment =
                                    Word.WdCellVerticalAlignment.wdCellAlignVerticalCenter;
                                oTable.Cell(2, 1).Range.Paragraphs.Alignment =
                                    Word.WdParagraphAlignment.wdAlignParagraphCenter;
                            }
                            else
                            {
                                MessageBox.Show("No se ha encontrado la imagen: " + path);
                                oTable.Rows[2].Delete();
                            }
                        }
                        else
                        {
                            oTable.Rows[2].Delete();
                        }

                        ////Add some text after the table.
                        oRng                = oDoc.Bookmarks.get_Item(ref oEndOfDoc).Range;
                        oParaAux            = oDoc.Content.Paragraphs.Add(ref oRng);
                        oParaAux.Range.Text = string.Empty;
                        oParaAux.Range.InsertParagraph();

                        int paginas_despues = (int)(oParaAux.Range.get_Information(
                                                        Word.WdInformation.wdNumberOfPagesInDocument));
                        if (paginas_antes < paginas_despues)
                        {
                            newRng.InsertBreak(ref oMissing);
                        }

                        i++;
                    }
                    PgMng.Grow();
                    oDoc.Close(Microsoft.Office.Interop.Word.WdSaveOptions.wdPromptToSaveChanges,
                               Microsoft.Office.Interop.Word.WdOriginalFormat.wdPromptUser,
                               true);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message,
                                moleQule.Face.Resources.Labels.ERROR_TITLE,
                                MessageBoxButtons.OK,
                                MessageBoxIcon.Error);
                return;
            }
            finally
            {
                WordExporter.Close();
                PgMng.FillUp();
            }
        }
        public override void PrintList()
        {
            //Separamos las preguntas tipo test de las de desarrollo
            //PreguntaList _all = null;
            SelectPreguntasReportForm select_report = new SelectPreguntasReportForm();

            DialogResult select_result = select_report.ShowDialog();

            if (select_result == DialogResult.OK)
            {
                if (select_report.Source == PrintSource.All)
                {
                    PreguntaList List = PreguntaList.GetList(Datos.List as IList <Pregunta>);
                    //_all = List;

                    //PreguntaList test = PreguntaList.SeparaPreguntasTest(_all);
                    //PreguntaList desarrollo = PreguntaList.SeparaPreguntasDesarrollo(_all);

                    //PreguntaExamens p_test = PreguntaExamens.NewChildList();
                    //PreguntaExamens p_desarrollo = PreguntaExamens.NewChildList();

                    //Preguntas preguntas = Preguntas.NewChildList();

                    //long orden = 1;

                    bool        defecto = moleQule.Library.Instruction.ModulePrincipal.GetImpresionEmpresaDefaultBoolSetting();
                    CompanyInfo empresa = null;

                    if (defecto)
                    {
                        empresa = CompanyInfo.Get(moleQule.Library.Instruction.ModulePrincipal.GetImpresionEmpresaDefaultOidSetting(), false);
                    }
                    while (empresa == null)
                    {
                        moleQule.Face.Common.CompanySelectForm form = new Common.CompanySelectForm(this);
                        DialogResult result = form.ShowDialog();

                        try
                        {
                            if (result == DialogResult.OK)
                            {
                                empresa = form.Selected as CompanyInfo;
                            }
                        }
                        catch
                        { empresa = null; }
                    }

                    //foreach (PreguntaInfo item in test)
                    //{
                    //    PreguntaExamen pexamen = PreguntaExamen.New();
                    //    Pregunta pregunta_examen = Pregunta.New();
                    //    pexamen.CopyValues(item);
                    //    pregunta_examen.Base.CopyValues(item);
                    //    pexamen.Orden = orden;
                    //    orden++;
                    //    p_test.AddItem(pexamen);
                    //    pregunta_examen.MarkItemChild();
                    //    preguntas.AddItem(pregunta_examen);
                    //    foreach (RespuestaInfo res in item.Respuestas)
                    //    {
                    //        if (res.OidPregunta == item.Oid)
                    //        {
                    //            RespuestaExamen rexamen = RespuestaExamen.NewChild(pexamen);
                    //            rexamen.CopyValues(res);
                    //            pexamen.RespuestaExamens.AddItem(rexamen);
                    //        }
                    //    }
                    //}

                    //foreach (PreguntaInfo item in desarrollo)
                    //{
                    //    PreguntaExamen pexamen = PreguntaExamen.New();
                    //    Pregunta pregunta_examen = Pregunta.New();
                    //    pexamen.CopyValues(item);
                    //    pregunta_examen.Base.CopyValues(item);
                    //    pexamen.Orden = orden;
                    //    orden++;
                    //    p_desarrollo.AddItem(pexamen);
                    //    pregunta_examen.MarkItemChild();
                    //    preguntas.AddItem(pregunta_examen);
                    //}

                    ExamenReportMng reportMng = new ExamenReportMng(AppContext.ActiveSchema);

                    if (List.Count > 0)
                    {
                        Library.Instruction.Reports.Preguntas.PreguntasListRpt report = reportMng.GetPreguntasListReport(List);
                        report.SetParameterValue("Empresa", empresa.Name);
                        if (empresa.Oid == 2)
                        {
                            ((CrystalDecisions.CrystalReports.Engine.TextObject)(report.Section5.ReportObjects["Text1"])).Color = System.Drawing.Color.FromArgb(13, 176, 46);
                        }
                        ReportViewer.SetReport(report);
                        ReportViewer.ShowDialog();
                    }

                    /*if (p_test.Count > 0)
                     * {
                     *  Library.Instruction.Reports.Examen.PreguntasTestRpt r_test = reportMng.GetDetailPreguntasTestReport(p_test, preguntas);
                     *  r_test.SetParameterValue("Empresa", empresa.Name);
                     *  if (empresa.Oid == 2) ((CrystalDecisions.CrystalReports.Engine.TextObject)(r_test.Section5.ReportObjects["Text1"])).Color = System.Drawing.Color.FromArgb(13, 176, 46);
                     *  ReportViewer.SetReport(r_test);
                     *  ReportViewer.ShowDialog();
                     * }
                     *
                     * if (p_desarrollo.Count > 0)
                     * {
                     *  Library.Instruction.Reports.Examen.PreguntasDesarrolloRpt r_desarrollo = reportMng.GetDetailPreguntasDesarrolloReport(p_desarrollo, preguntas);
                     *  r_desarrollo.SetParameterValue("Empresa", empresa.Name);
                     *  if (empresa.Oid == 2) ((CrystalDecisions.CrystalReports.Engine.TextObject)(r_desarrollo.Section5.ReportObjects["Text1"])).Color = System.Drawing.Color.FromArgb(13, 176, 46);
                     *  ReportViewer.SetReport(r_desarrollo);
                     *  ReportViewer.ShowDialog();
                     * }*/
                }
                else
                {
                    PreguntaList preguntas       = PreguntaList.GetList(Datos.List as IList <Pregunta>);
                    string       lista_preguntas = "(";
                    foreach (PreguntaInfo item in preguntas)
                    {
                        lista_preguntas += item.Oid.ToString() + ",";
                    }
                    if (lista_preguntas.IndexOf(",") > 0)
                    {
                        lista_preguntas = lista_preguntas.Substring(0, lista_preguntas.LastIndexOf(","));
                    }
                    lista_preguntas += ")";

                    InformePreguntasList List = InformePreguntasList.GetList(lista_preguntas);

                    ExamenReportMng reportMng = new ExamenReportMng(AppContext.ActiveSchema);

                    if (List.Count > 0)
                    {
                        bool        defecto = moleQule.Library.Instruction.ModulePrincipal.GetImpresionEmpresaDefaultBoolSetting();
                        CompanyInfo empresa = null;

                        if (defecto)
                        {
                            empresa = CompanyInfo.Get(moleQule.Library.Instruction.ModulePrincipal.GetImpresionEmpresaDefaultOidSetting(), false);
                        }
                        while (empresa == null)
                        {
                            moleQule.Face.Common.CompanySelectForm form = new Common.CompanySelectForm(this);
                            DialogResult result = form.ShowDialog();

                            try
                            {
                                if (result == DialogResult.OK)
                                {
                                    empresa = form.Selected as CompanyInfo;
                                }
                            }
                            catch
                            { empresa = null; }
                        }

                        moleQule.Library.Instruction.Reports.Preguntas.InformePreguntasRpt report = reportMng.GetInformePreguntasReport(List);
                        report.SetParameterValue("Empresa", empresa.Name);
                        if (empresa.Oid == 2)
                        {
                            ((CrystalDecisions.CrystalReports.Engine.TextObject)(report.Section5.ReportObjects["Text1"])).Color = System.Drawing.Color.FromArgb(13, 176, 46);
                        }
                        ReportViewer.SetReport(report);
                        ReportViewer.ShowDialog();
                    }
                }
            }
        }
Exemple #22
0
        private void Select_Button_Click(object sender, EventArgs e)
        {
            _plantilla = PlantillaExamenInfo.Get(ActiveOID);

            if (_plantilla != null)
            {
                _guardado = true;

                if (!_plantilla.Desarrollo)
                {
                    TemaList temas = TemaList.GetModuloList(_modulo.Oid, false);

                    foreach (Preguntas_PlantillaInfo item in _plantilla.Preguntas)
                    {
                        long count = item.NPreguntas;

                        PreguntaList preguntas_tema = PreguntaList.GetPreguntasDisponiblesTema(item.OidTema, _entity.Desarrollo, _entity.FechaExamen, count);

                        if (preguntas_tema != null)
                        {
                            foreach (PreguntaInfo info in preguntas_tema)
                            {
                                if (count == 0)
                                {
                                    break;
                                }

                                Pregunta_Examen pregunta = Pregunta_Examen.NewChild(_entity);
                                pregunta.OidPregunta = info.Oid;
                                _entity.Pregunta_Examens.AddItem(pregunta);
                                count--;
                            }
                        }

                        if (count != 0)
                        {
                            TemaInfo tema = temas.GetItem(item.OidTema);
                            MessageBox.Show("No hay suficientes preguntas disponibles para el tema " + tema.Codigo);
                        }
                    }
                }
                else
                {
                    long count = _plantilla.NPreguntas;

                    PreguntaList preguntas = PreguntaList.GetPreguntasDisponiblesModulo(_entity.OidModulo, _entity.Desarrollo, _entity.FechaExamen, count);

                    if (preguntas != null)
                    {
                        foreach (PreguntaInfo info in preguntas)
                        {
                            if (count == 0)
                            {
                                break;
                            }

                            Pregunta_Examen pregunta = Pregunta_Examen.NewChild(_entity);
                            pregunta.OidPregunta = info.Oid;
                            _entity.Pregunta_Examens.AddItem(pregunta);
                            count--;
                        }
                    }

                    if (count != 0)
                    {
                        MessageBox.Show("No hay suficientes preguntas disponibles en el submódulo");
                    }
                }
            }

            Cerrar();
            Close();
        }
Exemple #23
0
 public void SetSourceData(Examen item, ModuloInfo modulo)
 {
     SetSourceData(item, modulo, PreguntaList.GetPreguntasModulo(modulo.Oid));
 }
        private void ExportaDOC(CompanyInfo empresa)
        {
            object oMissing  = System.Reflection.Missing.Value;
            object oEndOfDoc = "\\endofdoc"; /* \endofdoc is a predefined bookmark */

            try
            {
                WordExporter.InitWordExporter();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message,
                                moleQule.Face.Resources.Labels.ERROR_TITLE,
                                MessageBoxButtons.OK,
                                MessageBoxIcon.Error);

                return;
            }

            Word.Document oDoc = WordExporter.NewDocument();

            //Start Word and create a new document.

            /*Word._Application oWord;
             * Word._Document oDoc;
             * oWord = new Word.Application();
             * oWord.Visible = true;
             * oDoc = oWord.Documents.Add(ref oMissing, ref oMissing,
             *  ref oMissing, ref oMissing);*/

            foreach (Word.Section wordSection in oDoc.Sections)
            {
                wordSection.Footers[Word.WdHeaderFooterIndex.wdHeaderFooterPrimary].Range.Text = empresa.Name;
                wordSection.Footers[Word.WdHeaderFooterIndex.wdHeaderFooterPrimary].PageNumbers.ShowFirstPageNumber = true;
                wordSection.Range.ParagraphFormat.SpaceAfter  = 0;
                wordSection.Range.ParagraphFormat.SpaceBefore = 0;
            }

            //Márgenes (1cm aprox.)
            oDoc.PageSetup.TopMargin    = 15;
            oDoc.PageSetup.BottomMargin = 0;
            oDoc.PageSetup.LeftMargin   = 30;
            oDoc.PageSetup.RightMargin  = 30;

            //Tabla de encabezado
            Word.Table oTable;
            Word.Range wrdRng = oDoc.Bookmarks.get_Item(ref oEndOfDoc).Range;
            oTable = oDoc.Tables.Add(wrdRng, 5, 4, ref oMissing, ref oMissing);

            oTable.Range.ParagraphFormat.SpaceAfter  = 6;
            oTable.Range.ParagraphFormat.SpaceBefore = 6;

            oTable.Columns[1].Cells.Merge();
            oTable.Borders.Enable           = 1;
            oTable.Borders.InsideLineWidth  = Word.WdLineWidth.wdLineWidth150pt;
            oTable.Borders.OutsideLineWidth = Word.WdLineWidth.wdLineWidth150pt;

            oTable.Columns[2].Cells[1].Merge(oTable.Columns[2].Cells[2]);

            oTable.Columns[1].Width = 108.44F;
            oTable.Columns[3].Width = 81.33F;
            oTable.Columns[4].Width = 81.33F;
            oTable.Columns[2].Width = 271.1F;

            oTable.Rows.Alignment = Word.WdRowAlignment.wdAlignRowCenter;

            string logo = CompanyInfo.GetLogoPath(empresa.Oid);

            if (!File.Exists(logo))
            {
                MessageBox.Show("No se ha encontrado la imagen: " + logo);
            }
            else
            {
                oTable.Cell(1, 1).Range.InlineShapes.AddPicture(logo, ref oMissing, ref oMissing, ref oMissing);
            }
            oTable.Cell(1, 1).VerticalAlignment = Word.WdCellVerticalAlignment.wdCellAlignVerticalCenter;

            ExamenPrint examen = Entity.GetPrintObject(empresa, string.Empty);

            oTable.Cell(1, 2).Range.Text                 = "HOJA DE PREGUNTAS";
            oTable.Cell(1, 2).Range.Font.Bold            = 1;
            oTable.Cell(1, 2).Range.Font.Size            = 16;
            oTable.Cell(1, 2).VerticalAlignment          = Word.WdCellVerticalAlignment.wdCellAlignVerticalCenter;
            oTable.Cell(1, 2).Range.Paragraphs.Alignment = Word.WdParagraphAlignment.wdAlignParagraphCenter;
            oTable.Columns[2].Cells[1].Range.Font.Name   = "Arial";

            oTable.Columns[2].Cells[2].Range.Text                 = examen.Modulo;
            oTable.Columns[2].Cells[2].Range.Font.Bold            = 1;
            oTable.Columns[2].Cells[2].Range.Font.Size            = 11;
            oTable.Columns[2].Cells[2].VerticalAlignment          = Word.WdCellVerticalAlignment.wdCellAlignVerticalCenter;
            oTable.Columns[2].Cells[2].Range.Paragraphs.Alignment = Word.WdParagraphAlignment.wdAlignParagraphCenter;
            oTable.Columns[2].Cells[2].Range.Font.Name            = "Arial";

            oTable.Columns[2].Cells[3].Range.Text                 = "CURSO : " + examen.Promocion;
            oTable.Columns[2].Cells[3].Range.Font.Bold            = 1;
            oTable.Columns[2].Cells[3].Range.Font.Size            = 11;
            oTable.Columns[2].Cells[3].VerticalAlignment          = Word.WdCellVerticalAlignment.wdCellAlignVerticalCenter;
            oTable.Columns[2].Cells[3].Range.Paragraphs.Alignment = Word.WdParagraphAlignment.wdAlignParagraphCenter;
            oTable.Columns[2].Cells[3].Range.Font.Name            = "Arial";

            oTable.Columns[2].Cells[4].Range.Text                 = "Deberá responder a las preguntas del examen a continuación de las mismas.";
            oTable.Columns[2].Cells[4].Range.Font.Size            = 11;
            oTable.Columns[2].Cells[4].VerticalAlignment          = Word.WdCellVerticalAlignment.wdCellAlignVerticalCenter;
            oTable.Columns[2].Cells[4].Range.Paragraphs.Alignment = Word.WdParagraphAlignment.wdAlignParagraphCenter;
            oTable.Columns[2].Cells[4].Range.Font.Name            = "Arial";

            oTable.Columns[3].Cells[1].Range.Text                 = "Nº EXAMEN";
            oTable.Columns[3].Cells[1].Range.Font.Bold            = 1;
            oTable.Columns[3].Cells[1].Range.Font.Size            = 11;
            oTable.Columns[3].Cells[1].VerticalAlignment          = Word.WdCellVerticalAlignment.wdCellAlignVerticalCenter;
            oTable.Columns[3].Cells[1].Range.Paragraphs.Alignment = Word.WdParagraphAlignment.wdAlignParagraphCenter;
            oTable.Columns[3].Cells[1].Range.Font.Name            = "Arial";

            oTable.Columns[3].Cells[2].Range.Text                 = "FECHA";
            oTable.Columns[3].Cells[2].Range.Font.Bold            = 1;
            oTable.Columns[3].Cells[2].Range.Font.Size            = 11;
            oTable.Columns[3].Cells[2].VerticalAlignment          = Word.WdCellVerticalAlignment.wdCellAlignVerticalCenter;
            oTable.Columns[3].Cells[2].Range.Paragraphs.Alignment = Word.WdParagraphAlignment.wdAlignParagraphCenter;
            oTable.Columns[3].Cells[2].Range.Font.Name            = "Arial";

            oTable.Columns[3].Cells[3].Range.Text                 = "TIPO EXAMEN";
            oTable.Columns[3].Cells[3].Range.Font.Bold            = 1;
            oTable.Columns[3].Cells[3].Range.Font.Size            = 11;
            oTable.Columns[3].Cells[3].VerticalAlignment          = Word.WdCellVerticalAlignment.wdCellAlignVerticalCenter;
            oTable.Columns[3].Cells[3].Range.Paragraphs.Alignment = Word.WdParagraphAlignment.wdAlignParagraphCenter;
            oTable.Columns[3].Cells[3].Range.Font.Name            = "Arial";

            oTable.Columns[3].Cells[4].Range.Text                 = "Nº PREGUNTAS";
            oTable.Columns[3].Cells[4].Range.Font.Bold            = 1;
            oTable.Columns[3].Cells[4].Range.Font.Size            = 11;
            oTable.Columns[3].Cells[4].VerticalAlignment          = Word.WdCellVerticalAlignment.wdCellAlignVerticalCenter;
            oTable.Columns[3].Cells[4].Range.Paragraphs.Alignment = Word.WdParagraphAlignment.wdAlignParagraphCenter;
            oTable.Columns[3].Cells[4].Range.Font.Name            = "Arial";

            oTable.Columns[3].Cells[5].Range.Text                 = "TIEMPO";
            oTable.Columns[3].Cells[5].Range.Font.Bold            = 1;
            oTable.Columns[3].Cells[5].Range.Font.Size            = 11;
            oTable.Columns[3].Cells[5].VerticalAlignment          = Word.WdCellVerticalAlignment.wdCellAlignVerticalCenter;
            oTable.Columns[3].Cells[5].Range.Paragraphs.Alignment = Word.WdParagraphAlignment.wdAlignParagraphCenter;
            oTable.Columns[3].Cells[5].Range.Font.Name            = "Arial";

            oTable.Columns[4].Cells[1].Range.Text                 = examen.Numero.ToString().Trim();
            oTable.Columns[4].Cells[1].Range.Font.Size            = 11;
            oTable.Columns[4].Cells[1].VerticalAlignment          = Word.WdCellVerticalAlignment.wdCellAlignVerticalCenter;
            oTable.Columns[4].Cells[1].Range.Paragraphs.Alignment = Word.WdParagraphAlignment.wdAlignParagraphCenter;
            oTable.Columns[4].Cells[1].Range.Font.Name            = "Arial";

            oTable.Columns[4].Cells[2].Range.Text                 = examen.FechaExamen.ToShortDateString().Trim();
            oTable.Columns[4].Cells[2].Range.Font.Size            = 11;
            oTable.Columns[4].Cells[2].VerticalAlignment          = Word.WdCellVerticalAlignment.wdCellAlignVerticalCenter;
            oTable.Columns[4].Cells[2].Range.Paragraphs.Alignment = Word.WdParagraphAlignment.wdAlignParagraphCenter;
            oTable.Columns[4].Cells[2].Range.Font.Name            = "Arial";

            oTable.Columns[4].Cells[3].Range.Text                 = examen.Tipo.Trim();
            oTable.Columns[4].Cells[3].Range.Font.Size            = 11;
            oTable.Columns[4].Cells[3].VerticalAlignment          = Word.WdCellVerticalAlignment.wdCellAlignVerticalCenter;
            oTable.Columns[4].Cells[3].Range.Paragraphs.Alignment = Word.WdParagraphAlignment.wdAlignParagraphCenter;
            oTable.Columns[4].Cells[3].Range.Font.Name            = "Arial";

            oTable.Columns[4].Cells[4].Range.Text                 = examen.NPreguntas.ToString().Trim();
            oTable.Columns[4].Cells[4].Range.Font.Size            = 11;
            oTable.Columns[4].Cells[4].VerticalAlignment          = Word.WdCellVerticalAlignment.wdCellAlignVerticalCenter;
            oTable.Columns[4].Cells[4].Range.Paragraphs.Alignment = Word.WdParagraphAlignment.wdAlignParagraphCenter;
            oTable.Columns[4].Cells[4].Range.Font.Name            = "Arial";

            oTable.Columns[4].Cells[5].Range.Font.Name            = "Arial";
            oTable.Columns[4].Cells[5].Range.Font.Size            = 11;
            oTable.Columns[4].Cells[5].VerticalAlignment          = Word.WdCellVerticalAlignment.wdCellAlignVerticalCenter;
            oTable.Columns[4].Cells[5].Range.Paragraphs.Alignment = Word.WdParagraphAlignment.wdAlignParagraphCenter;
            oTable.Columns[4].Cells[5].Range.Text = examen.Duracion.ToShortTimeString().Trim();

            ////Add some text after the table.
            Word.Paragraph oParaAux;
            object         oRng = oDoc.Bookmarks.get_Item(ref oEndOfDoc).Range;

            oParaAux            = oDoc.Content.Paragraphs.Add(ref oRng);
            oParaAux.Range.Text = string.Empty;
            oParaAux.Range.InsertParagraph();

            //Nombre y apellidos
            Word.Paragraph oPara1;
            oPara1                 = oDoc.Content.Paragraphs.Add(ref oMissing);
            oPara1.Range.Text      = "NOMBRE Y APELLIDOS:";
            oPara1.Range.Font.Size = 12;
            oPara1.Range.Font.Name = "Arial";
            oPara1.Range.InsertParagraphAfter();
            oPara1.Range.InsertParagraphBefore();

            //DNI/NIE, FIRMA
            Word.Paragraph oPara2;
            oPara2                 = oDoc.Content.Paragraphs.Add(ref oMissing);
            oPara2.Range.Text      = "DNI/NIE:                                                           FIRMA:";
            oPara2.Range.Font.Size = 12;
            oPara2.Range.Font.Name = "Arial";
            oPara2.Range.InsertParagraphAfter();
            oPara2.Range.InsertParagraphBefore();

            PreguntaList lista_preguntas = null;

            //Origen de las preguntas en función de si el examen está emitido o no
            if (_entity.Emitido)
            {
                lista_preguntas = PreguntaList.GetList(_entity.PreguntaExamenes);
            }
            else
            {
                lista_preguntas = _preguntas;
            }

            if (lista_preguntas != null)
            {
                int          i = 1;
                PreguntaInfo item;

                foreach (PreguntaExamenInfo pex in _entity.PreguntaExamenes)
                {
                    item = lista_preguntas.GetItem(pex.OidPregunta);

                    /*if (_preguntas_examen != null)
                     * {
                     *  int i = 1;
                     *
                     *  foreach (Pregunta_Examen preg in _preguntas_examen)
                     *  {
                     *      Pregunta item = _preguntas.GetItem(preg.OidPregunta);*/

                    //Para cada pregunta se inserta una tabla
                    wrdRng = oDoc.Bookmarks.get_Item(ref oEndOfDoc).Range;
                    Word.Range newRng        = oDoc.Bookmarks.get_Item(ref oEndOfDoc).Range;
                    int        paginas_antes = (int)(oTable.Range.get_Information(Word.WdInformation.wdNumberOfPagesInDocument));
                    oTable = oDoc.Tables.Add(wrdRng, 2, 3, ref oMissing, ref oMissing);

                    oTable.Rows.HeightRule = Word.WdRowHeightRule.wdRowHeightAuto;

                    oTable.Columns[1].Width                      = 30;
                    oTable.Cell(1, 1).Range.Text                 = i.ToString();
                    oTable.Cell(1, 1).Range.Font.Size            = 10;
                    oTable.Cell(1, 1).Range.Paragraphs.Alignment = Word.WdParagraphAlignment.wdAlignParagraphCenter;
                    oTable.Cell(1, 1).Range.Font.Bold            = 1;
                    oTable.Cell(1, 1).Range.Font.Name            = "Arial";

                    oTable.Cell(1, 2).Merge(oTable.Columns[3].Cells[1]);
                    oTable.Cell(1, 2).Width                      = 510;
                    oTable.Cell(1, 2).Range.Text                 = item.Texto;
                    oTable.Cell(1, 2).Range.Font.Size            = 10;
                    oTable.Cell(1, 2).Range.Paragraphs.Alignment = Word.WdParagraphAlignment.wdAlignParagraphJustify;
                    oTable.Cell(1, 2).Range.Font.Bold            = 1;
                    oTable.Cell(1, 2).Range.Font.Name            = "Arial";

                    oTable.Cell(2, 2).Merge(oTable.Cell(2, 3));
                    oTable.Cell(2, 1).Merge(oTable.Cell(2, 2));
                    oTable.Cell(2, 1).Width = 540;

                    if (item.Imagen != string.Empty)
                    {
                        string path = item.ImagenWithPath;

                        if (File.Exists(path))
                        {
                            oTable.Cell(2, 1).Range.InlineShapes.AddPictureBullet(path, ref oMissing);
                            oTable.Cell(2, 1).VerticalAlignment          = Word.WdCellVerticalAlignment.wdCellAlignVerticalCenter;
                            oTable.Cell(2, 1).Range.Paragraphs.Alignment = Word.WdParagraphAlignment.wdAlignParagraphCenter;
                        }
                        else
                        {
                            oTable.Rows[2].Delete();
                        }
                    }
                    else
                    {
                        oTable.Rows[2].Delete();
                    }

                    ////Add some text after the table.
                    oRng                = oDoc.Bookmarks.get_Item(ref oEndOfDoc).Range;
                    oParaAux            = oDoc.Content.Paragraphs.Add(ref oRng);
                    oParaAux.Range.Text = string.Empty;
                    oParaAux.Range.InsertParagraph();

                    int paginas_despues = (int)(oParaAux.Range.get_Information(Word.WdInformation.wdNumberOfPagesInDocument));
                    if (paginas_antes < paginas_despues)
                    {
                        newRng.InsertBreak(ref oMissing);
                    }

                    i++;
                }
            }
            else
            {
                foreach (PreguntaExamenInfo item in Entity.PreguntaExamenes)
                {
                    //Para cada pregunta se inserta una tabla
                    wrdRng = oDoc.Bookmarks.get_Item(ref oEndOfDoc).Range;
                    Word.Range newRng        = oDoc.Bookmarks.get_Item(ref oEndOfDoc).Range;
                    int        paginas_antes = (int)(oTable.Range.get_Information(Word.WdInformation.wdNumberOfPagesInDocument));
                    oTable = oDoc.Tables.Add(wrdRng, 2, 3, ref oMissing, ref oMissing);

                    oTable.Rows.HeightRule = Word.WdRowHeightRule.wdRowHeightAuto;

                    oTable.Columns[1].Width                      = 30;
                    oTable.Cell(1, 1).Range.Text                 = item.Orden.ToString();
                    oTable.Cell(1, 1).Range.Font.Size            = 10;
                    oTable.Cell(1, 1).Range.Paragraphs.Alignment = Word.WdParagraphAlignment.wdAlignParagraphCenter;
                    oTable.Cell(1, 1).Range.Font.Bold            = 1;
                    oTable.Cell(1, 1).Range.Font.Name            = "Arial";

                    oTable.Cell(1, 2).Merge(oTable.Columns[3].Cells[1]);
                    oTable.Cell(1, 2).Width                      = 510;
                    oTable.Cell(1, 2).Range.Text                 = item.Texto;
                    oTable.Cell(1, 2).Range.Font.Size            = 10;
                    oTable.Cell(1, 2).Range.Paragraphs.Alignment = Word.WdParagraphAlignment.wdAlignParagraphJustify;
                    oTable.Cell(1, 2).Range.Font.Bold            = 1;
                    oTable.Cell(1, 2).Range.Font.Name            = "Arial";

                    oTable.Cell(2, 2).Merge(oTable.Cell(2, 3));
                    oTable.Cell(2, 1).Merge(oTable.Cell(2, 2));
                    oTable.Cell(2, 1).Width = 540;

                    if (item.Imagen != string.Empty)
                    {
                        /*string path = Images.GetRootPath() + PreguntaExamenInfo.GetImagenesPath() +
                         *  item.OidExamen.ToString("00000") + "\\" + item.Imagen;*/
                        string path = item.ImagenWithPath;

                        if (File.Exists(path))
                        {
                            oTable.Cell(2, 1).Range.InlineShapes.AddPictureBullet(path, ref oMissing);
                            oTable.Cell(2, 1).VerticalAlignment          = Word.WdCellVerticalAlignment.wdCellAlignVerticalCenter;
                            oTable.Cell(2, 1).Range.Paragraphs.Alignment = Word.WdParagraphAlignment.wdAlignParagraphCenter;
                        }
                        else
                        {
                            oTable.Rows[2].Delete();
                        }
                    }
                    else
                    {
                        oTable.Rows[2].Delete();
                    }

                    ////Add some text after the table.
                    oRng                = oDoc.Bookmarks.get_Item(ref oEndOfDoc).Range;
                    oParaAux            = oDoc.Content.Paragraphs.Add(ref oRng);
                    oParaAux.Range.Text = string.Empty;
                    oParaAux.Range.InsertParagraph();

                    int paginas_despues = (int)(oParaAux.Range.get_Information(Word.WdInformation.wdNumberOfPagesInDocument));
                    if (paginas_antes < paginas_despues)
                    {
                        newRng.InsertBreak(ref oMissing);
                    }
                }
            }

            WordExporter.Close();
        }
Exemple #25
0
        protected override void PrintAction()
        {
            if (Entity.Pregunta_Examens.Count == 0)
            {
                return;
            }

            moleQule.Library.Timer t = new moleQule.Library.Timer();
            t.Start();

            //se obliga a guardar el examen antes de imprimir por si durante la impresión hubiera algún problema
            //quedan guardadas las modificaciones que pudieran no haberse guardado
            //if (Entity.IsDirty)
            //{
            //DialogResult result = MessageBox.Show(Resources.Messages.GUARDADO_EXAMEN,
            //    moleQule.Face.Resources.Labels.ADVISE_TITLE, MessageBoxButtons.OKCancel, MessageBoxIcon.Question);
            //if (result == DialogResult.OK)
            //{
            try
            {
                ValidateInput();
            }
            catch (iQValidationException ex)
            {
                MessageBox.Show(ex.Message,
                                moleQule.Face.Resources.Labels.ADVISE_TITLE,
                                MessageBoxButtons.OK,
                                MessageBoxIcon.Warning);
                return;
            }
            //}
            //else
            //    return;
            //}

            Entity.PreguntaExamens = PreguntaExamens.NewChildList();

            string memo = string.Empty;

            foreach (Pregunta_Examen item in Entity.Pregunta_Examens)
            {
                memo += item.OidPregunta.ToString() + ",";
            }

            if (memo != string.Empty)
            {
                memo = memo.Substring(0, memo.Length - 1);
            }
            RespuestaList respuestas = RespuestaList.GetRespuestasExamenList(memo);

            foreach (DataGridViewRow row in Preguntas_Grid.Rows)
            {
                PreguntaInfo p = _preguntas_modulo.GetItem(((PreguntaInfo)row.DataBoundItem).Oid);
                t.Record("Obtener pregunta de la lista de preguntas del examen");

                PreguntaExamen pexamen = PreguntaExamen.NewChild(_entity);
                pexamen.CopyValues(p);
                pexamen.Orden = Convert.ToInt64(row.Cells[N_Orden.Name].Value);
                pexamen.MarkItemChild();
                t.Record("Crear PreguntaExamen");

                Entity.PreguntaExamens.AddItem(pexamen);
                FCriteria <long> criteria = new FCriteria <long>("OidPregunta", p.Oid);

                foreach (RespuestaInfo item in respuestas)
                {
                    if (p.Oid == item.OidPregunta)
                    {
                        RespuestaExamen rexamen = RespuestaExamen.NewChild(pexamen);
                        rexamen.CopyValues(item);
                        rexamen.MarkItemChild();
                        pexamen.RespuestaExamens.AddItem(rexamen);
                    }
                }
            }

            //Preguntas preguntas_examen = null;/* Pregunta.GetPreguntasByList(memo);*/
            PreguntaList preguntas_examen_list = PreguntaList.GetPreguntasByList(memo);

            if (EntityInfo.Desarrollo)
            {
                //tiene que llamar a ExamenDesarrolloReportForm
                ExamenDesarrolloReportForm form = new ExamenDesarrolloReportForm(true, EntityInfo, preguntas_examen_list, _entity.Pregunta_Examens);
                form.ShowDialog();
            }
            else
            {
                //tiene que llamar a ExamenTestReportForm
                ExamenTestReportForm form = new ExamenTestReportForm(true, EntityInfo, preguntas_examen_list, _entity.Pregunta_Examens);
                form.ShowDialog();
            }

            Entity.PreguntaExamens = PreguntaExamens.NewChildList();
        }
Exemple #26
0
        protected override void CellContentClick(int column, int row)
        {
            switch (Preguntas_Grid.Columns[column].Name)
            {
            case "Ordenar_BT":
            {
                OrdenarPreguntasInputForm form = new OrdenarPreguntasInputForm(true, row + 1);
                form.SetSourceData(Entity, Preguntas_Grid.Rows.Count);
                form.ShowDialog();

                RellenaPreguntas();
            }
            break;

            case "Ver_BT":
            {
                //Pregunta.OpenSession();
                string memo = string.Empty;

                foreach (Pregunta_Examen item in Entity.Pregunta_Examens)
                {
                    memo += item.OidPregunta.ToString() + ",";
                }

                if (memo != string.Empty)
                {
                    memo = memo.Substring(0, memo.Length - 1);
                }

                PreguntaList preguntas = PreguntaList.GetPreguntasByList(memo);

                PreguntaInfo      info = (PreguntaInfo)Preguntas_Grid.Rows[row].DataBoundItem;
                PreguntasViewForm form = new PreguntasViewForm(info.Oid, preguntas, true);
                form.ShowDialog();
            }
            break;

            case "Editar_BT":
            {
                string memo = string.Empty;

                foreach (Pregunta_Examen item in Entity.Pregunta_Examens)
                {
                    memo += item.OidPregunta.ToString() + ",";
                }

                if (memo != string.Empty)
                {
                    memo = memo.Substring(0, memo.Length - 1);
                }

                Preguntas    preguntas = Preguntas.GetPreguntasByList(memo, _entity.SessionCode);
                Preguntas    ordenadas = Preguntas.NewList();
                PreguntaInfo info      = (PreguntaInfo)Preguntas_Grid.Rows[row].DataBoundItem;

                //se ordenan las preguntas para que se vayan mostrando en el mismo orden que en el examen
                foreach (Pregunta_Examen item in _entity.Pregunta_Examens)
                {
                    ordenadas.AddItem(preguntas.GetItem(item.OidPregunta));
                }

                Pregunta activa = ordenadas.GetItem(info.Oid);
                SortedBindingList <Pregunta> sorted = Preguntas.SortList(ordenadas, "Codigo", ListSortDirection.Ascending);

                PreguntasEditForm form = new PreguntasEditForm(activa, sorted, true);
                form.ShowDialog();

                //se recarga la lista de preguntas a seleccionar para que estén actualizadas
                PreguntasModulo = PreguntaList.GetPreguntasModulo(_entity.OidModulo, _entity.MemoPreguntas);

                RellenaPreguntas();
                //preguntas.CloseSession();
                ordenadas.CloseSession();
            }
            break;

            case "Eliminar_BT":
            {
                DialogResult result;

                result = MessageBox.Show("¿Está seguro que desea eliminar la pregunta seleccionada?", "Aviso", MessageBoxButtons.YesNo);

                if (result == DialogResult.Yes)
                {
                    //string memo_preguntas = Entity.MemoPreguntas;
                    //int pos = 0;

                    //long oid_eliminada = ((PreguntaInfo)Preguntas_Grid.Rows[row].DataBoundItem).Oid;

                    //string[] lista = Entity.MemoPreguntas.Split(';');
                    //Entity.MemoPreguntas = string.Empty;

                    //foreach (string oid in lista)
                    //{
                    //    try
                    //    {
                    //        long oid_pregunta = Convert.ToInt32(oid);
                    //        if (oid_pregunta != oid_eliminada)
                    //            Entity.MemoPreguntas += oid_pregunta + ";";
                    //        else
                    //        {
                    //            Pregunta item = _preguntas.GetItem(oid_pregunta);
                    //            item.Reservada = false;
                    //        }
                    //    }
                    //    catch
                    //    {
                    //        continue;
                    //    }
                    //}

                    foreach (Pregunta_Examen item in Entity.Pregunta_Examens)
                    {
                        if (item.OidPregunta == ((PreguntaInfo)Preguntas_Grid.Rows[row].DataBoundItem).Oid)
                        {
                            Entity.Pregunta_Examens.Remove(item);
                            break;
                        }
                    }

                    //while (memo_preguntas != string.Empty)
                    //{
                    //    string pregunta;
                    //    int index = memo_preguntas.IndexOf(";");
                    //    pregunta = memo_preguntas.Substring(0, index + 1);
                    //    memo_preguntas = memo_preguntas.Substring(index + 1);
                    //    if (pos != row)
                    //        Entity.MemoPreguntas += pregunta;
                    //    else
                    //    {
                    //        int l = pregunta.Length;
                    //        Pregunta p = _modulo.Preguntas.GetItem(Convert.ToInt64(pregunta.Substring(0, l - 1)));
                    //        p.Reservada = false;

                    //    }
                    //    pos++;
                    //}

                    RellenaPreguntas();
                }
            }
            break;
            }
        }