本文整理汇总了C#中Product.collection方法的典型用法代码示例。如果您正苦于以下问题:C# Product.collection方法的具体用法?C# Product.collection怎么用?C# Product.collection使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Product
的用法示例。
在下文中一共展示了Product.collection方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: refreshProductsListView
/// <summary>
/// Refresh product list view
/// Reload all data from database.
/// </summary>
private void refreshProductsListView()
{
listViewProducts.Items.Clear();
Product products = new Product();
DataTable results = products.collection();
String[] fields = new[] { "name", "price", "sku", "category_name", "status_label", "stock_qty" };
if (results != null)
{
foreach (DataRow row in results.Rows)
{
ListViewItem item = new ListViewItem(new[] { row["product_id"].ToString() });
foreach (String rowName in fields)
{
item.SubItems.Add(row[rowName].ToString());
}
listViewProducts.Items.Add(item);
}
}
else
{
listViewProducts.Items.Add(new ListViewItem(new[] { "Nu exista rezultate" }));
}
listViewProducts.View = View.Details;
}
示例2: button3_Click
/// <summary>
/// Export products into xml file.
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void button3_Click(object sender, EventArgs e)
{
Product products = new Product();
DataTable results = products.collection();
if (results == null || results.Rows.Count == 0)
{
MessageBox.Show("Nu exista rezultate ce pot fi exportate!", "Eroare");
}
else
{
DataSet dataSet = results.DataSet;
String output = @exportPath + "export-produse-minierp-" + DateTime.Now.ToString("yyyyMMddHHmmssffff") + ".xml";
try
{
dataSet.WriteXml(output);
MessageBox.Show(@"Fisier export: " + output, "Succes!");
}
catch (Exception)
{
MessageBox.Show("A intervenit o eroare!", "Eroare");
}
}
}