Exemple #1
0
 public void UpdateStock(string[] _stockID, string[] _qty)
 {
     for (int i = 0, y = _stockID.Count(); i < y; i++)
     {
         int   getStockID = Convert.ToInt32(_stockID[i]);
         int   getQty     = Convert.ToInt32(_qty[i]);
         Stock stock      = new Stock();
         repo.UpdateStock(getStockID, getQty);
     }
 }
Exemple #2
0
        public JsonResult SerializeFormData(FormCollection _collection, string Total, string Discount, string GrandTotal)
        {
            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(Total);
                decimal  _discount   = Convert.ToDecimal(Discount);
                decimal  _grandTotal = Convert.ToDecimal(GrandTotal);
                DateTime _date       = DateTime.Now;

                //instance of the global class
                // MvcApplication app = new MvcApplication();
                DataAccess.Sale _sales = new DataAccess.Sale()
                {
                    Date       = _date,
                    Amount     = _total,
                    Discount   = _discount,
                    GrandTotal = _grandTotal,
                    Tax        = 0,
                    SaleUser   = User.Identity.Name,
                    Remarks    = "-"
                };
                //insert into sales, sales-items, stock
                int salesID = slsrepo.InsertSales(_sales);
                slsrepo.InsertSalesItem(salesID, _stockID, _qty, _rate, _amt);
                slsrepo.UpdateStock(_stockID, _qty);
                return(Json(salesID));
            }
            return(Json("null"));
        }