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


C# Product类代码示例

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


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

示例1: ProductFactory

            public ProductFactory(Parameters parameters)
            {
                try
                {
                    using (var server = new VentsCad())
                    {
                        switch (parameters.Name)
                        {
                            case "spigot":                                
                                product = new Spigot(parameters.Type.SubType, parameters.Sizes[0].Width, parameters.Sizes[0].Height);
                                break;
                            case "dumper":
                                var material = new string[] { parameters.Materials[0].Value, parameters.Materials[0].Thikness, parameters.Materials[0].Name, parameters.Materials[0].Code };
                                product = new Dumper(parameters.Type.SubType, parameters.Sizes[0].Width, parameters.Sizes[0].Height, true, material);
                                break;
                            case "montageFrame":                                
                                product = new MontageFrame(parameters.Type.SubType, parameters.Sizes[0].Width, parameters.Sizes[0].Lenght, parameters.Sizes[0].Additional1, parameters.Materials[0]);
                                break;
                            default:
                                break;
                        }
                    }
                }
                catch (System.Exception ex)
                {
                    MessageBox.Show(ex.Message + "\n" + ex.StackTrace);
                }

                
            }
开发者ID:GitHubVents,项目名称:AirVentsCad,代码行数:30,代码来源:ProductFactory.cs

示例2: SelectByProductID

        public Product SelectByProductID(int ProductID)
        {
            string query = "select * from Product WHERE ProductID = @ProductID";
            List<SqlParameter> lstParams = new List<SqlParameter>();
            lstParams.Add(new SqlParameter("@ProductID", ProductID));

            DataTable dt = DBUtility.SelectData(query, lstParams);

            Product objProduct = new Product();
            if (dt.Rows.Count > 0)
            {
                objProduct.Name = dt.Rows[0]["Name"].ToString();
                objProduct.CreateDate = Convert.ToDateTime(dt.Rows[0]["CreateDate"]);
                objProduct.DesignFiles = dt.Rows[0]["DesignFiles"].ToString();
                objProduct.Status = dt.Rows[0]["Status"].ToString();
                objProduct.Description = dt.Rows[0]["Description"].ToString();
                objProduct.Size = dt.Rows[0]["Size"].ToString();
                objProduct.Colors = dt.Rows[0]["Colors"].ToString();
                objProduct.Type = dt.Rows[0]["Type"].ToString();
                objProduct.CustomerID = Convert.ToInt32(dt.Rows[0]["CustomerID"]);
                objProduct.ProductID = Convert.ToInt32(dt.Rows[0]["ProductID"]);
              
            }

            return objProduct;
        }
开发者ID:paulomi-mahidharia,项目名称:OfficeAutomationAndProductionPlanningApplication,代码行数:26,代码来源:ProductLogic.cs

示例3: SingleProductViewModel

        public SingleProductViewModel(Product p, MerchantTribeApplication mtapp)
        {
            var profiler = MiniProfiler.Current;

            using (profiler.Step("Price Product " + p.ProductName))
            {
                this.UserPrice = mtapp.PriceProduct(p, mtapp.CurrentCustomer, null, mtapp.CurrentlyActiveSales);
            }
            this.IsFirstItem = false;
            this.IsLastItem = false;
            this.Item = p;
            using (profiler.Step("Image Url Product" + p.ProductName))
            {
                this.ImageUrl = MerchantTribe.Commerce.Storage.DiskStorage.ProductImageUrlSmall(
                    mtapp,
                    p.Bvin,
                    p.ImageFileSmall,
                    mtapp.IsCurrentRequestSecure());
            }
            using (profiler.Step("Product Link " + p.ProductName))
            {
                this.ProductLink = UrlRewriter.BuildUrlForProduct(p,
                                                mtapp.CurrentRequestContext.RoutingContext,
                                                string.Empty);
            }
        }
开发者ID:mikeshane,项目名称:MerchantTribe,代码行数:26,代码来源:SingleProductViewModel.cs

示例4: CreateProduct

        public ActionResult CreateProduct(Product p, HttpPostedFileBase file)
        {
            string imgPath = "/Content/images/product";
            string path = "";
            if (ModelState.IsValid)
            {
                if (file != null)
                {
                    string pic = System.IO.Path.GetFileName(file.FileName);
                    path = System.IO.Path.Combine(
                                           Server.MapPath("~" + imgPath), pic);
                    // file is uploaded
                    file.SaveAs(path);
                    p.ProductPictureUrl = imgPath + "/" + file.FileName;
                }

                p.CreatedDate = DateTime.Now;
                _productRepository.Add(p);
                _productRepository.Save();
                int i = p.ProductId;
                return Json(i);
            }
            else
            {
                int wrongData = -2;
                return Json(wrongData);
            }
        }
开发者ID:goodwin3000,项目名称:Catalog,代码行数:28,代码来源:AdminController.cs

示例5: btnAdd_Click

    protected void btnAdd_Click(object sender, EventArgs e)
    {
        selectedProduct = new Product();
        this.selectedProduct.Course_id = course_id.ToString();

        if (Page.IsValid)
        {
            CartItemList cart = CartItemList.GetCart();
            int locCount = cart.Count;
            locCount = locCount + 1;
            this.selectedProduct.assignmentNumber = locCount.ToString();
            this.selectedProduct.aGUID = Guid.NewGuid().ToString();
            this.selectedProduct.Num_Assignment = locCount;
            CartItem cartItem = new CartItem();

            int Num_Assignments=0;
            int assignment = 1; //will be produced from loop according to Num_Assignments
            cart = CartItemList.GetCart();
            cartItem = cart[selectedProduct.Course_id];

            if (cartItem == null)
            {
                cart.AddItem(selectedProduct, Num_Assignments,assignment);
            }
            else
            {
                cart.AddItem(selectedProduct, Num_Assignments, assignment);
                cartItem.AddQuantity(1);
            }
            this.DisplayCart();

        }
    }
开发者ID:cweber-wou,项目名称:capstone,代码行数:33,代码来源:OrderPage.aspx.cs

示例6: AddToCart

        public void AddToCart(Product product, decimal price)
        {
            // Get the matching cart and product instances
            var cartItem = db.CartItems.SingleOrDefault(
                c => c.CartID == ShoppingCartId
                && c.ProductID == product.ProductID);

            if (cartItem == null)
            {
                // Create a new cart item if no cart item exists
                cartItem = new CartItem
                {
                    ProductID = product.ProductID,
                    CartID = ShoppingCartId,
                    Amount = 1,
                    Price = price,
                    Creation = DateTime.Now
                };

                db.CartItems.AddObject(cartItem);
            }
            else
            {
                // If the item does exist in the cart, then add one to the quantity
                cartItem.Amount++;
            }

            // Save changes
            db.SaveChanges();
        }
开发者ID:rogerex,项目名称:shopnet,代码行数:30,代码来源:ShoppingCart.cs

示例7: CanStoreAProduct

        public void CanStoreAProduct()
        {
            //Database.SetInitializer(new DropCreateDatabaseAlways<CoffeeShopContext>());
              long id;
              using (var session = sessionFactory.OpenSession())
              using (var tx = session.BeginTransaction())
              {
            var repository = new Repository<Product>(session);
            var product = new Product
                      {
                        Name = "Coffee 1",
                        Price = 10.4m
                      };

            repository.MakePersistent(product);
            id = product.Id;
            tx.Commit();
              }

              using (var session = sessionFactory.OpenSession())
              using (session.BeginTransaction())
              {
            var repository = new Repository<Product>(session);
            Product product = repository.GetById(id);

            product.Satisfy(p => p.Name == "Coffee 1" && p.Price == 10.4m);
              }
        }
开发者ID:horsdal,项目名称:Restbucks-on-Nancy,代码行数:28,代码来源:DataTests.cs

示例8: IsSatisfiedBy

        public bool IsSatisfiedBy(Product product)
        {
            if (_sizeIds.Count() > 0 )
                return _sizeIds.Any(s => product.Title.Products.Any(p => p.Size.Id == s));

            return true;
        }
开发者ID:modulexcite,项目名称:Fork_AgathasStorefront_ASPNET_MVC,代码行数:7,代码来源:ProductIsInSizeSpecification.cs

示例9: add

        public static void add(Product product)
        {
            var existingProduct = false;
            Product fetchedProduct;

            if (product.Id != 0)
            {
                throw new
                Exception(@"Posted products cannot
              contain an id");
            }

            try
            {
                fetchedProduct = get(product.Name);
                existingProduct = true;
            }
            catch (Exception)
            {
                //this is actually good that we are here. Means we didn't
                //find an existing product so it is OK to insert;
                product.Id = ProductsRepository.data.Select(x => x.Id).Max() + 1;

                var data = ProductsRepository.data.ToList();
                data.Add(product);
                ProductsRepository.data = data;
            }

            if (existingProduct)
            {
                throw new
                Exception(@"The product name you are
              attempting to insert already exists.");
            }
        }
开发者ID:mikaelo,项目名称:SecureWebAPI,代码行数:35,代码来源:ProductsRepository.cs

示例10: TestActiveAtSpecification

        public void TestActiveAtSpecification()
        {
            var productSpecification1 = new ProductSpecification
            {
                ActiveFrom = DateTime.Now.AddDays(-3),
                ActiveUntil = DateTime.Now.AddDays(3)
            };

            var productSpecification2 = new ProductSpecification
            {
                ActiveFrom = DateTime.Now.AddDays(-6),
                ActiveUntil = DateTime.Now.AddDays(-3)
            };

            var productSpecification3 = new ProductSpecification
            {
                ActiveFrom = DateTime.Now.AddDays(-9),
                ActiveUntil = DateTime.Now.AddDays(-6)
            };

            var product = new Product
            {
                ProductSpecifications =
                    new Collection<ProductSpecification>
                                  {
                                      productSpecification1,
                                      productSpecification2,
                                      productSpecification3
                                  }
            };

            var actual = product.ActiveAt(DateTime.Now.AddDays(-8));

            Assert.AreEqual(productSpecification3, actual);
        }
开发者ID:dibble-james,项目名称:Ketchup,代码行数:35,代码来源:ProductTests.cs

示例11: deleteProduct

 public void deleteProduct(Product p)
 {
     if (db.Products.Contains(p)&& p!=null)
     {
         db.Products.Remove(p);
     }
 }
开发者ID:jappedk,项目名称:webshop,代码行数:7,代码来源:Service.cs

示例12: activeSelect

 public void activeSelect(User _user, Product _product)
 {
     if (_product.Active == false)
     {
         throw new NonActiveProductException(_user, _product);
     }
 }
开发者ID:Stg3orge,项目名称:Gundamnation,代码行数:7,代码来源:InsertCashTransaction.cs

示例13: ImportTags

        internal static void ImportTags(Product product, List<string> tagsList, UploadConfig config)
        {
            TaxonomyManager taxonomyManager = TaxonomyManager.GetManager();
            CatalogManager catalogManager = CatalogManager.GetManager();

            FlatTaxonomy tagsTaxonomy = taxonomyManager.GetTaxonomies<FlatTaxonomy>().Where(t => t.Name == "Tags").SingleOrDefault();

            foreach (var tagString in tagsList)
            {
                try
                {
                    Taxon tag = GetTagIfItExsistsOrCreateOneIfItDoesnt(tagString, tagsTaxonomy, taxonomyManager);

                    SetTagProperties(tag, tagString);

                    taxonomyManager.SaveChanges();

                    if (product.Organizer.TaxonExists("Tags", tag.Id) == true)
                    {
                        continue;        // Product already linked to Tag
                    }

                    product.Organizer.AddTaxa("Tags", tag.Id);

                    catalogManager.SaveChanges();
                }
                catch
                {
                    //catching so even if one fails rest goes on
                }
            }
        }
开发者ID:vkoppaka,项目名称:ProductUploadPackage,代码行数:32,代码来源:TagsImporter.cs

示例14: EditProduct

        public ActionResult EditProduct(Product product)
        {
            products.Update(product);
            products.Commit();

            return RedirectToAction("ProductList");
        }
开发者ID:keevan,项目名称:Invoice-Management-System,代码行数:7,代码来源:AdminController.cs

示例15: GetProduct

        private string GetProduct(TextBox txtProductID,
                          ref Product product)
        {
            string result = "";

            try
            {
                int productID = Int32.Parse(txtProductID.Text);
                var client = new ProductServiceClient();
                product = client.GetProduct(productID);

                var sb = new StringBuilder();
                sb.Append("ProductID:" +
                    product.ProductID.ToString() + "\n");
                sb.Append("ProductName:" +
                    product.ProductName + "\n");
                sb.Append("UnitPrice:" +
                    product.UnitPrice.ToString() + "\n");
                sb.Append("RowVersion:");
                foreach (var x in product.RowVersion.AsEnumerable())
                {
                    sb.Append(x.ToString());
                    sb.Append(" ");
                }
                result = sb.ToString();

            }
            catch (Exception ex)
            {
                result = "Exception: " + ex.Message.ToString();
            }

            return result;
        }
开发者ID:ah16269,项目名称:rest-web-api-wcf,代码行数:34,代码来源:MainWindow.xaml.cs


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