Exemplo n.º 1
0
        static void PrintBase()
        {
            Console.Clear();
            List <string> lstType   = AlcoholBase.GetAlcoholTypesLst();
            int           countType = 1;


            foreach (var m in lstType)
            {
                Console.WriteLine($"{countType} {m}");
                var  alcohol    = AlcoholBase.GetAlcoholItemsByTypesArr(m);
                int  countItems = 1;
                uint sum        = 0;
                if (alcohol.Length != 0)
                {
                    sum = 0;
                    foreach (var bottle in alcohol)
                    {
                        Console.WriteLine($"  {countItems} {AlcoholBase.GetItemStr(bottle)}");
                        sum += bottle.PrisePosition;
                        countItems++;
                    }
                    Console.WriteLine($"\nОбщая сумма позиций:{sum}");
                }
                else
                {
                    Console.WriteLine("  Нет товара.");
                }
                Console.WriteLine();
                countType++;
            }
            Console.WriteLine("\n\n\nНажмите любую кнопку для возврата назад.");
            Console.ReadKey();
        }
Exemplo n.º 2
0
        static void addNewPosition()
        {
            Console.Clear();
            bool          success    = false;
            int           selectType = 0;
            List <string> alcoholTypes;

            do
            {
                alcoholTypes = AlcoholBase.GetAlcoholTypesLst();
                for (int i = 0; i < alcoholTypes.Count; i++)
                {
                    alcoholTypes[i] = $"{alcoholTypes[i]} ({AlcoholBase.GetQuantityBottleInTypes(alcoholTypes[i])})";
                }
                alcoholTypes.Add("Другой тип.");
                alcoholTypes.Add("Назад.");
                selectType = Menu("Добавление\nВыберите вид", alcoholTypes);
                if (selectType == alcoholTypes.Count)
                {
                    success = true;
                }
                else if (selectType == alcoholTypes.Count - 1)
                {
                    AlcoholBase.AddNewPosition(newBotlle());
                    Console.WriteLine($"Успешно добавлено.");
                    addRunMenu(ref success, "Добавить ещё");
                }
                else
                {
                    AlcoholBase.AddNewPosition(newBotlle(AlcoholBase.GetAlcoholTypesLst().ToArray()[selectType - 1]));
                    Console.WriteLine($"Успешно добавлено.");
                    addRunMenu(ref success, "Добавить ещё");
                }
            } while (!success);
        }
Exemplo n.º 3
0
 public ActionResult EditPosition(EditValue editValue)
 {
     if (ModelState.IsValid)
     {
         AlcoholBase.EditPosition(editValue.Types, (int)editValue.Pos, (uint)editValue.Quantity, (uint)editValue.Prise);
     }
     return(Redirect($"/Home/ByTypes?types={editValue.Types}"));
 }
Exemplo n.º 4
0
 public ActionResult ByTypes(string types)
 {
     ViewBag.types      = types;
     ViewData["ArrPos"] = AlcoholBase.GetAlcoholItemsByTypesArr(types);
     return(View(new BottleModel()
     {
         Types = types
     }));
 }
Exemplo n.º 5
0
 public ActionResult NewPosition(BottleModel bottleModel)
 {
     if (ModelState.IsValid)
     {
         AlcoholBase.AddNewPosition(new AlcoholBottle(bottleModel.Types, bottleModel.Name, bottleModel.Manufacturer, (double)bottleModel.AbvPercent,
                                                      (uint)bottleModel.KCal, (uint)bottleModel.Volume, (uint)bottleModel.Quantity, (uint)bottleModel.Prise));
         return(Redirect($"/Home/ByTypes?types={bottleModel.Types}"));
     }
     else
     {
         return(View(bottleModel));
     }
 }
Exemplo n.º 6
0
        static void addNewTypesAlcohol()
        {
            string typesAlc;
            bool   success = false;

            do
            {
                Console.Clear();
                Console.Write("Укажите новый вид алкоголя: ");
                typesAlc = Console.ReadLine();
                success  = AlcoholBase.newAlcoholTypes(typesAlc);
                if (success)
                {
                    Console.WriteLine("Новый вид успешно добавлен.");
                }
                else
                {
                    Console.WriteLine("Такой вид уже есть.");
                }
                addRunMenu(ref success, "Добавить ещё");
            } while (!success);
        }
Exemplo n.º 7
0
        static void EditPosition()
        {
            Console.Clear();
            bool          exit       = false;
            int           selectType = 0;
            List <string> alcoholTypes;
            string        types;
            uint          newQuantity = 0;
            uint          newPrice    = 0;

            do
            {
                alcoholTypes = AlcoholBase.GetAlcoholTypesLst();
                for (int i = 0; i < alcoholTypes.Count; i++)
                {
                    alcoholTypes[i] = $"{alcoholTypes[i]} ({AlcoholBase.GetQuantityBottleInTypes(alcoholTypes[i])})";
                }
                alcoholTypes.Add("Назад.");
                selectType = Menu("Редактирование\nВыберите вид", alcoholTypes);
                if (selectType == alcoholTypes.Count)
                {
                    exit = true;
                }
                else
                {
                    types = AlcoholBase.GetAlcoholTypesLst()[selectType - 1];
                    var items = AlcoholBase.GetAlcoholItemsByTypesArr(types);
                    alcoholTypes.Clear();
                    if (items.Length != 0)
                    {
                        foreach (var bottle in items)
                        {
                            alcoholTypes.Add(AlcoholBase.GetItemStr(bottle));
                        }
                        alcoholTypes.Add("Назад.");
                        selectType = Menu("Выберите ", alcoholTypes);
                        Console.Clear();
                        Console.WriteLine(AlcoholBase.GetItemStr(items[selectType - 1]));
                        Console.Write("Введите новое количество:");
                        while (!uint.TryParse(Console.ReadLine(), out newQuantity))
                        {
                            ClearLine(1);
                            Console.Write("Введите новое количество:");
                        }
                        Console.Write("Введите новую цену:");
                        while (!uint.TryParse(Console.ReadLine(), out newPrice))
                        {
                            ClearLine(1);
                            Console.Write("Введите новую цену:");
                        }

                        items[selectType - 1].NewPrise(newPrice);
                        items[selectType - 1].NewValueQuantity(newQuantity);
                        addRunMenu(ref exit, "Другой выбор");
                        //AlcoholBase.EditPosition(types,selectType, newQuantity, newPrice);
                    }
                    else
                    {
                        Console.Clear();
                        Console.WriteLine($"Список пуст");
                        addRunMenu(ref exit, "Другой выбор");
                    }
                }
            } while (!exit);
        }
Exemplo n.º 8
0
        static void delPosition()
        {
            Console.Clear();
            bool          success    = false;
            int           selectType = 0;
            List <string> alcoholTypes;
            string        types;

            do
            {
                alcoholTypes = AlcoholBase.GetAlcoholTypesLst();
                for (int i = 0; i < alcoholTypes.Count; i++)
                {
                    alcoholTypes[i] = $"{alcoholTypes[i]} ({AlcoholBase.GetQuantityBottleInTypes(alcoholTypes[i])})";
                }
                alcoholTypes.Add("Назад.");
                selectType = Menu("Удаление\nВыберите вид", alcoholTypes);
                if (selectType == alcoholTypes.Count)
                {
                    success = true;
                }
                else
                {
                    types = AlcoholBase.GetAlcoholTypesLst()[selectType - 1];
                    var items = AlcoholBase.GetAlcoholItemsByTypesArr(types);
                    alcoholTypes.Clear();
                    if (items.Length != 0)
                    {
                        foreach (var bottle in items)
                        {
                            alcoholTypes.Add(AlcoholBase.GetItemStr(bottle));
                        }
                        alcoholTypes.Add("Удалить все.");
                        alcoholTypes.Add("Назад.");
                        selectType = Menu("Выберите ", alcoholTypes);
                        if (selectType < alcoholTypes.Count - 1)
                        {
                            Console.WriteLine();
                            addRunMenu(ref success, "Вы уверены?");
                            if (!success)
                            {
                                ClearLine(1);
                                if (AlcoholBase.RemoveAlcohoBottleinBase(types, items[selectType - 1]))
                                {
                                    Console.WriteLine($"Успешно удалено.");
                                }
                                else
                                {
                                    Console.WriteLine($"Удалить не удалось.");
                                }
                            }
                            addRunMenu(ref success, "Удалить ещё");
                        }
                        else if (selectType == alcoholTypes.Count - 1)
                        {
                            Console.WriteLine();
                            addRunMenu(ref success, "Вы уверены?");
                            if (!success)
                            {
                                ClearLine(1);
                                if (AlcoholBase.RemoveAlcohoBottleAll(types))
                                {
                                    Console.WriteLine($"Успешно удалено.");
                                }
                                else
                                {
                                    Console.WriteLine($"Удалить не удалось.");
                                }
                            }
                            addRunMenu(ref success, "Удалить ещё");
                        }
                    }
                    else
                    {
                        Console.Clear();
                        Console.WriteLine($"Список пуст");
                        addRunMenu(ref success, "Другой выбор");
                    }
                }
            } while (!success);
        }
Exemplo n.º 9
0
 public ActionResult DelAllPositioninTypes(string types)
 {
     AlcoholBase.RemoveAlcohoBottleAll(types);
     return(Redirect($"/Home/ByTypes?types={types}"));
 }
Exemplo n.º 10
0
 public ActionResult Delposition(string types, uint possition)
 {
     AlcoholBase.RemoveAlcohoBottleinBase(types, possition);
     return(Redirect($"/Home/ByTypes?types={types}"));
 }