public void InitializeComp(System.Collections.Generic.List <Produit_commande> listProduit) { InitializeComponent(); foreach (var p in listProduit) { ElementPagnierVentes elmnt = new ElementPagnierVentes(false); elmnt.Title = p.Produit.libelle; elmnt.Id = p.codeProduit; elmnt.Icon = p.Produit.img != null?Image.FromStream(new MemoryStream(p.Produit.img)) : Properties.Resources.loading_product; elmnt.Description = p.Produit.description; elmnt.QuntiteProduit = p.quantite + ""; elmnt.PrixUnit = p.Produit.prixAchat; elmnt.PrixTotal = p.quantite * p.Produit.prixAchat + ""; this.Text = "Produit(s) commander dans la commande N'" + p.NCommande; this.flowLayoutPanel1.Controls.Add(elmnt); } }
private void labelHiden_TextChanged(object sender, EventArgs e) { if (labelHiden.Text != "") { nbCommandes++; labelNbCommande.Text = nbCommandes + ""; int idProduit = int.Parse(labelHiden.Text.Split(' ')[0]); int quantiteDemander = int.Parse(labelHiden.Text.Split(' ')[1]); pictureBox.Image = Properties.Resources.closed_box; Produit p = produitVentes.Where(pa => pa.codeProduit == idProduit).FirstOrDefault <Produit>(); if (p == null) { return; } var dbase = new dbContext(); ElementPagnierVentes elmnt = new ElementPagnierVentes(); elmnt.Title = p.libelle; elmnt.MaxQuantite = 10000; elmnt.Gain = (p.prixVente - p.prixAchat) * quantiteDemander; elmnt.Id = p.codeProduit; elmnt.Icon = p.img != null?Image.FromStream(new MemoryStream(p.img)) : Properties.Resources.loading_product; elmnt.Description = p.description; elmnt.Quantite = quantiteDemander; elmnt.QuntiteProduit = quantiteDemander + ""; elmnt.PrixUnit = p.prixAchat; elmnt.PrixTotal = p.prixAchat * quantiteDemander + ""; foreach (Control item in flowLayoutPagnierProduitCommandes.Controls) { ElementPagnierVentes epv = (ElementPagnierVentes)item; if (epv.Id == elmnt.Id) { epv.Quantite = quantiteDemander; labelNbCommande.Text = --nbCommandes + ""; return; } } flowLayoutPagnierProduitCommandes.Controls.Add(elmnt); labelHiden.Text = ""; } labelHiden.Text = ""; }
private void listBoxItemProduct_TextChanged(object sender, EventArgs e) { if (listBoxItemProduct.Text != "") { var dbase = new dbContext(); this.pictureBoxBasket.Image = Properties.Resources.cart__full; Produit p = produitVentes.Where(pa => pa.codeProduit == int.Parse(listBoxItemProduct.Text.Split(' ')[0])).ToList()[0]; labelBasket.Text = ++nbProduitInBasket + ""; var stock_produit_tables = dbase.Stock_Magazin.Where(s => s.Produit.libelle == p.libelle).ToList(); int quantity = 0; foreach (var elm in stock_produit_tables) { quantity += elm.quantite; } ElementPagnierVentes elmnt = new ElementPagnierVentes(); elmnt.Title = p.libelle; elmnt.MaxQuantite = quantity; elmnt.Gain = (p.prixVente - p.prixAchat) * int.Parse(listBoxItemProduct.Text.Split(' ')[1]); elmnt.Id = p.codeProduit; elmnt.Icon = p.img != null?Image.FromStream(new MemoryStream(p.img)) : Properties.Resources.loading_product; elmnt.Description = p.description; elmnt.Quantite = int.Parse(listBoxItemProduct.Text.Split(' ')[1]); elmnt.QuntiteProduit = listBoxItemProduct.Text.Split(' ')[1]; elmnt.PrixUnit = p.prixVente; elmnt.PrixTotal = p.prixVente * int.Parse(listBoxItemProduct.Text.Split(' ')[1]) + ""; foreach (Control item in flowLayoutPagnierProduitVentes.Controls) { ElementPagnierVentes epv = (ElementPagnierVentes)item; if (epv.Id == elmnt.Id) { epv.Quantite = int.Parse(listBoxItemProduct.Text.Split(' ')[1]); labelBasket.Text = --nbProduitInBasket + ""; return; } } flowLayoutPagnierProduitVentes.Controls.Add(elmnt); listBoxItemProduct.Text = ""; } }