Esempio n. 1
0
        private string GetStatistic()
        {
            decimal sum_quantity = 0;
            decimal sum_amount   = 0;
            decimal to_pay       = 0;
            int     sum_noPrice  = 0;

            foreach (ShoppingListView view in this.liste)
            {
                ShoppingItemListResult shoppingItem = view.ShoppingItem;

                sum_quantity += shoppingItem.Quantity;
                if (shoppingItem.Price != null)
                {
                    sum_amount += shoppingItem.Quantity * shoppingItem.Price.Value;

                    if (shoppingItem.Bought)
                    {
                        to_pay += shoppingItem.Quantity * shoppingItem.Price.Value;
                    }
                }
                else
                {
                    sum_noPrice++;
                }
            }

            string status;

            if (this.liste.Count == 1)
            {
                status = string.Format("{0:n0} Position", this.liste.Count);
            }
            else
            {
                status = string.Format("{0:n0} Positionen", this.liste.Count);
            }

            if (sum_quantity > 0)
            {
                status += string.Format(", Anzahl {0:n0}", sum_quantity);
            }
            if (sum_amount > 0)
            {
                status += string.Format(", Betrag {0:n2} €", sum_amount);
            }
            if (sum_noPrice > 0)
            {
                status += string.Format(", {0:n0} Artikel ohne Preisangabe", sum_noPrice);
            }
            if (to_pay > 0)
            {
                status += string.Format("\nZu zahlen: {0:n2} €", to_pay);
            }

            return(status);
        }
 public ShoppingListView(ShoppingItemListResult article)
 {
     this.ShoppingItem = article;
 }