Esempio n. 1
0
        private void button1_Click(object sender, EventArgs e)
        {
            if (numericUpDown3.Value < 10000 && numericUpDown1.Value < 10000 && numericUpDown2.Value < 10000 && Produits.Text != "" && comboBox1.Text != "" && numericUpDown1.Value > 0 && numericUpDown3.Value < 10000)
            {
                try
                {
                    var testQMoin = from t in data.Produit where t.NumProduit == indexNumPruduit select t;

                    if (int.Parse(testQMoin.Single().quantité.ToString()) - int.Parse(numericUpDown1.Value.ToString()) >= 0)
                    {
                        var a = new Achate();
                        a.NumProduit      = indexNumPruduit;
                        a.NumVendeur      = (from v in data.Vendeur where v.nameVendeur == comboBox1.Text select v.NumVendeur).Single();
                        a.prixAchate      = int.Parse(numericUpDown2.Value.ToString());
                        a.quantitéProduit = int.Parse(numericUpDown1.Value.ToString());
                        a.dateAchate      = dateTimePicker2.Value;
                        a.commenter       = richTextBox1.Text;
                        a.payment         = int.Parse(numericUpDown3.Value.ToString());
                        data.Achate.InsertOnSubmit(a);
                        testQMoin.Single().quantité = int.Parse(testQMoin.Single().quantité.ToString()) - int.Parse(numericUpDown1.Value.ToString());;
                        data.SubmitChanges();

                        afficher();
                        effacer_champ();
                        MessageBox.Show(" produit ajouter successful");
                    }
                    else
                    {
                        MessageBox.Show(" aucune quantité produite ", "attention", MessageBoxButtons.OK, MessageBoxIcon.Stop);
                    }
                }
                catch
                {
                    MessageBox.Show("error systeme ", "attention", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            else
            {
                if (Produits.Text == "")
                {
                    MessageBox.Show("incorrect ajouter  nom produit vide !!", "attention", MessageBoxButtons.OK, MessageBoxIcon.Stop);
                }
                else if (numericUpDown1.Value == 0)
                {
                    MessageBox.Show("impossible  Quantité Produit est 0 !!", "attention", MessageBoxButtons.OK, MessageBoxIcon.Stop);
                }

                else
                {
                    MessageBox.Show("champ Nom Vendeur est vide !!", "attention", MessageBoxButtons.OK, MessageBoxIcon.Stop);
                }
            }
        }
 private void attach_Achate1(Achate entity)
 {
     this.SendPropertyChanging();
     entity.Vendeur1 = this;
 }
 private void detach_Achate1(Achate entity)
 {
     this.SendPropertyChanging();
     entity.Vendeur1 = null;
 }
 partial void DeleteAchate(Achate instance);
 partial void UpdateAchate(Achate instance);
 partial void InsertAchate(Achate instance);
 private void detach_Achate(Achate entity)
 {
     this.SendPropertyChanging();
     entity.Produit = null;
 }
 private void attach_Achate(Achate entity)
 {
     this.SendPropertyChanging();
     entity.Produit = this;
 }