Example #1
0
        public ActionResult DeleteConfirmed(int id)
        {
            SuplyInvoice suplyInvoice = db.SuplyInvoice.Find(id);

            db.SuplyInvoice.Remove(suplyInvoice);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Example #2
0
        public ActionResult Cerrar(int Id)
        {
            SuplyInvoice suplyInvoice = db.SuplyInvoice.Find(Id);

            suplyInvoice.status = "0";

            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Example #3
0
 public ActionResult Edit([Bind(Include = "Id,Id_AccountingBook,Id_LatePayment,Date_Suply,TotalAmount,status")] SuplyInvoice suplyInvoice)
 {
     if (ModelState.IsValid)
     {
         db.Entry(suplyInvoice).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.Id_AccountingBook = new SelectList(db.AccoutingBook, "Id", "Name", suplyInvoice.Id_AccountingBook);
     ViewBag.Id_LatePayment    = new SelectList(db.LatePayment, "Id", "TypeIncrement", suplyInvoice.Id_LatePayment);
     return(View(suplyInvoice));
 }
Example #4
0
        // GET: SuplyInvoices/Delete/5
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            SuplyInvoice suplyInvoice = db.SuplyInvoice.Find(id);

            if (suplyInvoice == null)
            {
                return(HttpNotFound());
            }
            return(View(suplyInvoice));
        }
        // GET: SuplyProducts
        public ActionResult Index(int Id)
        {
            SuplyInvoice SI = db.SuplyInvoice.Find(Id);

            if (SI.status == "0")
            {
                return(RedirectToAction("Index", "SuplyInvoices"));
            }


            var suplyProduct = (from p in db.SuplyProduct where p.Id_SuplyInvoice == Id select p);

            ViewBag.Id = Id.ToString();
            return(View(suplyProduct.ToList()));
        }
Example #6
0
        // GET: SuplyInvoices/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            SuplyInvoice suplyInvoice = db.SuplyInvoice.Find(id);

            if (suplyInvoice == null)
            {
                return(HttpNotFound());
            }
            ViewBag.Id_AccountingBook = new SelectList(db.AccoutingBook, "Id", "Name", suplyInvoice.Id_AccountingBook);
            ViewBag.Id_LatePayment    = new SelectList(db.LatePayment, "Id", "TypeIncrement", suplyInvoice.Id_LatePayment);
            return(View(suplyInvoice));
        }
Example #7
0
        // GET: SuplyInvoices/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            SuplyInvoice suplyInvoice = db.SuplyInvoice.Find(id);

            if (suplyInvoice == null)
            {
                return(HttpNotFound());
            }

            var suplyProduct = (from p in db.SuplyProduct where p.Id_SuplyInvoice == id select p);

            ViewBag.Productos = suplyProduct.ToList();

            return(View(suplyInvoice));
        }
        public ActionResult Create(int Id, [Bind(Include = "Id,Id_SuplyInvoice,Id_Product,Quantity,UnitCost,TotalAmount")] SuplyProduct suplyProduct)
        {
            if (ModelState.IsValid)
            {
                suplyProduct.Id_SuplyInvoice = Id;
                suplyProduct.UnitCost        = (decimal)suplyProduct.TotalAmount / (decimal)suplyProduct.Quantity;

                db.SuplyProduct.Add(suplyProduct);
                db.SaveChanges();


                SuplyInvoice SI = db.SuplyInvoice.Find(Id);
                SI.TotalAmount = db.SuplyProduct.Where(t => t.Id_SuplyInvoice == Id).Select(i => i.TotalAmount).Sum();
                db.SaveChanges();

                return(RedirectToAction("Index", routeValues: new { Id = Id }));
            }

            return(RedirectToAction("Index", routeValues: new { Id = Id }));
        }
        public ActionResult DeleteConfirmed(int Id = 0, int Id2 = 0)
        {
            if (Id == 0 || Id2 == 0)
            {
                return(RedirectToAction("Index", "SuplyInvoices"));
            }



            SuplyProduct suplyProduct = db.SuplyProduct.Find(Id);

            db.SuplyProduct.Remove(suplyProduct);
            db.SaveChanges();
            SuplyInvoice SI = db.SuplyInvoice.Find(Id2);

            SI.TotalAmount = db.SuplyProduct.Where(t => t.Id_SuplyInvoice == Id).Select(i => i.TotalAmount).Sum();
            db.SaveChanges();



            return(RedirectToAction("Index", routeValues: new { Id = Id2 }));
        }