private void ButtonVal_Click(object sender, EventArgs e) { if (CheckValidData()) { article.RefArticle = textBoxRef.Text; if (article != null) { DialogResult result; result = MessageBox.Show("Etes vous sur de vouloir modifier cet article?", "Attention : modification d'un article existant", MessageBoxButtons.YesNo); if (result == System.Windows.Forms.DialogResult.Yes) { article.RefArticle = textBoxRef.Text; article.Description = textBoxDescrip.Text; article.RefMarque = Marques.getRefMarqueFromName(comboBoxMar.SelectedItem.ToString()); article.RefSousFamille = SousFamilles.getRefSousFamilleFromName(comboBoxSsFam.SelectedItem.ToString()); article.PrixHT = (float)decimal.ToDouble(numericUpDown1.Value); article.Quantite = decimal.ToInt32(numericUpDown2.Value); article.updateInDB(); this.DialogResult = DialogResult.OK; this.Close(); } } else { DialogResult result; result = MessageBox.Show("Etes vous sur de vouloir ajouter cet article?", "Attention : ajout d'un nouvel article", MessageBoxButtons.YesNo); if (result == System.Windows.Forms.DialogResult.Yes) { article = new Articles(); article.RefArticle = textBoxRef.Text; if (article.loadFromDB() == null) { article.Description = textBoxDescrip.Text; article.RefMarque = Marques.getRefMarqueFromName(comboBoxMar.SelectedItem.ToString()); article.RefSousFamille = SousFamilles.getRefSousFamilleFromName(comboBoxSsFam.SelectedItem.ToString()); article.PrixHT = prix; article.Quantite = quantite; article.saveInDB(); this.DialogResult = DialogResult.OK; this.Close(); } else { MessageBox.Show("Impossible d'ajouter cet article", "Attention : ajout d'un article existant"); } } } } else { MessageBox.Show("Veuillez remplir correctement les champs", "Erreur"); } }