Dynamicweb 8 Documentation
FormatOperator Field
Example 

Plus or Minus.
Syntax
'Declaration
 
Public Shared ReadOnly FormatOperator As String()
public static readonly string[] FormatOperator
Example
class MyPage : System.Web.UI.Page
{
   public int UpdateStock(Dynamicweb.eCommerce.Orders.Order order, Dynamicweb.eCommerce.Products.Product.OrderStockOperator _Operator)
   {
       Dynamicweb.eCommerce.Products.Product product = new Product();
       string SQL = string.Empty;
       int updateCount = 0;

       foreach (Dynamicweb.eCommerce.Orders.OrderLine orderLine in order.OrderLines)
       {
           if (!(orderLine.Product.Type == ProductType.Service))
           {
               Dynamicweb.eCommerce.Stocks.StockStatus oldStockStatus = orderLine.Product.get_StockStatus(orderLine.Product.LanguageID);

               if (!string.IsNullOrEmpty(orderLine.UnitID))
               {
                   if (UnitExists(orderLine.UnitID))
                   {
                       SQL = "UPDATE EcomStockUnit SET StockUnitQuantity = StockUnitQuantity " + Dynamicweb.eCommerce.Products.Product.FormatOperator[(int)_Operator] + " " + orderLine.Quantity + " ";
                       SQL += "WHERE StockUnitProductID = '" + orderLine.ProductID + "' AND StockUnitID = '" + orderLine.UnitID + "' ";
                       if (!string.IsNullOrEmpty(orderLine.ProductVariantID))
                       {
                           SQL += "AND StockUnitVariantID = '" + orderLine.ProductVariantID + "' ";
                       }
                   }
                   else { continue; }
               }
               else { continue; }

               if (Database.ExecuteNonQuery(SQL, "Ecom.mdb") > 0)
               {
                   updateCount += 1;
               }
           }
       }

       return updateCount;
   }

   public static bool UnitExists(string unitId)
   {
       foreach (Dynamicweb.eCommerce.Variants.VariantOption u in Dynamicweb.eCommerce.Common.Context.Units)
       {
           if (u.ID == unitId)
           {
               return true;
           }
       }

       return false;
   }
}
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

Product Class
Product Members

Send Feedback