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

            return(View(model));
        }
Esempio n. 3
0
 // GET: Sales/Edit/5
 public ActionResult Edit(int?id)
 {
     if (id == null)
     {
         return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
     }
     FYPPharmAssistant.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();
                FYPPharmAssistant.Models.Sales _sales = new FYPPharmAssistant.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");            
        }
Esempio n. 5
0
        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();
                FYPPharmAssistant.Models.Sales _sales = new FYPPharmAssistant.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"));
        }
Esempio n. 6
0
 public int InsertSales(Sales _sales)
 {
     return repo.InsertSales(_sales);
 }
 //Inserts in sales 
 public int InsertSales(Sales _sales)
 {           
     db.Sales.Add(_sales);
     db.SaveChanges();            
     return _sales.ID;
 }