public ActionResult Edit(Payment payment) { if (ModelState.IsValid) { payment.CreatedOn = DateTime.Now; db.Entry(payment).State = EntityState.Modified; db.SaveChanges(); PurchaseOrdersController purchaseOrdersController = new PurchaseOrdersController(); if (payment.TransactionType == 0) { purchaseOrdersController.updateBalanceHistory(payment.Id, payment.UserMasId, "payment", true, payment.Amount); } else { purchaseOrdersController.updateBalanceHistory(payment.Id, payment.UserMasId, "collection", true, payment.Amount); } return(RedirectToAction("Index")); } ViewBag.CompanyId = new SelectList(db.Company, "Id", "Name", payment.CompanyId); ViewBag.TransactionModeId = new SelectList(db.TransactionMode, "Id", "Name", payment.TransactionModeId); ViewBag.UserMasId = new SelectList(db.UserMas, "Id", "Name", payment.UserMasId); ViewBag.VendorBankId = new SelectList(db.VendorBank, "Id", "Name", payment.VendorBankId); return(View(payment)); }
public JsonResult confirmOrder(int companyID, int SelecteditemID, int quantity, int orderID, int UserMasId) { bool flag = false; Inventory inventory = new Inventory(); Inventory inventoryItem = db.Inventory.SingleOrDefault(x => x.CompanyId == companyID && x.ItemId == SelecteditemID); if (inventoryItem == null) { inventory.CompanyId = companyID; inventory.OrderId = orderID; inventory.Quantity = quantity; inventory.ItemId = SelecteditemID; db.Inventory.Add(inventory); flag = db.SaveChanges() > 0; } else { inventoryItem.Quantity = inventoryItem.Quantity - quantity; db.Entry(inventoryItem).State = EntityState.Modified; flag = db.SaveChanges() > 0; } //db.Inventory.Add(inventory); var checkUpdate = 0; if (flag) { checkUpdate = 1; var check = db.SalesOrder.Find(orderID).Status = 1; var confirmDate = db.SalesOrder.Find(orderID).ConfirmDate = DateTime.Now; db.SaveChanges(); } PurchaseOrdersController purchaseOrdersController = new PurchaseOrdersController(); purchaseOrdersController.updateBalanceHistory(orderID, UserMasId, "sales"); return(Json(checkUpdate, JsonRequestBehavior.AllowGet)); }