Beispiel #1
0
        public bool Valid(Estanteria unEstante)
        {
            if (unEstante == null)
            {
                _errorMsg = "El estante es null";
                return(false);
            }
            if (unEstante.Descripcion.Length > 250)
            {
                _errorMsg = "La descripcion no puede tener mas de 250 caracteres";
                return(false);
            }

            if (unEstante.Tipo_Estante == null)
            {
                _errorMsg = "El campo tipo estante es obligatorio";
                return(false);
            }
            if (unEstante.Tipo_Estante.Id == 0)
            {
                _errorMsg = "El campo tipo estante es obligatorio";
                return(false);
            }

            return(true);
        }
Beispiel #2
0
        private void RecargarGrillaLibros()
        {
            Estanteria estanteriaSelect = (Estanteria)bsListaEstantes.Current;

            if (estanteriaSelect == null)
            {
                return;
            }

            LibroDAL.ParamBusquedaLibro paramBusqueda = new LibroDAL.ParamBusquedaLibro()
            {
                Id_Estanteria = estanteriaSelect.Id
            };
            List <Libro> libros = _librosDAL.GetLibros(paramBusqueda);

            bsListaLibros.DataSource = libros;
            bsListaLibros.ResetBindings(true);

            if (libros.Count > 0)
            {
                bsLibroSelect.DataSource = libros.FirstOrDefault();
            }
            else
            {
                bsLibroSelect.Clear();
            }

            bsLibroSelect.ResetBindings(true);
        }
        public ActionResult DeleteConfirmed(string id)
        {
            Estanteria estanteria = db.Estanteria.Find(id);

            db.Estanteria.Remove(estanteria);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
 public ActionResult Edit([Bind(Include = "codigoEstanteria,capacidad")] Estanteria estanteria)
 {
     if (ModelState.IsValid)
     {
         db.Entry(estanteria).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(estanteria));
 }
        public ActionResult Create([Bind(Include = "codigoEstanteria,capacidad")] Estanteria estanteria)
        {
            if (ModelState.IsValid)
            {
                db.Estanteria.Add(estanteria);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(estanteria));
        }
 public ActionResult MasVistos( )
 {
     if (Utils.SessionManager.CuentaActiva( ) != null && Utils.SessionManager.PerfilActivo( ) == null)
     {
         return(RedirectToAction("Perfiles", "Cuenta"));
     }
     else
     {
         Estanteria est = new Estanteria( );
         return(View(est));
     }
 }
Beispiel #7
0
        public frmEstanteABM(int id_Estante = 0)
        {
            InitializeComponent();

            if (id_Estante == 0)
            {
                _unEstante = new Estanteria();
            }
            else
            {
                _unEstante = _estanteriaDAL.GetEstanteriaById(id_Estante);
            }
        }
Beispiel #8
0
        static void Main(string[] args)
        {
            Estanteria estanteria = new Estanteria();

            estanteria.BuscarPorPropiedad("Valor 10", 1, 10);
            var perfil = new Perfil();

            perfil.Seleccionar(1);
            var item = new Item();

            item.Seleccionar(perfil.MisItems().ElementAt(0).Key.Id);
            perfil.SeleccionarPrestamo(perfil.Id, item.Id);
        }
Beispiel #9
0
        private void EditarEstante()
        {
            Estanteria estanteSelect = (Estanteria)bsListaEstantes.Current;

            if (estanteSelect == null)
            {
                return;
            }

            frmEstanteABM frmEstantes = new frmEstanteABM(estanteSelect.Id);

            frmEstantes.ShowDialog();
            ResetBingigsForms();
        }
        // GET: Estanterias/Delete/5
        public ActionResult Delete(string id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Estanteria estanteria = db.Estanteria.Find(id);

            if (estanteria == null)
            {
                return(HttpNotFound());
            }
            return(View(estanteria));
        }
Beispiel #11
0
        static void Main(string[] args)
        {
            Estanteria <Alimenticio> est1 = new Estanteria <Alimenticio>(5);
            Estanteria <Ferreteria>  est2 = new Estanteria <Ferreteria>(5);
            Estanteria <Alimenticio> est3 = new Estanteria <Alimenticio>(5);
            DateTime d1 = new DateTime(1);
            DateTime d2 = new DateTime(2);

            Alimenticio alimento1 = new Alimenticio(5, "Verdura", d1);
            Alimenticio alimento2 = new Alimenticio(6, "Bebida", d2);
            Alimenticio alimento3 = new Alimenticio(7, "Snack", d1);
            Alimenticio alimento4 = new Alimenticio(8, "Carne", d1);
            Alimenticio alimento5 = new Alimenticio(9, "Pollo", d2);
            Alimenticio alimento6 = new Alimenticio(8, "AlimentoRepetido", d1);
            Ferreteria  ferre1    = new Ferreteria(23, "Martillo", 20);
            Ferreteria  ferre2    = new Ferreteria(24, "Destornillador", 25);
            Ferreteria  ferre3    = new Ferreteria(25, "Lija", 30);
            Ferreteria  ferre4    = new Ferreteria(26, "Tornillo", 5);
            Ferreteria  ferre5    = new Ferreteria(27, "Regla", 10);
            Ferreteria  ferre6    = new Ferreteria(26, "FerreRepetida", 30);

            Console.WriteLine("ESTANTE 1: ");
            if (est1 + alimento1)
            {
                Console.WriteLine("Alimento 1 ha sido agregado (Verdura)");
            }
            else
            {
                Console.WriteLine("No pudo agregarse");
            }
            if (est1 + alimento1)
            {
                Console.WriteLine("Alimento 1 ha sido agregado (Verdura)");
            }
            else
            {
                Console.WriteLine("No pudo agregarse");
            }
            if (est1 + ferre2)
            {
                Console.WriteLine("Pudo agregarse");
            }
            else
            {
                Console.WriteLine("No pudo agregarse");
            }
            Console.ReadKey();
        }
Beispiel #12
0
        static void Main(string[] args)
        {
            Estanteria <Ferreteria>  e1 = new Estanteria <Ferreteria>(3);
            Estanteria <Producto>    e2 = new Estanteria <Producto>(3);
            Estanteria <Alimenticio> e3 = new Estanteria <Alimenticio>(3);

            Alimenticio alimento1 = new Alimenticio(1, "arroz", new DateTime(2020, 05, 07));
            Alimenticio alimento2 = new Alimenticio(2, "fideos", new DateTime(2022, 10, 23));
            Ferreteria  ferrete1  = new Ferreteria(3, "pinza", 35.6f);
            Ferreteria  ferrete2  = new Ferreteria(4, "clavos", 1.5f);

            bool b1 = e3 + alimento1;
            bool b2 = e3 + alimento2;
            bool b3 = e1 + ferrete1;
            bool b4 = e1 + ferrete2;
        }
        static void Main(string[] args)
        {
            bool flag;
            Estanteria <Producto>    estanteria1 = new Estanteria <Producto>(5);
            Estanteria <Alimenticio> estanteria2 = new Estanteria <Alimenticio>(5);
            Estanteria <Ferreteria>  estanteria3 = new Estanteria <Ferreteria>(5);

            Alimenticio alimenticioGenerico = new Alimenticio(1, "Alimento Generico", new DateTime(2019, 10, 21));
            Ferreteria  ferreteriaGenerico  = new Ferreteria(2, "Herramienta Generica", 25.5f);

            flag = estanteria2 + alimenticioGenerico;
            flag = estanteria3 + ferreteriaGenerico;

            Console.WriteLine(estanteria2.Productos[0].Descripcion);
            Console.WriteLine(estanteria3.Productos[0].Descripcion);
            Console.ReadKey();
        }
Beispiel #14
0
        public static Estanteria GetEstanteria(int idx)
        {
            pav2Entidades db                = new pav2Entidades();
            var           dbEstanteria      = db.estanteria;
            var           estanteriaBuscada = new Estanteria();

            foreach (var e in dbEstanteria)
            {
                if (idx == e.id)
                {
                    estanteriaBuscada.Id        = e.id;
                    estanteriaBuscada.Ubicacion = e.nombre;
                    return(estanteriaBuscada);
                }
            }

            return(estanteriaBuscada);
        }
Beispiel #15
0
        public bool IsEstanteEliminable(Estanteria unEstante)
        {
            if (unEstante == null)
            {
                _errorMsg = "El estante es null";
                return(false);
            }
            if (unEstante == null)
            {
                _errorMsg = "El estante es null";
                return(false);
            }
            if (_contexto.Libros.Where(a => a.Id_Estanteria == unEstante.Id).Count() > 0)
            {
                _errorMsg = "El estante tiene libros asociados. No puede ser eliminado";
                return(false);
            }

            return(true);
        }
Beispiel #16
0
        public bool EliminarEstante(Estanteria unEstante)
        {
            try
            {
                if (!IsEstanteEliminable(unEstante))
                {
                    return(false);
                }

                _contexto.Estanterias.Remove(unEstante);
                _contexto.SaveChanges();
                return(true);
            }
            catch (Exception ex)
            {
                _errorMsg = "Ocurrio un error al eliminar el estante. Ver el LogError";
                StaticFileManager.LogError(ex);
                return(false);
            }
        }
Beispiel #17
0
        private void btnEliminarEstante_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            Estanteria estanteSelect = (Estanteria)bsListaEstantes.Current;

            if (estanteSelect == null)
            {
                return;
            }
            if (MessageBox.Show("Se eliminara el estante seleccionado.¿Desea continuar", "Atencion...", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
            {
                return;
            }

            if (_estanteriaDAL.EliminarEstante(estanteSelect))
            {
                MessageBox.Show("El estante fue eliminado exitosamente", "Atencion...", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else
            {
                MessageBox.Show(_estanteriaDAL._errorMsg, "Atencion...", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }

            ResetBingigsForms();
        }
Beispiel #18
0
        public bool GuardarEstante(Estanteria unEstante)
        {
            try
            {
                if (!Valid(unEstante))
                {
                    return(false);
                }

                if (unEstante.Id == 0)
                {
                    _contexto.Estanterias.Add(unEstante);
                }

                _contexto.SaveChanges();
                return(true);
            }
            catch (Exception ex)
            {
                _errorMsg = "Ocurrio un error mientras se guardan los cambios. Ver el LogError";
                StaticFileManager.LogError(ex);
                return(false);
            }
        }
        public ActionResult Busqueda(string buscar, int page = 1, int cantResult = 10, int filtro = 1)
        {
            Estanteria e = new Estanteria( );

            if (String.IsNullOrEmpty(buscar))
            {
                buscar = "";
            }
            var result = new List <Item> ();

            switch (filtro)
            {
            case 1:     //titulo
                result = e.Buscar(buscar, page, cantResult);
                break;

            case 2:     //Autor
                result = e.BuscarPorAutor(buscar, page, cantResult);
                break;

            case 3:     //Propiedad
                result = e.BuscarPorPropiedad(buscar, page, cantResult);
                break;

            case 4:     //Ubicacion    usamos radio de 40.
                try
                {
                    var       p     = Utils.SessionManager.PerfilActivo( );
                    Ubicacion u     = p.Ubicacion;
                    var       radio = 40;
                    result = e.Buscar(buscar, u, page, cantResult, radio);
                }
                catch (Exception ex)
                { }
                break;

            case 5:     //All
                result = e.BuscarPorAll(buscar, page, cantResult);
                break;

            default:
                result = e.Buscar(buscar, page, cantResult);
                break;
            }


            this.ViewBag.Page    = page;
            this.ViewBag.Results = cantResult;
            this.ViewBag.Termino = buscar;
            this.ViewBag.Filtro  = filtro;

            if (result.Count == cantResult)
            {
                this.ViewBag.More = 1;
            }
            else
            {
                this.ViewBag.More = 0;
            }

            return(View(result));
        }
Beispiel #20
0
        static void Main(string[] args)
        {
            Console.WriteLine("Hola Mundo");
            Cuenta cuenta = new Cuenta();

            cuenta.Seleccionar("*****@*****.**");
            cuenta.Perfiles();
            Perfil perfil = new Perfil();

            perfil.Seleccionar(1);

            Item item = new Item();

            //item.Crear();
            item.Seleccionar(1);
            perfil.Disponibilidad(item, false);
            item.Autores();
            Prestamo prestamo = new Prestamo();

            item.Titulo = "222";
            prestamo.Seleccionar(1);
            Comentario comentario = new Comentario()
            {
                Texto = "Texto N", Perfil = perfil, Prestamo = prestamo
            };

            comentario.Crear();
            comentario.Texto = "Texto NxN";
            comentario.Modificar();
            comentario.Eliminar();
            Comentario comentario2 = new Comentario();

            comentario2.Seleccionar(1);
            perfil.HistorialPrestamista(0, 10);
            perfil.HistorialPrestamista(0, 10);
            perfil.MisItems();
            Ubicacion ubicacion = new Ubicacion();

            ubicacion.Seleccionar(1);
            Estanteria estant = new Estanteria();

            estant.Buscar("Titulo 8", ubicacion, 1, 10, 2749);
            estant.LosMasCabrones(5);
            //prestamo.Eliminar_Comentario(comentario);
            //Console.WriteLine(string.Format("ID: {0}", item.Crear()));
            //item.Titulo = "2323";
            //item.Modificar();
            item.Agregar("perro", "Hola");
            item.Propiedades();
            item.Modificar("anio", "1111");
            item.Remove("anio");
            Console.WriteLine(string.Format("ENUM {0}", (int)EstadoPrestamo.Enviado));
            //item.Eliminar();
            //item.Seleccionar(1);
            //Console.WriteLine(string.Format("ID: {0}, Titutlo: {1}", item.Id, item.Titulo));
            //item.Autores();
            //Autor autor = new Autor() { Nombre = "Nuevo" };
            //autor.Crear();
            //item.Autor_item_crear(autor);
            //item.Autor_item_eliminar(autor);
            //item.Remove("anio");
            //autor.Nombre = "PEDRO";
            //autor.Modificar();
            //autor.Eliminar();
            //perfil2.Eliminar();
            //cuenta.Eliminar();
            Console.ReadLine();
        }
Beispiel #21
0
        static void Main(string[] args)
        {
            //Fecha de hoy
            DateTime fecha = DateTime.Today;

            // Instancio Estanterias.
            Estanteria <Producto>    estProductos   = new Estanteria <Producto>(50);
            Estanteria <Alimenticio> estAlimenticio = new Estanteria <Alimenticio>(50);
            Estanteria <Ferreteria>  estFerreteria  = new Estanteria <Ferreteria>(50);

            //Creo Productos.
            Alimenticio arroz  = new Alimenticio(1, "Arroz", new DateTime());
            Alimenticio leche  = new Alimenticio(2, "Leche", fecha);
            Alimenticio aceite = new Alimenticio(3, "Aceite", fecha);

            Ferreteria tornillo = new Ferreteria(4, "Tornillo", (float)30.5);
            Ferreteria bulon    = new Ferreteria(5, "Bulon", (float)4.5);
            Ferreteria tuerca   = new Ferreteria(6, "Tuerca", (float)2.5);

            // Agrego al estante (Ferreteria)
            Console.WriteLine("**Si esta bien, agrega 3 prod. Ferreteria.");
            Console.WriteLine("");
            if (estFerreteria + tornillo)
            {
                Console.WriteLine("Agrege Tornillo a Estante de Ferreteria");
            }
            if (estFerreteria + bulon)
            {
                Console.WriteLine("Agrege bulon a Estante de Ferreteria");
            }
            if (estFerreteria + tuerca)
            {
                Console.WriteLine("Agrege tuerca a Estante de Ferreteria");
            }
            Console.WriteLine("");

            // Agrego al estante (Alimenticio)
            Console.WriteLine("**Si esta bien, agrega 3 prod. Alimenticio.");
            Console.WriteLine("");
            if (estAlimenticio + arroz)
            {
                Console.WriteLine("Agrege arroz a Estante de Alimenticio");
            }
            if (estAlimenticio + aceite)
            {
                Console.WriteLine("Agrege aceite a Estante de Alimenticio");
            }
            if (estAlimenticio + leche)
            {
                Console.WriteLine("Agrege leche a Estante de Alimenticio");
            }
            Console.WriteLine("");

            // Agrego al estante (General)
            Console.WriteLine("**Si esta bien, agrega 4 prod. Generales.");
            Console.WriteLine("");
            if (estProductos + arroz)
            {
                Console.WriteLine("Agrege arroz a Estante de Productos Generales");
            }
            if (estProductos + bulon)
            {
                Console.WriteLine("Agrege bulon a Estante de Productos Generales");
            }
            if (estProductos + leche)
            {
                Console.WriteLine("Agrege leche a Estante de Productos Generales");
            }
            if (estProductos + tornillo)
            {
                Console.WriteLine("Agrege leche a Estante de Productos Generales");
            }
            Console.WriteLine("");

            //Quito elementos.
            Console.WriteLine("**Si esta bien, QUITO 4 prod. Generales.");
            Console.WriteLine("");
            if (estProductos - arroz)
            {
                Console.WriteLine("Quite arroz a Estante de Productos Generales");
            }
            if (estProductos - bulon)
            {
                Console.WriteLine("Quite bulon a Estante de Productos Generales");
            }
            if (estProductos - leche)
            {
                Console.WriteLine("Quite leche a Estante de Productos Generales");
            }
            if (estProductos - tornillo)
            {
                Console.WriteLine("Quite tornillo a Estante de Productos Generales");
            }

            Console.ReadKey();
        }