Exemplo n.º 1
0
        protected void Btn_Search_Click(object sender, EventArgs e)
        {
            string search = Txt_Search.Text;

            shoeSearch.DataSource = ShoeHandler.findShoeByName(search);
            shoeSearch.DataBind();
        }
        protected void DeleteBtn_Click(object sender, EventArgs e)
        {
            int       deleteID = Int32.Parse(delShoeID.Text);
            ShoeTable delShoe  = ShoeHandler.findShoeByID(deleteID);

            ShoeRepository.deleteShoe(delShoe);
            loadData();
        }
Exemplo n.º 3
0
 public static int checkStock(int id)
 {
     ShoeTable shoe = ShoeHandler.findShoeByID(id);
     if (shoe != null)
     {
         return shoe.ShoeStock;
     }
     return -1;
 }
Exemplo n.º 4
0
 public static bool updateStockAfterCheckout(int qty, int id)
 {
     if (qty > 0)
     {
         ShoeTable shoe = ShoeHandler.findShoeByID(id);
         int stockNow = shoe.ShoeStock - qty;
         updateStock(stockNow, id);
         return true;
     }
     return false;
 }
Exemplo n.º 5
0
 public static bool updateStock(int stock, int id)
 {
     if (stock > 0)
     {
         ShoeTable shoe = ShoeHandler.findShoeByID(id);
         ShoeRepository.updateShoe(shoe.ShoeId, shoe.ShoeName, shoe.ShoePrice, stock, shoe.ShoeImage);
         return true;
     }
     else
     {
         return false;
     }
 }
Exemplo n.º 6
0
 public static void addToCart(string shoeId, int UserId, string quantity)
 {
     if (shoeId.All(char.IsDigit) && quantity.All(char.IsDigit))
     {
         int id = Int32.Parse(shoeId);
         //int userId = Int32.Parse(UserId);
         int q = Int32.Parse(quantity);
         if (checkQuantity(quantity, id) && !checkSameProduct(UserId, id))
         {
             UserCart newCart = CartFactory.createCart(UserId, id, q);
             CartRepository.insertCart(newCart);
             ShoeHandler.incrementTotalSales(id);
         }
         else if (checkQuantity(quantity, id))
         {
             CartModel cart = CartHandler.getSpecificProductUserCart(UserId, id);
             int       qty  = cart.Quantity;
             qty += q;
             CartRepository.updateCart(cart.CartId, cart.UserId, cart.ShoeId, qty);
         }
     }
 }
Exemplo n.º 7
0
        public void loadData()
        {
            int             userID = Int32.Parse(Session["UserID"].ToString());
            List <UserCart> cart   = CartHandler.findCartByUserID(userID);

            cartDGV.DataSource = cart;
            cartDGV.DataBind();

            List <ShoeTable> shoeCart = new List <ShoeTable>();

            foreach (UserCart x in cart)
            {
                ShoeTable shoeTemp = ShoeHandler.findShoeByID(x.ShoeId);
                shoeCart.Add(shoeTemp);
            }

            productCart.DataSource = shoeCart;
            productCart.DataBind();


            shoeDGV.DataSource = ShoeRepository.getShoeData();
            shoeDGV.DataBind();
        }
Exemplo n.º 8
0
 public void loadData()
 {
     topDGV.DataSource = ShoeHandler.top5Product();
     topDGV.DataBind();
 }