Dynamicweb 8 Documentation
Round(Double) Method
Example 

The value.
Rounds the specified value. If Method = 0 return the value.
Syntax
'Declaration
 
Public Function Round( _ 
   ByVal value As Double _ 
) As Double
public double Round( 
   double value 
)

Parameters

value
The value.
Example
class MyPage : System.Web.UI.Page
{
    private Dynamicweb.eCommerce.Products.Product product;

    private void Page_Load(System.Object sender, System.EventArgs e)
    {
        product = (Dynamicweb.eCommerce.Products.Product)Session["Ecom.Backend.Product"];
    }

    public double Total(bool IncludeVAT, Dynamicweb.eCommerce.Discounts.Discount.DiscountCalculationType CalculateAs)
    {
        double discountTotal = 0.0;
        double productPrice = 0.0;

        if (IncludeVAT)
        {
            productPrice = product.Price.PriceWithVAT;
        }
        else
        {
            productPrice = product.Price.PriceWithoutVAT;
        }

        if (productPrice <= 0)
        {
            return 0;
        }

        foreach (Discount d in product.Discounts)
        {
            discountTotal += d.get_Value(IncludeVAT, Discount.DiscountCalculationType.DiscountCalculationAmount, false);
        }

        switch (CalculateAs)
        {
            case Discount.DiscountCalculationType.DiscountCalculationAmount:
                return Dynamicweb.eCommerce.Common.Context.Currency.Round(discountTotal);

            case Discount.DiscountCalculationType.DiscountCalculationPercent:
                string tmp = Dynamicweb.eCommerce.Common.Context.Currency.Format((discountTotal / productPrice) * 100, false);
                double ret = 0;
                double.TryParse(tmp, out ret);
                return ret;

            default:
                return discountTotal/productPrice;
        }
    }
}
Requirements

Target Platforms: Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

See Also

Reference

Rounding Class
Rounding Members

Send Feedback