/// <summary> /// Raised when the user clicks on the listview. If it's a right click on an article, create a CMS to let the user choose an action /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void LvItems_MouseUp(object sender, MouseEventArgs e) { if (LvItems.Columns.Count > 0) { if (e.Button.Equals(MouseButtons.Right) && LvItems.Columns[0].Text == "RefArticle" && LvItems.SelectedItems.Count == 1) { string RefArticle = LvItems.SelectedItems[0].Text; CmsModify.Items.Clear(); CmsModify.Items.Add("Ajouter un article"); CmsModify.Items[0].Tag = "AddArticle"; CmsModify.Items.Add("Modifier l'article : " + RefArticle); CmsModify.Items[1].Tag = "EditArticle"; CmsModify.Items.Add("Supprimer l'article : " + RefArticle); CmsModify.Items[2].Tag = "DeleteArticle"; CmsModify.Show(Cursor.Position); } else if (e.Button.Equals(MouseButtons.Right)) { CmsModify.Items.Clear(); CmsModify.Items.Add("Ajouter un article"); CmsModify.Items[0].Tag = "AddArticle"; CmsModify.Show(Cursor.Position); } } }
/// <summary> /// Raised when the user click on the treeview. If it's a right click, create a CMS to let the user choose an action depending on the node that has been clicked on /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void TvItems_NodeMouseClick(object sender, TreeNodeMouseClickEventArgs e) { if (e.Button.Equals(MouseButtons.Right)) { switch (e.Node.Name) { case "Families": CmsModify.Items.Clear(); CmsModify.Items.Add("Ajouter une Famille"); CmsModify.Items[0].Tag = "AddFamily"; CmsModify.Show(Cursor.Position); break; case "Brands": CmsModify.Items.Clear(); CmsModify.Items.Add("Ajouter une Marque"); CmsModify.Items[0].Tag = "AddBrand"; CmsModify.Show(Cursor.Position); break; case "AllItems": CmsModify.Items.Clear(); CmsModify.Items.Add("Ajouter un Article"); CmsModify.Items[0].Tag = "AddArticle"; CmsModify.Show(Cursor.Position); break; default: switch (e.Node.Parent.Name) { case "Families": CmsModify.Items.Clear(); CmsModify.Items.Add("Ajouter une Sous-Famille à : " + e.Node.Text); CmsModify.Items[0].Tag = "AddSubFamily"; CmsModify.Items.Add("Modifier la Famille : " + e.Node.Text); CmsModify.Items[1].Tag = "EditFamily"; CmsModify.Items.Add("Supprimer la Famille : " + e.Node.Text); CmsModify.Items[2].Tag = "DeleteFamily"; CmsModify.Show(Cursor.Position); break; case "Brands": CmsModify.Items.Clear(); CmsModify.Items.Add("Modifier la Marque : " + e.Node.Text); CmsModify.Items[0].Tag = "EditBrand"; CmsModify.Items.Add("Supprimer la Marque : " + e.Node.Text); CmsModify.Items[1].Tag = "DeleteBrand"; CmsModify.Show(Cursor.Position); break; default: if (e.Node.Parent.Parent.Name == "Families") { CmsModify.Items.Clear(); CmsModify.Items.Add("Modifier la Sous-Famille : " + e.Node.Text); CmsModify.Items[0].Tag = "EditSubFamily"; CmsModify.Items.Add("Supprimer la Sous-Famille : " + e.Node.Text); CmsModify.Items[1].Tag = "DeleteSubFamily"; CmsModify.Show(Cursor.Position); } break; } break; } } }