protected void DeleteBtn_Click(object sender, EventArgs e) { int deleteID = Int32.Parse(delShoeID.Text); ShoeTable delShoe = ShoeHandler.findShoeByID(deleteID); ShoeRepository.deleteShoe(delShoe); loadData(); }
public static int checkStock(int id) { ShoeTable shoe = ShoeHandler.findShoeByID(id); if (shoe != null) { return shoe.ShoeStock; } return -1; }
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; }
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; } }
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(); }