public ActionResult DeleteConfirmed(int id) { Rsal_tbl rsal_tbl = db.rsal_Tbls.Find(id); db.rsal_Tbls.Remove(rsal_tbl); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Edit([Bind(Include = "Id,Cust_Id,Cust_Name,OrderDate")] Rsal_tbl rsal_tbl) { if (ModelState.IsValid) { db.Entry(rsal_tbl).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(rsal_tbl)); }
public ActionResult Create([Bind(Include = "Id,Cust_Id,Cust_Name,OrderDate")] Rsal_tbl rsal_tbl) { if (ModelState.IsValid) { db.rsal_Tbls.Add(rsal_tbl); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(rsal_tbl)); }
// GET: Rsal_tbl/Delete/5 public ActionResult Delete(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Rsal_tbl rsal_tbl = db.rsal_Tbls.Find(id); if (rsal_tbl == null) { return(HttpNotFound()); } return(View(rsal_tbl)); }
public JsonResult AddReturnDetials(OrderViewModel orderViewModel) { bool status = true; var isValidModel = TryUpdateModel(orderViewModel); if (isValidModel) { using (ApplicationDbContext db = new ApplicationDbContext()) { var cusname = db.CUST_TBLs.Find(orderViewModel.Cust_TBLId); Rsal_tbl order = new Rsal_tbl() { OrderDate = System.DateTime.Now, Cust_Id = orderViewModel.Cust_TBLId, Cust_Name = cusname.CUST_NAME }; db.rsal_Tbls.Add(order); if (db.SaveChanges() > 0) { int orderID = db.rsal_Tbls.Max(o => o.Id); foreach (var item in orderViewModel.Items) { SaleDetails orderDetails = new SaleDetails() { Rsal_TblId = orderID, Product_TbleId = item.ProductID, Price = item.Price, QtyIn = item.Quantity, QtyOut = 0, Amount = item.TotalPrice }; Stock stock = new Stock() { Prod_Id = item.ProductID, StQty = item.Quantity, Case = "مردودات مبيعات", Date = System.DateTime.Now, MndId = cusname.MND_TBLId, Cust_Id = orderViewModel.Cust_TBLId }; Cust_Acount cust = new Cust_Acount() { CUST_TBLId = orderViewModel.Cust_TBLId, SalNo = 0, RslNo = orderID, EslNo = 0, Amount = -item.TotalPrice, Date = System.DateTime.Now }; db.SaleDetails.Add(orderDetails); db.stocks.Add(stock); db.cust_Acounts.Add(cust); } 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 !" } }); }