Esempio n. 1
0
        public bool SavePurchase(Purchase purchase)
        {
            _db.Purchases.Add(purchase);
            var isAdded = _db.SaveChanges() > 0;

            return(isAdded);
        }
Esempio n. 2
0
        public ActionResult SalesCreate(Sales sales)
        {
            DefaultLoad();
            try
            {
                bool isSave;

                foreach (var salesDetails in sales.SalesDetailses)
                {
                    var product = _db.Products.FirstOrDefault(p => p.Id == salesDetails.ProductId);
                    product.AvailableQuantity = product.AvailableQuantity - (double)salesDetails.Quantity;
                    //productManager.UpdateProduct(product);
                    _db.Entry(product).State = EntityState.Modified;
                    _db.SaveChanges();
                }
                isSave = salesManager.SaveSales(sales);
                if (isSave)
                {
                    ViewBag.SMsg = "Save Successfully !!";
                }
                else
                {
                    ViewBag.FMsg = "Save Failed !!";
                }
            }
            catch (Exception e)
            {
                ViewBag.FMsg = e.Message;
            }
            ViewBag.ProductDropdownList  = new SelectList(_db.Products, "Id", "Name");
            ViewBag.CustomerDropdownList = new SelectList(_db.Customers, "Id", "Name", sales.CustomerId);
            return(View());
        }
Esempio n. 3
0
 public ActionResult Register(Login login)
 {
     try
     {
         if (ModelState.IsValid)
         {
             using (SBMDbContext db = new SBMDbContext())
             {
                 db.Logins.Add(login);
                 int isSave = db.SaveChanges();
                 if (isSave > 0)
                 {
                     ViewBag.SMsg = "Save Successfully!!";
                 }
                 else
                 {
                     ViewBag.FMsg = "Save Filed!!";
                 }
             }
         }
     }
     catch (Exception e)
     {
         ViewBag.FMsg = e.Message;
     }
     return(View(login));
 }
Esempio n. 4
0
        public bool SaveSales(Sales sales)
        {
            _db.Sales.Add(sales);
            var isAdded = _db.SaveChanges() > 0;

            return(isAdded);
        }
 public ActionResult PurchaseCreate(Purchase purchase)
 {
     DefaultLoad();
     try
     {
         bool isSave;
         
         foreach (var purchasedetails in purchase.PurchaseDetailses)
         {
             var product = _db.Products.FirstOrDefault(p => p.Id == purchasedetails.ProductId);
             product.AvailableQuantity = product.AvailableQuantity + (double) purchasedetails.Quantity;
             product.Price = (double) purchasedetails.NewMRP;
             //productManager.UpdateProduct(product);
             _db.Entry(product).State = EntityState.Modified;
             _db.SaveChanges();
         }
         isSave = purchaseManager.SavePurchase(purchase);
         if (isSave)
         {
             ViewBag.SMsg = "Save Successfully !!";
         }
         else
         {
             ViewBag.FMsg = "Save Failed !!";
         }
     }
     catch (Exception e)
     {
         ViewBag.FMsg = e.Message;
     }
     ViewBag.ProductDropdownList = new SelectList(_db.Products, "Id", "Name");
     ViewBag.SupplierDropdownList = new SelectList(_db.Suppliers, "Id", "Name", purchase.SupplierId);
     return View();
 }
        public bool SaveCategory(Category category)
        {
            bool isSave = false;

            _db.Categories.Add(category);
            int save = _db.SaveChanges();

            if (save > 0)
            {
                isSave = true;
            }
            else
            {
                isSave = false;
            }
            return(isSave);
        }
Esempio n. 7
0
        public bool SaveProduct(Product product)
        {
            bool isSave = false;

            _db.Products.Add(product);
            int save = _db.SaveChanges();

            if (save > 0)
            {
                isSave = true;
            }
            else
            {
                isSave = false;
            }
            return(isSave);
        }
        public bool SaveSupplier(Supplier obj)
        {
            bool isSave = false;

            _db.Suppliers.Add(obj);
            int add = _db.SaveChanges();

            if (add > 0)
            {
                isSave = true;
            }
            else
            {
                isSave = false;
            }
            return(isSave);
        }