Exemple #1
0
        private void button_Retrait_Click(object sender, EventArgs e)
        {
            if (Validateur.itemSelectionneLV(listView_Commande))
            {
                int    itemCommandeSelectionne = listView_Commande.FocusedItem.Index;
                string quantiteCommandee;
                string isbnCommande;


                Commande uneCommande = new Commande();

                isbnCommande = listView_Commande.SelectedItems[0].Text;

                quantiteCommandee = listView_Commande.SelectedItems[0].SubItems[3].Text;

                livreVersStock(isbnCommande, quantiteCommandee);

                afficherListeLivresStockees(listeLivres);
                totalLivre -= decimal.Parse(listView_Commande.SelectedItems[0].SubItems[3].Text.ToString());
                listView_Commande.Items.RemoveAt(listView_Commande.FocusedItem.Index);

                label_total.Text = totalLivre.ToString();
                MessageBox.Show("La commande a été retirée", "Supression commande", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
            }
        }
Exemple #2
0
        private void button_Ajout_Click(object sender, EventArgs e)
        {
            if (Validateur.itemSelectionneLV(listView_Livre) && !Validateur.estVide(textBox_Quantite) &&
                Validateur.EstNumerique(textBox_Quantite))
            {
                int itemLivreSelectionne = listView_Livre.FocusedItem.Index;

                decimal totalPourunlivre = 0;
                int     stockLivre;

                Livre unLivre = new Livre();
                unLivre = listeLivres.ElementAt(itemLivreSelectionne);


                Client unClient = new Client();
                unClient.ClientNom = comboBox_Client.Text;
                MessageBox.Show(unClient.ClientNom.ToString());
                //ListeClients.rechercherClNom(unClient.ClientNom.ToString());



                totalPourunlivre = decimal.Parse(textBox_Quantite.Text.Trim()) * decimal.Parse(unLivre.PUnitaire.ToString());
                totalLivre      += totalPourunlivre;

                ListViewItem item = new ListViewItem(unLivre.isBN);
                item.SubItems.Add(unLivre.Titre);
                item.SubItems.Add(unLivre.PUnitaire.ToString());
                item.SubItems.Add(textBox_Quantite.Text.Trim());
                item.SubItems.Add(totalPourunlivre.ToString());
                item.SubItems.Add(comboBox_Client.Text);
                listView_Commande.Items.Add(item);

                label_total.Text = totalLivre.ToString();

                stockLivre            = int.Parse(unLivre.QuantiteDispo.ToString()) - int.Parse(textBox_Quantite.Text.Trim());
                unLivre.QuantiteDispo = Convert.ToInt32(stockLivre);

                listeLivres[itemLivreSelectionne] = unLivre;
                afficherListeLivresStockees(listeLivres);
                textBox_Quantite.Text = "";
            }
        }