using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace AP8___BDE_CANIAUX_Romain
{
    public partial class Vendre_produit : Form
    {
        public Vendre_produit()
        {
            InitializeComponent();
        }

        private void btn_valider_Click(object sender, EventArgs e)
        {
            Stock.sweat -= (int)nud_sweat.Value;
            Stock.mug -= (int)nud_mug.Value;
            Stock.polo -= (int)nud_polo.Value;
            Stock.gourde -= (int)nud_gourde.Value;
            Stock.PrixS = (int)nud_sweat.Value * int.Parse(txt_box_prix_sweat.Text);
            Stock.PrixM = (int)nud_mug.Value * int.Parse(txt_box_prix_mug.Text);
            Stock.PrixP = (int)nud_polo.Value * int.Parse(txt_box_prix_polo.Text);
            Stock.PrixG = (int)nud_gourde.Value * int.Parse(txt_box_prix_gourde.Text);
            Stock.PrixTotal = Stock.PrixS + Stock.PrixM + Stock.PrixP + Stock.PrixG;
            MessageBox.Show("Vous venez de vendre" +nud_sweat.Value+" Sweats à " +txt_box_prix_sweat.Text+ " et  "+nud_mug.Value +"  Mugs à "+txt_box_prix_mug.Text+ " et  "+nud_polo.Value +"Polos à "+txt_box_prix_polo.Text +" et "+nud_gourde.Value+" Gourde à "+txt_box_prix_gourde.Text +" pour un total de " + Stock.PrixTotal + " Euros  ");

        }

        private void btn_retour_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void Vendre_produit_Load(object sender, EventArgs e)
        {
            txt_box_prix_sweat.Text = "0";
            txt_box_prix_mug.Text = "0";
            txt_box_prix_polo .Text = "0";
            txt_box_prix_gourde.Text = "0";

            nud_sweat.Maximum = Stock.sweat;
            nud_mug.Maximum = Stock.mug;
            nud_polo .Maximum = Stock.polo;
            nud_gourde .Maximum = Stock.gourde;

            if (Stock.sweat == 0)
            {
                nud_sweat.Enabled = false;
                txt_box_prix_sweat.Enabled = false;
            }
            if (Stock.mug == 0)
            {
                nud_mug.Enabled = false;
                txt_box_prix_mug.Enabled=false;
            }
            if (Stock.polo == 0)
            {
                nud_polo.Enabled = false;
                txt_box_prix_polo.Enabled=false;
            }
            if (Stock.gourde == 0)
            {
                nud_gourde.Enabled = false;
                txt_box_prix_gourde.Enabled=false;
            }
        }
    }
}
