public ActionResult ChangeQuantity(int productId)
 {
     foreach (var data in BillDetailList.Where(x => x.ProductId == productId))
     {
         ChangeQuantityClass cqc = new ChangeQuantityClass()
         {
             ProductId     = data.ProductId,
             ProductName   = data.ProductName,
             Quantity      = data.Quantity,
             Price         = data.Price,
             DisPercentage = data.DisPercentage
         };
         ChangeQuantityList.Add(cqc);
     }
     return(RedirectToAction("OrderForm"));
 }
        public ActionResult OrderForm(FormCollection fc)
        {
            if (fc["btnNewOrder"] == "Add New Order")
            {
                var   selectlist = new List <BillDetailClass>();
                int   q, q2;
                float disper = 0, disval = 0, totalprice;
                if (fc["txtProduct"] != null)
                {
                    //q = q2 = q3 = q4 = 0;
                    selectlist = BillDetailList.Where(x => x.ProductId == int.Parse(fc["txtProduct"])).ToList();
                }
                if (selectlist.Count == 0)
                {
                    q  = int.Parse(fc["txtQuantity"]);
                    q2 = Oc.Quantity(Convert.ToInt32(int.Parse(fc["txtProduct"])));
                    if (q <= q2)
                    {
                        totalprice = float.Parse(fc["txtPrice"]) * q;
                        if (fc["txtDiscount"] != "")
                        {
                            disper = float.Parse(fc["txtDiscount"]);
                            disval = disper * totalprice / 100;
                        }


                        BillDetailClass bdc = new BillDetailClass
                        {
                            ProductId     = Convert.ToInt32(fc["txtProduct"]),
                            ProductName   = Oc.GetName(Convert.ToInt32(fc["txtProduct"])),
                            Quantity      = int.Parse(fc["txtQuantity"]),
                            Price         = float.Parse(fc["txtPrice"]),
                            DisPercentage = disper,
                            DisValue      = disval,
                            Total         = totalprice - disval
                        };
                        BillDetailList.Add(bdc);
                    }
                    else
                    {
                        ChangeQuantityClass cqc = new ChangeQuantityClass()
                        {
                            ProductId     = Convert.ToInt32(fc["txtProduct"]),
                            ProductName   = Oc.GetName(Convert.ToInt32(fc["txtProduct"])),
                            Quantity      = int.Parse(fc["txtQuantity"]),
                            Price         = float.Parse(fc["txtPrice"]),
                            DisPercentage = disper
                        };
                        ChangeQuantityList.Add(cqc);
                        Session["quantityerror"] = "Please enter quntity <=" + q2;
                    }
                }
                else
                {
                    foreach (var data in selectlist)
                    {
                        q = data.Quantity;
                        var q3 = Oc.Quantity(data.ProductId);
                        q2 = int.Parse(fc["txtQuantity"]);
                        var q4 = q3 - q;
                        if (q2 <= q4)
                        {
                            totalprice = float.Parse(fc["txtPrice"]) * (data.Quantity + q2);
                            if (fc["txtDiscount"] != "")
                            {
                                disper = float.Parse(fc["txtDiscount"]);
                                disval = disper * totalprice / 100;
                            }

                            BillDetailClass bdc = new BillDetailClass
                            {
                                ProductId     = data.ProductId,
                                ProductName   = data.ProductName,
                                Quantity      = data.Quantity + q2,
                                Price         = float.Parse(fc["txtPrice"]),
                                DisPercentage = float.Parse(disper.ToString(CultureInfo.InvariantCulture)),
                                DisValue      = disval,
                                Total         = totalprice - disval
                            };
                            var selectlist1 = BillDetailList.FirstOrDefault(x => x.ProductId == Convert.ToInt32(fc["txtProduct"]));
                            BillDetailList.Remove(selectlist1);
                            BillDetailList.Add(bdc);
                        }
                        else
                        {
                            ChangeQuantityClass cqc = new ChangeQuantityClass()
                            {
                                ProductId     = Convert.ToInt32(fc["txtProduct"]),
                                ProductName   = Oc.GetName(Convert.ToInt32(fc["txtProduct"])),
                                Quantity      = int.Parse(fc["txtQuantity"]),
                                Price         = float.Parse(fc["txtPrice"]),
                                DisPercentage = disper
                            };
                            ChangeQuantityList.Add(cqc);
                            Session["quantityerror"] = "Please enter quntity <=" + q4;
                        }
                    }
                }
            }
            return(RedirectToAction("OrderForm"));
        }