Share via


OrderFormCollection.Add (OrderForm) Method (BCL)

Use this method to add the specified order form to the collection.

Definition

[Visual Basic .NET]

Public Sub Add( _ByValorderForm As OrderForm _
) 

[C#]

public void Add(OrderFormorderForm);

Parameters

[Visual Basic .NET]

  • orderForm
    The OrderForm class instance to add to the collection.

[C#]

  • orderForm
    The OrderForm class instance to add to the collection.

Remarks

This method internally invokes the AddItem method on the underlying OrderGroup COM interop object.

If you have two OrderGroup objects, OrderGroup1 and OrderGroup2, then you retrieve OrderForm1 from OrderGroup1. Then you call OrderGroup2.OrderForms.Add(OrderForm1), then OrderForm1 is cloned and copied to OrderGroup2. OrderForm1 is now modified to point to the copied instance in OrderGroup2.

Example

using Microsoft.CommerceServer.Runtime;
using Microsoft.CommerceServer.Runtime.Orders;

private OrderGroup CreateBasket()
{
   CommerceContext csContext = CommerceContext.Current;
   
   // Get the user's user Id
   //Guid userID = new Guid(csContext.UserID);         
   // For this sample, we'll generate a new Unique UserID:
   Guid userID = Guid.NewGuid();
   
   // GetBasket() will load a user's existing basket, if it exists,
   // otherwise it will create a new, empty basket
   Basket basket = csContext.OrderSystem.GetBasket(userID);
   
   // If this is a new basket, then create a default OrderForm
   if (basket.OrderForms.Count < 1)
      basket.OrderForms.Add(new OrderForm("default"));

   return basket;
}

Requirements

Namespace: Microsoft.CommerceServer.Runtime.Orders

Platforms: Windows 2000, Windows Server 2003

Assembly: Microsoft.CommerceServer.Runtime.dll

Copyright © 2005 Microsoft Corporation.
All rights reserved.