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


C# NBrightInfo.Clone方法代码示例

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


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

示例1: ValidateCartItem


//.........这里部分代码省略.........
                            if (optvalueid != null && optvalueid.InnerText != "False")
                            {
                                XmlNode  optvalcostnod;
                                if (optvalueid.InnerText == "True")
                                    optvalcostnod = cartItemInfo.XMLDoc.SelectSingleNode("genxml/productxml/genxml/optionvalues[@optionid='" + optid.InnerText + "']/genxml/textbox/txtaddedcost");
                                else
                                    optvalcostnod = cartItemInfo.XMLDoc.SelectSingleNode("genxml/productxml/genxml/optionvalues/genxml[./hidden/optionvalueid='" + optvalueid.InnerText + "']/textbox/txtaddedcost");

                                if (optvalcostnod != null)
                                {
                                    var optvalcost = optvalcostnod.InnerText;
                                    if (Utils.IsNumeric(optvalcost))
                                    {
                                        cartItemInfo.SetXmlPropertyDouble("genxml/options/option[" + lp + "]/optvalcost", optvalcost);
                                        var optvaltotal = Convert.ToDouble(optvalcost, CultureInfo.GetCultureInfo("en-US"))*qty;
                                        cartItemInfo.SetXmlPropertyDouble("genxml/options/option[" + lp + "]/optvaltotal", optvaltotal);
                                        additionalCosts += optvaltotal;
                                    }
                                }
                                else
                                {
                                    cartItemInfo.SetXmlPropertyDouble("genxml/options/option[" + lp + "]/optvalcost", "0");
                                    cartItemInfo.SetXmlPropertyDouble("genxml/options/option[" + lp + "]/optvaltotal", "0");
                                }
                            }
                        }
                        lp += 1;
                    }
                }

                if (qty > 0)  // can't devide by zero
                {
                    unitcost += (additionalCosts / qty);
                    if (dealercost > 0) dealercost += (additionalCosts / qty); // zero turns off
                    if (saleprice > 0) saleprice += (additionalCosts / qty); // zero turns off
                    sellcost += (additionalCosts / qty);
                }

                var totalcost = qty * sellcost;
                var totaldealercost = qty * dealercost;
                var totalweight = weight * qty;

                if (unitcost != cartItemInfo.GetXmlPropertyDouble("genxml/unitcost") || dealercost != cartItemInfo.GetXmlPropertyDouble("genxml/dealercost") || saleprice != cartItemInfo.GetXmlPropertyDouble("genxml/saleprice"))
                {
                    cartItemInfo.SetXmlPropertyDouble("genxml/unitcost", unitcost);
                    cartItemInfo.SetXmlPropertyDouble("genxml/dealercost", dealercost);
                    cartItemInfo.SetXmlPropertyDouble("genxml/saleprice", saleprice);
                    cartItemInfo.RemoveXmlNode("genxml/productxml");
                    cartItemInfo.AddSingleNode("productxml", prd.Info.XMLData, "genxml");
                }

                cartItemInfo.SetXmlPropertyDouble("genxml/totalweight", totalweight.ToString(""));
                cartItemInfo.SetXmlPropertyDouble("genxml/totalcost", totalcost);
                cartItemInfo.SetXmlPropertyDouble("genxml/totaldealercost", totaldealercost);
                cartItemInfo.SetXmlPropertyDouble("genxml/totaldealerbonus", (totalcost - totaldealercost));

                Double salediscount = 0;
                Double dealerdiscount = 0;
                Double discountcodeamt = 0;
                Double totaldiscount = 0;

                //add update genxml/discountcodeamt
                if (saleprice == 0) // discount codes are only valid for items not on sale
                {
                    var discountcode = PurchaseInfo.GetXmlProperty("genxml/extrainfo/genxml/textbox/promocode");
                    cartItemInfo = DiscountCodeInterface.UpdateItemPercentDiscountCode(PortalId, UserId, cartItemInfo, discountcode);
                    discountcodeamt = cartItemInfo.GetXmlPropertyDouble("genxml/discountcodeamt");
                    if (discountcodeamt > 0) PurchaseInfo.SetXmlProperty("genxml/discountprocessed", "False");
                    totaldiscount = discountcodeamt;
                }
                else
                {
                    salediscount = (unitcost - saleprice);
                    totaldiscount = salediscount * qty;
                }

                var totalsalediscount = salediscount * qty;
                var totaldealerdiscount = dealerdiscount * qty;
                cartItemInfo.SetXmlPropertyDouble("genxml/totaldiscount", totaldiscount);
                cartItemInfo.SetXmlPropertyDouble("genxml/salediscount", totalsalediscount);
                cartItemInfo.SetXmlPropertyDouble("genxml/totaldealerdiscount", totaldealerdiscount);

                cartItemInfo.SetXmlPropertyDouble("genxml/appliedtotalcost", AppliedCost(portalId, userId, totalcost, totaldealercost));
                cartItemInfo.SetXmlPropertyDouble("genxml/appliedcost", AppliedCost(portalId, userId, sellcost, dealercost));

                // calc tax for item
                var taxproviderkey = PurchaseInfo.GetXmlProperty("genxml/hidden/taxproviderkey");
                var taxprov = TaxInterface.Instance(taxproviderkey);
                if (taxprov != null)
                {
                    var nbi = (NBrightInfo)cartItemInfo.Clone();
                    cartItemInfo.SetXmlPropertyDouble("genxml/taxcost", taxprov.CalculateItemTax(nbi));
                }

            }

            cartItemInfo = NBrightBuyUtils.ProcessEventProvider(EventActions.ValidateCartItemAfter, cartItemInfo);

            return cartItemInfo;
        }
开发者ID:Lewy-H,项目名称:NBrightBuy,代码行数:101,代码来源:CartData.cs

示例2: CalculatePromotion

        public override NBrightInfo CalculatePromotion(int portalId, NBrightInfo cartInfo)
        {
            // loop through cart items
            var rtncartInfo = (NBrightInfo)cartInfo.Clone();
            try
            {

                var cartData = new CartData(cartInfo.PortalId);
                var cartList = cartData.GetCartItemList();

                foreach (var cartItemInfo in cartList)
                {
                    cartInfo.SetXmlPropertyDouble("genxml/items/genxml[./itemcode = '" + cartItemInfo.GetXmlProperty("genxml/itemcode") + "']/promodiscount", 0); // remove any existing discount
                    if (cartItemInfo.GetXmlProperty("genxml/productxml/genxml/hidden/promotype") == "PROMOMULTIBUY")
                    {

                        var promoid = cartItemInfo.GetXmlPropertyInt("genxml/productxml/genxml/hidden/promoid");
                        var objCtrl = new NBrightBuyController();
                        var promoData = objCtrl.GetData(promoid);
                        if (promoData != null)
                        {
                            //NOTE: WE nedd to process disabld promotions so they can be removed from cart

                            var buyqty = promoData.GetXmlPropertyInt("genxml/textbox/buyqty");
                            var validfrom = promoData.GetXmlProperty("genxml/textbox/validfrom");
                            var validuntil = promoData.GetXmlProperty("genxml/textbox/validuntil");
                            var propbuygroupid = promoData.GetXmlProperty("genxml/dropdownlist/propbuy");
                            var propapplygroupid = promoData.GetXmlProperty("genxml/dropdownlist/propapply");
                            var amounttype = promoData.GetXmlProperty("genxml/radiobuttonlist/amounttype");
                            var amount = promoData.GetXmlPropertyDouble("genxml/textbox/amount");

                                // Applied discount to this single cart item
                            if (!promoData.GetXmlPropertyBool("genxml/checkbox/disabled") && cartItemInfo.GetXmlPropertyInt("genxml/qty") >= buyqty && Utils.IsDate(validfrom) && Utils.IsDate(validuntil)) // check we have correct qty to activate promo
                            {
                                var dteF = Convert.ToDateTime(validfrom).Date;
                                var dteU = Convert.ToDateTime(validuntil).Date;
                                if (DateTime.Now.Date >= dteF && DateTime.Now.Date <= dteU)
                                {
                                    // calc discount amount

                                    var cartqty = cartItemInfo.GetXmlPropertyDouble("genxml/qty");
                                    var qtycount = cartqty;
                                    var unitcost = cartItemInfo.GetXmlPropertyDouble("genxml/basecost");
                                    double discountamt = 0;
                                    while (qtycount > buyqty)
                                    {
                                        if (amounttype == "1")
                                        {
                                            discountamt += (unitcost - amount);
                                        }
                                        else
                                        {
                                            discountamt += ((unitcost/100)*amount);
                                        }
                                        if (discountamt < 0) discountamt = 0;

                                        qtycount = (qtycount - (buyqty + 1)); // +1 so we allow for discount 1 in basket.
                                    }

                                    cartInfo.SetXmlPropertyDouble("genxml/items/genxml[./itemcode = '" + cartItemInfo.GetXmlProperty("genxml/itemcode") + "']/promodiscount", discountamt);

                                }
                            }
                        }
                    }
                }

                return cartInfo;
            }
            catch (Exception ex)
            {
                var x = ex.ToString();
                return rtncartInfo;
            }
        }
开发者ID:DNNMonster,项目名称:NBrightBuy,代码行数:75,代码来源:PromoProvider.cs


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