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


C# Product.SetValue方法代码示例

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


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

示例1: btnConfirm_Click

    protected void btnConfirm_Click(object sender, EventArgs e)
    {
        Product[] products = new Product[gvShoppingCart.Rows.Count];
        foreach (GridViewRow row in gvShoppingCart.Rows)
        {
            if (row.RowType == DataControlRowType.DataRow)
            {
                Product prod = new Product();

                DataKey data = gvShoppingCart.DataKeys[row.DataItemIndex];

                prod.ProductId = int.Parse(data.Values["ProductId"].ToString());

                Literal litProductName = (Literal)row.FindControl("litProductName");
                prod.Name = litProductName.Text;

                Literal litQuantity = (Literal)row.FindControl("litQuantity");
                prod.Quantity = int.Parse(litQuantity.Text);

                Literal litUnitPrice = (Literal)row.FindControl("litUnitPrice");
                litUnitPrice.Text = litUnitPrice.Text.Replace("£", "");
                prod.Price = Convert.ToDecimal(litUnitPrice.Text);

                products.SetValue(prod, row.DataItemIndex);
            }
        }

        CurrentOrder.OrderDetails.Products = products;

        //order total
        this.litTotal.Text = this.litTotal.Text.Replace("£", "");
        this.CurrentOrder.OrderTotal = Convert.ToDecimal(this.litTotal.Text);
        this.CurrentOrder.EndUserId = this.CurrentEndUser.EndUserId;

        string url = "CheckOutReceipt.aspx";
        Response.Redirect("Loading.aspx?Page=" + url);
    }
开发者ID:simonbegg,项目名称:LiveFreeRange,代码行数:37,代码来源:CheckOutConfirm.aspx.cs

示例2: ibCompletePaypalOrder_Click

    protected void ibCompletePaypalOrder_Click(object sender, ImageClickEventArgs e)
    {
        Product[] products = new Product[gvShoppingCart.Rows.Count];
        foreach (GridViewRow row in gvShoppingCart.Rows)
        {
            if (row.RowType == DataControlRowType.DataRow)
            {
                Product prod = new Product();

                DataKey data = gvShoppingCart.DataKeys[row.DataItemIndex];

                prod.ProductId = int.Parse(data.Values["ProductId"].ToString());

                Literal litProductName = (Literal)row.FindControl("litProductName");
                prod.Name = litProductName.Text;

                Literal litQuantity = (Literal)row.FindControl("litQuantity");
                prod.Quantity = int.Parse(litQuantity.Text);

                Literal litUnitPrice = (Literal)row.FindControl("litUnitPrice");
                litUnitPrice.Text = litUnitPrice.Text.Replace("£", "");
                prod.Price = Convert.ToDecimal(litUnitPrice.Text);

                products.SetValue(prod, row.DataItemIndex);
            }
        }

        CurrentOrder.OrderDetails.Products = products;

        //order total
        this.litTotal.Text = this.litTotal.Text.Replace("£", "");
        this.CurrentOrder.OrderTotal = Convert.ToDecimal(this.litTotal.Text);
        this.CurrentOrder.EndUserId = this.CurrentEndUser.EndUserId;

        string token = Request.QueryString["token"];
        string payerId = Request.QueryString["PayerID"];

        //DoExpressCheckoutPayment
        PayPalManager payPal = new PayPalManager();
        PayPalInformation payPalInformation = new PayPalInformation();
        payPalInformation.Order = this.CurrentOrder;
        payPalInformation.Order.PayerId = payerId;
        payPalInformation.Order.SubTotal = this.CurrentOrder.OrderTotal;

        // #HACK: WJ: sub null for items array below to get it working
        PayPalManager.OrderInfo ppOrderInfo = new PayPalManager.OrderInfo();

        //this call returns an order info object
        //double orderTotal = Convert.ToDouble(this.CommercePage.Basket.GetBaseTotalAfterDiscount());

        double orderTotal = Math.Round(Convert.ToDouble(base.CurrentOrder.SubTotal), 2);

        // this call actually processes the payment
        ppOrderInfo = payPal.DoExpressCheckout(token, payPalInformation);

        string ack = ppOrderInfo.Ack; // says "Success" or "ERROR:..."
        string transactionId = ppOrderInfo.TransactionID;
        string receiptId = ppOrderInfo.ReceiptID;
        this.CurrentOrder.TransactionId = transactionId;
        // handle Paypal web service response
        if (ack.IndexOf("ERROR") != -1)
        {
            //find error placeholder, show and add error message
            ContentPlaceHolder cph = (ContentPlaceHolder)Page.Master.FindControl("ContentPlaceHolder1");

            this.pnlOrderDeclined.Visible = true;

            this.lblTransactionFailureMessage.Text = ack;

            // also need to show a credit card payment option - to do.
        }
        else
        {
            // Transaction successful: complete order!
            ProcessAddOrder addOrder = new ProcessAddOrder();
            addOrder.Orders = this.CurrentOrder;

            try
            {
                addOrder.Invoke();
            }
            catch (Exception ex)
            {
                Response.Redirect("ErrorPage.aspx");
            }

            this.UpdateStockLevel();
            this.DeleteShoppingCart();

            // now forward to order completed page
            Response.Redirect("~/CheckOut/CheckOutReceipt.aspx?ec=true");
        }
    }
开发者ID:simonbegg,项目名称:LiveFreeRange,代码行数:93,代码来源:CheckOutConfirm.aspx.cs


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