示例#1
0
 public ActionResult Edit([Bind(Include = "ID,Date,Amount,Discount,Tax,GrandTotal,UserID,Remarks")] PharmAssistant.Models.Sales sales)
 {
     if (ModelState.IsValid)
     {
         db.Entry(sales).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(sales));
 }
        // POST: SalesReturn/5
        public ActionResult Returns(int id)
        {
            PharmAssistant.Models.Sales model = db.Sales.Find(id);
            //null check
            if (model == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.NotFound));
            }

            return(View(model));
        }
示例#3
0
 // GET: Sales/Edit/5
 public ActionResult Edit(int?id)
 {
     if (id == null)
     {
         return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
     }
     PharmAssistant.Models.Sales 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();
                PharmAssistant.Models.Sales _sales = new PharmAssistant.Models.Sales()
                {
                    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"));
        }