private void supprimerLarticleToolStripMenuItem_Click(object sender, EventArgs e) { Articles article = new Articles(); article.RefArticle = listView.Items[listView.SelectedIndices[0]].Text; DialogResult dr = MessageBox.Show("Voulez vous supprimer l'article " + article.RefArticle + " ? ", "Suppression article", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question); if (dr == DialogResult.Yes) { article.deleteFromDB(); listView.Items.Remove(listView.Items[listView.SelectedIndices[0]]); listView.Refresh(); } }
public AddOrModifyArticle(Articles Article = null) { InitializeComponent(); article = Article; updateComboMarque(); updateComboFamille(); if (article != null) { article = Article; Text = "Modification d'un article"; textBoxRef.Text = article.RefArticle; textBoxRef.Enabled = false; textBoxDescrip.Text = article.Description; numericUpDown1.Value = (decimal)article.PrixHT; numericUpDown2.Value = article.Quantite; } else { Text = "Ajout d'un article"; } }
private void listView_KeyDown(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Enter) { modificationArticle(); } else if (e.KeyCode == Keys.Delete) { Articles article = new Articles(); article.RefArticle = listView.Items[listView.SelectedIndices[0]].Text; DialogResult dr = MessageBox.Show("Voulez vous supprimer l'article " + article.RefArticle + " ? ", "Suppression article", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question); if (dr == DialogResult.Yes) { article.deleteFromDB(); listView.Items.Remove(listView.Items[listView.SelectedIndices[0]]); listView.Refresh(); } } else if (e.KeyCode == Keys.F5) { refreshListView(); } }