本文整理汇总了C#中Product.delete方法的典型用法代码示例。如果您正苦于以下问题:C# Product.delete方法的具体用法?C# Product.delete怎么用?C# Product.delete使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Product
的用法示例。
在下文中一共展示了Product.delete方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: deleteProduct
public bool deleteProduct(Product product)
{
if (!ProductList.Exists(p => p.Id == product.Id))
return false;
bool productDeleted = product.delete();
if (productDeleted)
{
ProductList.RemoveAt(ProductList.FindIndex(p => p.Id == product.Id));
if (onProductsChangeHandler != null)
onProductsChangeHandler();
}
return productDeleted;
}
示例2: stergeToolStripMenuItem_Click
/// <summary>
/// Click event for delete product from contextual toolstrip menu.
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void stergeToolStripMenuItem_Click(object sender, EventArgs e)
{
int selected = listViewProducts.SelectedItems.Count;
if (selected == 0)
{
return;
}
if (MessageBox.Show("Sunteti sigur ca vreti sa stergeti acest produs?", "Atentie", MessageBoxButtons.YesNo) == DialogResult.Yes)
{
string id = listViewProducts.SelectedItems[0].Text;
Product product = new Product();
product.load(id);
if (product.isNew())
{
MessageBox.Show("Nu exista produsul cu id-ul " + id);
}
else
{
if (product.delete())
{
MessageBox.Show("Produsul cu id-ul " + id + " a fost sters");
this.refreshProductsListView();
}
else
{
MessageBox.Show("A intervenit o eroare.", "Eroare!");
}
}
}
}