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


C# ProductModel.GetProduct方法代码示例

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


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

示例1: FillPage

    private void FillPage()
    {
        //Get selected product's data
        if (!String.IsNullOrWhiteSpace(Request.QueryString["id"]))
        {
            int id = Convert.ToInt32(Request.QueryString["id"]);
            ProductModel productModel = new ProductModel();
            Product product = productModel.GetProduct(id);
            ZHUW15sqlserver1Entities db = new ZHUW15sqlserver1Entities();

            //Fill Page with data
            lblColor.Text = " " + product.Color;
            lblPrice.Text = " $" + product.Price;
            lblTitle.Text = product.Name;
            lblDescription.Text = product.Description;
            lblProductNum.Text = "Product Number: "+ id.ToString();
            imgProdcut.ImageUrl = "~/Image/Products/" + product.Image;

            //Retrieve supplier
            int supplierId = product.SupplierID;
            Supplier supplier = db.Suppliers.Find(supplierId);
            lblSupplier.Text = "By " + supplier.Name;


            //Fille amount dropdown list with numbers 1-30;
            int[] quantity = Enumerable.Range(1, 30).ToArray();
            ddlQuantity.DataSource = quantity;
            ddlQuantity.AppendDataBoundItems = true;
            ddlQuantity.DataBind();
        }
    }
开发者ID:alicezhuwy,项目名称:Asp.net-webshop,代码行数:31,代码来源:SingleProduct.aspx.cs

示例2: FillPage

 //FillPage() method
 private void FillPage(int id)
 {
     ProductModel pModel = new ProductModel();
     Product product = pModel.GetProduct(id);
     descriptionTextBox.Text = product.Description;
     nameTextBox.Text = product.Name;
     priceTextBox.Text = product.Price.ToString();
     imageDropDownList.SelectedValue = product.Image;
     typeDropDownList.SelectedValue = product.Type.ToString();
     quantityTextBox.Text = product.Quantity.ToString();
 }
开发者ID:lester88a,项目名称:COMP229-Final-Example,代码行数:12,代码来源:ManageProduct.aspx.cs

示例3: FillPage

    private void FillPage(int id ){
        ProductModel productModel = new ProductModel();
        Product product = productModel.GetProduct(id);

        txtDescription.Text = product.Description;
        txtName.Text = product.Name;
        txtPrice.Text = product.Price.ToString();

        ddlImage.SelectedValue = product.Image;
        ddlType.SelectedValue = product.TypeId.ToString();


    }
开发者ID:Rita124,项目名称:Rita124.github.io,代码行数:13,代码来源:ManageProducts.aspx.cs

示例4: FillPage

    private void FillPage(int id)
    {
        //Get selected product from DB
        ProductModel productModel = new ProductModel();
        Product product = productModel.GetProduct(id);

        //Fill textboxes
        txtDescription.Text = product.Description;
        txtName.Text = product.Name;
        txtPrice.Text = product.Price.ToString();

        //Set dropdown list values
        ddlImage.SelectedValue = product.Image;
        ddlType.SelectedValue = product.TypeId.ToString();

    }
开发者ID:apostolnikov,项目名称:NikovBikeOnlineStore,代码行数:16,代码来源:ManageProducts.aspx.cs

示例5: FillForm

    private void FillForm(int id)
    {
        //Get selected product from DB
        ProductModel productmodel = new ProductModel();
        Product product = productmodel.GetProduct(id);

        //Fill textboxes
        txtDescription.Text = product.Description;
        txtName.Text = product.Name;
        txtColor.Text = product.Color;
        txtPrice.Text = product.Price.ToString();
       
        //Set dropdpwn list value
        ddlImage.SelectedValue = product.Image;
        ddlCategory.SelectedValue = product.CategoryID.ToString();
        ddlSupplier.SelectedValue = product.SupplierID.ToString();
    }
开发者ID:alicezhuwy,项目名称:Asp.net-webshop,代码行数:17,代码来源:ManageProduct.aspx.cs

示例6: FillForm

    private void FillForm(int id)
    {
        try
        {
            ProductModel productModel = new ProductModel();
            Product product = productModel.GetProduct(id);

            txtDescription.Text = product.Description;
            txtName.Text = product.Name;
            txtPrice.Text = product.Price.ToString();

            ddlImage.SelectedValue = product.Image;
            ddlType.SelectedValue = product.TypeID.ToString();
        }
        catch (Exception ex)
        {
            lblResult.Text = ex.ToString();
        }
    }
开发者ID:SaifAsad,项目名称:garager,代码行数:19,代码来源:ManageProducts.aspx.cs

示例7: FillPage

    private void FillPage()
    {
        //Get selected product data
        if (!string.IsNullOrWhiteSpace(Request.QueryString["id"]))
        {
            int id = Convert.ToInt32(Request.QueryString["id"]);
            ProductModel model = new ProductModel();
            Product product = model.GetProduct(id);

            //Fill page with data
            lblTitle.Text = product.Name;
            lblDescription.Text = product.Description;
            lblPrice.Text = "Price per unit:<br/>£ " + product.Price;
            imgProduct.ImageUrl = "~/Images/Products/" + product.Image;
            lblItemNr.Text = product.ID.ToString();

            //Fill amount list with numbers 1-20
            int[] amount = Enumerable.Range(1, 20).ToArray();
            ddlAmount.DataSource = amount;
            ddlAmount.AppendDataBoundItems = true;
            ddlAmount.DataBind();
        }
    }
开发者ID:henrypedersen77,项目名称:GarageManagerMaster,代码行数:23,代码来源:Product.aspx.cs

示例8: CreateShopTable

    private void CreateShopTable(IEnumerable<Cart> carts, out double subTotal)
    {
        subTotal = new double();
        ProductModel model = new ProductModel();

        foreach (Cart cart in carts)
        {
            //Create HTML elements and fill values with database data
            Product product = model.GetProduct(cart.ProductID);

            ImageButton btnImage = new ImageButton
            {
                ImageUrl = string.Format("~/Images/Products/{0}", product.Image),
                PostBackUrl = string.Format("~/Pages/Product.aspx?id={0}", product.ID)
            };

            LinkButton lnkDelete = new LinkButton
            {
                PostBackUrl = string.Format("~/Pages/ShoppingCart.aspx?productId={0}", cart.ID),
                Text = "Delete Item",
                ID = "del" + cart.ID,
            };

            lnkDelete.Click += Delete_Item;

            //Fill amount list with numbers 1-20
            int[] amount = Enumerable.Range(1, 20).ToArray();
            DropDownList ddlAmount = new DropDownList
            {
                DataSource = amount,
                AppendDataBoundItems = true,
                AutoPostBack = true,
                ID = cart.ID.ToString()
            };
            ddlAmount.DataBind();
            ddlAmount.SelectedValue = cart.Amount.ToString();
            ddlAmount.SelectedIndexChanged += ddlAmount_SelectedIndexChanged;

            //Create table to hold shopping cart details
            Table table = new Table { CssClass = "CartTable" };
            TableRow row1 = new TableRow();
            TableRow row2 = new TableRow();

            TableCell cell1_1 = new TableCell { RowSpan = 2, Width = 50 };
            TableCell cell1_2 = new TableCell { Text = string.Format("<h4>{0}</h4><br />{1}<br/>In Stock",
                product.Name, "Item No:" + product.ID), HorizontalAlign = HorizontalAlign.Left, Width = 350, };
            TableCell cell1_3 = new TableCell { Text = "Unit Price<hr/>" };
            TableCell cell1_4 = new TableCell { Text = "Quantity<hr/>" };
            TableCell cell1_5 = new TableCell { Text = "Item Total<hr/>" };
            TableCell cell1_6 = new TableCell();

            TableCell cell2_1 = new TableCell();
            TableCell cell2_2 = new TableCell { Text = "£ " + product.Price };
            TableCell cell2_3 = new TableCell();
            TableCell cell2_4 = new TableCell { Text = "£ " + Math.Round((cart.Amount * product.Price), 2) };
            TableCell cell2_5 = new TableCell();

            //Set custom controls
            cell1_1.Controls.Add(btnImage);
            cell1_6.Controls.Add(lnkDelete);
            cell2_3.Controls.Add(ddlAmount);

            //Add rows & cells to table
            row1.Cells.Add(cell1_1);
            row1.Cells.Add(cell1_2);
            row1.Cells.Add(cell1_3);
            row1.Cells.Add(cell1_4);
            row1.Cells.Add(cell1_5);
            row1.Cells.Add(cell1_6);

            row2.Cells.Add(cell2_1);
            row2.Cells.Add(cell2_2);
            row2.Cells.Add(cell2_3);
            row2.Cells.Add(cell2_4);
            row2.Cells.Add(cell2_5);
            table.Rows.Add(row1);
            table.Rows.Add(row2);
            pnlShoppingCart.Controls.Add(table);

            //Add total of current purchased item to subtotal
            subTotal += (cart.Amount * product.Price);
        }

        //Add selected objects to Session
        Session[User.Identity.GetUserId()] = carts;
    }
开发者ID:henrypedersen77,项目名称:GarageManagerMaster,代码行数:86,代码来源:ShoppingCart.aspx.cs

示例9: CreateShopTable

    //out double subTotal: allow the mehod to return more than one value
    private void CreateShopTable(IEnumerable<Cart> carts, out double subTotal)
    {
        subTotal = new double();
        ProductModel model = new ProductModel();

        foreach (Cart cart in carts)
        {
            //Create HTML elements and fill values with database data
            Product product = model.GetProduct(cart.ProductID);

            //Create the image button
            ImageButton btnImage = new ImageButton
            {
                ImageUrl = string.Format("~/Images/Products/{0}", product.Image),
                PostBackUrl = string.Format("Product.aspx?id={0}", product.Id)
            };

            //Create the delete link
            /*
            when the use clicks on the delete link, the user will be directed back to this page
            and if a product id is found in the url, this means a product needs to be deleted
            from the shopping cart
            */
            LinkButton lnkDelete = new LinkButton
            {
                PostBackUrl = string.Format("ShoppingCart.aspx?productId={0}", cart.id),
                Text = "Delete Item",
                CssClass = "btn btn-primary",
                //ID is needed when working with dynamically generated controlls
                //will be needed to access this control later in the code
                ID = "del" + cart.id,
            };

            //Add onClick event
            lnkDelete.Click += Delete_Item;

            //Create the quantity dropdown list
            //Fill amount list with numbers 1-20
            int[] amount = Enumerable.Range(1, 20).ToArray();
            DropDownList ddlAmount = new DropDownList
            {
                DataSource = amount,
                AppendDataBoundItems = true,
                AutoPostBack = true, //when a value is selected in the drop down list, the page will refresh itself
                                     //and calculate the amount depending on what quantity value is selected

                //set the id of the dropdown list to the id of the current cart
                ID = cart.id.ToString()
            };
            ddlAmount.DataBind(); //is needed when dealing with dynamically generated data sources
            ddlAmount.SelectedValue = cart.Amount.ToString();
            ddlAmount.SelectedIndexChanged += ddlAmount_SelectedIndexChanged; //when dyncamically generating events, no need to add parantheses after the method name

            //Create table to hold shopping cart details (2 rows and 6 columns)
            Table table = new Table { CssClass = "CartTable" };
            TableRow row1 = new TableRow();
            TableRow row2 = new TableRow();

            //create 6 cells for a row
            TableCell cell1_1 = new TableCell { RowSpan = 2, Width = 50 };
            TableCell cell1_2 = new TableCell
            {
                Text = string.Format("<h4>{0}</h4><br />{1}<br/>In Stock",
                product.Name, "Item No:" + product.Id),
                HorizontalAlign = HorizontalAlign.Left,
                Width = 350,
            };
            TableCell cell1_3 = new TableCell { Text = "Unit Price<hr/>" };
            TableCell cell1_4 = new TableCell { Text = "Quantity<hr/>" };
            TableCell cell1_5 = new TableCell { Text = "Item Total<hr/>" };
            TableCell cell1_6 = new TableCell();

            TableCell cell2_1 = new TableCell();
            TableCell cell2_2 = new TableCell { Text = "$ " + product.Price };
            TableCell cell2_3 = new TableCell();
            TableCell cell2_4 = new TableCell { Text = "$ " + Math.Round((cart.Amount * (double)product.Price), 2) };
            TableCell cell2_5 = new TableCell();

            //Set custom controls
            cell1_1.Controls.Add(btnImage);
            cell1_6.Controls.Add(lnkDelete);
            cell2_3.Controls.Add(ddlAmount);

            //Add rows & cells to table
            row1.Cells.Add(cell1_1);
            row1.Cells.Add(cell1_2);
            row1.Cells.Add(cell1_3);
            row1.Cells.Add(cell1_4);
            row1.Cells.Add(cell1_5);
            row1.Cells.Add(cell1_6);

            row2.Cells.Add(cell2_1);
            row2.Cells.Add(cell2_2);
            row2.Cells.Add(cell2_3);
            row2.Cells.Add(cell2_4);
            row2.Cells.Add(cell2_5);
            table.Rows.Add(row1);
            table.Rows.Add(row2);
            pnlShoppingCart.Controls.Add(table);
//.........这里部分代码省略.........
开发者ID:SaifAsad,项目名称:garager,代码行数:101,代码来源:ShoppingCart.aspx.cs

示例10: CreateCartTable

    private void CreateCartTable(List<Cart> purchaseList, out double subTotal)
    {
        ProductModel productModel = new ProductModel();
        subTotal = new double();

        //Create image button
        foreach(Cart cart in purchaseList)
        {
            Product product = productModel.GetProduct(cart.ProductID);

            ImageButton btnImage = new ImageButton
            {
                ImageUrl = string.Format("~/Image/Products/{0}", product.Image),
                PostBackUrl = string.Format("~/Pages/SingleProduct.aspx?id={0}", product.ID)
            };

        //Create delete link
            LinkButton lnkDelete = new LinkButton
            {
                PostBackUrl = string.Format("~/Pages/ShoppingCart.aspx?id={0}", cart.ID),
                Text = "Delete Item",
                ID = "del" + cart.ID
            };

            //Add an onClick evernt
            lnkDelete.Click += Delete_Item;

            //Create drop down list for choose quantity, same as singleproduct page, from 1 to 30
            int[] quantity = Enumerable.Range(1, 30).ToArray();
            DropDownList ddlQuantity = new DropDownList
            {
                DataSource = quantity,
                AppendDataBoundItems = true,
                //Page refresh when select from dropdown list, and total amount will caculate again
                AutoPostBack = true,
                //Record the ID for later
                ID = cart.ID.ToString()
            };

            //Bind data when works on dynamic page
            ddlQuantity.DataBind();
            ddlQuantity.SelectedValue = cart.Quantity.ToString();
            ddlQuantity.SelectedIndexChanged += ddlQuantity_SelectedIndexChanged;

            //Create HTML table with 2 rows
            Table table = new Table { CssClass = "cartTable" };
            TableRow first = new TableRow();
            TableRow second = new TableRow();

            //Create 6 cells for row first
            TableCell firstA = new TableCell { RowSpan = 2, Width = 100};
            TableCell firstB = new TableCell { Text = string.Format("<h4>{0}</h4><br/>{1}<br/>In Stock", product.Name, "Product NO.: " + product.ID), HorizontalAlign = HorizontalAlign.Left, Width = 380};
            TableCell firstC = new TableCell { Text = "Unit Price<hr/>"};
            TableCell firstD = new TableCell { Text = "QUantity<hr/>"};
            TableCell firstE = new TableCell { Text = "Total Amount<hr/>"};
            TableCell firstF = new TableCell { };

            //Create 6 cells for row second
            TableCell secondA = new TableCell { };
            TableCell secondB = new TableCell { Text = "$" + (double)product.Price };
            TableCell secondC = new TableCell { };
            TableCell secondD = new TableCell { Text = "$" + Math.Round((cart.Quantity * (double)product.Price), 2)};
            TableCell secondE = new TableCell { };
            TableCell secondF = new TableCell { };

            //Set controls
            firstA.Controls.Add(btnImage);
            firstF.Controls.Add(lnkDelete);
            secondC.Controls.Add(ddlQuantity);

            //Add cells to first
            first.Cells.Add(firstA);
            first.Cells.Add(firstB);
            first.Cells.Add(firstC);
            first.Cells.Add(firstD);
            first.Cells.Add(firstE);
            first.Cells.Add(firstF);

            //Add cells to row second
            second.Cells.Add(secondA);
            second.Cells.Add(secondB);
            second.Cells.Add(secondC);
            second.Cells.Add(secondD);
            second.Cells.Add(secondE);
            second.Cells.Add(secondF);

            //Add rows to table
            table.Rows.Add(first);
            table.Rows.Add(second);

            //Add table to panel 
            pnlShoppingCart.Controls.Add(table);

            //Add total amount to subtotal
            subTotal += (cart.Quantity * (double)product.Price);
        };

        //Add current client's shopping to his/her shopping cart application
        Application["shoppingCart"] = purchaseList;
    }
开发者ID:alicezhuwy,项目名称:Asp.net-webshop,代码行数:100,代码来源:ShoppingCart.aspx.cs


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