private void btAjouterCategorie_Click(object sender, EventArgs e) // Ajouter { Requete_Sql = "insert into categorie values (null,null)"; sc.AjoutSupModifProduitSql(Requete_Sql); Requete_Sql = "select * from categorie"; List <ServiceWCF.ClsStockProduit> TableCateg = new List <ServiceWCF.ClsStockProduit>(); TableCateg.AddRange(sc.LireCategorieSql(Requete_Sql)); dgvArticle.DataSource = TableCateg; dgvArticle.Columns["Id"].Visible = false; }
// Commande client #region validation commande private void btValiderPanier_Click(object sender, EventArgs e) { string Txt = ""; Requete_Sql = @"select * from panier where id_client = " + PageAcceuil.NumUtilisateur; List <ServiceWCF.ClsPanier> lTablePanier = new List <ServiceWCF.ClsPanier>(); lTablePanier.AddRange(sc.LireTablePanierSql(Requete_Sql)); ServiceWCF.ClsPanier[] tabCmdClient = lTablePanier.ToArray(); List <ServiceWCF.ClsStockProduit> lTableStock = new List <ServiceWCF.ClsStockProduit>(); ServiceWCF.ClsStockProduit clsp = new ServiceWCF.ClsStockProduit(); int quantite_stock = 0; for (int i = 0; i < tabCmdClient.Length; i++) { Txt = ""; Txt += tabCmdClient[i].Id_Client; Txt += ";"; Txt += tabCmdClient[i].Id_produit; Txt += ";"; Txt += DateTime.Today.ToShortDateString(); Txt += ";"; Txt += "null"; Txt += ";"; Txt += tabCmdClient[i].Prix_Vente; Txt += ";"; Txt += tabCmdClient[i].Quantite; Txt += ";"; Txt += tabCmdClient[i].Somme; // Copie du produit panier dans la table Commande client Requete_Sql = @"insert into cmd_client set id_utilisateur = " + tabCmdClient[i].Id_Client + ", id_produit = " + tabCmdClient[i].Id_produit + ", date_cmd = current_date, date_livraison = null , prix_unitaire = " + tabCmdClient[i].Prix_Vente + ", quantite = " + tabCmdClient[i].Quantite + ", prix_quantite = " + tabCmdClient[i].Somme; sc.AjoutSupModifCmdClientSql(Requete_Sql); // Calcul de la quantité du stock quantite_stock = 0; Requete_Sql = @"select * from produit where id = " + tabCmdClient[i].Id_produit; lTableStock.AddRange(sc.LireStockProduitSql(Requete_Sql)); ServiceWCF.ClsStockProduit[] tabstock = lTableStock.ToArray(); quantite_stock = tabstock[i].Quantite_Stock - tabCmdClient[i].Quantite; Requete_Sql = @"update produit set quantite_stock = " + quantite_stock + " where id = " + tabstock[i].Id; sc.AjoutSupModifProduitSql(Requete_Sql); RafraichirPanier(); // Effacement du panier Requete_Sql = @"delete from panier where id_client = " + tabCmdClient[i].Id_Client; sc.AjoutSupModifPanierSql(Requete_Sql); RafraichirPanier(); } RafraichirCmdClient(); }