public ActionResult Edit([Bind(Include = "ID_PRODUCTO,DESCRIPCION,PRECIO,IVA,IEPS,U_MEDIDA,CLAVE_SAT,FECHA_ALTA,ESTATUS,ULTIM_PRECIO_COMPRA")] TBL_PRODUCTOS tBL_PRODUCTOS)
 {
     if (ModelState.IsValid)
     {
         db.Entry(tBL_PRODUCTOS).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(tBL_PRODUCTOS));
 }
Example #2
0
 public ActionResult Edit([Bind(Include = "ID_SUCURSAL,FECHA_REGISTRO_SUCURSAL,ID_USER_ASP,NOM_SUCURSAL,PAIS,ESTADO,CALLE,NUMERO,COLONIA,CP,ESTATUS,TELEFONO")] TBL_SUCURSALES tBL_SUCURSALES)
 {
     if (ModelState.IsValid)
     {
         db.Entry(tBL_SUCURSALES).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(tBL_SUCURSALES));
 }
Example #3
0
 public ActionResult Edit([Bind(Include = "ID_LOTE,COSTO_PRODUCCION,FECHA_PRODUC,FECHA_REGISTRO,ID_PRODUC,ABIERTO,ID_USU")] TBL_LOTE_PRODUCCION tBL_LOTE_PRODUCCION)
 {
     if (ModelState.IsValid)
     {
         db.Entry(tBL_LOTE_PRODUCCION).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.ID_PRODUC = new SelectList(db.TBL_PRODUCTOS, "ID_PRODUCTO", "DESCRIPCION", tBL_LOTE_PRODUCCION.ID_PRODUC);
     return(View(tBL_LOTE_PRODUCCION));
 }
Example #4
0
        public ActionResult Edit([Bind(Include = "ID_DETALLE,CANTIDAD")] TBL_DETALLE_LOTE tBL_DETALLE_LOTE)
        {
            var original = db.TBL_DETALLE_LOTE.AsNoTracking().Where(x => x.ID_DETALLE == tBL_DETALLE_LOTE.ID_DETALLE).ToList();

            if (original.Count > 0)
            {
                tBL_DETALLE_LOTE.ID_LOTE        = original[0].ID_LOTE;
                tBL_DETALLE_LOTE.FECHA_REGISTRO = DateTime.Now;
                tBL_DETALLE_LOTE.DISPONIBLE     = false;
                tBL_DETALLE_LOTE.VEDIDOS        = original[0].VEDIDOS;
                tBL_DETALLE_LOTE.ID_USER_ASP    = HttpContext.User.Identity.Name;
                //tBL_DETALLE_LOTE.TBL_LOTE_PRODUCCION = original[0].TBL_LOTE_PRODUCCION;

                if (ModelState.IsValid)
                {
                    db.Entry(tBL_DETALLE_LOTE).State = EntityState.Modified;
                    //se general carga la entrada de mercancia en la tabla STOCK
                    var    idProducto    = (db.TBL_LOTE_PRODUCCION.AsNoTracking().Where(x => x.ID_LOTE == tBL_DETALLE_LOTE.ID_LOTE).Select(x => x.ID_PRODUC).ToList());
                    int    idAlmacen     = 2;
                    string produc        = idProducto[0];
                    var    originalStock = (db.TBL_STOCK.Where(x => x.ID_PRODUC.Equals(produc)).Where(x => x.ID_ALMAC == idAlmacen)).ToList();

                    if (originalStock.Count == 0)
                    {
                        TBL_STOCK nuevoStock = new TBL_STOCK()
                        {
                            ID_PRODUC = produc, ID_ALMAC = idAlmacen, STOCK = tBL_DETALLE_LOTE.CANTIDAD, PEDIDO = 0, COMPROMETIDO = 0, ULTIMA_FECHA_ACTUALIZACION = DateTime.Now
                        };
                        db.TBL_STOCK.Add(nuevoStock);
                        db.SaveChanges();
                    }
                    else if (originalStock.Count == 1)
                    {
                        originalStock[0].STOCK += tBL_DETALLE_LOTE.CANTIDAD;
                        //db.Entry(originalStock[0]).State = EntityState.Modified;
                        db.SaveChanges();
                    }
                    else
                    {
                        TempData["Mensaje"] = "<div class=\"alert alert-danger\"><button type=\"button\" class=\"close\" data-dismiss=\"alert\">&times;</button><strong>No se pudo generar STOCK, favor de intentarlo de nuevo..</strong> </div>";
                        return(RedirectToAction("Index", "Lote"));
                    }

                    TempData["Mensaje"] = "<div class=\"alert alert-success\"><button type=\"button\" class=\"close\" data-dismiss=\"alert\">&times;</button><strong>STOCK del LOTE generado exitosamente.</strong> </div>";
                    return(RedirectToAction("Index", "Lote"));
                }
                TempData["Mensaje"] = "<div class=\"alert alert-danger\"><button type=\"button\" class=\"close\" data-dismiss=\"alert\">&times;</button><strong>No se pudo generar STOCK, favor de intentarlo de nuevo.</strong> </div>";
                return(RedirectToAction("Index", "Lote"));
            }
            return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
        }
Example #5
0
        public ActionResult Create([Bind(Include = "ID_PRODUC,STOCK,ID_ALMAC")] TBL_STOCK tBL_STOCK)
        {
            List <string> id_product = db.TBL_PRODUCTOS.Where(x => x.DESCRIPCION.Equals(tBL_STOCK.ID_PRODUC)).Where(x => x.ESTATUS == true).Select(x => x.ID_PRODUCTO).ToList();

            if (id_product.Count == 1)
            {
                if (tBL_STOCK.STOCK == null)
                {
                    ViewBag.ID_ALMAC  = new SelectList(db.TBL_ALMACENES, "ID_ALMACEN", "NOM_ALMACEN", tBL_STOCK.ID_ALMAC);
                    ViewBag.ID_PRODUC = new SelectList(db.TBL_PRODUCTOS, "ID_PRODUCTO", "DESCRIPCION", tBL_STOCK.ID_PRODUC);
                    ViewBag.Confirma  = "<div class=\"alert alert-danger\"><button type=\"button\" class=\"close\" data-dismiss=\"alert\">&times;</button><strong>El STOCK no fue ingresado.</strong> </div>";
                    return(View(tBL_STOCK));
                }
                tBL_STOCK.ID_PRODUC = id_product.ToArray()[0];
                var valida = db.TBL_STOCK.AsNoTracking().Where(x => x.ID_PRODUC.Equals(tBL_STOCK.ID_PRODUC)).Where(x => x.ID_ALMAC.Equals(tBL_STOCK.ID_ALMAC)).ToList();

                if (valida.Count() == 0 && valida != null)
                {
                    tBL_STOCK.COMPROMETIDO = 0;
                    tBL_STOCK.PEDIDO       = 0;
                    tBL_STOCK.ULTIMA_FECHA_ACTUALIZACION = DateTime.Now;
                    if (ModelState.IsValid)
                    {
                        db.TBL_STOCK.Add(tBL_STOCK);
                        db.SaveChanges();
                        ViewBag.ID_ALMAC  = new SelectList(db.TBL_ALMACENES, "ID_ALMACEN", "NOM_ALMACEN", tBL_STOCK.ID_ALMAC);
                        ViewBag.ID_PRODUC = new SelectList(db.TBL_PRODUCTOS, "ID_PRODUCTO", "DESCRIPCION", tBL_STOCK.ID_PRODUC);
                        ViewBag.Confirma  = "<div class=\"alert alert-success\"><button type=\"button\" class=\"close\" data-dismiss=\"alert\">&times;</button><strong>Stock GENERADO exitosamente.</strong> </div>";
                        return(View(tBL_STOCK));
                    }
                }
                else if (valida.Count() == 1)
                {
                    tBL_STOCK.COMPROMETIDO = 0;
                    tBL_STOCK.PEDIDO       = 0;
                    tBL_STOCK.ID_ALMAC     = (int)valida[0].ID_ALMAC;
                    tBL_STOCK.ID_PRODUC    = valida[0].ID_PRODUC.ToString();
                    tBL_STOCK.ULTIMA_FECHA_ACTUALIZACION = DateTime.Now;
                    tBL_STOCK.STOCK    = tBL_STOCK.STOCK + (int)valida[0].STOCK;
                    tBL_STOCK.ID_STOCK = (int)valida[0].ID_STOCK;

                    db.Entry(tBL_STOCK).State = EntityState.Modified;
                    db.SaveChanges();

                    ViewBag.ID_ALMAC  = new SelectList(db.TBL_ALMACENES, "ID_ALMACEN", "NOM_ALMACEN", tBL_STOCK.ID_ALMAC);
                    ViewBag.ID_PRODUC = new SelectList(db.TBL_PRODUCTOS, "ID_PRODUCTO", "DESCRIPCION", tBL_STOCK.ID_PRODUC);
                    ViewBag.Confirma  = "<div class=\"alert alert-success\"><button type=\"button\" class=\"close\" data-dismiss=\"alert\">&times;</button><strong>Stock AGREGADO exitosamente.</strong> </div>";
                    return(View(tBL_STOCK));
                }
                else
                {
                    ViewBag.ID_ALMAC  = new SelectList(db.TBL_ALMACENES, "ID_ALMACEN", "NOM_ALMACEN", tBL_STOCK.ID_ALMAC);
                    ViewBag.ID_PRODUC = new SelectList(db.TBL_PRODUCTOS, "ID_PRODUCTO", "DESCRIPCION", tBL_STOCK.ID_PRODUC);
                    ViewBag.Confirma  = "<div class=\"alert alert-danger\"><button type=\"button\" class=\"close\" data-dismiss=\"alert\">&times;</button><strong>Error al procesar la solicitud.</strong> </div>";
                    return(View(tBL_STOCK));
                }
            }
            ViewBag.ID_ALMAC  = new SelectList(db.TBL_ALMACENES, "ID_ALMACEN", "NOM_ALMACEN", tBL_STOCK.ID_ALMAC);
            ViewBag.ID_PRODUC = new SelectList(db.TBL_PRODUCTOS, "ID_PRODUCTO", "DESCRIPCION", tBL_STOCK.ID_PRODUC);
            ViewBag.Confirma  = "<div class=\"alert alert-danger\"><button type=\"button\" class=\"close\" data-dismiss=\"alert\">&times;</button><strong>El producto no existe en la base de datos.</strong> </div>";
            return(View(tBL_STOCK));
        }