protected void ddlCurso_SelectedIndexChanged(object sender, EventArgs e)
        {
            ListItem _curso = ddlCurso.SelectedItem;

            if (_curso.Value != "0")
            {
                IMetodosEstudiante _metEstudiante = new MetodosEstudiante();
                LinkedList<Grupo> _lisGrupos = _metEstudiante.ObtenerGruposParaInclusion(int.Parse(_curso.Value));

                ddlGrupo.Items.Clear();
                ddlGrupo.DataSource = _lisGrupos;
                ddlGrupo.DataValueField = "Id_Grupo";
                ddlGrupo.DataTextField = "Num_Grupo";
                ddlGrupo.DataBind();
            }
            else
            {
                ddlGrupo.Items.Clear();
            }
        }
 /**
  * Devuelve los grupos de un curso especifico.
  **/
 public LinkedList<Grupo> ObtenerGruposCurso(int pCurso)
 {
     IMetodosEstudiante _metEstudiante = new MetodosEstudiante();
     return _metEstudiante.ObtenerGruposParaInclusion(pCurso);
 }
        protected void Page_Load(object sender, EventArgs e)
        {
            if(!Page.IsPostBack)
            {
                IMetodosEstudiante _metEstudiante = new MetodosEstudiante();
                IMetodosAdministrador _metAdministrador = new MetodosAdministrador();
                Ado.ClasesComunes.Periodo _periodoActual = _metAdministrador.UltimoPeriodo();
                string _carnet = (string)Session["NUsuario"];

                if(_periodoActual != null)
                {

                    #region Pendientes

                    LinkedList<Solicitud> _lisPendientes = _metEstudiante.ObtenerSolicitudesPendientes(_carnet, _periodoActual.Id_Periodo);
                    if (_lisPendientes.Count != 0)
                    {
                        #region Encabezado

                        TableHeaderRow Row_Encabezado = new TableHeaderRow();
                        TableHeaderCell Cel_EncabezadoID = new TableHeaderCell();
                        Cel_EncabezadoID.Text = "Solicitud";
                        Row_Encabezado.Cells.Add(Cel_EncabezadoID);
                        TableHeaderCell Cel_EncabezadoNomCurso = new TableHeaderCell();
                        Cel_EncabezadoNomCurso.Text = "Nombre de Curso";
                        Row_Encabezado.Cells.Add(Cel_EncabezadoNomCurso);
                        TableHeaderCell Cel_EncabezadoFecha = new TableHeaderCell();
                        Cel_EncabezadoFecha.Text = "Recepción";
                        Row_Encabezado.Cells.Add(Cel_EncabezadoFecha);
                        TableHeaderCell Cel_EncabezadoAcciones = new TableHeaderCell();
                        Cel_EncabezadoAcciones.Text = "Acciones";
                        Row_Encabezado.Cells.Add(Cel_EncabezadoAcciones);
                        tblPendientes.Rows.Add(Row_Encabezado);

                        #endregion

                        #region Llenado de tabla

                        foreach (var _solicitud in _lisPendientes)
                        {
                            TableRow Row_Pendientes = new TableRow();

                            TableCell Cel_ID = new TableCell();
                            Cel_ID.Text = _solicitud.Id_Solicitud.ToString();
                            Row_Pendientes.Cells.Add(Cel_ID);

                            TableCell Cel_Curso = new TableCell();
                            Cel_Curso.Text = _solicitud.txt_Curso;
                            Row_Pendientes.Cells.Add(Cel_Curso);

                            TableCell Cel_Fecha = new TableCell();
                            Cel_Fecha.Text = _solicitud.Fec_Creacion.Date.ToString();
                            Row_Pendientes.Cells.Add(Cel_Fecha);

                            TableCell Cel_Acciones = new TableCell();
                            //Agregar las acciones por fila de regla
                            ImageButton btnAnular = new ImageButton(); //-- Incrementar prioridad
                            btnAnular.ImageUrl = "../Images/table_cancel_row.png";
                            btnAnular.Enabled = false;
                            btnAnular.AlternateText = "Anular";
                            btnAnular.ToolTip = "Anular";
                            btnAnular.Click += new ImageClickEventHandler(btnAnular_Click);
                            Cel_Acciones.Controls.Add(btnAnular);

                            Row_Pendientes.Cells.Add(Cel_Acciones);

                            tblPendientes.Rows.Add(Row_Pendientes);
                        }

                        #endregion
                    }
                    else
                    {
                        TableRow Row_SinPendientes = new TableRow();
                        TableCell Cel_SinPendientes = new TableCell();
                        Cel_SinPendientes.Text = "No se encuentran solicitudes pendientes para este periodo";
                        Row_SinPendientes.Cells.Add(Cel_SinPendientes);
                        tblPendientes.Rows.Add(Row_SinPendientes);
                    }

                    #endregion

                    #region Anuladas

                    LinkedList<Solicitud> _lisAnuladas = _metEstudiante.ObtenerSolicitudesAnuladas(_carnet, _periodoActual.Id_Periodo);
                    if (_lisAnuladas.Count != 0)
                    {
                        #region Encabezado

                        TableHeaderRow Row_Encabezado = new TableHeaderRow();
                        TableHeaderCell Cel_EncabezadoID = new TableHeaderCell();
                        Cel_EncabezadoID.Text = "Solicitud";
                        Row_Encabezado.Cells.Add(Cel_EncabezadoID);
                        TableHeaderCell Cel_EncabezadoNomCurso = new TableHeaderCell();
                        Cel_EncabezadoNomCurso.Text = "Nombre de Curso";
                        Row_Encabezado.Cells.Add(Cel_EncabezadoNomCurso);
                        TableHeaderCell Cel_EncabezadoFecha = new TableHeaderCell();
                        Cel_EncabezadoFecha.Text = "Recepción";
                        Row_Encabezado.Cells.Add(Cel_EncabezadoFecha);
                        tblAnuladas.Rows.Add(Row_Encabezado);

                        #endregion

                        #region Llenado de tabla

                        foreach (var _solicitud in _lisAnuladas)
                        {
                            TableRow Row_Anuladas = new TableRow();

                            TableCell Cel_ID = new TableCell();
                            Cel_ID.Text = _solicitud.Id_Solicitud.ToString();
                            Row_Anuladas.Cells.Add(Cel_ID);

                            TableCell Cel_Curso = new TableCell();
                            Cel_Curso.Text = _solicitud.txt_Curso;
                            Row_Anuladas.Cells.Add(Cel_Curso);

                            TableCell Cel_Fecha = new TableCell();
                            Cel_Fecha.Text = _solicitud.Fec_Creacion.Date.ToString();
                            Row_Anuladas.Cells.Add(Cel_Fecha);

                            tblAnuladas.Rows.Add(Row_Anuladas);
                        }

                        #endregion
                    }
                    else
                    {
                        TableRow Row_SinAnuladas = new TableRow();
                        TableCell Cel_SinAnuladas = new TableCell();
                        Cel_SinAnuladas.Text = "No se encuentran solicitudes anuladas para este periodo";
                        Row_SinAnuladas.Cells.Add(Cel_SinAnuladas);
                        tblAnuladas.Rows.Add(Row_SinAnuladas);
                    }

                    #endregion

                    #region Aprobadas

                    LinkedList<Solicitud> _lisAprobadas = _metEstudiante.ObtenerSolicitudesAprobadas(_carnet, _periodoActual.Id_Periodo);
                    if (_lisAprobadas.Count != 0)
                    {
                        #region Encabezado

                        TableHeaderRow Row_Encabezado = new TableHeaderRow();
                        TableHeaderCell Cel_EncabezadoID = new TableHeaderCell();
                        Cel_EncabezadoID.Text = "Solicitud";
                        Row_Encabezado.Cells.Add(Cel_EncabezadoID);
                        TableHeaderCell Cel_EncabezadoNomCurso = new TableHeaderCell();
                        Cel_EncabezadoNomCurso.Text = "Nombre de Curso";
                        Row_Encabezado.Cells.Add(Cel_EncabezadoNomCurso);
                        TableHeaderCell Cel_EncabezadoGrupo = new TableHeaderCell();
                        Cel_EncabezadoGrupo.Text = "Grupo Aceptado";
                        Row_Encabezado.Cells.Add(Cel_EncabezadoGrupo);
                        tblAprobadas.Rows.Add(Row_Encabezado);

                        #endregion

                        #region Llenado de tabla

                        foreach (var _solicitud in _lisAprobadas)
                        {
                            TableRow Row_Aprobadas = new TableRow();

                            TableCell Cel_ID = new TableCell();
                            Cel_ID.Text = _solicitud.Id_Solicitud.ToString();
                            Row_Aprobadas.Cells.Add(Cel_ID);

                            TableCell Cel_Curso = new TableCell();
                            Cel_Curso.Text = _solicitud.txt_Curso;
                            Row_Aprobadas.Cells.Add(Cel_Curso);

                            TableCell Cel_Grupo = new TableCell();
                            LinkedList<Curso> _cursos = _metEstudiante.ObtenerCursosEstudiante(_carnet, null);
                            LinkedList<Grupo> _grupos = new LinkedList<Grupo>();
                            int _idCurso;
                            foreach (var _curso in _cursos)
                            {
                                if (_curso.Txt_Curso.Equals(_solicitud.txt_Curso))
                                {
                                    _idCurso = _curso.Id_Curso;
                                    _grupos = _metEstudiante.ObtenerGruposParaInclusion(_idCurso);
                                }
                            }
                            //LinkedList<Grupo> _grupos = _metEstudiante.ObtenerGruposParaInclusion(_idCurso);
                            foreach (var _grupo in _grupos)
                            {
                                if (_grupo.Id_Grupo.Equals(_solicitud.Id_GrupoAceptado))
                                {
                                    Cel_Grupo.Text = _grupo.Num_Grupo.ToString();
                                }
                            }
                            Row_Aprobadas.Cells.Add(Cel_Grupo);

                            tblAprobadas.Rows.Add(Row_Aprobadas);
                        }

                        #endregion
                    }
                    else
                    {
                        TableRow Row_SinAprobadas = new TableRow();
                        TableCell Cel_SinAprobadas = new TableCell();
                        Cel_SinAprobadas.Text = "No se encuentran solicitudes aprobadas para este periodo";
                        Row_SinAprobadas.Cells.Add(Cel_SinAprobadas);
                        tblAprobadas.Rows.Add(Row_SinAprobadas);
                    }

                    #endregion

                    #region Reprobadas

                    LinkedList<Solicitud> _lisReprobadas = _metEstudiante.ObtenerSolicitudesReprobadas(_carnet, _periodoActual.Id_Periodo);
                    if (_lisReprobadas.Count != 0)
                    {
                        #region Encabezado

                        TableHeaderRow Row_Encabezado = new TableHeaderRow();
                        TableHeaderCell Cel_EncabezadoID = new TableHeaderCell();
                        Cel_EncabezadoID.Text = "Solicitud";
                        Row_Encabezado.Cells.Add(Cel_EncabezadoID);
                        TableHeaderCell Cel_EncabezadoNomCurso = new TableHeaderCell();
                        Cel_EncabezadoNomCurso.Text = "Nombre de Curso";
                        Row_Encabezado.Cells.Add(Cel_EncabezadoNomCurso);
                        TableHeaderCell Cel_EncabezadoMotivo = new TableHeaderCell();
                        Cel_EncabezadoMotivo.Text = "Motivo";
                        Row_Encabezado.Cells.Add(Cel_EncabezadoMotivo);
                        tblReprobadas.Rows.Add(Row_Encabezado);

                        #endregion

                        #region Llenado de tabla

                        foreach (var _solicitud in _lisReprobadas)
                        {
                            TableRow Row_Reprobadas = new TableRow();

                            TableCell Cel_ID = new TableCell();
                            Cel_ID.Text = _solicitud.Id_Solicitud.ToString();
                            Row_Reprobadas.Cells.Add(Cel_ID);

                            TableCell Cel_Curso = new TableCell();
                            Cel_Curso.Text = _solicitud.txt_Curso;
                            Row_Reprobadas.Cells.Add(Cel_Curso);

                            TableCell Cel_Motivo = new TableCell();
                            Cel_Motivo.Text = _solicitud.Txt_Motivo;
                            Row_Reprobadas.Cells.Add(Cel_Motivo);

                            tblReprobadas.Rows.Add(Row_Reprobadas);
                        }

                        #endregion
                    }
                    else
                    {
                        TableRow Row_SinReprobadas = new TableRow();
                        TableCell Cel_SinReprobadas = new TableCell();
                        Cel_SinReprobadas.Text = "No se encuentran solicitudes reprobadas para este periodo";
                        Row_SinReprobadas.Cells.Add(Cel_SinReprobadas);
                        tblReprobadas.Rows.Add(Row_SinReprobadas);
                    }

                    #endregion
                }
                else
                {
                    lblPopupHeader.Text = "Alerta del sistema";
                    lblPopupBody.Text = "No existe un periodo de recepcion de solicitudes definido aún.";
                    Pop_Alerta.Show();
                }

            }
        }
        /// <summary>
        /// Define las acciones a ejecutar cuando se cambia el index del
        /// DropDownList Cursos.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void ddlCursos_SelectedIndexChanged(object sender, EventArgs e)
        {
            int _curso = int.Parse(ddlCursos.SelectedValue);

            if (ddlCursos.SelectedValue != "0")
            {
                IMetodosEstudiante _metEstudiante = new MetodosEstudiante();
                LinkedList<Grupo> _lisGrupos = _metEstudiante.ObtenerGruposParaInclusion(_curso);
                string _carnet = (string)Session["NUsuario"];

                #region Obtener codigo de curso
                string _codCursoSeleccionado;
                LinkedList<Curso> _cursos = new LinkedList<Curso>();
                _cursos = _metEstudiante.ObtenerCursosEstudiante(_carnet, null);

                foreach (var _cursoActual in _cursos)
                {
                    if(_cursoActual.Id_Curso.Equals(int.Parse(ddlCursos.SelectedValue))){
                        lblCodigoCursoSeleccionado.Text = _cursoActual.Cod_Curso;
                    }
                }

                #endregion

                #region Encabezado
                tblGrupos.Rows.Clear();//-- Encabezado de la tabla
                TableHeaderRow Row_Encabezado = new TableHeaderRow();
                TableHeaderCell Cel_EncabezadoEstudiante = new TableHeaderCell();
                Cel_EncabezadoEstudiante.Text = "Número";
                Row_Encabezado.Cells.Add(Cel_EncabezadoEstudiante);
                TableHeaderCell Cel_EncabezadoCurso = new TableHeaderCell();
                Cel_EncabezadoCurso.Text = "Profesor";
                Row_Encabezado.Cells.Add(Cel_EncabezadoCurso);
                TableHeaderCell Cel_EncabezadoGrupo = new TableHeaderCell();
                Cel_EncabezadoGrupo.Text = "Horario";
                Row_Encabezado.Cells.Add(Cel_EncabezadoGrupo);
                TableHeaderCell Cel_EncabezadoAcciones = new TableHeaderCell();
                Cel_EncabezadoAcciones.Text = "Acciones";
                Row_Encabezado.Cells.Add(Cel_EncabezadoAcciones);
                tblGrupos.Rows.Add(Row_Encabezado);
                #endregion

                #region Llenado
                foreach (var _grupo in _lisGrupos)
                {
                    TableRow Row_Grupo = new TableRow();

                    TableCell Cel_Grupo = new TableCell();
                    Cel_Grupo.Text = _grupo.Num_Grupo.ToString();
                    Row_Grupo.Cells.Add(Cel_Grupo);

                    TableCell Cel_Profesor = new TableCell();
                    Cel_Profesor.Text = _metEstudiante.ObtenerProfesor(_grupo.Id_Grupo);
                    Row_Grupo.Cells.Add(Cel_Profesor);

                    TableCell Cel_Horario = new TableCell();
                    Cel_Horario.Text = CrearHorario(_grupo.Li_Horarios);
                    Row_Grupo.Cells.Add(Cel_Horario);

                    TableCell Cel_Acciones = new TableCell();
                    //Agregar las acciones por fila de regla
                    ImageButton btnSubir = new ImageButton(); //-- Incrementar prioridad
                    btnSubir.ImageUrl = "../Images/table_move_row_up.png";
                    btnSubir.AlternateText = "Subir";
                    btnSubir.ToolTip = "Subir";
                    btnSubir.Enabled = false;
                    //btnSubir.Click += new ImageClickEventHandler(btnSubir_Click);
                    Cel_Acciones.Controls.Add(btnSubir);

                    ImageButton btnBajar = new ImageButton(); //-- Decrementar prioridad
                    btnBajar.ImageUrl = "../Images/table_move_row_down.png";
                    btnBajar.AlternateText = "Bajar";
                    btnBajar.ToolTip = "Bajar";
                    btnBajar.Enabled = false;
                    //btnBajar.Click += new ImageClickEventHandler(btnBajar_Click);
                    Cel_Acciones.Controls.Add(btnBajar);
                    Row_Grupo.Cells.Add(Cel_Acciones);

                    tblGrupos.Rows.Add(Row_Grupo);
                }
                tblGrupos.DataBind();
                #endregion
            }
            else
            {
                lblCodigoCursoSeleccionado.Text = "Sin código disponible";
                lblCodigoCursoSeleccionado.DataBind();
                //ddlGrupo.Items.Clear();
                TableRow Row_SinGrupos = new TableRow();
                TableCell Cel_SinGrupos = new TableCell();
                Cel_SinGrupos.Text = "No se encuentran grupos disponibles";
                Row_SinGrupos.Cells.Add(Cel_SinGrupos);
                tblGrupos.Rows.Add(Row_SinGrupos);
                tblGrupos.DataBind();
            }
        }
        /// <summary>
        /// Define las acciones a la hora de cargar la pagina.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                //GET datos estudiante con un carnet
                string Txt_Carnet = (string)Session["NUsuario"];

                IMetodosEstudiante _metEstudiante = new MetodosEstudiante();

                #region Obtener Datos Estudiante
                //Revisamos si el estudiante existe en la bd local
                bool Bin_EstudianteExiste = _metEstudiante.EstudianteExiste(Txt_Carnet);
                //Obtenemos info del estudiante
                Ado.ClasesComunes.Estudiante _estudianteNuevo = new Ado.ClasesComunes.Estudiante();
                _estudianteNuevo = _metEstudiante.ObtenerDatosEstudiante(Txt_Carnet, Bin_EstudianteExiste);
                //Obtenemos plan de estudios del estudiante y lo asignamos
                Ado.ClasesComunes.PlanEstudios _planNuevo = new Ado.ClasesComunes.PlanEstudios();
                _planNuevo = _metEstudiante.ObtenerPlanEstudios(Txt_Carnet, Bin_EstudianteExiste);
                if (!Bin_EstudianteExiste)
                {
                    _estudianteNuevo.Id_Plan_Estudios = _planNuevo.Id_Plan_Estudios;
                }

                //Datos de backup
                string Txt_Sede = "CARTAGO";
                string Txt_CitaMatricula = _metEstudiante.ObtenerCitaMatricula(Txt_Carnet);
                #endregion

                #region Datos Asignados
                //Asigna datos estudiante a controles
                lblNombreCompleto.Text = _estudianteNuevo.Txt_Apellido1 + " " + _estudianteNuevo.Txt_Apellido2 + " " + _estudianteNuevo.Nom_Nombre;
                lblCarnet.Text = _estudianteNuevo.Id_Carnet;
                lblCarrera.Text = _planNuevo.Nom_Carrera;
                lblSede.Text = Txt_Sede;
                lblPlan.Text = _planNuevo.Id_Plan_Estudios.ToString();
                lblCitaMatricula.Text = Txt_CitaMatricula;
                txtTelefono.Text = _estudianteNuevo.Num_Telefono;
                txtCelular.Text = _estudianteNuevo.Num_Celular;
                txtCorreo.Text = _estudianteNuevo.Dir_Email;
                #endregion

                #region Cursos
                //Encuentra cursos y llena el autocomplete
                LinkedList<Curso> _cursos = new LinkedList<Curso>();
                _cursos = _metEstudiante.ObtenerCursosEstudiante(Txt_Carnet, null);

                foreach (var _cursoActual in _cursos)
                {
                    ListItem _item = new ListItem();
                    _item.Value = _cursoActual.Id_Curso.ToString();
                    _item.Text = _cursoActual.Txt_Curso;
                    ddlCursos.Items.Add(_item);
                }
                #endregion
                lblCodigoCursoSeleccionado.Text = "Sin código disponible";

                #region Grupos
                LinkedList<Grupo> _liGrupos = _metEstudiante.ObtenerGruposParaInclusion(Int32.Parse(ddlCursos.SelectedValue));

                if (_liGrupos.Count != 0)
                {
                    #region Encabezado de la tabla
                    TableHeaderRow Row_Encabezado = new TableHeaderRow();
                    TableHeaderCell Cel_EncabezadoGrupo = new TableHeaderCell();
                    Cel_EncabezadoGrupo.Text = "Número";
                    Row_Encabezado.Cells.Add(Cel_EncabezadoGrupo);
                    TableHeaderCell Cel_EncabezadoProfesor = new TableHeaderCell();
                    Cel_EncabezadoProfesor.Text = "Profesor";
                    Row_Encabezado.Cells.Add(Cel_EncabezadoProfesor);
                    TableHeaderCell Cel_EncabezadoHorario = new TableHeaderCell();
                    Cel_EncabezadoHorario.Text = "Horario";
                    Row_Encabezado.Cells.Add(Cel_EncabezadoHorario);
                    TableHeaderCell Cel_EncabezadoAcciones = new TableHeaderCell();
                    Cel_EncabezadoAcciones.Text = "Acciones";
                    Row_Encabezado.Cells.Add(Cel_EncabezadoAcciones);
                    tblGrupos.Rows.Add(Row_Encabezado);
                    #endregion

                    foreach (var _grupo in _liGrupos)
                    {
                        TableRow Row_Excepcion = new TableRow();

                        TableCell Cel_Estudiante = new TableCell();
                        Cel_Estudiante.Text = _grupo.Num_Grupo.ToString();
                        Row_Excepcion.Cells.Add(Cel_Estudiante);

                        TableCell Cel_Curso = new TableCell();
                        Cel_Curso.Text = _metEstudiante.ObtenerProfesor(_grupo.Id_Grupo);
                        Row_Excepcion.Cells.Add(Cel_Curso);

                        TableCell Cel_Grupo = new TableCell();
                        Cel_Grupo.Text = CrearHorario(_grupo.Li_Horarios);
                        Row_Excepcion.Cells.Add(Cel_Grupo);

                        TableCell Cel_Acciones = new TableCell();
                        ImageButton btnEliminar = new ImageButton();
                        btnEliminar.ImageUrl = "../Images/table_delete_row.png";
                        btnEliminar.AlternateText = "Eliminar";
                        btnEliminar.Enabled = false;
                        btnEliminar.ToolTip = "Eliminar";
                        //btnEliminar.Click += new ImageClickEventHandler(btnEliminar_Click);
                        Cel_Acciones.Controls.Add(btnEliminar);
                        Row_Excepcion.Cells.Add(Cel_Acciones);

                        tblGrupos.Rows.Add(Row_Excepcion);
                    }
                }
                else
                {
                    TableRow Row_SinGrupos = new TableRow();
                    TableCell Cel_SinGrupos = new TableCell();
                    Cel_SinGrupos.Text = "No se encuentran grupos para este curso";
                    Row_SinGrupos.Cells.Add(Cel_SinGrupos);
                    tblGrupos.Rows.Add(Row_SinGrupos);
                }
                #endregion

                Session["Estudiante"] = _estudianteNuevo;
                Session["Plan"] = _planNuevo;
            }
        }