示例#1
0
        public ActionResult Index()
        {
            using (var DB = new LibreriaDB())
            {
                DB.Configuration.LazyLoadingEnabled = false;
                var Car = DB.Carrito.Include("Producto").Where(P => P.SessionID == Session.SessionID & P.Transaccion == true & P.Activo == true).ToList();

                List <SelectListItem> Productos = new List <SelectListItem>();
                Productos.Add(new SelectListItem()
                {
                    Value    = "0",
                    Text     = "Seleccione un producto",
                    Selected = true
                });
                foreach (var Item in DB.PROListarProductos().ToList())
                {
                    Productos.Add(new SelectListItem()
                    {
                        Value    = Item.IdProducto.ToString(),
                        Text     = Item.Nombre,
                        Selected = false
                    });
                }

                ViewData["Productos"] = Productos;
                ViewData["Totales"]   = Car.Sum(P => P.CostoTotal).ToString("#,#0.00");
                return(View(Car));
            }
        }
示例#2
0
        public ActionResult Editar(short id)
        {
            using (var DB = new LibreriaDB())
            {
                var St = DB.Stock.SingleOrDefault(P => P.IdStock == id);

                List <SelectListItem> Proveedores = new List <SelectListItem>();
                foreach (var Item in DB.Proveedor.OrderBy(P => P.Nombre).ToList())
                {
                    Proveedores.Add(new SelectListItem()
                    {
                        Value    = Item.IdProveedor.ToString(),
                        Text     = Item.Nombre,
                        Selected = Item.IdProveedor == St.IdProveedor ? true : false
                    });
                }
                List <SelectListItem> Productos = new List <SelectListItem>();
                foreach (var Item in DB.Producto.OrderBy(P => P.Nombre).ToList())
                {
                    Productos.Add(new SelectListItem()
                    {
                        Value    = Item.IdProducto.ToString(),
                        Text     = Item.Nombre,
                        Selected = Item.IdProducto == St.IdProducto ? true : false
                    });
                }
                ViewData["Proveedores"] = Proveedores;
                ViewData["Productos"]   = Productos;

                return(PartialView(St));
            }
        }
示例#3
0
        public ActionResult Agregar(short id)
        {
            using (var DB = new LibreriaDB())
            {
                var     Pro = DB.PROObtenerProductoStock(id).SingleOrDefault();
                Carrito Car = new Carrito();
                Car.SessionID   = Session.SessionID;
                Car.IdProducto  = Pro.IdProducto;
                Car.Cantidad    = 1;
                Car.CostoUnidad = (decimal)Pro.Cobrar;
                Car.CostoTotal  = Car.Cantidad * Car.CostoUnidad;
                Car.FechaREG    = DateTime.Now;
                Car.Transaccion = false;
                Car.Activo      = true;

                DB.Carrito.Add(Car);

                DB.SaveChanges();


                DB.Configuration.LazyLoadingEnabled = false;

                var Cars = DB.Carrito.Include("Producto").Where(P => P.SessionID == Session.SessionID).ToList();

                return(View("Index", Cars));
            }
        }
示例#4
0
        //Vista Pacial -- PartialView
        public ActionResult Editar(short id)
        {
            using (var DB = new LibreriaDB())
            {
                var Rols = DB.Rol.OrderBy(P => P.Nombre).ToList();
                var Per  = DB.Sujeto.SingleOrDefault(P => P.IdSujeto == id);
                var Usu  = DB.Usuario.FirstOrDefault(P => P.IdSujeto == Per.IdSujeto);
                var RR   = DB.RolUsuario.FirstOrDefault(P => P.IdUsuario == Usu.IdUsuario);
                List <SelectListItem> Roles = new List <SelectListItem>();
                foreach (var Item in Rols)
                {
                    Roles.Add(new SelectListItem()
                    {
                        Value    = Item.IdRol.ToString(),
                        Text     = Item.Nombre,
                        Selected = Item.IdRol == RR.IdRol ? true : false
                    });
                }
                ViewData["Roles"] = Roles;
                ViewData["Login"] = Usu.Login;
                ViewData["Pwd"]   = Usu.Pwd;

                return(PartialView(Per));
            }
        }
        public ActionResult Agregar(FormCollection Col)
        {
            if (Col.Count > 0)
            {
                Proveedor Pro = new Proveedor();
                Pro.Nombre    = Col["txtNombre"];
                Pro.NIT       = Col["txtNit"];
                Pro.Telefonos = Col["txtTelefonos"];
                Pro.Contacto  = Col["txtContacto"];
                Pro.Activo    = true;

                using (var DB = new LibreriaDB())
                {
                    DB.Proveedor.Add(Pro);
                    DB.SaveChanges();

                    var Provs = DB.Proveedor.OrderBy(P => P.Nombre).ToList();

                    return(Redirect("/Libreria/proveedor/"));
                    //return View("Index", Provs);
                }
            }
            else
            {
                return(HttpNotFound());
            }
        }
示例#6
0
        public ActionResult Agregar()
        {
            using (var DB = new LibreriaDB())
            {
                List <SelectListItem> Productos = new List <SelectListItem>();
                Productos.Add(new SelectListItem()
                {
                    Value    = "0",
                    Text     = "Seleccione Producto",
                    Selected = true
                });

                foreach (var Item in DB.Producto.OrderBy(P => P.Nombre).ToList())
                {
                    Productos.Add(new SelectListItem()
                    {
                        Value    = Item.IdProducto.ToString(),
                        Text     = Item.Nombre,
                        Selected = false
                    });
                }

                ViewData["Productos"] = Productos;

                return(PartialView());
            }
        }
示例#7
0
        public ActionResult Agregar(FormCollection Col)
        {
            if (Col.Count > 0)
            {
                using (var DB = new LibreriaDB())
                {
                    Descuento Des = new Descuento();
                    Des.IdProducto = short.Parse(Col["IdProducto"]);
                    Des.Porcentaje = decimal.Parse(Col["txtPorcentaje"]);
                    Des.FechaIni   = DateTime.Parse(Col["txtIni"]);
                    Des.FechaFin   = DateTime.Parse(Col["txtFin"]);
                    Des.Activo     = true;
                    DB.Descuento.Add(Des);
                    DB.SaveChanges();

                    DB.Configuration.LazyLoadingEnabled = false;
                    var Dess = DB.Descuento.Include("Producto").OrderByDescending(P => P.FechaFin).ToList();

                    return(Redirect("/Libreria/promo/"));
                }
            }
            else
            {
                return(HttpNotFound());
            }
        }
 public ActionResult Agregar(FormCollection Col, HttpPostedFileBase txtFoto)
 {
     if (Col.Count > 0)
     {
         using (var DB = new LibreriaDB())
         {
             Producto Pro = new Producto();
             Pro.IdCategoria = short.Parse(Col["IdCategoria"]);
             Pro.Nombre      = Col["txtNombre"];
             Pro.Descripcion = Col["txtDescripcion"];
             Pro.Codigo      = Col["txtCodigo"];
             Pro.Activo      = true;
             if (txtFoto != null)
             {
                 //cargar fotos
                 string ruta = Server.MapPath("~/Content/productimg/");
                 txtFoto.SaveAs(ruta + System.IO.Path.GetFileName(txtFoto.FileName));
                 Pro.Foto = "~/Content/productimg/" + System.IO.Path.GetFileName(txtFoto.FileName);
             }
             else
             {
                 Pro.Foto = null;
             }
             DB.Producto.Add(Pro);
             DB.SaveChanges();
             var Pros = DB.Producto.Include("Categoria").OrderBy(P => P.Nombre);
             return(Redirect("/Libreria/producto/"));
         }
     }
     else
     {
         return(HttpNotFound());
     }
 }
 public ActionResult Agregar()
 {
     using (var DB = new LibreriaDB())
     {
         var Cat = DB.Categoria.OrderBy(P => P.Nombre).ToList();
         return(PartialView(Cat));
     }
 }
示例#10
0
 public ActionResult Index()
 {//Se obtienen los datos para pasarlos a la vista.
     using (var DB = new LibreriaDB())
     {
         var Per = DB.PROListarUsuarios().ToList();
         return(View(Per));
     }
 }
 public override bool ValidateUser(string username, string password)
 {
     //Coneccion con la base de datos.
     using (var DB = new LibreriaDB())
     {
         return(DB.PROAutenticar(username, password, 1).Any());
     }
 }
示例#12
0
        public JsonResult GetProductCode(int id)
        {
            var DB        = new LibreriaDB();
            var allsearch = DB.Producto.Where(p => p.Codigo.Equals(id)).Select(p => new { p.IdProducto, p.Nombre }).ToList();

            return(new JsonResult {
                Data = allsearch, JsonRequestBehavior = JsonRequestBehavior.AllowGet
            });
        }
示例#13
0
        public ActionResult Promos()
        {
            using (var DB = new LibreriaDB())
            {
                var Promos = DB.PROListarPromociones().ToList();

                return(View(Promos));
            }
        }
示例#14
0
 public ActionResult Index()
 {
     using (var DB = new LibreriaDB())
     {
         DB.Configuration.LazyLoadingEnabled = false;
         var Pro = DB.Producto.Include("Categoria").OrderBy(P => P.Nombre);
         return(View(Pro.ToList()));
     }
 }
示例#15
0
 public ActionResult Index()
 {
     using (var DB = new LibreriaDB())
     {
         DB.Configuration.LazyLoadingEnabled = false;
         var Des = DB.Descuento.Include("Producto").OrderByDescending(P => P.FechaFin).ToList();
         return(View(Des));
     }
 }
示例#16
0
        public JsonResult GetSearchValueCode(string search)
        {
            var DB        = new LibreriaDB();
            var allsearch = DB.Producto.Where(p => p.Codigo.Contains(search) || p.Nombre.Contains(search)).Select(p => new { p.IdProducto, p.Codigo, p.Nombre }).ToList();

            return(new JsonResult {
                Data = allsearch, JsonRequestBehavior = JsonRequestBehavior.AllowGet
            });
        }
示例#17
0
        // GET: Carrito
        public ActionResult Index()
        {
            using (var DB = new LibreriaDB())
            {
                DB.Configuration.LazyLoadingEnabled = false;
                var Car = DB.Carrito.Include("Producto").Where(P => P.SessionID == Session.SessionID).ToList();

                return(View(Car));
            }
        }
示例#18
0
 public ActionResult Eliminar(decimal id)
 {
     using (var DB = new LibreriaDB())
     {
         var Car = DB.Carrito.SingleOrDefault(P => P.IdCarrito == id);
         DB.Carrito.Remove(Car);
         DB.SaveChanges();
         return(Content("OK"));
     }
 }
示例#19
0
        public ActionResult Editar(short id)
        {
            using (var DB = new LibreriaDB())
            {
                var Pro = DB.Proveedor.
                          SingleOrDefault(P => P.IdProveedor == id);

                return(PartialView(Pro));
            }
        }
示例#20
0
 public ActionResult Eliminar(short id)
 {
     using (var DB = new LibreriaDB())
     {
         Producto Pro = DB.Producto.SingleOrDefault(P => P.IdProducto == id);
         DB.Producto.Remove(Pro);
         DB.SaveChanges();
         var Prods = DB.Producto.OrderBy(P => P.Nombre).ToList();
         return(Redirect("/Libreria/producto/"));
     }
 }
示例#21
0
        public ActionResult Index()
        {
            using (var DB = new LibreriaDB())
            {
                DB.Configuration.LazyLoadingEnabled = false;
                var St = DB.Stock.Include("Producto");
                St.Include("Proveedor");

                return(View(St.ToList()));
            }
        }
示例#22
0
        public ActionResult Facturar()
        {
            using (var DB = new LibreriaDB())
            {
                DB.Configuration.LazyLoadingEnabled = false;
                var Car = DB.Carrito.Include("Producto").Where(P => P.SessionID == Session.SessionID & P.Transaccion == true & P.Activo == true).ToList();
                ViewData["Totales"] = Car.Sum(P => P.CostoTotal).ToString("#,#0.00");

                return(View(Car));
            }
        }
示例#23
0
        public ActionResult Eliminar(short id)
        {
            using (var DB = new LibreriaDB())
            {
                Stock obj = DB.Stock.SingleOrDefault(U => U.IdStock == id);
                DB.Stock.Remove(obj);
                DB.SaveChanges();

                return(Redirect("/Libreria/stock/"));
            }
        }
示例#24
0
        public ActionResult Index()
        {
            using (var DB = new LibreriaDB())
            {
                var Promos = DB.PROListarPromociones().ToList();

                ViewData["ID"] = HttpContext.Session.SessionID;

                return(View(Promos));
            }
        }
示例#25
0
        public ActionResult Eliminar(short id)
        {
            using (var DB = new LibreriaDB())
            {
                Descuento obj = DB.Descuento.SingleOrDefault(U => U.IdDescuento == id);
                DB.Descuento.Remove(obj);
                DB.SaveChanges();

                return(Redirect("/Libreria/promo/"));
            }
        }
示例#26
0
        //[Route("editar/{id}/{cantidad}")]
        public ActionResult Editar(decimal id, short cantidad)
        {
            using (var DB = new LibreriaDB())
            {
                var Car = DB.Carrito.SingleOrDefault(P => P.IdCarrito == id);
                Car.Cantidad   = cantidad;
                Car.CostoTotal = Car.Cantidad * Car.CostoUnidad;
                DB.SaveChanges();

                return(Content("OK"));
            }
        }
示例#27
0
        public ActionResult Agregar(FormCollection Col)
        {
            if (Col.Count > 0)
            {
                using (var DB = new LibreriaDB())
                {
                    var Us = DB.Usuario.SingleOrDefault(P => P.Login == User.Identity.Name);

                    Stock St = new Stock();
                    St.IdSucursal     = 1;//se debe revisar para el tema de las sucursales.
                    St.IdProveedor    = short.Parse(Col["IdProveedor"]);
                    St.IdProducto     = short.Parse(Col["IdProducto"]);
                    St.Cantidad       = short.Parse(Col["txtCantidad"]);
                    St.PrecioUnitario = decimal.Parse(Col["txtPrecio"]);
                    St.CostoVenta     = decimal.Parse(Col["txtCosto"]);
                    try
                    {
                        if (Col["txtVencimiento"] != null)
                        {
                            St.FechaVencimiento = DateTime.Parse(Col["txtVencimiento"]);
                        }
                        else
                        {
                            St.FechaVencimiento = DateTime.Parse("31/12/2030");
                        }
                    }
                    catch (Exception)
                    {
                        St.FechaVencimiento = DateTime.Parse("31/12/2030");
                    }

                    St.IdUsuario = short.Parse(Us.IdSujeto.ToString());
                    St.FechaREG  = DateTime.Now;
                    St.Activo    = true;

                    DB.Stock.Add(St);
                    DB.SaveChanges();

                    //Muestra de nuevo la vista.
                    DB.Configuration.LazyLoadingEnabled = false;

                    var Sts = DB.Stock.Include("Producto");
                    Sts.Include("Proveedor");

                    return(Redirect("/Libreria/stock/"));
                }
            }
            else
            {
                return(HttpNotFound());
            }
        }
示例#28
0
        public ActionResult Pedido()
        {
            using (var DB = new LibreriaDB())
            {
                DB.Configuration.LazyLoadingEnabled = false;
                var Car = DB.Carrito.Include("Producto").Where(P => P.SessionID == Session.SessionID).ToList();

                var Totales = Car.Sum(P => P.CostoTotal).ToString("#,#0.00");
                ViewData["Totales"] = Totales;

                return(View(Car));
            }
        }
示例#29
0
        public ActionResult Cancelar()
        {
            using (var DB = new LibreriaDB())
            {
                var lista = (from cc in DB.Carrito where cc.Activo == true select cc);
                foreach (Carrito carrito in lista.ToList())
                {
                    carrito.Activo = false;
                    DB.SaveChanges();
                }

                return(Content("OK"));
            }
        }
示例#30
0
 public short ObtenerRol(string Name)
 {
     using (var DB = new LibreriaDB())
     {
         var Us = DB.Usuario.Include("RolUsuario").SingleOrDefault(P => P.Login == Name);
         if (Us != null)
         {
             return((short)Us.RolUsuario.FirstOrDefault(P => P.Activo == true).IdRol);
         }
         else
         {
             return(0);
         }
     }
 }