Exemple #1
0
        // Validation de la ligne de produit
        private void buttonValiderProduit_Click(object sender, EventArgs e)
        {
            // todo reference déjà dans le panier
            txtMessageP.Text = " ";
            // création de la ligne de commande
            LigneCommandeClient laLigne = new LigneCommandeClient(qte, laCommande, leProduit);

            // insertion dans la collection
            laCommande.getLesLignes().Add(laLigne);
            // ajout de la ligne dans le datagrid
            double totalLigne = Convert.ToDouble(textBoxPUHT.Text) * Int32.Parse(textBoxQuantite.Text);

            //Image imgPoubelle = Image.FromFile(@"C:\Users\Brigitte\Google Drive\Travail\2016-2017\PPE\L3B\L3BV1\sol_gestionPriseCommande - Les3Belges\gestionPriseCommande\Resources\Poubelle3.png");

            //Bitmap bmImgPoubelle = new Bitmap(imgPoubelle);
            string[] ligne = { textBoxReference.Text, textBoxNomProduit.Text, textBoxCouleur.Text, textBoxTaille.Text, textBoxPUHT.Text, textBoxQuantite.Text, textBoxEtat.Text, totalLigne.ToString() };
            dataGridViewListeProduit.Rows.Add(ligne);
            dataGridViewListeProduit.AutoSize = true;
            //maj total commande
            double totCde = laCommande.getMontantCommandeTTC() + totalLigne;

            laCommande.setMontantCommandeTTC(totCde);
            textBoxTotCde.Text = totCde.ToString();
            textBoxTva.Text    = (Math.Round(totCde * leProduit.getTauxTVA() / 100, 2)).ToString();
            razPanel(panel1);
            txtMessageP.Text = "Entrez une référence et appuyez sur entrée ou validez le panier";
        }
        /// <summary>
        /// Insère une ligne dans ligneCommandeClient
        /// </summary>
        /// <param name="uneLigne">objet Ligne</param>
        /// <returns>retourne 1 si ok, 0 sinon</returns>
        public static int creerLigneCommande(LigneCommandeClient uneLigne)
        {
            int    num       = uneLigne.getLaCommande().getNumCommande();
            string reference = uneLigne.getLeProduit().getReference();
            int    qte       = uneLigne.getLaQuantité();
            double prixv     = uneLigne.getLeProduit().getPrixUHTProduit();
            // remplacement virgule décimale par point décimal ...............à améliorer
            string   prixP     = prixv.ToString().Replace(",", ".");
            string   requete   = "INSERT INTO ligneCommandeClient VALUES( " + num + ",'" + reference + "'," + qte + "," + prixP + ", 0, ' ')";
            ClassReq reqInsLig = new ClassReq(requete);
            int      resultat  = reqInsLig.ExecuteIUD();

            return(resultat);
        }
        /// Retourne une collection de LigneCommandeClient de la commande uneCOmmande
        /// </summary>
        /// <param name="uneCommande"></param>
        /// <returns>Collection LigneCommandeClient</returns>
        public static List <LigneCommandeClient> getLignesCmd(Commande uneCommande)
        {
            LigneCommandeClient        uneLigne  = null;
            List <LigneCommandeClient> lesLignes = new List <LigneCommandeClient>();

            string req = "SELECT * FROM LIGNECOMMANDECLIENT WHERE NUMCOMMANDE =" + uneCommande.getNumCommande();

            ClassReq  ReqCli = new ClassReq(req);
            DataTable res    = new DataTable();

            res = ReqCli.ExecuteSelect();

            foreach (DataRow ligne in res.Rows)
            {
                int    uneQuantiteProduit = Convert.ToInt32(ligne["QUANTITEPRODUIT"]);
                string refProd            = ligne["REFERENCEPROD"].ToString();


                uneLigne = new LigneCommandeClient(uneQuantiteProduit, uneCommande, getProduit(refProd));
                lesLignes.Add(uneLigne);
            }

            return(lesLignes);
        }