Example #1
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"));
        }
Example #2
0
 public int InsertSales(Sales _sales)
 {
     return(repo.InsertSales(_sales));
 }