当前位置: 首页>>代码示例>>C#>>正文


C# Product.load方法代码示例

本文整理汇总了C#中Product.load方法的典型用法代码示例。如果您正苦于以下问题:C# Product.load方法的具体用法?C# Product.load怎么用?C# Product.load使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Product的用法示例。


在下文中一共展示了Product.load方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: btnDuplicate_Click

 /// <summary>
 /// Duplicate product.
 /// Implement iCloneable interface functionality.
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void btnDuplicate_Click(object sender, EventArgs e)
 {
     string productId = textBoxId.Text;
     Product oldProduct = new Product();
     oldProduct.load(productId);
     Product cloned = (Product) oldProduct.Clone();
     var sku = cloned.getData().First(item => item.Key == "sku");
     cloned.setData(cloned.getData());
     if (cloned.save())
     {
         MessageBox.Show(@"Produsul a fost duplicat cu codul SKU " + sku.Value.ToString(), "Succes!");
         this.Dispose();
     }
     else
     {
         MessageBox.Show("A intervenit o eroare!", "Eroare");
     }
 }
开发者ID:replsv,项目名称:minierp,代码行数:24,代码来源:EditProductForm.cs

示例2: btnExport_Click

 /// <summary>
 /// Export product data into a txt file. Usage of streamWriter from System.IO.
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void btnExport_Click(object sender, EventArgs e)
 {
     try
     {
         string productId = textBoxId.Text;
         Product product = new Product();
         product.load(productId);
         string exportPath = @parent.exportPath + "export-produs-" + product.getData().Single(item => item.Key == "sku").Value.ToString() + ".txt";
         System.IO.StreamWriter write = new System.IO.StreamWriter(exportPath);
         write.WriteLine(product.ToString());
         write.Close();
         MessageBox.Show(@"Fisier export: " + exportPath);
         this.Dispose();
     }
     catch (Exception)
     {
         MessageBox.Show("A intervenit o eroare!", "Eroare");
     }
 }
开发者ID:replsv,项目名称:minierp,代码行数:24,代码来源:EditProductForm.cs

示例3: 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!");
            }
        }
开发者ID:replsv,项目名称:minierp,代码行数:43,代码来源:EditProductForm.cs

示例4: 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!");
                    }
                }
            }
        }
开发者ID:replsv,项目名称:minierp,代码行数:36,代码来源:Form1.cs


注:本文中的Product.load方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。