public ActionResult Edit([Bind(Include = "ID,Date,Amount,Discount,Tax,GrandTotal,UserID,Remarks")] pharmacy.Models.Sale sales) { if (ModelState.IsValid) { db.Entry(sales).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(sales)); }
// GET: Sales/Details/5 //public ActionResult Details(int? id) //{ // if (id == null) // { // return new HttpStatusCodeResult(HttpStatusCode.BadRequest); // } // var _salesItems = (from si in db.SalesItem // where si.SalesID == id // select si).ToList(); // if (_salesItems == null) // { // return HttpNotFound(); // } // return View(_salesItems.ToList()); //} // GET: Sales/Create //public ActionResult Create() //{ // return View(); //} //// POST: Sales/Create //// To protect from overposting attacks, please enable the specific properties you want to bind to, for //// more details see https://go.microsoft.com/fwlink/?LinkId=317598. //[HttpPost] //[ValidateAntiForgeryToken] //public ActionResult Create([Bind(Include = "ID,Date,Amount,Discount,Tax,GrandTotal,UserID,Remarks")] Sale sale) //{ // if (ModelState.IsValid) // { // db.Sales.Add(sale); // db.SaveChanges(); // return RedirectToAction("Index"); // } // return View(sale); //} // GET: Sales/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } pharmacy.Models.Sale sales = db.Sales.Find(id); if (sales == null) { return(HttpNotFound()); } return(View(sales)); }
public JsonResult SerializeFormData(FormCollection _collection) { if (_collection != null) { string[] _stockID, _qty, _rate, _amt; //for salesItem _stockID = _collection["StockID"].Split(','); _qty = _collection["Qty"].Split(','); _rate = _collection["Rate"].Split(','); _amt = _collection["Amount"].Split(','); //for sales decimal _total = Convert.ToDecimal(_collection["Total"]); decimal _discount = Convert.ToDecimal(_collection["Discount"]); decimal _grandTotal = Convert.ToDecimal(_collection["GrandTotal"]); DateTime _date = DateTime.Now; //instance of the global class MvcApplication app = new MvcApplication(); pharmacy.Models.Sale _sales = new pharmacy.Models.Sale() { Date = _date, Amount = _total, Discount = _discount, GrandTotal = _grandTotal, Tax = 0, // UserID = User.Identity.GetUserId(), Remarks = "-" }; //insert into sales, sales-items, stock int salesID = service.InsertSales(_sales); service.InsertSalesItem(salesID, _stockID, _qty, _rate, _amt); service.UpdateStock(_stockID, _qty); return(Json(salesID)); } return(Json("null")); }
//Inserts in sales public int InsertSales(Sale _sales) { db.Sales.Add(_sales); db.SaveChanges(); return(_sales.ID); }