Пример #1
0
        private void SetupOrderForEditing(IList <CustomerOrderItem> orderItems)
        {
            // Bind the ListView
            OrderItemsListView.DataSource = orderItems;
            OrderItemsListView.DataBind();

            // Calculate the Totals
            decimal total    = 0;
            decimal totalRaw = 0;

            foreach (var item in orderItems)
            {
                totalRaw += (item.Quantity * item.UnitPrice);
                total    += (item.Quantity * item.UnitPrice) - (item.Quantity * item.UnitPrice) * (Convert.ToDecimal(item.DiscountPercent));
            }
            decimal freight;

            decimal.TryParse(EditFreight.Text, NumberStyles.Currency, CultureInfo.CurrentCulture, out freight);
            decimal totalWithFreight = total + freight;

            // Display the totals
            OrderTotal.Text           = totalWithFreight.ToString("C");
            TotalExtendedLabel.Text   = totalRaw.ToString("C");
            TotalDiscountedLabel.Text = total.ToString("C");

            // Setup the ListView's Products (InsertTemplate)
            var controller = new SalesController();
            var products   = controller.GetProducts();
            var dropDown   = OrderItemsListView.InsertItem.FindControl("AvailableProducts") as DropDownList;

            dropDown.DataSource     = FilteredProductList(orderItems);
            dropDown.DataTextField  = "Text";
            dropDown.DataValueField = "Key";
            dropDown.DataBind();
            dropDown.Items.Insert(0, "[select a product]");
            ResetInsertItemDefaultValues(dropDown, 0, 0, 0);
        }
Пример #2
0
 protected void OrderItemsListView_LayoutCreated(object sender, EventArgs e)
 {
     TotalExtendedLabel   = OrderItemsListView.FindControl("TotalExtended") as Label;
     TotalDiscountedLabel = OrderItemsListView.FindControl("TotalDiscounted") as Label;
 }