示例#1
0
        // GET: Libro
        public ActionResult Listar()
        {
            LibroViewModel lvm = new LibroViewModel();

            lvm.lista = LibroService.findAll();
            return(View(lvm));
        }
 public ConsultarCompra()
 {
     InitializeComponent();
     oProveedorService   = new ProveedorService();
     oLibroService       = new LibroService();
     oCompraService      = new CompraService();
     oCompraSeleccionada = new Compra();
 }
示例#3
0
 public EjemplarController()
 {
     eS  = new EjemplarServiceImp();
     lS  = new LibroServiceImp();
     aS  = new AutorServiceImp();
     edS = new EditorialServiceImp();
     pS  = new PrestamoServiceImp();
     uS  = new UsuarioServiceImp();
 }
示例#4
0
 public ABMPrestamos()
 {
     InitializeComponent();
     oEstadoDetallePrestamoService = new EstadoDetallePrestamoService();
     oDetallePrestamoService       = new DetallePrestamoService();
     oPrestamoService       = new PrestamoService();
     oEstadoPrestamoService = new EstadoPrestamoService();
     oLibroService          = new LibroService();
     oSoporteForm           = new SoporteForm();
     oPrestamoSelected      = new Prestamo();
     oEjemplarService       = new EjemplarService();
 }
 public frmCompra()
 {
     InitializeComponent();
     compraSeleccionada     = new Compra();
     oSoporteForm           = new SoporteForm();
     oProveedorService      = new ProveedorService();
     oLibroService          = new LibroService();
     oCompraService         = new CompraService();
     oEjemplarService       = new EjemplarService();
     oEstadoEjemplarService = new EstadoEjemplarService();
     oProveedor             = new Proveedor();
     oDetalleCompraService  = new DetalleCompraService();
     formMode = FormMode.insert;
     nuevo    = true;
 }
示例#6
0
        public ActionResult adminFiltrarLibro(String option, String search)
        {
            /*no hago back-end de option o search, si el usuario escribe cualquier cosa
             * porque en la view va a aparecer 0 registros encontrados!*/

            LibroService ls       = new LibroService();
            String       consulta = "Select * from libros";

            if (option == "all")
            {
                return(View(ls.LibrosByQueryGet(consulta)));
            }

            else if (option == "bookName")
            {
                if (String.IsNullOrEmpty(search))
                {
                    ViewBag.Msg = "Ingrese el nombre de libro";
                    return(View());
                }
                else
                {
                    consulta = consulta + " where libros.nombre like'%" + search + "%'";
                }
            }

            else if (option == "idBook")
            {
                if (String.IsNullOrEmpty(search))
                {
                    ViewBag.Msg = "Ingrese el id de libro";
                    return(View());
                }
                else
                {
                    consulta = consulta + " where libros.IdLibro = " + search;
                }
            }

            else
            { /*por si pinchan los values de los radio button*/
                ViewBag.Msg = "Error al recibir los value de los radio button";
                return(View());
            }

            return(View(ls.LibrosByQueryGet(consulta)));
        }
示例#7
0
        public ActionResult BajaLibro(int idLibro)
        {
            ViewBag.Message = "Your contact page.";
            Libro book = new Libro();

            book.IdLibro = idLibro;
            LibroService ls             = new LibroService();
            int          filasAfectadas = ls.DeleteBook(book);

            if (filasAfectadas > 0)
            {
                ViewBag.afectedRows = 1;
            }
            else
            {
                ViewBag.afectedRows = 0;
            }

            return(View());
        }
示例#8
0
        public ActionResult AltaLibro(int idLibro)
        {
            ViewBag.Message = "Your contact page.";
            LibroService ls   = new LibroService();
            Libro        book = new Libro();

            book        = ls.GetBook(idLibro);
            book.Estado = true;

            int filasAfectadas = ls.UpdateBook(book);

            if (filasAfectadas > 0)
            {
                ViewBag.afectedRows = 1;
            }
            else
            {
                ViewBag.afectedRows = 0;
            }

            return(View());
        }
示例#9
0
        //[HttpPost]
        public ActionResult EditarLibro(int idLibro)
        {
            LibroService ls   = new LibroService();
            Libro        book = new Libro();

            book = ls.GetBook(idLibro);

            /****************** VALIDANDO LADO BACK-END *********************************/

            /*nota: todos los TempData son creados en ActionResult Libroeditado();*/

            /*Aviso error de precio*/
            if (TempData["errorPrice"] != null)
            {
                ViewBag.Msg = "El precio no es valido!, si es un numero decimal use el punto decimal con un maximo de dos decimales ej: 1500.88";
                return(View(book));
            }

            /*Aviso si hay un error en el año del libro*/
            if (TempData["errorYear"] != null)
            {
                ViewBag.Msg = "El año no es valido!";
                return(View(book));
            }

            /*Aviso si el autor existe en la base de datos*/
            if (TempData["errorAutor"] != null)
            {
                ViewBag.Msg = "El autor no existe en la base de datos!";
                return(View(book));
            }

            if (TempData["errorCategory"] != null)
            {
                ViewBag.Msg = "La categoria no existe en la base de datos!";
                return(View(book));
            }

            if (TempData["errorEditorial"] != null)
            {
                ViewBag.Msg = "La editorial no existe en la base de datos!";
                return(View(book));
            }

            if (TempData["errorQuantity"] != null)
            {
                ViewBag.Msg = "La cantidad debe ser un numero entero";
                return(View(book));
            }

            /*Aviso si la img no se encuentra en la ruta especificada*/
            if (TempData["errorPathImg"] != null)
            {
                ViewBag.Msg = "Error. La imagen no se encuentra en la ruta especificada";
                return(View(book));
            }

            /*Aviso si el formato de img es incorrecto*/
            if (TempData["errorImg"] != null)
            {
                ViewBag.Msg = "Error. El formato de imagen no es correcto. Formatos permitidos .jpg, .png, .gif, .bmp";
                return(View(book));
            }

            /*Aviso error de precio*/
            if (TempData["errorPrice"] != null)
            {
                ViewBag.Msg = "El precio fue invalido!. No debe contener simbolos. Si el precio es decimal, use el punto decimal en vez de la coma.";
                return(View(book));
            }

            /******************* fin validaciones back-end ************************/


            return(View(book));
        }
示例#10
0
 public ActionResult EliminarAction(LibroViewModel lvm)
 {
     LibroService.remove(lvm.LibroId);
     return(volverAlListado());
 }
示例#11
0
 public LibroController(LibroService servicio)
 {
     _servicio = servicio;
 }
示例#12
0
 public LibrosController()
 {
     eS = new LibroServiceImp();
 }
示例#13
0
 public EditorialController()
 {
     edS = new EditorialServiceImp();
     eS  = new EjemplarServiceImp();
     lS  = new LibroServiceImp();
 }
示例#14
0
 public ActionResult Modificar(int LibroId)
 {
     return(View(LibroService.findById(LibroId)));
 }
示例#15
0
 public ActionResult Modificar(LibroViewModel lvm)
 {
     LibroService.update(lvm);
     return(volverAlListado());
 }
示例#16
0
 public ActionResult BuscarAutor(LibroViewModel lvm)
 {
     lvm.lista = LibroService.findLibroByAutor(lvm.autor);
     return(View(lvm));
 }
示例#17
0
 public ActionResult BuscarTitulo(LibroViewModel lvm)
 {
     lvm.lista = LibroService.findLibroByTitulo(lvm.titulo);
     return(View(lvm));
 }
示例#18
0
        public ActionResult LibroEditado(FormCollection form)
        {
            ViewBag.Message = "Your contact page.";
            String    ruta   = "principal/imagenes/";
            Libro     book   = new Libro();
            CheckData check  = new CheckData();
            int       idBook = Convert.ToInt32(form[0]);

            /****************** VALIDACIONES BACK-END ***********************/

            /*check length del año de lanzamiento solo cuatro numeros*/
            if (Request.Form["nbr_lanzamiento"].Length != 4)
            {
                TempData["errorYear"] = true;
                return(RedirectToAction("EditarLibro", new { idLibro = idBook }));
            }
            /*check que el año de lanzamiento sea solo numeros*/
            if (!check.CheckIntNumber(Request.Form["nbr_lanzamiento"]))
            {
                TempData["errorYear"] = true;
                return(RedirectToAction("EditarLibro", new { idLibro = idBook }));
            }

            /*check si existe el idAutor es un dato int*/
            if (!check.CheckIntNumber(Request.Form["ddlAutor"]))
            {
                TempData["errorAutor"] = true;
                return(RedirectToAction("EditarLibro", new { idLibro = idBook }));
            }
            /*check si el idAutor existe en la base de datos*/
            if (!check.CheckIdAutor(Request.Form["ddlAutor"]))
            {
                TempData["errorAutor"] = true;
                return(RedirectToAction("EditarLibro", new { idLibro = idBook }));
            }

            /*check si existe el idCategoria es un dato int*/
            if (!check.CheckIntNumber(Request.Form["ddlCategory"]))
            {
                TempData["errorCategory"] = true;
                return(RedirectToAction("EditarLibro", new { idLibro = idBook }));
            }
            /*check si el idCategory existe en la base de datos*/
            if (!check.CheckIdCategory(Request.Form["ddlCategory"]))
            {
                TempData["errorCategory"] = true;
                return(RedirectToAction("EditarLibro", new { idLibro = idBook }));
            }

            /*check si el idEditorial es un dato int*/
            if (!check.CheckIntNumber(Request.Form["ddlEditorial"]))
            {
                TempData["errorEditorial"] = true;
                return(RedirectToAction("EditarLibro", new { idLibro = idBook }));
            }
            /*check si el idEditorial existe en la base de datos*/
            if (!check.CheckIdEditorial(Request.Form["ddlEditorial"]))
            {
                TempData["errorEditorial"] = true;
                return(RedirectToAction("EditarLibro", new { idLibro = idBook }));
            }

            /*checking si la cantidad es un numero (si es null devuelve false)*/
            if (!check.CheckIntNumber(Request.Form["nbr_quantity"]))
            {
                TempData["errorQuantity"] = true;
                return(RedirectToAction("EditarLibro", new { idLibro = idBook }));
            }

            /*checking precio, tambien evalua si llega vacio*/
            if (!check.CheckPrice(Request.Form["txt_price"]))
            {
                TempData["errorPrice"] = true;
                return(RedirectToAction("EditarLibro", new { idLibro = idBook }));
            }

            /****************** fin validaciones back end ****************************/

            /*convierto el precio string en decimal*/
            String  precio = Request.Form["txt_price"];
            decimal price  = check.ConvertStringToDecimal(precio);

            book.IdLibro           = Convert.ToInt32(form[0]);
            book.Nombre            = form[1];
            book.AnioDeLanzamiento = Convert.ToInt32(form[2]);
            book.IdAutor           = Convert.ToInt32(form[3]);
            book.IdCategoria       = Convert.ToInt32(form[4]);
            book.IdEditorial       = Convert.ToInt32(form[5]);
            /*Obtengo lo que se edito en el textarea llamado "description"*/
            book.Descripcion = Request.Form["description"];
            book.Cantidad    = Convert.ToInt32(form[7]);
            book.Precio      = price;

            if (Request.Form["itf_urlImage"].Equals(""))
            {
                book.UrlImagen = Request.Form["txt_urlImage"];
            }
            else
            {
                book.UrlImagen = ruta + Request.Form["itf_urlImage"];
            }


            book.Estado = true;

            LibroService ls = new LibroService();
            int          filasAfectadas;

            filasAfectadas = ls.UpdateBook(book);

            if (filasAfectadas > 0)
            {
                ViewBag.Filas = 1;
            }
            else
            {
                ViewBag.Filas = 0;
            }

            return(View());
        }
示例#19
0
 public ActionResult NuevoLibro(LibroViewModel lvm)
 {
     LibroService.add(lvm);
     return(volverAlListado());
 }
示例#20
0
        public ActionResult LibroInsertado()
        {
            ViewBag.Message = "Your contact page.";
            String    ruta  = "principal/imagenes/";
            Libro     book  = new Libro();
            CheckData check = new CheckData();

            /****************** VALIDACIONES BACK-END ***********************/

            /*check length del año de lanzamiento solo cuatro numeros*/
            if (Request.Form["nbr_lanzamiento"].Length != 4)
            {
                TempData["errorYear"] = true;
                return(RedirectToAction("InsertarLibro"));
            }
            /*check que el año de lanzamiento sea solo numeros*/
            if (!check.CheckIntNumber(Request.Form["nbr_lanzamiento"]))
            {
                TempData["errorYear"] = true;
                return(RedirectToAction("InsertarLibro"));
            }

            /*check si existe el idAutor es un dato int*/
            if (!check.CheckIntNumber(Request.Form["ddlAutor"]))
            {
                TempData["errorAutor"] = true;
                return(RedirectToAction("InsertarLibro"));
            }
            /*check si el idAutor existe en la base de datos*/
            if (!check.CheckIdAutor(Request.Form["ddlAutor"]))
            {
                TempData["errorAutor"] = true;
                return(RedirectToAction("InsertarLibro"));
            }

            /*check si existe el idCategoria es un dato int*/
            if (!check.CheckIntNumber(Request.Form["ddlCategory"]))
            {
                TempData["errorCategory"] = true;
                return(RedirectToAction("InsertarLibro"));
            }
            /*check si el idCategory existe en la base de datos*/
            if (!check.CheckIdCategory(Request.Form["ddlCategory"]))
            {
                TempData["errorCategory"] = true;
                return(RedirectToAction("InsertarLibro"));
            }

            /*check si el idEditorial es un dato int*/
            if (!check.CheckIntNumber(Request.Form["ddlEditorial"]))
            {
                TempData["errorEditorial"] = true;
                return(RedirectToAction("InsertarLibro"));
            }
            /*check si el idEditorial existe en la base de datos*/
            if (!check.CheckIdEditorial(Request.Form["ddlEditorial"]))
            {
                TempData["errorEditorial"] = true;
                return(RedirectToAction("InsertarLibro"));
            }
            /*checking precio, tambien evalua si llega vacio*/
            if (!check.CheckPrice(Request.Form["txt_price"]))
            {
                TempData["errorPrice"] = true;
                return(RedirectToAction("InsertarLibro"));
            }
            /*checking si la cantidad es un numero (si es null devuelve false)*/
            if (!check.CheckIntNumber(Request.Form["nbr_quantity"]))
            {
                TempData["errorQuantity"] = true;
                return(RedirectToAction("InsertarLibro"));
            }

            /*convierto el precio string en decimal*/
            String  precio = Request.Form["txt_price"];
            decimal price  = check.ConvertStringToDecimal(precio);

            /*para la descripcion no hago check*/

            /*pregunto si se recibió null como imagen*/
            String imagen = Request.Form["itf_urlImage"];

            if (imagen != "")
            {
                /*check formato de imagen jpg, png, gif, bmp*/
                if (!check.checkImageFormat(ruta + Request.Form["itf_urlImage"]))
                {
                    TempData["errorImg"] = true;
                    return(RedirectToAction("InsertarLibro"));
                }
            }

            /*ckeck existencia del libro en la base de datos por idAutor y nombre de libro*/
            if (check.checkAutorAndBookName(Request.Form["txt_bookName"], Request.Form["ddlAutor"]))
            {
                TempData["duplicatedBook"] = true;
                return(RedirectToAction("InsertarLibro"));
            }


            /**************** fin validaciones back-end *********************/

            book.Nombre            = Request.Form["txt_bookName"];
            book.AnioDeLanzamiento = Convert.ToInt32(Request.Form["nbr_lanzamiento"]);
            book.IdAutor           = Convert.ToInt32(Request.Form["ddlAutor"]);
            book.IdCategoria       = Convert.ToInt32(Request.Form["ddlCategory"]);
            book.IdEditorial       = Convert.ToInt32(Request.Form["ddlEditorial"]);
            book.Descripcion       = Request.Form["txta_description"];
            book.Cantidad          = Convert.ToInt32(Request.Form["nbr_quantity"]);
            book.Precio            = price;

            /*Para obtener la ruta absoluta de la img Usar esto:
             * var nombreImagen = Request.Form["itf_urlImage"];
             * var path = Path.Combine(Server.MapPath("~/principal/imagenes/"), nombreImagen);
             * book.UrlImagen = path;
             */
            if (imagen == "")
            {
                book.UrlImagen = imagen;
            }
            else
            {
                book.UrlImagen = ruta + Request.Form["itf_urlImage"];
            }

            book.Estado = true;

            LibroService ls             = new LibroService();
            int          filasAfectadas = 0;

            filasAfectadas = ls.InsertBook(book);
            /*si filasAfectadas devuelve 1, es porque se pudo insertar en la base de datos*/
            if (filasAfectadas > 0)
            {
                ViewBag.Msg = 1;
            }
            else
            {
                ViewBag.Msg = 0;
            }

            return(View());
        }
示例#21
0
 public LibroController(LibroService libroService)
 {
     _libroService = libroService;
 }
 public LibroController()
 {
     ls = new LibroServiceImp();
     As = new AutorServiceImp();
 }
 public ClienteController(LibroService libroService, ILoggerManager logger)
 {
     _libroService = libroService;
     _logger       = logger;
 }
示例#24
0
 public AutorController()
 {
     aS = new AutorServiceImp();
     lS = new LibroServiceImp();
     eS = new EjemplarServiceImp();
 }
示例#25
0
 public ActionResult Eliminar(int LibroId)
 {
     return(View(LibroService.findById(LibroId)));
 }