// An Overload for class constructor
        public FoodItemSummary(CategorizedFood Summary)
        {
            InitializeComponent();

            // Keeping for further use
            categorized = Summary;

            // Showing the summary inside the text box
            TxtSummary.Text = Summary.ToString();
        }
Пример #2
0
        private void BtnInventory_Click(object sender, RoutedEventArgs e)
        {
            // Creating an instance of data context
            ofosDataContext dc = new ofosDataContext();
            // an instance of categorized food to generate a summary
            CategorizedFood categorize = new CategorizedFood();

            // Adding each item to category summary (it keeps distinct values and total only)
            foreach (FoodItem item in dc.FoodItems)
            {
                categorize.Add(new FoodCategory()
                {
                    CategoryName = item.FoodItemCategory, Amount = (int)item.FoodItemAvailable
                });
            }

            FoodItemSummary fis = new FoodItemSummary(categorize);

            fis.ShowDialog();
        }