예제 #1
0
        private void AddUpdateToProduct(TreeNode productNode, CatalogProduct product)
        {
            foreach (CatalogUpdate update in product.Updates)
            {
                if (string.IsNullOrEmpty(txtBxFilterText.Text))
                {
                    TreeNode updateNode = new TreeNode(update.Title);
                    updateNode.Tag = new CatalogItem(update);
                    productNode.Nodes.Add(updateNode);
                }
                else
                {
                    FilterCriterias criteria = (cmbBxFilterCriteria.SelectedIndex == 0) ? FilterCriterias.Title : FilterCriterias.Description;
                    switch (criteria)
                    {
                    case FilterCriterias.Title:
                        if (System.Globalization.CultureInfo.InvariantCulture.CompareInfo.IndexOf(update.Title, txtBxFilterText.Text, System.Globalization.CompareOptions.IgnoreCase) >= 0)
                        {
                            TreeNode updateNode = new TreeNode(update.Title);
                            updateNode.Tag = new CatalogItem(update);
                            productNode.Nodes.Add(updateNode);
                        }
                        break;

                    case FilterCriterias.Description:
                        if (System.Globalization.CultureInfo.InvariantCulture.CompareInfo.IndexOf(update.Description, txtBxFilterText.Text, System.Globalization.CompareOptions.IgnoreCase) >= 0)
                        {
                            TreeNode updateNode = new TreeNode(update.Title);
                            updateNode.Tag = new CatalogItem(update);
                            productNode.Nodes.Add(updateNode);
                        }
                        break;

                    default:
                        break;
                    }
                }
            }
        }
 internal void AddProduct(CatalogProduct productToAdd)
 {
     _products.Add(productToAdd.ProductName, productToAdd);
 }
 internal CatalogItem(CatalogProduct product)
 {
     ItemType = CatalogItemTypes.Product;
     Product = product;
 }