protected void productList_ItemCommand(object sender, ListViewCommandEventArgs e)
        {
            string customerID = txtCustomerID.Text;
            var    cartID     = e.CommandArgument;

            if (e.CommandName == "Delete")
            {
                decimal                   d_total = 0; int delCartQty = 0;
                ProductController         productControl            = new ProductController();
                ProductDiscountController productDiscountController = new ProductDiscountController();

                List <CartInfo> lstCartInfo          = new List <CartInfo>();
                List <CartInfo> lstCartInfoWithImage = new List <CartInfo>();
                List <CartInfo> lstCart = GettingJson(customerID);
                foreach (CartInfo obj in lstCart)
                {
                    if (obj.CartID != cartID.ToString())
                    {
                        //For Json file, can't add image byty[] property.
                        CartInfo obj_cart = new CartInfo();
                        obj_cart.CartID       = obj.CartID;
                        obj_cart.ProductID    = obj.ProductID;
                        obj_cart.ProductName  = obj.ProductName;
                        obj_cart.Quantity     = obj.Quantity;
                        obj_cart.ProductPrice = obj.ProductPrice;
                        obj_cart.TotalPrice   = obj.TotalPrice;
                        obj_cart.CustomerID   = obj.CustomerID;
                        lstCartInfo.Add(obj_cart);

                        obj.ProductImage   = productControl.GetProductImagebyID(obj.ProductID);
                        obj.DiscountAmount = productDiscountController.GetDiscountByProductID(obj.ProductID);
                        obj.TotalPrice     = obj.Quantity * (obj.ProductPrice - obj.DiscountAmount);
                        lstCartInfoWithImage.Add(obj);

                        d_total += obj.TotalPrice;
                    }
                    else
                    {
                        delCartQty = obj.Quantity;
                    }
                }

                Label lbl     = (Label)(this.Master).FindControl("lblCartQty");
                int   cartQty = Convert.ToInt32(String.IsNullOrEmpty(lbl.Text) ? "0" : lbl.Text);
                if ((cartQty - delCartQty) > 0)
                {
                    lbl.Text = (cartQty - delCartQty).ToString();
                }
                else
                {
                    lbl.Text = "";
                }

                MakeJson(lstCartInfo, customerID);

                DataBindToPage(lstCartInfoWithImage, d_total, customerID);
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Request.Cookies["CustomerID"] != null)
            {
                string customerID = Request.Cookies["CustomerID"].Value;

                if (!IsPostBack)
                {
                    if (!String.IsNullOrEmpty(customerID))
                    {
                        ProductController         productControl            = new ProductController();
                        ProductDiscountController productDiscountController = new ProductDiscountController();

                        List <CartInfo> lstCartInfo = new List <CartInfo>();
                        List <CartInfo> lstCart     = GettingJson(customerID);
                        decimal         d_total     = 0;
                        foreach (CartInfo obj in lstCart)
                        {
                            obj.ProductImage   = productControl.GetProductImagebyID(obj.ProductID);
                            obj.DiscountAmount = productDiscountController.GetDiscountByProductID(obj.ProductID);
                            obj.TotalPrice     = obj.Quantity * (obj.ProductPrice - obj.DiscountAmount);
                            d_total           += obj.TotalPrice;

                            lstCartInfo.Add(obj);
                        }
                        DataBindToDDL(customerID);
                        DataBindToPage(lstCartInfo, d_total, customerID);
                    }
                    else
                    {
                        Response.Redirect("Login.aspx");
                    }
                }
            }
            else
            {
                Response.Redirect("Login.aspx");
            }
        }
        protected void btnCreateOrder_Click(object sender, EventArgs e)
        {
            int     orderQty = 0; decimal totalAmount = 0, discountAmount = 0;
            string  customerID    = txtCustomerID.Text;
            decimal taxPercentage = Convert.ToDecimal(txtTax.Text);

            //============ Detail Data Preparation ============
            ProductDiscountController productDiscountController = new ProductDiscountController();
            List <OrderDetail>        lst_OrderDetailInfo       = new List <OrderDetail>();
            List <CartInfo>           lstCart = GettingJson(customerID);

            foreach (CartInfo obj in lstCart)
            {
                if (obj.Quantity > 0)
                {
                    orderQty      += obj.Quantity;
                    discountAmount = productDiscountController.GetDiscountByProductID(obj.ProductID);

                    OrderDetail obj_OrderDetail = new OrderDetail();
                    obj_OrderDetail.ProductID      = obj.ProductID;
                    obj_OrderDetail.Quantity       = obj.Quantity;
                    obj_OrderDetail.Price          = obj.ProductPrice;
                    obj_OrderDetail.DiscountAmount = discountAmount;
                    lst_OrderDetailInfo.Add(obj_OrderDetail);

                    totalAmount += obj.Quantity * (obj.ProductPrice - discountAmount);
                }
            }
            decimal commercialTax = decimal.Round(totalAmount * (taxPercentage / 100), 2);

            string[] selectedValue   = (ddlTownship.Items[ddlTownship.SelectedIndex].Value).Split('-');
            decimal  deliveryCharges = Convert.ToDecimal(selectedValue[1]);

            //============ Header Data Preparation ============
            OrderInfo obj_OrderInfo = new OrderInfo();

            obj_OrderInfo.OrderDate        = DateTime.Now;
            obj_OrderInfo.OrderQuantity    = orderQty;
            obj_OrderInfo.Tax              = commercialTax;                                 //When I get directly from lable, I can't get last changes amount.
            obj_OrderInfo.DiscountAmount   = Convert.ToDecimal(0);                          //Will add control later.
            obj_OrderInfo.DeliveryCharges  = deliveryCharges;
            obj_OrderInfo.OrderAmount      = totalAmount + commercialTax + deliveryCharges; //When I get directly from lable, I can't get last changes amount.
            obj_OrderInfo.OrderDescription = txtOrderDescription.Text;
            obj_OrderInfo.OrderStatus      = "Created";
            obj_OrderInfo.CustomerID       = customerID;

            //============ Insert Data ============
            OrderController orderControl     = new OrderController();
            OrderInfo       return_OrderInfo = orderControl.InsertOrder(obj_OrderInfo);

            if (return_OrderInfo != null)
            {
                OrderDetailController orderDetailControl = new OrderDetailController();
                orderDetailControl.InsertOrderDetail(return_OrderInfo.OrderID, lst_OrderDetailInfo);

                //============ Delete Json File ============
                File.Delete(Server.MapPath("~/CartJson/" + customerID + "_cart.json"));
            }

            Response.Redirect("OrderInfoList.aspx");
            #region +++ When you want to get data from Listview +++
            ////for (int i = 0; i < productList.Items.Count; i++)
            ////{
            ////    Label lblProductID = (Label)productList.Items[i].FindControl("lbl_ProductID");
            ////    string productID = lblProductID.Text;
            ////}
            #endregion
        }