// populate the form with data
    private void PopulateControls()
    {
        // obtain order ID from the session
        string orderId = Session["AdminOrderID"].ToString();
        // obtain order info
        OrderInfo orderInfo = OrdersAccess.GetInfo(orderId);

        // populate labels and text boxes with order info
        orderIdLabel.Text           = "Displaying Order #" + orderId;
        totalAmountLabel.Text       = String.Format("{0:c}", orderInfo.TotalAmount);
        dateCreatedTextBox.Text     = orderInfo.DateCreated;
        dateShippedTextBox.Text     = orderInfo.DateShipped;
        verifiedCheck.Checked       = orderInfo.Verified;
        completedCheck.Checked      = orderInfo.Completed;
        canceledCheck.Checked       = orderInfo.Canceled;
        commentsTextBox.Text        = orderInfo.Comments;
        customerNameTextBox.Text    = orderInfo.CustomerName;
        shippingAddressTextBox.Text = orderInfo.ShippingAddress;
        customerEmailTextBox.Text   = orderInfo.CustomerEmail;
        // by default the Edit button is enabled, and the
        // Update and Cancel buttons are disabled
        editButton.Enabled   = true;
        updateButton.Enabled = false;
        cancelButton.Enabled = false;
        // Decide which one of the other three buttons
        // should be enabled and which should be disabled
        if (canceledCheck.Checked || completedCheck.Checked)
        {
            // if the order was canceled or completed ...
            markVerifiedButton.Enabled  = false;
            markCompletedButton.Enabled = false;
            markCanceledButton.Enabled  = false;
        }
        else if (verifiedCheck.Checked)
        {
            // if the order was not canceled but is verified ...
            markVerifiedButton.Enabled  = false;
            markCompletedButton.Enabled = true;
            markCanceledButton.Enabled  = true;
        }
        else
        {
            // if the order was not canceled and is not verified ...
            markVerifiedButton.Enabled  = true;
            markCompletedButton.Enabled = false;
            markCanceledButton.Enabled  = true;
        }
        // fill the data grid with order details
        grid.DataSource = OrdersAccess.GetDetails(orderId);
        grid.DataBind();
    }
Ejemplo n.º 2
0
    GetOrderDetails(string orderId)
    {
        // use existing method for DataTable
        DataTable orderDetailsData = OrdersAccess.GetDetails(orderId);
        // create List<>
        List <CommerceLibOrderDetailInfo> orderDetails =
            new List <CommerceLibOrderDetailInfo>(
                orderDetailsData.Rows.Count);

        foreach (DataRow orderDetail in orderDetailsData.Rows)
        {
            orderDetails.Add(
                new CommerceLibOrderDetailInfo(orderDetail));
        }
        return(orderDetails);
    }