public static void Insert(Article a)
        {
            Program.DbConnection.Open();
            string strsql = "INSERT INTO article VALUES (?,?,?,?,?,?,?)";
            OleDbCommand cmd = new OleDbCommand(strsql, Program.DbConnection);
            OleDbParameter p1 = new OleDbParameter("pref", OleDbType.Integer);
            OleDbParameter p2 = new OleDbParameter("pdesign", OleDbType.VarChar);
            OleDbParameter p3 = new OleDbParameter("pprix", OleDbType.Single);
            OleDbParameter p4 = new OleDbParameter("pquantite", OleDbType.Integer);
            OleDbParameter p5 = new OleDbParameter("ppromo", OleDbType.Boolean);
            OleDbParameter p6 = new OleDbParameter("pDatePromo", OleDbType.Date);
            OleDbParameter p7 = new OleDbParameter("pVersion", OleDbType.Date);

            p1.Value = a.Ref;
            p2.Value = a.Designation;
            p3.Value = a.Prix;
            p4.Value = a.Quantite;
            p5.Value = a.Promo;
            p6.Value = a.DatePromo;
            p7.Value = DateTime.Now;

            cmd.Parameters.Add(p1);
            cmd.Parameters.Add(p2);
            cmd.Parameters.Add(p3);
            cmd.Parameters.Add(p4);
            cmd.Parameters.Add(p5);
            cmd.Parameters.Add(p6);
            cmd.Parameters.Add(p7);

            cmd.ExecuteNonQuery();
            Program.DbConnection.Close();
        }
 private void BtnAjout_Click(object sender, EventArgs e)
 {
     String[] ObjetArticle = ListeArticlesComBx.Text.Split('|');
     Article A = new Article();
     A = DAL_Article.SelectByRef(int.Parse(ObjetArticle[0]));
     if(A.Quantite < Quantite.Value)
     {
         MessageBox.Show("Quantité d'article insufisante !\nVous avez que " + A.Quantite + " articles dans votre stock.", "Erreur", MessageBoxButtons.OK, MessageBoxIcon.Stop);
     }
     else
     {
         Article CurrArticle = DAL_Article.SelectByRef(int.Parse(ObjetArticle[0]));
         AddFacture.RowVersion = CurrArticle.Version = DateTime.Now;
         DAL_Article.Update(CurrArticle, CurrArticle);
         AddFacture.ListeA.Add(new DetailArticleModelView(int.Parse(ObjetArticle[0]),ObjetArticle[1],int.Parse(Quantite.Value.ToString())));
         this.Close();
     }
 }
        // Constructeur paramétré
        public FormArticle(Article a, string ModeUtilisation)
        {
            InitializeComponent();
            CtrlsErrors = new List<ControlError>();
            switch (ModeUtilisation)
            {
                case "AJOUT" :
                    this.PanelAjout.Visible = true;
                    this.PanelModification.Visible = false;
                    break;
                case "MODIFICATION" :
                     this.PanelAjout.Visible = false;
                    this.PanelModification.Visible = true;
                    if (a != null)
                    {
                        this.BindDataToInterface(a);
                        this.OldRef = Int32.Parse(this.TxtRef.Text);
                    }
                    else
                        MessageBox.Show("Objet nn alloué");

                    break;
            }
        }
 Article GetArticleFromDGV(DataGridViewRow dgvr)
 {
     Article a = new Article();
     a.Ref = (int)dgvr.Cells[0].Value;
     a.Designation = (string)dgvr.Cells[1].Value;
     a.Prix = (float)dgvr.Cells[2].Value;
     a.Quantite = (int)dgvr.Cells[3].Value;
     a.Promo = (bool)dgvr.Cells[4].Value;
     a.DatePromo = (DateTime)dgvr.Cells[5].Value;
     return a;
 }
 /******************************************************************************
 *
 *                Méthodes utilitaires
 *
 * ****************************************************************************/
 Article GetDataFromInterface()
 {
     Article a = new Article();
     a.Ref = Int32.Parse(this.TxtRef.Text);
     a.Designation = this.TxtDesignation.Text;
     a.Prix = Single.Parse(this.TxtPrix.Text);
     a.Quantite = Int32.Parse(this.TxtQuantite.Text);
     a.Promo = this.ChkPromo.Checked;
     a.DatePromo = this.dateTimeDatePromo.Value.Date;
     return a;
 }
 void BindDataToInterface(Article a)
 {
     this.TxtRef.Text = a.Ref.ToString();
     this.TxtDesignation.Text = a.Designation;
     this.TxtPrix.Text = a.Prix.ToString();
     this.TxtQuantite.Text = a.Quantite.ToString();
     this.ChkPromo.Checked = a.Promo;
     this.dateTimeDatePromo.Value = a.DatePromo;
 }
 public static void Delete(Article a)
 {
     Delete(a.Ref);
 }
        public static void Update(int OldRef, Article NewArticle)
        {
            Program.DbConnection.Open();
            string strsql = "UPDATE ARTICLE SET Ref=?, Designation=?, Prix=?, Quantite= ?, Promo= ?, DatePromo= ? WHERE REF= ?";

            OleDbCommand cmd = new OleDbCommand(strsql, Program.DbConnection);
            OleDbParameter p1 = new OleDbParameter("pNewRef", OleDbType.Integer);
            OleDbParameter p2 = new OleDbParameter("pdesign", OleDbType.VarChar);
            OleDbParameter p3 = new OleDbParameter("pprix", OleDbType.Single);
            OleDbParameter p4 = new OleDbParameter("pquantite", OleDbType.Integer);
            OleDbParameter p5 = new OleDbParameter("ppromo", OleDbType.Boolean);
            OleDbParameter p6 = new OleDbParameter("pDatePromo", OleDbType.Date);
            OleDbParameter p7 = new OleDbParameter("pOldRef", OleDbType.Integer);

            p1.Value = NewArticle.Ref;
            p2.Value = NewArticle.Designation;
            p3.Value = NewArticle.Prix;
            p4.Value = NewArticle.Quantite;
            p5.Value = NewArticle.Promo;
            p6.Value = NewArticle.DatePromo;
            p7.Value = OldRef;

            cmd.Parameters.Add(p1);
            cmd.Parameters.Add(p2);
            cmd.Parameters.Add(p3);
            cmd.Parameters.Add(p4);
            cmd.Parameters.Add(p5);
            cmd.Parameters.Add(p6);
            cmd.Parameters.Add(p7);
            cmd.ExecuteNonQuery();
            Program.DbConnection.Close();
        }