public ActionResult Delete_Customer_Item(int id, int invoice, int quantity, int item_id_in_sell)
        {
            //MyStock mm = db.MyStocks.Find(id);
            //db.MyStocks.Remove(mm);
            //db.SaveChanges();

            ViewBag.preQuantity = from TotalItemsQuantity in db.TotalItemsQuantitys.Where(z => z.id == id) select TotalItemsQuantity;
            foreach (var mm in ViewBag.preQuantity)
            {
                ViewBag.c = mm.quantity;
            }
            int pp     = Convert.ToInt32(ViewBag.c);
            int total  = pp + quantity;
            var itemid = db.TotalItemsQuantitys.Where(x => x.id == id).ToList();

            foreach (var vm in itemid)
            {
                vm.quantity = total;
                db.SaveChanges();
            }

            //here i am deleting order item if user dont want to confirm that order
            Sell_Item md = db.Sell_Items.Find(item_id_in_sell);

            db.Sell_Items.Remove(md);
            int res = db.SaveChanges();

            if (res > 0)
            {
                var query = from v in db.Sell_Items.Where(x => x.invoice == invoice) select v;
                return(View(query));
            }

            return(RedirectToAction("Sells"));
        }
        public ActionResult Save_Customer_Order(int id, int invoice_no, string bill_date, string customer_name, string item_name, int quantity, int price, int total_price_per_item, int total_amount, string current_date)
        {
            ApplicationDbContext db = new ApplicationDbContext();

            //here the quantity will be minus from total stock'
            //here the total_amount parameter is the id of the item;
            ViewBag.preQuantity = from TotalItemsQuantity in db.TotalItemsQuantitys.Where(z => z.id == total_amount) select TotalItemsQuantity;
            foreach (var mm in ViewBag.preQuantity)
            {
                ViewBag.c = mm.quantity;
            }
            int pp    = Convert.ToInt32(ViewBag.c);
            int total = pp - quantity;

            var itemid = db.TotalItemsQuantitys.Where(x => x.item_name == item_name).ToList();

            foreach (var vm in itemid)
            {
                vm.quantity = total;
                db.SaveChanges();
            }



            Sell_Item md = new Sell_Item();

            md.id            = id;
            md.invoice       = invoice_no;
            md.bill_date     = bill_date;
            md.customer_name = customer_name;

            md.item_name            = item_name;
            md.quantity             = quantity;
            md.price                = price;
            md.total_price_per_item = total_price_per_item;
            md.total_amount         = total_amount;
            md.date = current_date;
            db.Sell_Items.Add(md);

            int res = db.SaveChanges();

            if (res > 0)
            {
                List <Sell_Item> myst = db.Sell_Items.Where(x => x.invoice == invoice_no).ToList();
                return(View(myst));
                //return RedirectToAction("Index");
            }
            else
            {
                ViewBag.notstored = "value not stored";
                return(View());
            }
        }