public ActionResult Receive(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } PO_Header pO_Header = db.PO_Header.Find(id); if (pO_Header == null) { return(HttpNotFound()); } foreach (var detail in pO_Header.PO_Detail) { Stock stock = db.Stocks.Find(detail.Item_ID); if (stock != null) { stock.Qty = stock.Qty + detail.Qty; db.Entry(stock).State = EntityState.Modified; } } db.SaveChanges(); return(RedirectToAction("Index", "Stocks")); }
public ActionResult Create([Bind(Include = "Id,UserId,Comments,CreatedBy,CreatedDate,CustomerId,Discount,UpdatedBy,UpdatedDate")] Order_Master order_Master, List <Order_Details> order_Details) { if (ModelState.IsValid) { string UserId = System.Web.HttpContext.Current.User.Identity.Name; order_Master.CreatedBy = UserId; string ordNo = "Ord00000001"; int? max = (from o in db.Order_Master select(int?) o.Id).Max(); if (max == 0 || max == null) { max = 1; ordNo = max.ToString().PadLeft(5, '0'); ordNo = "ORD" + ordNo; } else { int?nextmax = max + 1; ordNo = nextmax.ToString().PadLeft(5, '0'); ordNo = "ORD" + ordNo;; } order_Master.Order_No = ordNo; order_Master.CreatedDate = DateTime.Now; db.Order_Master.Add(order_Master); db.SaveChanges(); int id = db.Order_Master.FirstOrDefault(s => s.Order_No == order_Master.Order_No).Id; int OrderLine = 1; foreach (var detail in order_Details) { detail.OrderId = id; detail.Order_Line = OrderLine; detail.CreatedBy = UserId; detail.CreatedDate = DateTime.Now; Stock stock = db.Stocks.Find(detail.StockId); if (stock != null) { stock.Qty = stock.Qty - detail.Quantity; if (stock.Qty < 0) { stock.Qty = 0; } db.Entry(stock).State = EntityState.Modified; } OrderLine++; } db.Order_Details.AddRange(order_Details); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(order_Master)); }
public ActionResult Edit(HttpPostedFileBase file, [Bind(Include = "Item_ID,Item_Name,Description,Unit,Cat_ID,Photo")] Item_Master item_Master) { if (ModelState.IsValid) { if (file != null) { file.InputStream.Read(new byte[file.ContentLength], 0, file.ContentLength); var filename = "Prod_" + DateTime.Now.Ticks.ToString() + ".jpg"; if (!string.IsNullOrEmpty(item_Master.Photo)) { filename = item_Master.Photo; } var filePath = Server.MapPath(FolderPath); string savedFileName = Path.Combine(filePath, filename); file.SaveAs(savedFileName); item_Master.Photo = savedFileName; } db.Entry(item_Master).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.Cat_ID = new SelectList(db.Item_Category, "Category_ID", "Cat_Name", item_Master.Cat_ID); ViewBag.Unit = new SelectList(db.UOMs, "Unit_ID", "Unit", item_Master.Unit); return(View(item_Master)); }
// GET: Notifications/Details/5 public ActionResult Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Notification notification = db.Notifications.Find(id); if (notification == null) { return(HttpNotFound()); } notification.Is_Read = true; db.Entry(notification).State = EntityState.Modified; db.SaveChanges(); return(View(notification)); }
public ActionResult Edit([Bind(Include = "Category_ID,Cat_Name,Description,Aprroval_Needed")] Item_Category item_Category) { if (ModelState.IsValid) { db.Entry(item_Category).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(item_Category)); }
public ActionResult Edit([Bind(Include = "Unit_ID,Unit,Description")] UOM uOM) { if (ModelState.IsValid) { db.Entry(uOM).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(uOM)); }
public ActionResult Edit([Bind(Include = "Item_ID,Item_Name,Description,Unit,Cat_ID,Photo")] Item_Master item_Master) { if (ModelState.IsValid) { db.Entry(item_Master).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.Cat_ID = new SelectList(db.Item_Category, "Category_ID", "Cat_Name", item_Master.Cat_ID); ViewBag.Unit = new SelectList(db.UOMs, "Unit_ID", "Unit", item_Master.Unit); return(View(item_Master)); }
public ActionResult Edit([Bind(Include = "LineItem_ID,Product_ID,Qty,Loc_ID,Price,WIP_Qty,Warranty_Expiry,Item_Expiry")] Stock stock) { if (ModelState.IsValid) { db.Entry(stock).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.Product_ID = new SelectList(db.Item_Master, "Item_ID", "Item_Name", stock.Product_ID); ViewBag.Loc_ID = new SelectList(db.Locations, "Loc_ID", "Location1", stock.Loc_ID); return(View(stock)); }