public static void Insert(DetailFacture df) { Program.DbConnection.Open(); string strsql = "INSERT INTO DetailFacture(RefFacture,RefArticle,Quantite) VALUES (?,?,?)"; OleDbCommand cmd = new OleDbCommand(strsql, Program.DbConnection); OleDbParameter p1 = new OleDbParameter("prefF", OleDbType.Integer); OleDbParameter p2 = new OleDbParameter("prefA", OleDbType.Integer); OleDbParameter p3 = new OleDbParameter("pqt", OleDbType.Integer); p1.Value = df.RefFacture; p2.Value = df.RefArticle; p3.Value = df.Quantite; cmd.Parameters.Add(p1); cmd.Parameters.Add(p2); cmd.Parameters.Add(p3); int x = cmd.ExecuteNonQuery(); if (x < 1) MessageBox.Show("Echec : [Modification].", "Article", MessageBoxButton.OK); Program.DbConnection.Close(); }
int AddDatilFacture() { try { List<DetailFacture> ListeDetailFacture = new List<DetailFacture>(); foreach (DetailArticleModelView df in ListeA) { DetailFacture ddf = new DetailFacture(int.Parse(RefFac.Text), df.Ref, df.Quantite); ListeDetailFacture.Add(ddf); } foreach (DetailFacture df in ListeDetailFacture) { DAL_Article.UpdateQuantite(df.RefArticle, df.Quantite, RowVersion); DetailFacture.Insert(df); } return 0; } catch (Exception ex) { MessageBox.Show("[ERROR] : " + ex.Message); return 1; } }