コード例 #1
0
        protected void addBtn_Click(object sender, EventArgs e)
        {
            int qty = 0;
            int id  = Convert.ToInt32(Request.QueryString["Id"]);

            if (AddToCartController.checkIsNumeric(qtyBox.Text))
            {
                qty = Convert.ToInt32(qtyBox.Text);
                if (!AddToCartController.checkQty(qty))
                {
                    warningLbl.Text = "Qty must be more than 0!";
                }
                else if (!AddToCartController.checkStock(id, qty))
                {
                    warningLbl.Text = "Qty must be less than or equal with stock!";
                }
                else if (!AddToCartController.checkCurrentStock(id, qty))
                {
                    warningLbl.Text = "Current Qty is exceeded current stock.";
                }
                else
                {
                    int userId = Convert.ToInt32(Session["UserID"].ToString());
                    AddToCartController.requestAddToCart(userId, id, qty);
                    Response.Redirect("./ViewCart.aspx");
                }
            }
            else
            {
                warningLbl.Text = "Inputted qty must be a number";
            }
        }
コード例 #2
0
        protected void BtnAdd_Click(object sender, EventArgs e)
        {
            int      Qty = 0;
            Response response;
            String   UserID    = Session["LoginSession"].ToString();
            String   ProductID = Request.QueryString["id"];

            if (int.TryParse(BoxQuantity.Text.ToString(), out Qty) == true)
            {
                Qty      = int.Parse(BoxQuantity.Text.ToString());
                response = AddToCartController.DoAddCart(UserID, ProductID, Qty);
            }
            else
            {
                response = new Response(false, "Must be Numeric");
            }

            if (response.successStatus == false)
            {
                LabelAddToCart.Text = response.message;
            }
            else
            {
                Response.Redirect("ViewCart.aspx");
            }
        }
コード例 #3
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (Session["LoginSession"] == null)
     {
         Response.Redirect("../HomeView/Home.aspx");
     }
     else if (Request.QueryString["id"] == null)
     {
         Response.Redirect("../HomeView/Home.aspx");
     }
     else
     {
         String ID   = Session["LoginSession"].ToString();
         MsUser user = HomeController.FetchDataForHome(ID);
         if (user.RoleID != "RL2")
         {
             Response.Redirect("../HomeView/Home.aspx");
         }
         else
         {
             String        ProductID = Request.QueryString["id"];
             MsProduct     product   = AddToCartController.FetchDataByID(ProductID);
             MsProductType type      = AddToCartController.GetProductType(product.ProductTypeID);
             LabelProductName.Text  = product.ProductName.ToString();
             LabelProductStock.Text = product.ProductStock.ToString();
             LabelProductPrice.Text = product.ProductPrice.ToString();
             LabelProductType.Text  = type.ProductTypeName.ToString();
         }
     }
 }
コード例 #4
0
        protected void Add_Click(object sender, EventArgs e)
        {
            string userId    = Session["id"].ToString();
            int    productId = Int32.Parse(Request.QueryString["id"]);
            int    qty       = int.Parse(Quantity.Text);

            Response respond = AddToCartController.DoAddToCart(int.Parse(userId), productId, qty);

            if (respond.successStatus == true)
            {
                Response.Redirect("ViewCart.aspx");
            }
            else
            {
                alert.Text = respond.message;
            }
        }
コード例 #5
0
        protected void BtnAddCart_Click(object sender, EventArgs e)
        {
            int    parsedValue;
            string errorMessage = "";

            if (!int.TryParse(TBStock.Text, out parsedValue))
            {
                LblError.Visible = true;
                LblError.Text    = "Please specify a number only !!";
            }
            else
            {
                int  stock  = Int32.Parse(TBStock.Text);
                bool isTrue = AddToCartController.AddToCartValidation(curr, stock, Int32.Parse(Request.QueryString["productId"]), out errorMessage);
                condition(isTrue, errorMessage);
            }
        }
コード例 #6
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!AddToCartController.checkIsAMember())
            {
                userWarnLbl.Text = "You are not logged in as member.";
                addBtn.Visible   = false;
                qtyBox.Enabled   = false;
            }
            else
            {
                int      id             = Convert.ToInt32(Request.QueryString["id"]);
                vProduct currentProduct = AddToCartController.findProductDetail(id);

                productNameLbl.Text  = currentProduct.Name;
                productPriceLbl.Text = currentProduct.Price.ToString();
                productStockLbl.Text = currentProduct.Stock.ToString();
                productTypeLbl.Text  = currentProduct.Type;
            }
        }