/// <summary>
 /// Gets the total price formatted.
 /// </summary>
 /// <param name="item">The item.</param>
 /// <returns></returns>
 protected string GetTotalPriceFormatted(LineItem item)
 {
     return(CurrencyFormatter.FormatCurrency(item.ListPrice * item.Quantity, OrderGroup.BillingCurrency));
 }
Пример #2
0
        /// <summary>
        /// When the row gets bound to its data, we need to do some things to present the data correctly
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void gvCart_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            //the footer row should only have two cells
            if (e.Row.RowType == DataControlRowType.Footer)
            {
                e.Row.Cells[0].Attributes["colspan"] = (e.Row.Cells.Count - 2).ToString();
                for (int i = 1; i < e.Row.Cells.Count - 2; i++)
                {
                    e.Row.Cells[i].Visible = false;
                }

                e.Row.Cells[e.Row.Cells.Count - 2].Text = CurrencyFormatter.FormatCurrency(NWTD.Orders.Cart.CartTotal(this.SelectedCartHelper.Cart), this.SelectedCartHelper.Cart.BillingCurrency);
            }


            if (e.Row.RowType == DataControlRowType.DataRow)
            {
                LineItem item = e.Row.DataItem as LineItem;

                TextBox tbGratis          = e.Row.FindControl("tbGratis") as TextBox;
                TextBox tbQuantityCharged = e.Row.FindControl("tbQuantityCharged") as TextBox;

                tbQuantityCharged.TabIndex = (short)((e.Row.RowIndex + 1) + e.Row.RowIndex);
                tbGratis.TabIndex          = (short)((e.Row.RowIndex + 2) + e.Row.RowIndex);

                tbGratis.Text          = item["Gratis"] == null? "0" : item["Gratis"].ToString();
                tbQuantityCharged.Text = item["Gratis"] == null?item.Quantity.ToString("n0") : (item.Quantity - (decimal)item["Gratis"]).ToString("n0");

                if (tbQuantityCharged.Text.IndexOf(',') > -1)
                {
                    tbQuantityCharged.Text = tbQuantityCharged.Text.Replace(",", string.Empty);
                }

                //can't do this cuz it overwrites the alternating style css class, unfortunately we'll do it in javascript
                //if (item.Quantity < 1) e.Row.CssClass = e.Row.CssClass + " nwtd-cartrow-zero-quanity";

                //get the entry from the lineitem
                Entry entry = CatalogContext.Current.GetCatalogEntry(item.CatalogEntryId);

                if (entry == null)
                {
                    return;                //if no entry was found, we need to abort, and leave the rest of the row empty
                }
                //handle the ISBN column
                Mediachase.Cms.Website.Structure.User.NWTDControls.Controls.Catalog.ISBN isbn = e.Row.FindControl("ISBN") as Mediachase.Cms.Website.Structure.User.NWTDControls.Controls.Catalog.ISBN;
                isbn.Entry = entry;

                //handle the year column
                String Year = string.Empty;
                if (entry.ItemAttributes["Year"] != null)
                {
                    Year = !string.IsNullOrEmpty(entry.ItemAttributes["Year"].ToString())? decimal.Parse(entry.ItemAttributes["Year"].ToString()).ToString("#") : String.Empty;
                }
                //we have to deal with the possibility of a null year.
                Literal litYear = e.Row.FindControl("litYear") as Literal;
                if (litYear != null)
                {
                    float year = 0f;
                    float.TryParse(entry.ItemAttributes["Year"].ToString(), out year);
                    if (year > 0)
                    {
                        litYear.Text = year.ToString("#");
                    }
                }

                //handle the grade column
                String  Grade    = entry.ItemAttributes["Grade"] != null ? entry.ItemAttributes["Grade"].ToString() : String.Empty;
                Literal litGrade = e.Row.FindControl("litGrade") as Literal;
                litGrade.Text = Grade;

                CheckBox cbItemSelected = e.Row.FindControl("cbItemSelected") as CheckBox;

                if (!NWTD.Orders.Cart.CartCanBeEdited(this.SelectedCartHelper.Cart))
                {
                    tbGratis.Enabled          = false;
                    tbQuantityCharged.Enabled = false;
                    cbItemSelected.Enabled    = false;
                }
            }
        }
Пример #3
0
        /// <summary>
        /// Handles the ItemDataBound event of the ShipmentList control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.Web.UI.WebControls.RepeaterItemEventArgs"/> instance containing the event data.</param>
        protected void ShipmentList_ItemDataBound(object sender, RepeaterItemEventArgs e)
        {
            if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
            {
                Shipment sh = e.Item.DataItem as Shipment;

                //decimal subtotal = 0;
                //decimal discount = 0;
                Label lblSubtotal = e.Item.FindControl("SubTotal") as Label;
                if (lblSubtotal != null)
                {
                    if (sh != null)
                    {
                        lblSubtotal.Text = GetShipmentSubtotal(sh);
                    }
                }

                Label shippingcost = e.Item.FindControl("ShippingCost") as Label;
                if (shippingcost != null)
                {
                    shippingcost.Text = CurrencyFormatter.FormatCurrency(sh.ShipmentTotal, Order.BillingCurrency); //(spi.ShippingCost.Amount + spi.Charge.Amount, spi.ShippingCost.CurrencyCode);
                }

                HyperLink trackingurl = e.Item.FindControl("TrackingUrl") as HyperLink;
                if (trackingurl != null && !String.IsNullOrEmpty(sh.ShipmentTrackingNumber))
                {
                    trackingurl.NavigateUrl = String.Format("http://www.google.com/search?q={0}", sh.ShipmentTrackingNumber);
                    trackingurl.Text        = RM.GetString("ACCOUNT_ORDER_SHIPMENT_TRACK");
                    trackingurl.Visible     = true;
                }

                Label taxes = e.Item.FindControl("Taxes") as Label;
                if (taxes != null)
                {
                    taxes.Text = CurrencyFormatter.FormatCurrency(0m, Order.BillingCurrency);
                }

                Label total = e.Item.FindControl("TotalCost") as Label;
                if (total != null)
                {
                    total.Text = GetShipmentTotal(sh);                     //Tax.Amount + spi.ShippingCost.Amount + spi.Charge.Amount + subtotal - spi.Discount.Amount, spi.ShippingCost.CurrencyCode);
                }

                // Print discount price

                /*Label discountLabel = e.Item.FindControl("ShipmentDiscount") as Label;
                 * if (discountLabel != null)
                 * {
                 *                      discountLabel.Text = "-" + CurrencyFormatter.FormatCurrency(sh.ShippingDiscountAmount, Order.BillingCurrency); //discount, spi.ShippingCost.CurrencyCode);
                 *  TableRow discountRow = e.Item.FindControl("ShipmentDiscount") as TableRow;
                 *  if (discountRow != null)
                 *  {
                 *      if (discount == 0)
                 *          discountRow.Visible = false;
                 *      else
                 *          discountRow.Visible = true;
                 *  }
                 * }*/

                // Print whole order shipment discount price
                Label discountShipmentLabel = e.Item.FindControl("lblTotalShipmentDiscount") as Label;
                if (discountShipmentLabel != null)
                {
                    discountShipmentLabel.Text = "-" + CurrencyFormatter.FormatCurrency(sh.ShippingDiscountAmount, Order.BillingCurrency);                     //ClientHelper.FormatCurrency(spi.Discount.Amount, spi.Discount.CurrencyCode);
                    TableRow discountRow = e.Item.FindControl("trTotalShipmentDiscount") as TableRow;
                    if (discountRow != null)
                    {
                        if (sh.ShippingDiscountAmount > 0)
                        {
                            discountRow.Visible = true;
                        }
                        else
                        {
                            discountRow.Visible = false;
                        }
                    }
                }

                GridView gv = (GridView)e.Item.FindControl("gvOrders");
                if (gv != null && gv.Columns.Count > 1)
                {
                    gv.Columns[0].HeaderText = RM.GetString("ACCOUNT_ORDER_SHIPMENT_ITEMS_ORDERED");
                    gv.Columns[1].HeaderText = RM.GetString("ACCOUNT_ORDER_SHIPMENT_PRICE");
                    gv.DataBind();
                }
            }
        }
Пример #4
0
        /// <summary>
        /// Binds the form.
        /// </summary>
        private void BindForm()
        {
            /*
             * WorkflowList.DataSource = WorkflowConfiguration.Instance.Workflows;
             * WorkflowList.DataBind();
             * */

            // Bind Status
            OrderStatusList.DataSource = OrderStatusManager.GetOrderStatus();
            OrderStatusList.DataBind();

            // Bind Currency
            OrderCurrencyList.DataSource = CatalogContext.Current.GetCurrencyDto();
            OrderCurrencyList.DataBind();

            OrderGroup order = _order;

            if (order != null)
            {
                LoadAddresses();

                ComboBoxItem item = CustomerName.Items.FindByValue(order.CustomerId.ToString());
                if (item != null)
                {
                    CustomerName.SelectedItem = item;
                }
                else
                {
                    ComboBoxItem newItem = new ComboBoxItem();
                    newItem.Text  = order.CustomerName;
                    newItem.Value = order.CustomerId.ToString();
                    CustomerName.Items.Add(newItem);
                    CustomerName.SelectedItem = newItem;
                }

                CustomerName.Text = order.CustomerName;
                //TrackingNo.Text = order.TrackingNumber;

                OrderSubTotal.Text      = CurrencyFormatter.FormatCurrency(order.SubTotal, order.BillingCurrency);
                OrderTaxTotal.Text      = CurrencyFormatter.FormatCurrency(order.TaxTotal, order.BillingCurrency);
                OrderShippingTotal.Text = CurrencyFormatter.FormatCurrency(order.ShippingTotal, order.BillingCurrency);
                OrderHandlingTotal.Text = CurrencyFormatter.FormatCurrency(order.HandlingTotal, order.BillingCurrency);

                OrderTotal.Text = CurrencyFormatter.FormatCurrency(order.Total, order.BillingCurrency);
                //OrderExpires.Value = order.ExpirationDate;

                if (_order.OrderForms.Count > 0)
                {
                    if (AddressesList.Items.Count > 0)
                    {
                        ManagementHelper.SelectListItem(AddressesList, _order.OrderForms[0].BillingAddressId);
                    }
                    DiscountTotal.Text = CurrencyFormatter.FormatCurrency(order.OrderForms[0].DiscountAmount, order.BillingCurrency);
                }

                ManagementHelper.SelectListItem(OrderStatusList, order.Status);
                ManagementHelper.SelectListItem(OrderCurrencyList, order.BillingCurrency);

                /*
                 * if (po.Status == OrderConfiguration.Instance.NewOrderStatus)
                 * {
                 *      WorkflowDisabledDescription.Visible = false;
                 *      RunWorkflowButton.Enabled = true;
                 * }
                 * else
                 * {
                 *      RunWorkflowButton.Enabled = false;
                 *      WorkflowDisabledDescription.Visible = true;
                 *      WorkflowDisabledDescription.Text = String.Format("Can only run workflow for orders with \"{0}\" status", OrderConfiguration.Instance.NewOrderStatus);
                 * }
                 * */
            }
            else
            {
                ManagementHelper.SelectListItem(OrderCurrencyList, CommonSettingsManager.GetDefaultCurrency());
            }
        }