예제 #1
0
        //  ДОБАВИТЬ ТОВАР  //
        static void AddGoodMenu()
        {
            SectionGoods section = mainMarket.AllExistSections[currentSection];

            Console.WriteLine("\nВведите номер позиции товара: ");
            int    position, realPosition;
            double price;

            while (!int.TryParse(Console.ReadLine(), out position))
            {
                ClearConsoleLines(2);
                Console.WriteLine("Неверное значение. Введите порядковый номер позиции, в которую нужно вставить товар.");
            }
            realPosition = section.AddGoodAtPosition(position);
            Console.WriteLine("Введите название товара: ");
            section.GetElementByPosition(realPosition).Name = Console.ReadLine();
            Console.WriteLine("Введите цену товара: ");
            while (!double.TryParse(Console.ReadLine(), out price) && price >= 0)
            {
                ClearConsoleLines(2);
                Console.WriteLine("Неверное значение. Введите положительное число.");
            }
            section.GetElementByPosition(realPosition).Price = price;
            ClearConsoleLines(6);
            //Console.ForegroundColor = ConsoleColor.Red;
            //Console.WriteLine("Список заполнен. Нет свободного места для добавления секции.");
            //Console.ForegroundColor = ConsoleColor.White;
        }
예제 #2
0
        public void Deserialize()
        {
            string        path = @"C:\Users\Mollusc\source\repos\MarketGoodsManager\MarketGoodsManager\bin\Debug\netcoreapp2.1\good.xml";
            XmlSerializer ser  = new XmlSerializer(typeof(SectionGoods));

            using (FileStream st = new FileStream(path, FileMode.Open))
            {
                SectionGoods goods = new SectionGoods();
                //this.Name = "";
                //this.Count = 0;
                //this.AllElements;
                //this.Clear();
                goods = (SectionGoods)ser.Deserialize(st);
                //this.Clear();
                this.Count       = goods.Count;
                this.Name        = goods.Name;
                this.AllElements = goods.AllElements;
                //if (goods.AllElements.Length > 0)
                //{
                //    for (int i = 0; i < goods.AllElements.Length; i++)
                //    {
                //        AddGoodAtPosition(i + 1);
                //        GetElementByPosition(i + 1).Name = goods.AllElements[i].Name;
                //        GetElementByPosition(i + 1).Price = goods.AllElements[i].Price;
                //    }
                //}
                //GetElementByPosition(2).Name = "WOW 2";
            }
        }
예제 #3
0
        //Функции для работы со списком
        private int AddInQueue(SectionGoods section)
        {
            if (IsQueueFull())
            {
                return(-1);
            }
            else
            {
                if (IsQueueEmpty())
                {
                    front = rear = 0;
                }
                else
                {
                    rear++;
                }

                sectionsQueue[rear] = section;
                sectionAmount++;
                return(rear);
            }
        }