private void btnAdd_Click(object sender, EventArgs e) { if (curGame.gameQuantity > 0) { if (!cart.cart.ContainsKey(curGame.gameID)) { tblOrdergame detail = new tblOrdergame { gameID = curGame.gameID, numOfgame = 1, tblGame = curGame, pricegame = curGame.gamePrice }; MessageBox.Show("Added Successfully!!"); cart.addToCart(detail); } else { if (cart.cart[curGame.gameID].numOfgame < curGame.gameQuantity) { tblOrdergame detail = new tblOrdergame { gameID = curGame.gameID, numOfgame = 1, tblGame = curGame, pricegame = curGame.gamePrice }; cart.addToCart(detail); MessageBox.Show("Added Successfully!!"); } else { MessageBox.Show("Out of stock"); } } } else { MessageBox.Show("Out of stock"); } }
public ProductDetail(tblOrdergame detail) : this() { this.detail = detail; picture.ImageLocation = @"..\..\..\images\" + detail.tblGame.gameImage; picture.SizeMode = PictureBoxSizeMode.StretchImage; lblName.Text = detail.tblGame.gameName; lblQuanity.Text = detail.numOfgame.ToString(); }
public void addToCart(tblOrdergame detail) { if (this.cart.ContainsKey(detail.gameID)) { int quantity = this.cart[detail.gameID].numOfgame.Value + 1; detail.numOfgame = quantity; } this.cart[detail.gameID] = detail; }
public void reduceQuantity(tblOrdergame detail) { if (this.cart.ContainsKey(detail.gameID)) { if (this.cart[detail.gameID].numOfgame != 1) { int quantity = this.cart[detail.gameID].numOfgame.Value - 1; detail.numOfgame = quantity; } } this.cart[detail.gameID] = detail; }