示例#1
0
        private void SizeButt_Click(object sender, RoutedEventArgs e)
        {
            IItem local = (Tag as IItem);

            if (local.IsPieDish)
            {
                PieItem p = ((PieItem)local);
                switch (p.Size)
                {
                case PieItem.PieSize.Whole:
                    p.Size = PieItem.PieSize.Half;
                    break;

                case PieItem.PieSize.Half:
                    p.Size = PieItem.PieSize.Quarter;
                    break;

                case PieItem.PieSize.Quarter:
                    p.Size = PieItem.PieSize.Whole;
                    break;
                }
                Content = p.SizeString;
            }

            if (local.IsSizeDish)
            {
                SizeItem item = ((SizeItem)local);
                if (item.IsLarge)
                {
                    item.IsLarge = false;
                }
                else
                {
                    item.IsLarge = true;
                }
                Content = item.EnglishSizeString;
            }
        }
        public static void LoadItems()
        {
            totalItems = new List <IItem>();
            int[] columnsString = new int[2] {
                0, 1
            };
            int[] columnNumber = new int[1] {
                2
            };
            string[,] output = ExcelReader_NPOI.ReadAllXLSX("FoodItems.xlsx", columnsString, columnNumber, true);
            XSSFWorkbook footItemsBook = ExcelReader_NPOI.OpenXLSX("FoodItems.xlsx", true);

            for (int i = 0; i < output.GetLength(0); i++)
            {
                float price = float.Parse(output[i, 2]);
                if (price == -1)
                {
                    float    smallPrice = float.Parse(ExcelReader_NPOI.ReadSingleXLSXFromWorkBook(footItemsBook, i, 3, true));
                    float    largePrice = float.Parse(ExcelReader_NPOI.ReadSingleXLSXFromWorkBook(footItemsBook, i, 4, true));
                    SizeItem item       = new SizeItem(output[i, 0], output[i, 1], i + 1, smallPrice, largePrice);
                    totalItems.Add(item);
                }
                else if (price == -2)
                {
                    float   wholePrice   = float.Parse(ExcelReader_NPOI.ReadSingleXLSXFromWorkBook(footItemsBook, i, 3, true));
                    float   halfPrice    = float.Parse(ExcelReader_NPOI.ReadSingleXLSXFromWorkBook(footItemsBook, i, 4, true));
                    float   quarterPrice = float.Parse(ExcelReader_NPOI.ReadSingleXLSXFromWorkBook(footItemsBook, i, 5, true));
                    PieItem item         = new PieItem(output[i, 0], output[i, 1], i + 1, wholePrice, halfPrice, quarterPrice);
                    //Console.WriteLine("seabass");
                    totalItems.Add(item);
                }
                else
                {
                    Item item = new Item(output[i, 0], output[i, 1], i + 1, price);
                    totalItems.Add(item);
                }
            }
        }