public ActionResult DeleteConfirmed(int id) { tblLeftPage tblLeftPage = db.tblLeftPages.Find(id); db.tblLeftPages.Remove(tblLeftPage); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Edit([Bind(Include = "PageId,ReceiveingInfo,ReceivingSerial,ReceivingDate,PreviousBalance,NoOfReceivingArticles,TotalBalance,SectorId,InventoryId,VoucharId")] tblLeftPage tblLeftPage) { if (ModelState.IsValid) { db.Entry(tblLeftPage).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("IndexWithSectorAndInventoryId", new { sectorId = tblLeftPage.SectorId, inventoryId = tblLeftPage.InventoryId })); } ViewBag.InventoryId = new SelectList(db.tblInventories, "InventoryId", "InventoryName", tblLeftPage.InventoryId); ViewBag.SectorId = new SelectList(db.tblSectors, "SectorId", "SectorName", tblLeftPage.SectorId); ViewBag.VoucharId = new SelectList(db.tblVouchars, "VoucharId", "VoucharFilePath", tblLeftPage.VoucharId); return(View(tblLeftPage)); }
public ActionResult CreateWithSectorAndInventoryId([Bind(Include = "PageId,ReceiveingInfo,ReceivingSerial,ReceivingDate,PreviousBalance,NoOfReceivingArticles,TotalBalance,SectorId,InventoryId,VoucharId")] tblLeftPage tblLeftPage) { //tblSector sector = db.tblSectors.Find(sectorId); // tblInventory inventory = db.tblInventories.Find(inventoryId); if (ModelState.IsValid) { List <tblItem> items = db.tblItems.ToList(); List <tblLeftPage> leftPages = db.tblLeftPages.ToList(); // count items which are not picked int count = 0; foreach (var item in items) { if (item.SectorId == tblLeftPage.SectorId && item.InventoryId == tblLeftPage.InventoryId && item.IsPicked == 0) { count++; } } tblLeftPage.PreviousBalance = count; // count revceiving serial int receive = 0; foreach (var item in leftPages) { if (item.SectorId == tblLeftPage.SectorId && item.InventoryId == tblLeftPage.InventoryId) { receive++; } } receive++; tblLeftPage.ReceivingSerial = receive; // set date tblLeftPage.ReceivingDate = DateTime.Now; //set total balance tblLeftPage.TotalBalance = count + tblLeftPage.NoOfReceivingArticles; db.tblLeftPages.Add(tblLeftPage); db.SaveChanges(); return(RedirectToAction("CreateItem", "Items", new { sectorId = tblLeftPage.SectorId, inventoryId = tblLeftPage.InventoryId })); } ViewBag.InventoryId = new SelectList(db.tblInventories, "InventoryId", "InventoryName", tblLeftPage.InventoryId); ViewBag.SectorId = new SelectList(db.tblSectors, "SectorId", "SectorName", tblLeftPage.SectorId); ViewBag.VoucharId = new SelectList(db.tblVouchars, "VoucharId", "VoucharFilePath", tblLeftPage.VoucharId); return(View(tblLeftPage)); }
// GET: LeftPages/Delete/5 public ActionResult Delete(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } tblLeftPage tblLeftPage = db.tblLeftPages.Find(id); if (tblLeftPage == null) { return(HttpNotFound()); } return(View(tblLeftPage)); }
public ActionResult Create([Bind(Include = "PageId,ReceiveingInfo,ReceivingSerial,ReceivingDate,PreviousBalance,NoOfReceivingArticles,TotalBalance,SectorId,InventoryId,VoucharId")] tblLeftPage tblLeftPage) { if (ModelState.IsValid) { db.tblLeftPages.Add(tblLeftPage); db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.InventoryId = new SelectList(db.tblInventories, "InventoryId", "InventoryName", tblLeftPage.InventoryId); ViewBag.SectorId = new SelectList(db.tblSectors, "SectorId", "SectorName", tblLeftPage.SectorId); ViewBag.VoucharId = new SelectList(db.tblVouchars, "VoucharId", "VoucharFilePath", tblLeftPage.VoucharId); return(View(tblLeftPage)); }
// GET: LeftPages/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } tblLeftPage tblLeftPage = db.tblLeftPages.Find(id); if (tblLeftPage == null) { return(HttpNotFound()); } ViewBag.InventoryId = new SelectList(db.tblInventories, "InventoryId", "InventoryName", tblLeftPage.InventoryId); ViewBag.SectorId = new SelectList(db.tblSectors, "SectorId", "SectorName", tblLeftPage.SectorId); ViewBag.VoucharId = new SelectList(db.tblVouchars, "VoucharId", "VoucharFilePath", tblLeftPage.VoucharId); return(View(tblLeftPage)); }