Пример #1
0
        /// <summary>
        /// Overide the ToString() method;
        /// To generate the details(Receipt) of this order;
        /// </summary>
        /// <returns>A string description for this order</returns>
        public override string ToString()
        {
            StringBuilder sb = new StringBuilder();

            // Order Number
            sb.AppendLine("订单编号: " + OrderNumber);
            sb.AppendLine();

            // Order items
            foreach (OrderItem item in CartItemList)
            {
                sb.AppendLine(item.ToString());
            }
            sb.AppendLine();

            // Price, tax and discount for the order
            sb.AppendLine("价格: " + NetPrice.ToString("C2", CultureInfo.CreateSpecificCulture("en-NZ")));
            sb.AppendLine("邮费: " + TaxPrice.ToString("C2", CultureInfo.CreateSpecificCulture("en-NZ")));
            sb.AppendLine("折扣: -" + DiscountedTotalPrice.ToString("C2", CultureInfo.CreateSpecificCulture("en-NZ")));
            sb.AppendLine("总计价格: " + TotalPrice.ToString("C2", CultureInfo.CreateSpecificCulture("en-NZ")));

            return(sb.ToString());
        }
Пример #2
0
        /// <summary>
        /// Override the ToString() method;
        /// To generate an item string description
        /// </summary>
        /// <returns>An string description of the item</returns>
        public override string ToString()
        {
            string unitPriceAndQuantity = UnitPrice.ToString("C2", CultureInfo.CreateSpecificCulture("en-NZ")) + "*" + Quantity;
            string discount             = IsDiscountApplied ? ("Dis.:" + DiscountPercentage + "%\t-" + DiscountedTotalPrice.ToString("C2", CultureInfo.CreateSpecificCulture("en-NZ"))) : null;
            string totalPrice           = TotalPrice.ToString("C2", CultureInfo.CreateSpecificCulture("en-NZ"));

            return(Name + "\n" + unitPriceAndQuantity + "\t" + totalPrice + "\t" + discount);
        }