Ejemplo n.º 1
0
        public ActionResult DeleteConfirmed(int id)
        {
            MndStkIn mndStkIn = db.mndStkIns.Find(id);

            db.mndStkIns.Remove(mndStkIn);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Ejemplo n.º 2
0
 public ActionResult Edit([Bind(Include = "Id,MndId,MndName,OrderDate")] MndStkIn mndStkIn)
 {
     if (ModelState.IsValid)
     {
         db.Entry(mndStkIn).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(mndStkIn));
 }
Ejemplo n.º 3
0
        public ActionResult Create([Bind(Include = "Id,MndId,MndName,OrderDate")] MndStkIn mndStkIn)
        {
            if (ModelState.IsValid)
            {
                db.mndStkIns.Add(mndStkIn);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(mndStkIn));
        }
Ejemplo n.º 4
0
        // GET: MndStkIns/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            MndStkIn mndStkIn = db.mndStkIns.Find(id);

            if (mndStkIn == null)
            {
                return(HttpNotFound());
            }
            return(View(mndStkIn));
        }
Ejemplo n.º 5
0
        public JsonResult AddMndStockDetials(OrderViewModel orderViewModel)
        {
            bool status = true;

            var isValidModel = TryUpdateModel(orderViewModel);

            if (isValidModel)
            {
                using (ApplicationDbContext db = new ApplicationDbContext())
                {
                    var mndname = db.MND_TBLs.Find(orderViewModel.Cust_TBLId);

                    MndStkIn order = new MndStkIn()
                    {
                        OrderDate = System.DateTime.Now,
                        MndId     = orderViewModel.Cust_TBLId,
                        MndName   = mndname.MND_NAME
                    };

                    db.mndStkIns.Add(order);

                    if (db.SaveChanges() > 0)
                    {
                        int orderID = db.mndStkIns.Max(o => o.Id);

                        foreach (var item in orderViewModel.Items)
                        {
                            MainStore orderDetails = new MainStore()
                            {
                                MndStkInId     = orderID,
                                Product_TbleId = item.ProductID,
                                Price          = item.Price,
                                QtyOut         = item.Quantity,
                                QtyIn          = 0,
                                Date           = DateTime.Now,
                                Amount         = item.TotalPrice
                            };
                            Stock stock = new Stock()
                            {
                                Prod_Id = item.ProductID,
                                MndId   = mndname.Id,
                                StQty   = item.Quantity,
                                Date    = DateTime.Now,
                                Case    = "منصرف لمندوب",
                                Cust_Id = 0
                            };

                            var stck = db.product_Tbles.Where(p => p.Id == item.ProductID).FirstOrDefault();
                            stck.SQty = stck.SQty - item.Quantity;
                            db.mainStores.Add(orderDetails);
                            db.stocks.Add(stock);
                        }

                        if (db.SaveChanges() > 0)
                        {
                            return(new JsonResult {
                                Data = new { status = status, message = "Order Added Successfully" }
                            });
                        }
                    }
                }
            }

            status = false;
            return(new JsonResult {
                Data = new { status = status, message = "Error !" }
            });
        }