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 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131
| using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using BiblioTP3;
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
private Entreprise uneEntreprise;
private Produit unProduit;
List<Produit> lesProduits = new List<Produit>();
public Form1()
{
InitializeComponent();
uneEntreprise = new Entreprise("Sass");
unProduit = new Produit("code", "tomate", 5, 1, 15);
//lstGestion.Items.Add(unProduit); Ca ne marche pas !
}
private void Form1_Load(object sender, EventArgs e)
{
foreach (Produit unProd in lesProduits)
{
cmbCodeEntree.Items.Add(unProd.getCode());
unProduit.entrée(int.Parse(txtQuantiteAjout.Text));
}
}
private void btnQuit_Click(object sender, EventArgs e)
{
Close();
}
private void btnCreer_Click(object sender, EventArgs e)
{
int nb;
if (txtCode.Text == "" || txtLibelleProduit.Text == "" || txtQtiteMax.Text == "" || txtQtiteMin.Text == "" || txtQtiteStock.Text == "")
{
MessageBox.Show("Veuillez remplir tous les champs");
}
else if (!int.TryParse(txtQtiteMax.Text, out nb) || !int.TryParse(txtQtiteMin.Text, out nb) || !int.TryParse(txtQtiteStock.Text, out nb))
{
MessageBox.Show("Veuillez entrer des nombres aux champs appropriés");
}
else if (txtCode.Text == unProduit.getCode())
{
MessageBox.Show("Le code produit existe déjà ! ");
}
else
{
uneEntreprise.ajouterProduit(unProduit);
unProduit = new Produit(txtCode.Text, txtLibelleProduit.Text, int.Parse(txtQtiteStock.Text), int.Parse(txtQtiteMin.Text), int.Parse(txtQtiteMax.Text));
lstGestion.Items.Add("code : " + unProduit.getCode() + " Libellé :" + unProduit.getLibelle() + " Quantité en stock : " + unProduit.getQteStock());
cmbCodeEntree.Items.Add(unProduit.getCode());
MessageBox.Show("Le produit a été créé avec succès !");
txtCode.Clear();
txtLibelleProduit.Clear();
txtQtiteMin.Clear();
txtQtiteMax.Clear();
txtQtiteStock.Clear();
}
}
private void btnQuitter_Click(object sender, EventArgs e)
{
Close();
}
private void btnEffacer_Click(object sender, EventArgs e)
{
txtCode.Clear();
txtLibelleProduit.Clear();
txtQtiteMin.Clear();
txtQtiteMax.Clear();
txtQtiteStock.Clear();
}
private void btnQuitterEntree_Click(object sender, EventArgs e)
{
Close();
}
private void btnEnregistrerEntree_Click(object sender, EventArgs e)
{
int nb;
if (txtQuantiteAjout.Text == "")
{
MessageBox.Show("Veuillez remplir tous les champs !");
}
else if (!int.TryParse(txtQuantiteAjout.Text, out nb))
{
MessageBox.Show("Veuillez entrer un nombre pour la quantité !");
}
else
{
/*int ajout = int.Parse(txtQuantiteAjout.Text);
foreach (Produit unProd in lesProduits)
{
if (cmbCodeEntree.Text == txtCode.Text)
{
int total = unProduit.getQteStock() + ajout;
txtQtiteStock.Text = total.ToString();
unProduit.entrée(ajout);
}
}
int nombreProd = lesProduits.Count();
unProduit.entrée(int.Parse(txtQuantiteAjout.Text));*/
MessageBox.Show("La qantité "+txtQuantiteAjout.Text + " a été ajouté avec succès");
txtQuantiteAjout.Clear();
}
}
}
} |
Partager