Example #1
0
 public static void AjoutLignecom(Produit produit,Ligne_commande ligcom)
 {
     using (SqlConnection conx = ConnectionDB.getConnection())
     {
         using (SqlCommand cmd = conx.CreateCommand())
         {
             cmd.CommandType = CommandType.StoredProcedure;
             cmd.CommandText = "insertion_Lignecommande";
             SqlParameter produit_nom = new SqlParameter("@produit", SqlDbType.NVarChar);
             produit_nom.Direction = ParameterDirection.Input;
             produit_nom.Value = produit.libelle;
             cmd.Parameters.Add(produit_nom);
             SqlParameter produit_qte = new SqlParameter("@qte", SqlDbType.Int);
             produit_qte.Direction = ParameterDirection.Input;
             produit_qte.Value = ligcom.qte_produit;
             cmd.Parameters.Add(produit_qte);
              cmd.Connection = conx;
             cmd.ExecuteNonQuery();
         }
     }
 }
Example #2
0
 public static void ajoutlignecom(Produit produit, Ligne_commande ligncom)
 {
     DataLayer.CrudLigne_Commande.AjoutLignecom(produit, ligncom);
 }
Example #3
0
        private void button_com_2_Click(object sender, EventArgs e)
        {
            ModelLayer.Client client = new Client(comboBox_client.SelectedItem.ToString(), textBox_prenom.Text);
            ModelLayer.Adresse addresse = new Adresse(textBox_add_liv.Text, textBox_cp_liv.Text, textBox_ville_liv.Text);
            ModelLayer.Commande commande = new Commande(dateTimePicker1.Value);
            CommandeOperation.ajoutCommande2(commande, client, addresse);

            int a = dataGridView3.Rows.Count;
            for (int i = 0; i < a; i++)
            {
                string libelle = dataGridView3[1, i].Value.ToString();
                int qte = Convert.ToInt32(dataGridView3[3, i].Value.ToString());
                Ligne_commande ligncom = new Ligne_commande(qte);
                Produit produit = new Produit(libelle);
                Ligne_CommandeOperation.ajoutlignecom(produit, ligncom);
            }
            dataGridView3.Rows.Clear();
            textBox_add_liv.Clear();
            textBox_cp_liv.Clear();
            textBox_ville_liv.Clear();
            comboBox_client.Text = "";
            radioButton7.Checked = true;
        }