예제 #1
0
        private void Ajouter_Click(object sender, EventArgs e)
        {
            var db = new dbContext();

            if (fournisseur.nomFournisseur != null)
            {
                try
                {
                    var           prod  = db.Produits.ToList <Produit>()[comboBox1.SelectedIndex];
                    Stock_Magazin stock = new Stock_Magazin();
                    stock.codeProduit    = prod.codeProduit;
                    stock.codeMagazin    = 1;
                    stock.dateExpiration = dateExpirePick.Value;
                    stock.quantite       = Convert.ToInt32(tbQuantite.Text);
                    db.Stock_Magazin.Add(stock);
                    db.SaveChanges();
                    MessageBox.Show("Produit ajouté!", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    this.Close();
                    //refrech flowlayoutpanel1
                    if (formParent.filter == 0)
                    {
                        formParent.btnViewAll_Click(null, null);
                    }
                    else if (formParent.filter == 1)
                    {
                        formParent.btnDisponible_Click(null, null);
                    }
                    else if (formParent.filter == 2)
                    {
                        formParent.btnNonDisponible_Click(null, null);
                    }
                    Form1.SetMessageLog("L'ajout d'un nouveau stock de " + prod.libelle + ", quantité: " + stock.quantite + ", date d'expiration: " + stock.dateExpiration);
                }
                catch (Exception exc)
                {
                    MessageBox.Show("Error! " + exc.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
            }
            else
            {
                MessageBox.Show("Veuillez remplir tous les champs demandés", "Error", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }
예제 #2
0
 private void FormProdDescri_FormClosing(object sender, FormClosingEventArgs e)
 {
     //refrech flowlayoutpanel1
     if (!isDetailleFourn)
     {
         if (formParent.filter == 0)
         {
             formParent.btnViewAll_Click(null, null);
         }
         else if (formParent.filter == 1)
         {
             formParent.btnDisponible_Click(null, null);
         }
         else if (formParent.filter == 2)
         {
             formParent.btnNonDisponible_Click(null, null);
         }
     }
     else
     {
         var db = new dbContext();
         formParrent2.remplireLayout(db);
     }
 }