本文整理汇总了C#中Product.save方法的典型用法代码示例。如果您正苦于以下问题:C# Product.save方法的具体用法?C# Product.save怎么用?C# Product.save使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Product
的用法示例。
在下文中一共展示了Product.save方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: addProduct
public Product addProduct(Product product)
{
if (ProductList.Exists(p => p.Id == product.Id))
return null;
Product savedProduct = product.save();
if (savedProduct != null)
{
ProductList.Add(savedProduct);
if (onProductsChangeHandler != null)
onProductsChangeHandler();
return savedProduct;
}
return null;
}
示例2: btnUserControlCheckbox1_tryToSave
/// <summary>
/// Trigger save product.
/// We're using a custom UserControl.
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void btnUserControlCheckbox1_tryToSave(object sender, EventArgs e)
{
dynamic selectedCategory = comboBoxCategory.SelectedItem;
List<KeyValuePair<String, String>> formData = new List<KeyValuePair<String, String>>
{
new KeyValuePair<String, String>("product_id", textBoxId.Text),
new KeyValuePair<String, String>("name", textBoxNume.Text),
new KeyValuePair<String, String>("price", textBoxPrice.Text),
new KeyValuePair<String, String>("sku", textBoxSku.Text),
new KeyValuePair<String, String>("stock_qty", textBoxStock.Text),
new KeyValuePair<String, String>("category_id", selectedCategory.category_id.ToString()),
};
Product product = new Product();
product.setData(formData);
if (textBoxId.Text != "")
{
Product compare = new Product();
compare.load(textBoxId.Text);
if (product.CompareTo(compare) == 1)
{
MessageBox.Show("Trebuie sa faceti cel putin o modificare!", "Atentie");
return;
}
}
if (product.save())
{
MessageBox.Show("Produsul a fost salvat!");
this.Dispose();
}
else
{
MessageBox.Show("A intervenit o eroare!");
}
}