protected void btnClick_Click(object sender, EventArgs e)
    {
        if (hdnProductDetailID.Value != "")
        {
            tblProductDetail objProductDetail = new tblProductDetail();
            if (objProductDetail.LoadByPrimaryKey(Convert.ToInt32(hdnProductDetailID.Value)))
            {
                if (objProductDetail.AppQuantity > 0)
                {
                    objCommon = new clsCommon();
                    objCommon.AddToCart(hdnPKID.Value, hdnProductColorId.Value, hdnProductDetailID.Value, 1);

                    //objCommon.AddToCart(hdnPKID.Value, objProductDetail.s_AppProductColorID, objProductDetail.s_AppSizeID, 1, hdnPriceDiscount.Value);
                    objCommon = null;
                    //txtQty.Text = "1";
                    SetCartProductCount();
                    ViewCart.LoadProduct();
                }
                else
                {
                    DInfoSearch.ShowMessage("Product out of stock.", Enums.MessageType.Error);
                }
            }
            else
            {
                DInfoSearch.ShowMessage("Product out of stock.", Enums.MessageType.Error);
            }
            objProductDetail = null;
        }
        else
        {
            // DInfo.ShowMessage("Product out of stock.", Enums.MessageType.Error);
        }
    }
 protected void btnCart_Click(object sender, EventArgs e)
 {
     if (hdnProductDetailId.Value != "")
     {
         tblProductDetail objProductDetail = new tblProductDetail();
         if (objProductDetail.LoadByPrimaryKey(Convert.ToInt32(hdnProductDetailId.Value)))
         {
             if (objProductDetail.AppQuantity > 0 & objProductDetail.AppQuantity >= Convert.ToInt32(txtQty.Text))
             {
                 objCommon = new clsCommon();
                 objCommon.AddToCart(hdnPKID.Value, hdnProductColorId.Value, ddlSize.SelectedValue, Convert.ToInt32(txtQty.Text), hdnPriceDiscount.Value);
                 objCommon   = null;
                 txtQty.Text = "1";
                 SetCartProductCount();
                 ViewCart.LoadProduct();
             }
             else
             {
                 DInfo.ShowMessage("Product out of stock.", Enums.MessageType.Error);
             }
         }
         else
         {
             DInfo.ShowMessage("Product out of stock.", Enums.MessageType.Error);
         }
         objProductDetail = null;
     }
     else
     {
         DInfo.ShowMessage("Product out of stock.", Enums.MessageType.Error);
     }
 }
Exemplo n.º 3
0
    void Start()
    {
        _ViewCart    = GameObject.Find("Actions").GetComponent <ViewCart>();
        checkOutMenu = GameObject.Find("CheckOutMenu");

        checkOutMenu.transform.position = new Vector3(0, -20, 10);
    }
Exemplo n.º 4
0
        private void btnViewCart_Click(object sender, EventArgs e)
        {
            this.Hide();
            ViewCart viewCart = new ViewCart(cart, this.curUser);

            viewCart.ShowDialog();
            this.Close();
        }
Exemplo n.º 5
0
        public IActionResult ViewCart([FromRoute] string id)
        {
            var carts  = userServices.GetCartById(id);
            var game   = userServices.GetGameList();
            var gameVM = new ViewCart {
                Orders = carts, Games = game
            };

            return(View(gameVM));
        }
Exemplo n.º 6
0
        /*---------------------------------*/

        private void suppliers_listBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            stores_listBox.Visibility = System.Windows.Visibility.Visible;

            selected_cart = suppliers_listBox.SelectedItem as ViewCart;

            stores_listBox.ItemsSource = _currentChaincarts = (from c in _carts
                                                               where c.ChainName.Equals(selected_cart.ChainName)
                                                               select c).ToList();
        }
Exemplo n.º 7
0
        public ActionResult addCart(FormCollection form, int Id)
        {
            DBConn        db            = new DBConn();
            RegisterUser  sessionReg    = (RegisterUser)Session["Registration"];
            CartViewModel cartViewModel = null;

            if (sessionReg == null)
            {
                return(RedirectToAction("Login", "Home"));
            }
            else
            {
                if (sessionReg.Id == 0)
                {
                    //Its guest user.
                    //Get cart from session.
                    if (cartViewModel == null)
                    {
                        //If its not in session already, create and put new one.
                        cartViewModel = new CartViewModel();
                        cartViewModel.ListofCartItems = (List <ViewCart>)Session["ListofCartItems"];
                        if (cartViewModel.ListofCartItems == null)
                        {
                            cartViewModel.ListofCartItems = new List <ViewCart>();
                            Session["ListofCartItems"]    = cartViewModel.ListofCartItems;
                        }
                    }

                    Product product = db.getProduct(Id);

                    ViewCart addCart = new ViewCart();
                    addCart.Quantity    = Convert.ToInt32(form["QUANTITY"].ToString());
                    addCart.Product_Id  = Id;
                    addCart.Id          = sessionReg.Id;
                    addCart.Photo       = product.Photo;
                    addCart.ProductName = product.ProductName;
                    addCart.Price       = product.Price;
                    addCart.Total       = product.Price * addCart.Quantity;
                    cartViewModel.ListofCartItems.Add(addCart);
                }
                else
                {
                    AddToCart addCart = new AddToCart();
                    addCart.Quantity   = Convert.ToInt32(form["QUANTITY"].ToString());
                    addCart.Product_Id = Id;
                    addCart.UserId     = sessionReg.Id;
                    db.SaveToCart(addCart);
                }
                return(RedirectToAction("Cart", "Home"));
            }
        }
Exemplo n.º 8
0
    void Start()
    {
        _ObjectState   = new ObjectState();
        _ObjectManager = GameObject.Find("GameEvents").GetComponent <ObjectManager>(); //gets the component ObjectManager from the GameObject GameEvents

        // Intialize actions from components on Action gameobject. All future actions should be attached to Action object and called in the same way
        // All actions also need to implment the function Act()
        _PileGrab     = GameObject.Find("Actions").GetComponent <PileGrab>();
        _Shelfgrab    = GameObject.Find("Actions").GetComponent <ShelfGrab>();
        _StateManager = GameObject.Find("GameEvents").GetComponent <StateManager>();
        _ViewCart     = GameObject.Find("Actions").GetComponent <ViewCart>();
        _PileToCart   = GameObject.Find("Actions").GetComponent <PileToCart>();
        _PileReturn   = GameObject.Find("Actions").GetComponent <PileReturn>();

        _mapState = GameObject.Find("Actions").GetComponent <Map>();
    }
Exemplo n.º 9
0
 public ActionResult Add_To_cart(ViewCart view)
 {
     try
     {
         SPECS_DETAILS specs = specsDetailsEntities.SPECS_DETAILS.FirstOrDefault(id => id.SPECS_ID == view.SPECS_ID);
         ADD_TO_CART   add   = new ADD_TO_CART();
         add.SPECS_ID    = view.SPECS_ID;
         add.SPECS_NAME  = view.SPECS_NAME;
         add.QUANTITY    = view.QUANTITY;
         add.SPECS_PRICE = (view.QUANTITY) * (view.SPECS_PRICE);
         add.EMAILID     = TempData.Peek("CUSTOMER_EMAIL").ToString();
         specsDetailsEntities.ADD_TO_CART.Add(add);
         specsDetailsEntities.SaveChanges();
         ViewBag.Message = "Added To cart Sucessfully";
         return(RedirectToAction("ViewSpecs"));
     }
     catch (Exception e)
     {
         return(View("Error" + e.Message));
     }
 }
Exemplo n.º 10
0
        public ActionResult Add_to_cart(int SPECS_ID)
        {
            SPECS_DETAILS specs = specsDetailsEntities.SPECS_DETAILS.FirstOrDefault(id => id.SPECS_ID == SPECS_ID);
            ViewCart      view  = new ViewCart();

            try
            {
                if (specs != null)
                {
                    view.SPECS_ID    = specs.SPECS_ID;
                    view.SPECS_NAME  = specs.SPECS_NAME;
                    view.SPECS_PRICE = specs.SPECS_PRICE;
                }
            }

            catch (Exception)
            {
                return(View("Error"));
            }
            return(View(view));
        }
Exemplo n.º 11
0
        protected void grvChckout_RowDataBound
            (object sender, GridViewRowEventArgs e)
        {
            if (e.Row.RowType == DataControlRowType.DataRow)
            {
                ViewCart myCart = new ViewCart();
                myCart = (ViewCart)e.Row.DataItem;

                cartTotal += myCart.MovieCost * myCart.Quantity;
            }
            else if (e.Row.RowType == DataControlRowType.Footer)
            {
                if (cartTotal > 0)
                {
                    CheckoutHeader.InnerText = "Review and Submit Order";
                    lblCartHeader.Text       =
                        "Please review your order information below:";
                    btnChceckout.Visible = true;
                    e.Row.Cells[4].Text  = "Total: " + cartTotal.ToString();
                }
            }
        }
Exemplo n.º 12
0
    public void rpNewProduct_ItemCommand(Object Sender, RepeaterCommandEventArgs e)
    {
        if (e.CommandName == "Add To Cart")
        {
            if (e.CommandArgument.ToString() != "")
            {
                tblProductDetail objProductDetail = new tblProductDetail();
                objDataTable = objProductDetail.LoadProductIDs(e.CommandArgument.ToString());
                if (objDataTable.Rows.Count > 0)
                {
                    if (Convert.ToInt32(objDataTable.Rows[0][tblProductDetail.ColumnNames.AppQuantity].ToString()) > 0)
                    {
                        objCommon = new clsCommon();
                        //objCommon.AddToCart(objDataTable.Rows[0][tblProductColor.ColumnNames.AppProductID].ToString(), objDataTable.Rows[0][tblProductDetail.ColumnNames.AppProductColorID].ToString(), e.CommandArgument.ToString());
                        objCommon.AddToCart(objDataTable.Rows[0][tblProductColor.ColumnNames.AppProductID].ToString(), objDataTable.Rows[0][tblProductDetail.ColumnNames.AppProductColorID].ToString(), e.CommandArgument.ToString(), 1);
                        objCommon = null;
                        SetCartProductCount();
                        ViewCart.LoadProduct();
                    }
                    else
                    {
                        DInfo.ShowMessage("Product out of stock.", Enums.MessageType.Error);
                    }
                }
                else
                {
                    DInfo.ShowMessage("Product out of stock.", Enums.MessageType.Error);
                }


                objProductDetail = null;
            }
            else
            {
                DInfo.ShowMessage("Product out of stock.", Enums.MessageType.Error);
            }
        }
    }
Exemplo n.º 13
0
        public IHttpActionResult EditCart(string id, [Bind(Include = "Id,ProductUnit")] ViewCart viewCart)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            Cart cart    = new Cart();
            int  id_temp = Convert.ToInt32(id);

            cart = db.Carts.FirstOrDefault(c => c.Id == id_temp);
            //db.Carts.Where(c => c.Id == id_temp).FirstOrDefault();
            cart.ProductUnit = viewCart.ProductUnit;
            cart.Amount      = viewCart.ProductUnit * cart.ProductPrice;
            //cart.Amount = viewCart.Amount;

            db.Entry(cart).State = EntityState.Modified;
            db.SaveChanges();

            return(Ok(new
            {
                result = true,
                message = "購物車更新成功"
            }));
        }
 public ActionResult ViewCart(int id)
 {
     id = GetUserId();
     using (var cn = new SqlConnection(ConfigurationManager.ConnectionStrings["ServiceLayer"].ConnectionString))
     {
         SqlCommand cmd = new SqlCommand("GetCartDetails", cn);
         cmd.CommandType = System.Data.CommandType.StoredProcedure;
         cmd.Parameters.AddWithValue("@Userid", id);
         cn.Open();
         SqlDataReader   dr        = cmd.ExecuteReader();
         List <ViewCart> viewCarts = new List <ViewCart>();
         while (dr.Read())
         {
             var detail = new ViewCart();
             detail.Cartid      = Convert.ToInt32(dr["Cartid"]);
             detail.ProductName = dr["ProductName"].ToString();
             detail.ProductCost = Convert.ToInt32(dr["ProductCost"].ToString());
             detail.Image       = dr["Image"].ToString();
             detail.Quantity    = Convert.ToInt32(dr["Quantity"].ToString());
             viewCarts.Add(detail);
         }
         return(View(viewCarts));
     }
 }
Exemplo n.º 15
0
        public ActionResult OrderStatus(int Id)
        {
            List <ViewCart> viewCarts = new List <ViewCart>();
            Buyer           buyer     = db.Buyers.Find(Id);

            List <Order> Orders = db.Orders.Where(a => a.BuyerId == Id).ToList();

            if (Orders.Count != 0)
            {
                foreach (Order P in Orders)
                {
                    Product  product = db.Products.Find(P.ProductId);
                    ViewCart VC      = new ViewCart();

                    VC.Id          = product.Id;
                    VC.ProductId   = product.ProductId;
                    VC.Name        = product.Name;
                    VC.Quantity    = P.Quantity;
                    VC.ProductFile = product.ProductFile;
                    VC.Price       = product.Price;
                    VC.Weight      = product.Weight;
                    VC.Discount    = product.Discount;


                    if (((product.Quantity - P.Quantity) >= 0) || buyer.PaymentStatus == true)
                    {
                        VC.Available = "Yes";
                        decimal discount = P.Quantity * product.Price * (product.Discount / 100);
                        VC.NPrice = product.Price * P.Quantity - discount;
                    }
                    else
                    {
                        Order O = db.Orders.Find(P.Id);

                        db.Orders.Remove(O);
                        db.SaveChanges();

                        VC.Available = "No";
                        VC.NPrice    = 0;
                    }


                    viewCarts.Add(VC);
                }



                double TotalPayable = 0;


                foreach (ViewCart V in viewCarts)
                {
                    TotalPayable = TotalPayable + Convert.ToDouble(V.NPrice);
                }

                double ShippingCost = Convert.ToDouble(buyer.Location.Charge);
                TotalPayable = ShippingCost + TotalPayable;


                buyer.Payment         = Convert.ToDecimal(TotalPayable);
                db.Entry(buyer).State = EntityState.Modified;
                db.SaveChanges();
                if (buyer.PaymentStatus == true)
                {
                    ViewBag.PaymentStatus = "Ok";
                }
                else
                {
                    ViewBag.PaymentStatus = "Not Ok";
                }
                ViewBag.PaymentId    = buyer.PaymentId;
                ViewBag.TotalPayable = TotalPayable;
                ViewBag.ShippingCost = ShippingCost + "TK.(" + buyer.Location.Name + ")";
            }

            return(View(viewCarts.ToList()));
        }
Exemplo n.º 16
0
        public ActionResult ShowCart()
        {
            List <ViewCart> viewCarts = new List <ViewCart>();

            if (Session["products"] != null)
            {
                List <Product> products = (List <Product>)Session["products"];

                foreach (Product P in products)
                {
                    Product  product = db.Products.Find(P.Id);
                    ViewCart VC      = new ViewCart();

                    VC.Id          = product.Id;
                    VC.ProductId   = product.ProductId;
                    VC.Name        = product.Name;
                    VC.Quantity    = P.Quantity;
                    VC.ProductFile = product.ProductFile;
                    VC.Price       = product.Price;
                    VC.Weight      = product.Weight;
                    VC.Discount    = product.Discount;

                    var vC = viewCarts.FirstOrDefault(a => a.Id == P.Id);

                    if (vC == null)
                    {
                        if ((product.Quantity - P.Quantity) >= 0)
                        {
                            VC.Available = "Yes";
                            decimal discount = P.Quantity * product.Price * (product.Discount / 100);
                            VC.NPrice = product.Price * P.Quantity - discount;
                        }
                        else
                        {
                            VC.Available = "No";
                            VC.NPrice    = 0;
                        }
                    }
                    else
                    {
                        if ((product.Quantity - P.Quantity - vC.Quantity) >= 0)
                        {
                            VC.Available = "Yes";
                            decimal discount = P.Quantity * product.Price * (product.Discount / 100);
                            VC.NPrice = product.Price * P.Quantity - discount;
                        }
                        else
                        {
                            VC.Available = "No";
                            VC.NPrice    = 0;
                        }
                    }


                    viewCarts.Add(VC);
                }
            }

            double TotalPayable = 0;


            foreach (ViewCart V in viewCarts)
            {
                TotalPayable = TotalPayable + Convert.ToDouble(V.NPrice);
            }
            ViewBag.TotalPayable = TotalPayable;

            return(View(viewCarts.ToList()));
        }
Exemplo n.º 17
0
 public void ViewCartItem()
 {
     ViewCart.Click();
 }
Exemplo n.º 18
0
        public IHttpActionResult PostCart(ViewCart viewCart)
        {
            var Product = db.ProductLists.Find(viewCart.ProductListId);

            if (Product == null)
            {
                return(NotFound());
            }

            //顧客資料
            string      token       = Request.Headers.Authorization.Parameter;
            JwtAuthUtil jwtAuthUtil = new JwtAuthUtil();
            int         id          = Convert.ToInt32(jwtAuthUtil.GetId(token));

            bool isCart = db.Carts
                          .Where(c => c.CustomerId == id)
                          .Any(c => c.ProductListId == viewCart.ProductListId);

            if (isCart) //購物車有相同的商品
            {
                Cart cart = db.Carts.First(c => c.CustomerId == id && c.ProductListId == viewCart.ProductListId);
                cart.ProductUnit += 1;
                cart.Amount       = cart.ProductPrice * cart.ProductUnit;
            }
            else
            {
                //餐車業主
                var Brand = db.Brands.FirstOrDefault(b => b.Id == Product.BrandId);

                var image = db.ProductLists.FirstOrDefault(p => p.Id == viewCart.ProductListId).ProductPhoto;

                db.Carts.Add(new Cart
                {
                    CustomerId    = id,
                    BrandId       = Brand.Id,
                    BrandName     = Brand.BrandName,
                    ProductListId = viewCart.ProductListId,
                    ProductName   = Product.ProductName,
                    ProductPhoto  = Product.ProductPhoto,
                    ProductPrice  = Product.Price,
                    ProductUnit   = viewCart.ProductUnit,
                    Amount        = Product.Price * viewCart.ProductUnit,
                });
            }

            db.SaveChanges();

            return(Ok(new
            {
                result = true,
                message = "已加入購物車",
                carts = db.Carts
                        .Where(cart => cart.CustomerId == id)
                        .Select(cart => new
                {
                    cart.Id,
                    cart.CustomerId,
                    cart.BrandId,
                    cart.BrandName,
                    ProductList = new
                    {
                        cart.ProductListId,
                        cart.ProductName,
                        cart.ProductUnit,
                        cart.ProductPrice,
                        cart.Amount,
                        cart.ProductPhoto
                    }
                })
            }));
        }