Пример #1
0
 public void SetSourceData(Cronograma item, int count, ClaseTeoricaList teoricas, ClasePracticaList practicas)
 {
     _entity    = item;
     _count     = count;
     _teoricas  = teoricas;
     _practicas = practicas;
 }
Пример #2
0
        protected override void RefreshMainData()
        {
            if (_practicas.Count == 0)
            {
                for (int i = 0; i < 3; i++)
                {
                    _practicas.Add(null);
                }
            }

            for (int i = 1; i < 3; i++)
            {
                _practicas[i] = ClasePracticaList.GetDisponiblesList(EntityInfo.Oid, OidPromocion, 0, i);
                PgMng.Grow();
            }

            _teoricas = ClaseTeoricaList.GetDisponiblesList(EntityInfo.Oid, OidPromocion, 0);
            PgMng.Grow();

            _lista = new ListaClases();
            RellenaLista();
            PgMng.FillUp();

            Datos_Clases.DataSource = _lista;
        }
Пример #3
0
        private void Hojas_BT_Click(object sender, EventArgs e)
        {
            PrintSource seleccion = PrintSource.All;
            bool        alumno    = false;

            PartesPrintSelectForm form   = new PartesPrintSelectForm(seleccion);
            DialogResult          result = form.ShowDialog();

            if (result != DialogResult.Cancel)
            {
                if (form.Source == PrintSource.Selection)
                {
                    alumno = true;
                }
            }

            CronogramaReportMng reportMng = new CronogramaReportMng(AppContext.ActiveSchema);

            AlumnoList lista = AlumnoList.GetListByPromocion(_entity.OidPromocion, false);

            foreach (ParteAsistenciaInfo item in _entity.Asistencias)
            {
                AlumnoList alumnos = null;
                SesionInfo sesion  = null;

                foreach (SesionInfo ses in _entity.Sesions)
                {
                    if (ses.Fecha.ToShortDateString() == item.Fecha.ToShortDateString() &&
                        ses.Hora.ToShortTimeString() == DateTime.Parse(item.HoraInicio).ToShortTimeString())
                    {
                        sesion = ses;
                        break;
                    }
                }

                alumnos = AlumnoList.CreateAlumnosList(lista, item.Alumno_Partes);

                if (item.Sesiones != string.Empty && alumnos.Count > 0)
                {
                    if (item.Tipo == 2 || sesion.OidClasePractica > 0)
                    {
                        ReportViewer.SetReport(reportMng.GetDetailPracticasReport(sesion, alumnos, item.NHoras,
                                                                                  _teoricas, /*ClasePracticaList.Merge(_practicas[1], _practicas[2])*/
                                                                                  ClasePracticaList.GetClasesPlanList(_entity.OidPlan), _extras, item.Texto, _entity.OidPromocion, alumno));
                    }
                    else
                    {
                        ReportViewer.SetReport(reportMng.GetDetailTeoricasReport(sesion, alumnos, item.NHoras,
                                                                                 _teoricas, ClasePracticaList.Merge(_practicas[1], _practicas[2]), _extras, item.Texto, _entity.OidPromocion, alumno));
                    }
                }

                ReportViewer.ShowDialog();
            }
        }
Пример #4
0
        protected new SortedBindingList <ClasePracticaInfo> Localize(FilterItem item)
        {
            SortedBindingList <ClasePracticaInfo> list = null;
            ClasePracticaList sourceList = null;

            switch (FilterType)
            {
            case IFilterType.None:
                if (List == null)
                {
                    MessageBox.Show(Face.Resources.Messages.NO_RESULTS);
                    return(null);
                }
                sourceList = List;
                break;

            case IFilterType.Filter:
                if (FilteredList == null)
                {
                    MessageBox.Show(Face.Resources.Messages.NO_RESULTS);
                    return(null);
                }
                sourceList = FilteredList;
                break;

            default:
                sourceList = List;
                break;
            }

            if (item.FilterProperty == IFilterProperty.All)
            {
                FCriteria criteria = GetCriteria(string.Empty, item.Value, null, item.Operation);
                list = sourceList.GetSortedSubList(criteria, _properties_list);
            }
            else
            {
                FCriteria criteria = GetCriteria(item.Column, item.Value, null, item.Operation);
                list = sourceList.GetSortedSubList(criteria, _properties_list);
            }

            if (list.Count == 0)
            {
                MessageBox.Show(Face.Resources.Messages.NO_RESULTS);
                return(sourceList.GetSortedList());
            }

            DatosSearch.DataSource = list;
            DatosSearch.MoveFirst();

            AddFilterLabel(item);

            return(list);
        }
        protected override void RefreshMainData()
        {
            _practicas = ClasePracticaList.GetClasesPlanList(EntityInfo.OidPlan);
            PgMng.Grow();

            _teoricas = ClaseTeoricaList.GetClasesPlanList(EntityInfo.OidPlan);
            PgMng.Grow();

            _modulos = ModuloList.GetList(false);
            PgMng.FillUp();
        }
Пример #6
0
 public ClasesPracticasProgramadasForm(bool isModal, Form parent, ClasePracticaList list, PromocionInfo promocion)
     : base(isModal, parent, list)
 {
     InitializeComponent();
     _view_mode = molView.Select;
     _promocion = promocion;
     // Parche para poder abrir el formulario en modo diseño y no perder la configuracion de columnas
     DatosLocal_BS    = Datos;
     Tabla.DataSource = DatosLocal_BS;
     SetMainDataGridView(Tabla);
     Datos.DataSource = ClasePracticaList.NewList().GetSortedList();
 }
        protected override void RefreshMainData()
        {
            _practicas = ClasePracticaList.GetClasesPlanList(EntityInfo.Oid);
            PgMng.Grow();

            _teoricas = ClaseTeoricaList.GetClasesPlanList(EntityInfo.Oid);
            PgMng.Grow();

            _lista = new ListaClases();
            RellenaLista();
            PgMng.Grow();

            Datos_Clases.DataSource = _lista;
            PgMng.FillUp();
        }
Пример #8
0
        public void ResetSesiones(bool limpiar)
        {
            ClasePracticaList practicas = null;

            if (_practicas.Count > 1)
            {
                practicas = ClasePracticaList.Merge(_practicas[1], _practicas[2]);
            }
            _combo_clases           = Submodulo.GetComboClases(_teoricas, practicas, _extras);
            _combo_clases.Childs    = _combo_instructores;
            Datos_Clases.DataSource = _combo_clases;

            if (_teoricas != null && _practicas != null && _extras != null && _generado)
            {
                foreach (ClaseTeoricaInfo clase in _teoricas)
                {
                    clase.Estado = 1;
                }
                foreach (ClasePracticaList lista in _practicas)
                {
                    foreach (ClasePracticaInfo clase in lista)
                    {
                        clase.Estado = 1;
                    }
                }
                foreach (ClaseExtraInfo clase in _extras)
                {
                    clase.Estado = 1;
                }
            }

            if (_lista_sesiones != null && limpiar && _generado)
            {
                foreach (SesionAuxiliar sesion in _lista_sesiones)
                {
                    sesion.AsignaClaseASesion((ClaseTeoricaInfo)null);
                }
            }

            _no_asignables = new List <SesionNoAsignable>();

            if (_lista_sesiones != null)
            {
                RellenaCasillas();
            }
        }
        public ClasesPromocionMngForm(bool isModal, Form parent, ClaseTeoricaList teoricas, ClasePracticaList practicas, ClaseExtraList extras)
            : base(isModal, parent, ClaseGenericaList.GetList(teoricas, practicas, extras))
        {
            InitializeComponent();
            SetView(molView.Normal);
            _teoricas  = teoricas;
            _practicas = practicas;
            _extras    = extras;
            // Parche para poder abrir el formulario en modo diseño y no perder la configuracion de columnas
            DatosLocal_BS    = Datos;
            Tabla.DataSource = DatosLocal_BS;

            SetMainDataGridView(Tabla);
            Datos.DataSource = ClaseGenericaList.NewList().GetSortedList();
            SortProperty     = Submodulo.DataPropertyName;

            this.Text = Resources.Labels.CLASE_HORARIO_TITLE;
        }
Пример #10
0
        /// <summary>
        /// Toma la lista de bancos de la base de datos y rellena la tabla.
        /// </summary>
        protected override void RefreshMainData()
        {
            PgMng.Grow(string.Empty, "Alumno");

            _selectedOid = ActiveOID;

            switch (DataType)
            {
            case EntityMngFormTypeData.Default:
                List = ClasePracticaList.GetList();
                break;

            case EntityMngFormTypeData.ByParameter:
                _sorted_list = List.GetSortedList();
                break;
            }

            PgMng.Grow(string.Empty, "Lista de Alumnos");
        }
        private void Submodulos_Grid_UserDeletingRow(object sender, DataGridViewRowCancelEventArgs e)
        {
            Submodulo        item   = Submodulos_Grid.CurrentRow.DataBoundItem as Submodulo;
            ClaseTeoricaList listaT = ClaseTeoricaList.GetListBySubmodulo(item.Oid);

            if (listaT.Count > 0)
            {
                MessageBox.Show("No es posible borrar un submódulo que ha sido incluido en un plan de estudios");
                e.Cancel = true;
                return;
            }

            ClasePracticaList listaP = ClasePracticaList.GetListBySubmodulo(item.Oid);

            if (listaP.Count > 0)
            {
                MessageBox.Show("No es posible borrar un submódulo que ha sido incluido en un plan de estudios");
                e.Cancel = true;
            }
        }
        protected void DoRefresh()
        {
            try
            {
                PgMng.Reset(8, 1, Resources.Messages.LOADING_DATA, this);

                for (int i = 1; i < 3; i++)
                {
                    _practicas[i] = ClasePracticaList.GetDisponiblesList(Entity.OidPlan, Entity.OidPromocion, Entity.Oid, i);
                }
                PgMng.Grow();

                _teoricas = ClaseTeoricaList.GetDisponiblesList(Entity.OidPlan, Entity.OidPromocion, Entity.Oid);
                PgMng.Grow();

                _extras = ClaseExtraList.GetDisponiblesList(Entity.OidPromocion, Entity.Oid);
                PgMng.Grow();

                profesores_encargados.GetEncargados(Entity.OidPlan, Entity.OidPromocion);
                PgMng.Grow();

                _combo_clases           = Submodulo.GetComboClases(_teoricas, ClasePracticaList.Merge(_practicas[1], _practicas[2]), _extras);
                Datos_Clases.DataSource = _combo_clases;
                PgMng.Grow();

                _instructores_asignados = Sesion.CargaSesionesProfesores(Entity.FechaInicial, Entity.OidPromocion);
                PgMng.Grow();

                _profesores = InstructorList.GetInstructoresHorariosList(EntityInfo.OidPromocion, EntityInfo.FechaInicial, EntityInfo.FechaFinal);
                PgMng.Grow();
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                PgMng.FillUp();
            }
        }
        protected void RefreshHorario()
        {
            try
            {
                PgMng.Reset(7, 1, Resources.Messages.UPDATING_PROMOCION_HORARIO, this);

                for (int i = 1; i < 3; i++)
                {
                    _practicas[i] = ClasePracticaList.GetDisponiblesList(Entity.OidPlan, Entity.OidPromocion, Entity.Oid, i);
                }
                _teoricas = ClaseTeoricaList.GetDisponiblesList(Entity.OidPlan, Entity.OidPromocion, Entity.Oid);
                _extras   = ClaseExtraList.GetDisponiblesList(Entity.OidPromocion, Entity.Oid);
                PgMng.Grow(string.Empty, "clases");

                _instructores_asignados = Sesion.CargaSesionesProfesores(Entity.FechaInicial, Entity.OidPromocion);
                _profesores             = InstructorList.GetInstructoresHorariosList(EntityInfo.OidPromocion, EntityInfo.FechaInicial, EntityInfo.FechaFinal);

                _disponibilidades = _profesores.GetDisponibilidadesProfesores(_entity.FechaInicial);
                PgMng.Grow(string.Empty, "Instructores y profesores");

                //Se rellena el horario

                //_lista_sesiones = new ListaSesiones(Entity.FechaInicial);
                //ResetSesiones(false);
                PgMng.Grow(string.Empty, "lista sesiones");

                Horario.MuestraSesiones(Entity.Sesions, _lista_sesiones, _teoricas, ClasePracticaList.Merge(_practicas[1], _practicas[2]), _extras);

                _combo_clases           = Submodulo.GetComboClases(_teoricas, ClasePracticaList.Merge(_practicas[1], _practicas[2]), _extras);
                _combo_clases.Childs    = _combo_instructores;
                Datos_Clases.DataSource = _combo_clases;
                PgMng.Grow(string.Empty, "combo_clases");
            }
            finally
            {
                PgMng.FillUp();
            }
        }
Пример #14
0
        public ClaseHorarioSelectForm(ListaSesiones sesiones,
                                      ClaseTeoricaList teoricas,
                                      ClasePracticaList practicas,
                                      ClaseExtraList extras)
            : base(true)
        {
            InitializeComponent();

            List <ClaseTeoricaInfo>  t_ordenadas = teoricas.OrdenaLista();
            List <ClasePracticaInfo> p_ordenadas = practicas.OrdenaLista();

            List <ClaseTeoricaInfo>  lista_teoricas  = new List <ClaseTeoricaInfo>();
            List <ClasePracticaInfo> lista_practicas = new List <ClasePracticaInfo>();
            List <ClaseExtraInfo>    lista_extras    = new List <ClaseExtraInfo>();

            foreach (ClaseTeoricaInfo clase in t_ordenadas)
            {
                bool esta = false;
                foreach (SesionAuxiliar item in sesiones)
                {
                    if (item.OidClaseTeorica == clase.Oid)
                    {
                        if (item.Estado == 3)
                        {
                            esta = true;
                        }
                        break;
                    }
                }
                if (!esta)
                {
                    lista_teoricas.Add(clase);
                }
            }

            foreach (ClasePracticaInfo clase in p_ordenadas)
            {
                bool esta = false;
                foreach (SesionAuxiliar item in sesiones)
                {
                    if (item.OidClasePractica == clase.Oid && clase.Grupo == item.Grupo)
                    {
                        if (item.Estado == 3)
                        {
                            esta = true;
                        }
                        break;
                    }
                }
                if (!esta)
                {
                    lista_practicas.Add(clase);
                }
            }

            foreach (ClaseExtraInfo clase in extras)
            {
                bool esta = false;
                foreach (SesionAuxiliar item in sesiones)
                {
                    if (item.OidClaseExtra == clase.Oid)
                    {
                        if (item.Estado == 3)
                        {
                            esta = true;
                        }
                        break;
                    }
                }
                if (!esta)
                {
                    lista_extras.Add(clase);
                }
            }

            Datos_Teoricas.DataSource = lista_teoricas;

            Datos_Practicas.DataSource = lista_practicas;

            Datos_Extras.DataSource = lista_extras;

            this.Text = Resources.Labels.CLASE_HORARIO_TITLE;
        }
Пример #15
0
        public ClasesPromocionSelectForm(bool isModal, Form parent, ClaseTeoricaList teoricas, ClasePracticaList practicas, ClaseExtraList extras)
            : base(isModal, parent, teoricas, practicas, extras)
        {
            InitializeComponent();
            _view_mode = molView.Select;

            _action_result = DialogResult.Cancel;
        }
Пример #16
0
        protected void DoHorario()
        {
            try
            {
                PgMng.Reset(12, 1, Resources.Messages.UPDATING_PROMOCION_HORARIO, this);
                //Se rellena lo referente al plan
                if (_planes == null)
                {
                    return;
                }

                if (EntityInfo.Plan == null)
                {
                    Plan_CB.Text = _planes.GetItem(EntityInfo.OidPlan).Nombre;
                }
                else
                {
                    Plan_CB.Text = EntityInfo.Plan;
                }
                PgMng.Grow(string.Empty, "Plan");

                //Se rellena lo referente a la promoción
                if (_promociones == null)
                {
                    return;
                }

                if (EntityInfo.Promocion != string.Empty && EntityInfo.Promocion != null)
                {
                    Promocion_CB.Text = EntityInfo.Promocion;
                }
                else
                {
                    Promocion_CB.Text = _promociones.GetItem(EntityInfo.OidPromocion).Nombre;
                }
                PgMng.Grow(string.Empty, "Promocion");

                DateTime hoy = DateTime.Today;

                // si la fecha del horario que se va a cargar es anterior a la del día en el que se edita
                // no se tiene en cuenta si las clases sesiones planificadas se han impartido o no para meterlas
                // en las lista, ya que de ningún modo se va a permitir modificar un horario antiguo
                if (hoy.Date >= EntityInfo.FechaInicial)
                {
                    hoy = EntityInfo.FechaInicial;
                }
                else
                {
                    while (hoy.DayOfWeek != DayOfWeek.Monday)
                    {
                        hoy = hoy.AddDays(-1);
                    }
                }
                PgMng.Grow(string.Empty, "Hoy");

                for (int i = 1; i < 3; i++)
                {
                    if (_practicas.Count <= i)
                    {
                        _practicas.Add(ClasePracticaList.GetDisponiblesList(EntityInfo.OidPlan, EntityInfo.OidPromocion, EntityInfo.Oid, i));
                    }
                }
                if (_teoricas == null)
                {
                    _teoricas = ClaseTeoricaList.GetDisponiblesList(EntityInfo.OidPlan, EntityInfo.OidPromocion, EntityInfo.Oid);
                }
                if (_extras == null)
                {
                    _extras = ClaseExtraList.GetDisponiblesList(EntityInfo.OidPromocion, EntityInfo.Oid);
                }
                PgMng.Grow(string.Empty, "clases");

                _day = Fecha_DTP.Value;
                while (_day.DayOfWeek != System.DayOfWeek.Monday)
                {
                    _day = _day.AddDays(-1);
                }

                this.Text = Resources.Labels.HORARIO_ADD_TITLE +
                            "De Lunes, " + _day.ToShortDateString() +
                            " A Sábado, " + _day.AddDays(5).ToShortDateString();

                if (_day < Fecha_DTP.MinDate)
                {
                    Fecha_DTP.Value = Fecha_DTP.MinDate;
                }
                else
                {
                    Fecha_DTP.Value = _day;
                }
                PgMng.Grow(string.Empty, "Fecha_DTP");

                if (_instructores_asignados == null)
                {
                    _instructores_asignados = Sesion.CargaSesionesProfesores(EntityInfo.FechaInicial, EntityInfo.OidPromocion);
                }
                if (_profesores == null)
                {
                    _profesores = InstructorList.GetList(true);
                }

                _disponibilidades = _profesores.GetDisponibilidadesProfesores(_entity.FechaInicial);
                PgMng.Grow(string.Empty, "Instructores y profesores");

                CLB_1.SetItemChecked(0, EntityInfo.H8AM);
                CLB_1.SetItemChecked(1, EntityInfo.H0);
                CLB_1.SetItemChecked(2, EntityInfo.H1);
                CLB_1.SetItemChecked(3, EntityInfo.H2);
                CLB_1.SetItemChecked(4, EntityInfo.H3);
                CLB_1.SetItemChecked(5, EntityInfo.H4);
                CLB_1.SetItemChecked(6, EntityInfo.H5);
                CLB_1.SetItemChecked(7, EntityInfo.H6);
                CLB_1.SetItemChecked(8, EntityInfo.H7);
                CLB_1.SetItemChecked(9, EntityInfo.H8);
                CLB_1.SetItemChecked(10, EntityInfo.H9);
                CLB_1.SetItemChecked(11, EntityInfo.H10);
                CLB_1.SetItemChecked(12, EntityInfo.H11);
                CLB_1.SetItemChecked(13, EntityInfo.H12);

                CLB_2.SetItemChecked(0, EntityInfo.Hs0);
                CLB_2.SetItemChecked(1, EntityInfo.Hs1);
                CLB_2.SetItemChecked(2, EntityInfo.Hs2);
                CLB_2.SetItemChecked(3, EntityInfo.Hs3);
                CLB_2.SetItemChecked(4, EntityInfo.Hs4);
                PgMng.Grow(string.Empty, "Lista horas");

                //Se rellena la fecha
                Fecha_DTP.Value = EntityInfo.FechaInicial;
                this.Text       = Resources.Labels.HORARIO_ADD_TITLE +
                                  "De Lunes, " + EntityInfo.FechaInicial.ToShortDateString() +
                                  " A Sábado, " + EntityInfo.FechaInicial.AddDays(5).ToShortDateString();
                PgMng.Grow(string.Empty, "string fechas");

                //Se rellena el horario
                if (_lista_sesiones == null)
                {
                    _lista_sesiones = new ListaSesiones(EntityInfo.FechaInicial);
                    //ResetSesiones(false);
                    PgMng.Grow(string.Empty, "lista sesiones");

                    Horario.MuestraSesiones(EntityInfo.Sesions, _lista_sesiones, _teoricas, ClasePracticaList.Merge(_practicas[1], _practicas[2]), _extras);
                }

                Confirmar_BT.Enabled = true;
                Marcar_BT.Enabled    = true;
                Generar_BT.Enabled   = true;
                PgMng.Grow(string.Empty, "MuestraSesiones");

                if (_combo_clases == null)
                {
                    _combo_clases = Submodulo.GetComboClases(_teoricas, ClasePracticaList.Merge(_practicas[1], _practicas[2]), _extras);
                }
                _combo_clases.Childs    = _combo_instructores;
                Datos_Clases.DataSource = _combo_clases;
                PgMng.Grow(string.Empty, "combo_clases");

                Lunes_LB.Text = "LUNES (" + EntityInfo.FechaInicial.Day.ToString("00") + "/" +
                                EntityInfo.FechaInicial.Month.ToString("00") + ")";
                Martes_LB.Text = "MARTES (" + EntityInfo.FechaInicial.AddDays(1).Day.ToString("00") + "/" +
                                 EntityInfo.FechaInicial.AddDays(1).Month.ToString("00") + ")";
                Miercoles_LB.Text = "MIÉRCOLES (" + EntityInfo.FechaInicial.AddDays(2).Day.ToString("00") + "/" +
                                    EntityInfo.FechaInicial.AddDays(2).Month.ToString("00") + ")";
                Jueves_LB.Text = "JUEVES (" + EntityInfo.FechaInicial.AddDays(3).Day.ToString("00") + "/" +
                                 EntityInfo.FechaInicial.AddDays(3).Month.ToString("00") + ")";
                Viernes_LB.Text = "VIERNES (" + EntityInfo.FechaInicial.AddDays(4).Day.ToString("00") + "/" +
                                  EntityInfo.FechaInicial.AddDays(4).Month.ToString("00") + ")";
                Sabado_LB.Text = "SÁBADO (" + EntityInfo.FechaInicial.AddDays(5).Day.ToString("00") + "/" +
                                 EntityInfo.FechaInicial.AddDays(5).Month.ToString("00") + ")";
            }
            finally
            {
                PgMng.FillUp();
            }
        }
        protected override void DoPromociones()
        {
            try
            {
                PgMng.Reset(15, 1, Resources.Messages.UPDATING_PROMOCION_HORARIO, this);
                DateTime hoy = DateTime.Today;

                // si la fecha del horario que se va a cargar es anterior a la del día en el que se edita
                // no se tiene en cuenta si las clases sesiones planificadas se han impartido o no para meterlas
                // en las lista, ya que de ningún modo se va a permitir modificar un horario antiguo
                if (hoy.Date >= Entity.FechaInicial)
                {
                    hoy = Entity.FechaInicial;
                }
                else
                {
                    while (hoy.DayOfWeek != DayOfWeek.Monday)
                    {
                        hoy = hoy.AddDays(-1);
                    }
                }

                for (int i = 1; i < 3; i++)
                {
                    ClasePracticaList practicas = ClasePracticaList.GetDisponiblesList(Entity.OidPlan, Entity.OidPromocion, Entity.Oid, i);
                    if (_practicas.Count <= i)
                    {
                        _practicas.Add(practicas);
                    }
                    else
                    {
                        _practicas[i] = practicas;
                    }
                    PgMng.Grow(string.Empty, "Rellena clases prácticas grupo " + i.ToString());
                }
                _teoricas = ClaseTeoricaList.GetDisponiblesList(Entity.OidPlan, Entity.OidPromocion, Entity.Oid);
                PgMng.Grow(string.Empty, "Rellena clases teóricas");
                _extras = ClaseExtraList.GetDisponiblesList(Entity.OidPromocion, Entity.Oid);
                PgMng.Grow(string.Empty, "Rellena clases extra");

                //_combo_clases = Submodulo.GetComboClases(_teoricas, ClasePracticaList.Merge(_practicas[1],_practicas[2]), _extras);
                //pmg.Grow("combo clases");

                //pmg.Grow("Rellena fecha");

                while (_day.DayOfWeek != System.DayOfWeek.Monday)
                {
                    _day = _day.AddDays(-1);
                }
                Fecha_DTP.Value = _day;
                DoSetFecha();

                if (Promocion_CB.SelectedItem != null)
                {
                    //ResetSesiones(false);
                    PgMng.Grow(string.Empty, "reset sesiones");
                    _profesores = InstructorList.GetInstructoresHorariosList(((ComboBoxSource)Promocion_CB.SelectedItem).Oid, EntityInfo.FechaInicial, EntityInfo.FechaFinal);
                }

                if (_profesores != null)
                {
                    _disponibilidades = _profesores.GetDisponibilidadesProfesores(_day);
                }
                PgMng.Grow(string.Empty, "_profesores");


                if (Entity.OidPromocion != 0)
                {
                    PromocionInfo promocion = _promociones.GetItem(Entity.OidPromocion);
                    _entity.Promocion = promocion.Nombre;
                    PlanEstudiosInfo plan = _planes.GetItem(promocion.OidPlan);
                    _entity.Plan = plan.Nombre;

                    PgMng.Grow(string.Empty, "Promociones");
                    //_profesores = InstructorList.GetInstructoresHorariosList(Entity.OidPromocion);
                    PgMng.Grow(string.Empty, "GetInstructoresHorarioList");

                    CLB_1.SetItemChecked(0, promocion.H8AM);
                    CLB_1.SetItemChecked(1, promocion.H0);
                    CLB_1.SetItemChecked(2, promocion.H1);
                    CLB_1.SetItemChecked(3, promocion.H2);
                    CLB_1.SetItemChecked(4, promocion.H3);
                    CLB_1.SetItemChecked(5, promocion.H4);
                    CLB_1.SetItemChecked(6, promocion.H5);
                    CLB_1.SetItemChecked(7, promocion.H6);
                    CLB_1.SetItemChecked(8, promocion.H7);
                    CLB_1.SetItemChecked(9, promocion.H8);
                    CLB_1.SetItemChecked(10, promocion.H9);
                    CLB_1.SetItemChecked(11, promocion.H10);
                    CLB_1.SetItemChecked(12, promocion.H11);
                    CLB_1.SetItemChecked(13, promocion.H12);

                    CLB_2.SetItemChecked(0, promocion.HS0);
                    CLB_2.SetItemChecked(1, promocion.HS1);
                    CLB_2.SetItemChecked(2, promocion.HS2);
                    CLB_2.SetItemChecked(3, promocion.HS3);
                    CLB_2.SetItemChecked(4, promocion.HS4);

                    PgMng.Grow(string.Empty, "SetItemChecked");

                    Entity.CopiaConfiguracion(promocion);
                }
                PgMng.Grow(string.Empty, "Inicializa horas disponibles");

                if (!_generado)
                {
                    Generar_BT.Enabled = true;
                }
                Instructores_BT.Enabled     = true;
                Planes_BT.Enabled           = true;
                Disponibilidades_BT.Enabled = true;

                if (_lista_sesiones == null)
                {
                    _lista_sesiones = new ListaSesiones(Entity.FechaInicial);
                }
                RellenaCasillas();
            }
            finally
            {
                PgMng.FillUp();
            }
        }
        private void Clases_BT_Click(object sender, EventArgs e)
        {
            SelectEnumInputForm form = new SelectEnumInputForm(true);

            form.SetDataSource(Library.Instruction.EnumText <ETipoListadoClases> .GetList(false, false, true));

            if (form.ShowDialog(this) == DialogResult.OK)
            {
                ComboBoxSource     combo = form.Selected as ComboBoxSource;
                ETipoListadoClases tipo  = (ETipoListadoClases)combo.Oid;

                switch (tipo)
                {
                case ETipoListadoClases.Todas:
                {
                    ClasesOrdenadasViewForm cform = new ClasesOrdenadasViewForm(EntityInfo.OidPlan);
                    EntityMngForm           mng   = new EntityMngForm();
                    mng.AddForm(cform);
                }
                break;

                case ETipoListadoClases.Restantes:
                {
                    RestantesOrdenadasViewForm cform = new RestantesOrdenadasViewForm(EntityInfo.OidPlan, EntityInfo.Oid);
                    EntityMngForm mng = new EntityMngForm();
                    mng.AddForm(cform);
                }
                break;

                case ETipoListadoClases.TeoricasImpartidas:
                {
                    ClaseTeoricaList lista = null;
                    PgMng.Reset(2, 1, Resources.Messages.LOADING_DATA, this);
                    try
                    {
                        PgMng.Grow();
                        lista = ClaseTeoricaList.GetProgramadasList(EntityInfo.OidPlan,
                                                                    EntityInfo.Oid);
                    }
                    finally
                    {
                        PgMng.FillUp();
                    }

                    if (lista != null && lista.Count > 0)
                    {
                        ClasesTeoricasProgramadasForm cform = new ClasesTeoricasProgramadasForm(true, this, lista, EntityInfo);
                        cform.ShowDialog();
                    }
                }
                break;

                case ETipoListadoClases.TeoricasNoImpartidas:
                {
                    ClaseTeoricaList lista = null;
                    PgMng.Reset(2, 1, Resources.Messages.LOADING_DATA, this);
                    try
                    {
                        PgMng.Grow();
                        lista = ClaseTeoricaList.GetNoImpartidasList(EntityInfo.OidPlan, EntityInfo.OidPlanExtra,
                                                                     EntityInfo.Oid);
                    }
                    finally
                    {
                        PgMng.FillUp();
                    }

                    if (lista != null && lista.Count > 0)
                    {
                        ClasesTeoricasDisponiblesForm cform = new ClasesTeoricasDisponiblesForm(true, this, lista, EntityInfo);
                        cform.ShowDialog();
                    }
                }
                break;

                case ETipoListadoClases.PracticasImpartidas:
                {
                    ClasePracticaList lista = null;
                    PgMng.Reset(2, 1, Resources.Messages.LOADING_DATA, this);
                    try
                    {
                        PgMng.Grow();
                        lista = ClasePracticaList.GetProgramadasList(EntityInfo.OidPlan,
                                                                     EntityInfo.Oid);
                    }
                    finally
                    {
                        PgMng.FillUp();
                    }

                    if (lista != null && lista.Count > 0)
                    {
                        ClasesPracticasProgramadasForm cform = new ClasesPracticasProgramadasForm(true, this, lista, EntityInfo);
                        cform.ShowDialog();
                    }
                }
                break;

                case ETipoListadoClases.PracticasNoImpartidas:
                {
                    ClasePracticaList lista = null;
                    PgMng.Reset(2, 1, Resources.Messages.LOADING_DATA, this);
                    try
                    {
                        PgMng.Grow();
                        lista = ClasePracticaList.GetNoImpartidasList(EntityInfo.OidPlan,
                                                                      EntityInfo.Oid);
                    }
                    finally
                    {
                        PgMng.FillUp();
                    }

                    if (lista != null && lista.Count > 0)
                    {
                        ClasesPracticasDisponiblesForm cform = new ClasesPracticasDisponiblesForm(true, this, lista, EntityInfo);
                        cform.ShowDialog();
                    }
                }
                break;

                case ETipoListadoClases.TodasCronograma:
                {
                    GeneraCronogramaAction(false);
                }
                break;

                case ETipoListadoClases.RestantesCronograma:
                {
                    GeneraCronogramaAction(false, true);
                }
                break;

                case ETipoListadoClases.ComparativaCronograma:
                {
                    GeneraCronogramaAction(true);
                }
                break;
                }
            }
        }
        /// <summary>Imprime la lista del objetos
        /// <returns>void</returns>
        /// </summary>
        public override void PrintList()
        {
            ETipoImpresionCronograma tipo = ETipoImpresionCronograma.Lista;
            SelectEnumInputForm      form = new SelectEnumInputForm(true);

            form.SetDataSource(Library.Instruction.EnumText <ETipoImpresionCronograma> .GetList(false, false, false));
            form.ShowDialog(this);

            if (form.ActionResult == DialogResult.OK)
            {
                ComboBoxSource combo = form.Selected as ComboBoxSource;
                tipo = (ETipoImpresionCronograma)combo.Oid;
            }

            ClaseTeoricaList         teoricas        = ClaseTeoricaList.GetList();
            ClasePracticaList        practicas       = ClasePracticaList.GetList(false);
            List <ClasePracticaList> lista_practicas = new List <ClasePracticaList>();

            lista_practicas.Add(null);
            lista_practicas.Add(practicas);
            lista_practicas.Add(practicas);
            ModuloList modulos = ModuloList.GetList(false);

            CronogramaReportMng reportMng = new CronogramaReportMng(AppContext.ActiveSchema);
            CronogramaRpt       report    = null;

            switch (FilterType)
            {
            case IFilterType.None:
                if (tipo == ETipoImpresionCronograma.Lista)
                {
                    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 sform = new Common.CompanySelectForm(this);
                        DialogResult result = sform.ShowDialog();

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

                    report = reportMng.GetCronogramaReport(_cronograma, empresa, modulos, teoricas, practicas, _sorted_list);

                    if (report != null)
                    {
                        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();
                    }
                    else
                    {
                        MessageBox.Show(Resources.Messages.NO_DATA_REPORTS,
                                        moleQule.Face.Resources.Labels.ADVISE_TITLE,
                                        MessageBoxButtons.OK,
                                        MessageBoxIcon.Exclamation);
                    }
                }
                else
                {
                    Dictionary <Horario, ListaSesiones> horarios = Cronograma.GetHorarios(_sorted_list, teoricas, practicas);

                    if (horarios.Count > 0)
                    {
                        PgMng.Reset(horarios.Count + 5, 1, Resources.Messages.LOADING_DATA, this);

                        try
                        {
                            InstructorList instructores = InstructorList.GetList(false);
                            PgMng.Grow();

                            //EntidadInfo entidad = EntidadInfo.Get(typeof(Promocion), true);
                            //Agente agente = null;

                            //PromocionInfo promocion = PromocionInfo.Get(_cronograma.OidPromocion, true);

                            //if (entidad.Agentes.GetItemByProperty("OidAgenteExt", promocion.Oid) != null)
                            //    agente = Agente.Get(typeof(Promocion), promocion);
                            //else
                            //{
                            //    agente = Agente.New();
                            //    agente.CopyFrom(entidad, promocion);
                            //    agente.Codigo = agente.GetCode();
                            //}

                            PgMng.Grow();

                            string       sFile = "C:\\cronograma.pdf";
                            FileStream   fs    = new FileStream(sFile, FileMode.Create, FileAccess.Write, FileShare.None);
                            Document     doc   = new Document();
                            PdfSmartCopy copy  = new PdfSmartCopy(doc, fs);

                            doc.Open();

                            foreach (KeyValuePair <Horario, ListaSesiones> item in horarios)
                            {
                                item.Key.OidPlan      = _cronograma.OidPlan;
                                item.Key.OidPromocion = _cronograma.OidPromocion;
                                HorarioRpt rpt    = reportMng.GetHorarioReport(item.Key.GetInfo(false), true, teoricas, lista_practicas, null, instructores, modulos, item.Value, false, DateTime.Now);
                                PdfReader  reader = new PdfReader(rpt.ExportToStream(ExportFormatType.PortableDocFormat));
                                copy.AddPage(copy.GetImportedPage(reader, 1));
                                rpt.Close();
                                rpt.Dispose();
                                PgMng.Grow();
                            }

                            doc.Close();

                            System.Diagnostics.Process process = new System.Diagnostics.Process();
                            process.StartInfo.FileName = sFile;
                            process.Start();
                            try
                            {
                                process.WaitForExit();
                            }
                            catch { }
                            PgMng.Grow();

                            //Documento documento = Documento.New();
                            //documento.Fecha = DateTime.Now;
                            //documento.FechaAlta = DateTime.Now;
                            //documento.Nombre = documento.Fecha.ToString("yyyyMMdd") + "_CRONOGRAMA";
                            //documento.Ruta = "C:\\";
                            //documento.Tipo = "PDF";


                            //AgenteDocumento agente_documento = agente.Documentos.NewItem(agente);
                            //agente_documento.OidDocumento = documento.Oid;

                            //agente.Save();
                        }
                        catch (Exception ex) { throw ex; }
                        finally { PgMng.FillUp(); }
                    }
                }
                break;

            case IFilterType.Filter:
                if (tipo == ETipoImpresionCronograma.Lista)
                {
                    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 sform = new Common.CompanySelectForm(this);
                        DialogResult result = sform.ShowDialog();

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

                    report = reportMng.GetCronogramaReport(_cronograma, empresa, modulos, teoricas, practicas, _filter_results);

                    if (report != null)
                    {
                        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();
                    }
                    else
                    {
                        MessageBox.Show(Resources.Messages.NO_DATA_REPORTS,
                                        moleQule.Face.Resources.Labels.ADVISE_TITLE,
                                        MessageBoxButtons.OK,
                                        MessageBoxIcon.Exclamation);
                    }
                }
                else
                {
                    Dictionary <Horario, ListaSesiones> horarios = Cronograma.GetHorarios(_filter_results, teoricas, practicas);

                    if (horarios.Count > 0)
                    {
                        PgMng.Reset(horarios.Count + 5, 1, Resources.Messages.LOADING_DATA, this);

                        try
                        {
                            InstructorList instructores = InstructorList.GetList(false);
                            PgMng.Grow();

                            //EntidadInfo entidad = EntidadInfo.Get(typeof(Promocion), true);
                            //Agente agente = null;

                            //PromocionInfo promocion = PromocionInfo.Get(_cronograma.OidPromocion, true);

                            //if (entidad.Agentes.GetItemByProperty("OidAgenteExt", promocion.Oid) != null)
                            //    agente = Agente.Get(typeof(Promocion), promocion);
                            //else
                            //{
                            //    agente = Agente.New();
                            //    agente.CopyFrom(entidad, promocion);
                            //    agente.Codigo = agente.GetCode();
                            //}

                            PgMng.Grow();

                            string       sFile = "C:\\cronograma.pdf";
                            FileStream   fs    = new FileStream(sFile, FileMode.Create, FileAccess.Write, FileShare.None);
                            Document     doc   = new Document();
                            PdfSmartCopy copy  = new PdfSmartCopy(doc, fs);

                            doc.Open();

                            foreach (KeyValuePair <Horario, ListaSesiones> item in horarios)
                            {
                                item.Key.OidPlan      = _cronograma.OidPlan;
                                item.Key.OidPromocion = _cronograma.OidPromocion;
                                HorarioRpt rpt    = reportMng.GetHorarioReport(item.Key.GetInfo(false), true, teoricas, lista_practicas, null, instructores, modulos, item.Value, false, DateTime.Now);
                                PdfReader  reader = new PdfReader(rpt.ExportToStream(ExportFormatType.PortableDocFormat));
                                copy.AddPage(copy.GetImportedPage(reader, 1));
                                rpt.Close();
                                rpt.Dispose();
                                PgMng.Grow();
                            }

                            doc.Close();

                            System.Diagnostics.Process process = new System.Diagnostics.Process();
                            process.StartInfo.FileName = sFile;
                            process.Start();
                            try
                            {
                                process.WaitForExit();
                            }
                            catch { }
                            PgMng.Grow();

                            //Documento documento = Documento.New();
                            //documento.Fecha = DateTime.Now;
                            //documento.FechaAlta = DateTime.Now;
                            //documento.Nombre = documento.Fecha.ToString("yyyyMMdd") + "_CRONOGRAMA";
                            //documento.Ruta = "C:\\";
                            //documento.Tipo = "PDF";


                            //AgenteDocumento agente_documento = agente.Documentos.NewItem(agente);
                            //agente_documento.OidDocumento = documento.Oid;

                            //agente.Save();
                        }
                        catch (Exception ex) { throw ex; }
                        finally { PgMng.FillUp(); }
                    }
                }
                break;
            }
        }
        public void ResetSesiones(bool limpiar)
        {
            ClasePracticaList practicas = null;

            if (_practicas.Count > 1)
            {
                practicas = ClasePracticaList.Merge(_practicas[1], _practicas[2]);
            }
            _combo_clases           = Submodulo.GetComboClases(_teoricas, practicas, _extras);
            _combo_clases.Childs    = _combo_instructores;
            Datos_Clases.DataSource = _combo_clases;


            if (_lista_sesiones != null && limpiar /*&& _generado*/)
            {
                foreach (SesionAuxiliar sesion in _lista_sesiones)
                {
                    if (sesion.EEstadoClase != EEstadoClase.Impartida)
                    {
                        if (sesion.OidClaseTeorica > 0)
                        {
                            _teoricas.GetItem(sesion.OidClaseTeorica).Estado = 1;
                        }
                        if (sesion.OidClaseExtra > 0)
                        {
                            _extras.GetItem(sesion.OidClaseExtra).Estado = 1;
                        }
                        if (sesion.OidClasePractica > 0)
                        {
                            _practicas[(int)sesion.Grupo].GetItem(sesion.OidClasePractica).Estado = 1;
                        }

                        sesion.AsignaClaseASesion((ClaseTeoricaInfo)null);
                    }
                }
            }
            else
            {
                if (_teoricas != null && _practicas != null && _extras != null /*&& _generado*/)
                {
                    foreach (ClaseTeoricaInfo clase in _teoricas)
                    {
                        if (clase.EEstadoClase != EEstadoClase.Impartida)
                        {
                            clase.Estado = 1;
                        }
                    }
                    foreach (ClasePracticaList lista in _practicas)
                    {
                        foreach (ClasePracticaInfo clase in lista)
                        {
                            if (clase.EEstadoClase != EEstadoClase.Impartida)
                            {
                                clase.Estado = 1;
                            }
                        }
                    }
                    foreach (ClaseExtraInfo clase in _extras)
                    {
                        if (clase.Estado != (long)EEstadoClase.Impartida)
                        {
                            clase.Estado = 1;
                        }
                    }
                }
            }

            _no_asignables = new List <SesionNoAsignable>();

            if (_lista_sesiones != null)
            {
                RellenaCasillas();
            }
        }
        protected void DoNuevoHorario()
        {
            try
            {
                PgMng.Reset(10, 1, Resources.Messages.CREANDO_HORARIO, this);

                if (this is HorarioAddForm && Horario.ExisteHorario(Entity.OidPlan, Entity.OidPromocion, Entity.FechaInicial))
                {
                    MessageBox.Show("Ya existe un horario para la promoción y fecha indicadas, si lo desea modifique el que ya existe.");
                    PgMng.FillUp();
                    return;
                }

                profesores_encargados.GetEncargados(Entity.OidPlan, Entity.OidPromocion);
                PgMng.Grow();

                _combo_clases           = Submodulo.GetComboClases(_teoricas, ClasePracticaList.Merge(_practicas[1], _practicas[2]), _extras);
                Datos_Clases.DataSource = _combo_clases;
                PgMng.Grow();

                _instructores_asignados = Sesion.CargaSesionesProfesores(Entity.FechaInicial, Entity.OidPromocion);
                PgMng.Grow();

                if (_profesores == null)
                {
                    _profesores = InstructorList.GetInstructoresHorariosList(EntityInfo.OidPromocion, EntityInfo.FechaInicial, EntityInfo.FechaFinal);
                }
                PgMng.Grow();

                CleanAction();
                PgMng.Grow(string.Empty, "CleanAction");

                if (_generado)
                {
                    ResetNoConfirmadas();
                }
                PgMng.Grow(string.Empty, "ResetNoConfirmadas");

                if (_lista_sesiones == null)
                {
                    _lista_sesiones = new ListaSesiones(Entity.FechaInicial);
                }

                if (!Entity.FechaInicial.Date.Equals(_lista_sesiones[0].Fecha.Date))
                {
                    DateTime fecha = Entity.FechaInicial;
                    for (int i = 0; i < 70; i += 14)
                    {
                        _lista_sesiones[i].Fecha      = fecha;
                        _lista_sesiones[i + 1].Fecha  = fecha;
                        _lista_sesiones[i + 2].Fecha  = fecha;
                        _lista_sesiones[i + 3].Fecha  = fecha;
                        _lista_sesiones[i + 4].Fecha  = fecha;
                        _lista_sesiones[i + 5].Fecha  = fecha;
                        _lista_sesiones[i + 6].Fecha  = fecha;
                        _lista_sesiones[i + 7].Fecha  = fecha;
                        _lista_sesiones[i + 8].Fecha  = fecha;
                        _lista_sesiones[i + 9].Fecha  = fecha;
                        _lista_sesiones[i + 10].Fecha = fecha;
                        _lista_sesiones[i + 11].Fecha = fecha;
                        _lista_sesiones[i + 12].Fecha = fecha;
                        _lista_sesiones[i + 13].Fecha = fecha;
                        fecha = fecha.AddDays(1);
                    }
                    for (int i = 70; i < 75; i++)
                    {
                        _lista_sesiones[i].Fecha = fecha;
                    }
                }

                _lista_sesiones = Entity.SetSesionesActivas(_lista_sesiones);
                PgMng.Grow(string.Empty, "Entity.SetSesionesActivas");

                decimal n_practicas = 11;
                if (Practicas_CB.Checked)
                {
                    n_practicas = NPracticas.Value;
                }

                HorarioController controlador = new HorarioController(_entity, _lista_sesiones,
                                                                      _teoricas, _practicas, _extras, _profesores,
                                                                      profesores_encargados, _instructores_asignados,
                                                                      _disponibilidades, n_practicas, DiasSuplente.Value);

                controlador.Rules[(int)TRule.MismoInstructorMismaSesion] = !MismoInstructorMismaSesion_CB.Checked;
                controlador.Rules[(int)TRule.MismoInstructorMismoDia]    = !MismoInstructorMismoDia_CB.Checked;

                controlador.GeneraHorario(_no_asignables);
                PgMng.Grow(string.Empty, "Generación de horario");

                RellenaCasillas();
                PgMng.Grow(string.Empty, "Rellenar Casillas");

                Completar_BT.Enabled = false;
                Marcar_BT.Enabled    = true;
                Clean_BT.Enabled     = true;
                if (this is HorarioEditForm)
                {
                    Confirmar_BT.Enabled = true;
                }
                _generado = true;
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                PgMng.FillUp();
            }
        }