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)); } }
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)); } }
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)); } }
//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()); } }
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()); } }
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)); } }
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()); } }
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 }); }
public ActionResult Promos() { using (var DB = new LibreriaDB()) { var Promos = DB.PROListarPromociones().ToList(); return(View(Promos)); } }
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())); } }
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)); } }
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 }); }
// 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)); } }
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")); } }
public ActionResult Editar(short id) { using (var DB = new LibreriaDB()) { var Pro = DB.Proveedor. SingleOrDefault(P => P.IdProveedor == id); return(PartialView(Pro)); } }
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/")); } }
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())); } }
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)); } }
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/")); } }
public ActionResult Index() { using (var DB = new LibreriaDB()) { var Promos = DB.PROListarPromociones().ToList(); ViewData["ID"] = HttpContext.Session.SessionID; return(View(Promos)); } }
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/")); } }
//[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")); } }
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()); } }
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)); } }
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")); } }
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); } } }