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); }
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(); }
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); }
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); }