BJR, j'ai une table inventaire je veux introduire des données, mais en même temps je veux que chaque enregistrement soit vérifier s'il existe déjà
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
 private void Ajout_inventaire()
        {
            OleDbConnection con = new OleDbConnection(Program.con);
            string position = cmb_inv_posit.Text;
            bool nature = false;
            bool affiche = false;
            if (text_code_prod_inv.Text == string.Empty & combo_inv_famille.Text == string.Empty & combo_inv_marq.Text == string.Empty & combo_inv_desig.Text == string.Empty & txt_inv_qnt.Value == 0)
            {
                MessageBox.Show("Veuiller saisir votre produit....!");
            }
 
                con.Open();
                cmd.Connection = con;
                if (fromDGVinventaire)
                {
                    //inv_txt_observation.Text = "";
                    cmd.CommandText = "INSERT INTO INVENTAIRE (Code, FAMILLE, MARQUE, DESIGNATION, NATURE, STOCK_MIN, AFFICHE, QNT, [POSITION], EMPLACEMENT, OBSERVATION, DATE_INV ) VALUES ('" + text_code_prod_inv.Text + "' , '" + combo_inv_famille.Text + "' , '" + combo_inv_marq.Text + "' , '" + combo_inv_desig.Text + "' , " + nature + " , " + txt_inv_stock_min.Text + " , " + affiche + " , " + txt_inv_qnt.Text + " , '" + cmb_inv_posit.Text + "' , '" + emplaceme + "' , '" + inv_txt_observation.Text + "' , #" + inv_date.Text + "#)";
                    cmd.ExecuteNonQuery();
                    con.Close();
                    vider_champ_inventaire();
                    getdata_inventaire();
                }
                else
                {
                    cmd.CommandText = " UPDATE INVENTAIRE SET INVENTAIRE.QNT =" + txt_inv_qnt.Text + ", NATURE= " + nature + ", STOCK_MIN= " + txt_inv_stock_min.Text + ", AFFICHE= " + affiche + ", [POSITION]='" + cmb_inv_posit.Text + "', EMPLACEMENT='" + emplaceme + "', OBSERVATION='" + inv_txt_observation.Text + "', DATE_INV=#" + inv_date.Text + "# WHERE (((INVENTAIRE.Code)='" + text_code_prod_inv.Text + "'))";
                    cmd.ExecuteNonQuery();
                    con.Close();
                    vider_champ_inventaire();
                    getdata_inventaire();
 
                }
 
               fromDGVinventaire = false;
help