1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
| using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Drawing;
namespace GestionBar
{
class BoutonProduit : Button
{
private Produit produitBouton = new Produit();
public BoutonProduit(Produit ProduitBouton)
: base()
{
this.produitBouton = ProduitBouton;
this.Height = 120;
this.Width = 120;
this.Margin = new Padding(0);
this.BackgroundImage = Image.FromFile(this.produitBouton.Image);
this.Font = new Font(this.Font, FontStyle.Bold);
this.TextAlign = ContentAlignment.MiddleCenter;
if (this.produitBouton.Stock == 0)
{
this.Text = "Plus en stock";
}
}
public Produit ProduitBouton
{
get{ return produitBouton; }
}
protected override void OnClick(EventArgs e)
{
base.OnClick(e);
this.produitBouton.Stock--;
if(this.produitBouton.Stock==0)
{
this.Text = "Plus en stock";
}
}
}
} |
Partager