Beispiel #1
0
        }//DELETE

        public MateriaModel GetMateriaId(int idMateria)
        {
            try
            {
                string         Query   = "GetMateriasById";
                SqlCommand     cmd     = new SqlCommand(Query, conn);
                SqlDataAdapter adapter = new SqlDataAdapter(cmd);
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Parameters.AddWithValue("@idMateria", idMateria);

                DataSet dsMateria = new DataSet();
                adapter.Fill(dsMateria);

                if (dsMateria.Tables[0].Rows.Count > 0)
                {
                    DataRow      dr      = dsMateria.Tables[0].Rows[0];
                    MateriaModel Materia = new MateriaModel(dr);
                    return(Materia);
                }
                else
                {
                    MateriaModel Materia = new MateriaModel();
                    return(Materia);
                }
            }
            catch (Exception)
            {
                throw;
            }
        }//GET MATERIA BY ID
        public bool DeleteMateria(MateriaModel materia)
        {
            var menu       = new MenuService();
            var optionMenu = new OptionMenuService();

            try
            {
                using (var context = new UniversidadeContext())
                {
                    var materiaDB = context.Materias.Where(w => w.MateriaDesc == materia.MateriaDesc).SingleOrDefault();

                    if (materiaDB != null)
                    {
                        context.Remove(materiaDB);
                        context.SaveChanges();

                        return(true);
                    }
                    else
                    {
                        return(false);
                    }
                }
            }
            catch (Exception)
            {
                throw;
            }
        }
Beispiel #3
0
        public virtual void Insertar(MateriaModel model, HttpContextBase context)
        {
            Dictionary <string, object> parameters = new Dictionary <string, object>();

            parameters.Add("@nombre", model.Nombre);
            try
            {
                MateriaModel dup = this.ObtenerMaterias(new QueryExpresion($"lcase({SqlUtil.SurroundColumn("Nombre")}) = @nombre"), new Dictionary <string, object>()
                {
                    { "@nombre", model.Nombre.ToLower() }
                }, context)?.FirstOrDefault();

                //buscar por duplicados
                if (dup != null)
                {
                    throw new Exception(string.Format(CatalogoRes.MateriaYaExisteFmt, dup.Nombre));
                }

                DataConnection.Instance.ExecuteNonQuery(SqlResource.SqlMateriasInsert, parameters, context);
                ulong id = (ulong)DataConnection.Instance.ExecuteScalar(SqlResource.SqlLastInsertedId, default(Dictionary <string, object>), context, transaction: null);
                model.ID = (long)id;
                this.RemoveValueIfExists(this.GetOrCreateKey(context), nameof(ObtenerMaterias));
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Beispiel #4
0
 private void listarMaterias()
 {
     MateriaModel materiaModel = new MateriaModel();
     this.dgv_BuscarMateria.DataSource = materiaModel.listarMaterias();
     this.cmb_Materia.DataSource = materiaModel.listarMaterias();
     this.cmb_Materia.DisplayMember = "nombre";
     this.cmb_Materia.ValueMember = "codigo";
 }
Beispiel #5
0
        public ActionResult EditarMateria(int id)
        {
            MateriaModel model = new MateriaModel();

            using (CursoEntities db = new CursoEntities())
            {
                var emateria = db.MateriasTs.Find(id);
                model.nombre_materia = emateria.nombre_materia;
                model.id_materia     = emateria.id_materia;
            }
            return(View(model));
        }
        protected virtual List <MateriaModel> LlenarMateriasDelCatalogo(IDataReader reader, long catalogo_id)
        {
            List <MateriaModel> result = new List <MateriaModel>();

            while (reader.Read())
            {
                MateriaModel nc = new MateriaModel();
                nc.Fill(reader);
                result.Add(nc);
            }
            return(result);
        }
Beispiel #7
0
        protected virtual List <MateriaModel> LlenarModelos(IDataReader reader)
        {
            List <MateriaModel> result = new List <MateriaModel>();

            while (reader.Read())
            {
                MateriaModel nc = new MateriaModel();
                nc.Fill(reader);
                result.Add(nc);
            }
            return(result);
        }
 public ActionResult Editar(int id, MateriaModel collection)
 {
     try
     {
         this.materiaLogic.Save(this.MateriaToBusiness(collection, Business.Entities.BusinessEntity.States.Modified));
         return(RedirectToAction("Index"));
     }
     catch (Exception ex)
     {
         return(View());
     }
 }
 public ActionResult Nuevo(MateriaModel collection)
 {
     try
     {
         this.materiaLogic.Save(this.MateriaToBusiness(collection, Business.Entities.BusinessEntity.States.New));
         return(RedirectToAction("Index"));
     }
     catch
     {
         return(View());
     }
 }
Beispiel #10
0
 public void AtualizaMateria(MateriaModel MateriaModelo)
 {
     foreach (MateriaModel Materia in listaMaterias)
     {
         if (Materia.NumeroMateria == MateriaModelo.NumeroMateria)
         {
             listaMaterias.Remove(Materia);
             listaMaterias.Add(MateriaModelo);
             break;
         }
     }
 }
        public void TestDeleteMateriaERROR()
        {
            var materiaRepository = new MateriaRepository();

            var materiaModel = new MateriaModel()
            {
                MateriaDesc    = "Matemática",
                MateriaDataCad = DateTime.Parse("10/10/2000"),
                materiaSitacao = "A"
            };

            Assert.AreEqual(materiaRepository.DeleteMateria(materiaModel), false);
        }
        public ActionResult UpdateMateria(MateriaModel m)
        {
            try
            {
                materias.UpdateMateria(m.IdMateria, m.Nombre, m.Costo);
            }
            catch (Exception)
            {
                throw;
            }

            return(Content("1"));
        }
 public Business.Entities.Materia MateriaToBusiness(MateriaModel model, Business.Entities.BusinessEntity.States estado)
 {
     Business.Entities.Materia materia = new Business.Entities.Materia();
     materia.Descripcion = model.Descripcion;
     materia.HSSemanales = model.HSSemanales;
     materia.HSTotales   = model.HSTotales;
     materia.IDPlan      = model.IDPlan;
     materia.State       = estado;
     if (estado == Business.Entities.BusinessEntity.States.Modified)
     {
         materia.ID = model.ID;
     }
     return(materia);
 }
Beispiel #14
0
        public ActionResult EditaMateria(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            MateriaModel materiaAtt = materia.listaMaterias.Where(x => x.NumeroMateria == id).FirstOrDefault();

            if (materiaAtt == null)
            {
                return(HttpNotFound());
            }
            return(View(materiaAtt));
        }
Beispiel #15
0
        public MateriaModel GetMateria(int NumeroMateria)
        {
            MateriaModel _MateriaModel = null;

            foreach (MateriaModel _Materia in listaMaterias)
            {
                if (_Materia.NumeroMateria == NumeroMateria)
                {
                    _MateriaModel = _Materia;
                }
            }

            return(_MateriaModel);
        }
Beispiel #16
0
        public ActionResult EditaMateria(MateriaModel model)
        {
            if (ModelState.IsValid)
            {
                var materiaAtt = materia.listaMaterias.Where(x => x.NumeroMateria == model.NumeroMateria).FirstOrDefault();
                if (materiaAtt == null)
                {
                    return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
                }
                materiaAtt.NomeMateria   = model.NomeMateria;
                materiaAtt.NumeroMateria = model.NumeroMateria;

                return(RedirectToAction("Index"));
            }
            return(View(model));
        }
        public IHttpActionResult Post(MateriaModel materia)
        {
            try
            {
                if (!ModelState.IsValid)
                {
                    return(BadRequest());
                }

                _materiaRules.Insert(_mapper.Map <Materia>(materia));
                return(Ok(materia));
            }
            catch (Exception ex)
            {
                return(InternalServerError(ex));
            }
        }
        private SelectList obtenListadoMaterias(HORARIO hAux)
        {
            SelectList          listado;
            List <MateriaModel> listaMaterias = new List <MateriaModel>();

            foreach (MATERIA mAux in db.MATERIA)
            {
                MateriaModel mat = new MateriaModel();
                mat.idMateria   = Convert.ToInt32(mAux.ID_MATERIA);
                mat.displayText = mAux.NOMBRE;
                listaMaterias.Add(mat);
            }

            listado = new SelectList(listaMaterias, "idMateria", "displayText", hAux.ID_MATERIA);

            return(listado);
        }
        public ActionResult Edit(int id)
        {
            MateriaModel model = materias.GetMateriaId(id);

            try
            {
                var materia = materias.GetMateriaId(id);
                model.IdMateria = materia.IdMateria;
                model.Nombre    = materia.Nombre;
            }
            catch (Exception)
            {
                throw;
            }

            return(View(model));
        }
Beispiel #20
0
 public EditarViewModel(int a)  //para materias
 {
     _mat   = new MateriaModel();
     this.a = a;
     if (a == 1)
     {
         _visible = true;
         _texto   = "ingrese parametro de entrada";
     }
     else
     {
         _texto   = "ingrese la materia a eliminar";
         _visible = false;
     }
     GuardarElementoCommand  = new Command(GuardarElemento);
     EliminarElementoCommand = new Command(EliminarElemento);
 }
        public ActionResult SaveMateria(MateriaModel m)
        {
            MateriaModel mat = new MateriaModel();

            try
            {
                mat.Nombre = m.Nombre;
                mat.Costo  = m.Costo;

                materias.InsertMateria(mat.Nombre, mat.Costo);
            }
            catch (Exception)
            {
                throw;
            }

            return(Content("1"));
        }
Beispiel #22
0
        public void TestDeleteNotaOK()
        {
            var notaRepository    = new NotaRepository();
            var alunoRepository   = new AlunoRepository();
            var materiaRepository = new MateriaRepository();

            var alunoModel = new AlunoModel()
            {
                AlunoCPF        = 99689899082,
                AlunoNome       = "Logan",
                AlunoSobrenome  = "Da Silva",
                AlunoCurso      = "Geografia",
                AlunoNascimento = Convert.ToDateTime("10/02/1998"),
            };

            alunoRepository.CreateAluno(alunoModel);
            alunoRepository.VerificaCPFAluno(alunoModel.AlunoCPF.ToString(), out int?idAluno);

            var materiaModel = new MateriaModel()
            {
                MateriaDesc    = "Matemática",
                MateriaDataCad = DateTime.Parse("10/10/2000"),
                materiaSitacao = "A"
            };

            materiaRepository.CreateMateria(materiaModel);
            materiaRepository.VerificaMateriaCadastrada(materiaModel.MateriaDesc, out int?idMateria);

            var notaModel = new NotasAlunoModel()
            {
                AlunoID     = Convert.ToInt32(idAluno),
                MateriaID   = Convert.ToInt32(idMateria),
                notaMateria = 100
            };

            notaRepository.SalvaNotaMateriaAluno(notaModel);

            Assert.AreEqual(notaRepository.DeletaNotaMateriaAluno(notaModel), true);

            notaRepository.DeletaNotaMateriaAluno(notaModel);
            alunoRepository.DeleteAluno(alunoModel);
            materiaRepository.DeleteMateria(materiaModel);
        }
Beispiel #23
0
        private void txt_BuscarMateria_TextChanged(object sender, EventArgs e)
        {
            MateriaModel materiaModel = new MateriaModel();

            try
            {
                if (this.chk_LuAlu.Checked == true && this.chk_NombreAlu.Checked == false)
                {
                    dgv_Alumnos.DataSource = materiaModel.filtrarMaterias("XCodigo", txt_BuscarAlumno.Text);
                }
                if (this.chk_NombreAlu.Checked == true && this.chk_LuAlu.Checked == false)
                {
                    dgv_Alumnos.DataSource = materiaModel.filtrarMaterias("XNombre", txt_BuscarAlumno.Text);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error cuando Filtras" + ex.Message, "Atencion", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                throw;
            }
        }
Beispiel #24
0
        public ActionResult NuevaMateria(MateriaModel model)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    using (CursoEntities db = new CursoEntities())
                    {
                        var materia = new MateriasT();
                        materia.nombre_materia = model.nombre_materia;

                        db.MateriasTs.Add(materia);
                        db.SaveChanges();
                    }
                    return(Redirect("Materia/"));
                }
                return(View(model));
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
Beispiel #25
0
        public ActionResult EditarMateria(MateriaModel model)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    using (CursoEntities db = new CursoEntities())
                    {
                        var emateria = db.MateriasTs.Find(model.id_materia);
                        emateria.nombre_materia = model.nombre_materia;


                        db.Entry(emateria).State = System.Data.Entity.EntityState.Modified;
                        db.SaveChanges();
                    }
                    return(Redirect("/"));
                }
                return(View(model));
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
Beispiel #26
0
 public ActionResult AdicionaMateria(MateriaModel _MateriaModel)
 {
     materia.CriaMateria(_MateriaModel);
     TempData["ListaMaterias"] = materia.listaMaterias;
     return(View());
 }
 public ActionResult NewMateria(MateriaModel m)
 {
     return(View());
 }
        protected virtual List <T> FillCatalogoListExcel <T>(IDataReader reader, SeriesDataService serieDs, IEnumerable <SerieModel> seriesList, MateriasDataService materiaDs, IEnumerable <MateriaModel> materiasList, bool limitarStrings, HttpContextBase context) where T : CatalogoModel, new()
        {
            List <T> result = new List <T>();
            long     count  = 0;

            while (reader.Read())
            {
                T nc = new T();
                //--------------------------\\
                nc.Contenido = Convert.IsDBNull(reader["Contenido"]) ? null : reader["Contenido"].ToString();
                nc.Año       = Convert.IsDBNull(reader["Año"]) ? (short?)null : Convert.ToInt16(reader["Año"]); //Año
                nc.Fecha     = Convert.IsDBNull(reader["Fecha"]) ? (DateTime?)null : (DateTime)reader["Fecha"];
                nc.Folio     = Convert.IsDBNull(reader["Folio"]) ? null : reader["Folio"].ToString();

                if (seriesList.Count() > 0)
                {
                    SerieModel serie = seriesList.FirstOrDefault(sm => sm.Nombre.Trim().Equals(reader["Series"].ToString().Trim()));
                    if (serie == null)
                    {
                        serie = new SerieModel()
                        {
                            Nombre = reader["Series"].ToString()
                        };
                        serieDs.Insertar(serie, context);
                    }
                    nc.IdSerie      = serie?.ID;
                    nc.SeriesNombre = serie?.Nombre;
                }

                if (materiasList.Count() > 0)
                {
                    string materiaExt = Convert.IsDBNull(reader["Materias"]) ? null : reader["Materias"].ToString();
                    if (!string.IsNullOrEmpty(materiaExt))
                    {
                        nc.ListaMaterias = new List <MateriaModel>();
                        string[] valoresSeparados = null;
                        if (materiaExt.Contains(" / "))
                        {
                            valoresSeparados = materiaExt.Split(new string[] { " / " }, StringSplitOptions.RemoveEmptyEntries);
                        }
                        else
                        {
                            valoresSeparados = new string[] { materiaExt };
                        }
                        foreach (string item in valoresSeparados)
                        {
                            MateriaModel materia = materiasList.FirstOrDefault(m => m.Nombre.Trim().Equals(item.Trim()));
                            if (materia == null)
                            {
                                materia = new MateriaModel()
                                {
                                    Nombre = item
                                };
                                materiaDs.Insertar(materia, context);
                            }
                            nc.ListaMaterias.Add(materia);
                        }
                    }
                }

                nc.Libro         = Convert.IsDBNull(reader["Libro"]) ? (int?)null : Convert.ToInt32(reader["Libro"]);
                nc.Lugar         = Convert.IsDBNull(reader["Lugar"]) ? null : reader["Lugar"].ToString();
                nc.NumCaja       = Convert.IsDBNull(reader["Caja"]) ? null : reader["Caja"].ToString();
                nc.NumCarpeta    = Convert.IsDBNull(reader["Carpeta"]) ? (int?)null : Convert.ToInt32(reader["Carpeta"]);
                nc.NumExpediente = Convert.IsDBNull(reader["Expediente"]) ? null : reader["Expediente"].ToString();
                nc.NumTomo       = Convert.IsDBNull(reader["Tomo"]) ? (int?)null : Convert.ToInt32(reader["Tomo"]);
                nc.Observaciones = Convert.IsDBNull(reader["Observaciones"]) ? null : reader["Observaciones"].ToString();
                //nc.Materias = Convert.IsDBNull(reader["Materias"]) ? null : reader["Materias"].ToString();
                nc.Origen = 1;
                nc.ID     = count++;
                //--------------------------\\
                result.Add(nc);
            }
            return(result);
        }
Beispiel #29
0
 public void CriaMateria(MateriaModel MateriaModelo)
 {
     listaMaterias.Add(MateriaModelo);
 }
Beispiel #30
0
        private void listarMaterias()
        {
            MateriaModel materiaModel = new MateriaModel();

            this.dgv_Materias.DataSource = materiaModel.listarMaterias();
        }