Ejemplo n.º 1
0
        public ActionResult OfertaCursosPorSede(pa_Curso_x_Sede_SoloID_Select_Result modeloVista, pa_Curso_x_Sede_RetornaID_Select_Result OtroModelo)
        {
            int    RegistrosAfectados = 0;
            string mensaje            = "";

            try
            {
                ///Se verifica si  ya existe cierto curso en x cuatrimestre en x sede

                pa_Curso_x_Sede_VerificaCurso_Select_Result ModeloVerificar =
                    this.matriculaBD.pa_Curso_x_Sede_VerificaCurso_Select(modeloVista.Id_Curso,
                                                                          modeloVista.Id_Sedes_universitarias,
                                                                          OtroModelo.Numero_Cuatrimestre,
                                                                          OtroModelo.Anio_Cuatrimestre).FirstOrDefault();
                ///Si es diferente de  null o si esta en la base de datos
                if (ModeloVerificar != null)///antes estaba ModeloVerificar
                {
                    mensaje = "Ya existe ese curso por cuatrimestre en dicha sede.";
                }
                else
                {
                    RegistrosAfectados = this.matriculaBD.pa_Cuatrimestre_OfertaCursos_Insert(modeloVista.Id_Curso,
                                                                                              modeloVista.Id_Sedes_universitarias,
                                                                                              OtroModelo.Numero_Cuatrimestre,
                                                                                              modeloVista.Cantidad_Estudiantes,
                                                                                              OtroModelo.Anio_Cuatrimestre);
                }
            }
            catch (Exception error)
            {
                mensaje = "Hubo un error. " + error.Message;
            }
            finally {
                if (RegistrosAfectados > 0)
                {
                    mensaje = "Oferta ingresada";
                }
                else
                {
                    mensaje += "No se pudo ingresar la oferta.";
                }
                Response.Write("<script language=javascript>alert('" + mensaje + "');</script>");
            }
            this.Lista_Num_CuatrimestreViewBag();
            this.CargarSedesUniversitariasViewbag();
            this.CargarCursosViewBag();
            return(View(OtroModelo));
        }
Ejemplo n.º 2
0
        public ActionResult MatriculaEstudianteCurso(pa_Curso_x_Sede_SoloID_Select_Result modeloVista, pa_Curso_x_Sede_RetornaID_Select_Result OtroModelo, pa_Curso_x_Cuatrimestre_ListaEstudiantes_Result modeloEstudiante)
        {
            int    RegistrosAfectados = 0;
            bool   VerificaID_Est     = false;
            string mensaje            = "";

            try
            {
                ///Se obtiene el id del cuatrimestre del para hacer la inserción
                ///
                pa_Curso_x_Cuatrimestre_Id_Cuatrimestre_Result modeloSoloId_Cuatrimestre =
                    this.matriculaBD.pa_Curso_x_Cuatrimestre_Id_Cuatrimestre(OtroModelo.Numero_Cuatrimestre,
                                                                             modeloVista.Anio_Cuatrimestre,
                                                                             modeloVista.Id_Sedes_universitarias).FirstOrDefault();

                ///Se verifica que no hayan registros similiares
                List <pa_Curso_x_CuatrimestreVerificar_Result> modeloVerificar
                    = this.matriculaBD.pa_Curso_x_CuatrimestreVerificar(modeloVista.Id_Curso,
                                                                        OtroModelo.Numero_Cuatrimestre,
                                                                        modeloVista.Anio_Cuatrimestre,
                                                                        modeloSoloId_Cuatrimestre.Id_Cuatrimeste,
                                                                        modeloEstudiante.Id_Estudiante,
                                                                        modeloVista.Id_Sedes_universitarias).ToList();

                ///Busca en el resultado del procedimiento esta el Id estudiante
                foreach (pa_Curso_x_CuatrimestreVerificar_Result modeloEst in modeloVerificar)
                {
                    if (modeloEst.Id_Estudiante == modeloEstudiante.Id_Estudiante)
                    {
                        mensaje        = "No puede haber estudiantes matriculados dos o más veces en un mismo curso por cuatrimestre en alguna de las sedes universitarias.";
                        VerificaID_Est = true;
                    }
                    else
                    {
                        VerificaID_Est = false;
                    }
                }
                if (VerificaID_Est == false)
                {
                    RegistrosAfectados = this.matriculaBD.pa_Curso_x_Cuatrimestre_Insert(modeloVista.Id_Curso,
                                                                                         OtroModelo.Numero_Cuatrimestre,
                                                                                         modeloVista.Anio_Cuatrimestre,
                                                                                         modeloSoloId_Cuatrimestre.Id_Cuatrimeste,
                                                                                         modeloEstudiante.Id_Estudiante,
                                                                                         modeloVista.Id_Sedes_universitarias);
                }
            }
            catch (Exception error)
            {
                mensaje = "Hubo un error." + error.Message;
            }
            finally
            {
                if (RegistrosAfectados > 0)
                {
                    mensaje = "Matricula ingresada";
                }
                else
                {
                    mensaje += ".No se pudo ingresar";
                }
                Response.Write("<script language=javascript>alert('" + mensaje + "');</script>");
            }
            this.Lista_Num_CuatrimestreViewBag();
            this.CargarSedesUniversitariasViewbag();
            this.CargarCursosViewBag();
            this.CargaListaEstudianteViewBag();
            this.cargaCursosSCA(OtroModelo.Numero_Cuatrimestre, modeloVista.Id_Sedes_universitarias, modeloVista.Anio_Cuatrimestre);
            return(View(OtroModelo));
        }