Listing P
Public Class ViewCustomerOrders
    Inherits System.Web.UI.Page
    Protected WithEvents Label1 As System.Web.UI.WebControls.Label
 
 
#Region " Web Form Designer Generated Code "
 
 
    'This call is required by the Web Form Designer.
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
 
 
    End Sub
 
 
    Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init
        'CODEGEN: This method call is required by the Web Form Designer
        'Do not modify it using the code editor.
        InitializeComponent()
    End Sub
 
 
#End Region
 
 
    Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
 
 
        If Not Page.IsPostBack Then
            Dim SessionObj As ClientSession = Session.Item(ClientSession.CLIENT_SESSION_REF)
 
 
           'placeholders for dynamic controls
            Dim Lbl As Label
            Dim Dg As DataGrid
            Dim Column As BoundColumn
 
 
            ' Grab the pending orders for the customer and display a summary in the label
            Dim OrderObj As New OrderServices()
            Dim OrderDs As DataSet = OrderObj.GetOrdersByCustomer(SessionObj.CustomerId, OrderDb.ORDER_STATUS_PENDING)
            Dim Dr As DataRow
 
 
            If Not OrderDs.Tables(0) Is Nothing Then
                For Each Dr In OrderDs.Tables(0).Rows
                    Lbl = New Label()
                    Lbl.CssClass = "ASP_TEXT"
                    Lbl.Text = "Order placed on: " + Dr.Item(OrderDb.FIELD_CREATION_DATE)
 
 
                    Dg = New DataGrid()
                   Dg.AutoGenerateColumns = False
                    Dg.CssClass = "DG_DEFAULT"
                    Dg.HeaderStyle.CssClass = "DG_HEADER"
 
 
                    Column = New BoundColumn()
                    Column.DataField = JohnDb.BookDb.FIELD_BOOK_NAME
                    Column.HeaderText = "Book Name"
                    Dg.Columns.Add(Column)
 
 
                    Column = New BoundColumn()
                    Column.DataField = JohnDb.BookDb.FIELD_AUTHOR
                    Column.HeaderText = "Author"
                    Dg.Columns.Add(Column)
 
 
                    Dim OrderProxy As New OrderProxy.OrderWS()
                    OrderProxy.OrderSecurityContextValue = WSUtil.GetOrderSecurityContext
                    Dim OrderDetailsDs As DataSet = OrderProxy.GetOrders(Dr.Item(OrderDb.FIELD_ORDER_ID), Nothing, Nothing)
                    Dg.DataSource = OrderDetailsDs
 
 
                    Me.Controls.Add(Lbl)
                    Me.Controls.Add(Dg)
                    Me.Controls.Add(New HtmlGenericControl("BR"))
                Next
            End If
 
 
            ' Insert the label for completed orders
            Lbl = New Label()
            Lbl.Text = "Orders placed that have been shipped:"
            Lbl.CssClass = "TITLE"
            Me.Controls.Add(New HtmlGenericControl("BR"))
            Me.Controls.Add(Lbl)
            Me.Controls.Add(New HtmlGenericControl("BR"))
 
 
            ' Now grab the completed orders and repeat as above
            OrderDs = OrderObj.GetOrdersByCustomer(SessionObj.CustomerId, OrderDb.ORDER_STATUS_COMPLETE)
 
 
            If Not OrderDs.Tables(0) Is Nothing Then
                For Each Dr In OrderDs.Tables(0).Rows
                    Lbl = New Label()
                    Lbl.CssClass = "ASP_TEXT"
                   Lbl.Text = "Order placed on: " + Dr.Item(OrderDb.FIELD_CREATION_DATE)
 
 
                    Dg = New DataGrid()
                    Dg.AutoGenerateColumns = False
                    Dg.CssClass = "DG_DEFAULT"
                    Dg.HeaderStyle.CssClass = "DG_HEADER"
 
 
                    Column = New BoundColumn()
                    Column.DataField = JohnDb.BookDb.FIELD_BOOK_NAME
                    Column.HeaderText = "Book Name"
                    Dg.Columns.Add(Column)
 
 
                    Column = New BoundColumn()
                    Column.DataField = JohnDb.BookDb.FIELD_AUTHOR
                    Column.HeaderText = "Author"
                    Dg.Columns.Add(Column)
 
 
                    Dim OrderProxy As New OrderProxy.OrderWS()
                   OrderProxy.OrderSecurityContextValue = WSUtil.GetOrderSecurityContext
                    Dim OrderDetailsDs As DataSet = OrderProxy.GetOrders(Dr.Item(OrderDb.FIELD_ORDER_ID), Nothing, Nothing)
                    Dg.DataSource = OrderDetailsDs
 
 
                   Me.Controls.Add(Lbl)
                    Me.Controls.Add(Dg)
                    Me.Controls.Add(New HtmlGenericControl("BR"))
                Next
 
 
            End If
 
 
            Me.DataBind()
        End If
 
 
    End Sub
 
 
End Class