Exemplo n.º 1
0
        /// <summary>
        /// Guarda en la bd el objeto actual
        /// </summary>
        protected override bool SaveObject()
        {
            using (StatusBusy busy = new StatusBusy(moleQule.Face.Resources.Messages.SAVING))
            {
                this.Datos.RaiseListChangedEvents = false;

                IAcreedor temp = _entity.IClone();
                temp.ApplyEdit();

                // do the save
                try
                {
                    _entity = temp.ISave();
                    _entity.ApplyEdit();

                    return(true);
                }
                catch (Exception ex)
                {
                    PgMng.ShowInfoException(iQExceptionHandler.GetAllMessages(ex));
                    return(false);
                }
                finally
                {
                    this.Datos.RaiseListChangedEvents = true;
                }
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Guarda en la bd el objeto actual
        /// </summary>
        protected override bool SaveObject()
        {
            using (StatusBusy busy = new StatusBusy(moleQule.Face.Resources.Messages.SAVING))
            {
                this.Datos.RaiseListChangedEvents = false;;

                // do the save
                try
                {
                    _cargos.Save();
                    return(true);
                }
                catch (iQValidationException ex)
                {
                    MessageBox.Show(ex.Message,
                                    Controler.APP_TITLE,
                                    MessageBoxButtons.OK,
                                    MessageBoxIcon.Exclamation);
                    return(false);
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message,
                                    Controler.APP_TITLE,
                                    MessageBoxButtons.OK,
                                    MessageBoxIcon.Exclamation);
                    return(false);
                }
                finally
                {
                    RefreshMainData();
                    this.Datos.RaiseListChangedEvents = true;
                }
            }
        }
        /// <summary>
        /// Guarda en la bd el objeto actual
        /// </summary>
        protected override bool SaveObject()
        {
            using (StatusBusy busy = new StatusBusy(moleQule.Face.Resources.Messages.SAVING))
            {
                this.Datos.RaiseListChangedEvents = false;

                Despachante temp = _entity.Clone();
                temp.ApplyEdit();

                // do the save
                try
                {
                    _entity = temp.Save();
                    _entity.ApplyEdit();

                    //Decomentar si se va a mantener en memoria
                    //_entity.BeginEdit();
                    return(true);
                }
                catch (Exception ex)
                {
                    MessageBox.Show(iQExceptionHandler.GetAllMessages(ex),
                                    Application.ProductName,
                                    MessageBoxButtons.OK,
                                    MessageBoxIcon.Exclamation);
                    return(false);
                }
                finally
                {
                    this.Datos.RaiseListChangedEvents = true;
                }
            }
        }
Exemplo n.º 4
0
 public override void Execute()
 {
     using (var busy = new StatusBusy("Paint.NET wird geladen ...", true))
     {
         PaintNetHelper.EditPicture();
     }
 }
        /// <summary>
        /// Guarda en la bd el objeto actual
        /// </summary>
        protected override bool SaveObject()
        {
            using (StatusBusy busy = new StatusBusy(moleQule.Face.Resources.Messages.SAVING))
            {
                this.Datos.RaiseListChangedEvents = false;;

                // do the save
                try
                {
                    _raza_animales.Save();
                    return(true);
                }
                catch (iQValidationException ex)
                {
                    MessageBox.Show(ex.Message,
                                    Application.ProductName,
                                    MessageBoxButtons.OK,
                                    MessageBoxIcon.Exclamation);
                    return(false);
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message,
                                    Application.ProductName,
                                    MessageBoxButtons.OK,
                                    MessageBoxIcon.Exclamation);
                    return(false);
                }
                finally
                {
                    this.Datos.RaiseListChangedEvents = true;
                }
            }
        }
Exemplo n.º 6
0
        /// <summary>
        /// Guarda en la bd el objeto actual
        /// </summary>
        protected override bool SaveObject()
        {
            using (StatusBusy busy = new StatusBusy(moleQule.Face.Resources.Messages.SAVING))
            {
                // Comprobamos que no se intente insertar uno con el mismo codigo
                //if (Entity.IsNew && Empresa.Exists(Codigo_TB.Text))
                //{
                //    MessageBox.Show(moleQule.Face.Resources.Messages.OPERATION_ERROR + Messages.DUPLICATED_CODE);
                //    return false;
                //}

                this.Datos.RaiseListChangedEvents           = false;
                this.Datos_Contactos.RaiseListChangedEvents = false;

                Empresa temp = _entity.Clone();
                temp.ApplyEdit();

                // do the save
                try
                {
                    _entity = temp.Save();
                    _entity.ApplyEdit();

                    // Se modifica el nombre de la foto
                    if (_entity.Logo == "00.bmp")
                    {
                        Images.Rename(_entity.Logo, _entity.Code + ".bmp", Controler.LOGOS_EMPRESAS_PATH);
                        _entity.Logo = _entity.Code + ".bmp";
                        _entity.Save();
                    }

                    //_entity.BeginEdit();
                    return(true);
                }
                catch (iQValidationException ex)
                {
                    MessageBox.Show(iQExceptionHandler.GetAllMessages(ex) +
                                    Environment.NewLine + ex.SysMessage,
                                    System.Windows.Forms.Application.ProductName,
                                    MessageBoxButtons.OK,
                                    MessageBoxIcon.Exclamation);
                    return(false);
                }
                catch (Exception ex)
                {
                    MessageBox.Show(moleQule.Face.Resources.Messages.OPERATION_ERROR + Environment.NewLine +
                                    ex.Message,
                                    System.Windows.Forms.Application.ProductName,
                                    MessageBoxButtons.OK,
                                    MessageBoxIcon.Exclamation);
                    return(false);
                }
                finally
                {
                    this.Datos.RaiseListChangedEvents           = true;
                    this.Datos_Contactos.RaiseListChangedEvents = true;
                }
            }
        }
Exemplo n.º 7
0
        /// <summary>
        /// Guarda en la bd el objeto actual
        /// </summary>
        protected override bool SaveObject()
        {
            using (StatusBusy busy = new StatusBusy(moleQule.Face.Resources.Messages.SAVING))
            {
                this.Datos.RaiseListChangedEvents = false;

                if (_submodulos.GetItem(_pregunta.OidSubmodulo).OidModulo != _pregunta.OidModulo)
                {
                    MessageBox.Show("Debe especificar un submódulo asociado a la pregunta");
                    return(false);
                }

                int      index = Lista.IndexOf(_pregunta);
                Pregunta temp  = _pregunta.CloneAsRoot();

                temp.ApplyEdit();

                // do the save
                try
                {
                    Lista[index] = temp.Save();
                    Lista[index].ApplyEdit();

                    Lista[index].MarkItemChild();
                    Lista[index].MarkItemOld();
                    Lista[index].BeginEdit();

                    _pregunta       = Lista[index];
                    _copia_pregunta = _pregunta.Clone();

                    return(true);
                }
                catch (iQValidationException ex)
                {
                    MessageBox.Show(iQExceptionHandler.GetAllMessages(ex) +
                                    Environment.NewLine + ex.SysMessage,
                                    moleQule.Library.Application.AppController.APP_TITLE,
                                    MessageBoxButtons.OK,
                                    MessageBoxIcon.Exclamation);
                    return(false);
                }
                catch (Exception ex)
                {
                    MessageBox.Show(iQExceptionHandler.GetAllMessages(ex),
                                    moleQule.Library.Application.AppController.APP_TITLE,
                                    MessageBoxButtons.OK,
                                    MessageBoxIcon.Exclamation);
                    return(false);
                }
                finally
                {
                    this.Datos.RaiseListChangedEvents = true;
                }
            }
        }
        /// <summary>
        /// Guarda en la bd el objeto actual
        /// </summary>
        protected override bool SaveObject()
        {
            using (StatusBusy busy = new StatusBusy(moleQule.Face.Resources.Messages.SAVING))
            {
                this.Datos.RaiseListChangedEvents = false;

                if (!CreaSesiones())
                {
                    return(true);
                }
                if (_entity.IsDirty)
                {
                    if (!CrearPartes())
                    {
                        MessageBox.Show(Resources.Messages.ERROR_CREAR_PARTES);
                        return(false);
                    }
                }

                Horario temp = _entity.Clone();
                temp.ApplyEdit();

                // do the save
                try
                {
                    _entity = temp.Save();
                    _entity.ApplyEdit();

                    //Decomentar si se va a mantener en memoria
                    //_entity.BeginEdit();
                    return(true);
                }
                catch (iQValidationException ex)
                {
                    MessageBox.Show(iQExceptionHandler.GetAllMessages(ex) +
                                    Environment.NewLine + ex.SysMessage,
                                    moleQule.Library.Application.AppController.APP_TITLE,
                                    MessageBoxButtons.OK,
                                    MessageBoxIcon.Exclamation);
                    return(false);
                }
                catch (Exception ex)
                {
                    MessageBox.Show(iQExceptionHandler.GetAllMessages(ex),
                                    moleQule.Library.Application.AppController.APP_TITLE,
                                    MessageBoxButtons.OK,
                                    MessageBoxIcon.Exclamation);
                    return(false);
                }
                finally
                {
                    this.Datos.RaiseListChangedEvents = true;
                }
            }
        }
Exemplo n.º 9
0
        /// <summary>
        /// Guarda en la bd el objeto actual
        /// </summary>
        protected override bool SaveObject()
        {
            using (StatusBusy busy = new StatusBusy(moleQule.Face.Resources.Messages.SAVING))
            {
                this.Datos.RaiseListChangedEvents = false;

                PlanAnual temp = _entity.Clone();
                temp.ApplyEdit();

                foreach (Plan_Tipo item in _entity.PlanesTipos)
                {
                    if (item.OidTipo == 0)
                    {
                        MessageBox.Show(Resources.Messages.PLAN_TIPO_NO_VALIDO,
                                        moleQule.Library.Application.AppController.APP_TITLE,
                                        MessageBoxButtons.OK,
                                        MessageBoxIcon.Exclamation);
                        return(false);
                    }
                }

                // do the save
                try
                {
                    _entity = temp.Save();
                    _entity.ApplyEdit();

                    //Decomentar si se va a mantener en memoria
                    //_entity.BeginEdit();
                    return(true);
                }
                catch (iQValidationException ex)
                {
                    MessageBox.Show(iQExceptionHandler.GetAllMessages(ex) +
                                    Environment.NewLine + ex.SysMessage,
                                    moleQule.Library.Application.AppController.APP_TITLE,
                                    MessageBoxButtons.OK,
                                    MessageBoxIcon.Exclamation);
                    return(false);
                }
                catch (Exception ex)
                {
                    MessageBox.Show(iQExceptionHandler.GetAllMessages(ex),
                                    moleQule.Library.Application.AppController.APP_TITLE,
                                    MessageBoxButtons.OK,
                                    MessageBoxIcon.Exclamation);
                    return(false);
                }
                finally
                {
                    this.Datos.RaiseListChangedEvents = true;
                }
            }
        }
Exemplo n.º 10
0
 /// <summary>
 /// Handler for the back event.  The Back button is disabled
 /// when at the beginning of the wizard and is hidden when finished.
 /// </summary>
 protected void OnBack(object sender, EventArgs e)
 {
     using (var busy = new StatusBusy("Vorherige Wizard Seite wird geladen", true))
     {
         ClearEvents();
         _manager.HidePage();
         _manager.Previous();
         SetState();
         SetEvents();
         _manager.ShowPage();
     }
 }
        /// <summary>
        /// Guarda en la bd el objeto actual
        /// </summary>
        protected override bool SaveObject()
        {
            using (StatusBusy busy = new StatusBusy(moleQule.Face.Resources.Messages.SAVING))
            {
                this.Datos.RaiseListChangedEvents = false;

                Modulo temp = _entity.Clone();
                temp.ApplyEdit();

                // do the save
                try
                {
                    if (MaterialRepetido())
                    {
                        MessageBox.Show("No se puede incluir el mismo material más de una vez.");
                        return(false);
                    }

                    if (SubmoduloRepetido())
                    {
                        MessageBox.Show("No se puede incluir dos veces el mismo código de submódulo");
                        return(false);
                    }
                    _entity = temp.Save();
                    _entity.ApplyEdit();

                    //Decomentar si se va a mantener en memoria
                    //_entity.BeginEdit();
                    return(true);
                }
                catch (iQValidationException ex)
                {
                    MessageBox.Show(iQExceptionHandler.GetAllMessages(ex) +
                                    Environment.NewLine + ex.SysMessage,
                                    moleQule.Library.Application.AppController.APP_TITLE,
                                    MessageBoxButtons.OK,
                                    MessageBoxIcon.Exclamation);
                    return(false);
                }
                catch (Exception ex)
                {
                    MessageBox.Show(iQExceptionHandler.GetAllMessages(ex),
                                    moleQule.Library.Application.AppController.APP_TITLE,
                                    MessageBoxButtons.OK,
                                    MessageBoxIcon.Exclamation);
                    return(false);
                }
                finally
                {
                    this.Datos.RaiseListChangedEvents = true;
                }
            }
        }
Exemplo n.º 12
0
 /// <summary>
 /// Handler for the next event.  The Next button is hidden
 /// when at the end of the wizard sequence.
 /// </summary>
 protected void OnNext(object sender, EventArgs e)
 {
     using (var busy = new StatusBusy("Nächste Wizard Seite wird geladen", true))
     {
         ClearEvents();
         _manager.HidePage();
         _manager.Next();
         SetState();
         SetEvents();
         _manager.ShowPage();
     }
 }
Exemplo n.º 13
0
 void DoLoadTemplates()
 {
     if (DockForm != null)
     {
         using (StatusBusy s = new StatusBusy(Strings.LoadingTemplate, DockForm))
         {
             var files = DockForm.DockPanel.Documents
                 .OfType<IDocument>()
                 .Select(p => p.DocumentItem)
                 .OfType<TemplateFile>();
             view.Load(files);
         }
         DockForm.StatusText = Strings.TemplateLoaded;
     }
 }
Exemplo n.º 14
0
        /// <summary>
        /// Guarda en la bd el objeto actual
        /// </summary>
        protected override bool SaveObject()
        {
            using (StatusBusy busy = new StatusBusy(moleQule.Face.Resources.Messages.SAVING))
            {
                this.Datos.RaiseListChangedEvents = false;

                Almacen temp = _entity.Clone();
                temp.ApplyEdit();

                // do the save
                try
                {
                    _entity = temp.Save();
                    _entity.ApplyEdit();


                    //Decomentar si se va a mantener en memoria
                    //_entity.BeginEdit();
                    return(true);
                }
                catch (iQValidationException ex)
                {
                    MessageBox.Show(iQExceptionHandler.GetAllMessages(ex) +
                                    Environment.NewLine + ex.SysMessage,
                                    ControlerBase.GetApplicationTitle(),
                                    MessageBoxButtons.OK,
                                    MessageBoxIcon.Exclamation);
                    return(false);
                }
                catch (Exception ex)
                {
                    MessageBox.Show(iQExceptionHandler.GetAllMessages(ex),
                                    ControlerBase.GetApplicationTitle(),
                                    MessageBoxButtons.OK,
                                    MessageBoxIcon.Exclamation);
                    return(false);
                }
                finally
                {
                    this.Datos.RaiseListChangedEvents = true;
                }
            }
        }
Exemplo n.º 15
0
        /// <summary>
        /// Guarda en la bd el objeto actual
        /// </summary>
        protected override bool SaveObject()
        {
            using (StatusBusy busy = new StatusBusy(moleQule.Face.Resources.Messages.SAVING))
            {
                this.Datos.RaiseListChangedEvents = false;

                Transporter temp = _entity.Clone();
                temp.ApplyEdit();

                // do the save
                try
                {
                    _entity = temp.Save();
                    _entity.ApplyEdit();

                    //_entity.BeginEdit();
                    return(true);
                }
                catch (iQValidationException ex)
                {
                    MessageBox.Show(iQExceptionHandler.GetAllMessages(ex) +
                                    Environment.NewLine + ex.SysMessage,
                                    Application.ProductName,
                                    MessageBoxButtons.OK,
                                    MessageBoxIcon.Exclamation);
                    return(false);
                }
                catch (Exception ex)
                {
                    MessageBox.Show(moleQule.Face.Resources.Messages.OPERATION_ERROR + Environment.NewLine +
                                    ex.Message,
                                    Application.ProductName,
                                    MessageBoxButtons.OK,
                                    MessageBoxIcon.Exclamation);
                    return(false);
                }
                finally
                {
                    this.Datos.RaiseListChangedEvents = true;
                }
            }
        }
Exemplo n.º 16
0
 public void SetMainForm(Form frmMain, BarItem statusBarItem)
 {
     StatusBusy.SetMainForm(frmMain, statusBarItem);
 }
Exemplo n.º 17
0
 private void saveAsToolStripMenuItem_Click(object sender, EventArgs e)
 {
     using (StatusBusy s = new StatusBusy(Strings.Saveing, this))
     {
         Workspace.SaveActiveProjectAs();
     }
     StatusText = Strings.Saved;
 }
Exemplo n.º 18
0
 private void saveAllToolStripMenuItem_Click(object sender, EventArgs e)
 {
     using (StatusBusy s = new StatusBusy(Strings.Saveing, this))
     {
         Workspace.SaveAllProjects();
         foreach (var d in docManager.Documents)
             if (d.IsDirty)
                 d.Save();
     }
     StatusText = Strings.Saved;
 }
Exemplo n.º 19
0
 private void openFileToolStripMenuItem_Click(object sender, EventArgs e)
 {
     using (StatusBusy s = new StatusBusy(Strings.LoadingProject, this))
     {
         Workspace.OpenProject();
     }
     StatusText = Strings.ProjectLoaded;
 }
Exemplo n.º 20
0
 private void saveToolStripMenuItem_Click(object sender, EventArgs e)
 {
     if (docManager.HasActiveDocument)
     {
         using (StatusBusy s = new StatusBusy(Strings.Saveing, this))
         {
             docManager.ActiveDocument.Save();
         }
         StatusText = Strings.Saved;
     }
 }
Exemplo n.º 21
0
 private void MainForm_Load(object sender, EventArgs e)
 {
     if (!DesignMode)
         LoadWindowSettings();
     Show();
     using (StatusBusy status = new StatusBusy(Strings.Loading, this))
     {
         if (Settings.Default.RememberOpenProjects)
         {
             Workspace.Load();
         }
         LoadDocking();
         ProjectExplorer.LoadProjects(this);
     }
 }
        /// <summary>
        /// Guarda en la bd el objeto actual
        /// </summary>
        protected override bool SaveObject()
        {
            using (StatusBusy busy = new StatusBusy(moleQule.Face.Resources.Messages.SAVING))
            {
                this.Datos.RaiseListChangedEvents = false;

                if (PracticaRepetida())
                {
                    return(false);
                }

                Alumno temp = _entity.Clone();
                temp.ApplyEdit();

                // do the save
                try
                {
                    _entity = temp.Save();
                    _entity.ApplyEdit();

                    // Se modifica el nombre de la foto
                    if (_entity.Foto != string.Empty)
                    {
                        if (File.Exists(AppController.FOTOS_ALUMNOS_PATH + _entity.Foto))
                        {
                            Bitmap imagen = new Bitmap(AppController.FOTOS_ALUMNOS_PATH + _entity.Foto);

                            string ext = string.Empty;

                            if (imagen.RawFormat.Guid.Equals(System.Drawing.Imaging.ImageFormat.Jpeg.Guid))
                            {
                                ext = ".jpg";
                            }
                            else
                            {
                                if (imagen.RawFormat.Guid.Equals(System.Drawing.Imaging.ImageFormat.Bmp.Guid))
                                {
                                    ext = ".bmp";
                                }
                                else
                                {
                                    if (imagen.RawFormat.Guid.Equals(System.Drawing.Imaging.ImageFormat.Png.Guid))
                                    {
                                        ext = ".png";
                                    }
                                }
                            }

                            imagen.Dispose();

                            if (_entity.Foto != _entity.Oid.ToString("000") + ext)
                            {
                                File.Copy(AppController.FOTOS_ALUMNOS_PATH + _entity.Foto,
                                          AppController.FOTOS_ALUMNOS_PATH + _entity.Oid.ToString("000") + ext,
                                          true);
                                File.Delete(AppController.FOTOS_ALUMNOS_PATH + _entity.Foto);

                                _entity.Foto = _entity.Oid.ToString("000") + ext;
                                _entity.Save();
                            }
                        }
                    }

                    //Decomentar si se va a mantener en memoria
                    //_entity.BeginEdit();
                    return(true);
                }
                catch (iQValidationException ex)
                {
                    MessageBox.Show(iQExceptionHandler.GetAllMessages(ex) +
                                    Environment.NewLine + ex.SysMessage,
                                    moleQule.Library.Application.AppController.APP_TITLE,
                                    MessageBoxButtons.OK,
                                    MessageBoxIcon.Exclamation);
                    return(false);
                }
                catch (Exception ex)
                {
                    MessageBox.Show(iQExceptionHandler.GetAllMessages(ex),
                                    moleQule.Library.Application.AppController.APP_TITLE,
                                    MessageBoxButtons.OK,
                                    MessageBoxIcon.Exclamation);
                    return(false);
                }
                finally
                {
                    this.Datos.RaiseListChangedEvents = true;
                }
            }
        }
Exemplo n.º 23
0
 public void UnSetMainForm()
 {
     StatusBusy.UnSetMainForm();
 }
Exemplo n.º 24
0
        /// <summary>
        /// Guarda en la bd el objeto actual
        /// </summary>
        protected override bool SaveObject()
        {
            using (StatusBusy busy = new StatusBusy(moleQule.Face.Resources.Messages.SAVING))
            {
                this.Datos.RaiseListChangedEvents = false;

                // do the save
                try
                {
                    string memo = Entity.MemoPreguntas;

                    foreach (Pregunta_Examen item in Entity.Pregunta_Examens)
                    {
                        //si se han añadido preguntas al examen, se añaden al memo
                        if (memo.IndexOf(";" + item.OidPregunta.ToString() + ";") == -1 ||
                            memo.IndexOf(item.OidPregunta.ToString() + ";") != 0)
                        {
                            memo += item.OidPregunta.ToString() + ";";
                        }
                    }

                    if (memo != string.Empty)
                    {
                        //se cambian los ; por coma porque los estamos guardando en la base de datos
                        //separandolos con ; y el SQL necesita que se separen con ,
                        memo = memo.Substring(0, memo.Length - 1);
                        memo = memo.Replace(';', ',');
                    }

                    _preguntas_examen = Preguntas.GetPreguntasByList(memo, _entity.SessionCode);

                    List <long> incluidas = new List <long>();

                    //hay que reconstruir el memo_preguntas
                    string memo_viejo = _entity.MemoPreguntas;
                    _entity.MemoPreguntas = string.Empty;

                    foreach (Pregunta_Examen item in Entity.Pregunta_Examens)
                    {
                        if (_preguntas_examen.GetItem(item.OidPregunta).Activa)
                        {
                            incluidas.Add(item.OidPregunta);
                            _entity.MemoPreguntas += item.OidPregunta.ToString() + ";";
                        }
                    }

                    GetPreguntasReservadas();

                    foreach (Pregunta item in _preguntas_examen)
                    {
                        if (item.Reservada && !preguntas_mismo_dia.Contains(item.Oid))
                        {
                            //hay que comprobar que estaba en el memopreguntas
                            //si no estaba, es que alguien la ha reservado  y no se puede incluir en el examen
                            if (memo_viejo.IndexOf(";" + item.Oid.ToString() + ";") == -1 &&
                                memo_viejo.IndexOf(item.Oid.ToString() + ";") != 0)
                            {
                                MessageBox.Show(string.Format(Resources.Messages.PREGUNTA_INCLUIDA, item.Codigo),
                                                moleQule.Library.Application.AppController.APP_TITLE,
                                                MessageBoxButtons.OK,
                                                MessageBoxIcon.Exclamation);
                                //_preguntas_examen.CloseSession();
                                return(false);
                            }
                        }

                        //si están en el examen
                        if (incluidas.Contains(item.Oid))
                        {
                            //y el examen ha sido emitido, se bloquean
                            if (_entity.FechaEmision.Date.Equals(DateTime.Today.Date))
                            {
                                item.Reservada           = false;
                                item.Bloqueada           = true;
                                item.FechaUltimoExamen   = _entity.FechaExamen;
                                item.FechaDisponibilidad = _entity.FechaExamen.AddMonths(6);
                            }
                            else //si no, se reservan
                            {
                                item.Reservada = true;
                            }
                        }
                        else //si se han quitado del examen, deja de estar reservada
                        {
                            if (!preguntas_mismo_dia.Contains(item.Oid))
                            {
                                item.Reservada = false;
                            }
                        }
                    }
                    _entity.Pregunta_Examens = Pregunta_Examens.NewChildList();

                    Examen temp = _entity.Clone();
                    temp.ApplyEdit();

                    _entity = temp.Save();
                    _entity.ApplyEdit();

                    //rutina para copiar las imágenes de las preguntas en la carpeta de fotos
                    //de preguntas de examen
                    if (_entity.FechaEmision.Date.Equals(DateTime.Today.Date))
                    {
                        PgMng.Grow("Guardando imágenes...");

                        _entity.MemoPreguntas = string.Empty;
                        int orden = 1;
                        foreach (Pregunta origen in _preguntas_examen)
                        {
                            if (origen.Bloqueada == false)
                            {
                                continue;
                            }

                            foreach (PreguntaExamen destino in _entity.PreguntaExamens)
                            {
                                if (destino.OidPregunta == origen.Oid)
                                {
                                    if (origen.Imagen != string.Empty && File.Exists(origen.ImagenWithPath))
                                    {
                                        //string ext = string.Empty;

                                        Bitmap imagen = new Bitmap(origen.ImagenWithPath);

                                        //if (imagen.RawFormat.Guid.Equals(System.Drawing.Imaging.ImageFormat.Jpeg.Guid))
                                        //    ext = ".jpg";
                                        //else
                                        //{
                                        //    if (imagen.RawFormat.Guid.Equals(System.Drawing.Imaging.ImageFormat.Bmp.Guid))
                                        //        ext = ".bmp";
                                        //    else
                                        //    {
                                        //        if (imagen.RawFormat.Guid.Equals(System.Drawing.Imaging.ImageFormat.Png.Guid))
                                        //            ext = ".png";
                                        //    }
                                        //}

                                        string path = origen.ImagenWithPath;

                                        destino.Imagen = destino.Oid.ToString("000000") + path.Substring(path.LastIndexOf("."));

                                        int maxHeight = imagen.Height > imagen.Width ? imagen.Height : imagen.Width;

                                        Images.Save(origen.ImagenWithPath, destino.ImagenWithPath, maxHeight);

                                        imagen.Dispose();
                                    }
                                    else
                                    {
                                        destino.Imagen = string.Empty;
                                    }
                                    if (origen.ModeloRespuesta != string.Empty && File.Exists(origen.ModeloRespuestaPath))
                                    {
                                        string ext = origen.ModeloRespuesta.Substring(origen.ModeloRespuesta.LastIndexOf('.'));
                                        destino.ModeloRespuesta = destino.Oid.ToString("000000") + ext;

                                        string directorio = destino.ModeloRespuestaPath.Substring(0, destino.ModeloRespuestaPath.Length - destino.ModeloRespuesta.Length);
                                        if (!Directory.Exists(directorio))
                                        {
                                            Directory.CreateDirectory(directorio);
                                        }
                                        File.Copy(origen.ModeloRespuestaPath, destino.ModeloRespuestaPath);
                                    }
                                    else
                                    {
                                        origen.ModeloRespuesta = string.Empty;
                                    }
                                    orden++;
                                    break;
                                }
                            }

                            PgMng.Grow();
                        }
                        temp = _entity.Clone();
                        //_preguntas_examen.Save();
                        //_entity = temp.Save();
                    }

                    PgMng.Grow("Guardando examen...");

                    _preguntas_examen.Save();

                    temp    = _entity.Clone();
                    _entity = temp.Save();
                    _entity.BeginEdit();

                    PgMng.FillUp();

                    return(true);
                }
                catch (iQValidationException ex)
                {
                    MessageBox.Show(iQExceptionHandler.GetAllMessages(ex) +
                                    Environment.NewLine + ex.SysMessage,
                                    moleQule.Library.Application.AppController.APP_TITLE,
                                    MessageBoxButtons.OK,
                                    MessageBoxIcon.Exclamation);
                    return(false);
                }
                catch (Exception ex)
                {
                    MessageBox.Show(iQExceptionHandler.GetAllMessages(ex),
                                    moleQule.Library.Application.AppController.APP_TITLE,
                                    MessageBoxButtons.OK,
                                    MessageBoxIcon.Exclamation);
                    return(true);
                }
                finally
                {
                    this.Datos.RaiseListChangedEvents = true;
                }
            }
        }
        /// <summary>
        /// Guarda en la bd el objeto actual
        /// </summary>
        protected override bool SaveObject()
        {
            using (StatusBusy busy = new StatusBusy(moleQule.Face.Resources.Messages.SAVING))
            {
                this.Datos.RaiseListChangedEvents = false;

                //if (SubmoduloRepetido())
                //{
                //    MessageBox.Show("Sólo se puede incluir un profesor titular por submódulo y periodo");
                //    return false;
                //}

                Instructor temp = _entity.Clone();
                temp.ApplyEdit();

                // do the save
                try
                {
                    if (CapacidadRepetida())
                    {
                        MessageBox.Show("Se está añadiendo varias veces el mismo submódulo");
                        return(false);
                    }
                    if (PromocionRepetida())
                    {
                        MessageBox.Show("Se está añadiendo varias veces la misma promoción");
                        return(false);
                    }

                    _entity = temp.Save();
                    _entity.ApplyEdit();

                    // Se modifica el nombre de la foto
                    if (_entity.Foto != string.Empty)
                    {
                        Bitmap imagen = new Bitmap(AppController.FOTOS_INSTRUCTORES_PATH + _entity.Foto);

                        string ext = string.Empty;

                        if (imagen.RawFormat.Guid.Equals(System.Drawing.Imaging.ImageFormat.Jpeg.Guid))
                        {
                            ext = ".jpg";
                        }
                        else
                        {
                            if (imagen.RawFormat.Guid.Equals(System.Drawing.Imaging.ImageFormat.Bmp.Guid))
                            {
                                ext = ".bmp";
                            }
                            else
                            {
                                if (imagen.RawFormat.Guid.Equals(System.Drawing.Imaging.ImageFormat.Png.Guid))
                                {
                                    ext = ".png";
                                }
                            }
                        }

                        imagen.Dispose();

                        if (_entity.Foto != _entity.Oid.ToString("000") + ext)
                        {
                            File.Copy(AppController.FOTOS_INSTRUCTORES_PATH + _entity.Foto,
                                      AppController.FOTOS_INSTRUCTORES_PATH + _entity.Oid.ToString("000") + ext,
                                      true);
                            File.Delete(AppController.FOTOS_INSTRUCTORES_PATH + _entity.Foto);

                            _entity.Foto = _entity.Oid.ToString("000") + ext;
                            _entity.Save();
                        }
                    }

                    //Decomentar si se va a mantener en memoria
                    //_entity.BeginEdit();
                    return(true);
                }
                catch (iQValidationException ex)
                {
                    MessageBox.Show(iQExceptionHandler.GetAllMessages(ex) +
                                    Environment.NewLine + ex.SysMessage,
                                    moleQule.Library.Application.AppController.APP_TITLE,
                                    MessageBoxButtons.OK,
                                    MessageBoxIcon.Exclamation);
                    return(false);
                }
                catch (Exception ex)
                {
                    MessageBox.Show(iQExceptionHandler.GetAllMessages(ex),
                                    moleQule.Library.Application.AppController.APP_TITLE,
                                    MessageBoxButtons.OK,
                                    MessageBoxIcon.Exclamation);
                    return(false);
                }
                finally
                {
                    this.Datos.RaiseListChangedEvents = true;
                }
            }
        }